@syncfusion/ej2-calculate 35.1.37 → 35.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * filename: ej2-calculate.min.js
3
- * version : 35.1.37
3
+ * version : 35.1.39
4
4
  * Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
5
5
  * Use of this code is subject to the terms of our license.
6
6
  * A copy of the current license can be obtained at any time by e-mailing
7
7
  * licensing@syncfusion.com. Any infringement will be prosecuted under
8
8
  * applicable laws.
9
9
  */
10
- this.ej=this.ej||{},this.ej.calculate=function(r,t){"use strict";function e(r){return void 0===r}function n(r){switch(r){case"dd-MMM-yyyy":case"dd MMM yyyy":r="medium";break;case"MMM yyyy":r="yMMM";break;case"MM/dd/yyyy":case"dd/MM/yyyy":case"dd/MM/yy":r="short";break;case"dddd MMMM dd yyyy":case"dd MMMM yyyy":r="long";break;case"d MMMM yyyy":r="yMMMd";break;case"yyyy":r="y";break;case"h:mm":r="Hm";break;case"h:mm tt":r="hm";break;case"h":r="H";break;case"h tt":r="h";break;case"h:mm:ss tt":r="hms";break;case"h:mm:ss":r="Hms";break;case"d":r="d";break;case"d dddd":r="Ed";break;case"M":r="M";break;case"Md":r="Md";break;case"MMM":r="MMM";break;case"ddd MMM d":r="MMMEd";break;case"MMM d":r="MMMd";break;case"M/yyyy":r="yM";break;case"ddd":r="E";break;default:r=""}return r}function i(t){var e=!1;for(var n in r.ExcelFileFormats)if(t.indexOf("."+n+"]")>-1){e=!0;break}return e}function o(r){return"[object Date]"===Object.prototype.toString.call(r)&&!isNaN(r.valueOf())}function s(r){return r-parseFloat(r)>=0}function a(r,t,e){var n=new Date("01/01/1900"),i=o(r)?r:new Date(r),s=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),a=(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())-s)/864e5;return(t?a:parseInt(a.toString(),10))+(e?0:a>60?2:1)}function u(r){return r.charCodeAt(0)>=65&&r.charCodeAt(0)<=90||r.charCodeAt(0)>=97&&r.charCodeAt(0)<=122}function l(r){var t=0,e=0;if(r=r.toUpperCase(),t<r.length&&"!"===r[t]){for(t++;t<r.length&&"!"!==r[t];)t++;t++}for(;t<r.length&&u(r[t]);)e=26*e+r[t].charCodeAt(0)-64,t++;return 0===e?-1:e}function h(r){for(var t=r,e=0,n=t.length,i=0;i<n;i++)u(t[i])&&e++;var o=t.substring(0,e),s=o.length;if(s!==n&&s<4&&1!==n&&isNaN(parseInt(t,10))){var a=l(o);if(a<1||a>16384)return!1;var h=t.substring(e,n);if(h.length>0){for(var p=!0,g=0;g<h.length;g++){var f=h.charCodeAt(g);if(f<48||f>57){p=!1;break}}if(p){var m=parseFloat(h);if(m>0&&m<1048577)return!0}}}return!1}function p(r){var t=r;if((t=t.split("$").join("")).indexOf(":")>-1){var e=t.split(":");if(h(e[0])&&h(e[1]))return!0}else if(t.indexOf(":")<0&&h(t))return!0;return!1}function g(r){var t=r<0?-1:1,e=Math.abs(r),n=1/(1+.3275911*e);return t*(1-((((1.061405429*n-1.453152027)*n+1.421413741)*n-.284496736)*n+.254829592)*n*Math.exp(-e*e))}function f(r){return 1-g(r)}function m(r,t,e){return void 0===t&&(t=0),void 0===e&&(e=1),e<=0?NaN:.5*(1+g((r-t)/(e*Math.SQRT2)))}function c(r,t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),r<=0||r>=1||e<=0)return NaN;var n,i,o=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411018,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416];return r<.02425?(n=Math.sqrt(-2*Math.log(r)),i=(((((a[0]*n+a[1])*n+a[2])*n+a[3])*n+a[4])*n+a[5])/((((u[0]*n+u[1])*n+u[2])*n+u[3])*n+1)):r<=.97575?(i=(n=r-.5)*n,i=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])*n/(((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+s[4])*i+1)):(n=Math.sqrt(-2*Math.log(1-r)),i=-(((((a[0]*n+a[1])*n+a[2])*n+a[3])*n+a[4])*n+a[5])/((((u[0]*n+u[1])*n+u[2])*n+u[3])*n+1)),t+e*i}function d(r){var t=r.trim();if(""===t)return null;var e=t.match(/^(-?\d+(?:\.\d+)?)([+-]\d+(?:\.\d+)?)[ij]$/i);if(e)return{re:parseFloat(e[1]),im:parseFloat(e[2])};var n=t.match(/^([+-]?\d+(?:\.\d+)?)[ij]$/i);if(n)return{re:0,im:parseFloat(n[1])};var i=t.match(/^(-?\d+(?:\.\d+)?)$/);return i?{re:parseFloat(i[1]),im:0}:null}function v(r,t,e){if(void 0===e&&(e="i"),0===t)return r.toString();if(0===r)return t.toString()+e;var n=t>=0?"+":"-";return r.toString()+n+Math.abs(t).toString()+e}function N(r){if(r<0||r>170)return NaN;for(var t=1,e=2;e<=r;e++)t*=e;return t}function E(r,t){if(t<0||t>r)return 0;t=Math.min(t,r-t);for(var e=1,n=1;n<=t;n++)e=e*(r-t+n)/n;return e}function S(r){if(r<=0)return NaN;var t=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,Number("9.984369578019571e-6"),1.5056327351493116e-7];if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-S(1-r);r-=1;for(var e=t[0],n=1;n<9;n++)e+=t[n]/(r+n);var i=r+7+.5;return.5*Math.log(2*Math.PI)+(r+.5)*Math.log(i)-i+Math.log(e)}function y(r){var t=S(r);return isFinite(t)?Math.exp(t):NaN}function C(r,t){if(t<0||r<=0)return NaN;if(0===t)return 0;if(t>1e6)return 1;for(var e=1/r,n=e,i=1;i<200&&(n*=t/(r+i),e+=n,!(Math.abs(n)<1e-12*Math.abs(e)));i++);return e*Math.exp(-t+r*Math.log(t)-S(r))}function b(r,t){return r<0||t<=0?NaN:C(t/2,r/2)}function A(r,t){if(r<=0||r>=1||t<=0)return NaN;for(var e=0,n=Math.max(100,t+10*Math.sqrt(2*t)),i=0;i<100;i++){var o=(e+n)/2;b(o,t)<r?e=o:n=o}return(e+n)/2}function O(r,t,e){return r<0||t<=0||e<=0?NaN:F(t/2,e/2,t*r/(t*r+e))}function F(r,t,e){if(e<=0)return 0;if(e>=1)return 1;for(var n=S(r)+S(t)-S(r+t),i=Math.exp(r*Math.log(e)+t*Math.log(1-e)-n)/r,o=1,s=1,a=0,u=0;u<=200;u++){var l=2*u,h=u*(t-u)*e/((r+l-1)*(r+l));a=1+h*a,Math.abs(a)<1e-30&&(a=1e-30),s=1+h/s,Math.abs(s)<1e-30&&(s=1e-30),o*=(a=1/a)*s,a=1+(h=-(r+u)*(r+t+u)*e/((r+l)*(r+l+1)))*a,Math.abs(a)<1e-30&&(a=1e-30),s=1+h/s,Math.abs(s)<1e-30&&(s=1e-30);var p=(a=1/a)*s;if(o*=p,Math.abs(p-1)<1e-10)break}return i*(o-1)}function x(r,t,e){if(r<=0||r>=1||t<=0||e<=0)return NaN;for(var n=0,i=1e3;O(i,t,e)<r&&!((i*=2)>1e12););for(var o=0;o<100;o++){var s=(n+i)/2;O(s,t,e)<r?n=s:i=s}return(n+i)/2}function V(r,t){if(t<0)return V(r,-t);for(var e=Math.abs(Math.floor(r)),n=0,i=0;i<100;i++){var o=Math.pow(t/2,2*i+e)/(N(i)*N(i+e));if(n+=o,i>10&&o<1e-15*n)break}return n}function I(r,t){for(var e=Math.abs(Math.floor(r)),n=0,i=0;i<100;i++){var o=(i%2==0?1:-1)*Math.pow(t/2,2*i+e)/(N(i)*N(i+e));if(n+=o,i>10&&Math.abs(o)<1e-15*Math.abs(n))break}return n}function R(r,t){if(t<=0)return NaN;var e=Math.abs(Math.floor(r));return 0===e?Math.PI/2*(V(0,t)-I(0,t)):Math.PI/2*(V(e,t)-I(e,t))}function T(r){for(var t=I(0,r),e=0,n=1;n<100;n++){for(var i=0,o=1;o<=n;o++)i+=1/o;e+=Math.pow(r/2,2*n)/(N(n)*N(n))*i}return 2/Math.PI*(t*(Math.log(r/2)+.5772156649)-e)}function M(r){for(var t=I(1,r),e=0,n=0;n<100;n++)e+=(n%2==0?1:-1)*Math.pow(r/2,2*n+1)/(N(n)*N(n+1)*(2*n+1));return 2/Math.PI*(t*Math.log(r/2)-1/(r/2)+e)}function D(r,t){if(t<=0)return NaN;var e=Math.abs(Math.floor(r));if(0===e)return T(t);var n=T(t),i=M(t);if(1===e)return i;for(var o=1;o<e;o++){var s=2*o/t*i-n;n=i,i=s}return i}function U(r,t,e){return r<=0||e<=0?NaN:m(Math.log(r),t,e)}function w(r,t,e){return Math.exp(c(r,t,e))}function j(r,t){if(t<=0)return NaN;var e=F(t/2,.5,t/(t+r*r));return r>=0?1-.5*e:.5*e}function L(r,t){if(r<=0||r>=1||t<=0)return NaN;for(var e=-100,n=100,i=0;i<100;i++){var o=(e+n)/2;j(o,t)<r?e=o:n=o}return(e+n)/2}function k(r,t,e){return r<0||r>1||t<=0||e<=0?NaN:F(t,e,r)}function _(r,t,e){if(r<=0||r>=1||t<=0||e<=0)return NaN;for(var n=0,i=1,o=0;o<100;o++){var s=(n+i)/2;F(t,e,s)<r?n=s:i=s}return(n+i)/2}function P(r){for(var t=0,e=(r=r.split("").reverse().join("")).length-1;e>=0;e--)t+=(r[e].charCodeAt(0)-64)*Math.pow(26,e);return t-1}function W(r){return r/26>1?W(r%26==0?r/26-1:Math.floor(r/26))+String.fromCharCode(r%26==0?"Z".charCodeAt(0):64+r%26):String.fromCharCode(64+r)}function q(r){return[parseInt(r.match(/\d+/)[0],10)-1,P(r.match(/[A-Z]+/i)[0].toUpperCase())]}function B(r,t){return W(t+1)+(r+1)}function X(r){return B(r[0],r[1])+":"+(t.isNullOrUndefined(r[2])?B(r[0],r[1]):B(r[2],r[3]))}function Y(r,e){var n,i=[];if(r){if(r=-1===(r=r.lastIndexOf("!")>-1?r.substring(r.lastIndexOf("!")+1):r).indexOf(":")?r+":"+r:r,!new RegExp(/^(?=.*[a-zA-Z])(?=.*\d)/g).test(r)){var o=r.split(":"),s=e&&e.rowCount?e.rowCount-1:1,a=e&&e.colCount?W(e.colCount):"A";r=t.isNullOrUndefined(r.match(/[0-9]/))?o[0]+"1:"+o[1]+s:"A"+o[0]+":"+a+o[1]}r.split(":").forEach(function(r){n=q(r),i.push(n[0]),i.push(n[1])})}return i}function H(r){var t="Descending"===r;return function(r,e){if(r===e)return 0;if(null===r||void 0===r)return 1;if(null===e||void 0===e)return-1;var n=0;return"string"==typeof r?n=r.localeCompare(e):r>e?n=1:r<e&&(n=-1),t?-n:n}}function G(r,t){var e=H(t);return r.slice().sort(e)}function Z(r,t){for(var e=t.length,n=0;n<e;n++)if(t[n].sheet.toUpperCase()===r.toUpperCase())return t[n].index;return-1}function K(r){for(var t=[],e=0;r>0&&e<9;){r--;var n="A".charCodeAt(0);t[e]=String.fromCharCode(r%26+n),r=parseInt((r/26).toString(),10),e++}for(var i=[],o=0;o<e;o++)i[e-o-1]=t[o];return i.join("")}!function(r){r[r.NA=0]="NA",r[r.Value=1]="Value",r[r.Ref=2]="Ref",r[r.DivZero=3]="DivZero",r[r.Num=4]="Num",r[r.Name=5]="Name",r[r.Null=6]="Null",r[r.Calc=7]="Calc"}(r.CommonErrors||(r.CommonErrors={})),function(r){r[r.OperatorsCannotStartWithExpression=0]="OperatorsCannotStartWithExpression",r[r.ReservedWordAND=1]="ReservedWordAND",r[r.ReservedWordXOR=2]="ReservedWordXOR",r[r.ReservedWordIf=3]="ReservedWordIf",r[r.NumberContains2DecimalPoints=4]="NumberContains2DecimalPoints",r[r.ReservedWordElse=5]="ReservedWordElse",r[r.ReservedWordNOT=6]="ReservedWordNOT",r[r.InvalidCharInNumber=7]="InvalidCharInNumber",r[r.InvalidCharactersFollowingWithOperator=6]="InvalidCharactersFollowingWithOperator",r[r.MismatchedParentheses=8]="MismatchedParentheses",r[r.UnknownFormulaName=9]="UnknownFormulaName",r[r.RequiresASingleArgument=10]="RequiresASingleArgument",r[r.Requires3Args=11]="Requires3Args",r[r.InvalidMathArgument=12]="InvalidMathArgument",r[r.Requires2Args=13]="Requires2Args",r[r.BadIndex=14]="BadIndex",r[r.TooComplex=15]="TooComplex",r[r.CircularReference=16]="CircularReference",r[r.MissingFormula=17]="MissingFormula",r[r.ImproperFormula=18]="ImproperFormula",r[r.InvalidExpression=19]="InvalidExpression",r[r.CellEmpty=20]="CellEmpty",r[r.BadFormula=21]="BadFormula",r[r.EmptyExpression=22]="EmptyExpression",r[r.VirtualModeRequired=23]="VirtualModeRequired",r[r.MismatchedTics=24]="MismatchedTics",r[r.WrongNumberArguments=25]="WrongNumberArguments",r[r.InvalidArguments=26]="InvalidArguments",r[r.IterationsDoNotConverge=27]="IterationsDoNotConverge",r[r.CalculationOverflow=29]="CalculationOverflow",r[r.AlreadyRegistered=28]="AlreadyRegistered",r[r.MissingSheet=30]="MissingSheet",r[r.CannotParse=31]="CannotParse",r[r.ExpressionCannotEndWithAnOperator=32]="ExpressionCannotEndWithAnOperator",r[r.Spill=33]="Spill",r[r.Div=34]="Div"}(r.FormulasErrorsStrings||(r.FormulasErrorsStrings={})),function(r){r.xlsx="xlsx",r.xlsm="xlsm",r.xlsb="xlsb",r.xltx="xltx",r.xltm="xltm",r.xls="xls",r.xml="xml",r.xlam="xlam",r.xla="xla",r.xlw="xlw",r.xlr="xlr",r.prn="prn",r.txt="txt",r.csv="csv",r.dif="dif",r.slk="slk"}(r.ExcelFileFormats||(r.ExcelFileFormats={}));var $=function(){function r(r){this.parent=r}return r.prototype.getModuleName=function(){return"calc-common"},r}(),z={OperatorsCannotStartWithExpression:"binary operators cannot start an expression",CannotParse:"cannot parse",BadLibrary:"bad library",InvalidCharInFrontOf:"invalid char in front of",NumberContains2DecimalPoints:"number contains 2 decimal points",ExpressionCannotEndWithAnOperator:"expression cannot end with an operator",InvalidCharactersFollowingWithOperator:"invalid characters following an operator",InvalidCharInNumber:"invalid character in number",MismatchedParentheses:"mismatched parentheses",UnknownFormulaName:"unknown formula name",RequiresASingleArgument:"requires a single argument",Requires3Args:"requires 3 arguments",InvalidMathArgument:"invalid Math argument",Requires2Args:"requires 2 arguments",TooComplex:"too complex",MissingFormula:"missing formula",ImproperFormula:"improper formula",InvalidExpression:"invalid expression",CellEmpty:"cell empty",BadFormula:"bad formula",EmptyExpression:"empty expression",MismatchedTics:"mismatched string quotes",WrongNumberArguments:"wrong number of arguments",InvalidArguments:"invalid arguments",IterationsDoNotConverge:"iterations do not converge",AlreadyRegistered:"Control is already registered",CalculationOverflow:"Calculation overflow",MissingSheet:"Missing sheet",CannotParseUnderscore:"cannot_parse",ExpressionCannotEndWithAnOperatorUnderscore:"expression_cannot_end_with_an_operator",CategoryAll:"All"},Q=function(){function e(r){this.owner=r,this.parent=r.parent}return e.prototype.parseDouble=function(r){var t=this.parent.parseFloat(r.toString());return isNaN(t)?NaN:t},e.prototype.getSheetReference=function(r){return 0===r.indexOf(this.parent.sheetToken)&&r.lastIndexOf(this.parent.sheetToken)>r.indexOf(this.parent.sheetToken)?r.substring(0,r.lastIndexOf(this.parent.sheetToken)+1):""},e.prototype.calculateIFS=function(e,n){var i=this;if(t.isNullOrUndefined(e)||""===e[0]||e.length<2||e.length>127||e.length%2==0)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(3===e.length&&'""'!==e[2]&&e[2].includes(this.parent.tic+this.parent.tic)){var o,s="",a=this.parent.getParseArgumentSeparator();return e[2].split(this.parent.tic+this.parent.tic).forEach(function(r){(r=r.trim().split(i.parent.tic).join(""))&&(o=i.parent.computeIfsFormulas([e[0],e[1],r],i.parent.falseValue,n).toString(),s+=(s?a:"")+o)}),s}return this.parent.computeIfsFormulas(e,this.parent.falseValue,n)},e.prototype.resolveTextArg=function(r){if(t.isNullOrUndefined(r))return"";var e=this.parent.getValueFromArg(r);return this.parent.getErrorStrings().indexOf(e)>-1?e:(this.parent.isCellReference(r)||(e=this.parent.removeTics(e)),e)},e.prototype.resolveNumberArg=function(t){var e=this.parent.getErrorStrings(),n=this.parent.getValueFromArg(t);if(e.indexOf(n)>-1)return n;if(""===n)return 0;var i=n.toUpperCase();if(i===this.parent.trueValue)return 1;if(i===this.parent.falseValue)return 0;if(this.parent.isCellReference(t)||(n=this.parent.removeTics(n)),n.indexOf("%")>-1){var o=n.replace("%","");if(this.parent.isNumber(o))return this.parent.parseFloat(o)/100}var s=this.parent.parseFloat(n);return isNaN(s)?e[r.CommonErrors.Value]:s},e}(),J=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),rr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SUM",category:"Math & Trig",description:"Sums individual values, cell references or ranges."},{formulaName:"SUMIF",category:"Math & Trig",description:"It will sum up cells that meet the given criteria."},{formulaName:"SUMIFS",category:"Math & Trig",description:"Sums the cells specified by a given set of conditionsor criteria."},{formulaName:"SUMPRODUCT",category:"Math & Trig",description:"Returns sum of the product of given ranges of arrays."},{formulaName:"PRODUCT",category:"Math & Trig",description:"Multiplies all the numbers given as arguments and returns the product."}],t}return J(n,e),n.prototype.ComputeSUM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o,s,a=0,u=0;if(!t.isNullOrUndefined(e))for(var l=e,h=function(r){r.toString().indexOf(".")>-1&&(u=Math.max(u,r.split(".")[1].length))},p=0;p<l.length;p++){var g=l[p].toString();if(g.indexOf(":")>-1&&this.parent.isCellReference(g)){for(var f=this.parent.getCellCollection(g.split(this.parent.tic).join("")),m=0;m<f.length;m++)if(o=i?this.parent.getValueFromArg(f[m],null,null,!0):this.parent.getValueFromArg(f[m]),!i||!o.includes("SUBTOTAL(")){if(this.parent.getErrorStrings().indexOf(o)>-1)return o;t.isNullOrUndefined(o[0])||isNaN(this.parent.parseFloat(o))||(h(o),a+=this.parent.parseFloat(o))}}else{if(l[p].indexOf(this.parent.tic)>-1&&(isNaN(this.parent.parseFloat(l[p].split(this.parent.tic).join("")))||""===l[p].split(this.parent.tic).join("").trim()))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(l[p].split(this.parent.tic).join("")===this.parent.trueValue&&(l[p]="1"),l[p].split(this.parent.tic).join("")===this.parent.falseValue&&(l[p]="0"),s=i?this.parent.getValueFromArg(l[p].split(this.parent.tic).join(""),null,null,!0):this.parent.getValueFromArg(l[p].split(this.parent.tic).join("")),i&&s.includes("SUBTOTAL("))continue;if(this.parent.getErrorStrings().indexOf(s)>-1)return s;if(t.isNullOrUndefined(s)||isNaN(this.parent.parseFloat(s)))continue;s.length>0&&(h(s),a+=this.parent.parseFloat(s+""))}}return a.toString().indexOf(".")>-1?a.toFixed(u):a},n.prototype.ComputeSUMIF=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t;if(n[0].indexOf(":")<0&&!this.parent.isCellReference(n[0])||n[2]&&n[2].indexOf(":")<0&&!this.parent.isCellReference(n[2]))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];if(n.length>3||n.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.computeSumIfAndAvgIf(t,!1);return"string"==typeof i&&(this.parent.formulaErrorStrings.indexOf(i)||this.parent.getErrorStrings().indexOf(i))?i:i[0]},n.prototype.ComputeSUMIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.calculateIFS(r)},n.prototype.ComputeSUMPRODUCT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o;if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var s,a=0,u=0,l=null,h=e,p=[],g=0;g<h.length;g++){var f=this.parent.getCellCollection(h[g]);if("#REF!"===f[0])return this.parent.getErrorStrings()[r.CommonErrors.Name];p.push(f.length)}for(var m=0;m<p.length;m++)if(p[m]&&p[m+1]&&p[m]!==p[m+1])return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var c=0;c<h.length;++c){var d=h[c];if(d.startsWith(this.parent.tic)||!this.parent.isCellReference(d)){var v=this.parent.getValueFromArg(d);return s=v.indexOf('"'),this.parent.getErrorStrings().indexOf(v)>-1?v:s>-1?0:this.parent.getErrorStrings()[r.CommonErrors.Value]}var g=d.indexOf(":"),N=this.parent.rowIndex(d.substr(0,g)),E=this.parent.rowIndex(d.substr(g+1));if(!(-1!==N||-1===E)==(-1===N||-1!==E))return this.parent.getErrorStrings()[r.CommonErrors.Name];N>E&&(N=(i=[E,N])[0],E=i[1]);var S=this.parent.colIndex(d.substr(0,g)),y=this.parent.colIndex(d.substr(g+1));if(S>y&&(S=(o=[y,S])[0],y=o[1]),null===l)for(u=(E-N+1)*(y-S+1),l=[],g=0;g<u;++g)l[g]=1;g=0;for(var C=N;C<=E;++C)for(var b=S;b<=y;++b){var A=this.getSheetReference(d)+this.parent.convertAlpha(b)+C,O=this.parent.getValueFromArg(A);if(this.parent.getErrorStrings().indexOf(O)>-1)return O;if(isNaN(this.parent.parseFloat(O)))l[g]=0;else{if(isNaN(l[g]))return this.parent.getErrorStrings()[r.CommonErrors.Name];l[g]=l[g]*this.parent.parseFloat(O)}g++}}for(g=0;g<u;++g)a+=l[g];return a},n.prototype.ComputePRODUCT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o,a,u,l=1,h=!0;if(!t.isNullOrUndefined(e))for(var p=e,g=0;g<p.length;g++){var f=p[g];if(f.indexOf(":")>-1&&this.parent.isCellReference(f)){for(var m=this.parent.getCellCollection(f),c=0;c<m.length;c++)if(o=i?this.parent.getValueFromArg(m[c],null,null,!0):this.parent.getValueFromArg(m[c]),(!i||!o.includes("SUBTOTAL("))&&s(o)){if(this.parent.getErrorStrings().indexOf(o)>-1)return o;u=this.parent.parseFloat(o),isNaN(u)||o.length>0&&(l*=u,h=!1)}}else if(-1===f.indexOf(":")&&this.parent.isCellReference(f)){if(a=i?this.parent.getValueFromArg(p[g],null,null,!0):this.parent.getValueFromArg(p[g]),i&&a.includes("SUBTOTAL("))continue;if(!s(a))continue;if(this.parent.getErrorStrings().indexOf(a)>-1)return a}else{if((a=p[g]).indexOf(this.parent.tic)>-1&&""===a.split(this.parent.tic).join("").trim()||p[g].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(a.split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(a=this.parent.getValueFromArg(p[g].split(this.parent.tic).join("")),a=a===this.parent.trueValue?"1":a===this.parent.falseValue?"0":a.split(this.parent.tic).join(""),this.parent.getErrorStrings().indexOf(a)>-1)return a}u=this.parent.parseFloat(a),isNaN(u)||a.length>0&&(l*=u,h=!1)}return h?"0":l.toString()},n}(Q),tr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),er=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ROUND",category:"Math & Trig",description:"Rounds a number to a specified number of digits."},{formulaName:"ROUNDUP",category:"Math & Trig",description:"Rounds a number away from zero."},{formulaName:"ROUNDDOWN",category:"Math & Trig",description:"Rounds a number down, toward zero."},{formulaName:"FLOOR",category:"Math & Trig",description:"Returns the round a number down to the nearest integer."},{formulaName:"CEILING",category:"Math & Trig",description:"Returns a number rounded up to a multiple of another number."},{formulaName:"INT",category:"Math & Trig",description:"Returns a number to the nearest integer."},{formulaName:"TRUNC",category:"Math & Trig",description:"Returns the truncated value of a number to a specified number of decimal places."},{formulaName:"ODD",category:"Math & Trig",description:"Rounds a positive number up and negative number down to the nearest odd integer."},{formulaName:"EVEN",category:"Math & Trig",description:"Rounds a positive number up and negative number down to the nearest even integer."}],t}return tr(n,e),n.prototype.ComputeROUND=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!t.length||1===t.length||t.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var n=t;if(1===t.length){var i="TRUE"===n[0].split(this.parent.tic).join("")?"1":"FALSE"===n[0].split(this.parent.tic).join("")?"0":n[0];return isNaN(this.parent.parseFloat(i))?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:Math.round(this.parent.parseFloat(i)).toString()}var o=this.parent.getValueFromArg(n[0]);if(this.parent.getErrorStrings().indexOf(o)>-1)return o;var s=this.parent.getValueFromArg(n[1]);if(this.parent.getErrorStrings().indexOf(s)>-1)return s;o="TRUE"===o?"1":"FALSE"===o?"0":o,s="TRUE"===s?"1":"FALSE"===s?"0":s,o=o.split(this.parent.tic).join(""),s=s.split(this.parent.tic).join("");var a=isNaN(Number(o))||""===o.trim(),u=isNaN(Number(s))||""===s.trim();if((n[0].indexOf('"')>-1||this.parent.isCellReference(n[0]))&&a||(n[1].indexOf('"')>-1||this.parent.isCellReference(n[1]))&&u)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(""===o&&""===s||""===o)return 0;var l,h=this.parent.parseFloat(o),p=this.parent.parseFloat(s);if(!isNaN(p)&&!isNaN(h)&&p>0)l=this.parent.parseFloat(this.preciseRound(h,p,"ROUND"));else{var g=Math.pow(10,-p);l=Math.round(h/g)*g}return l.toString()},n.prototype.preciseRound=function(r,t,e){var n=Math.pow(10,t),i=Math.abs(r)*n;return((r>=0?1:-1)*(("ROUND"===e?Math.round(i):"ROUNDDOWN"===e?Math.floor(i):Math.ceil(i))/n)).toFixed(t)},n.prototype.ComputeROUNDUP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i,o,s,a=t.length;if(1===a&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==a)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(this.parent.isCellReference(t[0]))i=this.parent.getValueFromArg(t[0])||"0";else{if(t[0].indexOf(this.parent.tic)>-1&&(t[0].split(this.parent.tic).join("")===this.parent.trueValue||t[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(t[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.isCellReference(t[1]))o=this.parent.getValueFromArg(t[1])||"0";else{if(t[1].indexOf(this.parent.tic)>-1&&(t[1].split(this.parent.tic).join("")===this.parent.trueValue||t[1].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(t[1]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(o)>-1)return o;i="TRUE"===i.toUpperCase()?"1":"FALSE"===i?"0":i,o="TRUE"===o.toUpperCase()?"1":"FALSE"===o?"0":o;var u=isNaN(Number(i))||""===i.trim(),l=isNaN(Number(o))||""===o.trim();if((t[0].indexOf('"')>-1||this.parent.isCellReference(t[0]))&&u||(t[1].indexOf('"')>-1||this.parent.isCellReference(t[1]))&&l)return this.parent.getErrorStrings()[r.CommonErrors.Value];var h=Math.ceil(this.parent.parseFloat(o));if(s=this.parent.parseFloat(i),h>0){var p=i.split("."),g=2===p.length?p[1].length>=h?h:p[1].length:0;n=(s=this.parent.parseFloat(this.preciseRound(s,g,"ROUNDUP"))).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:this.parent.getErrorStrings()[r.CommonErrors.Name])}else s>0?s=s/Math.pow(10,-h)+.49999:s<0&&(s=s/Math.pow(10,-h)-.49999),n=(s=s>0&&h<-9?1*Math.pow(10,-h):this.parent.parseFloat(s.toFixed(0))*Math.pow(10,-h)).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:n=this.parent.getErrorStrings()[r.CommonErrors.Name]);return n},n.prototype.ComputeROUNDDOWN=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i,o,s,a=t.length;if(1===a&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==a)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(this.parent.isCellReference(t[0]))i=this.parent.getValueFromArg(t[0])||"0";else{if(t[0].indexOf(this.parent.tic)>-1&&(t[0].split(this.parent.tic).join("")===this.parent.trueValue||t[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(t[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.isCellReference(t[1]))o=this.parent.getValueFromArg(t[1])||"0";else{if(t[1].indexOf(this.parent.tic)>-1&&(t[1].split(this.parent.tic).join("")===this.parent.trueValue||t[1].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(t[1]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(o)>-1)return o;i="TRUE"===i.toUpperCase()?"1":"FALSE"===i?"0":i,o="TRUE"===o.toUpperCase()?"1":"FALSE"===o?"0":o;var u=isNaN(Number(i))||""===i.trim(),l=isNaN(Number(o))||""===o.trim();if((t[0].indexOf('"')>-1||this.parent.isCellReference(t[0]))&&u||(t[1].indexOf('"')>-1||this.parent.isCellReference(t[1]))&&l)return this.parent.getErrorStrings()[r.CommonErrors.Value];var h=Math.ceil(this.parent.parseFloat(o));if(s=this.parent.parseFloat(i),h>0){var p=i.indexOf("."),g=0;-1!==p&&(g=(g=i.length-p-1)>=h?h:g),n=(s=this.parent.parseFloat(this.preciseRound(s,g,"ROUNDDOWN"))).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:this.parent.getErrorStrings()[r.CommonErrors.Name])}else s>0?s=s/Math.pow(10,-h)-.49999:s<0&&(s=s/Math.pow(10,-h)+.49999),n=(s=s>0&&h<-9?1*Math.pow(10,-h):this.parent.parseFloat(s.toFixed(0))*Math.pow(10,-h)).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:n=this.parent.getErrorStrings()[r.CommonErrors.Name]);return n},n.prototype.ComputeFLOOR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i,o=e;if(2!==o.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===o[0]&&""===o[1]||""===o[0]&&!o[1].includes('"'))return 0;""!==o[1]||o[0].includes('"')||(o[1]="0");for(var s=0;s<o.length;s++){var a=o[s].split(this.parent.tic).join("").trim();if(""===a||o[s].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(a)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(p(o[s])){if(i=this.parent.getValueFromArg(o[s])||"0",(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(i=this.parent.getValueFromArg(o[s].split(this.parent.tic).join("")),(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value];o[s]=i}var u=this.parent.parseFloat(o[0]),l=this.parent.parseFloat(o[1]);return u>0&&l<0?this.parent.getErrorStrings()[r.CommonErrors.Num]:(u>0||u<0)&&0===l?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:isNaN(u)?this.parent.getErrorStrings()[r.CommonErrors.Name]:0===u&&0===l?0:Math.floor(u/l)*l},n.prototype.ComputeCEILING=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i,o=e;if(2!==o.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===o[0]&&""===o[1]||""===o[0]&&!o[1].includes('"'))return 0;""!==o[1]||o[0].includes('"')||(o[1]="0");for(var s=0;s<o.length;s++){var a=o[s].split(this.parent.tic).join("").trim();if(""===a||o[s].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(a)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(p(o[s])){if(i=this.parent.getValueFromArg(o[s])||"0",(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(i=this.parent.getValueFromArg(o[s].split(this.parent.tic).join("")),(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value];o[s]=i}var u=this.parent.parseFloat(o[0]),l=this.parent.parseFloat(o[1]);return u>0&&l<0?this.parent.getErrorStrings()[r.CommonErrors.Num]:isNaN(u)?this.parent.getErrorStrings()[r.CommonErrors.Name]:(u>0||0===u)&&0===l?0:Math.ceil(u/l)*l},n.prototype.ComputeINT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=this.parent.getErrorStrings();return""===t[0]&&1===t.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:t.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(n=this.parent.getValueFromArg(t[0]),i.indexOf(n)>-1?n:(n.toUpperCase()===this.parent.trueValue?n="1":n.toUpperCase()===this.parent.falseValue&&(n="0"),this.parent.isCellReference(t[0])||(-1===t[0].indexOf(this.parent.tic+this.parent.tic)&&(n=n.split(this.parent.tic).join("")),""!==n.trim())?(n.indexOf("%")>-1&&(n=(.01*Number(n.split("%")[0])).toString()),isNaN(this.parent.parseFloat(n))?i[r.CommonErrors.Value]:(n=this.parent.parseFloat(n),n=Math.floor(n))):i[r.CommonErrors.Value]))},n.prototype.ComputeTRUNC=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s=0,a=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||""===n[0]&&1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(0===n.length||n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var u=function(t){var n=e.parent.getValueFromArg(t);if(a.indexOf(n)>-1)return n;if(n===e.parent.trueValue)n="1";else if(n===e.parent.falseValue)n="0";else if(!e.parent.isCellReference(t)){if(t.indexOf(e.parent.tic)>-1&&e.parent.removeTics(t).match(/^(\d*\.\d+|\d+)\s*[*]\s*(\d*\.\d+|\d+)$/))n=e.parent.getValueFromArg(e.parent.removeTics(t));else if(n.indexOf(e.parent.tic)>-1){if(""===(n=e.parent.removeTics(n)).trim())return a[r.CommonErrors.Value];if(n.indexOf(":")>-1){var i=n.split(":");if(!(i.length<=3))return a[r.CommonErrors.Value];if(!e.parent.isNumber(i[0])||!e.parent.isNumber(i[1]))return a[r.CommonErrors.Value];var o=Number(i[0])+Number(Number(i[1])/60);if(3===i.length){if(!e.parent.isNumber(i[2]))return a[r.CommonErrors.Value];o+=Number(Number(i[2])/3600)}n=(o/24).toString()}}2===n.split("%").length&&e.parent.isNumber(n.split("%")[0])&&(n=(.01*Number(n.split("%")[0])).toString())}return n};if(!t.isNullOrUndefined(n[0])){if(o=u(n[0]),a.indexOf(o)>-1)return o;if(o=this.parent.parseFloat(o),isNaN(o))return a[r.CommonErrors.Value]}if(!t.isNullOrUndefined(n[1])){if(s=u(n[1]),a.indexOf(s)>-1)return s;if(s=this.parent.parseFloat(s),isNaN(s))return a[r.CommonErrors.Value]}return s=Math.pow(10,Math.floor(s)),o=Number(o),((o<0?-1:1)*Math.floor(s*Math.abs(o))/s).toString()},n.prototype.ComputeODD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=e[0].split(this.parent.tic).join("").trim();if(""===i||e[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(i)))return this.parent.getErrorStrings()[r.CommonErrors.Value];var o;if(p(e[0])){if(o=this.parent.getValueFromArg(e[0]),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||o.includes('"')||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if("#NAME?"===(o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Name];if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}var s=Math.ceil(parseInt(o,10)),a=0===s;return s=s%2==0?s>0?s+1:s-1:s,Math.ceil(parseInt(o,10))%2!=0&&(parseInt(o,10)>0&&parseFloat(o)>parseInt(o,10)?s+=2:parseInt(o,10)<0&&parseFloat(o)<parseInt(o,10)&&(s-=2)),isNaN(s)?this.parent.getErrorStrings()[r.CommonErrors.Name]:a?1:s},n.prototype.ComputeEVEN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=e[0].split(this.parent.tic).join("").trim();if(""===i||e[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(i)))return this.parent.getErrorStrings()[r.CommonErrors.Value];var o;if(p(e[0])){if(o=this.parent.getValueFromArg(e[0]),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||o.includes('"')||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if("#NAME?"===(o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Name];if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}var s=Math.ceil(parseInt(o,10));return s=s%2==0?s:s>0?s+1:s-1,Math.ceil(parseInt(o,10))%2==0&&(parseInt(o,10)>0&&parseFloat(o)>parseInt(o,10)?s+=2:parseInt(o,10)<0&&parseFloat(o)<parseInt(o,10)&&(s-=2)),isNaN(s)?this.parent.getErrorStrings()[r.CommonErrors.Name]:s},n}(Q),nr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ir=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ABS",category:"Math & Trig",description:"Returns the absolute value of a number."},{formulaName:"RAND",category:"Math & Trig",description:"Return a random number between 0 and 1."},{formulaName:"RANDBETWEEN",category:"Math & Trig",description:"Returns an integer random number in a specified range."},{formulaName:"RADIANS",category:"Math & Trig",description:"Converts degrees to radians."},{formulaName:"DEGREES",category:"Math & Trig",description:"Converts radians to degrees."},{formulaName:"PI",category:"Math & Trig",description:"Returns the value of pi."},{formulaName:"MOD",category:"Math & Trig",description:"Returns a remainder after a number is divided by divisor."},{formulaName:"FACT",category:"Math & Trig",description:"Returns the factorial of a number."},{formulaName:"DECIMAL",category:"Math & Trig",description:"Converts a text representation of a number in a given base into a decimal number."},{formulaName:"LN",category:"Math & Trig",description:"Returns the natural logarithm of a number."},{formulaName:"LOG",category:"Math & Trig",description:"Returns the logarithm of a number to the base that you specify."},{formulaName:"POWER",category:"Math & Trig",description:"Returns the result of a number raised to power."},{formulaName:"SQRT",category:"Math & Trig",description:"Returns the square root of a positive number."},{formulaName:"EXP",category:"Math & Trig",description:"Returns e raised to the power of the given number."}],t}return nr(n,e),n.prototype.ComputeABS=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=t,o="";if(0===t.length||t.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var s=i[0].split(this.parent.tic).join("").trim();if(""===s||i[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(s)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(i[0])){if(o=this.parent.getValueFromArg(i[0]),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o===this.parent.trueValue&&(o="1"),""!==o&&o!==this.parent.falseValue||(o="0"),n=this.parent.parseFloat(o),isNaN(n)&&!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if((o=this.parent.getValueFromArg(i[0]).split(this.parent.tic).join())===this.parent.trueValue&&(o="1"),o===this.parent.falseValue&&(o="0"),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(n=this.parent.parseFloat(o),isNaN(n)&&!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}return Math.abs(n)},n.prototype.ComputeRAND=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===t.length&&""===t[0]&&(t.length=0),t.length>0?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:Math.random().toString()},n.prototype.ComputeRANDBETWEEN=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o;if(1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.parent.getErrorStrings(),a=function(e){var n;if(n=t.parent.getValueFromArg(e),s.indexOf(n)>-1)return n;if(t.parent.isCellReference(e)){if(""===n)n="0";else if(e.indexOf(":")>-1||n.match(/^(\d*\.\d+|\d+)\s*[+\-*/]\s*(\d*\.\d+|\d+)$/))return s[r.CommonErrors.Value]}else{if(""===n)return s[r.CommonErrors.NA];if(e.indexOf(t.parent.tic)>-1&&t.parent.removeTics(e).match(/^(\d*\.\d+|\d+)\s*[+*]\s*(\d*\.\d+|\d+)$/))return s[r.CommonErrors.Value];if(n.indexOf(t.parent.tic)>-1&&(n=t.parent.removeTics(n)).indexOf(":")>-1){var i=n.split(":");if(!(i.length<=3))return s[r.CommonErrors.Value];if(!t.parent.isNumber(i[0])||!t.parent.isNumber(i[1]))return s[r.CommonErrors.Value];var o=Number(i[0])+Number(Number(i[1])/60);if(3===i.length){if(!t.parent.isNumber(i[2]))return s[r.CommonErrors.Value];o+=Number(Number(i[2])/3600)}n=(o/24).toString()}2===n.split("%").length&&t.parent.isNumber(n.split("%")[0])&&(n=(.01*Number(n.split("%")[0])).toString())}return n=parseFloat(n),isNaN(n)?s[r.CommonErrors.Value]:n};return o=a(e[1]),s.indexOf(o)>-1?o:(i=a(e[0]),s.indexOf(i)>-1?i:0===i&&0===o?"0":o<i?s[r.CommonErrors.Num]:(i=Math.ceil(i),o=Math.floor(o),Math.floor(Math.random()*(o-i+1)+i)))},n.prototype.ComputeRADIANS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||""===e[0]&&1===e.length||2===e[0].split("!").length&&-1===e[0].indexOf(this.parent.tic)?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:e[0].indexOf(":")>-1||""===e[0].split(this.parent.tic).join("").trim()||"!"===e[0].split(this.parent.tic).join("").trim()||2===e[0].split("!").length?o[r.CommonErrors.Value]:(i=this.parent.getValueFromArg(e[0]).trim(),o.indexOf(i)>-1?i:i.indexOf(this.parent.tic)>-1&&-1===e[0].indexOf(this.parent.tic)||i.split(this.parent.tic).length>3?o[r.CommonErrors.Value]:(i.toUpperCase()===this.parent.trueValue?i="1":i.toUpperCase()===this.parent.falseValue?i="0":2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),i=this.parent.parseFloat(i.split(this.parent.tic).join("")),isNaN(i)?this.parent.isCellReference(e[0])||e[0].indexOf(this.parent.tic)>-1?o[r.CommonErrors.Value]:o[r.CommonErrors.Name]:i=Math.PI*i/180))},n.prototype.ComputeDEGREES=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||""===e[0]&&1===e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]).trim();if(i.indexOf(o)>-1)return o;if(this.parent.isCellReference(e[0])){if(""===o||o.indexOf(":")>-1)return 0;if(o.indexOf(this.parent.tic)>-1||isNaN(Number(o))&&!isNaN(parseInt(o,10)))return i[r.CommonErrors.Value]}else if(o.indexOf('"TRUE"')>-1)return i[r.CommonErrors.Value];if((o=o.split(this.parent.tic).join("")).toUpperCase()===this.parent.trueValue)o="1";else if(o.toUpperCase()===this.parent.falseValue)o="0";else if(o.indexOf("%")>-1)o=(Number(o.split("%")[0])/100).toString();else if(o.toUpperCase().match(/[A-Z]/)||isNaN(parseInt(o,10)))return i[r.CommonErrors.Value];return parseFloat(o)*(180/Math.PI)},n.prototype.ComputePI=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&""!==t[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:Math.PI},n.prototype.ComputeMOD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[1]&&!e[0].includes('"'))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Div];if(""===e[0]&&!e[1].includes('"'))return 0;for(var o=0;o<e.length;o++){var s=e[o].split(this.parent.tic).join("").trim();if(""===s||e[o].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(s)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(p(e[o])){if(i=this.parent.getValueFromArg(e[o])||"0",(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(i=this.parent.getValueFromArg(e[o].split(this.parent.tic).join("")),i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i,this.parent.getErrorStrings().indexOf(i)>-1)return i;e[o]=i}var a=e[0],u=e[1];if("0"===u||""===u)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Div];if("0"===a||""===a)return 0;var l=((a=parseFloat(a))%(u=parseFloat(u))+u)%u;return isNaN(l)?this.parent.getErrorStrings()[r.CommonErrors.Name]:l},n.prototype.ComputeFACT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=1,i=this.parent.getErrorStrings();if(""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=t[0];if(this.parent.isCellReference(t[0])||isNaN(Number(o.split(this.parent.tic).join("")))){if(o=this.parent.getValueFromArg(t[0]),i.indexOf(o)>-1)return o;if(o.startsWith(this.parent.tic)||o.match(/^(\d*\.\d+|\d+)\s*[+\-*/]\s*(\d*\.\d+|\d+)$/))return i[r.CommonErrors.Value];if(""===o)return 1}if(o=o.split(this.parent.tic).join("").trim(),i.indexOf(o)>-1)return o;if(o.toUpperCase()===this.parent.trueValue||o.toUpperCase()===this.parent.falseValue)return 1;o.indexOf("%")>-1&&(o=(Number(o.split("%")[0])/100).toString());var s=parseInt(o,10);if(s<0||s>170)return i[r.CommonErrors.Num];if(o.toUpperCase().match(/[A-Z]/)||""===o)return i[r.CommonErrors.Value];if(o.indexOf(":")>-1)return 0;for(var a=1;a<=s;a++)n*=a;return n},n.prototype.ComputeDECIMAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e[0].match(/[@#$%^&*()?:{}|<>+-]/g))return this.parent.getErrorStrings()[r.CommonErrors.Num];if(e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var o=void 0,s=void 0;o=this.parent.isCellReference(e[0].toString())?this.parent.getValueFromArg(e[0]):this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),s=this.parent.isCellReference(e[1].toString())?this.parent.getValueFromArg(e[1]):this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");var a=parseInt(o,10),u=parseInt(s,10);return this.parent.getErrorStrings().indexOf(o)>-1?o:this.parent.getErrorStrings().indexOf(s)>-1?s:""===o&&""!==s?0:""===o||a<0||!isNaN(a)&&!Number.isInteger(parseFloat(o))?this.parent.getErrorStrings()[r.CommonErrors.Num]:""===s||u<2||u>36||isNaN(u)?this.parent.getErrorStrings()[r.CommonErrors.Num]:isNaN(this.parent.parseFloat(o))&&this.parent.parseFloat(s)<=10?this.parent.getErrorStrings()[r.CommonErrors.Num]:(i=parseInt(o,parseInt(s,10)),isNaN(i)?this.parent.getErrorStrings()[r.CommonErrors.Num]:i)},n.prototype.ComputeLN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||""===e[0]&&1===e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:0===e.length||e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]),o.indexOf(i)>-1?i:(i.toUpperCase()===this.parent.trueValue?i="1":i.toUpperCase()===this.parent.falseValue&&(i="0"),this.parent.isCellReference(e[0])||""!==(i=this.parent.removeTics(i)).trim()?(2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(.01*Number(i.split("%")[0])).toString()),i=this.parent.parseFloat(i),i<=0?o[r.CommonErrors.Num]:isNaN(i)?o[r.CommonErrors.Value]:Math.log(i)):o[r.CommonErrors.Value]))},n.prototype.ComputeLOG=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s,a=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var u=function(t){var n=e.parent.getValueFromArg(t);if(n===e.parent.trueValue?n="1":n===e.parent.falseValue&&(n="0"),!e.parent.isCellReference(t)&&""!==n){if(n.indexOf(e.parent.tic)>-1&&-1===a.indexOf(n.split(e.parent.tic).join(""))){if(""===(n=e.parent.removeTics(n)).trim())return a[r.CommonErrors.Value];if(n.indexOf(":")>-1){var i=n.split(":");if(!(i.length<=3))return a[r.CommonErrors.Value];if(!e.parent.isNumber(i[0])||!e.parent.isNumber(i[1]))return a[r.CommonErrors.Value];var o=Number(i[0])+Number(Number(i[1])/60);if(3===i.length){if(!e.parent.isNumber(i[2]))return a[r.CommonErrors.Value];o+=Number(Number(i[2])/3600)}n=(o/24).toString()}}2===n.split("%").length&&e.parent.isNumber(n.split("%")[0])&&(n=(.01*Number(n.split("%")[0])).toString())}return n};if(!t.isNullOrUndefined(n[0])){if(o=u(n[0]),a.indexOf(o)>-1)return o;o=this.parent.parseFloat(o)}if(s=10,!t.isNullOrUndefined(n[1])){if(s=u(n[1]),a.indexOf(s)>-1)return s;s=this.parent.parseFloat(s)}return o=Number(o),isNaN(o)||isNaN(s)?a[r.CommonErrors.Value]:o<=0||s<=0?a[r.CommonErrors.Num]:1===s?a[r.CommonErrors.DivZero]:(Math.log(o)/Math.LN10/(Math.log(s)/Math.LN10)).toString()},n.prototype.ComputePOWER=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0].trim()&&""===n[1].trim())return s[r.CommonErrors.Num];var a=function(t){var n=e.parent.getValueFromArg(t);if(s.indexOf(n)>-1)return n;if(n.toUpperCase()===e.parent.trueValue?n="1":n.toUpperCase()===e.parent.falseValue&&(n="0"),n.indexOf(e.parent.tic)>-1&&(n=e.parent.removeTics(n),-1===t.indexOf(e.parent.tic)||""===n.trim()))return s[r.CommonErrors.Value];if(2===n.split("%").length&&e.parent.isNumber(n.split("%")[0]))n=(Number(n.split("%")[0])/100).toString();else if(n.indexOf("/")>-1&&e.parent.isNumber(n.split("/").join("")))return s[r.CommonErrors.Num];return n=e.parent.parseFloat(n),isNaN(n)?s[r.CommonErrors.Value]:n},u=a(n[0]);if(s.indexOf(u)>-1)return u;var l=a(n[1]);return s.indexOf(l)>-1?l:isNaN(u)||isNaN(l)?s[r.CommonErrors.Value]:0===u&&l<0?s[r.CommonErrors.DivZero]:0===u&&0===l?s[r.CommonErrors.Num]:(o=Math.pow(u,l),isNaN(o)||o===1/0?s[r.CommonErrors.Num]:o.toString())},n.prototype.ComputeSQRT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=t[0];if(0===t.length||t.length>1||""===i)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i.split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(i)){if((n=this.parent.getValueFromArg(i)||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(i.indexOf(this.parent.tic)>-1&&(i.split(this.parent.tic).join("")===this.parent.trueValue||i.split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];n=this.parent.getValueFromArg(i).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(n)>-1)return n;n=n===this.parent.trueValue?"1":n===this.parent.falseValue?"0":n;var o=this.parent.parseFloat(n);if(o<0)return this.parent.getErrorStrings()[r.CommonErrors.Num];if(isNaN(o)||i.indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(i))){var s=this.parent.hostParseDate(isNaN(o)?n:i.split(this.parent.tic).join(""));if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];n=s.value}return Math.sqrt(this.parent.parseFloat(n))},n.prototype.ComputeEXP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=this.parent.getErrorStrings();if(""===t[0]&&1===t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===t[0].split(this.parent.tic).join("").trim())return i[r.CommonErrors.Value];if(n=this.parent.getValueFromArg(t[0]),i.indexOf(n)>-1)return n;if(n.indexOf(this.parent.tic)>-1&&(this.parent.isCellReference(t[0])||isNaN(Number(n.split(this.parent.tic).join("")))))return i[r.CommonErrors.Value];if((n=n.split(this.parent.tic).join(""))===this.parent.trueValue)n="1";else if(n===this.parent.falseValue||""===n)n="0";else if(n.indexOf("%")>-1)n=(Number(n.split("%")[0])/100).toString();else if(n.indexOf(":")>-1)return"0";var o=this.parent.parseFloat(n);return isNaN(o)?i[r.CommonErrors.Value]:o>709?i[r.CommonErrors.Num]:Math.exp(o).toString()},n}(Q),or=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),sr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SIN",category:"Math & Trig",description:"Returns the sine of an angle."},{formulaName:"COS",category:"Math & Trig",description:"Returns the cosine of an angle."},{formulaName:"TAN",category:"Math & Trig",description:"Returns the tangent of an angle."},{formulaName:"ASIN",category:"Math & Trig",description:"Returns the arcsine of a number."},{formulaName:"ACOS",category:"Math & Trig",description:"Returns the arccosine of a number."},{formulaName:"ATAN",category:"Math & Trig",description:"Returns the arctangent of a number."},{formulaName:"ATAN2",category:"Math & Trig",description:"Returns the arctangent from x- and y-coordinates."},{formulaName:"SINH",category:"Math & Trig",description:"Returns the hyperbolic sine of a number."},{formulaName:"COSH",category:"Math & Trig",description:"Returns the hyperbolic cosine of a number."},{formulaName:"TANH",category:"Math & Trig",description:"Returns the hyperbolic tangent of a number."},{formulaName:"SIGN",category:"Math & Trig",description:"Returns the sign of a number."},{formulaName:"LOG10",category:"Math & Trig",description:"Returns the base-10 logarithm of a number."},{formulaName:"QUOTIENT",category:"Math & Trig",description:"Returns the integer portion of a division."},{formulaName:"SQRTPI",category:"Math & Trig",description:"Returns the square root of a number multiplied by pi."}],t}return or(n,e),n.prototype.unaryMath=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.resolveNumberArg(e[0]);return"string"==typeof s?s:i&&!i(s)?o[r.CommonErrors.Num]:n(s).toString()},n.prototype.ComputeSIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.sin)},n.prototype.ComputeCOS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.cos)},n.prototype.ComputeTAN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.tan)},n.prototype.ComputeASIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.asin,function(r){return r>=-1&&r<=1})},n.prototype.ComputeACOS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.acos,function(r){return r>=-1&&r<=1})},n.prototype.ComputeATAN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.atan)},n.prototype.ComputeSINH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.sinh)},n.prototype.ComputeCOSH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.cosh)},n.prototype.ComputeTANH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.tanh)},n.prototype.ComputeLOG10=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.log10,function(r){return r>0})},n.prototype.ComputeSQRTPI=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,function(r){return Math.sqrt(r*Math.PI)},function(r){return r>=0})},n.prototype.ComputeATAN2=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:0===o&&0===s?i[r.CommonErrors.DivZero]:Math.atan2(s,o).toString()},n.prototype.ComputeSIGN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:(i>0?1:i<0?-1:0).toString()},n.prototype.ComputeQUOTIENT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:0===s?i[r.CommonErrors.DivZero]:Math.trunc(o/s).toString()},n}(Q),ar=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ur=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ACOSH",category:"Math & Trig",description:"Returns the inverse hyperbolic cosine of a number."},{formulaName:"ASINH",category:"Math & Trig",description:"Returns the inverse hyperbolic sine of a number."},{formulaName:"ATANH",category:"Math & Trig",description:"Returns the inverse hyperbolic tangent of a number."}],t}return ar(n,e),n.prototype.unaryMath=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.resolveNumberArg(e[0]);if("string"==typeof s)return s;if(i&&!i(s))return o[r.CommonErrors.Num];var a=n(s);return isFinite(a)?a.toString():o[r.CommonErrors.Num]},n.prototype.ComputeACOSH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.acosh,function(r){return r>=1})},n.prototype.ComputeASINH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.asinh)},n.prototype.ComputeATANH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.atanh,function(r){return r>-1&&r<1})},n}(Q),lr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),hr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"FACTDOUBLE",category:"Math & Trig",description:"Returns the double factorial of a number."},{formulaName:"MULTINOMIAL",category:"Math & Trig",description:"Returns the multinomial of a set of numbers."},{formulaName:"PERMUT",category:"Math & Trig",description:"Returns the number of permutations for a given number of objects."},{formulaName:"SERIESSUM",category:"Math & Trig",description:"Returns the sum of a power series."},{formulaName:"ROMAN",category:"Math & Trig",description:"Converts an Arabic numeral to Roman, as text."}],t}return lr(n,e),n.prototype.ComputeFACTDOUBLE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=Math.floor(o);if(s<0||s>300)return i[r.CommonErrors.Num];for(var a=1,u=s;u>0;u-=2)a*=u;return a.toString()},n.prototype.ComputeMULTINOMIAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=[],s=0;s<e.length;s++){var a=this.resolveNumberArg(e[s]);if("string"==typeof a)return a;var u=Math.floor(a);if(u<0)return i[r.CommonErrors.Num];o.push(u)}for(var l=o.reduce(function(r,t){return r+t},0),h=1,s=0;s<o.length;s++)h*=N(o[s]);return(N(l)/h).toString()},n.prototype.ComputePERMUT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(o),u=Math.floor(s);if(a<0||u<0||a<u)return i[r.CommonErrors.Num];for(var l=1,h=0;h<u;h++)l*=a-h;return l.toString()},n.prototype.ComputeSERIESSUM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;for(var a=[],u=3;u<e.length;u++){var l=this.resolveNumberArg(e[u]);if("string"==typeof l)return l;a.push(l)}for(var h=0,u=0;u<a.length;u++){var p=o+u*s;h+=a[u]*Math.pow(i,p)}return h.toString()},n.prototype.ComputeROMAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=0;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;if((s=Math.floor(a))<0||s>4)return i[r.CommonErrors.Value]}var u=Math.floor(o);return u<0||u>3999?i[r.CommonErrors.Value]:0===u?"":this.toRoman(u,s)},n.prototype.toRoman=function(r,t){var e=["","M","MM","MMM"],n=[["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]],i=[["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"]],o=[["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"]],s=Math.min(t,4),a=e[Math.floor(r/1e3)];return a+=n[s][Math.floor(r%1e3/100)],a+=i[s][Math.floor(r%100/10)],a+=o[s][r%10],1===t?a=a.replace(/XLV/g,"VL").replace(/XCV/g,"VC").replace(/CDL/g,"LD").replace(/CML/g,"LM").replace(/CMVC/g,"LMVL"):2===t?a=a.replace(/IV/g,"IIII").replace(/IX/g,"VIIII").replace(/XL/g,"XXXX").replace(/XC/g,"LXXXX").replace(/CD/g,"CCCC").replace(/CM/g,"DCCCC"):3===t?a=a.replace(/IV/g,"IIII").replace(/IX/g,"VIIII").replace(/XL/g,"XXXX").replace(/XC/g,"LXXXX").replace(/CD/g,"CCCC").replace(/CM/g,"DCCCC"):4===t&&(a=a.replace(/V/g,"IV").replace(/L/g,"XL").replace(/D/g,"CD")),a},n}(Q),pr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),gr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"GCD",category:"Math & Trig",description:"Returns the greatest common divisor."},{formulaName:"LCM",category:"Math & Trig",description:"Returns the least common multiple."},{formulaName:"MROUND",category:"Math & Trig",description:"Returns a number rounded to the desired multiple."},{formulaName:"COMBIN",category:"Math & Trig",description:"Returns the number of combinations for a given number of objects."},{formulaName:"SUMSQ",category:"Math & Trig",description:"Returns the sum of the squares of the arguments."}],t}return pr(n,e),n.prototype.collectNumbers=function(r){for(var t=this.parent.getErrorStrings(),e=[],n=0;n<r.length;n++){var i=r[n];if(""!==i)if(this.parent.isCellReference(i)&&i.indexOf(":")>-1)for(var o=this.parent.getCellCollection(i),s=Array.isArray(o)?o:[o],a=0;a<s.length;a++){var u=this.parent.getValueFromArg(s[a]);if(t.indexOf(u)>-1)return u;""!==u&&this.parent.isNumber(u)&&e.push(this.parent.parseFloat(u))}else{var l=this.resolveNumberArg(i);if("string"==typeof l)return l;e.push(l)}}return e},n.prototype.gcd2=function(r,t){for(var e=Math.abs(Math.floor(r)),n=Math.abs(Math.floor(t));n;){var i=n;n=e%n,e=i}return e},n.prototype.ComputeGCD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectNumbers(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.Value];for(a=0;a<o.length;a++)if(o[a]<0)return i[r.CommonErrors.Num];for(var s=Math.floor(o[0]),a=1;a<o.length;a++)s=this.gcd2(s,o[a]);return s.toString()},n.prototype.ComputeLCM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectNumbers(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.Value];for(a=0;a<o.length;a++)if(o[a]<0)return i[r.CommonErrors.Num];for(var s=Math.floor(o[0]),a=1;a<o.length;a++){var u=Math.floor(o[a]);s=0===s||0===u?0:Math.abs(s*u)/this.gcd2(s,u)}return s.toString()},n.prototype.ComputeMROUND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:0===s?"0":o>0&&s<0||o<0&&s>0?i[r.CommonErrors.Num]:(Math.round(o/s)*s).toString()},n.prototype.ComputeCOMBIN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(o),u=Math.floor(s);if(a<0||u<0||a<u)return i[r.CommonErrors.Num];for(var l=1,h=1;h<=u;h++)l=l*(a-u+h)/h;return Math.round(l).toString()},n.prototype.ComputeSUMSQ=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=this.collectNumbers(e);if("string"==typeof i)return i;for(var o=0,s=0;s<i.length;s++)o+=i[s]*i[s];return o.toString()},n}(Q),fr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),mr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return fr(e,t),e.prototype.readMatrix=function(t){var e=this.parent.getErrorStrings(),n=t.split("$").join("");if(!this.parent.isCellReference(n.split(":")[0]))return e[r.CommonErrors.Value];var i=Y(n),o=i[2]-i[0]+1,s=i[3]-i[1]+1,a=this.parent.getCellCollection(n),u=Array.isArray(a)?a:[a];if(u.length!==o*s)return e[r.CommonErrors.Value];for(var l=[],h=0;h<o;h++){for(var p=[],g=0;g<s;g++){var f=this.parent.getValueFromArg(u[h*s+g]);if(e.indexOf(f)>-1)return f;if(""===f||!this.parent.isNumber(f))return e[r.CommonErrors.Value];p.push(this.parent.parseFloat(f))}l.push(p)}return l},e.prototype.flattenMatrix=function(r,t){void 0===t&&(t=!1);var e=this.parent.getParseArgumentSeparator(),n=r.length,i=r[0].length,o=[];if(t)for(a=0;a<i;a++)for(s=0;s<n;s++)o.push(r[s][a].toString());else for(var s=0;s<n;s++)for(var a=0;a<i;a++)o.push(r[s][a].toString());return o.join(e)},e.prototype.determinant=function(r){var t=r.length;if(1===t)return r[0][0];if(2===t)return r[0][0]*r[1][1]-r[0][1]*r[1][0];for(var e=0,n=0;n<t;n++){for(var i=[],o=1;o<t;o++){for(var s=[],a=0;a<t;a++)a!==n&&s.push(r[o][a]);i.push(s)}e+=(n%2==0?1:-1)*r[0][n]*this.determinant(i)}return e},e.prototype.inverse=function(r){for(var t=r.length,e=[],n=0;n<t;n++){e.push(r[n].slice());for(l=0;l<t;l++)e[n].push(n===l?1:0)}for(n=0;n<t;n++){for(var i=n,o=n+1;o<t;o++)Math.abs(e[o][n])>Math.abs(e[i][n])&&(i=o);var s=e[n];e[n]=e[i],e[i]=s;var a=e[n][n];if(Math.abs(a)<1e-12)return null;for(l=0;l<2*t;l++)e[n][l]/=a;for(o=0;o<t;o++)if(o!==n)for(var u=e[o][n],l=0;l<2*t;l++)e[o][l]-=u*e[n][l]}for(var h=[],n=0;n<t;n++)h.push(e[n].slice(t));return h},e.prototype.multiply=function(r,t){if(r[0].length!==t.length)return null;for(var e=r.length,n=t[0].length,i=t.length,o=[],s=0;s<e;s++){for(var a=[],u=0;u<n;u++){for(var l=0,h=0;h<i;h++)l+=r[s][h]*t[h][u];a.push(l)}o.push(a)}return o},e}(Q),cr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),dr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"MDETERM",category:"Math & Trig",description:"Returns the matrix determinant of an array."},{formulaName:"MINVERSE",category:"Math & Trig",description:"Returns the matrix inverse of an array."},{formulaName:"MMULT",category:"Math & Trig",description:"Returns the matrix product of two arrays."},{formulaName:"TRANSPOSE",category:"Math & Trig",description:"Returns the transpose of an array."}],t}return cr(n,e),n.prototype.ComputeMDETERM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.readMatrix(e[0]);return"string"==typeof o?o:o.length!==o[0].length?i[r.CommonErrors.Value]:this.determinant(o).toString()},n.prototype.ComputeMINVERSE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.readMatrix(e[0]);if("string"==typeof o)return o;if(o.length!==o[0].length)return i[r.CommonErrors.Value];var s=this.inverse(o);return s?this.flattenMatrix(s):i[r.CommonErrors.Num]},n.prototype.ComputeMMULT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.readMatrix(e[0]),s=this.readMatrix(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.multiply(o,s);return a?this.flattenMatrix(a):i[r.CommonErrors.Value]},n.prototype.ComputeTRANSPOSE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.readMatrix(e[0]);return"string"==typeof i?i:this.flattenMatrix(i,!0)},n}(mr),vr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Nr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"BIN2DEC",category:"Engineering",description:"Converts a binary number to decimal."},{formulaName:"BIN2HEX",category:"Engineering",description:"Converts a binary number to hexadecimal."},{formulaName:"BIN2OCT",category:"Engineering",description:"Converts a binary number to octal."},{formulaName:"DEC2BIN",category:"Engineering",description:"Converts a decimal number to binary."},{formulaName:"DEC2HEX",category:"Engineering",description:"Converts a decimal number to hexadecimal."},{formulaName:"DEC2OCT",category:"Engineering",description:"Converts a decimal number to octal."},{formulaName:"HEX2BIN",category:"Engineering",description:"Converts a hexadecimal number to binary."},{formulaName:"HEX2DEC",category:"Engineering",description:"Converts a hexadecimal number to decimal."},{formulaName:"HEX2OCT",category:"Engineering",description:"Converts a hexadecimal number to octal."},{formulaName:"OCT2BIN",category:"Engineering",description:"Converts an octal number to binary."},{formulaName:"OCT2DEC",category:"Engineering",description:"Converts an octal number to decimal."},{formulaName:"OCT2HEX",category:"Engineering",description:"Converts an octal number to hexadecimal."}],t}return vr(n,e),n.prototype.parseBaseNumber=function(t,e){var n=this.parent.getErrorStrings(),i=t.trim().toUpperCase();if(""===i)return n[r.CommonErrors.Num];if(!(16===e?/^[0-9A-F]+$/:2===e?/^[01]+$/:/^[0-7]+$/).test(i))return n[r.CommonErrors.Num];var o=parseInt(i,e);return isNaN(o)?n[r.CommonErrors.Num]:o},n.prototype.resolveBaseArg=function(r,t){var e=this.parent.getErrorStrings(),n=this.resolveTextArg(r);return e.indexOf(n)>-1?n:this.parseBaseNumber(n,t)},n.prototype.formatToBase=function(t,e,n){var i=this.parent.getErrorStrings(),o=Math.trunc(t),s={2:{min:-512,max:511,maxPlaces:10},8:{min:-536870912,max:536870911,maxPlaces:10},10:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,maxPlaces:0},16:{min:-549755813888,max:549755813887,maxPlaces:10}}[e];if(o<s.min||o>s.max)return i[r.CommonErrors.Num];o<0&&(!0,o=(1<<(n&&n>0?n:10))+o);var a=o.toString(e).toUpperCase();if(void 0!==n&&n>0){if(n>s.maxPlaces)return i[r.CommonErrors.Num];for(;a.length<n;)a="0"+a}return a},n.prototype.ComputeBIN2DEC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveBaseArg(e[0],2);if("string"==typeof i)return i;var o=this.resolveTextArg(e[0]).trim();if(o.length>10)return this.parent.getErrorStrings()[r.CommonErrors.Num];var s=i;return 10===o.length&&"1"===o.charAt(0)&&(s=parseInt(o,2)-1024),s.toString()},n.prototype.ComputeBIN2HEX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.binTo(r,16)},n.prototype.ComputeBIN2OCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.binTo(r,8)},n.prototype.binTo=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.ComputeBIN2DEC(e[0]);if("string"==typeof o&&i.indexOf(o)>-1)return o;var s;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=Math.floor(a)}return this.formatToBase(parseInt(o.toString(),10),n,s)},n.prototype.ComputeDEC2BIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.decTo(r,2)},n.prototype.ComputeDEC2HEX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.decTo(r,16)},n.prototype.ComputeDEC2OCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.decTo(r,8)},n.prototype.decTo=function(e,n){if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o;if(2===e.length){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=Math.floor(s)}return this.formatToBase(Math.trunc(i),n,o)},n.prototype.ComputeHEX2DEC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveTextArg(e[0]).trim().toUpperCase(),o=this.parseBaseNumber(i,16);if("string"==typeof o)return o;if(i.length>10)return this.parent.getErrorStrings()[r.CommonErrors.Num];var s=o;return 10===i.length&&parseInt(i.charAt(0),16)>=8&&(s=parseInt(i,16)-256),s.toString()},n.prototype.ComputeHEX2BIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,2,this.ComputeHEX2DEC.bind(this))},n.prototype.ComputeHEX2OCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,8,this.ComputeHEX2DEC.bind(this))},n.prototype.ComputeOCT2DEC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveTextArg(e[0]).trim(),o=this.parseBaseNumber(i,8);if("string"==typeof o)return o;if(i.length>10)return this.parent.getErrorStrings()[r.CommonErrors.Num];var s=o;return 10===i.length&&i.charAt(0)>="4"&&(s=parseInt(i,8)-(1<<30)),s.toString()},n.prototype.ComputeOCT2BIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,2,this.ComputeOCT2DEC.bind(this))},n.prototype.ComputeOCT2HEX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,16,this.ComputeOCT2DEC.bind(this))},n.prototype.hexOctTo=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=i(e[0]);if("string"==typeof s&&o.indexOf(s)>-1)return s;var a;if(2===e.length){var u=this.resolveNumberArg(e[1]);if("string"==typeof u)return u;a=Math.floor(u)}return this.formatToBase(parseInt(s.toString(),10),n,a)},n}(Q),Er=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Sr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DELTA",category:"Engineering",description:"Tests whether two values are equal."},{formulaName:"GESTEP",category:"Engineering",description:"Tests whether a number is greater than a threshold."},{formulaName:"ERF",category:"Engineering",description:"Returns the error function."},{formulaName:"ERFC",category:"Engineering",description:"Returns the complementary error function."}],t}return Er(n,e),n.prototype.ComputeDELTA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=0;if(2===e.length){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=s}return(i===o?1:0).toString()},n.prototype.ComputeGESTEP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=0;if(2===e.length){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=s}return(i>=o?1:0).toString()},n.prototype.ComputeERF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(1===e.length){var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:g(i).toString()}var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:(g(s)-g(o)).toString()},n.prototype.ComputeERFC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:f(i).toString()},n}(Q),yr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Cr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CONVERT",category:"Engineering",description:"Converts a number from one measurement system to another."}],t}return yr(n,e),n.prototype.ComputeCONVERT=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.resolveNumberArg(e[0]);if("string"==typeof s)return s;var a=this.resolveTextArg(e[1]).toLowerCase(),u=this.resolveTextArg(e[2]).toLowerCase();if(o.indexOf(a)>-1)return a;if(o.indexOf(u)>-1)return u;if(a===u)return s.toString();if("c"===a&&"f"===u)return(9*s/5+32).toString();if("f"===a&&"c"===u)return(5*(s-32)/9).toString();for(var l=0,h=n.UNITS;l<h.length;l++){var p=h[l];if(p.from===a&&p.to===u&&!isNaN(p.factor))return(s*p.factor).toString()}var g=n.UNITS.find(function(r){return r.from===a&&!isNaN(r.factor)}),f=g?g.to:void 0,m=n.UNITS.find(function(r){return r.to===u&&r.from===f&&!isNaN(r.factor)});return g&&m?(s*g.factor*m.factor).toString():o[r.CommonErrors.NA]},n.UNITS=[{from:"g",to:"kg",factor:.001},{from:"kg",to:"g",factor:1e3},{from:"lbm",to:"kg",factor:.45359237},{from:"kg",to:"lbm",factor:2.2046226218},{from:"m",to:"ft",factor:3.280839895},{from:"ft",to:"m",factor:.3048},{from:"in",to:"m",factor:.0254},{from:"m",to:"in",factor:39.37007874},{from:"mi",to:"m",factor:1609.344},{from:"m",to:"mi",factor:1/1609.344},{from:"yr",to:"day",factor:365.25},{from:"day",to:"yr",factor:1/365.25},{from:"hr",to:"sec",factor:3600},{from:"sec",to:"hr",factor:1/3600},{from:"C",to:"F",factor:NaN},{from:"F",to:"C",factor:NaN},{from:"l",to:"m3",factor:.001},{from:"m3",to:"l",factor:1e3},{from:"N",to:"lbf",factor:.224808943},{from:"lbf",to:"N",factor:4.4482216153}],n}(Q),br=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ar=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"BESSELI",category:"Engineering",description:"Returns the modified Bessel function In(x)."},{formulaName:"BESSELJ",category:"Engineering",description:"Returns the Bessel function Jn(x)."},{formulaName:"BESSELK",category:"Engineering",description:"Returns the modified Bessel function Kn(x)."},{formulaName:"BESSELY",category:"Engineering",description:"Returns the Bessel function Yn(x)."}],t}return br(n,e),n.prototype.besselArgs=function(e){var n=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);return"string"==typeof i?i:"string"==typeof o?o:o<0?n[r.CommonErrors.Num]:{x:i,n:Math.floor(o)}},n.prototype.ComputeBESSELI=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.besselArgs(t);if("string"==typeof n)return n;var i=V(n.n,n.x);return isFinite(i)?i.toString():this.parent.getErrorStrings()[r.CommonErrors.Num]},n.prototype.ComputeBESSELJ=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.besselArgs(r);return"string"==typeof e?e:I(e.n,e.x).toString()},n.prototype.ComputeBESSELK=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.besselArgs(t);if("string"==typeof i)return i;if(i.x<=0)return n[r.CommonErrors.Num];var o=R(i.n,i.x);return isFinite(o)?o.toString():n[r.CommonErrors.Num]},n.prototype.ComputeBESSELY=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.besselArgs(t);if("string"==typeof i)return i;if(i.x<=0)return n[r.CommonErrors.Num];var o=D(i.n,i.x);return isFinite(o)?o.toString():n[r.CommonErrors.Num]},n}(Q),Or=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Fr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"FV",category:"Financial",description:"Returns the future value of an investment."},{formulaName:"PV",category:"Financial",description:"Returns the present value of an investment."},{formulaName:"PMT",category:"Financial",description:"Returns the periodic payment for an annuity."},{formulaName:"NPER",category:"Financial",description:"Returns the number of periods for an investment."},{formulaName:"IPMT",category:"Financial",description:"Returns the interest payment for an investment for a given period."},{formulaName:"PPMT",category:"Financial",description:"Returns the payment on the principal for an investment for a given period."},{formulaName:"NPV",category:"Financial",description:"Returns the net present value of an investment based on periodic cash flows."},{formulaName:"RATE",category:"Financial",description:"Returns the interest rate per period of an annuity."}],t}return Or(n,e),n.prototype.resolveOptional=function(r,t,e){return r.length<=t||""===r[t]?e:this.resolveNumberArg(r[t])},n.prototype.ComputeFV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveOptional(e,3,0),u=this.resolveOptional(e,4,0);if("string"==typeof a)return a;if("string"==typeof u)return u;if(0===i)return(-a-s*o).toString();var l=Math.pow(1+i,o);return(-a*l-s*(1+i*(u?1:0))*(l-1)/i).toString()},n.prototype.ComputePV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveOptional(e,3,0),u=this.resolveOptional(e,4,0);if("string"==typeof a)return a;if("string"==typeof u)return u;if(0===i)return(-a-s*o).toString();var l=Math.pow(1+i,o);return((-a-s*(1+i*(u?1:0))*(l-1)/i)/l).toString()},n.prototype.ComputePMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveOptional(e,3,0),u=this.resolveOptional(e,4,0);if("string"==typeof a)return a;if("string"==typeof u)return u;if(0===i)return(-s-a)/o;var l=Math.pow(1+i,o);return(i*(a+s*l)/((1+i*(u?1:0))*(1-l))).toString()},n.prototype.ComputeNPER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=this.resolveOptional(e,3,0),l=this.resolveOptional(e,4,0);if("string"==typeof u)return u;if("string"==typeof l)return l;if(0===o)return 0===s?i[r.CommonErrors.Num]:(-(a+u)/s).toString();var h=l?1:0,p=s*(1+o*h)/o-u,g=a+s*(1+o*h)/o;return 0===g||p/g<=0?i[r.CommonErrors.Num]:(Math.log(p/g)/Math.log(1+o)).toString()},n.prototype.ComputeIPMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=this.resolveOptional(e,4,0),l=this.resolveOptional(e,5,0);if("string"==typeof u)return u;if("string"==typeof l)return l;var h=this.ComputePMT(i.toString(),s.toString(),a.toString(),u.toString(),l.toString());if("string"==typeof h&&this.parent.getErrorStrings().indexOf(h)>-1)return h;for(var p=parseFloat(h.toString()),g=a,f=1;f<o;f++)g=g*(1+i)+p;return(g*i).toString()},n.prototype.ComputePPMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.ComputeIPMT.apply(this,e);if("string"==typeof i&&this.parent.getErrorStrings().indexOf(i)>-1)return i;var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveOptional(e,4,0),l=this.resolveOptional(e,5,0),h=this.ComputePMT(o.toString(),s.toString(),a.toString(),("number"==typeof u?u:0).toString(),("number"==typeof l?l:0).toString());return(parseFloat(h.toString())-parseFloat(i.toString())).toString()},n.prototype.ComputeNPV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;for(var o=0,s=1;s<e.length;s++){var a=this.resolveNumberArg(e[s]);if("string"==typeof a)return a;o+=a/Math.pow(1+i,s)}return o.toString()},n.prototype.ComputeRATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=this.resolveOptional(e,3,0),l=this.resolveOptional(e,4,0),h=this.resolveOptional(e,5,.1);if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;for(var p=h,g=0;g<100;g++){var f=l?1:0,m=Math.pow(1+p,o),c=a*m+s*(1+p*f)*(m-1)/p+u,d=o*a*Math.pow(1+p,o-1)+s*(1+p*f)*(o*Math.pow(1+p,o-1)*p-(m-1))/(p*p)+s*f*(m-1)/p;if(Math.abs(d)<1e-12)break;var v=p-c/d;if(Math.abs(v-p)<1e-10)return v.toString();p=v}return i[r.CommonErrors.Num]},n}(Q),xr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Vr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SLN",category:"Financial",description:"Returns the straight-line depreciation of an asset for one period."},{formulaName:"SYD",category:"Financial",description:"Returns the sum-of-years digits depreciation for a specified period."},{formulaName:"DB",category:"Financial",description:"Returns the depreciation of an asset for a period using fixed-declining balance."},{formulaName:"DDB",category:"Financial",description:"Returns the depreciation of an asset for a period using double-declining balance."}],t}return xr(n,e),n.prototype.ComputeSLN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);return"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:0===a?i[r.CommonErrors.DivZero]:((o-s)/a).toString()},n.prototype.ComputeSYD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||4!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);return"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:"string"==typeof u?u:a<=0||u<=0||u>a?i[r.CommonErrors.Num]:((o-s)*(a-u+1)/(a*(a+1)/2)).toString()},n.prototype.ComputeDB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=12;if(5===e.length){var h=this.resolveNumberArg(e[4]);if("string"==typeof h)return h;l=Math.floor(h)}if(a<=0||u<=0)return i[r.CommonErrors.Num];for(var p=1-Math.pow(s/o,1/a),g=0,f=1;f<=Math.floor(u);f++)g+=d=(o-g)*p*(1===f?l/12:1);var m=u-Math.floor(u);if(m>0&&(g+=(o-g)*p*m),1===Math.floor(u))return g.toString();for(var c=0,f=1;f<Math.floor(u);f++){var d=(o-c)*p*(1===f?l/12:1);c+=d}return(g-c).toString()},n.prototype.ComputeDDB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=2;if(5===e.length){var h=this.resolveNumberArg(e[4]);if("string"==typeof h)return h;l=h}if(a<=0||u<=0)return i[r.CommonErrors.Num];for(var p=l/a,g=o,f=0,m=1;m<=Math.floor(u);m++)g-=f=Math.min(g*p,g-s);var c=u-Math.floor(u);return c>0&&(f=Math.min(g*p*c,(g-s)*c)),f.toString()},n}(Q),Ir=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Rr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"EFFECT",category:"Financial",description:"Returns the effective annual interest rate."},{formulaName:"NOMINAL",category:"Financial",description:"Returns the nominal annual interest rate."},{formulaName:"FVSCHEDULE",category:"Financial",description:"Returns the future value of an initial principal after applying compound interest rates."}],t}return Ir(n,e),n.prototype.ComputeEFFECT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:s<1?i[r.CommonErrors.Num]:(Math.pow(1+o/s,s)-1).toString()},n.prototype.ComputeNOMINAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:s<1?i[r.CommonErrors.Num]:(s*(Math.pow(1+o,1/s)-1)).toString()},n.prototype.ComputeFVSCHEDULE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;for(var o=i,s=1;s<e.length;s++){var a=this.resolveNumberArg(e[s]);if("string"==typeof a)return a;o*=1+a}return o.toString()},n}(Q),Tr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Mr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"IRR",category:"Financial",description:"Returns the internal rate of return for a series of cash flows."},{formulaName:"MIRR",category:"Financial",description:"Returns the modified internal rate of return for cash flows."}],t}return Tr(n,e),n.prototype.collectCashflows=function(r){for(var t=this.parent.getErrorStrings(),e=[],n=0;n<r.length;n++){var i=r[n];if(""!==i)if(this.parent.isCellReference(i)&&i.indexOf(":")>-1)for(var o=this.parent.getCellCollection(i),s=Array.isArray(o)?o:[o],a=0;a<s.length;a++){var u=this.parent.getValueFromArg(s[a]);if(t.indexOf(u)>-1)return u;""!==u&&this.parent.isNumber(u)&&e.push(this.parent.parseFloat(u))}else{var l=this.resolveNumberArg(i);if("string"==typeof l)return l;e.push(l)}}return e},n.prototype.npvAtRate=function(r,t){for(var e=0,n=0;n<r.length;n++)e+=r[n]/Math.pow(1+t,n);return e},n.prototype.npvDerivative=function(r,t){for(var e=0,n=1;n<r.length;n++)e-=n*r[n]/Math.pow(1+t,n+1);return e},n.prototype.ComputeIRR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=.1,s=e;if(2===e.length&&this.parent.isCellReference(e[0])){var a=this.resolveNumberArg(e[1]);"number"==typeof a&&(o=a,s=[e[0]])}var u=this.collectCashflows(s);if("string"==typeof u)return u;if(u.length<2)return i[r.CommonErrors.Num];for(var l=!1,h=!1,p=0;p<u.length;p++)u[p]>0&&(l=!0),u[p]<0&&(h=!0);if(!l||!h)return i[r.CommonErrors.Num];for(var g=o,f=0;f<100;f++){var m=this.npvAtRate(u,g),c=this.npvDerivative(u,g);if(Math.abs(c)<1e-12)break;var d=g-m/c;if(Math.abs(d-g)<1e-10)return d.toString();g=d}return i[r.CommonErrors.Num]},n.prototype.ComputeMIRR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.collectCashflows([e[0]]);if("string"==typeof a)return a;if(a.length<2)return i[r.CommonErrors.Num];for(var u=a.length-1,l=0,h=0,p=0;p<a.length;p++){var g=a[p];g>=0?h+=g*Math.pow(1+s,u-p):l+=g/Math.pow(1+o,p)}return 0===l||0===h?i[r.CommonErrors.DivZero]:(Math.pow(-h/l,1/u)-1).toString()},n}(Q),Dr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ur=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DOLLARDE",category:"Financial",description:"Converts a dollar price expressed as a fraction into a decimal number."},{formulaName:"DOLLARFR",category:"Financial",description:"Converts a dollar price expressed as a decimal number into a fraction."},{formulaName:"DISC",category:"Financial",description:"Returns the discount rate for a security."},{formulaName:"DURATION",category:"Financial",description:"Returns the annual duration of a security with periodic interest payments."},{formulaName:"INTRATE",category:"Financial",description:"Returns the interest rate for a fully invested security."},{formulaName:"RECEIVED",category:"Financial",description:"Returns the amount received at maturity for a fully invested security."},{formulaName:"CUMIPMT",category:"Financial",description:"Returns the cumulative interest paid between two periods."},{formulaName:"CUMPRINC",category:"Financial",description:"Returns the cumulative principal paid on a loan between two periods."},{formulaName:"VDB",category:"Financial",description:"Returns the depreciation of an asset for a period using the declining balance method."},{formulaName:"XIRR",category:"Financial",description:"Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic."}],t}return Dr(n,e),n.prototype.ComputeDOLLARDE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(s);if(a<=0)return i[r.CommonErrors.Num];var u=Math.trunc(o);return(u+(o-u)*Math.pow(10,Math.ceil(Math.log10(a)))/a).toString()},n.prototype.ComputeDOLLARFR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(s);if(a<=0)return i[r.CommonErrors.Num];var u=Math.trunc(o);return(u+(o-u)*a/Math.pow(10,Math.ceil(Math.log10(a)))).toString()},n.prototype.ComputeDISC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.max(s-o,1),l=3===(e.length>=5?this.resolveNumberArg(e[4]):0)?365:360;return a<=0?i[r.CommonErrors.Num]:((1-a/100)*l/u).toString()},n.prototype.ComputeDURATION=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<5||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[3]),o=this.resolveNumberArg(e[4]);return"string"==typeof i?i:"string"==typeof o?o:(1/(e.length>=6?this.resolveNumberArg(e[5]):2)).toString()},n.prototype.ComputeINTRATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=Math.max(s-o,1),h=3===(e.length>=5?this.resolveNumberArg(e[4]):0)?365:360;return a<=0?i[r.CommonErrors.Num]:((u-a)/a*h/l).toString()},n.prototype.ComputeRECEIVED=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);return"string"==typeof i?i:"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:(s*(1+a*Math.max(o-i,1)/(3===(e.length>=5?this.resolveNumberArg(e[4]):0)?365:360))).toString()},n.prototype.ComputeCUMIPMT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.cumIpmtPrinc(r,!0)},n.prototype.ComputeCUMPRINC=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.cumIpmtPrinc(r,!1)},n.prototype.cumIpmtPrinc=function(e,n){if(t.isNullOrUndefined(e)||6!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]),l=this.resolveNumberArg(e[5]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;for(var h=parseFloat(this.computePmt(i,o,s,l)),p=s,g=0,f=1;f<=u;f++){var m=p*i,c=h-m;f>=a&&(g+=n?m:c),p+=h}return g.toString()},n.prototype.computePmt=function(r,t,e,n){if(0===r)return(-e/t).toString();var i=Math.pow(1+r,t);return(r*e*i/((1+r*(n?1:0))*(1-i))).toString()},n.prototype.ComputeVDB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<5||e.length>7)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=2;if(e.length>=6&&""!==e[5]){var h=this.resolveNumberArg(e[5]);if("string"==typeof h)return h;l=h}for(var p=l/s,g=i,f=0,m=1;m<=Math.floor(u);m++)g-=f=Math.min(g*p,g-o);var c=0;g=i;for(m=1;m<=u;m++)f=Math.min(g*p,g-o),m>a&&(c+=f),g-=f;return c.toString()},n.prototype.ComputeXIRR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=[],s=[],a=.1,u=e[e.length-1];if(e.length>=3&&!this.parent.isCellReference(u)){var l=this.resolveNumberArg(u);"number"==typeof l&&(a=l)}var h=e[0],p=e[1],g=this.parent.getCellCollection(h),f=this.parent.getCellCollection(p),m=Array.isArray(g)?g:[g],c=Array.isArray(f)?f:[f];if(m.length!==c.length||m.length<2)return i[r.CommonErrors.Num];for(var d=0;d<m.length;d++){var v=this.parent.getValueFromArg(m[d]),N=this.parent.getValueFromArg(c[d]);if(i.indexOf(v)>-1)return v;if(i.indexOf(N)>-1)return N;o.push(this.parent.parseFloat(v)),s.push(this.parent.parseFloat(N))}for(var E=s[0],S=function(r){for(var t=0,e=0;e<o.length;e++)t+=o[e]/Math.pow(1+r,(s[e]-E)/365);return t},y=a,C=0;C<100;C++){var b=S(y),A=(S(y+1e-7)-b)/1e-7;if(Math.abs(A)<1e-12)break;var O=y-b/A;if(Math.abs(O-y)<1e-10)return O.toString();y=O}return i[r.CommonErrors.Num]},n}(Q),wr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),jr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"AVERAGE",category:"Statistical",description:"The sum of the numbers divided by how many numbers are being averaged."},{formulaName:"AVERAGEIF",category:"Statistical",description:"Computes the average of the numbers in a range that meet the supplied criteria."},{formulaName:"AVERAGEA",category:"Statistical",description:"Calculates the average of values in the list of arguments.Arguments can be numbers, names, arrays or references."},{formulaName:"AVERAGEIFS",category:"Statistical",description:"Conditionally returns the average of the contents of cells for the set of ranges."},{formulaName:"COUNT",category:"Statistical",description:"Counts the numbers in the list of arguments, exclude text entries."},{formulaName:"COUNTA",category:"Statistical",description:"Counts the non-empty values in the list of arguments."},{formulaName:"COUNTIF",category:"Statistical",description:"Counts the number of cells in a range that meet a specified condition."},{formulaName:"COUNTIFS",category:"Statistical",description:"Counts the number of times each cells in all the ranges that meet the specific conditions."},{formulaName:"COUNTBLANK",category:"Statistical",description:"Returns the number of empty cells in a specified range of cells."},{formulaName:"MIN",category:"Statistical",description:"Returns the smaller number in set of arguments."},{formulaName:"MAX",category:"Statistical",description:"Returns the largest number in set of arguments."}],t}return wr(n,e),n.prototype.ComputeAVERAGE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=e,s=0;s<o.length;s++)if(o[s].indexOf(":")>-1&&o[s].indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];return this.parent.calculateAvg(o,i)},n.prototype.ComputeAVERAGEIF=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t;if(n[0].indexOf(":")<0&&!this.parent.isCellReference(n[0]))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];var i=this.parent.computeSumIfAndAvgIf(t,!0);return 0===i[1]||"NaN"===i[0].toString()?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Div]:"string"==typeof i&&(this.parent.formulaErrorStrings.indexOf(i)||this.parent.getErrorStrings().indexOf(i))?i:this.parent.parseFloat(i[0])/this.parent.parseFloat(i[1])},n.prototype.ComputeAVERAGEA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var i,o,s,a,u=e,l=0,h=0,p=0;p<u.length;p++)if(this.parent.isCellReference(u[p]))if(u[p].indexOf(":")>-1){i=this.parent.getCellCollection(u[p].split(this.parent.tic).join(""));for(var g=0;g<i.length;g++){if(o=this.parent.getValueFromArg(i[g]),o=this.processLogicalCellValue(o),this.parent.getErrorStrings().indexOf(o)>-1)return o;t.isNullOrUndefined(o)||""===o||(a=this.parent.parseFloat(o),l+=o=isNaN(a)?0:a,h+=1)}}else{if(o=this.parent.getValueFromArg(u[p]),o=this.processLogicalCellValue(o),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(t.isNullOrUndefined(o)||""===o)continue;a=this.parent.parseFloat(o),l+=o=isNaN(a)?0:a,h+=1}else{if(u[p].indexOf(this.parent.tic)>-1&&(isNaN(this.parent.parseFloat(u[p].split(this.parent.tic).join("")))||""===u[p].split(this.parent.tic).join("").trim()))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(u[p]=this.processLogicalCellValue(u[p]),s=this.parent.getValueFromArg(u[p].split(this.parent.tic).join("")),this.parent.getErrorStrings().indexOf(s)>-1)return s;l+=this.parent.parseFloat(s),h+=1}return 0===h?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:l/h},n.prototype.processLogicalCellValue=function(r){var t=r;return t.toUpperCase()===this.parent.trueValue?t="1":t.toUpperCase()===this.parent.falseValue&&(t="0"),t},n.prototype.ComputeAVERAGEIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.calculateIFS(r,this.parent.trueValue)},n.prototype.ComputeCOUNT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o,s,a,u,l=e,h=0,p=0;p<l.length;p++)if(o=l[p],this.parent.isCellReference(o))if(o.indexOf(":")>-1){s=this.parent.getCellCollection(o.split(this.parent.tic).join(""));for(var g=0;g<s.length;g++)a=i?this.parent.getValueFromArg(s[g],null,null,!0):this.parent.getValueFromArg(s[g]),i&&a.includes("SUBTOTAL(")||isNaN(this.parent.parseFloat(a))||o.length>0&&""!==a.trim()&&h++}else{if(a=i?this.parent.getValueFromArg(o,null,null,!0):this.parent.getValueFromArg(o),i&&a.includes("SUBTOTAL("))continue;isNaN(this.parent.parseFloat(a))||o.length>0&&""!==a.trim()&&h++}else u=this.parent.getValueFromArg(o).split(this.parent.tic).join(""),0===o.length&&""===u.trim()?h++:isNaN(this.parent.parseFloat(u))&&o!==this.parent.trueValue&&o!==this.parent.falseValue||o.length>0&&""!==o.trim()&&""!==u.trim()&&h++;return h},n.prototype.ComputeCOUNTA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o,s,a,u=e,l=0,h=0;h<u.length;h++)if(this.parent.isCellReference(u[h]))if(u[h].indexOf(":")>-1){o=this.parent.getCellCollection(u[h].split(this.parent.tic).join(""));for(var p=0;p<o.length;p++)s=i?this.parent.getValueFromArg(o[p],null,null,!0):this.parent.getValueFromArg(o[p]),i&&s.includes("SUBTOTAL(")||s.length>0&&l++}else{if(s=i?this.parent.getValueFromArg(u[h],null,null,!0):this.parent.getValueFromArg(u[h]),i&&s.includes("SUBTOTAL("))continue;s.length>0&&l++}else(a=this.parent.getValueFromArg(u[h]).split(this.parent.tic).join("")).length>0?l++:0===a.length&&""===a.trim()&&l++;return l},n.prototype.ComputeCOUNTIF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;if(t.isNullOrUndefined(e)||""===e[0]||2!==i.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(i[0].indexOf(":")<0&&!this.parent.isCellReference(i[0]))return this.parent.getErrorStrings()[r.CommonErrors.Name];var o,s,a=0,u=[],l="equal";if(""===i[1])return 0;var h=i[1].startsWith(this.parent.tic)&&i[1].endsWith(this.parent.tic),p=this.parent.getANDComputedValue(i[1]),g=p.includes("*"),f="*"===p||"<>*"===p,m=g&&!f?p.replace(/\*/g,"").trim():p,c=!1;if(!h&&this.parent.isCellReference(m)&&(m=this.parent.getValueFromArg(m),c=!0),g&&!f){var d=p.indexOf("*");"*"===p[0]&&(m="*"+m),"*"===p[p.length-1]&&(m+="*"),d>0&&d<p.length-1&&(m=p.substring(0,d)+"*"+p.substring(d+1))}(p=m).startsWith("<=")?(l="lessEq",p=p.substring(2)):p.startsWith(">=")?(l="greaterEq",p=p.substring(2)):p.startsWith("<>")?(l="notEq",p=p.substring(2)):p.startsWith("<")?(l="less",p=p.substring(1)):p.startsWith(">")?(l="greater",p=p.substring(1)):p.startsWith("=")&&(l="equal",p=p.substring(1));var v=p.indexOf("*")>-1||p.indexOf("?")>-1;if((!h&&this.parent.isCellReference(p)&&!c||p.includes(this.parent.arithMarker)||p.includes(this.parent.getParseDecimalSeparator())&&!v)&&(p=this.parent.getValueFromArg(p)),this.parent.isCellReference(i[0])){o=this.parent.getCellCollection(i[0].split(this.parent.tic).join(""));for(var N=0;N<o.length;N++)s=this.parent.getValueFromArg(o[N]),v&&(s=this.parent.findWildCardValue(p.toLowerCase(),s.toLowerCase())),u.push(s),u.push(p),this.parent.processLogical(u,l)===this.parent.trueValue&&a++}return a},n.prototype.ComputeCOUNTIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parent.computeCountIfsFormulas(r)},n.prototype.ComputeCOUNTBLANK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=0;if(1!==e.length||t.isNullOrUndefined(e)||!this.parent.isCellReference(e[0]))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0])return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var o=this.parent.getCellCollection(e[0]),s=0;s<o.length;s++)""===this.parent.getValueFromArg(o[s])&&i++;return i},n.prototype.ComputeMIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parent.computeMinMax(r,"min")},n.prototype.ComputeMAX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parent.computeMinMax(r,"max")},n}(Q),Lr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),kr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SMALL",category:"Statistical",description:"Returns the k-th smallest value in a given array."},{formulaName:"LARGE",category:"Statistical",description:"Returns the k-th largest value in a given array."},{formulaName:"MEDIAN",category:"Statistical",description:"Returns the median of the given set of numbers."},{formulaName:"SLOPE",category:"Statistical",description:"Returns the slope of the line from linear regression of the data points."},{formulaName:"INTERCEPT",category:"Statistical",description:"Calculates the point of the Y-intercept line via linear regression."},{formulaName:"RSQ",category:"Statistical",description:"Returns the square of the Pearson product moment correlation coefficient based on data points in known_ys and known_xs."},{formulaName:"GEOMEAN",category:"Statistical",description:"Returns the geometric mean of an array or range of positive data."}],t}return Lr(n,e),n.prototype.ComputeMEDIAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=[];if(t.isNullOrUndefined(e)||""===e[0]&&1===e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var s=0;s<e.length;s++)if(this.parent.isCellReference(e[s]))if(e[s].indexOf(":")>-1)for(var a=this.parent.getCellCollection(e[s]),u=0;u<a.length;u++){var l=this.parent.getValueFromArg(a[u]);if(this.parent.getErrorStrings().indexOf(l)>-1)return l;""!==l.trim()&&o.push(this.parent.parseFloat(l))}else{var h=this.parent.getValueFromArg(e[s]);if(this.parent.getErrorStrings().indexOf(h)>-1)return h;""!==h.trim()&&o.push(this.parent.parseFloat(h))}else if(""===e[s]||e[s]===this.parent.falseValue&&!this.parent.isCellReference(e[s]))o.push(0);else if(e[s]!==this.parent.trueValue||this.parent.isCellReference(e[s])){if(e[s].indexOf(this.parent.tic)>-1&&isNaN(parseFloat(e[s].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var p=this.parent.getValueFromArg(e[s]).split(this.parent.tic).join("");if(this.parent.getErrorStrings().indexOf(p)>-1)return p;o.push(this.parent.parseFloat(p))}else o.push(1);for(var g=(o=o.sort(function(r,t){return r-t})).length,f=0;f<g&&(!isNaN(o[f])||(o.splice(f,1),g=o.length,f--,0!==o.length));f++);if(o.length%2==0||isNaN(o[parseInt((o.length/2).toString(),10)])){if(isNaN(o[o.length/2])||isNaN(o[o.length/2-1]))return this.parent.getErrorStrings()[r.CommonErrors.Num];i=(o[o.length/2]+o[o.length/2-1])/2}else i=o[parseInt((o.length/2).toString(),10)];return i},n.prototype.ComputeSMALL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length||""===e[0])return""===e[0]&&""===e[1]?i[r.CommonErrors.Num]:this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=[],s=[],a=[];if(!t.isNullOrUndefined(e[0])){var u=void 0;if(this.parent.isCellReference(e[0])){o=this.parent.getCellCollection(e[0]);for(l=0;l<o.length;l++){if(u=this.parent.getValueFromArg(o[l]),i.indexOf(u)>-1)return u;s.push(u)}}else{if(u=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),i.indexOf(u)>-1)return u;s.push(u)}for(var l=0;l<s.length;l++)""===s[l]||isNaN(this.parent.parseFloat(s[l]))||a.push(this.parent.parseFloat(s[l]));if(0===a.length&&(t.isNullOrUndefined(s[0])||e[0].indexOf(this.parent.tic)>-1))return i[r.CommonErrors.Value]}a=a.sort(function(r,t){return r-t});var h;if(!t.isNullOrUndefined(e[1])){if(this.parent.isCellReference(e[1])){if(""===(h=this.parent.getValueFromArg(e[1])))return i[r.CommonErrors.Num];if(""===h.trim())return i[r.CommonErrors.Value];h.toUpperCase()===this.parent.trueValue?h="1":h.toUpperCase()===this.parent.falseValue&&(h="0")}else h=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");if(i.indexOf(h)>-1)return h;if(""===h.trim())return e[1].length>0?i[r.CommonErrors.Value]:i[r.CommonErrors.Num];if(isNaN(this.parent.parseFloat(h)))if(e[1].toUpperCase()===this.parent.trueValue)h="1";else{if(e[1].toUpperCase()!==this.parent.falseValue)return i[r.CommonErrors.Value];h="0"}}var p=Number(h)<1?0:Math.floor(Number(h));return t.isNullOrUndefined(a[p-1])&&!isNaN(Number(p))?i[r.CommonErrors.Num]:a[p-1]},n.prototype.ComputeLARGE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length||""===e[0])return""===e[0]&&""===e[1]?i[r.CommonErrors.Num]:this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=[],s=[],a=[];if(!t.isNullOrUndefined(e[0])){var u=void 0;if(this.parent.isCellReference(e[0])){o=this.parent.getCellCollection(e[0]);for(l=0;l<o.length;l++){if(u=this.parent.getValueFromArg(o[l]),i.indexOf(u)>-1)return u;s.push(u)}}else{if(u=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),i.indexOf(u)>-1)return u;s.push(u)}for(var l=0;l<s.length;l++)""===s[l]||isNaN(this.parent.parseFloat(s[l]))||a.push(this.parent.parseFloat(s[l]));if(0===a.length&&(t.isNullOrUndefined(s[0])||e[0].indexOf(this.parent.tic)>-1))return i[r.CommonErrors.Value]}a=a.sort(function(r,t){return t-r});var h;if(!t.isNullOrUndefined(e[1])){if(this.parent.isCellReference(e[1])){if(""===(h=this.parent.getValueFromArg(e[1])))return i[r.CommonErrors.Num];if(""===h.trim())return i[r.CommonErrors.Value];h.toUpperCase()===this.parent.trueValue?h="1":h.toUpperCase()===this.parent.falseValue&&(h="0")}else h=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");if(i.indexOf(h)>-1)return h;if(""===h.trim())return e[1].length>0?i[r.CommonErrors.Value]:i[r.CommonErrors.Num];if(isNaN(this.parent.parseFloat(h)))if(e[1].toUpperCase()===this.parent.trueValue)h="1";else{if(e[1].toUpperCase()!==this.parent.falseValue)return i[r.CommonErrors.Value];h="0"}}var p=Number(h)<1?0:Math.ceil(Number(h));return t.isNullOrUndefined(a[p-1])&&!isNaN(Number(p))?i[r.CommonErrors.Num]:a[p-1]},n.prototype.ComputeSLOPE=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0]||""===n[1])return o[r.CommonErrors.Value];var s=function(r){return r=-1===r.indexOf(e.parent.tic)?e.parent.getCellCollection(r.split(e.parent.tic).join("")):void 0},a=s(n[0].trim()),u=s(n[1].trim());if(t.isNullOrUndefined(a)||t.isNullOrUndefined(u)||a.length<2&&u.length<2)return o[r.CommonErrors.DivZero];if(a.length!==u.length)return o[r.CommonErrors.NA];var l=function(r){r=e.getDataCollection(r);for(var t=0;t<r.length;t++)if(o.indexOf(r[t])>-1)return r[t].toString();return r};if(a=l(a),o.indexOf(a.toString())>-1)return a.toString();if(u=l(u),o.indexOf(u.toString())>-1)return u.toString();for(var h=0,p=0,g=0,f=0,m=0,c=0,d=u.length;c<d;++c)""!==u[c]&&"NaN"!==Number(u[c]).toString()&&""!==a[c]&&"NaN"!==Number(a[c]).toString()&&(h+=Number(u[c])*Number(a[c]),g+=Number(u[c]),f+=Number(a[c]),p+=Number(u[c])*Number(u[c]),m++);var v=((h-g*f/m)/(p-g*g/m)).toString();return"NaN"===v?o[r.CommonErrors.DivZero]:v},n.prototype.ComputeINTERCEPT=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0]||""===n[1])return o[r.CommonErrors.Value];var s=function(r){return r=-1===r.indexOf(e.parent.tic)?e.parent.getCellCollection(r.split(e.parent.tic).join("")):void 0},a=s(n[0].trim()),u=s(n[1].trim());if(t.isNullOrUndefined(a)||t.isNullOrUndefined(u)||a.length<2&&u.length<2)return o[r.CommonErrors.DivZero];if(a.length!==u.length)return o[r.CommonErrors.NA];var l=function(r){r=e.getDataCollection(r);for(var t=0;t<r.length;t++)if(o.indexOf(r[t])>-1)return r[t];return r};if(a=l(a),o.indexOf(a.toString())>-1)return a.toString();if(u=l(u),o.indexOf(u.toString())>-1)return u.toString();var h,p=0,g=0,f=0,m=0,c=0,d=function(r){for(var t=0,e=u.length;t<e;++t)""!==a[t]&&"NaN"!==Number(a[t]).toString()&&""!==u[t]&&"NaN"!==Number(u[t]).toString()&&(r?(p+=Number(a[t]),g+=Number(u[t]),f++):(h=Number(u[t])-g,m+=h*(Number(a[t])-p),c+=h*h))};d(!0),p/=f,g/=f,d(!1);var v=(p-m/c*g).toString();return"NaN"===v?o[r.CommonErrors.DivZero]:v},n.prototype.ComputeGEOMEAN=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i,o,s,a=t,u=1,l=0,h=0,p=0;if(0===t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(1===a.length&&""===a[0])return u.toString();var g;for(i=0;i<a.length;i++)if(a[i].indexOf(":")>-1){if(a[0]===this.parent.tic)return this.parent.getErrorStrings()[r.CommonErrors.Value];for(s=this.parent.getCellCollection(a[i].split(this.parent.tic).join("")),o=0;o<s.length;o++){if(h=this.parent.getValueFromArg(s[o]),p=h.split(this.parent.tic).join(""),g=p===this.parent.trueValue||p===this.parent.falseValue,(n=this.parent.parseFloat(h))<=0)return this.parent.getErrorStrings()[r.CommonErrors.Num];g||this.parent.getErrorStrings().indexOf(h)>-1||(isNaN(n)||(l++,u*=n))}}else{if(h=this.parent.getValueFromArg(a[i]),this.parent.getErrorStrings().indexOf(h)>-1)return h;var f=h.split(this.parent.tic).join("");if(h.indexOf('"')>-1&&isNaN(this.parent.parseFloat(f)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(a[i]=a[i].startsWith("n")?a[i].slice(1):a[i],""===h&&""===a[i])return this.parent.getErrorStrings()[r.CommonErrors.Num];if(("TRUE"===f||"FALSE"===f)&&this.parent.isCellReference(a[i]))continue;if(h.length>0){if(h=h.indexOf('"')>-1?f:h,h="TRUE"===h.split(this.parent.tic).join("")?"1":"FALSE"===h.split(this.parent.tic).join("")?"0":h,!this.parent.isCellReference(a[i])&&isNaN(this.parent.parseFloat(h)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if((n=this.parent.parseFloat(h))<=0)return this.parent.getErrorStrings()[r.CommonErrors.Num];isNaN(n)||(l++,u*=n)}}return l>0&&(u=Math.pow(u,1/l)),u.toString()},n.prototype.ComputeRSQ=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=0,i=t;if(2!==i.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i[0]||""===i[1])return this.parent.getErrorStrings()[r.CommonErrors.Value];if(i[0].includes('"')||i[1].includes('"'))return this.parent.getErrorStrings()[r.CommonErrors.NA];if(-1===i[0].indexOf(":")&&p(i[0])&&-1===i[1].indexOf(":")&&p(i[1]))return this.parent.getErrorStrings()[r.CommonErrors.DivZero];var o=this.parent.getCellCollection(i[0]),a=this.parent.getCellCollection(i[1]);if(o.length!==a.length)return this.parent.getErrorStrings()[r.CommonErrors.NA];for(var u=this.getDataCollection(a),l=0;l<u.length;l++)if(this.parent.getErrorStrings().indexOf(u[l])>-1)return u[l];for(var h=this.getDataCollection(o),g=0;g<h.length;g++)if(this.parent.getErrorStrings().indexOf(h[g])>-1)return h[g];for(var f,m,c=0;c<u.length;c++)f=Number(u[c]),m=Number(h[c]),s(f)&&s(m)&&n++;if(n<=1)return this.parent.getErrorStrings()[r.CommonErrors.DivZero];if(2===n)return 1;var d=this.getMeanArray(u,h),v=d[0],N=d[1],E=this.getCorrelation(u,h,v,N);return Math.pow(E,2)},n.prototype.getCorrelation=function(r,t,e,n){for(var i,o,a=0,u=0,l=0,h=0;h<r.length;h++)s(r[h])&&s(t[h])&&(a+=(o=Number(r[h])-e)*(i=Number(t[h])-n),u+=Math.pow(o,2),l+=Math.pow(i,2));return a/Math.sqrt(u*l)},n.prototype.getMeanArray=function(r,t){for(var e=0,n=0,i=0,o=0,a=0,u=0;u<r.length;u++)s(r[u])&&s(t[u])&&(n+=Number(r[u]),i+=Number(t[u]),e++);return o=n/e,a=i/e,[o,a]},n.prototype.getDataCollection=function(r){for(var t=[],e=0,n=r.length;e<n;e++)t.push(this.parent.getValueFromArg(r[e]));return t},n}(Q),_r=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Pr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"STDEV",category:"Statistical",description:"Estimates standard deviation based on a sample."},{formulaName:"STDEVP",category:"Statistical",description:"Calculates standard deviation based on the entire population."},{formulaName:"VAR",category:"Statistical",description:"Estimates variance based on a sample."},{formulaName:"VARP",category:"Statistical",description:"Calculates variance based on the entire population."},{formulaName:"MODE",category:"Statistical",description:"Returns the most common value in a data set."},{formulaName:"RANK",category:"Statistical",description:"Returns the rank of a number in a list of numbers."},{formulaName:"MAXA",category:"Statistical",description:"Returns the maximum value in a list of arguments, including text and logicals."},{formulaName:"MINA",category:"Statistical",description:"Returns the minimum value in a list of arguments, including text and logicals."}],t}return _r(n,e),n.prototype.collectSample=function(t,e){for(var n=this.parent.getErrorStrings(),i=[],o=0;o<t.length;o++){var s=t[o];if(""!==s)if(this.parent.isCellReference(s)&&s.indexOf(":")>-1)for(var a=this.parent.getCellCollection(s),u=Array.isArray(a)?a:[a],l=0;l<u.length;l++){h=this.parent.getValueFromArg(u[l]);if(n.indexOf(h)>-1)return h;""!==h&&((p=h.toUpperCase())===this.parent.trueValue?i.push(1):p===this.parent.falseValue?i.push(0):this.parent.isNumber(h)?i.push(this.parent.parseFloat(h)):e&&i.push(0))}else{var h=this.parent.getValueFromArg(s);if(n.indexOf(h)>-1)return h;var p=h.toUpperCase();if(p===this.parent.trueValue)i.push(1);else if(p===this.parent.falseValue)i.push(0);else{if(""===h)continue;if(this.parent.isNumber(this.parent.removeTics(h)))i.push(this.parent.parseFloat(this.parent.removeTics(h)));else{if(!e)return n[r.CommonErrors.Value];i.push(0)}}}}return i},n.prototype.variance=function(r,t){for(var e=r.reduce(function(r,t){return r+t},0)/r.length,n=0,i=0;i<r.length;i++){var o=r[i]-e;n+=o*o}return n/(t?r.length:r.length-1)},n.prototype.ComputeSTDEV=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!1,!1)},n.prototype.ComputeSTDEVP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!0,!1)},n.prototype.ComputeVAR=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!1,!0)},n.prototype.ComputeVARP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!0,!0)},n.prototype.stdevVar=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var s=this.collectSample(e,!1);if("string"==typeof s)return s;if(s.length<(n?1:2))return o[r.CommonErrors.DivZero];var a=this.variance(s,n);return(i?a:Math.sqrt(a)).toString()},n.prototype.ComputeMODE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e,!1);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.Value];for(var s=new Map,a=o[0],u=0,l=0;l<o.length;l++){var h=o[l],p=(s.get(h)||0)+1;s.set(h,p),p>u&&(u=p,a=h)}return u<2?i[r.CommonErrors.NA]:a.toString()},n.prototype.ComputeRANK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=this.collectSample([e[1]],!1);if("string"==typeof s)return s;var a=0;if(3===e.length&&""!==e[2]){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a=u}var l=s.slice().sort(function(r,t){return a?r-t:t-r}).indexOf(o);return l<0?i[r.CommonErrors.NA]:(l+1).toString()},n.prototype.ComputeMAXA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.minMaxA(r,!0)},n.prototype.ComputeMINA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.minMaxA(r,!1)},n.prototype.minMaxA=function(e,n){if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=this.collectSample(e,!0);if("string"==typeof i)return i;if(0===i.length)return"0";for(var o=i[0],s=1;s<i.length;s++)(n?i[s]>o:i[s]<o)&&(o=i[s]);return o.toString()},n}(Q),Wr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),qr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Wr(e,t),e.prototype.collectSample=function(t,e){void 0===e&&(e=!1);for(var n=this.parent.getErrorStrings(),i=[],o=0;o<t.length;o++){var s=t[o];if(""!==s)if(this.parent.isCellReference(s)&&s.indexOf(":")>-1)for(var a=this.parent.getCellCollection(s),u=Array.isArray(a)?a:[a],l=0;l<u.length;l++){h=this.parent.getValueFromArg(u[l]);if(n.indexOf(h)>-1)return h;""!==h&&((p=h.toUpperCase())===this.parent.trueValue?i.push(1):p===this.parent.falseValue?i.push(0):this.parent.isNumber(h)?i.push(this.parent.parseFloat(h)):e&&i.push(0))}else{var h=this.parent.getValueFromArg(s);if(n.indexOf(h)>-1)return h;var p=h.toUpperCase();if(p===this.parent.trueValue)i.push(1);else if(p===this.parent.falseValue)i.push(0);else{if(""===h)continue;if(this.parent.isNumber(this.parent.removeTics(h)))i.push(this.parent.parseFloat(this.parent.removeTics(h)));else{if(!e)return n[r.CommonErrors.Value];i.push(0)}}}}return i},e.prototype.collectPair=function(t){var e=this.parent.getErrorStrings();if(2!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var n=this.parent.getCellCollection(t[0]),i=this.parent.getCellCollection(t[1]),o=Array.isArray(n)?n:[n],s=Array.isArray(i)?i:[i];if(o.length!==s.length)return e[r.CommonErrors.NA];for(var a=[],u=[],l=0;l<o.length;l++){var h=this.parent.getValueFromArg(o[l]),p=this.parent.getValueFromArg(s[l]);if(e.indexOf(h)>-1)return h;if(e.indexOf(p)>-1)return p;""!==h&&""!==p&&this.parent.isNumber(h)&&this.parent.isNumber(p)&&(a.push(this.parent.parseFloat(h)),u.push(this.parent.parseFloat(p)))}return{x:a,y:u}},e.prototype.mean=function(r){return r.reduce(function(r,t){return r+t},0)/r.length},e}(Q),Br=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Xr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"AVEDEV",category:"Statistical",description:"Returns the average of the absolute deviations of data points from their mean."},{formulaName:"DEVSQ",category:"Statistical",description:"Returns the sum of squares of deviations."},{formulaName:"HARMEAN",category:"Statistical",description:"Returns the harmonic mean."},{formulaName:"SKEW",category:"Statistical",description:"Returns the skewness of a distribution."},{formulaName:"KURT",category:"Statistical",description:"Returns the kurtosis of a data set."},{formulaName:"STANDARDIZE",category:"Statistical",description:"Returns a normalized value from a distribution."}],t}return Br(n,e),n.prototype.ComputeAVEDEV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.DivZero];for(var s=this.mean(o),a=0,u=0;u<o.length;u++)a+=Math.abs(o[u]-s);return(a/o.length).toString()},n.prototype.ComputeDEVSQ=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.DivZero];for(var s=this.mean(o),a=0,u=0;u<o.length;u++){var l=o[u]-s;a+=l*l}return a.toString()},n.prototype.ComputeHARMEAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.DivZero];for(var s=0,a=0;a<o.length;a++){if(o[a]<=0)return i[r.CommonErrors.Num];s+=1/o[a]}return(o.length/s).toString()},n.prototype.ComputeSKEW=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;var s=o.length;if(s<3)return i[r.CommonErrors.DivZero];for(var a=this.mean(o),u=0,l=0,h=0;h<s;h++){var p=o[h]-a;u+=p*p,l+=p*p*p}return u/=s,l/=s,0===u?i[r.CommonErrors.DivZero]:(l/Math.pow(u,1.5)*Math.sqrt(s*(s-1))/(s-2)).toString()},n.prototype.ComputeKURT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;var s=o.length;if(s<4)return i[r.CommonErrors.DivZero];for(var a=this.mean(o),u=0,l=0,h=0;h<s;h++){var p=o[h]-a;u+=p*p,l+=p*p*p*p}return u/=s,l/=s,0===u?i[r.CommonErrors.DivZero]:(s*(s+1)/((s-1)*(s-2)*(s-3))*(l/(u*u))-3*(s-1)*(s-1)/((s-2)*(s-3))).toString()},n.prototype.ComputeSTANDARDIZE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);return"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:a<=0?i[r.CommonErrors.Num]:((o-s)/a).toString()},n}(qr),Yr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Hr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CORREL",category:"Statistical",description:"Returns the correlation coefficient between two data sets."},{formulaName:"COVAR",category:"Statistical",description:"Returns covariance, the average of the products of paired deviations."},{formulaName:"PEARSON",category:"Statistical",description:"Returns the Pearson product moment correlation coefficient."},{formulaName:"FORECAST",category:"Statistical",description:"Returns a value along a linear trend."},{formulaName:"STEYX",category:"Statistical",description:"Returns the standard error of the predicted y-value for each x in the regression."}],t}return Yr(n,e),n.prototype.regressionStats=function(e){var n=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.collectPair(e);if("string"==typeof i)return i;var o=i.x,s=i.y;if(o.length<2)return n[r.CommonErrors.DivZero];for(var a=this.mean(o),u=this.mean(s),l=0,h=0,p=0,g=0;g<o.length;g++){var f=o[g]-a,m=s[g]-u;l+=f*f,h+=m*m,p+=f*m}return{n:o.length,meanX:a,meanY:u,sxx:l,syy:h,sxy:p}},n.prototype.ComputeCORREL=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.regressionStats(t);return"string"==typeof i?i:0===i.sxx||0===i.syy?n[r.CommonErrors.DivZero]:(i.sxy/Math.sqrt(i.sxx*i.syy)).toString()},n.prototype.ComputePEARSON=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeCORREL.apply(this,r)},n.prototype.ComputeCOVAR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.regressionStats(t);return"string"==typeof i?i:i.n<2?n[r.CommonErrors.DivZero]:(i.sxy/(i.n-1)).toString()},n.prototype.ComputeFORECAST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=this.regressionStats([e[2],e[1]]);if("string"==typeof s)return s;if(0===s.sxx)return i[r.CommonErrors.DivZero];var a=s.sxy/s.sxx;return(s.meanY-a*s.meanX+a*o).toString()},n.prototype.ComputeSTEYX=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.regressionStats([t[1],t[0]]);if("string"==typeof i)return i;if(i.n<=2||0===i.sxx)return n[r.CommonErrors.DivZero];var o=i.syy-i.sxy*i.sxy/i.sxx;return Math.sqrt(o/(i.n-2)).toString()},n}(qr),Gr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Zr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"PERCENTILE",category:"Statistical",description:"Returns the k-th percentile of values in a range."},{formulaName:"PERCENTRANK",category:"Statistical",description:"Returns the percentage rank of a value in a data set."},{formulaName:"QUARTILE",category:"Statistical",description:"Returns the quartile of a data set."}],t}return Gr(n,e),n.prototype.sortedSample=function(e){if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var n=this.collectSample(e);return"string"==typeof n?n:n.slice().sort(function(r,t){return r-t})},n.prototype.percentile=function(t,e){var n=this.parent.getErrorStrings();if(e<0||e>1)return n[r.CommonErrors.Num];if(0===t.length)return n[r.CommonErrors.Num];var i=t.length,o=e*(i-1),s=Math.floor(o),a=o-s;return s>=i-1?t[i-1]:t[s]+a*(t[s+1]-t[s])},n.prototype.ComputePERCENTILE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;var o=this.sortedSample([e[0]]);if("string"==typeof o)return o;var s=this.percentile(o,i);return"string"==typeof s?s:s.toString()},n.prototype.ComputePERCENTRANK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=this.sortedSample([e[1]]);if("string"==typeof s)return s;if(0===s.length)return i[r.CommonErrors.Num];var a=0,u=1;if(3===e.length){var l=this.resolveNumberArg(e[2]);if("string"==typeof l)return l;a=l,u=1-l}if(o<s[0])return a.toString();if(o>s[s.length-1])return u.toString();for(var h=0,p=0;p<s.length;p++){if(s[p]===o){h=p/(s.length-1||1);break}if(s[p]>o){h=(p-1+(o-s[p-1])/(s[p]-s[p-1]))/(s.length-1);break}}return h.toString()},n.prototype.ComputeQUARTILE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;var s=Math.floor(o);if(s<0||s>4)return i[r.CommonErrors.Num];var a={0:0,1:.25,2:.5,3:.75,4:1},u=this.sortedSample([e[0]]);if("string"==typeof u)return u;var l=this.percentile(u,a[s]);return"string"==typeof l?l:l.toString()},n}(qr),Kr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),$r=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"NORMDIST",category:"Statistical",description:"Returns the normal cumulative distribution."},{formulaName:"NORMSDIST",category:"Statistical",description:"Returns the standard normal cumulative distribution."},{formulaName:"NORMINV",category:"Statistical",description:"Returns the inverse of the normal cumulative distribution."},{formulaName:"NORMSINV",category:"Statistical",description:"Returns the inverse of the standard normal cumulative distribution."},{formulaName:"POISSON",category:"Statistical",description:"Returns the Poisson distribution."},{formulaName:"BINOMDIST",category:"Statistical",description:"Returns the individual term binomial distribution probability."},{formulaName:"EXPONDIST",category:"Statistical",description:"Returns the exponential distribution."},{formulaName:"CONFIDENCE",category:"Statistical",description:"Returns the confidence interval for a population mean."}],t}return Kr(n,e),n.prototype.ComputeNORMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(a<=0)return i[r.CommonErrors.Num];var u=!0;if(4===e.length){var l=this.resolveNumberArg(e[3]);if("string"==typeof l)return l;u=0!==l}if(u)return m(o,s,a).toString();var h=(o-s)/a;return(Math.exp(-.5*h*h)/(a*Math.sqrt(2*Math.PI))).toString()},n.prototype.ComputeNORMSDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:m(i).toString()},n.prototype.ComputeNORMINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=c(o,s,a);return isNaN(u)?i[r.CommonErrors.Num]:u.toString()},n.prototype.ComputeNORMSINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=c(o);return isNaN(s)?i[r.CommonErrors.Num]:s.toString()},n.prototype.ComputePOISSON=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(o);if(a<0||s<0)return i[r.CommonErrors.Num];var u=!0;if(3===e.length){var l=this.resolveNumberArg(e[2]);if("string"==typeof l)return l;u=0!==l}if(!u)return(Math.exp(-s)*Math.pow(s,a)/N(a)).toString();for(var h=0,p=0;p<=a;p++)h+=Math.exp(-s)*Math.pow(s,p)/N(p);return h.toString()},n.prototype.ComputeBINOMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(o),l=Math.floor(s);if(u<0||l<0||u>l||a<0||a>1)return i[r.CommonErrors.Num];var h=!0;if(4===e.length){var p=this.resolveNumberArg(e[3]);if("string"==typeof p)return p;h=0!==p}var g=E(l,u)*Math.pow(a,u)*Math.pow(1-a,l-u);if(!h)return g.toString();for(var f=0,m=0;m<=u;m++)f+=E(l,m)*Math.pow(a,m)*Math.pow(1-a,l-m);return f.toString()},n.prototype.ComputeEXPONDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;if(o<0||s<=0)return i[r.CommonErrors.Num];var a=!0;if(3===e.length){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a=0!==u}return a?(1-Math.exp(-s*o)).toString():(s*Math.exp(-s*o)).toString()},n.prototype.ComputeCONFIDENCE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<=0||o>=1||s<=0||a<1)return i[r.CommonErrors.Num];var u=c(1-o/2);return isNaN(u)?i[r.CommonErrors.Num]:(u*s/Math.sqrt(a)).toString()},n}(qr),zr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Qr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"MAXIFS",category:"Statistical",description:"Returns the maximum value among cells specified by criteria."},{formulaName:"MINIFS",category:"Statistical",description:"Returns the minimum value among cells specified by criteria."}],t}return zr(n,e),n.prototype.ComputeMAXIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.aggregateIfs(r,!0)},n.prototype.ComputeMINIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.aggregateIfs(r,!1)},n.prototype.aggregateIfs=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length%2==0)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o=e[0],s=this.parent.getCellCollection(o),a=Array.isArray(s)?s:[s],u=[],l=1;l<e.length;l+=2)u.push([e[l],e[l+1]]);for(var h=[],p=0;p<u.length;p++){var g=this.parent.getCellCollection(u[p][0]),f=Array.isArray(g)?g:[g];if(f.length!==a.length)return i[r.CommonErrors.Value];h.push(f)}for(var m=null,c=!1,l=0;l<a.length;l++){for(var d=!0,p=0;p<u.length;p++){var v=this.parent.getValueFromArg(h[p][l]);if(!this.matchesCriteria(v,u[p][1])){d=!1;break}}if(d){var N=this.parent.getValueFromArg(a[l]);if(i.indexOf(N)>-1)return N;if(""!==N&&this.parent.isNumber(N)){var E=this.parent.parseFloat(N);c=!0,null===m?m=E:(n?E>m:E<m)&&(m=E)}}}return c&&null!==m?m.toString():"0"},n.prototype.matchesCriteria=function(r,t){var e=t.trim();e.startsWith(this.parent.tic)&&e.endsWith(this.parent.tic)?e=this.parent.removeTics(e):this.parent.isCellReference(e)?e=this.parent.getValueFromArg(e):(e=this.parent.getValueFromArg(e),this.parent.isCellReference(t)||(e=this.parent.removeTics(e)));var n="equal";return e.startsWith("<=")?(n="lessEq",e=e.substring(2)):e.startsWith(">=")?(n="greaterEq",e=e.substring(2)):e.startsWith("<>")?(n="notEq",e=e.substring(2)):e.startsWith("<")?(n="less",e=e.substring(1)):e.startsWith(">")?(n="greater",e=e.substring(1)):e.startsWith("=")&&(n="equal",e=e.substring(1)),(e=e.trim()).startsWith(this.parent.tic)&&(e=this.parent.removeTics(e)),this.parent.processLogical([r.toLowerCase(),e.toLowerCase()],n)===this.parent.trueValue},n}(Q),Jr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),rt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"STDEVA",category:"Statistical",description:"Estimates standard deviation based on a sample, including text and logicals."},{formulaName:"STDEVPA",category:"Statistical",description:"Calculates standard deviation based on the entire population, including text and logicals."},{formulaName:"VARA",category:"Statistical",description:"Estimates variance based on a sample, including text and logicals."},{formulaName:"VARPA",category:"Statistical",description:"Calculates variance based on the entire population, including text and logicals."},{formulaName:"TRIMMEAN",category:"Statistical",description:"Returns the mean of the interior of a data set."},{formulaName:"FISHER",category:"Statistical",description:"Returns the Fisher transformation."},{formulaName:"FISHERINV",category:"Statistical",description:"Returns the inverse of the Fisher transformation."},{formulaName:"GAMMALN",category:"Statistical",description:"Returns the natural logarithm of the gamma function."},{formulaName:"SUMX2MY2",category:"Statistical",description:"Returns the sum of the difference of squares of corresponding values in two arrays."},{formulaName:"SUMX2PY2",category:"Statistical",description:"Returns the sum of the sum of squares of corresponding values in two arrays."},{formulaName:"SUMXMY2",category:"Statistical",description:"Returns the sum of squares of differences of corresponding values in two arrays."}],t}return Jr(n,e),n.prototype.stdevVarA=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var s=this.collectSample(e,!0);if("string"==typeof s)return s;if(s.length<(n?1:2))return o[r.CommonErrors.DivZero];for(var a=this.mean(s),u=0,l=0;l<s.length;l++){var h=s[l]-a;u+=h*h}var p=u/(n?s.length:s.length-1);return(i?p:Math.sqrt(p)).toString()},n.prototype.ComputeSTDEVA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!1,!1)},n.prototype.ComputeSTDEVPA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!0,!1)},n.prototype.ComputeVARA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!1,!0)},n.prototype.ComputeVARPA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!0,!0)},n.prototype.ComputeTRIMMEAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if(o<0||o>=1)return i[r.CommonErrors.Num];var s=this.collectSample([e[0]],!1);if("string"==typeof s)return s;if(0===s.length)return i[r.CommonErrors.DivZero];var a=s.slice().sort(function(r,t){return r-t}),u=Math.floor(a.length*o/2),l=a.slice(u,a.length-u);return 0===l.length?i[r.CommonErrors.DivZero]:this.mean(l).toString()},n.prototype.ComputeFISHER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);return"string"==typeof o?o:o<=-1||o>=1?i[r.CommonErrors.Num]:(.5*Math.log((1+o)/(1-o))).toString()},n.prototype.ComputeFISHERINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=Math.exp(2*i);return((o-1)/(o+1)).toString()},n.prototype.ComputeGAMMALN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;if(o<=0)return i[r.CommonErrors.Num];var s=S(o);return isFinite(s)?s.toString():i[r.CommonErrors.Num]},n.prototype.sumSquaresPair=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectPair(e);if("string"==typeof o)return o;var s=o.x,a=o.y;if(0===s.length)return i[r.CommonErrors.DivZero];for(var u=0,l=0;l<s.length;l++)if("x2my2"===n)u+=s[l]*s[l]-a[l]*a[l];else if("x2py2"===n)u+=s[l]*s[l]+a[l]*a[l];else{var h=s[l]-a[l];u+=h*h}return u.toString()},n.prototype.ComputeSUMX2MY2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.sumSquaresPair(r,"x2my2")},n.prototype.ComputeSUMX2PY2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.sumSquaresPair(r,"x2py2")},n.prototype.ComputeSUMXMY2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.sumSquaresPair(r,"xmy2")},n}(qr),tt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),et=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CRITBINOM",category:"Statistical",description:"Returns the smallest value for which the cumulative binomial distribution is less than or equal to a criterion value."},{formulaName:"NEGBINOMDIST",category:"Statistical",description:"Returns the negative binomial distribution."},{formulaName:"HYPGEOMDIST",category:"Statistical",description:"Returns the hypergeometric distribution."},{formulaName:"WEIBULL",category:"Statistical",description:"Returns the Weibull distribution."},{formulaName:"LOGNORMDIST",category:"Statistical",description:"Returns the cumulative log-normal distribution."},{formulaName:"LOGINV",category:"Statistical",description:"Returns the inverse of the log-normal cumulative distribution."},{formulaName:"GAMMADIST",category:"Statistical",description:"Returns the gamma distribution."},{formulaName:"GAMMAINV",category:"Statistical",description:"Returns the inverse of the gamma cumulative distribution."},{formulaName:"CHIDIST",category:"Statistical",description:"Returns the one-tailed probability of the chi-squared distribution."},{formulaName:"CHIINV",category:"Statistical",description:"Returns the inverse of the one-tailed probability of the chi-squared distribution."},{formulaName:"CHITEST",category:"Statistical",description:"Returns the test for independence."},{formulaName:"FDIST",category:"Statistical",description:"Returns the F probability distribution."},{formulaName:"FINV",category:"Statistical",description:"Returns the inverse of the F probability distribution."},{formulaName:"ZTEST",category:"Statistical",description:"Returns the one-tailed probability-value of a z-test."},{formulaName:"PROB",category:"Statistical",description:"Returns the probability that values in a range are between two limits."}],t}return tt(n,e),n.prototype.parseCumulative=function(r,t){if(r.length<=t)return!0;var e=this.resolveNumberArg(r[t]);return"string"==typeof e?e:0!==e},n.prototype.ComputeCRITBINOM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(o),l=s;if(u<0||l<0||l>1||a<0||a>1)return i[r.CommonErrors.Num];for(var h=0,p=0;p<=u;p++)if((h+=E(u,p)*Math.pow(l,p)*Math.pow(1-l,u-p))>=a)return p.toString();return u.toString()},n.prototype.ComputeNEGBINOMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(o),l=Math.floor(s);return u<0||l<1||a<=0||a>1?i[r.CommonErrors.Num]:(E(u+l-1,l-1)*Math.pow(a,l)*Math.pow(1-a,u)).toString()},n.prototype.ComputeHYPGEOMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=Math.floor(o),h=Math.floor(s),p=Math.floor(a),g=Math.floor(u);if(l<0||l>h||h>g||p>g)return i[r.CommonErrors.Num];var f=this.parseCumulative(e,4);if("string"==typeof f)return f;var m=E(p,l)*E(g-p,h-l)/E(g,h);if(!f)return m.toString();for(var c=0,d=0;d<=l;d++)c+=E(p,d)*E(g-p,h-d)/E(g,h);return c.toString()},n.prototype.ComputeWEIBULL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<0||s<=0||a<=0)return i[r.CommonErrors.Num];var u=this.parseCumulative(e,3);return"string"==typeof u?u:u?(1-Math.exp(-Math.pow(o/a,s))).toString():(s/Math.pow(a,s)*Math.pow(o,s-1)*Math.exp(-Math.pow(o/a,s))).toString()},n.prototype.ComputeLOGNORMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=U(i,o,s);return isNaN(a)?this.parent.getErrorStrings()[r.CommonErrors.Num]:a.toString()},n.prototype.ComputeLOGINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=w(i,o,s);return isNaN(a)?this.parent.getErrorStrings()[r.CommonErrors.Num]:a.toString()},n.prototype.ComputeGAMMADIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<0||s<=0||a<=0)return i[r.CommonErrors.Num];var u=this.parseCumulative(e,3);if("string"==typeof u)return u;var l=o/a;return u?C(s,l).toString():(Math.pow(l,s-1)*Math.exp(-l)/(a*y(s))).toString()},n.prototype.ComputeGAMMAINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<=0||o>=1||s<=0||a<=0)return i[r.CommonErrors.Num];for(var u=0,l=s*a*20+1,h=0;h<100;h++){var p=(u+l)/2;C(s,p/a)<o?u=p:l=p}return((u+l)/2).toString()},n.prototype.ComputeCHIDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);return"string"==typeof i?i:"string"==typeof o?o:(1-b(i,o)).toString()},n.prototype.ComputeCHIINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=A(1-i,o);return isNaN(s)?this.parent.getErrorStrings()[r.CommonErrors.Num]:s.toString()},n.prototype.ComputeCHITEST=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.chiSquareTest(r)},n.prototype.chiSquareTest=function(e){var n=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.collectSample([e[0]],!1),o=this.collectSample([e[1]],!1);if("string"==typeof i)return i;if("string"==typeof o)return o;if(i.length!==o.length||0===i.length)return n[r.CommonErrors.NA];for(var s=0,a=0;a<i.length;a++){if(0===o[a])return n[r.CommonErrors.DivZero];var u=i[a]-o[a];s+=u*u/o[a]}return(1-b(s,i.length-1)).toString()},n.prototype.ComputeFDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);return"string"==typeof i?i:"string"==typeof o?o:"string"==typeof s?s:(1-O(i,o,s)).toString()},n.prototype.ComputeFINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=x(1-i,o,s);return isNaN(a)?this.parent.getErrorStrings()[r.CommonErrors.Num]:a.toString()},n.prototype.ComputeZTEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1);if("string"==typeof o)return o;if(o.length<2)return i[r.CommonErrors.DivZero];var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;for(var a=this.mean(o),u=0,l=0;l<o.length;l++){var h=o[l]-a;u+=h*h}var p=Math.sqrt(u/(o.length-1));if(0===p)return i[r.CommonErrors.DivZero];var g=p/Math.sqrt(o.length);if(3===e.length){var f=this.resolveNumberArg(e[2]);if("string"==typeof f)return f;g=f/Math.sqrt(o.length)}return(1-m((a-s)/g)).toString()},n.prototype.ComputePROB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1);if("string"==typeof o)return o;var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof s)return s;if("string"==typeof a)return a;if(0===o.length)return i[r.CommonErrors.Num];for(var u=0,l=0,h=0;h<o.length;h++)u+=1,o[h]>=s&&o[h]<=a&&(l+=1);return(l/u).toString()},n}(qr),nt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),it=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"COMPLEX",category:"Engineering",description:"Converts real and imaginary coefficients into a complex number."},{formulaName:"IMABS",category:"Engineering",description:"Returns the absolute value (modulus) of a complex number."},{formulaName:"IMAGINARY",category:"Engineering",description:"Returns the imaginary coefficient of a complex number."},{formulaName:"IMREAL",category:"Engineering",description:"Returns the real coefficient of a complex number."},{formulaName:"IMCONJUGATE",category:"Engineering",description:"Returns the complex conjugate of a complex number."},{formulaName:"IMSUM",category:"Engineering",description:"Returns the sum of complex numbers."},{formulaName:"IMSUB",category:"Engineering",description:"Returns the difference between two complex numbers."},{formulaName:"IMPRODUCT",category:"Engineering",description:"Returns the product of complex numbers."},{formulaName:"IMDIV",category:"Engineering",description:"Returns the quotient of two complex numbers."},{formulaName:"IMSIN",category:"Engineering",description:"Returns the sine of a complex number."},{formulaName:"IMCOS",category:"Engineering",description:"Returns the cosine of a complex number."},{formulaName:"IMEXP",category:"Engineering",description:"Returns the exponential of a complex number."},{formulaName:"IMLN",category:"Engineering",description:"Returns the natural logarithm of a complex number."},{formulaName:"IMSQRT",category:"Engineering",description:"Returns the square root of a complex number."},{formulaName:"IMPOWER",category:"Engineering",description:"Returns a complex number raised to an integer power."},{formulaName:"IMARGUMENT",category:"Engineering",description:"Returns the argument theta of a complex number in radians."},{formulaName:"IMLOG10",category:"Engineering",description:"Returns the base-10 logarithm of a complex number."},{formulaName:"IMLOG2",category:"Engineering",description:"Returns the base-2 logarithm of a complex number."}],t}return nt(n,e),n.prototype.resolveComplex=function(t){var e=this.parent.getErrorStrings(),n=this.resolveTextArg(t);if(e.indexOf(n)>-1)return n;var i=d(n);return i||e[r.CommonErrors.Num]},n.prototype.ComputeCOMPLEX=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s="i";return 3===e.length&&"i"!==(s=this.resolveTextArg(e[2]))&&"j"!==s?this.parent.getErrorStrings()[r.CommonErrors.Value]:v(i,o,s)},n.prototype.ComputeIMABS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:Math.sqrt(i.re*i.re+i.im*i.im).toString()},n.prototype.ComputeIMAGINARY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:i.im.toString()},n.prototype.ComputeIMREAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:i.re.toString()},n.prototype.ComputeIMCONJUGATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:v(i.re,-i.im)},n.prototype.ComputeIMSUM=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.complexReduce(r,function(r,t){return{re:r.re+t.re,im:r.im+t.im}})},n.prototype.ComputeIMSUB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]),o=this.resolveComplex(e[1]);return"string"==typeof i?i:"string"==typeof o?o:v(i.re-o.re,i.im-o.im)},n.prototype.ComputeIMPRODUCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.complexReduce(r,function(r,t){return{re:r.re*t.re-r.im*t.im,im:r.re*t.im+r.im*t.re}},{re:1,im:0})},n.prototype.ComputeIMDIV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveComplex(e[0]),s=this.resolveComplex(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=s.re*s.re+s.im*s.im;return 0===a?i[r.CommonErrors.DivZero]:v((o.re*s.re+o.im*s.im)/a,(o.im*s.re-o.re*s.im)/a)},n.prototype.complexReduce=function(e,n,i){if(t.isNullOrUndefined(e)||e.length<1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=void 0!==i?i:this.resolveComplex(e[0]);if("string"==typeof o)return o;for(var s=i?0:1;s<e.length;s++){var a=this.resolveComplex(e[s]);if("string"==typeof a)return a;o=n(o,a)}return v(o.re,o.im)},n.prototype.ComputeIMEXP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);if("string"==typeof i)return i;var o=Math.exp(i.re);return v(o*Math.cos(i.im),o*Math.sin(i.im))},n.prototype.ComputeIMLN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);if("string"==typeof i)return i;var o=Math.sqrt(i.re*i.re+i.im*i.im);return 0===o?this.parent.getErrorStrings()[r.CommonErrors.Num]:v(Math.log(o),Math.atan2(i.im,i.re))},n.prototype.ComputeIMLOG10=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeIMLN.apply(this,r);if("string"==typeof e&&this.parent.getErrorStrings().indexOf(e)>-1)return e;var n=d(e.toString());if(!n)return e;var i=1/Math.LN10;return v(n.re*i,n.im*i)},n.prototype.ComputeIMLOG2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeIMLN.apply(this,r);if("string"==typeof e&&this.parent.getErrorStrings().indexOf(e)>-1)return e;var n=d(e.toString());if(!n)return e;var i=1/Math.LN2;return v(n.re*i,n.im*i)},n.prototype.ComputeIMSQRT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);if("string"==typeof i)return i;var o=Math.sqrt(i.re*i.re+i.im*i.im),s=Math.atan2(i.im,i.re),a=Math.sqrt(o);return v(a*Math.cos(s/2),a*Math.sin(s/2))},n.prototype.ComputeIMPOWER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveComplex(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(s),u=Math.sqrt(o.re*o.re+o.im*o.im);if(0===u&&a<=0)return i[r.CommonErrors.Num];var l=Math.atan2(o.im,o.re),h=Math.pow(u,a),p=a*l;return v(h*Math.cos(p),h*Math.sin(p))},n.prototype.ComputeIMARGUMENT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:0===i.re&&0===i.im?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:Math.atan2(i.im,i.re).toString()},n.prototype.ComputeIMSIN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:v(Math.sin(i.re)*Math.cosh(i.im),Math.cos(i.re)*Math.sinh(i.im))},n.prototype.ComputeIMCOS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:v(Math.cos(i.re)*Math.cosh(i.im),-Math.sin(i.re)*Math.sinh(i.im))},n}(Q),ot=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),st=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DATE",category:"Date",description:"Returns the date, given the year, month and day of the month."},{formulaName:"DAY",category:"Date",description:"Returns the day of a given date."},{formulaName:"TODAY",category:"Date",description:"Returns the current date as date value."},{formulaName:"DAYS",category:"Date",description:"Returns the number of days between two dates."},{formulaName:"WEEKDAY",category:"Date",description:"Returns the day of the week corresponding to a date."},{formulaName:"TIME",category:"Date & Time",description:"Converts hours, minutes, seconds to the time formatted text."},{formulaName:"EDATE",category:"Date & Time",description:"Returns a date with given number of months before or after the specified date."},{formulaName:"EOMONTH",category:"Date & Time",description:"Returns the last day of the month that is a specified number of months before or after an initially supplied start date."},{formulaName:"DATEVALUE",category:"Date & Time",description:"Converts a date string into date value."},{formulaName:"HOUR",category:"Date & Time",description:"Returns the number of hours in a specified time string."},{formulaName:"MINUTE",category:"Date & Time",description:"Returns the number of minutes in a specified time string."},{formulaName:"SECOND",category:"Date & Time",description:"Returns the number of seconds in a specified time string."},{formulaName:"NOW",category:"Date & Time",description:"Returns the current date and time."},{formulaName:"MONTH",category:"Date & Time",description:"Returns the number of months in a specified date string."}],t}return ot(n,e),n.prototype.ComputeDATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o=[],s=0;s<e.length;++s)o[s]=this.parent.getValueFromArg(e[s]);o[0]=o[0]===this.parent.trueValue?"1":o[0]===this.parent.falseValue?"0":o[0],o[1]=o[1]===this.parent.trueValue?"1":o[1]===this.parent.falseValue?"0":o[1],o[2]=o[2]===this.parent.trueValue?"1":o[2]===this.parent.falseValue?"0":o[2];for(var a=0;a<o.length;a++){var u=o[a];if(this.parent.getErrorStrings().indexOf(u)>-1)return u;if('""'===u||'"0"'===u&&'"0"'!==e[a]||'"TRUE"'===u||'"FALSE"'===u)return this.parent.getErrorStrings()[r.CommonErrors.Value].toString()}var l=Math.floor(this.parent.parseFloat(o[0].split(this.parent.tic).join(""))),h=Math.floor(this.parent.parseFloat(o[1].split(this.parent.tic).join(""))),p=Math.floor(this.parent.parseFloat(o[2].split(this.parent.tic).join(""))),g=0;if(isNaN(l)||isNaN(h)||isNaN(p))return this.parent.getErrorStrings()[r.CommonErrors.Value].toString();if(l<0&&h<=12||l>=1e4&&h>0)return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();for(;h>12;)h-=12,l++;if(0===(g=this.parent.getSerialDateFromDate(l,h,p)))return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();var f=this.parent.fromOADate(g);if("Invalid Date"!==f.toString()){if(f.getFullYear()<1900||1e4<=f.getFullYear())return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();if(!i)return new t.Internationalization(this.parent.parentObject.locale||"en-US").formatDate(f,{type:"date",skeleton:"yMd"})}return g.toString()},n.prototype.ComputeDAY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(e[0].startsWith(this.parent.tic)){if(""===(o=e[0].split(this.parent.tic).join(""))||o===this.parent.trueValue||o===this.parent.falseValue)return s[r.CommonErrors.Value]}else if(o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join("")),this.parent.isCellReference(e[0])&&o.indexOf(this.parent.tic)>-1)return s[r.CommonErrors.Value];return s.indexOf(o)>-1?o:Number(o)<0?s[r.CommonErrors.Num]:0===Math.floor(Number(o))||o===this.parent.falseValue?0:o===this.parent.trueValue?1:(i=this.parent.isNaN(Number(o))?this.parent.parseDate(o):this.parent.intToDate(o),"[object Date]"===Object.prototype.toString.call(i)&&(i=new Date(i).getFullYear()<1900||new Date(i).getFullYear()>9999?this.parent.isNumber(o)?"Num":"NaN":i.getDate()),"NaN"===i.toString()?s[r.CommonErrors.Value]:"Num"===i.toString()?s[r.CommonErrors.Num]:i)},n.prototype.ComputeTODAY=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n;if(1!==t.length||""!==t[0])n=this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];else{var i=new Date(Date.now());"spreadsheet"===this.parent.parentObject.getModuleName()?(n=a(i).toString(),0===this.parent.parser.storedStringText.toUpperCase().indexOf("TODAY")&&""!==this.parent.cell&&this.parent.parentObject.setDateFormat(this.parent.getSheetId(this.parent.grid),this.parent.rowIndex(this.parent.cell)-1,this.parent.colIndex(this.parent.cell)-1)):n=i.getFullYear()+"/"+this.parent.calculateDate((i.getMonth()+1).toString())+"/"+this.parent.calculateDate(i.getDate().toString())}return n},n.prototype.ComputeDAYS=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)&&1===n.length&&""===n[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=function(t){var n=e.parent.getValueFromArg(t).trim();if(n.indexOf(e.parent.tic)>-1&&(""===(n=n.split(e.parent.tic).join("").trim())||e.parent.isCellReference(t)||n.toUpperCase()===e.parent.trueValue||n.toUpperCase()===e.parent.falseValue))return o[r.CommonErrors.Value];if((n=n.split(e.parent.tic).join("")).toUpperCase()===e.parent.trueValue)n="1";else if(""===n||n.toUpperCase()===e.parent.falseValue)n="0";else if(Number(n)<0)return o[r.CommonErrors.Num];var i=e.parent.hostParseDate(n.toString());return(i.isDate||i.isTime)&&(n=(e.parent.parseDate(n).getTime()/864e5).toString()),n},a=s(n[0]);if(o.indexOf(a)>-1)return a;var u=s(n[1]);if(o.indexOf(u)>-1)return u;var l=Math.floor(Number(a))-Math.floor(Number(u));return isNaN(l)?o[r.CommonErrors.Value]:l},n.prototype.ComputeWEEKDAY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(""===e[0]&&t.isNullOrUndefined(e[1])||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0]&&""===e[1]||""===e[1])return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();if(1===e.length&&e.push("1"),e[0].indexOf(this.parent.tic)>-1&&""===e[0].split(this.parent.tic).join("").trim()||""===e[1].split(this.parent.tic).join("").trim()||e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var i,o,s;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else i=e[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[0].split(this.parent.tic).join("")))?this.parent.getValueFromArg(e[0]):this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0";if(o=this.parent.isCellReference(e[1])?this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0":this.parent.getValueFromArg(e[1].split(this.parent.tic).join("")),this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.getErrorStrings().indexOf(o)>-1)return o;if(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i,o=o===this.parent.trueValue?"1":o===this.parent.falseValue?"0":o,s=this.parent.parseFloat(i),o=this.parent.parseFloat(o),isNaN(o)||isNaN(s))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(s<0||s>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();switch(o=parseInt(o.toString(),10),s=s<1?0:Math.floor(s)%7,o){case 1:case 17:s=s<=0?s+7:s;break;case 2:case 11:s=(s-=1)<=0?s+7:s;break;case 3:s=(s-=2)<0?s+7:s;break;case 12:s=(s+=5)>7?s-7:s;break;case 13:s=(s+=4)>7?s-7:s;break;case 14:s=(s+=3)>7?s-7:s;break;case 15:s=(s+=2)>7?s-7:s;break;case 16:s=(s+=1)>7?s-7:s;break;default:s=this.parent.getErrorStrings()[r.CommonErrors.Num].toString()}return s},n.prototype.ComputeTIME=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e[0].indexOf(this.parent.tic)>-1&&""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];if(e[1].indexOf(this.parent.tic)>-1&&""===e[1].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];if(e[2].indexOf(this.parent.tic)>-1&&""===e[2].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var o,s,a;if(this.parent.isCellReference(e[0])){if((o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")||"0"}if(this.parent.getErrorStrings().indexOf(o)>-1)return o;if(isNaN(this.parent.parseFloat(o))&&o!==this.parent.trueValue&&o!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(e[1])){if((s=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[1].indexOf(this.parent.tic)>-1&&(e[1].split(this.parent.tic).join("")===this.parent.trueValue||e[1].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];s=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("")||"0"}if(this.parent.getErrorStrings().indexOf(s)>-1)return s;if(isNaN(this.parent.parseFloat(s))&&s!==this.parent.trueValue&&s!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(e[2])){if((a=this.parent.getValueFromArg(e[2].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[2].indexOf(this.parent.tic)>-1&&(e[2].split(this.parent.tic).join("")===this.parent.trueValue||e[2].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];a=this.parent.getValueFromArg(e[2]).split(this.parent.tic).join("")||"0"}if(this.parent.getErrorStrings().indexOf(a)>-1)return a;if(isNaN(this.parent.parseFloat(a))&&a!==this.parent.trueValue&&a!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(o=o===this.parent.trueValue?"1":o===this.parent.falseValue?"0":o,s=s===this.parent.trueValue?"1":s===this.parent.falseValue?"0":s,a=a===this.parent.trueValue?"1":a===this.parent.falseValue?"0":a,o=parseInt(this.parent.parseFloat(o).toString(),10),s=parseInt(this.parent.parseFloat(s).toString(),10),a=parseInt(this.parent.parseFloat(a).toString(),10),isNaN(o)||isNaN(s)||isNaN(a))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(o>32767||s>32767||a>32767)return this.parent.getErrorStrings()[r.CommonErrors.Num];var u=new Date(1900,0,1,o,s,a);if(u.getFullYear()<1900)return this.parent.getErrorStrings()[r.CommonErrors.Num];var l=u.getHours(),h=u.getMinutes(),p=u.getSeconds();h=h<10?"0"+h:h,p=p<10?"0"+p:p,i=(l=l<10?"0"+l:l)+":"+h+":"+p;var g=this.parent.hostParseDate(i.toString());return g.isTime&&(i=g.value),i},n.prototype.ComputeEDATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2!==e.length||t.isNullOrUndefined(e))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0]||""===e[1])return this.parent.getErrorStrings()[r.CommonErrors.NA];if(""===e[0].split(this.parent.tic).join("")||""===e[1].split(this.parent.tic).join("")||e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var i,o;if(this.parent.isCellReference(e[0])){if(e[0].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.getErrorStrings().indexOf(i.toString())>-1)return i.toString()}else i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""));if(this.parent.isCellReference(e[1])){if(e[1].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0"}else o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""));if(this.parent.getErrorStrings().indexOf(o)>-1)return o;o=parseInt(o,10);var s;if(this.parent.isNumber(i)){if((i=parseInt(i,10))<0||i>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];s=this.parent.fromOADate(i)}else s=this.parent.checkDateFormat(i);if(isNaN(o)||t.isNullOrUndefined(this.parent.isDate(s))||s.getFullYear()>9999)return this.parent.getErrorStrings()[r.CommonErrors.Value];var u=s.getDate();s.setMonth(s.getMonth()+o),u!==s.getDate()&&s.setDate(0);var l=a(s);return"0"===i.toString()&&(l-=1),l<0||l>2958465?this.parent.getErrorStrings()[r.CommonErrors.Num]:l.toString()},n.prototype.ComputeEOMONTH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2!==e.length||t.isNullOrUndefined(e))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0]||""===e[1])return this.parent.getErrorStrings()[r.CommonErrors.NA];if(""===e[0].split(this.parent.tic).join("")||""===e[1].split(this.parent.tic).join("")||e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var i,o;if(this.parent.isCellReference(e[0])){if(e[0].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("");if(this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.isCellReference(e[1])){if(e[1].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0"}else o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""));if(this.parent.getErrorStrings().indexOf(o)>-1)return o;o=parseInt(o,10);var s;if(this.parent.isNumber(i)){if((i=parseInt(i,10))<0||i>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];s=this.parent.fromOADate(i)}else s=this.parent.checkDateFormat(i);if(isNaN(o)||t.isNullOrUndefined(this.parent.isDate(s))||s.getFullYear()>9999)return this.parent.getErrorStrings()[r.CommonErrors.Value];var u=a(s=new Date(s.getFullYear(),s.getMonth()+(o+1),0));return u<0||u>2958465||s.getFullYear()<1900?this.parent.getErrorStrings()[r.CommonErrors.Num]:u.toString()},n.prototype.ComputeDATEVALUE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();if(""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(i=o=this.parent.getValueFromArg(e[0])||"0",s.indexOf(i)>-1)return i;if(this.parent.isCellReference(e[0])){if(e[0].indexOf(":")>-1||i.startsWith(this.parent.tic))return s[r.CommonErrors.Value]}else i=e[0].split(this.parent.tic).join("")||"0";if(this.parent.isNumber(i)||t.isNullOrUndefined(this.parent.isDate(i))){if(this.parent.isNumber(o)||!this.parent.isDate(o))return s[r.CommonErrors.Value];i=o}var a=this.parent.parseDate(i);return s.indexOf(i)>-1?i:t.isNullOrUndefined(a)||"Invalid Date"===a.toString()||a.getFullYear()<1900||a.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:(i=this.parent.toOADate(a).toString(),parseFloat(i).toFixed(0).toString())},n.prototype.ComputeHOUR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(1!==e.length||t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var i;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i;var o;if(this.parent.isNumber(i)){if(this.parent.parseFloat(i)<0||this.parent.parseFloat(i)>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];o=this.parent.intToTime(i)}else{var s=this.parent.hostParseDate(i.toString());if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=s.dateObj}if("Invalid Date"===o.toString()&&(o=new Date(Date.parse(i))),"Invalid Date"===o.toString()){var a=new Date(Date.now()).toLocaleDateString()+" "+i;o=new Date(Date.parse(a))}return"Invalid Date"===o.toString()&&(o=this.parent.fromOADate(this.parent.parseFloat(i))),"Invalid Date"===o.toString()?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getFullYear()<1900||o.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getHours()},n.prototype.ComputeMINUTE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(1!==e.length||t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var i;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i;var o;if(this.parent.isNumber(i)){if(this.parent.parseFloat(i)<0||this.parent.parseFloat(i)>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];o=this.parent.intToTime(i)}else{var s=this.parent.hostParseDate(i.toString());if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=s.dateObj}if("Invalid Date"===o.toString()&&(o=new Date(Date.parse(i))),"Invalid Date"===o.toString()){var a=new Date(Date.now()).toLocaleDateString()+" "+i;o=new Date(Date.parse(a))}return"Invalid Date"===o.toString()&&(o=this.parent.fromOADate(this.parent.parseFloat(i))),"Invalid Date"===o.toString()?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getFullYear()<1900||o.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getMinutes()},n.prototype.ComputeSECOND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(1!==e.length||t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var i;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i;var o;if(this.parent.isNumber(i)){if(this.parent.parseFloat(i)<0||this.parent.parseFloat(i)>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];o=this.parent.intToTime(i)}else{var s=this.parent.hostParseDate(i.toString());if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=s.dateObj}if("Invalid Date"===o.toString()&&(o=new Date(Date.parse(i))),"Invalid Date"===o.toString()){var a=new Date(Date.now()).toLocaleDateString()+" "+i;o=new Date(Date.parse(a))}return"Invalid Date"===o.toString()&&(o=this.parent.fromOADate(this.parent.parseFloat(i))),"Invalid Date"===o.toString()?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getFullYear()<1900||o.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getSeconds()},n.prototype.ComputeNOW=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1!==t.length||""!==t[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:a(new Date(Date.now()),!0).toString()},n.prototype.ComputeMONTH=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings();if(1===t.length&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.getValueFromArg(t[0]).trim();if(n.indexOf(i)>-1)return i;if(this.parent.isCellReference(t[0])){if(i.indexOf(this.parent.tic)>-1)return n[r.CommonErrors.Value];if(""===i)return 1}else{if('"TRUE"'===i.toUpperCase()||'"FALSE"'===i.toUpperCase())return n[r.CommonErrors.Value];i=i.split(this.parent.tic).join("")}if(""===i)return n[r.CommonErrors.Value];if(i===this.parent.trueValue||i===this.parent.falseValue||Number(i)>-1&&Number(i)<32)return 1;if(Number(i)<0)return n[r.CommonErrors.Num];i.indexOf("%")>-1&&(i=(.01*Number(i.split("%")[0])).toString()),this.parent.isNumber(i)&&(i=parseInt(Math.floor(Number(i)).toString(),10));var o=this.parent.parseDate(i);return"Invalid Date"===o.toString()?this.parent.isNumber(i)?n[r.CommonErrors.Num]:n[r.CommonErrors.Value]:o.getFullYear()<1900||1e4<=o.getFullYear()?n[r.CommonErrors.Num]:(o.getMonth()+1).toString()},n}(Q),at=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ut=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"YEAR",category:"Date & Time",description:"Converts a serial number to a year."},{formulaName:"WEEKNUM",category:"Date & Time",description:"Converts a serial number to a number representing where the week falls numerically within a year."},{formulaName:"TIMEVALUE",category:"Date & Time",description:"Converts a time in the form of text to a serial number."},{formulaName:"DAYS360",category:"Date & Time",description:"Calculates the number of days between two dates based on a 360-day year."},{formulaName:"YEARFRAC",category:"Date & Time",description:"Returns the year fraction representing the number of whole days between start_date and end_date."},{formulaName:"NETWORKDAYS",category:"Date & Time",description:"Returns the number of whole workdays between two dates."},{formulaName:"WORKDAY",category:"Date & Time",description:"Returns the serial number of the date before or after a specified number of workdays."}],t}return at(n,e),n.prototype.toSerial=function(t){var e=this.parent.getErrorStrings(),n=this.parent.getValueFromArg(t);if(e.indexOf(n)>-1)return n;if(this.parent.isCellReference(t)||(n=this.parent.removeTics(n)),""===n)return e[r.CommonErrors.Value];if(this.parent.isNumber(n))return this.parent.parseFloat(n);var i=this.parent.isDate(new Date(n));return i?this.parent.toOADate(i):e[r.CommonErrors.Value]},n.prototype.ComputeYEAR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]);return"string"==typeof o?o:o<0?i[r.CommonErrors.Num]:this.parent.fromOADate(o).getFullYear().toString()},n.prototype.ComputeWEEKNUM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]);if("string"==typeof o)return o;var s=1;if(2===e.length&&""!==e[1]){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=Math.floor(a)}var u=this.parent.fromOADate(o),l=new Date(u.getFullYear(),0,1),h=0;2!==s&&11!==s||(h=1);var p=(l.getDay()+7-h)%7,g=Math.floor((u.getTime()-l.getTime())/864e5),f=Math.floor((g+p)/7)+1;return f<1?i[r.CommonErrors.Num]:f.toString()},n.prototype.ComputeTIMEVALUE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=o.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM)?$/i);if(!s){var a=this.parent.isDate(new Date(o));if(a){var u=this.parent.toOADate(a,!0);return(u-Math.floor(u)).toString()}return i[r.CommonErrors.Value]}var l=parseInt(s[1],10),h=parseInt(s[2],10),p=s[3]?parseInt(s[3],10):0,g=s[4]?s[4].toUpperCase():"";return"PM"===g&&l<12&&(l+=12),"AM"===g&&12===l&&(l=0),l>23||h>59||p>59?i[r.CommonErrors.Value]:((3600*l+60*h+p)/86400).toString()},n.prototype.ComputeDAYS360=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=!1;if(3===e.length&&""!==e[2]){var a=this.parent.getValueFromArg(e[2]).toUpperCase();s=a===this.parent.trueValue||0!==this.parent.parseFloat(a)}var u=this.parent.fromOADate(i),l=this.parent.fromOADate(o),h=u.getFullYear(),p=u.getMonth()+1,g=u.getDate(),f=l.getFullYear(),m=l.getMonth()+1,c=l.getDate();return s?(31===g&&(g=30),31===c&&(c=30)):(31===g&&(g=30),31===c&&30===g&&(c=30)),(360*(f-h)+30*(m-p)+(c-g)).toString()},n.prototype.ComputeYEARFRAC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=0;if(3===e.length&&""!==e[2]){var a=this.resolveNumberArg(e[2]);if("string"==typeof a)return a;s=Math.floor(a)}var u=Math.abs(o-i);switch(s){case 0:return(Math.abs(this.parent.parseFloat(this.ComputeDAYS360(e[0],e[1],"FALSE")))/360).toString();case 1:return(u/365.25).toString();case 2:return(u/360).toString();case 3:return(u/365).toString();case 4:return(Math.abs(this.parent.parseFloat(this.ComputeDAYS360(e[0],e[1],"TRUE")))/360).toString();default:return this.parent.getErrorStrings()[r.CommonErrors.Num]}},n.prototype.isWeekend=function(r){var t=r.getDay();return 0===t||6===t},n.prototype.holidaySet=function(r){var t=new Set;if(!r||""===r)return t;var e=this.parent.getErrorStrings();if(this.parent.isCellReference(r)&&r.indexOf(":")>-1){for(var n=this.parent.getCellCollection(r),i=Array.isArray(n)?n:[n],o=0;o<i.length;o++)if("string"!=typeof(s=this.toSerial(i[o])))t.add(Math.floor(s));else if(e.indexOf(s)>-1)return s}else{var s=this.toSerial(r);if("string"==typeof s)return s;t.add(Math.floor(s))}return t},n.prototype.ComputeNETWORKDAYS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=this.holidaySet(e[2]);if(!(s instanceof Set))return s;for(var a=i<=o?1:-1,u=0,l=Math.floor(i);a>0?l<=Math.floor(o):l>=Math.floor(o);l+=a){var h=this.parent.fromOADate(l);this.isWeekend(h)||s.has(l)||(u+=a)}return u.toString()},n.prototype.ComputeWORKDAY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.trunc(s),u=this.holidaySet(e[2]);if(!(u instanceof Set))return u;for(var l=Math.floor(o),h=a>=0?1:-1,p=Math.abs(a);p>0;){l+=h;var g=this.parent.fromOADate(l);if(this.isWeekend(g)||u.has(l)||p--,l<0)return i[r.CommonErrors.Num]}return l.toString()},n}(Q),lt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ht=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"IF",category:"Logical",description:"Returns one value if a logical expression is TRUE and another if it is FALSE"},{formulaName:"AND",category:"Logical",description:"Returns TRUE if all the arguments are considered TRUE, and FALSE otherwise."},{formulaName:"OR",category:"Logical",description:"Returns TRUE if any arguments considered TRUE, and all the arguments are FALSE it will return FALSE."},{formulaName:"NOT",category:"Logical",description:"Returns the inverse of a given logical expression."},{formulaName:"IFS",category:"Logical",description:"Checks multiple conditions and returns a value corresponding to the first TRUE result."},{formulaName:"IFERROR",category:"Logical",description:"Returns a value you specify if a formula evaluates to an error; otherwise, it returns the result of the formula."}],t}return lt(n,e),n.prototype.ComputeIF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(this.parent.getErrorStrings().indexOf(e[0])>-1)return e[0];var o,a=e;4===a.length&&"nestedFormulaTrue"===a[3]&&(o=!0,a.pop());var u,l;if(a.length>3||1===a.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(a.length<=3){var h=void 0,p=void 0,g="";if(u=this.parent.getValueFromArg(a[0]),this.parent.getErrorStrings().indexOf(u)>-1)return u;var f=u.toUpperCase(),m=this.parent.parseFloat(u);if(f===this.parent.trueValue||m<0||m>0){if(i&&a[1].includes(":")){h=this.parent.getCellCollection(a[1]);for(c=0;c<h.length;c++)p=this.parent.getValueFromArg(h[c]),isNaN(this.parent.parseFloat(p))||(g+=p+",");return g.slice(0,g.length-1)}l=""===a[1]?"0":this.parent.getValueFromArg(a[1],void 0,void 0,void 0,!0)}else{if(f!==this.parent.falseValue&&0!==m)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Requires3Args];if(t.isNullOrUndefined(a[2]))return this.parent.falseValue;if(i&&a[2].includes(":")){h=this.parent.getCellCollection(a[2]);for(var c=0;c<h.length;c++)p=this.parent.getValueFromArg(h[c]),isNaN(this.parent.parseFloat(p))||(g+=p+",");return g.slice(0,g.length-1)}l=""===a[2]?"0":this.parent.getValueFromArg(a[2],void 0,void 0,void 0,!0)}}var d=l.indexOf(this.parent.tic);return!o&&d>-1?l.split(this.parent.tic).join(""):!o||s(l)||-1!==d||l===this.parent.trueValue||l===this.parent.falseValue||this.parent.isCellReference(l)?""===l?"0":l:'"'+l+'"'},n.prototype.ComputeAND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(e)||1===i.length&&""===i[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:this.parent.computeAndOrNot(i,"and")},n.prototype.ComputeOR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(e)||1===i.length&&""===i[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:this.parent.computeAndOrNot(i,"or")},n.prototype.ComputeNOT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(e)||e.length>1||""===e[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.computeAndOrNot(i,"not")},n.prototype.ComputeIFS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;if(t.isNullOrUndefined(e)||1===i.length&&""===i[0]||i.length%2!=0)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o="",s="",a=0;a<i.length;a++){if(o=this.parent.getValueFromArg(i[a]),""===i[a])return this.parent.getErrorStrings()[r.CommonErrors.NA];if(this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o!==this.parent.trueValue&&o!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(o===this.parent.trueValue)return this.parent.isCellReference(i[a+1].split(this.parent.tic).join(""))||i[a+1].includes(this.parent.arithMarker)?s=""===(s=this.parent.getValueFromArg(i[a+1]))?"0":s:(s=""===i[a+1]?"0":this.parent.getValueFromArg(i[a+1])).indexOf(this.parent.tic)>-1&&(s=s.split(this.parent.tic).join("")),a+=1,s;o===this.parent.falseValue&&(a+=1)}return this.parent.getErrorStrings()[r.CommonErrors.NA]},n.prototype.ComputeIFERROR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i,o=e;if(2!==o.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(this.parent.isCellReference(o[0])){if(i=this.parent.getValueFromArg(o[0])||"0",-1===this.parent.getErrorStrings().indexOf(i)&&"NaN"!==i)return i}else if(i=this.parent.getValueFromArg(o[0],null,!0)||"0",-1===this.parent.getErrorStrings().indexOf(i)&&"NaN"!==i)return i=i.split(this.parent.tic).join("").trim();return i=this.parent.isCellReference(o[1])?this.parent.getValueFromArg(o[1])||"0":(i=this.parent.getValueFromArg(o[1])||"0").split(this.parent.tic).join("").trim()},n}(Q),pt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),gt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"TRUE",category:"Logical",description:"Returns the logical value TRUE."},{formulaName:"FALSE",category:"Logical",description:"Returns the logical value FALSE."},{formulaName:"XOR",category:"Logical",description:"Returns a logical exclusive OR of all arguments."},{formulaName:"IFNA",category:"Logical",description:"Returns the value you specify if the expression resolves to #N/A; otherwise returns the result of the expression."},{formulaName:"SWITCH",category:"Logical",description:"Evaluates an expression against a list of values and returns the result corresponding to the first matching value."}],t}return pt(n,e),n.prototype.ComputeTRUE=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&1===t.length&&""===t[0]?this.parent.trueValue:t&&t.length>0&&(1!==t.length||""!==t[0])?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.trueValue},n.prototype.ComputeFALSE=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&1===t.length&&""===t[0]?this.parent.falseValue:t&&t.length>0&&(1!==t.length||""!==t[0])?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.falseValue},n.prototype.isTruthy=function(r){var t=r.toUpperCase();if(t===this.parent.trueValue)return!0;if(t===this.parent.falseValue||""===r)return!1;var e=this.parent.parseFloat(r);return!isNaN(e)&&0!==e},n.prototype.ComputeXOR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=0,s=0;s<e.length;s++){var a=e[s];if(this.parent.isCellReference(a)&&a.indexOf(":")>-1)for(var u=this.parent.getCellCollection(a),l=Array.isArray(u)?u:[u],h=0;h<l.length;h++){p=this.parent.getValueFromArg(l[h]);if(i.indexOf(p)>-1)return p;this.isTruthy(p)&&o++}else{var p=this.parent.getValueFromArg(a);if(i.indexOf(p)>-1)return p;this.isTruthy(p)&&o++}}return o%2==1?this.parent.trueValue:this.parent.falseValue},n.prototype.ComputeIFNA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.getValueFromArg(e[0]);return i===this.parent.getErrorStrings()[r.CommonErrors.NA]||"#N/A"===i?this.parent.getValueFromArg(e[1]):""===i?"0":i},n.prototype.ComputeSWITCH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;var s=Math.floor((e.length-1)/2),a=i[r.CommonErrors.NA];(e.length-1)%2==1&&(a=this.parent.getValueFromArg(e[e.length-1]));for(var u=0;u<s;u++){var l=1+2*u,h=l+1,p=this.parent.getValueFromArg(e[l]);if(i.indexOf(p)>-1)return p;if(p===o||!isNaN(this.parent.parseFloat(p))&&this.parent.parseFloat(p)===this.parent.parseFloat(o)){var g=this.parent.getValueFromArg(e[h]);return""===g?"0":this.parent.removeTics(g)}}return""===a?"0":this.parent.removeTics(a)},n}(Q),ft=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),mt=function(e){function i(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CHOOSE",category:"Lookup & Reference",description:"Returns a value from a list, given an index number."},{formulaName:"INDEX",category:"Lookup & Reference",description:"Returns a value from a table, given a row and column number."},{formulaName:"MATCH",category:"Lookup & Reference",description:"Returns the relative position of an checked item in range that matches a specified value in a specified order"},{formulaName:"LOOKUP",category:"Lookup & Reference",description:"Looks for a value in a one-row or one-column range, then returns a value from the same position in a second one-row or one-column range."},{formulaName:"VLOOKUP",category:"Lookup & Reference",description:"Looks for a specific value in the first column of a lookup range and returns a corresponding value from a different column within the same row."},{formulaName:"HLOOKUP",category:"Lookup & Reference",description:"Looks for a value in the top row of the array of values and then returns a value in the same column from a row in the array that you specify."},{formulaName:"ADDRESS",category:"Lookup & Reference",description:"Returns a cell reference as text, given specified row and column numbers."},{formulaName:"SUBTOTAL",category:"Lookup & Reference",description:"Returns a subtotal in a list or database."},{formulaName:"TEXT",category:"Lookup & Reference",description:"Converts a value to text in specified number format."}],t}return ft(i,e),i.prototype.ComputeCHOOSE=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(t.isNullOrUndefined(n)||""===n[0]&&1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o,s=this.parent.getErrorStrings();if(o=function(r){return r=e.parent.getValueFromArg(r),r.toUpperCase()===e.parent.trueValue?r="1":r.toUpperCase()===e.parent.falseValue&&(r="0"),r}(n[0]),s.indexOf(o)>-1)return o;if(this.parent.isCellReference(n[0])){if(n[0].indexOf(":")>-1)return s[r.CommonErrors.Value]}else 2===(o=this.parent.removeTics(o)).split("%").length&&this.parent.isNumber(o.split("%")[0])&&(o=(.01*Number(o.split("%")[0])).toString());return(o=Math.floor(this.parent.parseFloat(o)))<1||isNaN(o)||t.isNullOrUndefined(n[o])?s[r.CommonErrors.Value]:(""===(o=n[o])&&(o="0"),this.parent.isCellReference(o)?o.indexOf(":")>-1?s[r.CommonErrors.Value]:this.parent.getValueFromArg(o):(o.indexOf(this.parent.tic)>-1&&(s.indexOf(o.split(this.parent.tic).join(""))>-1||this.parent.removeTics(o).match(/^(\d*\.\d+|\d+)\s*[-*/]\s*(\d*\.\d+|\d+)$/))&&(o=this.parent.removeTics(o)),(o=this.parent.removeTics(this.parent.getValueFromArg(o))).indexOf(this.parent.tic+this.parent.tic)>-1?o.replace(/""/g,this.parent.tic):(2===o.split("%").length&&this.parent.isNumber(o.split("%")[0])&&(o=(.01*Number(o.split("%")[0])).toString()),o)))},i.prototype.ComputeINDEX=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s,a=this.parent.getErrorStrings();if(n.length&&"nestedFormulaTrue"===n[n.length-1]&&(o=!0,n.pop()),t.isNullOrUndefined(n)||1===n.length&&""===n[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length<2||n.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0]||""===n[3]||n[3]&&("0"===n[3]||"FALSE"===n[3]))return a[r.CommonErrors.Value];var u,l,h,p=function(n){if(t.isNullOrUndefined(n)||""===n)return 1;var i=e.parent.getValueFromArg(n);return a.indexOf(i)>-1?i:(i.toUpperCase()===e.parent.trueValue?i="1":i.toUpperCase()===e.parent.falseValue&&(i="0"),i.indexOf(e.parent.tic)>-1&&(i=e.parent.removeTics(i),-1===n.indexOf(e.parent.tic)||""===i.trim())?a[r.CommonErrors.Value]:(2===i.split("%").length&&e.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),i=parseInt(Number(i).toString(),10),isNaN(i)||i<0?a[r.CommonErrors.Value]:(0===i&&(i=1),i)))};if(n[3]&&(h=p(n[3]),a.indexOf(h.toString())>-1))return h.toString();n[0].startsWith(this.parent.tic)&&n[0].endsWith(this.parent.tic)&&(n[0]=n[0].substring(1,n[0].length-1));var g=n[0].split(this.parent.getParseArgumentSeparator());if(n[0]=g[h?h-1:0],!n[0])return a[r.CommonErrors.Ref];if(s=n[0],u=p(n[1]),a.indexOf(u.toString())>-1)return u.toString();if(l=p(n[2]),a.indexOf(l.toString())>-1)return l.toString();var f=s.indexOf(":");if(-1===f){if(u>1||l>1)return a[r.CommonErrors.Ref];s=this.parent.isCellReference(s)?this.parent.getValueFromArg(s):s}else{var m=this.parent.rowIndex(s.substring(0,f)),c=this.parent.rowIndex(s.substring(f+1)),d=this.parent.colIndex(s.substring(0,f)),v=this.parent.colIndex(s.substring(f+1));if(u>c-m+1||l>v-d+1)return a[r.CommonErrors.Ref];u=m+u-1,l=d+l-1,s=this.parent.getValueFromArg(this.getSheetReference(s)+this.parent.convertAlpha(l)+u)}return""===s?0:o&&-1===a.indexOf(s)&&!this.parent.isNumber(s)&&s!==this.parent.trueValue&&s!==this.parent.falseValue?this.parent.tic+s+this.parent.tic:s},i.prototype.ComputeMATCH=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=n.slice(),s=this.parent.getErrorStrings();if(t.isNullOrUndefined(o)||1===o.length&&""===o[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(o.length<2||o.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];o[0]=this.parent.getValueFromArg(n[0]);var a=o[0].indexOf(this.parent.tic)>-1;if(o[0]=o[0].split(this.parent.tic).join(""),s.indexOf(o[0])>-1)return o[0];if(""===o[0])return s[r.CommonErrors.NA];isNaN(Number(o[0]))&&(a=!0);var u;if(t.isNullOrUndefined(n[2]))o[2]="1";else{if(o[2]=this.parent.getValueFromArg(o[2]),o[2].indexOf(this.parent.tic)>-1&&isNaN(Number(o[2].split(this.parent.tic).join(""))))return s[r.CommonErrors.Value];o[2].toUpperCase()===this.parent.trueValue?o[2]="1":o[2].toUpperCase()===this.parent.falseValue&&(o[2]="0")}u=parseFloat(o[2]),-1===[-1,0,1].indexOf(u)&&(u=0);var l,h=[],p=!1,g=this.parent.grid,f=this.parent.grid;if(o[1].indexOf(":")>-1||this.parent.isCellReference(o[1])){var m=Y(o[1]),c=m[0],d=m[1],v=m[2],N=m[3];if(c>=1048576||v>=1048576||d>=16384||N>=16384)return s[r.CommonErrors.Name];if(c!==v&&d!==N)return s[r.CommonErrors.NA];var E="",S=this.parent.getSheetFamilyItem(g);o[1].startsWith("!")?(E=o[1].substring(0,o[1].replace("!","").indexOf("!")+2),null!==S.tokenToParentObject&&(g=S.tokenToParentObject.get(E))):null!==S.parentObjectToToken&&(E=S.parentObjectToToken.get(g));var y,C,b=this.parent.getSheetId(g),A=this.parent.getCellValueFn(g,this.parent.cell,b,!0),O=0,F=void 0;0===u?(l=o[0].indexOf("*")>-1||o[0].indexOf("?")>-1,F=function(){if(l&&(y=e.parent.findWildCardValue(o[0],y)),o[0]===y)return N=-2,v=-2,void(C=O+1);O++}):F=function(){h[O]=y,O++};for(var x=c;x<=v;x++)for(var V=d;V<=N;V++)y=A(x+1,V+1,B(x,V)),!p&&isNaN(Number(y))&&(p=!0),F();if(C)return this.parent.grid=f,C;if(a!==p)return this.parent.grid=f,s[r.CommonErrors.NA]}else!t.isNullOrUndefined(o[1])&&o[1].includes(this.parent.tic+this.parent.tic)&&o[1].split(this.parent.tic+this.parent.tic).forEach(function(r){(r=r.trim().split(e.parent.tic).join(""))&&h.push(r)});for(var I=0,R="",T=!1,M=isNaN(Number(o[0]))?o[0]:Number(o[0]),D=0;D<h.length;D++)if(""!==h[D]){if(-1===u&&(a||p))break;var U=isNaN(Number(h[D]))?h[D]:Number(h[D]);if(1===u)M===U?(I=D+1,T=!0,isNaN(Number(o[0]))&&(a=!1)):M>U&&!a&&!T&&(!R||U>(isNaN(Number(R))?R:Number(R)))&&(I=D+1,R=h[D]);else if(0===u){if(l&&(h[D]=this.parent.findWildCardValue(o[0],h[D])),o[0]===h[D])return D+1}else if(-1===u){if(!(Number(h[D])>Number(h[D+1])||D===h.length-1))return this.parent.grid=f,s[r.CommonErrors.NA];M===U?(I=D+1,M=void 0):M<U&&(!R||U<(isNaN(Number(R))?R:Number(R)))&&(I=D+1,R=h[D])}}else D===h.length-1&&h.pop();return a&&p&&1===u&&(I=h.length),this.parent.grid=f,I||s[r.CommonErrors.NA]},i.prototype.ComputeLOOKUP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(i)||1===i.length&&""===i[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.computeLookup(i)},i.prototype.ComputeVLOOKUP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=r;return this.parent.computeVHLookup(e,!0)},i.prototype.ComputeHLOOKUP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=r;return this.parent.computeVHLookup(e)},i.prototype.ComputeADDRESS=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length<2||n.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0].split(this.parent.tic).join("").trim()||""===n[1].split(this.parent.tic).join("").trim())return s[r.CommonErrors.Value];var a=function(t){var n=e.parent.getValueFromArg(t).trim();return s.indexOf(n)>-1?n:(n.toUpperCase()===e.parent.trueValue?n="1":n.toUpperCase()===e.parent.falseValue&&(n="0"),e.parent.isCellReference(t)&&n.indexOf(e.parent.tic)>-1?s[r.CommonErrors.Value]:(2===(n=e.parent.removeTics(n)).split("%").length&&e.parent.isNumber(n.split("%")[0])&&(n=(Number(n.split("%")[0])/100).toString()),n))},u=a(n[0]);if(s.indexOf(u)>-1)return u;if(u=Number(u),isNaN(u)||u<1)return s[r.CommonErrors.Value];u=u.toString();var l=a(n[1]);if(s.indexOf(l)>-1)return l;if(l=Number(l),isNaN(l)||l<1)return s[r.CommonErrors.Value];l=l.toString();var h,p;if(t.isNullOrUndefined(n[2])||""===n[2].trim())h="1";else{if(h=a(n[2]),s.indexOf(h)>-1)return h;if(h=Number(h),isNaN(h)||h<1||h>4)return s[r.CommonErrors.Value];h=h.toString()}if(t.isNullOrUndefined(n[3])||""===n[3].trim())p="1";else{if(p=a(n[3]),s.indexOf(p)>-1)return p;p.toUpperCase()===this.parent.trueValue||Number(p)>1?p="1":""!==p&&p.toUpperCase()!==this.parent.falseValue||(p="0")}if("1"===p)"1"===h?o="$"+K(parseInt(l,10))+"$"+parseInt(u,10):"2"===h?o=K(parseInt(l,10))+"$"+parseInt(u,10):"3"===h?o="$"+K(parseInt(l,10))+parseInt(u,10):"4"===h&&(o=K(parseInt(l,10))+parseInt(u,10));else{if("0"!==p)return s[r.CommonErrors.Name];"1"===h?o="R"+parseInt(u,10)+"C"+parseInt(l,10):"2"===h?o="R"+parseInt(u,10)+"C["+parseInt(l,10)+"]":"3"===h?o="R["+parseInt(u,10)+"]C"+parseInt(l,10):"4"===h&&(o="R["+parseInt(u,10)+"]C["+parseInt(l,10)+"]")}var g;return!t.isNullOrUndefined(n[4])&&""!==n[4]&&(g=this.parent.getValueFromArg(n[4]).split(this.parent.tic).join(""),s.indexOf(g)>-1)?g:(t.isNullOrUndefined(g)||(o=g+"!"+o),o)},i.prototype.ComputeSUBTOTAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s,a,u,l,h,p,g,f,m,c,d=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(c=this.parent.getValueFromArg(e[0]).trim(),d.indexOf(c)>-1)return c;if(""===c.split(this.parent.tic).join("").trim())return d[r.CommonErrors.Value];if(this.parent.isCellReference(e[0])||(c=this.parent.removeTics(c)),c.toUpperCase()===this.parent.trueValue?c="1":c.toUpperCase()===this.parent.falseValue?c="0":2===c.split("%").length&&this.parent.isNumber(c.split("%")[0])&&(c=(Number(c.split("%")[0])/100).toString()),c=this.parent.parseFloat(c),isNaN(c)||(1>c||c>11)&&(101>c||c>111))return d[r.CommonErrors.Value];var v=e.slice(1,e.length);switch(c){case 1:case 101:c=(i=this.owner).ComputeAVERAGE.apply(i,v.concat(["isSubtotal"]));break;case 2:case 102:c=(o=this.owner).ComputeCOUNT.apply(o,v.concat(["isSubtotal"]));break;case 3:case 103:c=(s=this.owner).ComputeCOUNTA.apply(s,v.concat(["isSubtotal"]));break;case 4:case 104:c=(a=this.owner).ComputeMAX.apply(a,v.concat(["isSubtotal"]));break;case 5:case 105:c=(u=this.owner).ComputeMIN.apply(u,v.concat(["isSubtotal"]));break;case 6:case 106:c=(l=this.owner).ComputePRODUCT.apply(l,v.concat(["isSubtotal"]));break;case 7:case 107:c=(h=this.owner).ComputeDAY.apply(h,v);break;case 8:case 108:c=(p=this.owner).ComputeCONCAT.apply(p,v);break;case 9:case 109:c=(g=this.owner).ComputeSUM.apply(g,v.concat(["isSubtotal"]));break;case 10:case 110:c=(f=this.owner).ComputeAVERAGEA.apply(f,v);break;case 11:case 111:c=(m=this.owner).ComputeABS.apply(m,v);break;default:c=d[r.CommonErrors.Value]}return c},i.prototype.ComputeTEXT=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var o;e.length&&"nestedFormulaTrue"===e[e.length-1]&&(o=!0,e.pop());var u=e.length,l=e[0],h=e[1];if(2!==u)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var p=l,g=h;if(""===h)return this.parent.getValueFromArg(p);var f=new Date(1900,0,1,0,0,0),m=p+","+g,c=new t.Internationalization;if(this.parent.getErrorStrings().indexOf(m)>-1)return m;if(p=this.parent.getValueFromArg(p),s(p.split(this.parent.tic).join(""))&&(p=p.split(this.parent.tic).join("")),""===(g=h.startsWith('"')&&h.endsWith('"')?g.split(this.parent.tic).join(""):this.parent.getValueFromArg(g)))return"";""===p&&(g.length>0&&(g.toUpperCase().indexOf("M")>-1||g.toUpperCase().indexOf("D")>-1||g.toUpperCase().indexOf("Y")>-1||g.toUpperCase().indexOf("S")>-1||g.toUpperCase().indexOf("T")>-1)||g.toUpperCase().indexOf("H")>-1)&&(p=f.toString());var d=this.parseDouble(p);if(isNaN(d)&&null!==this.parent.isDate(new Date(p))&&(d=this.parent.toOADate(new Date(p))),f=Date.parse(p.split(this.parent.tic).join("")),!isNaN(d)||!isNaN(f))if(g.length>0&&-1===g.indexOf("#")&&(g.toUpperCase().indexOf("M")>-1||g.toUpperCase().indexOf("D")>-1||g.toUpperCase().indexOf("Y")>-1||g.toUpperCase().indexOf("S")>-1||g.toUpperCase().indexOf("T")>-1)||g.toUpperCase().indexOf("H")>-1){var v=(g=(g=g.split("Y").join("y").split("D").join("d").split("H").join("h")).split("S").join("s").split("m").join("M").split("AM/PM").join("tt")).split(""),N=!1,E=!1,S=0,y=0;for(S=0;S<v.length;){var C=v[S];"s"===C&&"M"===v[y]&&(v[y]="m","M"===v[y-1]&&(v[y-1]="m")),this.parent.isChar(C)&&(y=S),"M"===C&&N&&(v[S]="m",E=!0),"h"===C?N=!0:this.parent.isChar(C)&&"M"!==C&&"h"!==C&&!E&&(N=!1,E=!1),S++}g=(g=String(v)).split(",").join("").split("\n").join(" ");var b=this.parent.fromOADate(d);0===d&&(b=f);var A=n(g);if(""===A){var O=a(b);return this.parent.parentObject.getDisplayText({format:g,value:O})}p=c.getDateFormat({skeleton:A,type:"date"})(b)}else p=this.parent.parentObject.getDisplayText({format:g,value:d});return o?this.parent.tic+p+this.parent.tic:p},i}(Q),ct=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),dt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ROW",category:"Lookup & Reference",description:"Returns the row number of a reference."},{formulaName:"ROWS",category:"Lookup & Reference",description:"Returns the number of rows in a reference."},{formulaName:"COLUMN",category:"Lookup & Reference",description:"Returns the column number of a reference."},{formulaName:"COLUMNS",category:"Lookup & Reference",description:"Returns the number of columns in a reference."},{formulaName:"HYPERLINK",category:"Lookup & Reference",description:"Creates a shortcut that opens a document on a network server, intranet, or Internet."},{formulaName:"OFFSET",category:"Lookup & Reference",description:"Returns a reference offset from a given reference."}],t}return ct(n,e),n.prototype.ComputeROW=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0]){var i=this.parent.actCell||this.parent.cell||"A1",o=i.indexOf("!")>-1?i.substring(i.lastIndexOf("!")+1):i;return this.parent.rowIndex(o).toString()}if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=e[0].split("$").join("");if(!this.parent.isCellReference(s.split(":")[0]))return this.parent.getErrorStrings()[r.CommonErrors.Value];var a=s.indexOf(":")>-1?s.split(":")[0]:s,u=a.indexOf("!")>-1?a.substring(a.lastIndexOf("!")+1):a;return this.parent.rowIndex(u).toString()},n.prototype.ComputeCOLUMN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0]){var i=this.parent.actCell||this.parent.cell||"A1",o=i.indexOf("!")>-1?i.substring(i.lastIndexOf("!")+1):i;return this.parent.colIndex(o).toString()}if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=e[0].split("$").join("");if(!this.parent.isCellReference(s.split(":")[0]))return this.parent.getErrorStrings()[r.CommonErrors.Value];var a=s.indexOf(":")>-1?s.split(":")[0]:s,u=a.indexOf("!")>-1?a.substring(a.lastIndexOf("!")+1):a;return this.parent.colIndex(u).toString()},n.prototype.ComputeROWS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=e[0].split("$").join("");if(-1===i.indexOf(":"))return this.parent.isCellReference(i)?"1":this.parent.getErrorStrings()[r.CommonErrors.Value];var o=i.split(":"),s=o[0].indexOf("!")>-1?o[0].substring(o[0].lastIndexOf("!")+1):o[0],a=o[1].indexOf("!")>-1?o[1].substring(o[1].lastIndexOf("!")+1):o[1];return(Math.abs(this.parent.rowIndex(a)-this.parent.rowIndex(s))+1).toString()},n.prototype.ComputeCOLUMNS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=e[0].split("$").join("");if(-1===i.indexOf(":"))return this.parent.isCellReference(i)?"1":this.parent.getErrorStrings()[r.CommonErrors.Value];var o=i.split(":"),s=o[0].indexOf("!")>-1?o[0].substring(o[0].lastIndexOf("!")+1):o[0],a=o[1].indexOf("!")>-1?o[1].substring(o[1].lastIndexOf("!")+1):o[1];return(Math.abs(this.parent.colIndex(a)-this.parent.colIndex(s))+1).toString()},n.prototype.ComputeHYPERLINK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;if(2===e.length){var s=this.resolveTextArg(e[1]);return i.indexOf(s),s}return o},n.prototype.ComputeOFFSET=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");if(!this.parent.isCellReference(o.split(":")[0]))return i[r.CommonErrors.Value];var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof s)return s;if("string"==typeof a)return a;var u=1,l=1;if(e.length>=4&&""!==e[3]){var h=this.resolveNumberArg(e[3]);if("string"==typeof h)return h;u=Math.floor(h)}if(5===e.length&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;l=Math.floor(p)}if(u<1||l<1)return i[r.CommonErrors.Ref];var g=o.indexOf(":")>-1?o.split(":")[0]:o,f=g.indexOf("!")>-1?g.substring(0,g.lastIndexOf("!")+1):"",m=g.indexOf("!")>-1?g.substring(g.lastIndexOf("!")+1):g,c=this.parent.rowIndex(m)+Math.floor(s),d=this.parent.colIndex(m)+Math.floor(a);if(c<1||d<1)return i[r.CommonErrors.Ref];var v=f+K(d)+c;return 1===u&&1===l?this.parent.getValueFromArg(v):this.parent.getValueFromArg(v)||v},n}(Q),vt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Nt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"INDIRECT",category:"Lookup & Reference",description:"Returns a reference indicated by a text value."},{formulaName:"AREAS",category:"Lookup & Reference",description:"Returns the number of areas in a reference."},{formulaName:"FORMULATEXT",category:"Lookup & Reference",description:"Returns the formula in a cell as text."},{formulaName:"ISREF",category:"Information",description:"Returns TRUE if the value is a reference."}],t}return vt(n,e),n.prototype.ComputeINDIRECT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;o=o.split("$").join("");var s=!0;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=0!==a}if(!s)return i[r.CommonErrors.Value];if(!this.parent.isCellReference(o.split(":")[0]))return i[r.CommonErrors.Ref];if(o.indexOf(":")>-1){for(var u=this.parent.getCellCollection(o),l=Array.isArray(u)?u:[u],h=[],p=0;p<l.length;p++){var g=this.parent.getValueFromArg(l[p]);if(i.indexOf(g)>-1)return g;h.push(g)}return h.join(this.parent.getParseArgumentSeparator())}return this.parent.getValueFromArg(o)},n.prototype.ComputeAREAS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");return this.parent.isCellReference(o.split(":")[0])||-1!==o.indexOf("(")?o.indexOf(",")>-1?o.split(",").length.toString():"1":i[r.CommonErrors.Value]},n.prototype.ComputeFORMULATEXT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");if(!this.parent.isCellReference(o))return i[r.CommonErrors.Value];var s=o.indexOf("!")>-1?o.substring(0,o.lastIndexOf("!")+1):"",a=o.indexOf("!")>-1?o.substring(o.lastIndexOf("!")+1):o,u="!"+this.parent.getSheetID(this.parent.grid)+"!"+a,l=s?o:u,h=this.parent.getFormulaInfoTable(),p=s?l:u;return h.has(p)?h.get(p).getFormulaText():i[r.CommonErrors.NA]},n.prototype.ComputeISREF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=e[0].split("$").join("");return this.parent.isCellReference(i.split(":")[0])},n}(Q),Et=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),St=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"XLOOKUP",category:"Lookup & Reference",description:"Searches a range for a match and returns the corresponding item."},{formulaName:"XMATCH",category:"Lookup & Reference",description:"Returns the relative position of an item in an array."},{formulaName:"TEXTSPLIT",category:"Text",description:"Splits text strings by using column and row delimiters."},{formulaName:"TOCOL",category:"Lookup & Reference",description:"Returns the array in a single column."},{formulaName:"TOROW",category:"Lookup & Reference",description:"Returns the array in a single row."},{formulaName:"CHOOSECOLS",category:"Lookup & Reference",description:"Returns the specified columns from an array."},{formulaName:"CHOOSEROWS",category:"Lookup & Reference",description:"Returns the specified rows from an array."}],t}return Et(n,e),n.prototype.flattenValues=function(r){var t=this.parent.getErrorStrings();if(this.parent.isCellReference(r)&&r.indexOf(":")>-1){for(var e=this.parent.getCellCollection(r),n=Array.isArray(e)?e:[e],i=[],o=0;o<n.length;o++){var s=this.parent.getValueFromArg(n[o]);if(t.indexOf(s)>-1)return s;i.push(s)}return i}var a=this.parent.isCellReference(r)?this.parent.getValueFromArg(r):this.resolveTextArg(r);return t.indexOf(a)>-1?a:[a]},n.prototype.valuesEqual=function(r,t){if(r===t)return!0;var e=this.parent.parseFloat(r),n=this.parent.parseFloat(t);return!isNaN(e)&&!isNaN(n)&&e===n},n.prototype.ComputeXLOOKUP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.parent.removeTics(o),a=this.flattenValues(e[1]);if("string"==typeof a)return a;var u=this.flattenValues(e[2]);if("string"==typeof u)return u;if(a.length!==u.length)return i[r.CommonErrors.Value];var l=null;if(e.length>=4&&""!==e[3]&&(l=this.parent.getValueFromArg(e[3]),i.indexOf(l)>-1))return l;var h=0;if(e.length>=5&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;h=Math.floor(p)}for(var g=-1,f=0;f<a.length;f++){var m=a[f];if(this.valuesEqual(m,s)||m.toLowerCase()===s.toLowerCase()){g=f;break}if(0!==h&&m.toLowerCase().indexOf(s.toLowerCase())>-1){g=f;break}}if(g<0)return null!==l?this.parent.removeTics(l):i[r.CommonErrors.NA];var c=u[g];return""===c?"0":c},n.prototype.ComputeXMATCH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.flattenValues(e[1]);if("string"==typeof s)return s;for(var a=0;a<s.length;a++)if(this.valuesEqual(s[a],o)||s[a].toLowerCase()===this.parent.removeTics(o).toLowerCase())return(a+1).toString();return i[r.CommonErrors.NA]},n.prototype.ComputeTEXTSPLIT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]),s=this.resolveTextArg(e[1]);if(i.indexOf(o)>-1)return o;if(i.indexOf(s)>-1)return s;if(""===s)return o;var a=o.split(s);return void 0!==a[0]?a[0]:""},n.prototype.ComputeTOCOL=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.flattenJoin(r,!0)},n.prototype.ComputeTOROW=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.flattenJoin(r,!1)},n.prototype.flattenJoin=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.flattenValues(e[0]);if("string"==typeof o)return o;var s=0;if(e.length>=2&&""!==e[1]){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=Math.floor(a)}for(var u=[],l=0;l<o.length;l++){var h=o[l];(1!==s&&3!==s||""!==h)&&((2===s||3===s)&&i.indexOf(h)>-1||u.push(h))}return 0===u.length?i[r.CommonErrors.Calc]||"#CALC!":u[0]},n.prototype.ComputeCHOOSECOLS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.chooseAxis(r,!1)},n.prototype.ComputeCHOOSEROWS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.chooseAxis(r,!0)},n.prototype.chooseAxis=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");if(!this.parent.isCellReference(o.split(":")[0]))return i[r.CommonErrors.Value];for(var s=[],a=1;a<e.length;a++){var u=this.resolveNumberArg(e[a]);if("string"==typeof u)return u;s.push(Math.floor(u))}var l=o.indexOf(":")>-1?o.split(":")[0]:o,h=o.indexOf(":")>-1?o.split(":")[1]:o,p=l.indexOf("!")>-1?l.substring(0,l.lastIndexOf("!")+1):"",g=l.indexOf("!")>-1?l.substring(l.lastIndexOf("!")+1):l,f=h.indexOf("!")>-1?h.substring(h.lastIndexOf("!")+1):h,m=this.parent.rowIndex(g),c=this.parent.colIndex(g),d=this.parent.rowIndex(f),v=this.parent.colIndex(f),N=Math.abs(d-m)+1,E=Math.abs(v-c)+1,S=s[0];if(0===S)return i[r.CommonErrors.Value];if(n){var y=S>0?S:N+S+1;if(y<1||y>N)return i[r.CommonErrors.Value];var C=Math.min(m,d)+y-1;return this.parent.getValueFromArg(p+K(Math.min(c,v))+C)}var b=S>0?S:E+S+1;if(b<1||b>E)return i[r.CommonErrors.Value];var A=Math.min(c,v)+b-1;return this.parent.getValueFromArg(p+K(A)+Math.min(m,d))},n}(Q),yt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ct=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"UNIQUE",category:"Lookup & Reference",description:"Returns a unique values from a range or array."},{formulaName:"SORT",category:"Lookup & Reference",description:"Sorts a range of an array."}],t}return yt(n,e),n.prototype.ComputeUNIQUE=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s,a=this.parent.getErrorStrings();if("isComputeExp"===n[n.length-1]&&(s=!0,n.pop()),t.isNullOrUndefined(n)||""===n[0]&&1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var u=function(n){if(t.isNullOrUndefined(n))return e.parent.falseValue;var i=e.parent.getValueFromArg(n);return a.indexOf(i)>-1?i:0===Number(i)?e.parent.falseValue:Number(i)<0||Number(i)>0?e.parent.trueValue:(e.parent.isCellReference(n)||(i=e.parent.removeTics(i)),i.toUpperCase()===e.parent.trueValue||i.toUpperCase()===e.parent.falseValue?i.toUpperCase():i.indexOf(e.parent.tic)>-1||n.indexOf(e.parent.tic)>-1?a[r.CommonErrors.Value]:a[r.CommonErrors.Name])},l=u(n[1]);if(a.indexOf(l)>-1)return l;var h=u(n[2]);if(a.indexOf(h)>-1)return h;var p=[];if(n[0].indexOf(":")>-1){if(t.isNullOrUndefined(n[0].match(/[0-9]/))){g=n[0].split(":");n[0]=g[0]+"1:"+g[1]+(this.parent.spreadSheetUsedRange[0]+1)}else if(t.isNullOrUndefined(n[0].toUpperCase().match(/[A-Z]/))){var g=n[0].split(":");n[0]="A"+g[0]+":"+K(this.parent.spreadSheetUsedRange[1]+1)+g[1]}var f=n[0].split(":");if(this.parent.isCellReference(f[0])&&this.parent.isCellReference(f[1])){for(var m=this.parent.dependencyCollection,c=0;c<m.length&&!s;c++)m[c].split(":")[0]===n[0].split(":")[0]&&this.clearDependency(m[c]);-1===this.parent.dependencyCollection.indexOf(n[0])?s||this.parent.dependencyCollection.push(n[0]):this.clearDependency(n[0]);var d=n[0].indexOf(":"),v=void 0,N=this.parent.rowIndex(this.parent.substring(n[0],0,d)),E=this.parent.colIndex(this.parent.substring(n[0],0,d)),S=this.parent.rowIndex(this.parent.substring(n[0],d+1,d+n[0].length-d-1)),y=this.parent.colIndex(this.parent.substring(n[0],d+1,d+n[0].length-d-1));N>S&&(v=S,S=N,N=v),E>y&&(v=y,y=E,E=v);var C="";0===n[0].indexOf("!")&&(C=n[0].substring(0,n[0].replace("!","").indexOf("!")+2)),n[0]=C+K(E)+N+":"+K(y)+S;var b=y-E,A=this.parent.getCellCollection(n[0]),O=void 0,F=void 0;if(O=F=this.parent.actCell,l===this.parent.falseValue)if(0===b)for(c=0;c<A.length;c++)T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T,p.push(T);else for(var x="",V=b,c=0;c<A.length;c++)c===A.length-1&&(x=x+(T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T)+"++",p.push(x.substring(0,x.length-2))),c<=V?x=x+(T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T)+"++":(p.push(x.substring(0,x.length-2)),V=b+c,x=(T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T)+"++");else for(var x="",V=b+1,I=S-N,c=0;c<V;c++){for(var R=0;R<=I;R++){var T=this.parent.getValueFromArg(A[R*V+c]);x=x+(T=""===T?"0":T)+"++"}p.push(x.substring(0,x.length-2)),x=""}for(var M=[],D=[],U=[],w=[],c=0;c<p.length;c++)-1===M.indexOf(p[c].toLowerCase())?(M.push(p[c].toLowerCase()),U.push(p[c])):(-1===D.indexOf(p[c].toLowerCase())&&D.push(p[c].toLowerCase()),w.push(p[c]));if(h===this.parent.trueValue){for(var j=[],c=0;c<U.length;c++)-1===D.indexOf(U[c].toLowerCase())&&j.push(U[c]);if(0===(U=j).length)return a[r.CommonErrors.Calc]}if(s){var L;return 0!==b?(L=[],U.forEach(function(r){L=L.concat(r.split("++"))})):L=l===this.parent.falseValue?U:U[0].split("++"),L}O.indexOf("!")>-1&&(O=O.substring(O.lastIndexOf("!")+1));var k=this.parent.rowIndex(O),_=this.parent.colIndex(O);if(0===this.parent.dependencyLevel){var P=!1;if(l===this.parent.falseValue)for(var c=k,V=U.length+k;c<V;c++)for(var W=_,q=(Z=U[0].split("++")).length+_;W<q;W++)c===V-1&&W===q-1&&-1===this.parent.uniqueRange.indexOf(F+":"+K(W)+c)&&this.parent.uniqueRange.push(F+":"+K(W)+c),this.checkSpill(W,c)&&(P=!0);else for(var c=_,V=U.length+_;c<V;c++)for(var B=k,q=(Z=U[0].split("++")).length+k;B<q;B++)c===V-1&&B===q-1&&-1===this.parent.uniqueRange.indexOf(this.parent.actCell+":"+K(c)+B)&&this.parent.uniqueRange.push(this.parent.actCell+":"+K(c)+B),this.checkSpill(c,B)&&(P=!0);if(P)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill]}else if(this.parent.dependencyLevel>0&&this.parent.getValueFromArg(K(_)+k,!0).indexOf("#SPILL!")>-1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill];if(l===this.parent.falseValue){var X=this.parent.getSheetFamilyItem(this.parent.grid),Y="",H=void 0;null!==X.sheetNameToParentObject&&X.sheetNameToParentObject.size>0&&(H=(Y=X.parentObjectToToken.get(this.parent.grid))+O);for(c=0;c<U.length;c++){Z=U[c].split("++");c>0&&(k++,_=this.parent.colIndex(O));for(var G=0;G<Z.length;G++)this.setValueRefresh(Z[G],k,_),(c>0||G>0)&&this.parent.refreshDependentCells(Y+K(_)+k.toString(),H),Z[G+1]&&_++}o=U[0].split("++")[0]}else{for(c=0;c<U.length;c++)for(var Z=U[c].split("++"),$=0;$<Z.length;$++)this.setValueRefresh(Z[$],k,_),Z[$+1]?k++:(_++,k=this.parent.rowIndex(O));o=U[0].split("++")[0]}}}else if(this.parent.isCellReference(n[0]))-1===this.parent.dependencyCollection.indexOf(n[0])?s||this.parent.dependencyCollection.push(n[0]):this.clearDependency(n[0]),o=this.parent.getValueFromArg(n[0]);else{if(o=this.parent.getValueFromArg(n[0].trim()),a.indexOf(o)>-1)return o;o=this.parent.removeTics(o)}return o},n.prototype.setValueRefresh=function(r,t,e){this.parent.parentObject.setValueRowCol(this.parent.getSheetId(this.parent.grid),r,t,e)},n.prototype.checkSpill=function(t,e){var n,i=!1,o=this.parent.getValueFromArg(K(t)+e,!0),s="!"+this.parent.getSheetID(this.parent.grid)+"!"+K(t)+e;return this.parent.getFormulaInfoTable().get(s)&&(n=this.parent.getFormulaInfoTable().get(s).formulaText),o&&(o.toUpperCase().indexOf("UNIQUE")<0||n&&!n.toUpperCase().includes("UNIQUE"))&&(o.toUpperCase().indexOf("SORT")<0||n&&!n.toUpperCase().includes("SORT"))&&o!==this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]&&(i=!0),i},n.prototype.clearDependency=function(r){var t=this.parent.actCell,e="";if(t.lastIndexOf("!")>-1){var n=t;t=n.substring(n.lastIndexOf("!")+1),e=n.substring(0,n.lastIndexOf("!"))+"!"}for(var i=this.parent.rowIndex(t),o=this.parent.colIndex(t),s=r.indexOf(":"),a=this.parent.rowIndex(this.parent.substring(r,0,s)),u=this.parent.colIndex(this.parent.substring(r,0,s)),l=this.parent.rowIndex(this.parent.substring(r,s+1,s+r.length-s-1))-a+i,h=this.parent.colIndex(this.parent.substring(r,s+1,s+r.length-s-1))-u+o,p=this.parent.getFormulaInfoTable().get("!"+this.parent.getSheetID(this.parent.grid)+"!"+t)?this.parent.getFormulaInfoTable().get("!"+this.parent.getSheetID(this.parent.grid)+"!"+t).getFormulaText():"",g=i;g<=l;g++)for(var f=o;f<=h;f++)if(this.parent.dependencyLevel>0||p.indexOf("UNIQUE")>-1||p.indexOf("SORT")>-1){if(this.parent.getValueFromArg("!"+this.parent.getSheetID(this.parent.grid)+"!"+K(o)+i,!0).indexOf("#SPILL!")>-1)return;this.parent.parentObject.setValueRowCol(this.parent.getSheetID(this.parent.grid)+1,"",g,f),this.parent.refreshDependentCells("!"+this.parent.getSheetID(this.parent.grid)+"!"+K(f)+g,t),this.parent.actCell=e+t}},n.prototype.ComputeSORT=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,a;n.length&&"nestedFormulaTrue"===n[n.length-1]&&(o=!0,n.pop());var u,l=n,h=[];if(t.isNullOrUndefined(n)||""===n[0]||l.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];l[1]=l[1]?l[1]:"1",l[2]=l[2]?l[2]:"1",l[3]=l[3]?l[3]:"FALSE",l[0]=l[0].split("$").join("");var p,g=[];if(l[0].indexOf(":")>-1){if(t.isNullOrUndefined(l[0].match(/[0-9]/))){f=l[0].split(":");l[0]=f[0]+"1:"+f[1]+(this.parent.spreadSheetUsedRange[0]+1)}else if(t.isNullOrUndefined(l[0].toUpperCase().match(/[A-Z]/))){var f=l[0].split(":");l[0]="A"+f[0]+":"+K(this.parent.spreadSheetUsedRange[1]+1)+f[1]}var m=l[0].split(":");if(this.parent.isCellReference(m[0])&&this.parent.isCellReference(m[1])){for(var c=this.parent.dependencyCollection,d=0;d<c.length&&!o;d++)c[d].split(":")[0]===l[0].split(":")[0]&&this.clearDependency(c[d]);-1===this.parent.dependencyCollection.indexOf(l[0])?o||this.parent.dependencyCollection.push(l[0]):this.clearDependency(l[0]);var v=l[0].indexOf(":"),N=void 0,E=this.parent.rowIndex(this.parent.substring(l[0],0,v)),S=this.parent.colIndex(this.parent.substring(l[0],0,v)),y=this.parent.rowIndex(this.parent.substring(l[0],v+1,v+l[0].length-v-1)),C=this.parent.colIndex(this.parent.substring(l[0],v+1,v+l[0].length-v-1));if(E>y&&(N=y,y=E,E=N),S>C&&(N=C,C=S,S=N),this.parent.isCellReference(l[3])){if(l[3]=this.parent.getValueFromArg(l[3]).toUpperCase(),l[3]!==this.parent.trueValue&&l[3]!==this.parent.falseValue)if(s(l[3]))l[3]=0===Number(l[3])?this.parent.falseValue:this.parent.trueValue;else{if(""!==l[3])return this.parent.getErrorStrings()[r.CommonErrors.Value];l[3]=this.parent.falseValue}}else if(a=l[3].startsWith(this.parent.tic)&&l[3].endsWith(this.parent.tic),l[3]=this.parent.getValueFromArg(l[3]),l[3]=s(l[3])?0===Number(l[3])?this.parent.falseValue:this.parent.trueValue:l[3].split(this.parent.tic).join("").toUpperCase(),l[3]!==this.parent.trueValue&&l[3]!==this.parent.falseValue)return this.parent.getErrorStrings()[a?r.CommonErrors.Value:r.CommonErrors.Name];if(this.parent.isCellReference(l[2])?(l[2]=this.parent.getValueFromArg(l[2]),l[2]=l[2]===this.parent.trueValue?"1":l[2]):(l[2]=this.parent.getValueFromArg(l[2]),l[2]=l[2]===this.parent.trueValue?"1":l[2].split(this.parent.tic).join("")),l[2]=s(l[2])?Math.floor(Number(l[2])).toString():l[2],"1"!==l[2]&&"-1"!==l[2])return this.parent.getErrorStrings().indexOf(l[2])>-1?this.parent.getErrorStrings()[r.CommonErrors.Name]:this.parent.getErrorStrings()[r.CommonErrors.Value];var b="1"===l[2]?"Ascending":"Descending";if(this.parent.isCellReference(l[1])){if(l[1]=this.parent.getValueFromArg(l[1]),l[1]=s(l[1])?Math.floor(Number(l[1])).toString():l[1]===this.parent.trueValue?"1":l[1]===this.parent.falseValue?"0":l[1],isNaN(this.parseDouble(l[1]))||(this.parseDouble(l[1])<1||(l[3]===this.parent.trueValue?y-E+1<this.parseDouble(l[1]):C-S+1<this.parseDouble(l[1]))))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(a=l[1].startsWith(this.parent.tic)&&l[1].endsWith(this.parent.tic),l[1]=this.parent.getValueFromArg(l[1]),l[1]=s(l[1])?Math.floor(Number(l[1])).toString():l[1]===this.parent.trueValue?"1":l[1]===this.parent.falseValue?"0":l[1].split(this.parent.tic).join(""),isNaN(this.parseDouble(l[1]))?a:this.parseDouble(l[1])<1||(l[3]===this.parent.trueValue?y-E+1<this.parseDouble(l[1]):C-S+1<this.parseDouble(l[1])))return this.parent.getErrorStrings()[r.CommonErrors.Value];var A="";0===l[0].indexOf("!")&&(A=(A=(A=l[0]).replace("!","")).indexOf("!"),A=l[0].substring(0,A+2)),l[0]=A+K(S)+E+":"+K(C)+y,p=this.parent.getCellCollection(l[0]);for(d=0;d<p.length;d++)g.push(this.parent.getValueFromArg(p[d]));var O=[],F=[],x=[],V=[],I=[],R=C-S+1,T=function(r){r?"TRUE"===r.toUpperCase()||"FALSE"===r.toUpperCase()?(V.push(r),O.push(r)):isNaN(e.parseDouble(r))?(x.push(r),O.push(r)):(F.push(e.parseDouble(r)),O.push(e.parseDouble(r))):""===r&&(I.push(e.parseDouble(r).toString()),O.push(e.parseDouble(r).toString()))};if("TRUE"===l[3])for(d=0;d<R;d++)T(g[d+(this.parseDouble(l[1])-1)*R]);if("FALSE"===l[3])for(d=0;d<g.length;d++)T(g[d*R+this.parseDouble(l[1])-1]);for(var M=F.length>0?G(F,b):[],D=x.length>0?G(x,b):[],U=V.length>0?G(V,b):[],w="Ascending"===b?M.concat(D,U,I):U.concat(D,M,I),j=[],L=0;L<w.length;L++)for(var k=0;k<O.length;k++)JSON.stringify(w[L])===JSON.stringify(O[k])&&-1===j.indexOf(k)&&j.push(k);var _=void 0,P=void 0;_=(_=P=this.parent.actCell)?_.indexOf("!")>-1?_.substring(_.lastIndexOf("!")+1):_:this.parent.actCell;var W=this.parent.rowIndex(_),q=this.parent.colIndex(_);if(0===this.parent.dependencyLevel){for(var B=!1,X="TRUE"===l[3]?y-E+1:j.length,Y="TRUE"===l[3]?j.length:C-S+1,H=0;H<X;H++)for(var Z=0;Z<Y;Z++)if(this.checkSpill(q+Z,W+H)&&(B=!0),H===X-1&&Z===Y-1){var $=K(q+Z)+(W+H);-1===this.parent.sortRange.indexOf(P+":"+$)&&this.parent.sortRange.push(P+":"+$)}if(B)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill]}else if(this.parent.dependencyLevel>0&&this.parent.getValueFromArg(K(q)+W,!0).indexOf("#SPILL!")>-1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill];if("TRUE"===l[3]){for(var z=E,Q=0;z<=y;z++,Q++)for(var L=0,J=0;L<j.length;L++,J++){var rr=this.parent.getValueFromArg(A+K(j[L]+S)+z);if(o&&""!==rr)h.push(rr);else{rr=""===rr?"0":rr;var tr=this.parent.cell;if(tr){tr=tr.indexOf("!")>-1?tr.substring(tr.lastIndexOf("!")+1):tr;var er=this.parent.rowIndex(tr),nr=this.parent.colIndex(tr);this.parent.parentObject.setValueRowCol(this.parent.getSheetID(this.parent.grid)+1,rr,er+Q,nr+J)}}}u=this.parent.getValueFromArg(A+K(j[0]+S)+E)}if("FALSE"===l[3]){for(var L=0,Q=0;L<j.length;L++,Q++)for(var ir=S,J=0;ir<=C;ir++,J++){var or=this.parent.getValueFromArg(A+K(ir)+(j[L]+E));if(o&&""!==or)h.push(or);else{or=""===or?"0":or;var sr=this.parent.cell;if(sr){sr=sr.indexOf("!")>-1?sr.substring(sr.lastIndexOf("!")+1):sr;var ar=this.parent.colIndex(sr),ur=this.parent.rowIndex(sr);this.parent.parentObject.setValueRowCol(this.parent.getSheetID(this.parent.grid)+1,or,ur+Q,ar+J)}}}u=this.parent.getValueFromArg(A+K(S)+(j[0]+E))}}}else if(this.parent.isCellReference(l[0]))-1===this.parent.dependencyCollection.indexOf(l[0])?o||this.parent.dependencyCollection.push(l[0]):this.clearDependency(l[0]),u=this.parent.getValueFromArg(l[0]);else{if(u=l[0].trim(),this.parent.getErrorStrings().indexOf(u)>-1)return u;u=this.parent.removeTics(u)}return o?h.join(","):""===u?"0":u},n}(Q),bt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),At=function(e){function n(r){var t=e.call(this,r)||this;return t.isConcat=!1,t.formulas=[{formulaName:"FIND",category:"Text",description:"Returns the position of a string of text within another string."},{formulaName:"CONCATENATE",category:"Text",description:" Used to join two or more strings together."},{formulaName:"CONCAT",category:"Text",description:"Concatenates a list or range of text strings."},{formulaName:"T",category:"Text",description:"Checks whether a value is text or not and returns the text."},{formulaName:"EXACT",category:"Text",description:"Checks whether a two text strings are exactly same and returns TRUE or FALSE."},{formulaName:"LEN",category:"Text",description:"Returns a number of characters in a given string."},{formulaName:"CHAR",category:"Text",description:"Returns the character from the specified number."},{formulaName:"CODE",category:"Text",description:"Returns the numeric code for the first character in a given string."},{formulaName:"DOLLAR",category:"Text",description:"Converts the number to currency formatted text."},{formulaName:"PROPER",category:"Text",description:"Converts a text to proper case; first letter to uppercase and other letters to lowercase."}],t}return bt(n,e),n.prototype.ComputeFIND=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=function(r){var n=e.parent.getValueFromArg(r);return n=t.isNullOrUndefined(n)?"":n.toString(),o.indexOf(n)>-1?n:(e.parent.isCellReference(r)||(2===n.split("%").length&&e.parent.isNumber(n.split("%")[0])?n=(.01*Number(n.split("%")[0])).toString():r.indexOf(e.parent.tic)>-1&&(e.parent.removeTics(r).match(/^(\d*\.\d+|\d+)\s*[-*/]\s*(\d*\.\d+|\d+)$/)?(n=e.parent.getValueFromArg(e.parent.removeTics(r)),n=t.isNullOrUndefined(n)?"":n.toString()):n.indexOf(e.parent.tic+e.parent.tic)>-1&&(n=n.replace(/""/g,e.parent.tic)))),n)},a="";if(!t.isNullOrUndefined(n[0])){if(a=s(n[0]),o.indexOf(a)>-1)return a;this.parent.isCellReference(n[0])||(a=this.parent.removeTics(a))}var u="";if(!t.isNullOrUndefined(n[1])){if(u=s(n[1]),o.indexOf(u)>-1)return u;this.parent.isCellReference(n[1])||(u=this.parent.removeTics(u))}var l=1;if(!t.isNullOrUndefined(n[2])){if(l=s(n[2]),o.indexOf(l)>-1)return l;if(l.toUpperCase()===this.parent.trueValue?l="1":l.toUpperCase()===this.parent.falseValue&&(l="0"),this.parent.isCellReference(n[2])||(l=this.parent.removeTics(l)),l=this.parent.parseFloat(l),isNaN(l)||l<=0)return o[r.CommonErrors.Value]}return l=u.indexOf(a,l-1),l<0?o[r.CommonErrors.Value]:(Number(l)+Number(1)).toString()},n.prototype.ComputeCONCATENATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=e,s="",a="",u=0;u<o.length;u++){var l=o[u];if(this.parent.isCellReference(l)){if(l.indexOf(":")>-1){if(!this.isConcat)return i[r.CommonErrors.Value];for(var p=this.parent.getCellCollection(l),g=0;g<p.length;g++)s+=this.parent.getValueFromArg(p[g])}else{if(1===o.length&&o[0].indexOf(this.parent.tic)<0&&!h(o[0]))return i[r.CommonErrors.Name];a=this.parent.getValueFromArg(l)}if(i.indexOf(a)>-1)return a}else if(l.startsWith(this.parent.tic)&&l.endsWith(this.parent.tic)&&l.indexOf('""')>-1?a=(a=l.substring(1,l.length-1)).replace(/""/g,'"'):(a=l.split(this.parent.tic).join(""),(this.parent.isNumber(a)||t.isNullOrUndefined(this.parent.isDate(a))||l.startsWith(" n"))&&(a=this.parent.getValueFromArg(l).split(this.parent.tic).join(""))),i.indexOf(a)>-1)return a;s+=a}return this.isConcat=!1,s},n.prototype.ComputeCONCAT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e;return this.isConcat=!0,(e=this.owner).ComputeCONCATENATE.apply(e,r)},n.prototype.ComputeT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(o=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(i=this.parent.getValueFromArg(e[0]).trim(),s.indexOf(i)>-1)return i;if(e[0].indexOf(this.parent.tic)>-1)(i=this.parent.removeTics(e[0].trim())).indexOf(this.parent.tic+this.parent.tic)>-1&&(i=i.replace(/""/g,this.parent.tic));else if(2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),this.parent.isNumber(i)||i.toUpperCase()===this.parent.trueValue||i.toUpperCase()===this.parent.falseValue)return"";return o&&(i=this.parent.tic+i+this.parent.tic),i},n.prototype.ComputeEXACT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=!1,i=t.length&&"nestedFormulaTrue"===t[t.length-1],o=this.parent.getErrorStrings();if(i&&t.pop(),!t||!t[0]&&1===t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s,a,u;if(t[0]){if(s=this.parent.getValueFromArg(t[0]),o.indexOf(s)>-1)return s;-1===s.indexOf(this.parent.tic)&&s.includes("%")&&(s=(Number(s.split("%")[0])/100).toString()),this.parent.isCellReference(t[0])?u=!0:s=s.split(this.parent.tic).join("")}if(t[1]){if(a=this.parent.getValueFromArg(t[1]),o.indexOf(a)>-1)return a;-1===a.indexOf(this.parent.tic)&&a.includes("%")&&(a=(Number(a.split("%")[0])/100).toString()),this.parent.isCellReference(t[1])?u||0!==s.trim().length||0!==a.trim().length||(n=!1):(a=a.split(this.parent.tic).join(""),u&&0===s.trim().length&&0===a.trim().length&&(n=!1))}return s===a&&(n=!0),i?n?"1":"0":n},n.prototype.ComputeLEN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||""===e[0].trim()&&1===e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]),o.indexOf(i)>-1?i:(e[0].indexOf(this.parent.tic)>-1?e[0]!==i&&e[0].startsWith("n")?i=this.parent.removeTics(i.trim()):(i=this.parent.removeTics(e[0].trim())).indexOf(this.parent.tic+this.parent.tic)>-1&&(i=i.replace(/""/g,this.parent.tic)):!e[0].startsWith("n")&&2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])?i=(Number(i.split("%")[0])/100).toString():this.parent.isNumber(i)&&(i=i.trim()),i.length))},n.prototype.ComputeCHAR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]).trim();if(i.indexOf(o)>-1)return o;if(o.indexOf('"TRUE"')>-1||this.parent.isCellReference(e[0])&&o.startsWith(this.parent.tic))return i[r.CommonErrors.Value];if(o=o.split(this.parent.tic).join(""),this.parent.isNumber(o)?o=Math.floor(Number(o)).toString():o.indexOf("%")>-1?o=Math.floor(Number(o.split("%")[0])/100).toString():o===this.parent.trueValue&&(o="1"),!o.toUpperCase().match(/^[0-9]+$/))return i[r.CommonErrors.Value];var s=parseInt(o,10);return s>255||s<=0?i[r.CommonErrors.Value]:String.fromCharCode(s)},n.prototype.ComputeCODE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||1===e.length&&""===e[0].trim()?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]).trim(),o.indexOf(i)>-1?i:(e[0].indexOf(this.parent.tic)>-1?i=e[0]!==i&&e[0].startsWith("n")?this.parent.removeTics(i.trim()):this.parent.removeTics(e[0].trim()):!e[0].startsWith("n")&&2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),""===i?o[r.CommonErrors.Value]:i=i.charCodeAt(0)))},n.prototype.ComputeDOLLAR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s;if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(s=!0,e.pop()),1===e.length&&(""===e[0]&&(o=!0),e.push("2")),t.isNullOrUndefined(e)||2!==e.length||o)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var a=0;a<e.length;a++)if(e[a].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[a])))return this.parent.getErrorStrings()[r.CommonErrors.Value];var u=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),l=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");if(u=""===u||u===this.parent.falseValue?"0":u===this.parent.trueValue?"1":u,l=""===l||l===this.parent.falseValue?"0":l===this.parent.trueValue?"1":l,"#NAME?"===u||"#NAME?"===l)return this.parent.getErrorStrings()[r.CommonErrors.Name];if(!u.toUpperCase().match(/^[-]?[0-9.]+$/)||!l.toUpperCase().match(/^[-]?[0-9.]+$/))return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var h=new t.Internationalization,p=parseInt(l,10),g=Math.pow(10,-1*p),f="",m=1;m<=p;m++)f+="0";var c=Math.round(this.parent.parseFloat(u)/g)*g;return i=isNaN(c)?this.parent.getErrorStrings()[r.CommonErrors.Value]:h.formatNumber(c,{format:"$#,##0."+f+";($#,##0."+f+");$0."+f}),s&&(i=this.parent.tic+i+this.parent.tic),i},n.prototype.ComputePROPER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();return e.length&&"nestedFormulaTrue"===e[e.length-1]&&(o=!0,e.pop()),t.isNullOrUndefined(e)||""===e[0].trim()&&1===e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]).trim(),s.indexOf(i)>-1?i:(e[0].indexOf(this.parent.tic)>-1?e[0]!==i&&e[0].startsWith("n")?i=this.parent.removeTics(i.trim()):(i=this.parent.removeTics(e[0].trim())).indexOf(this.parent.tic+this.parent.tic)>-1&&(i=i.replace(/""/g,this.parent.tic)):!e[0].startsWith("n")&&2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),i=i.toLowerCase().replace(/\b\w/g,function(r){return r.toUpperCase()}).replace(/(\d)([a-z])/g,function(r,t,e){return t+e.toUpperCase()}),o&&(i=this.parent.tic+i+this.parent.tic),i))},n}(Q),Ot=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ft=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"LEFT",category:"Text",description:"Returns the leftmost characters from a text value."},{formulaName:"RIGHT",category:"Text",description:"Returns the rightmost characters from a text value."},{formulaName:"MID",category:"Text",description:"Returns a specific number of characters from a text string starting at the position you specify."},{formulaName:"UPPER",category:"Text",description:"Converts text to uppercase."},{formulaName:"LOWER",category:"Text",description:"Converts text to lowercase."},{formulaName:"TRIM",category:"Text",description:"Removes spaces from text except for single spaces between words."},{formulaName:"REPLACE",category:"Text",description:"Replaces characters within text."},{formulaName:"SUBSTITUTE",category:"Text",description:"Substitutes new text for old text in a text string."},{formulaName:"REPT",category:"Text",description:"Repeats text a given number of times."},{formulaName:"SEARCH",category:"Text",description:"Finds one text value within another (not case-sensitive)."},{formulaName:"VALUE",category:"Text",description:"Converts a text argument to a number."},{formulaName:"CLEAN",category:"Text",description:"Removes all nonprintable characters from text."},{formulaName:"FIXED",category:"Text",description:"Formats a number as text with a fixed number of decimals."},{formulaName:"TEXTJOIN",category:"Text",description:"Combines text from multiple ranges/strings with a delimiter."},{formulaName:"LEFTB",category:"Text",description:"Returns the leftmost characters from a text value (byte count alias)."},{formulaName:"RIGHTB",category:"Text",description:"Returns the rightmost characters from a text value (byte count alias)."},{formulaName:"MIDB",category:"Text",description:"Returns characters from a text string (byte count alias)."},{formulaName:"REPLACEB",category:"Text",description:"Replaces characters within text (byte count alias)."},{formulaName:"SEARCHB",category:"Text",description:"Finds one text value within another (byte count alias)."}],t}return Ot(n,e),n.prototype.ComputeLEFT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.substringSide(r,!0)},n.prototype.ComputeRIGHT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.substringSide(r,!1)},n.prototype.substringSide=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=1;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;if((s=Math.floor(a))<0)return i[r.CommonErrors.Value]}return n?o.substring(0,s):s>=o.length?o:o.substring(o.length-s)},n.prototype.ComputeMID=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(s),l=Math.floor(a);return u<1||l<0?i[r.CommonErrors.Value]:o.substring(u-1,u-1+l)},n.prototype.ComputeUPPER=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.caseTransform(r,!0)},n.prototype.ComputeLOWER=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.caseTransform(r,!1)},n.prototype.caseTransform=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);return i.indexOf(o)>-1?o:n?o.toUpperCase():o.toLowerCase()},n.prototype.ComputeTRIM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);return i.indexOf(o)>-1?o:o.trim().replace(/\s+/g," ")},n.prototype.ComputeREPLACE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||4!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveTextArg(e[3]);if("string"==typeof s)return s;if("string"==typeof a)return a;if(i.indexOf(u)>-1)return u;var l=Math.floor(s),h=Math.floor(a);return l<1||h<0?i[r.CommonErrors.Value]:o.substring(0,l-1)+u+o.substring(l-1+h)},n.prototype.ComputeSUBSTITUTE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]),s=this.resolveTextArg(e[1]),a=this.resolveTextArg(e[2]);if(i.indexOf(o)>-1)return o;if(i.indexOf(s)>-1)return s;if(i.indexOf(a)>-1)return a;if(""===s)return o;if(3===e.length)return o.split(s).join(a);var u=this.resolveNumberArg(e[3]);if("string"==typeof u)return u;var l=Math.floor(u);if(l<1)return i[r.CommonErrors.Value];for(var h=0,p=o.indexOf(s);p>-1;){if(++h===l)return o.substring(0,p)+a+o.substring(p+s.length);p=o.indexOf(s,p+s.length)}return o},n.prototype.ComputeREPT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;var a=Math.floor(s);return a<0?i[r.CommonErrors.Value]:0===a||""===o?"":new Array(a+1).join(o)},n.prototype.ComputeSEARCH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]).toLowerCase(),s=this.resolveTextArg(e[1]).toLowerCase();if(i.indexOf(o)>-1)return o;if(i.indexOf(s)>-1)return s;var a=1;if(3===e.length){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;if((a=Math.floor(u))<1)return i[r.CommonErrors.Value]}var l=s.indexOf(o,a-1);return l<0?i[r.CommonErrors.Value]:(l+1).toString()},n.prototype.ComputeVALUE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;if(""===o)return"0";var s=o.replace(/,/g,"").replace(/\$/g,"").trim(),a=this.parent.parseFloat(s);return isNaN(a)?i[r.CommonErrors.Value]:a.toString()},n.prototype.ComputeCLEAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;for(var s="",a=0;a<o.length;a++)o.charCodeAt(a)>=32&&(s+=o.charAt(a));return s},n.prototype.ComputeFIXED=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=2;if(e.length>=2&&""!==e[1]){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=Math.floor(s)}var a=!1;if(3===e.length&&""!==e[2]){var u=this.parent.getValueFromArg(e[2]).toUpperCase();a=u===this.parent.trueValue||0!==this.parent.parseFloat(u)}if(o<0){var l=Math.pow(10,-o),h=Math.round(i/l)*l;return a?h.toString():h.toLocaleString("en-US")}var p=i.toFixed(o);if(a)return p;var g=p.split("."),f=g[0],m="-"===f.charAt(0)?"-":"";m&&(f=f.substring(1));for(var c="",d=0;d<f.length;d++){var v=f.length-d;d>0&&v%3==0&&(c+=","),c+=f.charAt(d)}return g[0]=m+c,g.join(".")},n.prototype.ComputeTEXTJOIN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;for(var s=this.parent.getValueFromArg(e[1]).toUpperCase(),a=s===this.parent.trueValue||!isNaN(this.parent.parseFloat(s))&&0!==this.parent.parseFloat(s),u=[],l=2;l<e.length;l++){var h=e[l];if(this.parent.isCellReference(h)&&h.indexOf(":")>-1)for(var p=this.parent.getCellCollection(h),g=Array.isArray(p)?p:[p],f=0;f<g.length;f++){m=this.parent.getValueFromArg(g[f]);if(i.indexOf(m)>-1)return m;a&&""===m||u.push(m)}else{var m=this.resolveTextArg(h);if(i.indexOf(m)>-1)return m;a&&""===m||u.push(m)}}return u.join(o)},n.prototype.ComputeLEFTB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeLEFT.apply(this,r)},n.prototype.ComputeRIGHTB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeRIGHT.apply(this,r)},n.prototype.ComputeMIDB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeMID.apply(this,r)},n.prototype.ComputeREPLACEB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeREPLACE.apply(this,r)},n.prototype.ComputeSEARCHB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeSEARCH.apply(this,r)},n}(Q),xt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Vt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ASC",category:"Text",description:"Changes full-width characters to half-width."},{formulaName:"TEXTBEFORE",category:"Text",description:"Returns text before a given character or string."},{formulaName:"VALUETOTEXT",category:"Text",description:"Returns text from any specified value."},{formulaName:"ARRAYTOTEXT",category:"Text",description:"Returns the text representation of an array."}],t}return xt(n,e),n.prototype.ComputeASC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveTextArg(e[0]);if(this.parent.getErrorStrings().indexOf(i)>-1)return i;for(var o="",s=0;s<i.length;s++){var a=i.charCodeAt(s);o+=a>=65281&&a<=65374?String.fromCharCode(a-65248):12288===a?" ":i.charAt(s)}return o},n.prototype.ComputeTEXTBEFORE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveTextArg(e[1]);if(i.indexOf(s)>-1)return s;var a=1;if(e.length>=3&&""!==e[2]){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;if((a=Math.floor(u))<1)return i[r.CommonErrors.Value]}for(var l=0,h=0;h<a;h++){var p=o.indexOf(s,l);if(p<0)return e.length>=6&&""!==e[5]?this.resolveTextArg(e[5]):i[r.CommonErrors.NA];if(h===a-1)return o.substring(0,p);l=p+s.length}return o},n.prototype.ComputeVALUETOTEXT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.getErrorStrings(),o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;if(""===o)return"";var s=!0;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=0===a}return!s&&!this.parent.isCellReference(e[0])&&e[0].indexOf(this.parent.tic)>-1?this.parent.removeTics(o):o},n.prototype.ComputeARRAYTOTEXT=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(t.isNullOrUndefined(n)||n.length<1||n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getErrorStrings(),s=[],a=function(r){if(e.parent.isCellReference(r)&&r.indexOf(":")>-1)for(var t=e.parent.getCellCollection(r),n=Array.isArray(t)?t:[t],i=0;i<n.length;i++){a=e.parent.getValueFromArg(n[i]);if(o.indexOf(a)>-1)return a;s.push(a)}else{var a=e.resolveTextArg(r);if(o.indexOf(a)>-1)return a;s.push(a)}return null}(n[0]);return a||s.join(this.parent.getParseArgumentSeparator())},n}(Q),It=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Rt=function(t){function e(r){var e=t.call(this,r)||this;return e.formulas=[{formulaName:"ISNUMBER",category:"Information",description:"Returns TRUE, if the argument is number and FALSE otherwise."}],e}return It(e,t),e.prototype.ComputeISNUMBER=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=t;if(i&&"nestedFormulaTrue"===i[i.length-1]&&(n=!0,i.pop()),1===t.length&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.isCellReference(i[0])?this.parent.getValueFromArg(i[0]):this.parent.getValueFromArg(i[0].split(this.parent.tic).join(""));if(""===o.toString()||t.toString().startsWith(this.parent.tic))return!!n&&"0";var s=!isNaN(this.parent.parseFloat(o));return n?s?"1":"0":s},e}(Q),Tt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Mt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ISBLANK",category:"Information",description:"Returns TRUE if the value is blank."},{formulaName:"ISTEXT",category:"Information",description:"Returns TRUE if the value is text."},{formulaName:"ISNONTEXT",category:"Information",description:"Returns TRUE if the value is not text."},{formulaName:"ISLOGICAL",category:"Information",description:"Returns TRUE if the value is a logical value."},{formulaName:"ISERROR",category:"Information",description:"Returns TRUE if the value is any error value."},{formulaName:"ISERR",category:"Information",description:"Returns TRUE if the value is any error value except #N/A."},{formulaName:"ISNA",category:"Information",description:"Returns TRUE if the value is the #N/A error value."},{formulaName:"ISEVEN",category:"Information",description:"Returns TRUE if the number is even."},{formulaName:"ISODD",category:"Information",description:"Returns TRUE if the number is odd."},{formulaName:"N",category:"Information",description:"Returns a value converted to a number."},{formulaName:"NA",category:"Information",description:"Returns the error value #N/A."},{formulaName:"TYPE",category:"Information",description:"Returns a number indicating the data type of a value."}],t}return Tt(n,e),n.prototype.requireOne=function(e){return t.isNullOrUndefined(e)||1!==e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:null},n.prototype.ComputeISBLANK=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);return e||(this.parent.isCellReference(r[0]),""===this.parent.getValueFromArg(r[0]))},n.prototype.ComputeISTEXT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]);return!(this.parent.getErrorStrings().indexOf(n)>-1)&&(""!==n&&(n.toUpperCase()!==this.parent.trueValue&&n.toUpperCase()!==this.parent.falseValue&&(isNaN(this.parent.parseFloat(n))||!this.parent.isCellReference(r[0])&&r[0].indexOf(this.parent.tic)>-1)))},n.prototype.ComputeISNONTEXT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeISTEXT.apply(this,r);return"string"==typeof e?e:!e},n.prototype.ComputeISLOGICAL=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]).toUpperCase();return n===this.parent.trueValue||n===this.parent.falseValue},n.prototype.ComputeISERROR=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]);return this.parent.getErrorStrings().indexOf(n)>-1||/^#[A-Z/?!]+$/.test(n)},n.prototype.ComputeISERR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireOne(t);if(n)return n;var i=this.parent.getValueFromArg(t[0]);return i!==this.parent.getErrorStrings()[r.CommonErrors.NA]&&"#N/A"!==i&&(this.parent.getErrorStrings().indexOf(i)>-1||/^#[A-Z/?!]+$/.test(i))},n.prototype.ComputeISNA=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireOne(t);if(n)return n;var i=this.parent.getValueFromArg(t[0]);return i===this.parent.getErrorStrings()[r.CommonErrors.NA]||"#N/A"===i},n.prototype.ComputeISEVEN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parity(r,!0)},n.prototype.ComputeISODD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parity(r,!1)},n.prototype.parity=function(t,e){var n=this.parent.getErrorStrings(),i=this.requireOne(t);if(i)return i;var o=this.resolveNumberArg(t[0]);if("string"==typeof o)return n[r.CommonErrors.Value];var s=(o<0?Math.ceil(o):Math.floor(o))%2==0;return e?s:!s},n.prototype.ComputeN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.parent.getErrorStrings(),n=this.requireOne(r);if(n)return n;var i=this.parent.getValueFromArg(r[0]);if(e.indexOf(i)>-1)return i;if(i.toUpperCase()===this.parent.trueValue)return"1";if(i.toUpperCase()===this.parent.falseValue||""===i)return"0";var o=this.parent.parseFloat(i);return isNaN(o)?"0":o.toString()},n.prototype.ComputeNA=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&1===t.length&&""===t[0]?this.parent.getErrorStrings()[r.CommonErrors.NA]:t&&t.length>0&&(1!==t.length||""!==t[0])?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.getErrorStrings()[r.CommonErrors.NA]},n.prototype.ComputeTYPE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]);return this.parent.getErrorStrings().indexOf(n)>-1||/^#[A-Z/?!]+$/.test(n)?"16":n.toUpperCase()===this.parent.trueValue||n.toUpperCase()===this.parent.falseValue?"4":""===n||isNaN(this.parent.parseFloat(n))||!this.parent.isCellReference(r[0])&&-1!==r[0].indexOf(this.parent.tic)?"2":"1"},n}(Q),Dt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ut=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"INFO",category:"Information",description:"Returns information about the current operating environment."},{formulaName:"CELL",category:"Information",description:"Returns information about the formatting, location, or contents of a cell."}],t}return Dt(n,e),n.prototype.ComputeINFO=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]).toLowerCase();if(i.indexOf(o)>-1)return o;if(-1===["system","release","numfile","directory","origin","recalc","memavail","memused"].indexOf(o))return i[r.CommonErrors.NA];var s=o;switch(s){case"system":return"pcdos";case"release":return"16.0";case"numfile":return"1";case"directory":return"/";case"origin":return"A1";case"recalc":return"Manual"===this.parent.parentObject.calculationMode?"Manual":"Automatic";case"memavail":return"1048576";case"memused":return"0";default:return s}},n.prototype.ComputeCELL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]).toLowerCase();if(i.indexOf(o)>-1)return o;var s=2===e.length?e[1]:this.parent.actCell||this.parent.cell||"A1";if(s=s.split("$").join(""),!this.parent.isCellReference(s.split(":")[0]))return i[r.CommonErrors.Value];var a=s.indexOf(":")>-1?s.split(":")[0]:s,u=a.indexOf("!")>-1?a.substring(a.lastIndexOf("!")+1):a,l=this.parent.getValueFromArg(a);switch(o){case"address":return"$"+u.replace(/([A-Z]+)(\d+)/,"$1$$$2");case"col":return this.parent.colIndex(u).toString();case"row":return this.parent.rowIndex(u).toString();case"contents":return l;case"format":return"G";case"prefix":return"";case"protect":return"0";case"type":return""===l?"b":this.parent.isNumber(l)?"v":"l";case"width":return"8";case"parentheses":return"0";default:return i[r.CommonErrors.NA]}},n}(Q),wt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),jt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DATEDIF",category:"Date & Time",description:"Calculates the number of days, months, or years between two dates."},{formulaName:"NETWORKDAYS.INTL",category:"Date & Time",description:"Returns workdays between dates for a custom weekend."},{formulaName:"WORKDAY.INTL",category:"Date & Time",description:"Returns the date before or after a number of workdays with a custom weekend."}],t}return wt(n,e),n.prototype.toSerial=function(t){var e=this.parent.getErrorStrings(),n=this.parent.getValueFromArg(t);if(e.indexOf(n)>-1)return n;if(this.parent.isCellReference(t)||(n=this.parent.removeTics(n)),""===n)return e[r.CommonErrors.Value];if(this.parent.isNumber(n))return Math.floor(this.parent.parseFloat(n));var i=this.parent.isDate(new Date(n));return i?Math.floor(this.parent.toOADate(i)):e[r.CommonErrors.Value]},n.prototype.holidaySet=function(r){var t=new Set;if(!r||""===r)return t;var e=this.parent.getErrorStrings();if(this.parent.isCellReference(r)&&r.indexOf(":")>-1){for(var n=this.parent.getCellCollection(r),i=Array.isArray(n)?n:[n],o=0;o<i.length;o++)if("string"!=typeof(s=this.toSerial(i[o])))t.add(s);else if(e.indexOf(s)>-1)return s}else{var s=this.toSerial(r);if("string"==typeof s)return s;t.add(s)}return t},n.prototype.weekendMask=function(t){var e=[!1,!1,!1,!1,!1,!0,!0];if(!t||""===t)return e;var n=this.parent.getErrorStrings(),i=this.resolveTextArg(t);if(n.indexOf(i)>-1)return i;if(7===i.length&&/^[01]+$/.test(i)){for(var o=[],s=0;s<7;s++)o.push("1"===i.charAt(s));return o}var a=this.resolveNumberArg(t);return"string"==typeof a?a:{1:[!1,!1,!1,!1,!1,!0,!0],2:[!0,!1,!1,!1,!1,!1,!0],3:[!0,!0,!1,!1,!1,!1,!1],4:[!1,!0,!0,!1,!1,!1,!1],5:[!1,!1,!0,!0,!1,!1,!1],6:[!1,!1,!1,!0,!0,!1,!1],7:[!1,!1,!1,!1,!0,!0,!1],11:[!0,!1,!1,!1,!1,!1,!1],12:[!1,!0,!1,!1,!1,!1,!1],13:[!1,!1,!0,!1,!1,!1,!1],14:[!1,!1,!1,!0,!1,!1,!1],15:[!1,!1,!1,!1,!0,!1,!1],16:[!1,!1,!1,!1,!1,!0,!1],17:[!1,!1,!1,!1,!1,!1,!0]}[Math.floor(a)]||n[r.CommonErrors.Num]},n.prototype.isWeekendMask=function(r,t){return t[(r.getDay()+6)%7]},n.prototype.ComputeDATEDIF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]),s=this.toSerial(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveTextArg(e[2]).toUpperCase();if(o>s)return i[r.CommonErrors.Num];var u=this.parent.fromOADate(o),l=this.parent.fromOADate(s);switch(a){case"Y":return(l.getFullYear()-u.getFullYear()-(l.getMonth()<u.getMonth()||l.getMonth()===u.getMonth()&&l.getDate()<u.getDate()?1:0)).toString();case"M":var h=12*(l.getFullYear()-u.getFullYear())+(l.getMonth()-u.getMonth());return l.getDate()<u.getDate()&&h--,h.toString();case"D":return(s-o).toString();case"MD":var p=l.getDate()-u.getDate();return p<0&&(p+=new Date(l.getFullYear(),l.getMonth(),0).getDate()),p.toString();case"YM":var g=l.getMonth()-u.getMonth();return l.getDate()<u.getDate()&&g--,g<0&&(g+=12),g.toString();case"YD":var f=new Date(l.getFullYear(),u.getMonth(),u.getDate()),m=Math.round((l.getTime()-f.getTime())/864e5);return m<0&&(m+=this.isLeapYear(l.getFullYear())?366:365),m.toString();default:return i[r.CommonErrors.Num]}},n.prototype.isLeapYear=function(r){return r%4==0&&r%100!=0||r%400==0},n.prototype["ComputeNETWORKDAYS.INTL"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=this.weekendMask(e[2]);if(!(s instanceof Array))return s;var a=this.holidaySet(e[3]);if(!(a instanceof Set))return a;for(var u=i<=o?1:-1,l=0,h=i;u>0?h<=o:h>=o;h+=u){var p=this.parent.fromOADate(h);this.isWeekendMask(p,s)||a.has(h)||(l+=u)}return l.toString()},n.prototype["ComputeWORKDAY.INTL"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.weekendMask(e[2]);if(!(a instanceof Array))return a;var u=this.holidaySet(e[3]);if(!(u instanceof Set))return u;for(var l=o,h=s>=0?1:-1,p=Math.abs(Math.trunc(s));p>0;){l+=h;var g=this.parent.fromOADate(l);if(this.isWeekendMask(g,a)||u.has(l)||p--,l<0)return i[r.CommonErrors.Num]}return l.toString()},n}(Q),Lt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),kt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ISO.CEILING",category:"Math & Trig",description:"Rounds a number up to the nearest integer or multiple of significance."},{formulaName:"ECMA.CEILING",category:"Math & Trig",description:"Rounds a number up, away from zero, to the nearest multiple of significance."}],t}return Lt(n,e),n.prototype["ComputeISO.CEILING"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=1;if(2===e.length&&""!==e[1]){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=Math.abs(s)}return 0===i||0===o?"0":(Math.ceil(i/o)*o).toString()},n.prototype["ComputeECMA.CEILING"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;if(0===o||0===s)return"0";if(o>0&&s<0)return i[r.CommonErrors.Num];return(o>0?Math.ceil(o/s)*s:s>0?Math.ceil(o/s)*s:Math.floor(o/s)*s).toString()},n}(Q),_t=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Pt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ERROR.TYPE",category:"Information",description:"Returns a number corresponding to an error type."}],t}return _t(n,e),n.prototype["ComputeERROR.TYPE"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]),s={"#NULL!":1,"#DIV/0!":2,"#VALUE!":3,"#REF!":4,"#NAME?":5,"#NUM!":6,"#N/A":7,"#GETTING_DATA":8};if(void 0!==s[o])return s[o].toString();for(var a=0;a<i.length;a++)if(o===i[a]){var u=a+1;if(u>=1&&u<=8)return u.toString()}return i[r.CommonErrors.NA]},n}(Q),Wt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),qt=function(t){function e(r){var e=t.call(this,r)||this;return e.formulas=[{formulaName:"USDOLLAR",category:"Text",description:"Converts a number to text using currency format (US dollar)."},{formulaName:"FINDB",category:"Text",description:"Finds text within another string (byte-count alias of FIND)."},{formulaName:"LENB",category:"Text",description:"Returns the length of a text string (byte-count alias of LEN)."}],e}return Wt(e,t),e.prototype.ComputeUSDOLLAR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.owner.ComputeDOLLAR;return n?n.apply(void 0,t):this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]},e.prototype.ComputeFINDB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.owner.ComputeFIND;return n?n.apply(void 0,t):this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]},e.prototype.ComputeLENB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.owner.ComputeLEN;return n?n.apply(void 0,t):this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]},e}(Q),Bt=function(){function r(r){this.parent=r}return r.prototype.yearDays=function(r){switch(r){case 1:case 3:return 365;default:return 360}},r.prototype.toDate=function(r){return this.parent.fromOADate(r)},r.prototype.toSerial=function(r){return this.parent.toOADate(r)},r.prototype.coupPCD=function(r,t,e){for(var n=this.toDate(t),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=12/e;this.toSerial(i)>r;)i=this.addMonths(i,-o);return this.toSerial(i)>r?r:this.toSerial(i)},r.prototype.coupNCD=function(r,t,e){var n=this.coupPCD(r,t,e);if(n<=r){var i=12/e;n=this.toSerial(this.addMonths(this.toDate(n),i))}return n},r.prototype.coupDays=function(r,t,e,n){void 0===n&&(n=0);var i=this.coupPCD(r,t,e),o=this.coupNCD(r,t,e);return this.daysBetween(i,o,n)},r.prototype.coupDayBS=function(r,t,e,n){void 0===n&&(n=0);var i=this.coupPCD(r,t,e);return this.daysBetween(i,r,n)},r.prototype.coupDaysNC=function(r,t,e,n){void 0===n&&(n=0);var i=this.coupNCD(r,t,e);return this.daysBetween(r,i,n)},r.prototype.coupNum=function(r,t,e,n){for(var i=12/e,o=this.toDate(t),s=new Date(o.getFullYear(),o.getMonth(),o.getDate()),a=0;this.toSerial(s)>r;)a++,s=this.addMonths(s,-i);return a},r.prototype.daysBetween=function(r,t,e){if(1===e)return Math.round(t-r);var n=this.toDate(r),i=this.toDate(t);if(3===e)return Math.abs(Math.round((i.getTime()-n.getTime())/864e5));var o=n.getFullYear(),s=n.getMonth()+1,a=n.getDate(),u=i.getFullYear(),l=i.getMonth()+1,h=i.getDate();return 31===a&&(a=30),31===h&&(h=30),360*(u-o)+30*(l-s)+(h-a)},r.prototype.addMonths=function(r,t){var e=new Date(r.getTime());return e.setMonth(e.getMonth()+t),e},r}(),Xt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Yt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"COUPDAYBS",category:"Financial",description:"Returns the number of days from the beginning of the coupon period to the settlement date."},{formulaName:"COUPDAYS",category:"Financial",description:"Returns the number of days in the coupon period that contains the settlement date."},{formulaName:"COUPDAYSNC",category:"Financial",description:"Returns the number of days from the settlement date to the next coupon date."},{formulaName:"COUPNCD",category:"Financial",description:"Returns the next coupon date after the settlement date."},{formulaName:"COUPNUM",category:"Financial",description:"Returns the number of coupons payable between settlement and maturity."},{formulaName:"COUPPCD",category:"Financial",description:"Returns the previous coupon date before the settlement date."},{formulaName:"ACCRINT",category:"Financial",description:"Returns the accrued interest for a security that pays periodic interest."},{formulaName:"ACCRINTM",category:"Financial",description:"Returns the accrued interest for a security that pays interest at maturity."},{formulaName:"ISPMT",category:"Financial",description:"Returns the interest paid during a specific period of an investment."},{formulaName:"MDURATION",category:"Financial",description:"Returns the modified Macauley duration for a security with an assumed par value of $100."},{formulaName:"PRICE",category:"Financial",description:"Returns the price per $100 face value of a security that pays periodic interest."},{formulaName:"PRICEDISC",category:"Financial",description:"Returns the price per $100 face value of a discounted security."},{formulaName:"PRICEMAT",category:"Financial",description:"Returns the price per $100 face value of a security that pays interest at maturity."},{formulaName:"TBILLEQ",category:"Financial",description:"Returns the bond-equivalent yield for a Treasury bill."},{formulaName:"TBILLPRICE",category:"Financial",description:"Returns the price per $100 face value for a Treasury bill."},{formulaName:"TBILLYIELD",category:"Financial",description:"Returns the yield for a Treasury bill."},{formulaName:"XNPV",category:"Financial",description:"Returns the net present value for a schedule of cash flows that is not necessarily periodic."},{formulaName:"YIELD",category:"Financial",description:"Returns the yield on a security that pays periodic interest."},{formulaName:"YIELDDISC",category:"Financial",description:"Returns the annual yield for a discounted security."},{formulaName:"YIELDMAT",category:"Financial",description:"Returns the annual yield of a security that pays interest at maturity."}],t.bond=new Bt(t.parent),t}return Xt(n,e),n.prototype.parseBondArgs=function(e,n,i){if(t.isNullOrUndefined(e)||e.length<n||e.length>i)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a={settlement:o,maturity:s};if(e.length>=3){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a.rate=u}if(e.length>=4){var l=this.resolveNumberArg(e[3]);if("string"==typeof l)return l;a.yld=l}if(e.length>=5){var h=this.resolveNumberArg(e[4]);if("string"==typeof h)return h;a.redemption=h}return a.frequency=e.length>=6&&""!==e[5]?this.resolveNumberArg(e[5]):2,"string"==typeof a.frequency?a.frequency:(a.basis=e.length>=7&&""!==e[6]?this.resolveNumberArg(e[6]):0,"string"==typeof a.basis?a.basis:a)},n.prototype.coupArgs=function(e){if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var n=this.resolveNumberArg(e[0]),i=this.resolveNumberArg(e[1]),o=this.resolveNumberArg(e[2]);if("string"==typeof n)return n;if("string"==typeof i)return i;if("string"==typeof o)return o;var s=0;if(4===e.length&&""!==e[3]){var a=this.resolveNumberArg(e[3]);if("string"==typeof a)return a;s=Math.floor(a)}return{settlement:n,maturity:i,frequency:Math.floor(o),basis:s}},n.prototype.ComputeCOUPDAYBS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupDayBS(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPDAYS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupDays(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPDAYSNC=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupDaysNC(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPNCD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupNCD(e.settlement,e.maturity,e.frequency).toString()},n.prototype.ComputeCOUPNUM=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupNum(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPPCD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupPCD(e.settlement,e.maturity,e.frequency).toString()},n.prototype.ComputeACCRINT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.parseBondArgs(t,6,8);if("string"==typeof i)return i;var o=t.length>=8?this.resolveNumberArg(t[7]):i.settlement;if("string"==typeof o)return o;var s=i.rate,a=i.frequency,u=i.basis,l=this.bond.coupDayBS(i.settlement,i.maturity,a,u),h=this.bond.coupDays(i.settlement,i.maturity,a,u);return 0===h?n[r.CommonErrors.Num]:((t.length>=7&&""!==t[6]?this.resolveNumberArg(t[6]):1e3)*s/a*l/h).toString()},n.prototype.ComputeACCRINTM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0;if(5===e.length&&""!==e[4]){var l=this.resolveNumberArg(e[4]);if("string"==typeof l)return l;u=Math.floor(l)}return(a*s*this.bond.daysBetween(i,o,u)/this.bond.yearDays(u)).toString()},n.prototype.ComputeISPMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||4!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=Math.floor(s);return l<1||l>a?i[r.CommonErrors.Num]:(-u*o*(1-(l-1)/a)).toString()},n.prototype.ComputeMDURATION=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.parseBondArgs(r,5,7);if("string"==typeof e)return e;var n=e.frequency;return(1/n/(1+e.yld/n)).toString()},n.prototype.ComputePRICE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.parseBondArgs(r,6,7);if("string"==typeof e)return e;for(var n=e.rate,i=e.yld,o=e.redemption,s=e.frequency,a=e.basis,u=this.bond.coupNum(e.settlement,e.maturity,s,a),l=this.bond.coupDaysNC(e.settlement,e.maturity,s,a),h=this.bond.coupDays(e.settlement,e.maturity,s,a),p=this.bond.coupDayBS(e.settlement,e.maturity,s,a),g=100*n/s,f=o/Math.pow(1+i/s,u-1+l/h),m=1;m<=u;m++)f+=g/Math.pow(1+i/s,m-1+l/h);return(f-=g*p/h).toString()},n.prototype.ComputePRICEDISC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0;if(5===e.length&&""!==e[4]){var l=this.resolveNumberArg(e[4]);if("string"==typeof l)return l;u=Math.floor(l)}return(a*(1-s*this.bond.daysBetween(i,o,u)/this.bond.yearDays(u))).toString()},n.prototype.ComputePRICEMAT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<5||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=0;if(6===e.length&&""!==e[5]){var h=this.resolveNumberArg(e[5]);if("string"==typeof h)return h;l=Math.floor(h)}var p=this.bond.yearDays(l),g=this.bond.daysBetween(s,i,l);return((100+a*this.bond.daysBetween(s,o,l)/p)/(1+u*g/p)).toString()},n.prototype.ComputeTBILLPRICE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=o-i;return a<=0?this.parent.getErrorStrings()[r.CommonErrors.Num]:(100*(1-s*a/360)).toString()},n.prototype.ComputeTBILLYIELD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=o-i;return a<=0||s<=0?this.parent.getErrorStrings()[r.CommonErrors.Num]:((100-s)/s*360/a).toString()},n.prototype.ComputeTBILLEQ=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeTBILLYIELD.apply(this,r),n=this.parent.getErrorStrings();if("string"==typeof e&&n.indexOf(e)>-1)return e;var i=this.parent.parseFloat(e);return(365*i/(360-i*(this.resolveNumberArg(r[1])-this.resolveNumberArg(r[0])))).toString()},n.prototype.ComputeXNPV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=[],a=[],u=this.parent.getCellCollection(e[1]),l=this.parent.getCellCollection(e[2]),h=Array.isArray(u)?u:[u],p=Array.isArray(l)?l:[l];if(h.length!==p.length||h.length<1)return i[r.CommonErrors.Num];for(d=0;d<h.length;d++){var g=this.parent.getValueFromArg(h[d]),f=this.parent.getValueFromArg(p[d]);if(i.indexOf(g)>-1)return g;if(i.indexOf(f)>-1)return f;s.push(this.parent.parseFloat(g)),a.push(this.parent.parseFloat(f))}for(var m=a[0],c=0,d=0;d<s.length;d++)c+=s[d]/Math.pow(1+o,(a[d]-m)/365);return c.toString()},n.prototype.ComputeYIELD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputePRICE.apply(this,r),n=this.parent.getErrorStrings();if("string"==typeof e&&(n.indexOf(e)>-1||e.match(/arguments/i)))return e;var i=this.parseBondArgs(r,6,7);if("string"==typeof i)return i;for(var o=this.parent.parseFloat(e),s=i.yld||.05,a=0;a<50;a++){i.yld=s;var u=this.parent.parseFloat(this.ComputePRICE(r[0],r[1],r[2],s.toString(),r[4],r[5],r[6]))-o;if(Math.abs(u)<1e-8)return s.toString();s+=1e-4*u}return s.toString()},n.prototype.ComputeYIELDDISC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0;if(5===e.length&&""!==e[4]){var l=this.resolveNumberArg(e[4]);if("string"==typeof l)return l;u=Math.floor(l)}var h=this.bond.daysBetween(i,o,u),p=this.bond.yearDays(u);return h<=0?this.parent.getErrorStrings()[r.CommonErrors.Num]:((a-s)/s*p/h).toString()},n.prototype.ComputeYIELDMAT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<5||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]),l=this.resolveNumberArg(e[4]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;var h=0;if(6===e.length&&""!==e[5]){var p=this.resolveNumberArg(e[5]);if("string"==typeof p)return p;h=Math.floor(p)}var g=this.bond.yearDays(h),f=this.bond.daysBetween(a,o,h),m=100+u*this.bond.daysBetween(a,s,h)/g-l,c=l*f/g;return 0===c?i[r.CommonErrors.Num]:(m/c).toString()},n}(Q),Ht=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Gt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"AMORDEGRC",category:"Financial",description:"Returns the depreciation for each accounting period using a depreciation coefficient."},{formulaName:"AMORLINC",category:"Financial",description:"Returns the depreciation for each accounting period."},{formulaName:"ODDFPRICE",category:"Financial",description:"Returns the price per $100 face value of a security with an odd first period."},{formulaName:"ODDFYIELD",category:"Financial",description:"Returns the yield of a security with an odd first period."},{formulaName:"ODDLPRICE",category:"Financial",description:"Returns the price per $100 face value of a security with an odd last period."},{formulaName:"ODDLYIELD",category:"Financial",description:"Returns the yield of a security with an odd last period."}],t.bond=new Bt(t.parent),t}return Ht(n,e),n.prototype.ComputeAMORLINC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<6||e.length>7)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]),l=this.resolveNumberArg(e[4]),h=this.resolveNumberArg(e[5]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;var p=Math.floor(l);return p<0?i[r.CommonErrors.Num]:Math.min((o-u)*h*(p+1),o-u).toString()},n.prototype.ComputeAMORDEGRC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<7||e.length>8)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]),l=this.resolveNumberArg(e[5]),h=e.length>=8?this.resolveNumberArg(e[7]):0;if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;var p=l<.03?1:l<.05?1.5:l<.1?2:2.5;return this.ComputeAMORLINC(e[0],e[1],e[2],e[3],e[4],(l*p).toString())},n.prototype.oddBondPrice=function(e,n){if(t.isNullOrUndefined(e)||e.length<7||e.length>9)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]),l=this.resolveNumberArg(e[5]),h=this.resolveNumberArg(e[6]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;var p=e.length>=8&&""!==e[7]?this.resolveNumberArg(e[7]):2,g=e.length>=9&&""!==e[8]?this.resolveNumberArg(e[8]):0;if("string"==typeof p)return p;if("string"==typeof g)return g;var f=this.bond.coupNum(i,o,p,g),m=100*u/p,c=n?a:o,d=this.bond.daysBetween(i,c,g),v=this.bond.coupDays(i,o,p,g)||180,N=h/Math.pow(1+l/p,f+d/v);N+=m*d/v;for(var E=1;E<=f;E++)N+=m/Math.pow(1+l/p,E-1+d/v);return N.toString()},n.prototype.ComputeODDFPRICE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.oddBondPrice(r,!0)},n.prototype.ComputeODDLPRICE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.oddBondPrice(r,!1)},n.prototype.oddBondYield=function(r,t){for(var e=t[6],n=.05,i=this.parent.parseFloat(this.resolveNumberArg(e)),o=0;o<50;o++){var s=t.slice(0,6).concat([n.toString()],t.slice(7)),a=this.parent.parseFloat(r.apply(void 0,s))-i;if(Math.abs(a)<1e-6)return n.toString();n-=1e-4*a}return n.toString()},n.prototype.ComputeODDFYIELD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.isNullOrUndefined(e)||e.length<8||e.length>9?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.oddBondYield(this.ComputeODDFPRICE.bind(this),e)},n.prototype.ComputeODDLYIELD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.isNullOrUndefined(e)||e.length<8||e.length>9?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.oddBondYield(this.ComputeODDLPRICE.bind(this),e)},n}(Q),Zt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Kt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"BETADIST",category:"Statistical",description:"Returns the beta cumulative distribution function."},{formulaName:"BETAINV",category:"Statistical",description:"Returns the inverse of the beta cumulative distribution function."},{formulaName:"TDIST",category:"Statistical",description:"Returns the Student t-distribution."},{formulaName:"TINV",category:"Statistical",description:"Returns the inverse of the Student t-distribution."},{formulaName:"TTEST",category:"Statistical",description:"Returns the probability associated with a Student t-test."},{formulaName:"FTEST",category:"Statistical",description:"Returns the result of an F-test."},{formulaName:"FREQUENCY",category:"Statistical",description:"Returns the frequency distribution of a range of values."}],t}return Zt(n,e),n.prototype.ComputeBETADIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0,l=1;if(e.length>=4&&""!==e[3]){var h=this.resolveNumberArg(e[3]);if("string"==typeof h)return h;u=h}if(e.length>=5&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;l=p}if(o<u||o>l||s<=0||a<=0||u>=l)return i[r.CommonErrors.Num];var g=k((o-u)/(l-u),s,a);return isNaN(g)?i[r.CommonErrors.Num]:g.toString()},n.prototype.ComputeBETAINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0,l=1;if(e.length>=4&&""!==e[3]){var h=this.resolveNumberArg(e[3]);if("string"==typeof h)return h;u=h}if(e.length>=5&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;l=p}var g=_(o,s,a);return isNaN(g)?i[r.CommonErrors.Num]:(u+g*(l-u)).toString()},n.prototype.ComputeTDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=1;if(3===e.length&&""!==e[2]){var a=this.resolveNumberArg(e[2]);if("string"==typeof a)return a;s=Math.floor(a)}var u=j(Math.abs(i),o);return(1===s?1-u:2*(1-u)).toString()},n.prototype.ComputeTINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=2;if(3===e.length&&""!==e[2]){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a=Math.floor(u)}var l=L(1===a?1-o:1-o/2,s);return isNaN(l)?i[r.CommonErrors.Num]:l.toString()},n.prototype.ComputeTTEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1),s=this.collectSample([e[1]],!1);if("string"==typeof o)return o;if("string"==typeof s)return s;if(o.length<2||s.length<2)return i[r.CommonErrors.DivZero];for(var a=this.mean(o),u=this.mean(s),l=0,h=0,p=0;p<o.length;p++)l+=Math.pow(o[p]-a,2);for(p=0;p<s.length;p++)h+=Math.pow(s[p]-u,2);l/=o.length-1,h/=s.length-1;var g=Math.sqrt(l/o.length+h/s.length);if(0===g)return i[r.CommonErrors.DivZero];var f=Math.abs(a-u)/g,m=o.length+s.length-2,c=2;if(4===e.length&&""!==e[3]){var d=this.resolveNumberArg(e[3]);if("string"==typeof d)return d;c=Math.floor(d)}var v=j(f,m);return(1===c?1-v:2*(1-v)).toString()},n.prototype.ComputeFTEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1),s=this.collectSample([e[1]],!1);if("string"==typeof o)return o;if("string"==typeof s)return s;if(o.length<2||s.length<2)return i[r.CommonErrors.DivZero];var a=this.sampleVar(o),u=this.sampleVar(s);if(0===u)return i[r.CommonErrors.DivZero];var l=a/u,h=o.length-1,p=s.length-1;return(2*Math.min(O(l,h,p),O(1/l,p,h))).toString()},n.prototype.sampleVar=function(r){for(var t=this.mean(r),e=0,n=0;n<r.length;n++)e+=Math.pow(r[n]-t,2);return e/(r.length-1)},n.prototype.ComputeFREQUENCY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1),s=this.collectSample([e[1]],!1);if("string"==typeof o)return o;if("string"==typeof s)return s;if(0===s.length)return i[r.CommonErrors.Num];for(var a=s.slice().sort(function(r,t){return r-t}),u=new Array(a.length+1).fill(0),l=0;l<o.length;l++){for(var h=o[l],p=!1,g=0;g<a.length;g++)if(h<=a[g]){u[g]++,p=!0;break}p||u[u.length-1]++}var f=this.parent.getParseArgumentSeparator();return u.join(f)},n}(qr),$t=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),zt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DAVERAGE",category:"Database",description:"Averages the values in a column of a list or database that match criteria."},{formulaName:"DCOUNT",category:"Database",description:"Counts the cells that contain numbers in a column of a list or database that match criteria."},{formulaName:"DCOUNTA",category:"Database",description:"Counts nonblank cells in a column of a list or database that match criteria."},{formulaName:"DGET",category:"Database",description:"Extracts a single value from a column of a list or database that matches criteria."},{formulaName:"DMAX",category:"Database",description:"Returns the maximum value from a column of a list or database that matches criteria."},{formulaName:"DMIN",category:"Database",description:"Returns the minimum value from a column of a list or database that matches criteria."},{formulaName:"DPRODUCT",category:"Database",description:"Multiplies values in a column of a list or database that match criteria."},{formulaName:"DSTDEV",category:"Database",description:"Estimates the standard deviation of a population based on a sample of entries that match criteria."},{formulaName:"DSTDEVP",category:"Database",description:"Calculates the standard deviation of a population based on entries that match criteria."},{formulaName:"DSUM",category:"Database",description:"Adds the numbers in the field column of records in the database that match the criteria."},{formulaName:"DVAR",category:"Database",description:"Estimates variance based on a sample of entries that match criteria."},{formulaName:"DVARP",category:"Database",description:"Calculates variance based on the entire population of entries that match criteria."}],t}return $t(n,e),n.prototype.readRange=function(t){var e=this.parent.getErrorStrings();if(!this.parent.isCellReference(t))return e[r.CommonErrors.Value];for(var n=t.indexOf(":")>-1?t.split(":"):[t,t],i=this.parent.rowIndex(n[0]),o=this.parent.colIndex(n[0]),s=this.parent.rowIndex(n[1]),a=this.parent.colIndex(n[1]),u=Math.min(i,s),l=Math.max(i,s),h=Math.min(o,a),p=Math.max(o,a),g=[],f=u;f<=l;f++){for(var m=[],c=h;c<=p;c++){var d=K(c)+f;m.push(this.parent.getValueFromArg(d))}g.push(m)}return g},n.prototype.fieldIndex=function(t,e){var n=this.parent.getErrorStrings(),i=this.resolveTextArg(t);if(n.indexOf(i)>-1)return i;var o=this.parent.parseFloat(i);if(!isNaN(o)&&o>=1&&o<=e.length)return Math.floor(o)-1;for(var s=i.toUpperCase(),a=0;a<e.length;a++)if(e[a].toUpperCase()===s)return a;return n[r.CommonErrors.Value]},n.prototype.matchCriteria=function(r,t,e){for(var n=0;n<t.length;n++){for(var i=t[n],o=!0,s=0;s<e.length;s++){var a=i[s];if(void 0!==a&&""!==a){var u=r[s];if(!this.matchesCriterion(u,a)){o=!1;break}}}if(o)return!0}return!1},n.prototype.matchesCriterion=function(r,t){var e=t.trim();if(""===e)return!0;for(var n=[">=","<=","<>",">","<","="],i=0;i<n.length;i++){var o=n[i];if(e.startsWith(o)){var s=e.substring(o.length).trim(),a=this.parent.parseFloat(r),u=this.parent.parseFloat(s);if(!isNaN(a)&&!isNaN(u))switch(o){case">=":return a>=u;case"<=":return a<=u;case"<>":return a!==u;case">":return a>u;case"<":return a<u;case"=":return a===u;default:return o}return"="===o||""===o?r.toUpperCase()===s.toUpperCase():"<>"===o&&r.toUpperCase()!==s.toUpperCase()}}return e.includes("*")||e.includes("?")?new RegExp("^"+e.replace(/\*/g,".*").replace(/\?/g,".")+"$","i").test(r):r.toUpperCase()===e.toUpperCase()},n.prototype.collectMatching=function(t,e,n,i){var o=this.readRange(t);if("string"==typeof o)return o;if(o.length<2)return this.parent.getErrorStrings()[r.CommonErrors.Value];var s=o[0],a=this.fieldIndex(e,s);if("string"==typeof a)return a;var u=this.readRange(n);if("string"==typeof u)return u;if(u.length<2)return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var l=u[0],h=u.slice(1),p=[],g=this,f=1;f<o.length;f++)!function(r){var t=o[r],e=s.map(function(r,e){return t[e]||""}),n=h.map(function(r){return l.map(function(t,e){return r[e]||""})});if(!g.matchCriteria(e,n,s))return"continue";var i=t[a]||"";""!==i&&g.parent.isNumber(i)&&p.push(g.parent.parseFloat(i))}(f);return p},n.prototype.requireThree=function(e){return t.isNullOrUndefined(e)||3!==e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:null},n.prototype.mean=function(r){return r.reduce(function(r,t){return r+t},0)/r.length},n.prototype.variance=function(r,t){for(var e=this.mean(r),n=0,i=0;i<r.length;i++)n+=Math.pow(r[i]-e,2);return n/(t?r.length:r.length-1)},n.prototype.ComputeDAVERAGE=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof i?i:0===i.length?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:this.mean(i).toString()},n.prototype.ComputeDCOUNT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.collectMatching(r[0],r[1],r[2],!0);return"string"==typeof n?n:n.length.toString()},n.prototype.ComputeDCOUNTA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.readRange(r[0]);if("string"==typeof n)return n;var i=n[0],o=this.fieldIndex(r[1],i);if("string"==typeof o)return o;var s=this.readRange(r[2]);if("string"==typeof s)return s;for(var a=s.slice(1),u=0,l=1;l<n.length;l++){var h=n[l],p=a.map(function(r){return s[0].map(function(t,e){return r[e]||""})});this.matchCriteria(h,p,i)&&""!==(h[o]||"")&&u++}return u.toString()},n.prototype.ComputeDGET=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!1);return"string"==typeof o?o:0===o.length?i[r.CommonErrors.NA]:o.length>1?i[r.CommonErrors.Num]:o[0].toString()},n.prototype.ComputeDMAX=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof i?i:0===i.length?this.parent.getErrorStrings()[r.CommonErrors.NA]:Math.max.apply(Math,i).toString()},n.prototype.ComputeDMIN=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof i?i:0===i.length?this.parent.getErrorStrings()[r.CommonErrors.NA]:Math.min.apply(Math,i).toString()},n.prototype.ComputeDPRODUCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.collectMatching(r[0],r[1],r[2],!0);return"string"==typeof n?n:0===n.length?"0":n.reduce(function(r,t){return r*t},1).toString()},n.prototype.ComputeDSUM=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.collectMatching(r[0],r[1],r[2],!0);return"string"==typeof n?n:n.reduce(function(r,t){return r+t},0).toString()},n.prototype.ComputeDSTDEV=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<2?i[r.CommonErrors.DivZero]:Math.sqrt(this.variance(o,!1)).toString()},n.prototype.ComputeDSTDEVP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<1?i[r.CommonErrors.DivZero]:Math.sqrt(this.variance(o,!0)).toString()},n.prototype.ComputeDVAR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<2?i[r.CommonErrors.DivZero]:this.variance(o,!1).toString()},n.prototype.ComputeDVARP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<1?i[r.CommonErrors.DivZero]:this.variance(o,!0).toString()},n}(Q),Qt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Jt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"LINEST",category:"Statistical",description:"Returns statistics that describe a linear trend."},{formulaName:"LOGEST",category:"Statistical",description:"Returns statistics that describe an exponential curve."},{formulaName:"GROWTH",category:"Statistical",description:"Returns numbers in an exponential growth trend."},{formulaName:"TREND",category:"Statistical",description:"Returns numbers in a linear trend."}],t}return Qt(n,e),n.prototype.linearRegression=function(t,e){var n=this.collectPair([e,t]);if("string"==typeof n)return n;var i=n.x,o=n.y;if(i.length<2)return this.parent.getErrorStrings()[r.CommonErrors.NA];for(var s=this.mean(i),a=this.mean(o),u=0,l=0,h=0;h<i.length;h++){var p=i[h]-s;u+=p*p,l+=p*(o[h]-a)}if(0===u)return this.parent.getErrorStrings()[r.CommonErrors.DivZero];var g=l/u;return{slope:g,intercept:a-g*s}},n.prototype.expRegression=function(t,e){var n=this.collectPair([e,t]);if("string"==typeof n)return n;var i=n.x,o=n.y,s=this.parent.getErrorStrings();if(i.length<2)return s[r.CommonErrors.NA];for(var a=[],u=0;u<o.length;u++){if(o[u]<=0)return s[r.CommonErrors.Num];a.push(Math.log(o[u]))}for(var l=this.mean(i),h=this.mean(a),p=0,g=0,u=0;u<i.length;u++){var f=i[u]-l;p+=f*f,g+=f*(a[u]-h)}if(0===p)return s[r.CommonErrors.DivZero];var m=g/p;return{b:Math.exp(h-m*l),m:m}},n.prototype.ComputeLINEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.linearRegression(e[0],e[1]);return"string"==typeof i?i:i.slope.toString()},n.prototype.ComputeLOGEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.expRegression(e[0],e[1]);return"string"==typeof i?i:i.b.toString()},n.prototype.ComputeTREND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.linearRegression(e[0],e[1]);if("string"==typeof i)return i;var o;if(3===e.length&&""!==e[2]){var s=this.collectSample([e[2]],!1);if("string"==typeof s)return s;if(0===s.length)return this.parent.getErrorStrings()[r.CommonErrors.NA];o=s[0]}else{var a=this.collectSample([e[1]],!1);if("string"==typeof a)return a;o=a[a.length-1]+1}return(i.intercept+i.slope*o).toString()},n.prototype.ComputeGROWTH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.expRegression(e[0],e[1]);if("string"==typeof i)return i;var o;if(3===e.length&&""!==e[2]){var s=this.collectSample([e[2]],!1);if("string"==typeof s)return s;if(0===s.length)return this.parent.getErrorStrings()[r.CommonErrors.NA];o=s[0]}else{var a=this.collectSample([e[1]],!1);if("string"==typeof a)return a;o=a[a.length-1]+1}return(i.b*Math.pow(Math.E,i.m*o)).toString()},n}(qr),re=function(){function r(r){this.formulas=[],this.isConcat=!1,this.parent=r;for(var e=[new rr(this),new er(this),new ir(this),new sr(this),new ur(this),new hr(this),new gr(this),new dr(this),new Nr(this),new Sr(this),new Cr(this),new Ar(this),new Fr(this),new Vr(this),new Rr(this),new Mr(this),new Ur(this),new jr(this),new kr(this),new Pr(this),new Xr(this),new Hr(this),new Zr(this),new $r(this),new Qr(this),new rt(this),new et(this),new it(this),new st(this),new ut(this),new ht(this),new gt(this),new mt(this),new dt(this),new Nt(this),new St(this),new Ct(this),new At(this),new Ft(this),new Vt(this),new Rt(this),new Mt(this),new Ut(this),new jt(this),new kt(this),new Pt(this),new qt(this),new Yt(this),new Gt(this),new Kt(this),new zt(this),new Jt(this)],n=0;n<e.length;n++)for(var i=e[n],o=0;o<i.formulas.length;o++){var s=i.formulas[o];this.formulas.push(s);var a="Compute"+s.formulaName,u=s.formulaName.indexOf(".")>-1?i[a]:t.getValue(a,i);u&&(this[a]=u.bind(i))}this.init()}return r.prototype.init=function(){for(var r=0;r<this.formulas.length;r++){var t=this.formulas[r],e=this["Compute"+t.formulaName];this.addFormulaCollection(t.formulaName.toUpperCase(),e,t.category,t.description)}},r.prototype.addFormulaCollection=function(r,t,e,n){this.parent.libraryFormulas={fName:r,handler:t,category:e,description:n}},r}(),te=function(){function e(r){this.emptyStr="",this.storedStringText=this.emptyStr,this.sheetToken="!",this.tokenAdd="a",this.tokenSubtract="s",this.tokenMultiply="m",this.tokenDivide="d",this.tokenLess="l",this.charEm="r",this.charEp="x",this.tokenGreater="g",this.tokenEqual="e",this.tokenLessEq="k",this.tokenGreaterEq="j",this.tokenNotEqual="o",this.tokenAnd="c",this.tokenEm="v",this.tokenEp="t",this.tokenOr=String.fromCharCode(126),this.charAnd="i",this.charLess="<",this.charGreater=">",this.charEqual="=",this.charLessEq="f",this.charGreaterEq="h",this.charNoEqual="z",this.stringGreaterEq=">=",this.stringLessEq="<=",this.stringNoEqual="<>",this.stringAnd="&",this.stringOr="^",this.charOr="w",this.charAdd="+",this.charSubtract="-",this.charMultiply="*",this.charDivide="/",this.fixedReference="$",this.spaceString=" ",this.ignoreBracet=!1,this.isError=!1,this.isFormulaParsed=!1,this.findNamedRange=!1,this.stringsColl=new Map,this.tokens=[this.tokenAdd,this.tokenSubtract,this.tokenMultiply,this.tokenDivide,this.tokenLess,this.tokenGreater,this.tokenEqual,this.tokenLessEq,this.tokenGreaterEq,this.tokenNotEqual,this.tokenAnd,this.tokenOr],this.charNOTop=String.fromCharCode(167),this.specialSym=["~","@","#","?"],this.isFailureTriggered=!1,this.parent=r}return e.prototype.parse=function(e,n){var o=this;if(this.parent.isTextEmpty(e))return e;if(i(e))return this.parent.getErrorStrings()[r.CommonErrors.Ref];this.parent.getFormulaCharacter()!==String.fromCharCode(0)&&this.parent.getFormulaCharacter()===e[0]&&(e=e.substring(1)),(this.parent.namedRanges.size>0||this.parent.storedData.size>0)&&(e=this.checkForNamedRangeAndKeyValue(e),this.findNamedRange=!1);var s=this.storeStrings(e);e=(e=(e=this.storedStringText).replace(/[-+*/&^]+/g,function(t){for(var e="";1<t.length;)switch(t.substring(0,2)){case"++":case"--":t="+"+t.substring(2);break;case"+-":case"-+":t="-"+t.substring(2);break;case"*+":t="*"+t.substring(2);break;case"/+":t="/"+t.substring(2);break;case"^+":t="^"+t.substring(2);break;case"&+":t="&"+t.substring(2);break;case"*-":case"/-":case"^-":case"&-":e=t.substring(0,1),t=t.substring(1);break;default:throw new oe(o.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression],!0)}return e+t})).split("-(-").join("(");var a=0;if(t.isNullOrUndefined(s)&&(e=e.split(" ").join("")),e=e.split("=>").join(">="),(e=e.split("=<").join("<="))[e.length-1]===this.parent.arithMarker&&this.indexOfAny(e,this.tokens)===e.length-2||(e=e.toUpperCase()),e.indexOf(this.sheetToken)>-1){var u=this.parent.getSheetFamilyItem(this.parent.grid);if(null!=u.sheetNameToParentObject&&u.sheetNameToParentObject.size>0){e[0]!==this.sheetToken.toString()&&(e=this.parent.setTokensForSheets(e));var l=this.parent.getSheetToken(e.split(this.parent.tic).join(this.emptyStr)),h=this.checkScopedRange(e.split('"').join(this.emptyStr).split(this.sheetToken).join(""));t.isNullOrUndefined(l)&&""!==l&&this.parent.namedRanges.size>0&&""!==h&&(e=h)}}e=this.processIndexArg(e),e=this.markLibraryFormulas(e);try{e=this.formulaAutoCorrection(e)}catch(t){if(!(f={message:t.message,exception:t,isForceCalculable:t.formulaCorrection,computeForceCalculate:!1}).isForceCalculable)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression];if(this.isFailureTriggered||(this.parent.trigger("onFailure",f),this.isFailureTriggered=!0),!f.isForceCalculable||!f.computeForceCalculate)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression];e=this.formulaAutoCorrection(e,f),this.parent.storedData.get(n).formulaText="="+e}if(!this.ignoreBracet)for(a=e.indexOf(")");a>-1;){var p=e.substring(0,a).lastIndexOf("(");if(-1===p)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedParentheses]);if(p===a-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.EmptyExpression]);var g=this.emptyStr;g=this.ignoreBracet?this.parent.substring(e,p,a-p+1):this.parent.substring(e,p+1,a-p-1);try{e=e.substring(0,p)+this.parseSimple(g)+e.substring(a+1)}catch(t){if(t===this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference])throw t;var f=this.exceptionArgs(t);this.isFailureTriggered||(this.parent.trigger("onFailure",f),this.isFailureTriggered=!0);var m="string"==typeof f.exception?f.exception:f.message;return(this.parent.getErrorLine(t)?"":"#"+this.parent.getErrorLine(t)+": ")+m}a=e.indexOf(")")}if(!this.ignoreBracet&&e.indexOf("(")>-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedParentheses]);return e=this.parseSimple(e),null!==s&&s.size>0&&(e=this.setStrings(e,s)),e},e.prototype.exceptionArgs=function(r){return{message:r.message,exception:r,isForceCalculable:r.formulaCorrection,computeForceCalculate:!1}},e.prototype.formulaAutoCorrection=function(e,n,i){var o=["*","+","-","/","^","&"],s=[">","=","<"],a=0,u="",l="",h="",p="",g="",f="",m="",c=0;if(this.parent.formulaErrorStrings.indexOf(e)>-1)return e;if(this.indexOfAny(e,this.specialSym)>-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression],!1);for(e=e.split("-*").join("-").split("/*").join("/").split("*/").join("*").split("-/").join("-").split("*+").join("*").split("+*").join("+");a<e.length;)if(this.parent.isDigit(e[a])&&e.length>a+1&&this.indexOfAny(e[a+1],o)>-1&&e.length>a+2&&!t.isNullOrUndefined(e[a+2])&&this.indexOfAny(e[a+2],o)>-1&&("-"!==e[a+2]||"*"!==e[a+1]&&"/"!==e[a+1]&&"^"!==e[a+1]&&"&"!==e[a+1])){if(!n||!n.computeForceCalculate)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];this.parent.isDigit(e[a])?(c<1?(f=e[a],h=e[a+1],t.isNullOrUndefined(h)&&(h=this.emptyStr),c+=1,u=u+f+(h="&"===h?"":h)):c<2&&(m=e[a],p=e[a-1],g=e[a+1],c=0,u="-"===p?u+p+m+(g="&"===(g=t.isNullOrUndefined(g)?this.emptyStr:g)?"":g):u+m+(g=t.isNullOrUndefined(g)?this.emptyStr:g)),a+=2):(u="-"===e[a]?u+e[a]:u,a+=1)}else if((this.parent.isDigit(e[a])||e[a]===this.parent.rightBracket||this.parent.storedData.has(e[a].toUpperCase()))&&(t.isNullOrUndefined(e[a+1])||this.indexOfAny(e[a+1],o)>-1&&"&"!==e[a+1]))l="&"===(l=t.isNullOrUndefined(e[a+1])?this.emptyStr:e[a+1])&&"-"!==e[a+2]?"":l,u="-"===e[a-1]?u+e[a-1]+e[a]+l:u+e[a]+l,a+=2;else if(this.indexOfAny(e[a],s)>-1&&!t.isNullOrUndefined(e[a-1])&&!t.isNullOrUndefined(e[a+1]))u+=e[a],a+=1;else if("q"===e[a])for(;e[a]!==this.parent.leftBracket;)u+=e[a],a+=1;else e[a]===this.parent.leftBracket||e[a]===this.parent.rightBracket||"{"===e[a]||"}"===e[a]||"("===e[a]||")"===e[a]?(u+=e[a],a+=1):this.parent.isUpperChar(e[a])||e[a].indexOf(":")>-1||e[a]===this.parent.getParseArgumentSeparator()||"%"===e[a]&&this.parent.isDigit(e[a-1])||this.isOtherLangChar(e[a])?(u+=e[a],a+=1):e[a]===this.parent.tic||" "===e[a]||e[a]===this.parent.getParseDecimalSeparator()||e[a]===this.sheetToken||"$"===e[a]||"_"===e[a]?(u+=e[a],a+=1):(this.parent.isDigit(e[a])&&(u="-"===e[a-1]?u+e[a-1]+e[a]:u+e[a]),"-"!==e[a]&&"+"!==e[a]||(u=(u+=e[a]).split("++").join("+").split("+-").join("-").split("-+").join("-")),"/"!==e[a]&&"*"!==e[a]&&"^"!==e[a]||(u+=e[a]),"&"!==e[a]||!i&&"q"===e.substring(a+1).trim()[0]||(u+=e[a]),a+=1);return u=u===this.emptyStr?e:u,this.indexOfAny(u[u.length-1],o)>-1&&(u=u.substring(0,u.length-1)),u=u.split("--").join("-").split("-+").join("-").split("+-").join("-")},e.prototype.checkScopedRange=function(r){var e=this,n=this.emptyStr,i="NaN",o=this.parent.getSheetID(this.parent.grid),s=this.parent.getSheetFamilyItem(this.parent.grid);if(r[0]===this.sheetToken.toString()){var a=r.indexOf(this.sheetToken,1),u=parseInt(r.substr(1,a-1),10);a>1&&!this.parent.isNaN(u)&&(r=r.substring(a+1),o=u)}var l="!"+o.toString();return null===s||null==s.sheetNameToToken?i:(s.sheetNameToToken.forEach(function(o,a){if(s.sheetNameToToken.get(a).toString()===l+"!"){var u=e.emptyStr;e.parent.namedRanges.forEach(function(o,a){u=t.isNullOrUndefined(e.parent.parentObject)?s.sheetNameToToken.get(a).toUpperCase():e.parent.parentObject.getActiveSheet().name+e.sheetToken+r.toUpperCase(),e.parent.getNamedRanges().has(u)&&(n=e.parent.getNamedRanges().get(u).toUpperCase(),i=n)})}}),i)},e.prototype.storeStrings=function(t){var e,n=0,i=0,o=0,s="",a=null;if(t.indexOf(this.parent.tic)>-1)for(n=t.indexOf(this.parent.tic);n>-1&&t.length>0;){if(null===a&&(a=this.stringsColl),-1===(i=n+1<t.length?t.indexOf(this.parent.tic,n+1):-1))throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedTics]);e=this.parent.substring(t,n,i-n+1),s=this.parent.tic+this.spaceString+o.toString()+this.parent.tic,a=a.set(s,e),t=t.substring(0,n)+s+t.substring(i+1),(n+=s.length)<=t.length&&(n=t.indexOf(this.parent.tic,n)),o++}return this.storedStringText=t,a},e.prototype.setStrings=function(r,t){return t.forEach(function(t,e){r=r.split(e).join(t)}),r},e.prototype.parseSimple=function(r){var t=r;if(t.length>0&&"+"===t[0]&&(t=t.substring(1)),"#DIV/0!"===t)return"#DIV/0!";if("#NAME?"===t)return"#NAME?";if(""===t)return t;if(this.parent.formulaErrorStrings.indexOf(t)>-1)return t;t=(t=(t=(t=(t=(t=t.split(this.stringLessEq).join(this.charLessEq)).split(this.stringGreaterEq).join(this.charGreaterEq)).split(this.stringNoEqual).join(this.charNoEqual)).split(this.stringAnd).join(this.charAnd)).split(this.stringOr).join(this.charOr)).split(this.fixedReference).join(this.emptyStr);var e=[this.tokenEp,this.tokenEm],n=[this.tokenMultiply,this.tokenDivide],i=[this.tokenAdd,this.tokenSubtract],o=[this.charMultiply,this.charDivide],s=[this.charAdd,this.charSubtract],a=[this.tokenLess,this.tokenGreater,this.tokenEqual,this.tokenLessEq,this.tokenGreaterEq,this.tokenNotEqual],u=[this.charLess,this.charGreater,this.charEqual,this.charLessEq,this.charGreaterEq,this.charNoEqual],l=[this.charEp,this.charEm],h=[this.tokenAnd],p=[this.charAnd],g=[this.charOr],f=[this.tokenOr];return t=this.parseSimpleOperators(t,e,l),t=this.parseSimpleOperators(t,f,g),t=this.parseSimpleOperators(t,n,o),t=this.parseSimpleOperators(t,i,s),t=this.parseSimpleOperators(t,a,u),t=this.parseSimpleOperators(t,h,p)},e.prototype.parseSimpleOperators=function(e,n,i){if(this.parent.getErrorStrings().indexOf(e)>-1)return e;for(var o=e,s=0,a="",u=0;u<i.length;u++)a+=i[u];if(o=o.split("---").join("-").split("--").join("+").split(this.parent.getParseArgumentSeparator()+"-").join(this.parent.getParseArgumentSeparator()+"u").split(this.parent.leftBracket+"-").join(this.parent.leftBracket+"u").split("=-").join("=u"),o=o.split(",+").join(",").split(this.parent.leftBracket+"+").join(this.parent.leftBracket).split("=+").join("=").split(">+").join(">").split("<+").join("<").split("/+").join("/").split("*+").join("*").split("++").join("+").split("*-").join("*u").split("/-").join("/u").split("w-").join("wu").split("i-").join("iu").toString(),(o=o.split(">-").join(">u").split("<-").join("<u").split("h-").join("hu").split("f-").join("fu").split("z-").join("zu")).length>0&&"-"===o[0]){var l=String.fromCharCode(132);o="0-"+(o=o.substring(1).split("-").join(l)),o=(o=this.parseSimpleOperators(o,[this.tokenSubtract],[this.charSubtract])).split(l).join("-")}else o.length>0&&"+"===o[0]?o=o.substring(1):o.length>0&&"+"===o[o.length-1]&&(o=o.substring(0,o.length-1));try{if(this.indexOfAny(o,i)>-1){if(o.includes(" ")){for(var h="",p=0;p<o.length;p++){var g=o[p];if(i.indexOf(g)>=0)h=h.trim()+g;else{if(" "===g&&i.indexOf(h[h.length-1])>=0)continue;h+=g}}o=h}s=this.indexOfAny(o,i);for(var f=this.parent.getParseDecimalSeparator();s>-1;){var m="",c="",d=0,v=0,N=!1,E=["*","+","-","/","w","=","<",">"],S=0;if(o[s]===this.charNOTop)d=s;else if(S=s-1,o[S]===this.parent.arithMarker){if((C=this.findLeftMarker(o.substring(0,S-1)))<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);m=this.parent.substring(o,C+1,S-C-1),d=C+1}else if(o[S]===this.parent.rightBracket){for(var y=0,C=S-1;C>0&&("q"!==o[C]||0!==y);)"q"===o[C]?y--:o[C]===this.parent.rightBracket&&y++,C--;if(C<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);m=this.parent.substring(o,C,S-C+1),d=C}else if(o[S]===this.parent.tic[0]){var b=o.substring(0,S-1).lastIndexOf(this.parent.tic);if(b<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);m=this.parent.substring(o,b,S-b+1),d=b}else{for(O=!1;S>-1&&(this.parent.isDigit(o[S])||!O&&(o[S]===f||"%"===o[S]));)this.parent.isDigit(o[S])||"%"===o[S]||(O=!0),S-=1;if(S>-1&&O&&o[S]===f)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.NumberContains2DecimalPoints]);if(0===(S+=1)||S>0&&!this.parent.isUpperChar(o[S-1]))m="n"+this.parent.substring(o,S,s-S),d=S;else if(S>0&&"E"===o[S-1]&&("TRUE"===o.substring(S-4,S)&&(t.isNullOrUndefined(o[S-5])||E.indexOf(o[S-5])>-1)||"FALSE"===o.substring(S-5,S)&&(t.isNullOrUndefined(o[S-6])||E.indexOf(o[S-6])>-1))&&("TRUE"===o.substring(S+1,S+5)||"FALSE"===o.substring(S+1,S+6)))S="TRUE"===o.substring(S-4,S)?S-4:S-5,m="TRUE"===o.substring(S,s)?"n1":"FALSE"===o.substring(S,s)?"n0":m,d=S,N=!0;else{for(S-=1;S>-1&&(this.parent.isUpperChar(o[S])||this.parent.isDigit(o[S])||"_"===o[S]);)S-=1;if(S>-1&&o[S]===this.sheetToken){for(S-=1;S>-1&&o[S]!==this.sheetToken;)S-=1;S>-1&&o[S]===this.sheetToken&&(S-=1)}if(S>-1&&":"===o[S]){for(S-=1;S>-1&&this.parent.isDigit(o[S]);)S-=1;for(;S>-1&&this.parent.isUpperChar(o[S]);)S-=1;if(S>-1&&o[S]===this.sheetToken){for(S--;S>-1&&o[S]!==this.sheetToken;)S--;S>-1&&o[S]===this.sheetToken&&S--}S+=1,m=this.parent.substring(o,S,s-S),m=this.parent.getCellFrom(m)}else{var A=!1;S>0&&!this.parent.isUpperChar(o[S])&&(A="u"===o[S]&&o[S-1]===this.parent.getParseArgumentSeparator()),A||(S+=1),m=this.parent.substring(o,S,s-S)}this.parent.updateDependentCell(m),d=S}(this.parent.namedRanges.size>0&&this.parent.namedRanges.has(m.toUpperCase())||this.parent.storedData.has(m.toUpperCase()))&&(m="n"+this.checkForNamedRangeAndKeyValue(m))}if(s===o.length-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ExpressionCannotEndWithAnOperator]);if((A="u"===o[S=s+1])&&(S+=1),o[S]===this.parent.tic[0]){if((C=o.substring(S+1).indexOf(this.parent.tic))<0)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse];c=this.parent.substring(o,S,C+2),v=C+S+2}else if(o[S]===this.parent.arithMarker){if((C=this.findRightMarker(o.substring(S+1)))<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);c=this.parent.substring(o,S+1,C),v=C+S+2}else if("q"===o[S]){for(var y=0,C=S+1;C<o.length&&(o[C]!==this.parent.rightBracket||0!==y);)o[C]===this.parent.rightBracket?y++:"q"===o[C]&&y--,C++;if(C===o.length)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse];c=this.parent.substring(o,S,C-S+1),A&&(c="u"+c),v=C+1}else if(this.parent.isDigit(o[S])||o[S]===f){var O=o[S]===f;for(S+=1;S<o.length&&(this.parent.isDigit(o[S])||!O&&o[S]===f);)o[S]===f&&(O=!0),S+=1;if(S<o.length&&"%"===o[S]&&(S+=1),O&&S<o.length&&o[S]===f)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.NumberContains2DecimalPoints];c="n"+this.parent.substring(o,s+1,S-s-1),v=S}else if(this.parent.isUpperChar(o[S])||o[S]===this.sheetToken||"u"===o[S]){if(o[S]===this.sheetToken)for(S+=1;S<o.length&&o[S]!==this.sheetToken;)S+=1;S+=1;for(var F=0,x=!1;S<o.length&&(this.parent.isUpperChar(o[S])||"_"===o[S]||o[S]===f||"["===o[S]||"]"===o[S]||"#"===o[S]||" "===o[S]||"%"===o[S]||o[S]===f&&x);)S!==o.length-1&&"["===o[S]&&"["===o[S+1]&&(x=!0),S!==o.length-1&&"]"===o[S]&&"]"===o[S+1]&&(x=!1),S++,F++;var V=S===o.length||!this.parent.isDigit(o[S]);if(F>1){for(;S<o.length&&(this.parent.isUpperChar(o[S])||this.parent.isDigit(o[S])||" "===o[S]||"_"===o[S]);)S++;V=!0}for(;S<o.length&&this.parent.isDigit(o[S]);)S+=1;if(S<o.length&&":"===o[S]){if((S+=1)<o.length&&o[S]===this.sheetToken){for(S++;S<o.length&&o[S]!==this.sheetToken;)S+=1;S<o.length&&o[S]===this.sheetToken&&S++}for(;S<o.length&&this.parent.isUpperChar(o[S]);)S+=1;for(;S<o.length&&this.parent.isDigit(o[S]);)S+=1;S-=1,c=this.parent.substring(o,s+1,S-s),c=this.parent.getCellFrom(c)}else S-=1,c=this.parent.substring(o,s+1,S-s),(A="u"===o[S])&&(c="u"+c);V&&c.startsWith(this.sheetToken)&&(V=!this.parent.isCellReference(c)),V||this.parent.updateDependentCell(c),(this.parent.namedRanges.size>0&&this.parent.namedRanges.has(c.toUpperCase())||this.parent.storedData.has(c.toUpperCase()))&&(c="n"+this.checkForNamedRangeAndKeyValue(c));var I=["*","+","-","/","w"].indexOf(o[S-c.length])>-1;c="TRUE"===c&&(N||I)?"n1":"FALSE"===c&&(N||I)?"n0":c,v=S+1}var R=a.indexOf(o[s]),T=this.parent.arithMarker+m+c+n[R]+this.parent.arithMarker;d>0&&(T=o.substring(0,d)+T),v<o.length&&(T+=o.substring(v)),o=T=T.split(this.parent.arithMarker2).join(this.parent.arithMarker.toString()),s=this.indexOfAny(o,i)}}else if(o.length>0&&(this.parent.isUpperChar(o[0])||o[0]===this.sheetToken)){for(var M=!0,D=!0,U=!1,w=o.length,C=0;C<w;++C)if(o[C]===this.sheetToken){if(C>0&&!U)throw this.parent.getErrorStrings()[r.CommonErrors.Ref];for(U=!0,C++;C<w&&this.parent.isDigit(o[C]);)C++;if(C===w||o[C]!==this.sheetToken){M=!1;break}}else{if(!D&&this.parent.isChar(o[C])){M=!1;break}if(!this.parent.isChar(o[C])&&!this.parent.isDigit(o[C])&&o[C]!==this.sheetToken){M=!1;break}D=this.parent.isUpperChar(o[C])}M&&this.parent.updateDependentCell(o)}return o}catch(t){if(t===this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference])throw t;throw t}},e.prototype.indexOfAny=function(r,t){for(var e=0;e<r.length;e++)if(t.indexOf(r[e])>-1)return e;return-1},e.prototype.findLeftMarker=function(r){var t=-1;if(r.indexOf(this.parent.arithMarker)>-1)for(var e=0,n=r.length-1;n>=0;--n)if(r[n]===this.parent.rightBracket)e--;else if(r[n]===this.parent.leftBracket)e++;else if(r[n]===this.parent.arithMarker&&0===e){t=n;break}return t},e.prototype.findRightMarker=function(r){var t=-1;if(r.indexOf(this.parent.arithMarker)>-1)for(var e=0,n=0;n<r.length;++n)if(r[n]===this.parent.rightBracket)e--;else if(r[n]===this.parent.leftBracket)e++;else if(r[n]===this.parent.arithMarker&&0===e){t=n;break}return t},e.prototype.parseFormula=function(e,n){if(e.length>0&&e[0]===this.parent.getFormulaCharacter()&&(e=e.substring(1)),e.indexOf("#REF!")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Ref];e.length>0&&"+"===e[0]&&(e=e.substring(1));try{this.isFailureTriggered=!1,this.isError=!1,e=this.parse(e.trim(),n),this.isFormulaParsed=!0}catch(r){var i=this.exceptionArgs(r);this.isFailureTriggered||(this.parent.trigger("onFailure",i),this.isFailureTriggered=!0);var o="string"==typeof i.exception?i.exception:i.message;e=(t.isNullOrUndefined(this.parent.getErrorLine(r))?"":"#"+this.parent.getErrorLine(r)+": ")+o,this.isError=!0}return e},e.prototype.markLibraryFormulas=function(e){var n=0,i=e.indexOf(")");if(-1===i)e=this.markNamedRanges(e);else for(var o=this;i>-1;){var s=function(){for(var s=0,a=i-1;a>-1&&("("!==e[a]||0!==s);)")"===e[a]&&s++,a--;if(-1===a)throw new oe(o.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedParentheses]);for(var u=a-1;u>-1&&(o.parent.isChar(e[u])||o.parent.isDigit(e[u])||"."===e[u]);)u--;var l=a-u-1,h=o.parent.substring(e,u+1,l);if(l>0&&!t.isNullOrUndefined(o.parent.getFunction(h))&&(!h.includes(".")||o.isValidDotFormulaName(h))){var p=o.parent.substring(e,a,i-a+1),g=o.parent.getParseArgumentSeparator();if("AREAS"===h)o.ignoreBracet=!0;else if(o.ignoreBracet=!1,(h.includes("IFS")&&"COUNTIFS"!==h||"MATCH"===h)&&p.includes("{")){var f=p.indexOf("{"),m=o.parent.substring(p,f,p.indexOf("}")-f+1);p=p.split(m).join(m.split(g).join(o.parent.tic+o.parent.tic))}try{var c=void 0;p=p.split("(").join("").split(")").join(""),p="("+o.formulaAutoCorrection(p,c,!0)+")"}catch(t){if(!(c={message:t.message,exception:t,isForceCalculable:t.formulaCorrection,computeForceCalculate:!1}).isForceCalculable)throw o.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];if(o.isFailureTriggered||(o.parent.trigger("onFailure",c),o.isFailureTriggered=!0,n+=1),c.computeForceCalculate=n>0||c.computeForceCalculate,!c.isForceCalculable)throw o.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];if(!c.computeForceCalculate)throw o.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];p=p.split("(").join("").split(")").join(""),p="("+o.formulaAutoCorrection(p,c)+")"}p=o.markNamedRanges(p),p=o.swapInnerParens(p),-1===(p=o.addParensToArgs(p)).lastIndexOf(g)&&p.length>2&&"("===p[0]&&")"===p[p.length-1]&&"{"!==p[1]&&"("!==p[1]&&(p=(p=p.substring(0,p.length-1)+"}"+p.substring(p.length-1))[0]+"{"+p.substring(1)),e=e.substring(0,u+1)+"q"+o.parent.substring(e,u+1,l)+p.split("(").join(o.parent.leftBracket).split(")").join(o.parent.rightBracket)+e.substring(i+1)}else{var d=function(r){if(r.includes("IFERROR(")){var t=r.lastIndexOf("(");return"IFERROR"===r.substring(t-7,t)||d(r.substring(0,t))}return!1};if(l>0&&!d(e.substring(0,u+1)))return{value:o.parent.getErrorStrings()[r.CommonErrors.Name]};var v=o.emptyStr;a>0&&(v=e.substring(0,a)),v=v+"{"+o.parent.substring(e,a+1,i-a-1)+"}",i<e.length&&(v+=e.substring(i+1)),v=o.markNamedRanges(v),e=v}i=e.indexOf(")")}();if("object"==typeof s)return s.value}return e=e.split("{").join("(").split("}").join(")")},e.prototype.swapInnerParens=function(r){return r.length>2&&(r=r[0]+r.substr(1,r.length-2).split("(").join("{").split(")").join("}")+r[r.length-1]),r},e.prototype.addParensToArgs=function(r){if(0===r.length)return this.emptyStr;var t=[];t.push(this.parent.getParseArgumentSeparator()),t.push(this.parent.rightBracket);var e=r.lastIndexOf(this.parent.getParseArgumentSeparator()),n=0;if(-1===e){if(r.length>2&&"("===r[0]&&")"===r[r.length-1])if("{"!==r[1]&&"("!==r[1])r=(r=r.substring(0,r.length-1)+"}"+r.substring(r.length-1))[0]+"{"+r.substring(1);else{var i=["+","-","*","/"];e=this.lastIndexOfAny(r,i),0===n&&")"===r[r.length-1]&&(n=r.length-1),n>0&&"{"!==r[e+1]&&"}"===r[e-1]&&(r=(r=r.substr(0,n)+"}"+r.substr(n)).substr(0,e+1)+"{"+r.substr(e+1))}}else for(var o=!0;e>-1;){var s=this.indexOfAny(r.substring(e+1,r.length),t);s>=0?s=e+s+1:-1===s&&")"===r[r.length-1]&&(s=r.length-1),s>0&&"{"!==r[e+1]&&"}"!==r[s-1]&&"¢"!==r[s-1]&&(r=(r=r.substr(0,s).trim()+"}"+r.substr(s)).substr(0,e+1)+"{"+r.substr(e+1).trim()),e=r.substr(0,e).lastIndexOf(this.parent.getParseArgumentSeparator()),o&&-1===e&&"("===r[0]&&(e=0,o=!1)}return r=r.split("{}").join(this.emptyStr)},e.prototype.lastIndexOfAny=function(r,t){for(var e=r.length-1;e>-1;e--)if(t.indexOf(r[e])>-1)return e;return-1},e.prototype.markNamedRanges=function(r){var e=[")",this.parent.getParseArgumentSeparator(),"}","+","-","*","/","<",">","=","&",":"],n=r.length>0&&("("===r[0]||"{"===r[0])?1:0;r.indexOf("#N/A")>-1&&(r=r.split("#N/A").join("#N~A")),r.indexOf("#DIV/0!")>-1&&(r=r.split("#DIV/0!").join("#DIV~0!"));for(var i=this.indexOfAny(r.substring(n),e);i>-1&&i+n<r.length;){var o=this.emptyStr,s=null;if(this.parent.substring(r,n,i).indexOf("[")>-1?s=this.getTableRange(this.parent.substring(r,n,i)):this.parent.storedData.has(this.parent.substring(r,n,i))?s=this.checkForNamedRangeAndKeyValue(this.parent.substring(r,n,i)):this.parent.namedRanges.has(this.parent.substring(r,n,i))&&(s=this.checkForNamedRangeAndKeyValue(this.parent.substring(r,n,i))),t.isNullOrUndefined(s)&&("NaN"!==(o=this.checkScopedRange(this.parent.substring(r,n,i)))?(this.findNamedRange=!0,s=o):this.parent.substring(r,n,i).startsWith(this.sheetToken.toString()),!t.isNullOrUndefined(s)&&this.findNamedRange&&s.indexOf(this.fixedReference)>-1&&(s=s.split(this.fixedReference).join(this.emptyStr))),t.isNullOrUndefined(s)||(s=s.toUpperCase(),s=this.parent.setTokensForSheets(s),s=this.markLibraryFormulas(s)),t.isNullOrUndefined(s)||s===this.emptyStr)for(n+=i+1;n<r.length&&!this.parent.isUpperChar(r[n])&&r[n]!==this.sheetToken;)n++;else r=r.substring(0,n)+s+r.substring(n+i),n+=s.length+1;for(i=n,n<r.length-1&&"{"===r[n]&&(n+=1),i=this.indexOfAny(r.substring(n),e);0===i&&n<r.length-1;)n++,i=this.indexOfAny(r.substring(n),e);if((-1===i||r.substring(n).indexOf("[")>-1)&&n<r.length){if(s=r.substring(n).indexOf("[")>-1?this.getTableRange(r.substring(n)):this.parent.storedData.has(r.substring(n))?this.parent.storedData.size>0?this.checkForNamedRangeAndKeyValue(r.substring(n)):s:this.parent.namedRanges.size>0?this.checkForNamedRangeAndKeyValue(r.substring(n)):s,t.isNullOrUndefined(s)&&"NaN"!==(o=this.checkScopedRange(r.substring(n)))&&(s=o),!t.isNullOrUndefined(s)&&s!==this.emptyStr&&(s=s.toUpperCase(),s=this.parent.setTokensForSheets(s),null!=(s=this.markLibraryFormulas(s)))){var a=r.substring(n);r=")"===a[a.length-1]?r.substring(0,n)+s+")":r.substring(0,n)+s,n+=s.toString().length+1}i=n<r.length?this.indexOfAny(r.substring(n),e):-1}}return r.indexOf("#N~A")>-1&&(r=r.split("#N~A").join("#N/A")),r.indexOf("#DIV~0!")>-1&&(r=r.split("#DIV~0!").join("#DIV/0!")),r},e.prototype.checkForNamedRangeAndKeyValue=function(r){var e=this.emptyStr;if(r.indexOf("[")>-1){var n=this.getTableRange(r);t.isNullOrUndefined(n)||(this.findNamedRange=!0,r=n)}if("NaN"!==(e=this.checkScopedRange(r)))this.findNamedRange=!0,r=e;else{if(r.indexOf(this.sheetToken)>-1){var i=this.parent.getSheetFamilyItem(this.parent.grid),o=r.split('"').join(this.emptyStr);if(o=o.substr(0,o.indexOf(this.sheetToken)),i.sheetNameToToken.has(o.toUpperCase()))parseInt(i.sheetNameToToken.get(o.toUpperCase()).split(this.sheetToken).join(this.emptyStr))}this.parent.storedData.size>0&&this.parent.storedData.has(r)&&(r="A"+this.parent.colIndex(r)),this.parent.namedRanges.size>0&&this.parent.namedRanges.has(r.toUpperCase())&&(t.isNullOrUndefined(this.parent.parentObject)?(r=this.parse(this.parent.namedRanges.get(r.toUpperCase())),(r=this.parent.setTokensForSheets(r)).indexOf(this.fixedReference)>-1&&r.split(this.fixedReference).join(this.emptyStr),this.findNamedRange=!0):r=this.parse(this.parent.namedRanges.get(r.toUpperCase()))),this.findNamedRange&&"!"!==r[0]&&"q"!==r[0]&&"bq"!==r[0]&&(r=this.parent.setTokensForSheets(r)).indexOf(this.fixedReference)>-1&&(r=r.split(this.fixedReference).join(this.emptyStr))}return r},e.prototype.getTableRange=function(r){var t=(r=r.replace(" ",this.emptyStr).toUpperCase()).replace("]",this.emptyStr).replace("#DATA",this.emptyStr);t.indexOf(this.parent.getParseArgumentSeparator())>-1&&(t.substring(0,t.indexOf(this.parent.getParseArgumentSeparator())).replace("[",this.emptyStr),t=t.replace("[",this.emptyStr).replace(this.parent.getParseArgumentSeparator(),"_"));this.emptyStr;return t.toUpperCase()},e.prototype.findNextEndIndex=function(r,t){for(var e=0,n=t,i=!1;!i&&t<r.length;)"["===r[n]?e++:"]"===r[n]&&0===--e&&(i=!0),t++;return t-=n},e.prototype.processIndexArg=function(r){var t=r.indexOf("INDEX((");if(-1!==t){var e=t+("INDEX((".length-1);if(-1!==e){for(var n=0,i=-1,o=e;o<r.length;o++)if("("===r[o]?n++:")"===r[o]&&n--,0===n){i=o;break}i>e&&(r=r.slice(0,e)+this.parent.tic+r.slice(e+1,i)+this.parent.tic+r.slice(i+1))}}return r},e.prototype.isValidDotFormulaName=function(r){return r=r.toUpperCase(),["STDEV.P","STDEV.S","VAR.S","VAR.P","T.TEST","F.TEST","Z.TEST","CHISQ.TEST","COVARIANCE.S","COVARIANCE.P","CHISQ.DIST","F.DIST","T.DIST","NETWORKDAYS.INTL","WORKDAY.INTL","ERROR.TYPE","ECMA.CEILING","ISO.CEILING"].some(function(t){return r===t})},e.prototype.isOtherLangChar=function(r){var t=r.charCodeAt(0);return t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=255},e.prototype.destroy=function(){this.stringsColl.clear(),this.storedStringText=this.emptyStr,this.isError=!1,this.isFormulaParsed=!1,this.parent=null},e}(),ee=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ne=function(r,t,e,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,t,e,n);else for(var a=r.length-1;a>=0;a--)(i=r[a])&&(s=(o<3?i(s):o>3?i(t,e,s):i(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s},ie=function(e){function n(r){var n=e.call(this,null,null)||this;n.lFormulas=new Map,n.storedData=new Map,n.keyToRowsMap=new Map,n.rowsToKeyMap=new Map,n.rightBracket=String.fromCharCode(161),n.leftBracket=String.fromCharCode(162),n.sheetToken="!",n.cell="",n.cellPrefix="!0!A",n.treatEmptyStringAsZero=!1,n.tic='"',n.singleTic="'",n.trueValue="TRUE",n.falseValue="FALSE",n.parseDecimalSeparator=".",n.arithMarker=String.fromCharCode(180),n.arithMarker2=n.arithMarker+n.arithMarker,n.dependentCells=null,n.dependentFormulaCells=null,n.minValue=Number.MIN_SAFE_INTEGER,n.maxValue=Number.MAX_SAFE_INTEGER,n.categoryCollection=["All"],n.dependencyLevel=0,n.randomValues=new Map,n.isRandomVal=!1,n.randCollection=[],n.dependencyCollection=[],n.uniqueRange=[],n.sortRange=[],n.formulaErrorStrings=[],n.errorStrings=null,n.parseArgumentSeparator=",",n.dateTime1900=new Date(1900,0,1,0,0,0),n.isParseDecimalSeparatorChanged=!1,n.isArgumentSeparatorChanged=!1,n.sheetFamilyID=0,n.defaultFamilyItem=null,n.sheetFamiliesList=null,n.modelToSheetID=null,n.tokenCount=0,n.sortedSheetNames=null,n.tempSheetPlaceHolder=String.fromCharCode(133),n.namedRanges=new Map,n.formulaInfoTable=null,n.millisecondsOfaDay=864e5,n.parseDateTimeSeparator="/",n.evaluatingKeys=new Set;var i=r,o=i&&i.locale?i.locale:"en-US";return n.l10n=new t.L10n("calculate",z,o),n.refreshLocalizedStrings(),new re(n),n.parentObject=t.isNullOrUndefined(r)?n:r,n.grid=n.parentObject,n.parser=new te(n),n}return ee(n,e),Object.defineProperty(n.prototype,"libraryFormulas",{get:function(){return this.lFormulas},set:function(r){this.lFormulas.set(r.fName,{handler:r.handler,category:r.category,description:r.description})},enumerable:!0,configurable:!0}),n.prototype.setLocale=function(r){var t=this.parentObject,e=r||t&&t.locale||"en-US";this.l10n.setLocale(e),this.refreshLocalizedStrings()},n.prototype.refreshLocalizedStrings=function(){var r=this,t=function(t){return r.l10n.getConstant(t)};this.formulaErrorStrings=[t("OperatorsCannotStartWithExpression"),t("CannotParse"),t("BadLibrary"),t("InvalidCharInFrontOf"),t("NumberContains2DecimalPoints"),t("ExpressionCannotEndWithAnOperator"),t("InvalidCharactersFollowingWithOperator"),t("InvalidCharInNumber"),t("MismatchedParentheses"),t("UnknownFormulaName"),t("RequiresASingleArgument"),t("Requires3Args"),t("InvalidMathArgument"),t("Requires2Args"),"#NAME?",t("TooComplex"),"#CIRCULARREF!",t("MissingFormula"),t("ImproperFormula"),t("InvalidExpression"),t("CellEmpty"),t("BadFormula"),t("EmptyExpression"),"",t("MismatchedTics"),t("WrongNumberArguments"),t("InvalidArguments"),t("IterationsDoNotConverge"),t("AlreadyRegistered"),t("CalculationOverflow"),t("MissingSheet"),t("CannotParseUnderscore"),t("ExpressionCannotEndWithAnOperatorUnderscore"),"#SPILL!","#DIV/0!"],this.categoryCollection=[t("CategoryAll")]},n.prototype.getHostSheetInfo=function(){var r=this.parentObject;return r&&"function"==typeof r.getSheetInfo?r.getSheetInfo()||[]:[]},n.prototype.hostParseDate=function(r){var t=this.parentObject;return t&&"function"==typeof t.parseDate?t.parseDate(r)||{}:{}},n.prototype.getParseArgumentSeparator=function(){return this.isArgumentSeparatorChanged||","===this.parseArgumentSeparator||(this.parseArgumentSeparator=","),this.parseArgumentSeparator},n.prototype.setParseArgumentSeparator=function(r){this.parseArgumentSeparator=r,this.isArgumentSeparatorChanged=!0},n.prototype.getParseDateTimeSeparator=function(){return this.parseDateTimeSeparator},n.prototype.setTreatEmptyStringAsZero=function(r){this.treatEmptyStringAsZero=r},n.prototype.getTreatEmptyStringAsZero=function(){return this.treatEmptyStringAsZero},n.prototype.setParseDateTimeSeparator=function(r){this.parseDateTimeSeparator=r},n.prototype.onPropertyChanged=function(r,t){},n.prototype.getModuleName=function(){return"calculate"},n.prototype.getFormulaCharacter=function(){return"="},n.prototype.isUpperChar=function(r){var t=r.charCodeAt(0);return t>64&&t<91},n.prototype.resetKeys=function(){this.storedData.clear(),this.keyToRowsMap.clear(),this.rowsToKeyMap.clear()},n.prototype.updateDependentCell=function(t){var e=this,n=this.cell;if(""!==n){var i=this.getSheetFamilyItem(this.grid);if(i.sheetNameToParentObject&&(n.includes(this.sheetToken)||(n=i.parentObjectToToken.get(this.grid)+n),t.includes(this.sheetToken)||(t=i.parentObjectToToken.get(this.grid)+t)),n!==t){var o=this.getDependentCells();o.has(t)||o.set(t,[]);var s=o.get(t);if(-1===s.indexOf(n)){var a=this.getDependentFormulaCells(),u={},l=function(t){if(a.has(t)){var i=a.get(t);if(i.has(n))throw e.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference];u[t]||(u[t]=!0,i.forEach(function(r){l(r)}))}};l(t),s.push(n),a.has(n)?a.get(n).has(t)||a.get(n).set(t,t):(a.set(n,new Map),a.get(n).set(t,t))}}}},n.prototype.getDependentCells=function(){return null==this.dependentCells&&(this.dependentCells=new Map),this.dependentCells},n.prototype.getDependentFormulaCells=function(){if(this.isSheetMember()){var r=this.getSheetFamilyItem(this.grid);return null==r.sheetDependentFormulaCells&&(r.sheetDependentFormulaCells=new Map),r.sheetDependentFormulaCells}return null==this.dependentFormulaCells&&(this.dependentFormulaCells=new Map),this.dependentFormulaCells},n.prototype.getLibraryFormulas=function(){return this.lFormulas},n.prototype.getFunction=function(r){return this.getLibraryFormulas().has(r.toUpperCase())?this.getLibraryFormulas().get(r.toUpperCase()).handler:null},n.prototype.intToDate=function(r){var t=Number(r);(t=t>0&&t<1?1+t:0===t?1:t)>60&&(t-=1);var e=new Date("01/01/1900"),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());return new Date(new Date(864e5*(t-1)+n).toUTCString().replace(" GMT",""))},n.prototype.getFormulaInfoTable=function(){if(this.isSheetMember()){var r=this.getSheetFamilyItem(this.grid);return null===r.sheetFormulaInfotable&&(r.sheetFormulaInfotable=new Map),r.sheetFormulaInfotable}return null===this.formulaInfoTable&&(this.formulaInfoTable=new Map),this.formulaInfoTable},n.prototype.getParseDecimalSeparator=function(){return this.isParseDecimalSeparatorChanged||"."===this.parseDecimalSeparator||(this.parseDecimalSeparator="."),this.parseDecimalSeparator},n.prototype.setParseDecimalSeparator=function(r){this.parseDecimalSeparator=r,this.isParseDecimalSeparatorChanged=!0},n.prototype.getSheetToken=function(t){var e=0,n="";if(e<t.length&&t[e]===this.sheetToken){for(e++;e<t.length&&t[e]!==this.sheetToken;)e++;n=t.substring(0,e+1)}if(e<t.length)return n;throw this.formulaErrorStrings[r.FormulasErrorsStrings.BadIndex]},n.prototype.getSheetID=function(r){var t=this.getSheetFamilyItem(r);if(null!=t.sheetNameToParentObject&&t.sheetNameToParentObject.size>0){var e=t.parentObjectToToken.get(r);if(e){e=e.split(this.sheetToken).join("");var n=this.parseFloat(e);if(!this.isNaN(n))return n}}return-1},n.prototype.parseFloat=function(r){var t=Number(r);return isNaN(t)&&"string"==typeof r&&r.includes(",")&&(t=Number(r.split(",").join(""))),t},n.prototype.rowIndex=function(t){var e=0,n=!1;if(e<t.length&&t[e]===this.sheetToken){for(e++;e<t.length&&t[e]!==this.sheetToken;)e++;e++}for(;e<t.length&&this.isChar(t[e]);)n=!0,e++;var i=parseInt(t.substring(e),10);if(e<t.length&&!this.isNaN(i))return i;if(n)return-1;throw this.formulaErrorStrings[r.FormulasErrorsStrings.BadIndex]},n.prototype.colIndex=function(r){var t=0,e=0;if(r=r.toUpperCase(),t<r.length&&r[t]===this.sheetToken){for(t++;t<r.length&&r[t]!==this.sheetToken;)t++;t++}for(;t<r.length&&this.isChar(r[t]);)e=26*e+r[t].charCodeAt(0)-64,t++;return 0===e?-1:e},n.prototype.getErrorStrings=function(){return null===this.errorStrings&&(this.errorStrings=["#N/A","#VALUE!","#REF!","#DIV/0!","#NUM!","#NAME?","#NULL!","#CALC!"]),this.errorStrings},n.prototype.substring=function(r,t,e){return r.substring(t,e+t)},n.prototype.isChar=function(r){return r.charCodeAt(0)>=65&&r.charCodeAt(0)<=90||r.charCodeAt(0)>=97&&r.charCodeAt(0)<=122},n.prototype.getSheetFamilyItem=function(r,t){return 0===this.sheetFamilyID?(null==this.defaultFamilyItem&&(this.defaultFamilyItem=new ae),this.defaultFamilyItem):(null==this.sheetFamiliesList&&(this.sheetFamiliesList=new Map),void 0===t&&(t=this.modelToSheetID.get(r)),this.sheetFamiliesList.has(t)||this.sheetFamiliesList.set(t,new ae),this.sheetFamiliesList.get(t))},n.prototype.setKeyValue=function(r,t){r=r.toUpperCase();var e=t.toString().trim();this.storedData.get(r)&&0!==e.indexOf("{")||(this.storedData.set(r,new se),this.keyToRowsMap.set(r,this.keyToRowsMap.size+1),this.rowsToKeyMap.set(this.rowsToKeyMap.size+1,r));var n=this.storedData.get(r);if(null!=n.getFormulaText()&&n.getFormulaText().length>0&&n.getFormulaText()!==e){var i=this.cellPrefix+this.keyToRowsMap.get(r).toString();null!=this.getDependentFormulaCells().get(i)&&this.clearFormulaDependentCells(i)}e.length>0&&e[0]===this.getFormulaCharacter()?n.setFormulaText(e):n.getFormulaValue()!==e&&(n.setFormulaText(""),n.setParsedFormula(""),n.setFormulaValue(e))},n.prototype.clearFormulaDependentCells=function(r){var t=this,e=this.getDependentFormulaCells().get(r);e&&(e.forEach(function(e,n){var i=n,o=t.getDependentCells().get(i);t.arrayRemove(o,r),0===o.length&&t.getDependentCells().delete(i)}),this.getDependentFormulaCells().delete(r))},n.prototype.clearKeys=function(){this.resetKeys()},n.prototype.arrayRemove=function(r,t){var e=r.indexOf(t);return-1!==e&&r.splice(e,1),r},n.prototype.getKeyValue=function(e){if(e=e.toUpperCase(),!this.storedData.has(e))return"";var n=this.storedData.get(e),i=n.getFormulaText();if(i.length>0&&i[0]===this.getFormulaCharacter()){if(this.evaluatingKeys.has(e))return this.getErrorStrings()[r.CommonErrors.Ref];this.evaluatingKeys.add(e),this.cell=this.cellPrefix+this.keyToRowsMap.get(e).toString(),i=i.substring(1);try{try{n.setParsedFormula(this.parser.parseFormula(i,e))}catch(r){o={message:r.message,exception:r,isForceCalculable:!1,computeForceCalculate:!1};return this.trigger("onFailure",o),n.setFormulaValue(o.message),this.storedData.get(e).getFormulaValue()}try{n.setFormulaValue(this.computeFormula(n.getParsedFormula()))}catch(r){var o={message:r.message,exception:r,isForceCalculable:!1,computeForceCalculate:!1};this.trigger("onFailure",o);var s="string"==typeof o.exception?o.exception:o.message;return(t.isNullOrUndefined(this.getErrorLine(r))?"":"#"+this.getErrorLine(r)+": ")+s}}finally{this.evaluatingKeys.delete(e)}}return this.storedData.get(e).getFormulaValue()},n.prototype.getNamedRanges=function(){return this.namedRanges},n.prototype.addNamedRange=function(r,t){var e=r.split(this.sheetToken);if(e.length>1){var n=this.getSheetId(this.grid).toString();if(!this.getSheetFamilyItem(n).parentObjectToToken.get(n))return!1;r=e[0]+this.sheetToken+e[1].toUpperCase()}else r=r.toUpperCase();return this.namedRanges.set(r,t),!0},n.prototype.updateNamedRange=function(r,t){var e=new Map;this.namedRanges.forEach(function(n,i){var o=i;if(i.includes(r)){var s=i.split("!");s[0]=t,o=s.join("!")}e.set(o,n)}),this.namedRanges=e},n.prototype.removeNamedRange=function(r){return r=r.toUpperCase(),null!=this.namedRanges.get(r)&&(this.namedRanges.delete(r),!0)},n.prototype.convertAlpha=function(r){for(var t=[],e=0;r>0;){r--;var n="A".charCodeAt(0);t[e]=String.fromCharCode(r%26+n),r=parseInt((r/26).toString(),10),e++}for(var i=[],o=0;o<e;o++)i[e-o-1]=t[o];return i.join("")},n.prototype.getCellCollection=function(t){if(t.indexOf(":")<0){if(!this.isCellReference(t))return t.split(this.getParseArgumentSeparator());t=t+":"+t}var e="",n=t.indexOf(this.sheetToken);if(n>-1)for(var i=n+1;i<t.length;){if(t[i]===this.sheetToken){e=t.substr(0,i+1);break}i++}var o,s,a,u,l=t.indexOf(":");if(l>0&&this.isChar(t[l-1]))for(var h=l-2;h>=0&&this.isDigit(t[h]);)h--;if(o=this.rowIndex(this.substring(t,0,l)),s=this.rowIndex(this.substring(t,l+1,l+t.length-l-1)),a=this.colIndex(this.substring(t,0,l)),u=this.colIndex(this.substring(t,l+1,l+t.length-l-1)),o>=1048576||s>=1048576||a>=16384||u>=16384)return[this.getErrorStrings()[r.CommonErrors.Ref]];o>s&&(l=s,s=o,o=l),a>u&&(l=u,u=a,a=l);var p,g=[],f=0;for(l=o;l<=s;l++)for(p=a;p<=u;p++)g[f]=e+""+this.convertAlpha(p)+l.toString(),f++;return g},n.prototype.computeFormula=function(r,t){return this.calculateFormula(r,!1,t)},n.prototype.calculateFormula=function(e,n,i){var o,s,a,u,l=this,h=!1;if(this.parser.isError)return e;o=this.parser.isFormulaParsed?e:this.parser.parseFormula(e),this.parser.isFormulaParsed=!1;try{if((s=this.findLastIndexOfq(o))>0&&(h=!0),""!==o&&s>-1)for(var p=s+1,g=this;p>-1&&"break"!==function(){if(o[p]!==g.rightBracket)return p++,"continue";var e=o.substring(s,p+1),f=e.split(g.leftBracket)[0].split("q").join(""),m=void 0;if(g.getLibraryFormulas().get(f.toUpperCase()).isCustom){m=e.substring(e.indexOf(g.leftBracket)+1,e.indexOf(g.rightBracket)).split(g.getParseArgumentSeparator());var c=0,d=[],v=void 0;for(c=0;c<m.length;c++)m[c].includes(":")&&g.isCellReference(m[c])&&(v=g.getCellCollection(m[c])).length>1?(d.push(m[c]),v.forEach(function(r){l.updateDependentCell(r)})):d.push(g.getValueFromArg(m[c]));m=d}else{var N=e.substring(e.indexOf(g.leftBracket)+1,e.indexOf(g.rightBracket));m=[];for(var E=g.getParseArgumentSeparator(),S="",y=void 0,C=0,b=N.length-1;C<=b;C++)'"'===N[C]&&(y=!y),N[C]!==E||y?(S+=N[C],C===b&&m.push(S)):(m.push(S),S="",C===b&&m.push(S));if(m.length||(m=[""]),h&&f&&(["IF","INDEX","SORT","T","EXACT","PROPER","DOLLAR","DATE","TEXT","ISNUMBER"].some(function(r){return r===f})&&m.push("nestedFormulaTrue"),"IF"===f&&m.push("nestedFormulaTrue"),"VLOOKUP"===f||"HLOOKUP"===f)){var A=o.lastIndexOf("q",s-1);if(-1!==A){var O=o.substring(A+1,o.lastIndexOf(g.leftBracket,s-1));["IF","IFS","AND","OR","NOT"].some(function(r){return r===O})&&m.push("conditionalFormulaTrue")}}i&&"UNIQUE"===f&&m.push("isComputeExp")}if(a=t.isNullOrUndefined(g.getFunction(f))?g.getErrorStrings()[r.CommonErrors.Name]:g.getFunction(f).apply(void 0,m),h){u=g.processNestedFormula(o,e,a);var F=g.findLastIndexOfq(u);return 0===F&&(h=!1),-1===F&&(a=g.computeValue(u,n)),s=p=F,o=u,"continue"}return"break"}(););else this.formulaErrorStrings.indexOf(o)>-1?a=o:""!==o&&-1===s&&(a=this.computeValue(o,n))}catch(r){var f={message:r.message,exception:r,isForceCalculable:!1,computeForceCalculate:!1};this.trigger("onFailure",f);var m="string"==typeof f.exception?f.exception:f.message;a=(t.isNullOrUndefined(this.getErrorLine(r))?"":"#"+this.getErrorLine(r)+": ")+m}return a},n.prototype.computeSumIfAndAvgIf=function(e,n){if(t.isNullOrUndefined(e)||""===e[0]||0===e.length)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var i=e,o=0;o<i.length;o++)if(this.isCellReference(i[o])&&t.isNullOrUndefined(i[o].match(/[0-9]/))&&i[o].indexOf("!")<0){var s=i[o].split(":");i[o]=s[0]+"1:"+s[1]+this.spreadSheetUsedRange[0]}var a=i.length;if(2!==a&&3!==a&&0===a)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i[1])return n?this.getErrorStrings()[r.CommonErrors.DivZero]:"0";var u=i[0],l=i[1].startsWith(this.tic)&&i[1].endsWith(this.tic),h=this.getANDComputedValue(i[1]);if(h.length>255)return this.getErrorStrings()[r.CommonErrors.Value];var p=h.includes("*"),g=h.includes("?"),f=p?h.replace(/\*/g,"").trim():h,m=!1;if(!l&&this.isCellReference(f)&&(f=this.getValueFromArg(f),m=!0),p){var c=h.indexOf("*");"*"===h[0]&&(f="*"+f),"*"===h[h.length-1]&&(f+="*"),c>0&&c<h.length-1&&(f=h.substring(0,c)+"*"+h.substring(c+1))}h=f;var d=this.parser.tokenEqual;h.startsWith("<=")?(d=this.parser.tokenLessEq,h=h.substring(2)):h.startsWith(">=")?(d=this.parser.tokenGreaterEq,h=h.substring(2)):h.startsWith("<>")?(d=this.parser.tokenNotEqual,h=h.substring(2)):h.startsWith("<")?(d=this.parser.tokenLess,h=h.substring(1)):h.startsWith(">")?(d=this.parser.tokenGreater,h=h.substring(1)):h.startsWith("=")&&(d=this.parser.tokenEqual,h=h.substring(1)),(!l&&this.isCellReference(h)&&!m||h.includes(this.arithMarker)||h.includes(this.getParseDecimalSeparator())&&!p&&!g)&&(h=this.getValueFromArg(h));var v=this.parseFloat(h),N=i[0],E=this.getCellCollection(a>2?i[2]:u),S=this.getCellCollection(N);if("#REF!"===E[0]||"#REF!"===S[0])return this.getErrorStrings()[r.CommonErrors.Name];if(S.length>E.length){var y=this.colIndex(E[E.length-1])+this.colIndex(S[S.length-1])-this.colIndex(S[0]),C=i[2].split(":");if(C[1]=(this.convertAlpha(y)+this.rowIndex(S[S.length-1])).toString(),"#REF!"===(E=this.getCellCollection(C.join(":")))[0])return this.getErrorStrings()[r.CommonErrors.Name]}var b=this.getComputeSumIfValue(S,E,h.toLowerCase(),v,d,p,g);return[b[0],b[1]]},n.prototype.computeLookup=function(e){var n,i,o,s,a,u,l=[],h=[],p=[],g=[],f=[],m=e,c=m.length;if(1===c||c>3)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===m[1]||""===m[2])return this.getErrorStrings()[r.CommonErrors.Value];if(a=this.getValueFromArg(m[0]),m[0].indexOf(this.tic)>-1&&m[0].toUpperCase().split(this.tic).join("")!==this.trueValue&&m[0].toUpperCase().split(this.tic).join("")!==this.falseValue&&this.isNaN(this.parseFloat(m[0].split(this.tic).join("")))&&(a=a.split(this.tic).join("")),this.getErrorStrings().indexOf(a)>-1)return a;var d=m[1].split(":");if(2===d.length&&this.isCellReference(d[0])&&this.isCellReference(d[1])&&2===c){var v=m[1].indexOf(":"),N=this.rowIndex(this.substring(m[1],0,v)),E=this.colIndex(this.substring(m[1],0,v)),S=this.rowIndex(this.substring(m[1],v+1,v+m[1].length-v-1)),y=this.colIndex(this.substring(m[1],v+1,v+m[1].length-v-1));N>S&&(N=(n=[S,N])[0],S=n[1]),E>y&&(E=(i=[y,E])[0],y=i[1]);var C="";0===m[1].indexOf("!")&&(C=(C=(C=m[1]).replace("!","")).indexOf("!"),C=m[1].substring(0,C+2));var b=y-E+1,A=S-N+1;A>b||A===b?(o=C+K(E)+N+":"+K(E)+S,s=C+K(y)+N+":"+K(y)+S):A<b&&(o=C+K(E)+N+":"+K(y)+N,s=C+K(E)+S+":"+K(y)+S),N===S&&E===y||(u=!0)}if(u){if(l=this.getCellCollection(o),h=this.getCellCollection(s),"#REF!"===l[0]||"#REF!"===h[0])return this.getErrorStrings()[r.CommonErrors.Name]}else{l=this.getCellCollection(m[1]);var O=2===c?m[1]:m[2];if(h=this.getCellCollection(O),"#REF!"===l[0]||"#REF!"===h[0])return this.getErrorStrings()[r.CommonErrors.Name];var F=Y(m[1]),x=Y(O),V=F[1]===F[3]||F[0]===F[2],I=x[1]===x[3]||x[0]===x[2];if(!V||!I)return this.getErrorStrings()[r.CommonErrors.NA]}for(var R=0;R<l.length;R++)g.push(this.getValueFromArg(l[R]).split(this.tic).join(""));var T=g.map(function(r){return""===r?NaN:Number(r)}).sort(function(r,t){return r-t}),M=T[T.length-1],D=T[0],U=this.parseFloat(a);if(this.isNaN(U)){for(var w=0;w<l.length;w++)if(p[w]=this.getValueFromArg(l[w]).split(this.tic).join(""),!t.isNullOrUndefined(h[w])&&""!==a&&""!==p[w])if(a.toUpperCase()===p[w].toUpperCase())f.push(this.getValueFromArg(h[w]).split(this.tic).join("")||"0");else if(a.indexOf("*")>-1||a.indexOf("?")>-1){var j=a;if(a.indexOf("*")>-1){j=j.replace(/\*/g,"").trim(),this.isCellReference(j)&&(j=this.getValueFromArg(j));var L=a.indexOf("*");"*"===a[0]&&(j="*"+j),"*"===a[a.length-1]&&(j+="*"),L>0&&L<a.length-1&&(j=a.substring(0,L)+"*"+a.substring(L+1))}var k=[],_=this.findWildCardValue(j.toLowerCase(),p[w].toLowerCase());k.push(_),k.push(a),this.processLogical(k,"equal")===this.trueValue&&f.push(this.getValueFromArg(h[w]).split(this.tic).join("")||"0")}}else for(var P=0;P<T.length;P++)p[P]=T[P].toString().split(this.tic).join(""),t.isNullOrUndefined(h[P])||""===p[P]||U!==this.parseFloat(p[P])||f.push(this.getValueFromArg(h[P]).split(this.tic).join("")||"0");if(f.length>0)return f[f.length-1];if(U>M&&!t.isNullOrUndefined(h[l.length-1]))return this.getValueFromArg(h[l.length-1]).split(this.tic).join("")||"0";if(U<D)return this.getErrorStrings()[r.CommonErrors.NA];if(g.indexOf(a.split(this.tic).join(""))<0&&a!==this.trueValue&&a!==this.falseValue)if(this.isNaN(U)||this.isNaN(M)||this.isNaN(D)){if(this.isNaN(U)&&""!==a&&/^[a-zA-Z!@#$%^&*()_+{}[\]:;<>,.?~\\/-]/.test(a)){var W=g.sort(),v=this.findClosestMatch(a.split(this.tic).join(""),W);if(!t.isNullOrUndefined(h[v])&&v>=0)return this.getValueFromArg(h[v]).split(this.tic).join("")||"0"}}else{for(var q=[],B=0;B<T.length;B++)U>T[B]&&q.push(T[B]);v=q.length-1;if(!t.isNullOrUndefined(h[v])&&v>=0)return this.getValueFromArg(h[v]).split(this.tic).join("")||"0"}return this.getErrorStrings()[r.CommonErrors.NA]},n.prototype.computeVHLookup=function(e,n){var i,o,s,a=this,u=e;if(u&&"conditionalFormulaTrue"===u[u.length-1]&&(s=!0,u.pop()),t.isNullOrUndefined(u)||u.length<3||u.length>4)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===u[1])return this.getErrorStrings()[r.CommonErrors.NA];var l=this.getValueFromArg(u[0]);if(l){if(l.includes(this.tic)){var h=l.split(this.tic).join("");if(h&&!this.isNumber(h)){var p=h.toUpperCase();p!==this.trueValue&&p!==this.falseValue&&(l=h)}}}else l="0";var g=this.getErrorStrings();if(g.indexOf(l)>-1)return l;var f=(this.getValueFromArg(u[2])||"0").split(this.tic).join("").toUpperCase(),m=this.parseFloat(f===this.trueValue?"1":f);if(m<1)return g[r.CommonErrors.Value];var c;if(u[3]){if(u[3]=this.getValueFromArg(u[3]).split(this.tic).join(""),g.indexOf(u[3])>-1)return u[3];var d=u[3].toUpperCase();if(d===this.falseValue||"0"===u[3])c=!0;else if(d!==this.trueValue&&"1"!==u[3])return g[r.CommonErrors.Value]}var v,N,E,S,y,C,b=u[1].split(":");if(!this.isCellReference(b[0])||!this.isCellReference(b[1]))return g[r.CommonErrors.Value];var A=this.rowIndex(b[0]),O=this.colIndex(b[0]),F=this.rowIndex(b[1]),x=this.colIndex(b[1]);if(A>F&&(A=(i=[F,A])[0],F=i[1]),O>x&&(O=(o=[x,O])[0],x=o[1]),!(A>0&&F<=1048576&&O>0&&x<=16384))return this.getErrorStrings()[r.CommonErrors.Name];S=this.grid;var V="",I=this.getSheetFamilyItem(S);u[1].startsWith("!")?(V=u[1].substring(0,u[1].replace("!","").indexOf("!")+2),null!==I.tokenToParentObject&&(this.grid=I.tokenToParentObject.get(V))):null!==I.parentObjectToToken&&(V=I.parentObjectToToken.get(S));var R=this.getSheetId(this.grid);if(-1===Z("Sheet"+R,this.getHostSheetInfo()))return this.grid=S,g[r.CommonErrors.Ref];var T=this.getCellValueFn(S,this.cell,R,!0);if(n){var M=O+m-1;if(M>x)return g[r.CommonErrors.Ref];v=A,N=F;var D=V+K(O);y=function(r){return T(r,O,D+r)};var U=V+K(M);C=function(){return T(E,M,U+E)||(s?'""':"0")}}else{var w=A+m-1;if(w>F)return g[r.CommonErrors.Ref];v=O,N=x;var j;y=function(r){return j=V+K(r),T(A,r,j+A)},C=function(){return T(w,E,j+w)||(s?'""':"0")}}var L,k,_=[];if(c){var P=void 0;if(this.isNumber(l)){var W=this.parseFloat(l);P=function(){return W===a.parseFloat(k)}}else if(l.includes("*")||l.includes("?")){var q=l,B=l.indexOf("*");B>-1&&(q=q.replace(/\*/g,"").trim(),this.isCellReference(q)&&(q=this.getValueFromArg(q)),0===B?q="*"+q:B===l.length-1?q+="*":q=l.substring(0,B)+"*"+l.substring(B+1)),q=q.toLowerCase(),P=function(){return a.processLogical([a.findWildCardValue(q,k.toLowerCase()),l],"equal")===a.trueValue}}else{var X=l.toUpperCase();P=function(){return X===k.toUpperCase()}}for(E=v;E<=N;E++)(k=y(E))&&P()&&_.push(C());L=_.length?_[0]:g[r.CommonErrors.NA]}else if(l.indexOf("*")>-1||l.indexOf("?")>-1)L=g[r.CommonErrors.NA];else{var Y,G=void 0;if(this.isNumber(l)){var $=this.parseFloat(l),z=H("");G=function(){Y=z(a.isNumber(k)?a.parseFloat(k):k||null,$)}}else{var Q=new Intl.Collator(this.parentObject.locale||"en-US",{sensitivity:"base"});G=function(){Y=!k||a.isNumber(k)?null:Q.compare(k,l)}}var J=void 0;for(E=v;E<=N;E++)k=y(E),J||(G(),0===Y?_.push(C()):Y<0?_.push(C()):Y>0&&_.length&&(J=!0));L=_.length?_[_.length-1]:g[r.CommonErrors.NA]}return this.grid=S,s&&"string"==typeof L&&-1!==L.indexOf(this.getParseArgumentSeparator())?this.tic+L+this.tic:L},n.prototype.findClosestMatch=function(r,t){for(var e=0,n=t.length-1;e<=n;){var i=Math.floor((e+n)/2),o=t[i],s=this.compareStrings(r.toLowerCase(),o.toLowerCase());if(0===s)return i;1===s?e=i+1:n=i-1}for(var a=e-1;a>=0;a--)if(-1!==this.compareStrings(r.toLowerCase(),t[a].toLowerCase()))return a;return-1},n.prototype.compareStrings=function(r,t){for(var e=Math.min(r.length,t.length),n=0;n<e;n++){var i=r.charCodeAt(n),o=t.charCodeAt(n);if(i<o)return-1;if(i>o)return 1}return r.length<t.length?-1:r.length>t.length?1:0},n.prototype.findWildCardValue=function(r,t){var e="";if(r.indexOf("?")>-1){var n=RegExp(r.replace(/\?/g,"[\\s\\S]"));e=t.length===r.length&&this.isNaN(this.parseFloat(t))&&t.match(n)?r:t}else if(r.indexOf("*")>-1){for(var i=r.indexOf("*"),o="",s="",a=this.falseValue,u=this.falseValue,l=i-1;l>=0;l--)o+=r[l],u=this.trueValue;for(l=i+1;l<r.length;l++)s+=r[l],a=this.trueValue;var h=""===o?-1:t.indexOf(o.split("").reverse().join("")),p=""===s?-1:t.indexOf(s);if(h>-1||p>-1){var g=o.split("").reverse().join("")===t.substr(0,o.length),f=s===t.substring(t.length-s.length,t.length);u===this.trueValue&&a===this.trueValue&&this.isNaN(this.parseFloat(o))&&this.isNaN(this.parseFloat(s))?e=g&&f?r:t:u===this.trueValue&&this.isNaN(this.parseFloat(o))?e=g?r:t:a===this.trueValue&&this.isNaN(this.parseFloat(s))&&(e=f?r:t)}else{if(r.startsWith("*")&&r.endsWith("*")){var m=r.slice(1,-1);""!==m&&t.includes(m)&&this.isNaN(this.parseFloat(m))&&(t=r)}e=t}}return e},n.prototype.getComputeSumIfValue=function(r,t,e,n,i,o,s){var a=0,u=0;switch(i){case this.parser.tokenEqual:for(var l=o?e.replace(/\*/g,""):e,h=0;h<r.length;h++){var p=this.getValueFromRange(t,h),g=this.getValueFromArg(r[h].split(this.tic).join("")).toLowerCase(),f=this.parseFloat(g);if(g===e&&f===n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}else if(g===e)this.isNaN(p)||(a+=p,u+=1);else if(o&&l&&g&&this.isNaN(this.parseFloat(g))){d=e.indexOf("*");"*"===e[0]&&l.length<=g.length&&l===g.slice(g.length-l.length,g.length)?this.isNaN(p)||(a+=p,u+=1):"*"===e[e.length-1]&&l.length<=g.length&&l===g.slice(0,l.length)?this.isNaN(p)||(a+=p,u+=1):d>-1&&g.startsWith(e.substr(0,d))&&g.endsWith(e.substr(d+1))&&(this.isNaN(p)||(a+=p,u+=1))}else if(o&&!l&&g&&this.isNaN(this.parseFloat(g)))this.isNaN(p)||(a+=p,u+=1);else if(s&&l&&g&&this.isNaN(this.parseFloat(g))){v=RegExp(l.replace(/\?/g,"[\\s\\S]"));g.length===e.length&&g.match(v)&&(this.isNaN(p)||(a+=p,u+=1))}}break;case this.parser.tokenLess:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))<n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenGreater:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))>n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenLessEq:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))<=n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenGreaterEq:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))>=n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenNotEqual:for(var l=o?e.replace(/\*/g,""):e,h=0;h<r.length;h++){var p=this.getValueFromRange(t,h),g=this.getValueFromArg(r[h].split(this.tic).join("")).toLowerCase(),f=this.parseFloat(g);if(g===e||f===n||o||s)if(o&&l&&g&&this.isNaN(this.parseFloat(g))){var d=e.indexOf("*");"*"===e[0]&&l.length<=g.length&&l!==g.slice(g.length-l.length,g.length)?this.isNaN(p)||(a+=p,u+=1):"*"===e[e.length-1]&&l.length<=g.length&&l!==g.slice(0,l.length)?this.isNaN(p)||(a+=p,u+=1):(d>-1&&!g.startsWith(e.substr(0,d))||!g.endsWith(e.substr(d+1)))&&(this.isNaN(p)||(a+=p,u+=1))}else if(!o||l||this.isNaN(this.parseFloat(g))){if(s&&l&&g&&this.isNaN(this.parseFloat(g))){var v=RegExp(l.replace(/\?/g,"[\\s\\S]"));g.length===e.length&&g.match(v)||this.isNaN(p)||(a+=p,u+=1)}}else this.isNaN(p)||(a+=p,u+=1);else{var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}}return[a,u]},n.prototype.getValueFromRange=function(r,t){var e=r[t];return e=this.getValueFromArg(e),this.parseFloat(e.toString())},n.prototype.computeAndOrNot=function(t,e){for(var n,i,o=this,s="and"===e,a="or"===e,u="not"===e,l=!(!s&&!u),h=[],p=t,g=0;g<p.length;g++){if(p[g]===this.tic)return this.getErrorStrings()[r.CommonErrors.Value];if(p[g]=p[g].startsWith("n")?p[g].slice(1):p[g],this.isCellReference(p[g]))for(var f=this.getCellCollection(p[g]),m=0;m<f.length;m++){if(this.getErrorStrings().indexOf(f[m])>-1)return f[m];if(f[m][0]===this.tic)return this.getErrorStrings()[r.CommonErrors.Name];if(n=this.getValueFromArg(f[m]),this.getErrorStrings().indexOf(n)>-1)return n;i=this.parseFloat(n),n===this.falseValue||""!==n&&0===i||u&&""===n?h.push(this.falseValue):n===this.trueValue||!isNaN(i)&&""!==n?h.push(this.trueValue):(""===n||isNaN(i))&&h.push(this.getErrorStrings()[r.CommonErrors.Value])}else{if(n=this.getValueFromArg(p[g]).toUpperCase(),this.getErrorStrings().indexOf(n)>-1)return n;i=this.parseFloat(n),(n=n.split(this.tic).join(""))===this.falseValue||""===p[g]||""!==n&&0===i?h.push(this.falseValue):n===this.trueValue||!isNaN(i)&&""!==n?h.push(this.trueValue):(""===n||isNaN(i))&&h.push(this.getErrorStrings()[r.CommonErrors.Value])}}if(h.every(function(t){return t===o.getErrorStrings()[r.CommonErrors.Value]}))return this.getErrorStrings()[r.CommonErrors.Value];for(m=0;m<h.length;m++){if((s||u)&&h[m]===this.falseValue){l=!1;break}if(a&&h[m]===this.trueValue){l=!0;break}}return l=u?!l:l,l?this.trueValue:this.falseValue},n.prototype.removeTics=function(r){return r.length>1&&r[0]===this.tic[0]&&r[r.length-1]===this.tic[0]&&(r=this.substring(r,1,r.length-2)),r},n.prototype.getCellFrom=function(r){var t,e="",n=r.indexOf(":")>-1?r.split(":"):[r],i=n.length-1,o=this.rowIndex(n[0]);if(o===this.rowIndex(n[i])){var s=this.colIndex(n[0]),a=this.colIndex(n[i]),u=this.colIndex(this.cell);u>=s&&u<=a&&(e=K(u).toString()+o.toString())}else if(this.colIndex(n[0])===this.colIndex(n[i])){t=this.colIndex(n[0]);var l=this.rowIndex(n[i]),h=this.rowIndex(this.cell);h>=o&&h<=l&&(e=K(t).toString()+h.toString())}return e},n.prototype.computeValue=function(e,n,i){try{var o=[],s=0,a="";o.length=0;for(var u=[],l=this.getParseDecimalSeparator();s<e.length;){var h="u"===e[s];if(h&&(s+=1),e[s]!==this.arithMarker){if(this.isDigit(e[s])){for(p="";s<e.length&&(this.isDigit(e[s])||e[s]===l);)p+=e[s]===l?".":e[s],s+=1;if(o.push(p),!e[s])return o.toString()}if(e[s]===this.sheetToken){for(a=e[s],s+=1;s<e.length&&e[s]!==this.sheetToken;)a+=e[s],s+=1;s<e.length&&(a+=e[s],s+=1)}else if(this.isUpperChar(e[s])){for(var p="",g="";s<e.length&&this.isUpperChar(e[s]);)p+=e[s],s+=1;for(;s<e.length&&this.isDigit(e[s]);)p+=e[s],s+=1;if(s<e.length&&":"===e[s]){if(p+=e[s],(s+=1)<e.length&&e[s]===this.sheetToken)for(p+=e[s],s+=1;s<e.length&&e[s]!==this.sheetToken;)p+=e[s],s+=1;for(;s<e.length&&this.isUpperChar(e[s]);)p+=e[s],s+=1;for(;s<e.length&&this.isDigit(e[s]);)p+=e[s],s+=1;p=a+this.getCellFrom(p)}else p=a+p;var f=this.getParentObjectCellValue(p,n);if(g=t.isNullOrUndefined(f)?"":f.toString(),a="","string"==typeof g&&this.getErrorStrings().indexOf(g)>-1)return g;h&&(g=this.isNaN(this.parseFloat(g))?"-"+g:(-this.parseFloat(g)).toString()),o.push(g),""===g&&(u[o.length-1]="0")}else if("q"===e[s]){var m=e.substring(s+1).indexOf(this.leftBracket),c=e.substring(s+m+1).indexOf(this.rightBracket);e=this.substring(e,s+m+2,c-1)}else if(e[s]===this.tic[0]){for(var p=e[s].toString(),d="n"===e[(s+=1)-2]&&e[s]===this.tic[0];s<e.length&&e[s]!==this.tic[0];)p+=e[s],s+=1;(g=p.split(this.tic).join(""))===this.trueValue||g===this.falseValue||!this.isNaN(this.parseFloat(g))&&""!==g?o.push(this.tic+g+this.tic):(o.push(g),""===g&&d&&(u[o.length-1]="0")),s+=1}else if("%"===e[s]&&o.length>0){var v=o[0],N=this.parseFloat(v);this.isNaN(N)||(o.pop(),o.push((N/100).toString())),s+=1}else if(0===e.substring(s).indexOf(this.trueValue))o.push(this.trueValue),s+=this.trueValue.length;else if(0===e.substring(s).indexOf(this.falseValue))o.push(this.falseValue),s+=this.falseValue.length;else if(e[s]===this.tic[0]||"|"===e[s]){p=e[s].toString();for(s++;s<e.length&&e[s]!==this.tic[0];)p+=e[s],s+=1;o.push(p+this.tic),s+=1}else{if(" "===e[s]&&s<e.length-1){s+=1;continue}switch(e[s]){case"#":var E=0;this.getErrorStrings().indexOf(e.substring(s))>-1?(E=-1===e.indexOf("!")||-1===e.substring(s).indexOf("!")?e.indexOf("#N/A")>-1?e.indexOf("#N/A")+4+s:e.indexOf("?")+1+s:e.indexOf("!")+1+s,o.push(this.substring(e,s,E-s))):(E=s+1,o.push(this.substring(e,s,E-s))),s=E;break;case"n":p="";if("n"===e[s+=1])continue;if(0===e.substring(s).indexOf("Infinity"))s+=(p="Infinity").length;else{for(("u"===e[s]||h||"-"===e[s])&&(p="-",h?h=!1:s+=1);s<e.length&&(this.isDigit(e[s])||e[s]===l||"."===e[s]);)p+=e[s]===l?".":e[s],s+=1;if(s<e.length&&"%"===e[s])if(s+=1,""===p){if(o.length>0){var v=o[0],N=this.parseFloat(v);this.isNaN(N)||(o.pop(),o.push((N/100).toString()))}}else p=(this.parseFloat(p)/100).toString()}p&&o.push(p);break;case this.parser.tokenAdd:this.getValArithmetic(o,"add",i),s+=1;break;case this.parser.tokenSubtract:this.getValArithmetic(o,"sub",i),s+=1;break;case this.parser.tokenMultiply:this.getValArithmetic(o,"mul",i),s+=1;break;case this.parser.tokenDivide:this.getValArithmetic(o,"div",i),s+=1;break;case this.parser.tokenLess:this.processLogical(o,"less"),s+=1;break;case this.parser.tokenGreater:this.processLogical(o,"greater"),s+=1;break;case this.parser.tokenGreaterEq:this.processLogical(o,"greaterEq"),s+=1;break;case this.parser.tokenLessEq:this.processLogical(o,"lessEq"),s+=1;break;case this.parser.tokenNotEqual:this.processLogical(o,"notEq",u),u.length=0,s+=1;break;case this.parser.tokenOr:this.processLogical(o,"or"),s+=1;break;case this.parser.tokenAnd:this.processLogical(o,"and"),s+=1;break;case this.parser.tokenEqual:this.processLogical(o,"equal",u),u.length=0,s+=1;break;default:return this.getErrorStrings()[r.CommonErrors.Value]}}}else s+=1}if(0===o.length)return"";for(var p="",S=o.length;S>0;){var y=o.pop();if(this.getErrorStrings().indexOf(y)>-1)return y;if(""===(p=y+p)&&this.isCellReference(e)&&this.getTreatEmptyStringAsZero())return"0";S--}return p}catch(t){if(this.getErrorStrings().indexOf(t)>-1||this.formulaErrorStrings.indexOf(t)>-1)throw t;throw new oe(this.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression])}},n.prototype.getValArithmetic=function(t,e,n){var i=!1,o=t.pop(),s=-1!==o.indexOf(".")?o.split(".")[1].length:0,a=Math.pow(10,s),u=t.pop(),l=-1!==u.indexOf(".")?u.split(".")[1].length:0,h=Math.pow(10,l),p=a>=h?a:h,g=a*h;o=""===(o=o===this.trueValue?"1":o===this.falseValue?"0":o)?"0":this.getErrorStrings().indexOf(o.toString())<0?this.parseFloat(o+"").toString():o;var f=Number(o);isNaN(f)&&!n&&(i=!0,o===this.getErrorStrings()[r.CommonErrors.DivZero]?t.push(this.getErrorStrings()[r.CommonErrors.DivZero]):t.push(this.getErrorStrings()[r.CommonErrors.Value])),u=""===(u=u===this.trueValue?"1":u===this.falseValue?"0":u)?"0":this.getErrorStrings().indexOf(u.toString())<0?this.parseFloat(u+"").toString():u,f=Number(u),isNaN(f)&&!n&&(i=!0,u===this.getErrorStrings()[r.CommonErrors.DivZero]?t.push(this.getErrorStrings()[r.CommonErrors.DivZero]):t.push(this.getErrorStrings()[r.CommonErrors.Value])),"add"!==e||i||t.push(((Number(u)*p+Number(o)*p)/p).toString()),"sub"!==e||i||t.push(((Number(u)*p-Number(o)*p)/p).toString()),"mul"!==e||i||t.push((Number(u)*h*(Number(o)*a)/g).toString()),"div"!==e||i||(this.isNaN(this.parseFloat(o))||this.isNaN(this.parseFloat(u))?t.push(this.getErrorStrings()[r.CommonErrors.Value]):0===this.parseFloat(o)?t.push(this.getErrorStrings()[r.CommonErrors.DivZero]):t.push((Number(u)*g/(Number(o)*g)).toString()))},n.prototype.processLogical=function(e,n,i){var o,s,a,u,l,h,p=!1;if("and"!==n&&"equal"!==n&&"notEq"!==n&&(o=e.pop(),s=e.pop(),this.getErrorStrings().indexOf(o)>-1?(h=o,p=!0):this.getErrorStrings().indexOf(s)>-1&&(h=s,p=!0),this.isNaN(this.parseFloat(o))&&this.isNaN(this.parseFloat(s))&&(o=o.toString().toLowerCase(),s=s.toString().toLowerCase()),t.isNullOrUndefined(o)||(a=o.indexOf(this.tic)>-1?o:this.parseFloat(o)),t.isNullOrUndefined(s)||(u=s.indexOf(this.tic)>-1?s:this.parseFloat(s)),"*"===o&&this.isNaN(this.parseFloat(s))&&""!==s&&(l=!0)),"less"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))<0?this.trueValue:this.falseValue:u<a?this.trueValue:this.falseValue),"greater"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))>0?this.trueValue:this.falseValue:u>a?this.trueValue:this.falseValue),"lessEq"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))<=0?this.trueValue:this.falseValue:u<=a?this.trueValue:this.falseValue),"greaterEq"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))>=0?this.trueValue:this.falseValue:u>=a?this.trueValue:this.falseValue),"and"!==n||p||(o=e.pop().toString(),s="",e.length>0&&(s=e.pop().toString()),h=this.getErrorStrings().indexOf(o)>-1?o:this.getErrorStrings().indexOf(s)>-1?s:(h=""+s+o).split(this.tic).join("")),("equal"===n||"notEq"===n)&&!p){var g=void 0,f=void 0;i?(g=i[e.length-1],o=e.pop(),f=i[e.length-1],s=e.pop()):(o=e.pop(),s=e.pop()),this.getErrorStrings().indexOf(o)>-1?h=o:this.getErrorStrings().indexOf(s)>-1?h=s:(o="TRUE"===o?"1":"FALSE"===o?"0":o,s="TRUE"===s?"1":"FALSE"===s?"0":s,this.isNaN(this.parseFloat(o))&&this.isNaN(this.parseFloat(s))&&(o=o.toString().toLowerCase(),s=s.toString().toLowerCase()),"*"===o&&this.isNaN(this.parseFloat(s))&&""!==s&&(l=!0),h="equal"===n?o===s||void 0!==g&&g===s||void 0!==f&&f===o||l?this.trueValue:this.falseValue:l?this.falseValue:s===o||g&&g===s||f&&f===o?this.falseValue:this.trueValue)}return"or"!==n||p||(h=Math.pow(this.parseFloat(u),this.parseFloat(a)).toString(),h=this.isNaN(this.parseFloat(h))?this.getErrorStrings()[r.CommonErrors.Value]:h),e.push(h),h},n.prototype.computeStoreCells=function(r){for(var t,e=r.cellValue,n=r.cellRange,i=r.criteria,o=r.argArray,s=r.isCriteria,a=r.storedCells,u=r.isCountIfS===this.trueValue,l=r.countVal||0,h=s===this.trueValue?a:e,p=[],g=0;g<h.length;g++){var f=[],m=this.getValueFromArg(e[g]),c=o[u?1+2*l:2+l],d=c.startsWith(this.tic)&&c.endsWith(this.tic),v=(t=this.getANDComputedValue(c.trim())).includes("*"),N="*"===t||"<>*"===t,E=v&&!N?t.replace(/\*/g,"").trim():t,S=!1;if(!d&&this.isCellReference(E)&&(E=this.getValueFromArg(E),S=!0),v&&!N){var y=t.indexOf("*");"*"===t[0]&&(E="*"+E),"*"===t[t.length-1]&&(E+="*"),y>0&&y<t.length-1&&(E=t.substring(0,y)+"*"+t.substring(y+1))}t=E;var C="";if((s=u?this.trueValue:s)===this.trueValue){var b="",A=0,O=0,F=void 0,x=void 0,V=void 0,I=void 0;a[g]=u&&!l?e[g]:a[g],b=a[g],l&&(x=Y((F=n[l-1]).indexOf("!")>-1?F.substring(F.lastIndexOf("!")+1):F),V=q(b.indexOf("!")>-1?b.substring(b.lastIndexOf("!")+1):b),I=Y(n[l].indexOf("!")>-1?n[l].substring(n[l].lastIndexOf("!")+1):n[l]));var R=b.indexOf("!")>-1,T=void 0,M="",D="";for(R&&(D=b.substring(0,b.lastIndexOf("!")+1),b=b.substring(b.lastIndexOf("!")+1));!this.isDigit(b[A]);)A+=1;if(this.isCellReference(n[l])&&n[l].indexOf(":")>-1)for(C=u&&!l?h[g].indexOf("!")>-1?h[g].substring(h[g].lastIndexOf("!")+1):h[g]:B(I[0]+(V[0]-x[0]),I[1]+(V[1]-x[1])),(T=n[l].indexOf("!")>-1)&&(M=n[l].substring(0,n[l].lastIndexOf("!")+1));!this.isDigit(C[O]);)O+=1;var U=this.substring(b,A),w=this.substring(C,O),j=this.substring(b,A,b.length-A),L=this.substring(C,O,C.length-A);R&&(U=D+U,w=D+w),j!==L&&(a[g]=this.substring(a[g],R?D.length+A:A)+L),C=a[g].split(U).join(w),T?(C.indexOf("!")>-1&&(C=C.substring(C.lastIndexOf("!")+1)),C=M+C):C=C.substring(C.lastIndexOf("!")+1),m=this.getValueFromArg(C),t=u?t:this.getANDComputedValue(i[l-1])}var k="equal",_=this.getOperatorAndCriteria(t,k);k=_.op,t=_.criteria,(!d&&this.isCellReference(t)&&(!S||""!==C&&!u)||t.includes(this.arithMarker))&&(t=this.getValueFromArg(t)),(t.indexOf("*")>-1||t.indexOf("?")>-1)&&(m=this.findWildCardValue(t.toLowerCase(),m.toLowerCase())),f.push(m.toLowerCase()),f.push(t.toLowerCase()),this.processLogical(f,k)===this.trueValue&&(s===this.falseValue?p.push(e[g]):p.push(C))}return a=p,p=[],a},n.prototype.computeIfsFormulas=function(e,n,i){if(n===this.trueValue&&(t.isNullOrUndefined(e)||""===e[0]||e.length<2||e.length>127||e.length%2!=0))return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o=e,s=[],a=[],u=[],l=0,h=0;h<o.length;h++)0!==h&&h%2!=1||!this.isCellReference(o[h])?a.push(o[h].trim()):s.push(o[h].indexOf(":")>-1?o[h].trim():X(Y(o[h])));for(var p=[],h=0;h<s.length;h++)p.push(this.getCellCollection(s[h]).length);for(S=0;S<p.length;S++)if(p[S]&&p[S+1]&&p[S]!==p[S+1])return this.getErrorStrings()[r.CommonErrors.Value];for(var g=0;g<a.length;g++)if(""===a[g]||this.isCellReference(a[g])&&""===this.getValueFromArg(a[g]))return i===this.trueValue?this.getErrorStrings()[r.CommonErrors.DivZero]:0;var f,m;if(n===this.falseValue){m=this.falseValue;c={cellValue:f=this.getCellCollection(s[1]),cellRange:s,criteria:a,argArray:o,isCriteria:m,storedCells:u,isCountIfS:n};if(u=this.computeStoreCells(c),0===u.length)return i===this.trueValue?this.getErrorStrings()[r.CommonErrors.DivZero]:0}for(h=n===this.trueValue?0:2;h<s.length;h++){m=this.trueValue,m=n===this.trueValue&&0===h?this.falseValue:this.trueValue;var c={cellValue:f=this.getCellCollection(s[h]),cellRange:s,criteria:a,argArray:o,isCriteria:m,storedCells:u,isCountIfS:n,countVal:h};if(u=this.computeStoreCells(c),0===u.length)return i===this.trueValue?this.getErrorStrings()[r.CommonErrors.DivZero]:0}for(var d=0,v=Y(s[0].indexOf("!")>-1?s[0].substring(s[0].lastIndexOf("!")+1):s[0]),N=s[s.length-1],E=Y(N.indexOf("!")>-1?N.substring(N.lastIndexOf("!")+1):N),S=0;S<u.length;S++){var y="",C="",b=0,A=0,O=(y=u[S]).indexOf("!")>-1,F=void 0,x="",V="";for(O&&(V=y.substring(0,y.lastIndexOf("!")+1),y=y.substring(y.lastIndexOf("!")+1));!this.isDigit(y[b]);)b+=1;if(this.isCellReference(s[0])&&s[0].indexOf(":")>-1)for(C=B(v[0]+(q(y)[0]-E[0]),v[1]+(q(y)[1]-E[1])),(F=s[0].indexOf("!")>-1)&&(x=s[0].substring(0,s[0].lastIndexOf("!")+1));!this.isDigit(C[A]);)A+=1;var I=this.substring(y,b),R=this.substring(C,A),T=this.substring(y,b,y.length-b),M=this.substring(C,A,C.length-b);if(O&&(I=V+I,R=V+R),T!==M&&(u[S]=this.substring(u[S],O?V.length+b:b)+M),f=u[S].split(I).join(R),F?(f.indexOf("!")>-1&&(f=f.substring(f.lastIndexOf("!")+1)),f=x+f):f=f.substring(f.lastIndexOf("!")+1),n===this.trueValue)l+=1;else{var D=this.getValueFromArg(f),U=parseFloat(""===D&&i!==this.trueValue?"0":D);this.isNumber(U)&&(d++,l+=U)}}return i===this.trueValue&&(l/=d),l},n.prototype.computeCountIfsFormulas=function(e){var n=this.grid;if(t.isNullOrUndefined(e)||""===e[0]||e.length<2||e.length>127||e.length%2!=0)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var i=e,o=[],s=[],a=0;a<i.length;a++)a%2==0&&this.isCellReference(i[a])?o.push(i[a].indexOf(":")>-1?i[a].trim():X(Y(i[a]))):s.push(i[a].trim());if(o.length!==s.length)return this.getErrorStrings()[r.CommonErrors.Value];for(var u=[],l=this.grid,a=0;a<o.length;a++){var h=Y(o[a]),p=h[0],g=h[1],f=h[2],m=h[3],c="",d=this.getSheetFamilyItem(l);o[a].startsWith("!")?(c=o[a].substring(0,o[a].replace("!","").indexOf("!")+2),null!==d.tokenToParentObject&&(l=d.tokenToParentObject.get(c))):null!==d.parentObjectToToken&&(c=d.parentObjectToToken.get(l)),this.grid=l;var v=this.getSheetId(l);if(-1===Z("Sheet"+v,this.getHostSheetInfo()))return this.grid=n,this.getErrorStrings()[r.CommonErrors.Ref];U=this.getCellValueFn(l,this.cell,v,!0);if(u.length>0){var N=u[u.length-1],E=N.endRow-N.startRow+1,S=N.endCol-N.startCol+1;if(f-p+1!==E||m-g+1!==S)return this.getErrorStrings()[r.CommonErrors.Value]}u.push({startRow:p,startCol:g,endRow:f,endCol:m,getCellValue:U,grid:l})}for(var y=0;y<s.length;y++)if(""===s[y])return this.grid=n,0;for(var C=[],a=0;a<u.length;a++){this.grid=n;var b=s[a],A=b.startsWith(this.tic)&&b.endsWith(this.tic),O=(b=this.getANDComputedValue(b.trim())).includes("*"),F="*"===b||"<>*"===b,x=O&&!F?b.replace(/\*/g,"").trim():b,V=!1;if(!A&&this.isCellReference(x)&&(x=this.getValueFromArg(x),V=!0),O&&!F){var I=b.indexOf("*");"*"===b[0]&&(x="*"+x),"*"===b[b.length-1]&&(x+="*"),I>0&&I<b.length-1&&(x=b.substring(0,I)+"*"+b.substring(I+1))}b=x;var R="equal",T=this.getOperatorAndCriteria(b,R);R=T.op,b=T.criteria,(!A&&this.isCellReference(b)&&!V||b.includes(this.arithMarker))&&(b=this.getValueFromArg(b));var M=b.indexOf("*")>-1||b.indexOf("?")>-1,D=u[a],p=D.startRow,g=D.startCol,f=D.endRow,m=D.endCol,U=D.getCellValue,w=u[a].grid;this.grid=w;var j=void 0;if(0===a)for(var L=p;L<=f;L++)for(var k=g;k<=m;k++)j=U(L+1,k+1,B(L,k)),M&&(j=this.findWildCardValue(b.toLowerCase(),j.toLowerCase())),this.processLogical([j.toLowerCase(),b.toLowerCase()],R)===this.trueValue&&C.push({rowIdx:L,colIdx:k});else{var _=C,P=u[a-1];C=[];for(var W=0;W<_.length;W++){var q=_[W];q.rowIdx=p+(q.rowIdx-P.startRow),q.colIdx=g+(q.colIdx-P.startCol),j=U(q.rowIdx+1,q.colIdx+1,B(q.rowIdx,q.colIdx)),M&&(j=this.findWildCardValue(b.toLowerCase(),j.toLowerCase())),this.processLogical([j.toLowerCase(),b.toLowerCase()],R)===this.trueValue&&C.push({rowIdx:q.rowIdx,colIdx:q.colIdx})}}if(0===C.length)return this.grid=n,0}return this.grid=n,C.length},n.prototype.getOperatorAndCriteria=function(r,t){var e=r;return e.startsWith("<=")?(t="lessEq",e=e.substring(2)):e.startsWith(">=")?(t="greaterEq",e=e.substring(2)):e.startsWith("<>")?(t="notEq",e=e.substring(2)):e.startsWith("<")?(t="less",e=e.substring(1)):e.startsWith(">")?(t="greater",e=e.substring(1)):e.startsWith("=")&&(t="equal",e=e.substring(1)),{op:t,criteria:e}},n.prototype.processNestedFormula=function(r,t,e){return e&&!e.toString().includes('"')&&'"'===r[r.indexOf(t)+t.length]&&this.getErrorStrings().indexOf(e.toString())<0&&!this.isNumber(e)&&e!==this.trueValue&&e!==this.falseValue?r.split(t).join('"'+e+'"'):r.split(t).join("n"+e)},n.prototype.isNaN=function(r){return"NaN"===r.toString()||"string"==typeof r},n.prototype.isNumber=function(r){return r-parseFloat(r)>=0},n.prototype.fromOADate=function(r){(r=r>0&&r<1?1+r:0===r?1:r)>60&&(r-=1);var t=new Date("01/01/1900"),e=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());return new Date(new Date((r-1)*this.millisecondsOfaDay+e).toUTCString().replace(" GMT",""))},n.prototype.getSerialDateFromDate=function(r,t,e){var n=0;r<1900&&(r+=1900);for(var i=!1;!i;){for(;t>12;)r++,t-=12;for(;t<1;)t+=12,r--;i=!0;for(var o=new Date(r,t,1,-1).getDate();e>o;)o=new Date(r,t,1,-1).getDate(),t++,e-=o,i=!1;e<1&&(--t<1&&(t=12,r--),e=(o=new Date(r,t,1,-1).getDate())+e,i=!1)}var s=Date.parse(r+"/"+t+"/"+e);return this.isNaN(s)||(n=this.toOADate(new Date(s))),n},n.prototype.intToTime=function(r){var e=r.toString().split(".");return t.isNullOrUndefined(e[1])||(r=parseFloat(e[0]+1+"."+e[1])||r),this.intToDate(r.toString())},n.prototype.toOADate=function(r,t,e){var n=new Date("01/01/1900"),i=o(r)?r:new Date(r),s=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),a=(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())-s)/864e5;return(t?a:parseInt(a.toString(),10))+(e?0:a>60?2:1)},n.prototype.calculateDate=function(r){return this.parseFloat(r)<10?"0"+r:r},n.prototype.isTextEmpty=function(r){return null===r||""===r},n.prototype.isDigit=function(r){var t=r.charCodeAt(0);return t>47&&t<58},n.prototype.getANDComputedValue=function(r){return r.startsWith(this.arithMarker)&&r.includes("c")&&(r=this.getValueFromArg(r)),r.split(this.tic).join("")},n.prototype.findLastIndexOfq=function(r){for(var t=r.lastIndexOf("q"),e=r.lastIndexOf(this.leftBracket);e<t;)t=r.substring(0,t).lastIndexOf("q");return t},n.prototype.getValueFromArg=function(e,n,i,o,s){if(!(e=e.trim())||this.getErrorStrings().indexOf(e)>-1)return e;var a=e[0];if(a===this.tic||a===this.singleTic){h=e.split(this.tic).join("");if(this.isNaN(this.parseFloat(h))&&(!s||a!==this.tic||!e.endsWith(this.tic))){var u=this.isDate(h);if(u&&!this.isNaN(u.getDate()))return this.toOADate(u,!0).toString()}return e.endsWith(this.tic)&&"."!==(l=this.getParseDecimalSeparator())&&h.includes(l)&&(h=h.replace(l,"."),this.isNumber(h)&&(e=h)),e}if("u"===a&&e.includes(this.arithMarker))e=this.parser.parseSimpleOperators(e.split("u").join("0-"),[this.parser.tokenSubtract],["-"]);else if(!this.isUpperChar(a)){var l=this.getParseDecimalSeparator();if(this.isDigit(a)||a===l||"-"===a||"n"===a){if("n"===a&&(e=e.substring(1)).indexOf('"n')>-1&&(e=e.replace('"n','"')),"."!==l&&e.includes(l)){var h=e.replace(l,".");this.isNumber(h)&&(e=h)}return e}}var p=a===this.sheetToken;if(p||this.isUpperChar(a)&&!["+","-","/","*",")",")","{"].some(function(r){return e.includes(r)})){var g=this.isCellReference(e);if(g&&!p){var f=this.getSheetFamilyItem(this.grid);null!==f.sheetNameToParentObject&&f.parentObjectToToken.has(this.grid)&&(e=f.parentObjectToToken.get(this.grid)+e)}if(e===this.cell){var m=this.getDependentCells().get(e);if(null!=m&&m.indexOf(e)>-1&&this.arrayRemove(m,e),this.getDependentFormulaCells().has(this.cell)||this.clearFormulaDependentCells(this.cell),!n)throw new oe(this.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference])}var c=this.getParentObjectCellValue(e,!1,n,o),d=t.isNullOrUndefined(c)?"":c.toString();return g&&this.updateDependentCell(e),d}return this.computeValue(e,!1,i)},n.prototype.isDate=function(r){if("object"==typeof r||null!==Date.parse(r)){var t=void 0;return t="string"==typeof r?this.checkDateFormat(r,!1,!0):new Date(Date.parse(r)),t>=this.dateTime1900?t:null}return null},n.prototype.parseDate=function(t){if(!this.isNaN(t)){if(t instanceof Date)return new Date(t);var e=parseInt(t,10);return e<0?this.getErrorStrings()[r.CommonErrors.Num]:e<=60?new Date(this.dateTime1900.getTime()+864e5*(e-1)):new Date(this.dateTime1900.getTime()+864e5*(e-2))}return"string"!=typeof t||(t=this.checkDateFormat(t,!0),this.isNaN(t))?this.getErrorStrings()[r.CommonErrors.Value]:t},n.prototype.checkDateFormat=function(r,t,e){var n=this.parentObject;if(n&&"function"==typeof n.getModuleName&&"spreadsheet"===n.getModuleName()){var i=this.hostParseDate(r);if(i.isDate)return i.dateObj;if(e&&!i.isTime)return new Date(NaN)}return this.getErrorStrings().indexOf(r)>-1?new Date(NaN):t?new Date(r):new Date(Date.parse(r))},n.prototype.isCellReference=function(r){if(""===(r=r.trim()))return!1;r=this.setTokensForSheets(r);var t=this.getSheetToken(r),e=!1;""!==t&&(r=r.split(t).join(""));var n=!1,i=!1;if(r.indexOf(":")!==r.lastIndexOf(":"))return!1;for(var o=r.split("").join(this.getParseArgumentSeparator()).split(this.getParseArgumentSeparator()),s=0;s<o.length;s++)if(this.isChar(o[s]))n=!0;else if(this.isDigit(o[s]))i=!0;else{if(":"!==o[s])return!1;n&&i&&(e=!0),n=!1,i=!1}return r.indexOf(":")>-1&&-1===r.indexOf(this.tic)?!!(e&&n&&i||(n&&!i||!n&&i)&&!e):!!(n&&i&&-1===r.indexOf(this.tic)&&this.isValidCell(r))},n.prototype.setTokensForSheets=function(r){var t=this.getSheetFamilyItem(this.grid),e=this.getSortedSheetNames();if(null!=e)for(var n=0;n<e.length;n++){var i=t.sheetNameToToken.get(e[n]);i=i.split(this.sheetToken).join(this.tempSheetPlaceHolder);var o=this.singleTic+"SHEET"+e[n]+this.singleTic+this.sheetToken;-1===r.indexOf(o)&&(o="SHEET"+e[n]+this.sheetToken),r=r.split(o).join(i),o=e[n]+this.sheetToken,r=r.split(o).join(i)}if((r=r.split(this.tempSheetPlaceHolder).join(this.sheetToken)).indexOf("!!")>-1){var s=(r=r.replace("!!","!")).split("!");s[1]=(parseInt(s[1],10)+1).toString(),r=s.join("!")}return r},n.prototype.getParentObjectCellValue=function(e,n,i,o){if(e===this.trueValue||e===this.falseValue)return e;var s,a=e.lastIndexOf(this.sheetToken),u=this.grid;if(a>-1){if(null===(h=this.getSheetFamilyItem(u)).tokenToParentObject)return this.getErrorStrings()[r.CommonErrors.Value];this.grid=h.tokenToParentObject.get(e.substring(0,a+1)),s=e.substring(a+1)}else{for(var l=0;l<e.length&&this.isChar(e[l]);)l++;if(l===e.length)return""===e?this.getErrorStrings()[r.CommonErrors.Value]:this.getErrorStrings()[r.CommonErrors.Name];s=e;var h=this.getSheetFamilyItem(u);h.isSheetMember&&null!=h.parentObjectToToken&&(e=h.parentObjectToToken.get(this.grid)+e)}if(this.isDigit(s[0])){var p=s.search(/[a-zA-Z]/);p>0&&(s=s.substring(p,s.length)+s.substring(0,p))}var g,f=this.rowIndex(s),m=this.colIndex(s);if(f>0&&f<=1048576&&m>0&&m<=16384){var c=this.getSheetId(this.grid),d=this.getHostSheetInfo();if(d.length&&-1===Z("Sheet"+c,d))return this.grid=u,this.getErrorStrings()[r.CommonErrors.Ref];g=this.getCellValueFn(u,this.cell,c,!1,n,i,o)(f,m,e)}else g=this.getErrorStrings()[r.CommonErrors.Name];return this.grid=u,t.isNullOrUndefined(g)?"":g},n.prototype.getCellValueFn=function(e,n,i,o,s,a,u){var l=this,h=n;h&&(h=e===this.grid?"":h+","+("string"==typeof e&&Number(e)>-1?e:this.getSheetID(e)));var p=this.parentObject.getValueRowCol.bind(this.parentObject)||this.getValueRowCol.bind(this);return function(e,g,f){if(n===f&&!a)throw l.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference];l.cell=f;var m=p(i,e,g,h,s,a,u);if(t.isNullOrUndefined(m))m="";else{m=m.toString();var c=l.getParseDecimalSeparator();if("."!==c&&m.includes(c)){var d=m.replace(c,".");l.isNumber(d)&&(m=d)}}return l.cell=n,o&&l.updateDependentCell(f),m}},n.prototype.isValidCell=function(r){if(0===r.search(/\d/)){var t=r.search(/[a-zA-Z]/);r=r.substring(t,r.length)+r.substring(0,t)}var e=this.rowIndex(r),n=this.colIndex(r);return e>0&&e<=1048576&&n>0&&n<=16384},n.prototype.getSheetId=function(r){return r&&"string"==typeof r&&Number(r)>-1?Number(r):this.getSheetID(r)+1},n.prototype.getValueRowCol=function(r,e,n){var i=(this.convertAlpha(n)+e.toString()).toUpperCase();if(this.storedData.has(i)){var o=this.getKeyValue(i);return t.isNullOrUndefined(o)?"":o.toString()}var s=this.rowsToKeyMap.get(e);if(t.isNullOrUndefined(s))return"";var a=s.toString(),u=a.toUpperCase();if(this.isCellReference(u)&&u!==i)return"";if(this.evaluatingKeys.has(u))return"";var l=this.getKeyValue(a);if(t.isNullOrUndefined(l))return"";if(""!==(l=l.toString())&&"%"===l[l.length-1]&&l.length>1){var h=this.parseFloat(l.substring(0,l.length-1));this.isNaN(h)&&(l=(Number(h)/100).toString())}return l},n.prototype.defineFunction=function(r,e,n,i){"string"==typeof e&&(e=t.getValue(e,window)),r=r.toUpperCase(),this.libraryFormulas.set(r,{handler:e,isCustom:!0,description:n,category:i})},n.prototype.valueChanged=function(e,n,i,o,s,a,u,l,h,p,g,f){var m=e;this.spreadSheetUsedRange=o,this.grid=e;var c=!0,d=!0,v=this.getSheetFamilyItem(m),N=K(n.getColIndex())+n.getRowIndex().toString();this.actCell=a+"!"+N,null!==v.sheetNameToParentObject&&v.sheetNameToParentObject.size>0&&(N=v.parentObjectToToken.get(m)+N);var E=n.getFormulaValue().toUpperCase();if(E.indexOf("=RAND()")>-1||E.indexOf("=NOW()")>-1||E.indexOf("NOW()")>-1||E.indexOf("RAND()")>-1||E.indexOf("=RANDBETWEEN(")>-1||E.indexOf("RANDBETWEEN(")>-1||this.randomValues.has(N)){var S=this.randCollection.toString();this.randomValues.has(N)?this.randomValues.has(N)&&(E.indexOf("=RAND()")>-1||E.indexOf("=NOW()")>-1||E.indexOf("NOW()")>-1||E.indexOf("RAND()")>-1||E.indexOf("=RANDBETWEEN(")>-1||E.indexOf("RANDBETWEEN(")>-1?this.randomValues.set(N,n.getFormulaValue()):n.getFormulaValue().toUpperCase()!==this.randomValues.get(N.toUpperCase())&&(this.randomValues.delete(N),S=S.split(N+this.parseArgumentSeparator).join("").split(this.parseArgumentSeparator+N).join("").split(N).join(""),this.randCollection=S.split(this.parseArgumentSeparator)),0===this.randomValues.size&&this.randCollection.length&&(this.isRandomVal=!1,this.randomValues.clear(),this.randCollection=[])):(this.randomValues.set(N,n.getFormulaValue()),this.randCollection.push(N),this.isRandomVal=!0)}if(n.getFormulaValue()&&n.getFormulaValue()[0]===this.getFormulaCharacter()){this.cell=N;var y=void 0;if(t.isNullOrUndefined(d)||(d=i),this.getFormulaInfoTable().has(N)){if(y=this.getFormulaInfoTable().get(N),n.getFormulaValue()!==y.getFormulaText()||null==y.getParsedFormula()){y.setFormulaText(n.getFormulaValue()),this.getDependentFormulaCells().has(this.cell)&&this.clearFormulaDependentCells(this.cell);try{y.setParsedFormula(this.parser.parseFormula(n.getFormulaValue()))}catch(r){y.setFormulaValue(r),d=!1}}else this.parser.isError=!1;d&&(this.parser.isFormulaParsed=!0,c=(C=this.calculateFormula(y.getParsedFormula(),s))!==y.getFormulaValue()&&(!this.parentObject.isEdit||C!==this.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference]),y.setFormulaValue(C))}else{(y=new se).setFormulaText(n.getFormulaValue()),this.getDependentFormulaCells().has(N)||this.getDependentFormulaCells().set(N,new Map),this.getFormulaInfoTable().set(N,y);try{y.setParsedFormula(this.parser.parseFormula(n.getFormulaValue()))}catch(r){y.setFormulaValue(r),d=!1}if(d){var C=this.calculateFormula(y.getParsedFormula(),s);c=C!==this.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference],y.setFormulaValue(C)}}d&&(void 0===this.parentObject.setValueRowCol?this.setValueRowCol(this.getSheetID(m)+1,y.getFormulaValue(),n.getRowIndex(),n.getColIndex()):this.parentObject.setValueRowCol(this.getSheetId(m),y.getFormulaValue(),n.getRowIndex(),n.getColIndex(),y.getFormulaText(),u))}else this.getFormulaInfoTable().has(N)&&(this.getFormulaInfoTable().delete(N),this.getDependentFormulaCells().has(N)&&this.clearFormulaDependentCells(N));d&&c&&this.getDependentCells().has(N)&&("Automatic"===this.parentObject.calculationMode||!this.parentObject.isEdit||g)&&this.getDependentCells().get(N).toString()!==N&&this.refreshDependentCells(N,void 0,void 0,l,h,p,g,f)},n.prototype.setValueRowCol=function(r,t,e,n){},n.prototype.getSortedSheetNames=function(){var r=this.getSheetFamilyItem(this.grid);if(null!=r&&null!=r.sheetNameToToken){if(null!=this.sortedSheetNames)return this.sortedSheetNames;var t=[];r.sheetNameToToken.forEach(function(r,e){t.push(e)}),t.sort(function(r,t){return t.length-r.length}),this.sortedSheetNames=t}return this.sortedSheetNames},n.prototype.getErrorLine=function(r){var t=r.stack?r.stack.split("\n")[1].split(":"):null;return t?t[t.length-2]:null},n.prototype.createSheetFamilyID=function(){return this.sheetFamilyID===Number.MAX_SAFE_INTEGER&&(this.sheetFamilyID=Number.MIN_SAFE_INTEGER),this.sheetFamilyID++},n.prototype.computeMinMax=function(e,n){var i,o,s=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(s=!0,e.pop()),t.isNullOrUndefined(e)||0===e.length)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];i="max"===n?this.minValue:this.maxValue;for(var a=0,u=e.length;a<u;a++)""===e[a].split(this.tic).join("").trim()&&(i=0);var l=e;if(l.length>255)return this.getErrorStrings()[r.CommonErrors.Value];for(var h=0;h<l.length;h++)if(l[h].indexOf(":")>-1&&this.isCellReference(l[h])){for(var p=this.getCellCollection(l[h]),g=0;g<p.length;g++)if(o=s?this.getValueFromArg(p[g],null,null,!0):this.getValueFromArg(p[g]),!s||!o.includes("SUBTOTAL(")){m=this.parseFloat(o);""===o||this.isNaN(this.parseFloat(m))||this.getErrorStrings().indexOf(o)>-1||(i="max"===n?Math.max(i,m):Math.min(i,m))}}else{var f=s?this.getValueFromArg(l[h],null,null,!0):this.getValueFromArg(l[h]);if(s&&f.includes("SUBTOTAL("))continue;var m=0,c=this.isCellReference(l[h]),d=""===f&&c,v=this.isNaN(this.parseFloat(f))&&c,N=f===(this.trueValue||this.falseValue)&&c;if(l[h]=l[h].startsWith("n")?l[h].slice(1):l[h],this.getErrorStrings().indexOf(f)>-1)return f;if(f===this.trueValue&&l[h]===this.trueValue)f="1";else if(f===this.falseValue&&l[h]===this.falseValue)f="0";else if(d||v||N)continue;if(f.indexOf('"')>-1&&(f=f.split(this.tic).join("")),this.isNaN(this.parseFloat(f)))return this.getErrorStrings()[r.CommonErrors.Value];m=this.parseFloat(f),i="max"===n?Math.max(i,m):Math.min(i,m)}return i!==this.minValue&&i!==this.maxValue||(i=0),i.toString()},n.prototype.calculateAvg=function(e,n){for(var i,o,s=e,a=[],u=0,l=0,h=0;h<s.length;h++)if(this.isCellReference(s[h]))if(s[h].indexOf(":")>-1){a=this.getCellCollection(s[h]);for(var p=0;p<a.length;p++)if(i=n?this.getValueFromArg(a[p],null,null,!0):this.getValueFromArg(a[p]),!n||!i.includes("SUBTOTAL(")){if(this.getErrorStrings().indexOf(i)>-1)return i;t.isNullOrUndefined(i)||isNaN(this.parseFloat(i))||""===i||(u+=this.parseFloat(i),l+=1)}}else{if(i=n?this.getValueFromArg(s[h],null,null,!0):this.getValueFromArg(s[h]),n&&i.includes("SUBTOTAL("))continue;if(this.getErrorStrings().indexOf(i)>-1)return i;if(t.isNullOrUndefined(i)||isNaN(this.parseFloat(i))||""===i)continue;u+=this.parseFloat(i),l+=1}else{if(s[h].indexOf(this.tic)>-1&&(isNaN(this.parseFloat(s[h].split(this.tic).join("")))||""===s[h].split(this.tic).join("").trim()))return this.getErrorStrings()[r.CommonErrors.Value];if(0!==s[h].length&&e[h]!==this.falseValue||(s[h]="0"),e[h]===this.trueValue&&(s[h]="1"),o=this.getValueFromArg(s[h].split(this.tic).join("")),this.getErrorStrings().indexOf(o)>-1)return o;u+=this.parseFloat(o),l+=1}return 0===l?this.getErrorStrings()[r.CommonErrors.DivZero]:(u/l).toString()},n.prototype.registerGridAsSheet=function(r,e,n){t.isNullOrUndefined(this.modelToSheetID)&&(this.modelToSheetID=new Map),t.isNullOrUndefined(this.modelToSheetID.get(e))&&this.modelToSheetID.set(e,n);var i=this.getSheetFamilyItem(e);i.isSheetMember=!0;var o=r.toUpperCase();if(0===i.parentObjectToToken.size&&(i.parentObjectToToken=new Map),0===i.sheetNameToParentObject.size&&(i.sheetNameToParentObject=new Map),0===i.sheetNameToToken.size&&(i.sheetNameToToken=new Map),0===i.tokenToParentObject.size&&(i.tokenToParentObject=new Map),t.isUndefined(i.sheetNameToParentObject.get(o))){s=this.sheetToken+this.tokenCount.toString()+this.sheetToken;this.tokenCount++,i.tokenToParentObject.set(s,e),i.parentObjectToToken.set(e,s),i.sheetNameToToken.set(o,s),i.sheetNameToParentObject.set(o,e)}else{var s=i.sheetNameToToken.get(o);i.tokenToParentObject.set(s,e),i.parentObjectToToken.set(e,s)}return this.sortedSheetNames=null,r},n.prototype.unregisterGridAsSheet=function(r,e,n){var i=this,o=[e];n&&(o=[],t.isNullOrUndefined(this.modelToSheetID)||this.modelToSheetID.forEach(function(r,t){o.push(t)})),o.forEach(function(t){var e=i.getSheetFamilyItem(t),o=(n?t:r).toUpperCase();if(null!=e.sheetNameToParentObject&&e.sheetNameToParentObject.has(o)){e.sheetNameToParentObject.delete(o);var s=e.sheetNameToToken.get(o);e.sheetNameToToken.delete(o),e.tokenToParentObject.delete(s),e.parentObjectToToken.delete(t)}i.modelToSheetID&&i.modelToSheetID.has(t)&&i.modelToSheetID.delete(t)}),this.sortedSheetNames=null},n.prototype.computeExpression=function(r,t){var e=this.parser.parseFormula(r);return this.computeFormula(e,t)},n.prototype.isSheetMember=function(){var r=this.getSheetFamilyItem(this.grid);return!t.isNullOrUndefined(r)&&r.isSheetMember},n.prototype.destroy=function(){if(this.resetKeys(),this.dependentCells&&(this.dependentCells.clear(),this.dependentCells=null),this.dependentFormulaCells&&(this.dependentFormulaCells.clear(),this.dependentFormulaCells=null),this.formulaInfoTable&&(this.formulaInfoTable.clear(),this.formulaInfoTable=null),this.namedRanges.clear(),this.randomValues.clear(),this.randCollection=[],this.dependencyCollection=[],this.uniqueRange=[],this.sortRange=[],this.sortedSheetNames=null,this.evaluatingKeys.clear(),this.sheetFamiliesList&&(this.sheetFamiliesList.forEach(function(r){r.sheetDependentFormulaCells&&r.sheetDependentFormulaCells.clear(),r.sheetFormulaInfotable&&r.sheetFormulaInfotable.clear(),r.tokenToParentObject&&r.tokenToParentObject.clear(),r.parentObjectToToken&&r.parentObjectToToken.clear(),r.sheetNameToParentObject&&r.sheetNameToParentObject.clear(),r.sheetNameToToken&&r.sheetNameToToken.clear()}),this.sheetFamiliesList.clear(),this.sheetFamiliesList=null),this.modelToSheetID&&(this.modelToSheetID.clear(),this.modelToSheetID=null),this.defaultFamilyItem=null,this.lFormulas.clear(),this.parser&&this.parser.destroy(),this.parentObject=null,this.grid=null,"function"==typeof this.destroy)try{this.destroy()}catch(r){}},n.prototype.refreshRandValues=function(r){var t,e,n,i,o="";if(this.randomValues.has(r)){this.randomValues.delete(r);var s=this.randCollection.indexOf(r);s>-1&&this.randCollection.splice(s,1),0!==this.randomValues.size||this.randCollection.length||(this.randomValues.clear(),this.randCollection=[])}for(var a=0;a<this.randomValues.size;a++)t=this.rowIndex(this.randCollection[a]),e=this.colIndex(this.randCollection[a]),o=(parseFloat(this.getSheetToken(this.randCollection[a]).split(this.sheetToken).join(""))+1).toString(),i=this.getSheetFamilyItem(o),this.grid=i.sheetNameToParentObject.get(o),n=this.randomValues.get(this.randCollection[a]),n=this.computeFormula(n),void 0===this.parentObject.setValueRowCol?this.setValueRowCol(this.getSheetID(this.grid)+1,n,t,e):this.parentObject.setValueRowCol(this.getSheetId(this.grid),n,t,e)},n.prototype.refreshDependentCells=function(r,t,e,n,i,o,s,a){var u,l=this;e||(u=!0,e=[]);var h=this.getSheetFamilyItem(this.grid);try{var p=this.getDependentCells().get(r);if(p&&0!==p.length&&("Automatic"===this.parentObject.calculationMode||s||"calculate"===a)){var g=void 0;for(g=0;g<p.length;g++){var f=p[g];if(!(t&&f.indexOf(t)>-1||f===r||e.indexOf(f)>-1)){var m=this.getSheetToken(f),c=this.parentObject.sheets,d=this.parentObject.activeSheetIndex;if(m.length){this.grid=h.tokenToParentObject.get(m);var v=Number(this.grid),N="";if(!this.isNaN(v)&&c)for(var E=0;E<c.length;E++)c[E].id===v&&(N=c[E].name,d=E);this.actCell=N+"!"+f.split(m)[1]}else this.actCell=f.split(m)[1];try{var S=function(r,t){t&&(l.cell=r,l.parser.isFormulaParsed=!0,t.setFormulaValue(l.calculateFormula(t.getParsedFormula(),!0)))},y=this.rowIndex(f),C=this.colIndex(f),b=this.getFormulaInfoTable().get(f);if(void 0===this.parentObject.setValueRowCol)S(f,b),this.setValueRowCol(this.getSheetID(this.grid)+1,b.getFormulaValue(),y,C);else{var A=void 0;if((R=c&&c[d].rows&&c[d].rows[y-1]&&c[d].rows[y-1].cells&&c[d].rows[y-1].cells[C-1])&&R.formula&&R.formula.toLowerCase().includes("unique")){if(this.uniqueCells&&-1!==this.uniqueCells.indexOf(f))continue;this.uniqueCells||(this.uniqueCells=[]),this.uniqueCells.push(f),S(f,b),A=b.getFormulaValue(),this.uniqueCells.splice(this.uniqueCells.indexOf(f),1),this.uniqueCells.length||(this.uniqueCells=null)}else if(R&&R.formula&&R.formula.toLowerCase().includes("sort")){if(this.sortCells&&-1!==this.sortCells.indexOf(f))continue;this.sortCells||(this.sortCells=[]),this.sortCells.push(f),S(f,b),A=b.getFormulaValue(),this.sortCells.splice(this.sortCells.indexOf(f),1),this.sortCells.length||(this.sortCells=null)}else-1===e.indexOf(f)&&e.push(f),A=null;this.parentObject.setValueRowCol(this.getSheetId(this.grid),A,y,C,b.getFormulaText())}this.refreshDependentCells(f,null,e,null,i)}catch(r){continue}}}}if(u){if(!i&&o&&4===o.length){for(var m=this.getSheetToken(r),O=[],F=o[0],x=o[2];F<=x;F++)for(var V=o[1],I=o[3];V<=I&&(F!==x||V!==I);V++){var R=m+B(F,V);this.refreshDependentCells(R,null,e,null,i),O.push(R)}var T=new Set(O);e&&(e=e.filter(function(r){return!T.has(r)}))}var M=this.parentObject.sheets;M||(e=[]),e.forEach(function(r){for(var t,e=l.getSheetId(h.tokenToParentObject.get(l.getSheetToken(r))),i=0;i<M.length;i++)if(M[i].id===e){t=i;break}var o=l.rowIndex(r)-1,s=l.colIndex(r)-1,u=M[t].rows[o]&&M[t].rows[o].cells[s];u&&l.parentObject.notify("calculateFormula",{cell:u,rowIdx:o,colIdx:s,sheetIndex:t,isDependentRefresh:!0,isRandomFormula:n,action:a})})}}finally{this.getDependentCells().has(r)&&(this.grid=h.tokenToParentObject.get(this.getSheetToken(r)))}},ne([t.Event()],n.prototype,"onFailure",void 0),n=ne([t.NotifyPropertyChanges],n)}(t.Base),oe=function(){function r(r,t){this.formulaCorrection=!1,this.message=r,this.formulaCorrection=t}return r}(),se=function(){function r(){this.calcID=Number.MIN_VALUE+1,this.calcID1=Number.MIN_VALUE+1}return r.prototype.getFormulaText=function(){return this.formulaText},r.prototype.setFormulaText=function(r){this.formulaText=r},r.prototype.getFormulaValue=function(){return this.formulaValue},r.prototype.setFormulaValue=function(r){this.formulaValue=r},r.prototype.getParsedFormula=function(){return this.parsedFormula},r.prototype.setParsedFormula=function(r){this.parsedFormula=r},r}(),ae=function(){function r(){this.isSheetMember=!1,this.parentObjectToToken=new Map,this.sheetDependentFormulaCells=new Map,this.sheetNameToParentObject=new Map,this.sheetNameToToken=new Map,this.tokenToParentObject=new Map,this.sheetFormulaInfotable=new Map}return r}(),ue=function(){function r(r,t,e){return this.row=r,this.col=t,this.value=e,this.getRowIndex=function(){return r},this.setRowIndex=function(t){r=t},this.getColIndex=function(){return t},this.setColIndex=function(r){t=r},this.getFormulaValue=function(){return e},this}return r}();return r.ArrayFormulas=Ct,r.BasicFormulas=re,r.CalcSheetFamilyItem=ae,r.Calculate=ie,r.CalculateCommon=$,r.ComplexNumbersFormulas=it,r.DatabaseFormulas=zt,r.DateTimeExtraFormulas=ut,r.DateTimeFormulas=st,r.DateTimeIntlFormulas=jt,r.EngineeringBaseFormulas=Nr,r.EngineeringBesselFormulas=Ar,r.EngineeringConvertFormulas=Cr,r.EngineeringMiscFormulas=Sr,r.FinancialAmortizationEcmaFormulas=Gt,r.FinancialAnnuityFormulas=Fr,r.FinancialBondHelpers=Bt,r.FinancialCashflowFormulas=Mr,r.FinancialCouponsFormulas=Yt,r.FinancialDepreciationFormulas=Vr,r.FinancialRatesFormulas=Rr,r.FinancialSecuritiesFormulas=Ur,r.FormulaError=oe,r.FormulaInfo=se,r.FormulaModuleBase=Q,r.InformationAdvancedFormulas=Ut,r.InformationEcmaFormulas=Pt,r.InformationExtraFormulas=Mt,r.InformationFormulas=Rt,r.LogicalExtraFormulas=gt,r.LogicalFormulas=ht,r.LookupArrayFormulas=St,r.LookupFormulas=mt,r.LookupRefExtraFormulas=Nt,r.LookupRefFormulas=dt,r.MathAggregateFormulas=rr,r.MathCeilingEcmaFormulas=kt,r.MathCombinatoricsFormulas=hr,r.MathMiscFormulas=ir,r.MathNumberFormulas=gr,r.MathRoundingFormulas=er,r.MathTrigFormulas=sr,r.MathTrigHyperbolicFormulas=ur,r.MatrixFormulaBase=mr,r.MatrixFormulas=dr,r.Parser=te,r.RegressionEcmaFormulas=Jt,r.StatisticalAdvancedFormulas=kr,r.StatisticalCorrelationFormulas=Hr,r.StatisticalDispersionFormulas=Pr,r.StatisticalDistributionExtendedFormulas=et,r.StatisticalDistributionFormulas=$r,r.StatisticalEcmaFormulas=Kt,r.StatisticalExtendedFormulas=rt,r.StatisticalFormulas=jr,r.StatisticalIfsFormulas=Qr,r.StatisticalMomentsFormulas=Xr,r.StatisticalPercentileFormulas=Zr,r.StatisticalSampleBase=qr,r.TextAdvancedFormulas=Vt,r.TextEcmaFormulas=qt,r.TextExtraFormulas=Ft,r.TextFormulas=At,r.ValueChangedArgs=ue,r.besselI=V,r.besselJ=I,r.besselK=R,r.besselY=D,r.betaDist=k,r.betaInv=_,r.binomialCoeff=E,r.calculateDefaultLocale=z,r.chiSquareCDF=b,r.chiSquareInv=A,r.erf=g,r.erfc=f,r.fCDF=O,r.fInv=x,r.factorial=N,r.formatComplex=v,r.gamma=y,r.getAlphalabel=K,r.getSkeletonVal=n,r.isExternalFileLink=i,r.isUndefined=e,r.logGamma=S,r.logNormCDF=U,r.logNormInv=w,r.lowerRegularizedGamma=C,r.normCDF=m,r.normInv=c,r.parseComplexText=d,r.tCDF=j,r.tInv=L,r}({},ej.base),this.ejs=ej;
10
+ this.ej=this.ej||{},this.ej.calculate=function(r,t){"use strict";function e(r){return void 0===r}function n(r){switch(r){case"dd-MMM-yyyy":case"dd MMM yyyy":r="medium";break;case"MMM yyyy":r="yMMM";break;case"MM/dd/yyyy":case"dd/MM/yyyy":case"dd/MM/yy":r="short";break;case"dddd MMMM dd yyyy":case"dd MMMM yyyy":r="long";break;case"d MMMM yyyy":r="yMMMd";break;case"yyyy":r="y";break;case"h:mm":r="Hm";break;case"h:mm tt":r="hm";break;case"h":r="H";break;case"h tt":r="h";break;case"h:mm:ss tt":r="hms";break;case"h:mm:ss":r="Hms";break;case"d":r="d";break;case"d dddd":r="Ed";break;case"M":r="M";break;case"Md":r="Md";break;case"MMM":r="MMM";break;case"ddd MMM d":r="MMMEd";break;case"MMM d":r="MMMd";break;case"M/yyyy":r="yM";break;case"ddd":r="E";break;default:r=""}return r}function i(t){var e=!1;for(var n in r.ExcelFileFormats)if(t.indexOf("."+n+"]")>-1){e=!0;break}return e}function o(r){return"[object Date]"===Object.prototype.toString.call(r)&&!isNaN(r.valueOf())}function s(r){return r-parseFloat(r)>=0}function a(r,t,e){var n=new Date("01/01/1900"),i=o(r)?r:new Date(r),s=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),a=(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())-s)/864e5;return(t?a:parseInt(a.toString(),10))+(e?0:a>60?2:1)}function u(r){return r.charCodeAt(0)>=65&&r.charCodeAt(0)<=90||r.charCodeAt(0)>=97&&r.charCodeAt(0)<=122}function l(r){var t=0,e=0;if(r=r.toUpperCase(),t<r.length&&"!"===r[t]){for(t++;t<r.length&&"!"!==r[t];)t++;t++}for(;t<r.length&&u(r[t]);)e=26*e+r[t].charCodeAt(0)-64,t++;return 0===e?-1:e}function h(r){for(var t=r,e=0,n=t.length,i=0;i<n;i++)u(t[i])&&e++;var o=t.substring(0,e),s=o.length;if(s!==n&&s<4&&1!==n&&isNaN(parseInt(t,10))){var a=l(o);if(a<1||a>16384)return!1;var h=t.substring(e,n);if(h.length>0){for(var p=!0,g=0;g<h.length;g++){var f=h.charCodeAt(g);if(f<48||f>57){p=!1;break}}if(p){var m=parseFloat(h);if(m>0&&m<1048577)return!0}}}return!1}function p(r){var t=r;if((t=t.split("$").join("")).indexOf(":")>-1){var e=t.split(":");if(h(e[0])&&h(e[1]))return!0}else if(t.indexOf(":")<0&&h(t))return!0;return!1}function g(r){var t=r<0?-1:1,e=Math.abs(r),n=1/(1+.3275911*e);return t*(1-((((1.061405429*n-1.453152027)*n+1.421413741)*n-.284496736)*n+.254829592)*n*Math.exp(-e*e))}function f(r){return 1-g(r)}function m(r,t,e){return void 0===t&&(t=0),void 0===e&&(e=1),e<=0?NaN:.5*(1+g((r-t)/(e*Math.SQRT2)))}function c(r,t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),r<=0||r>=1||e<=0)return NaN;var n,i,o=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411018,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416];return r<.02425?(n=Math.sqrt(-2*Math.log(r)),i=(((((a[0]*n+a[1])*n+a[2])*n+a[3])*n+a[4])*n+a[5])/((((u[0]*n+u[1])*n+u[2])*n+u[3])*n+1)):r<=.97575?(i=(n=r-.5)*n,i=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])*n/(((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+s[4])*i+1)):(n=Math.sqrt(-2*Math.log(1-r)),i=-(((((a[0]*n+a[1])*n+a[2])*n+a[3])*n+a[4])*n+a[5])/((((u[0]*n+u[1])*n+u[2])*n+u[3])*n+1)),t+e*i}function d(r){var t=r.trim();if(""===t)return null;var e=t.match(/^(-?\d+(?:\.\d+)?)([+-]\d+(?:\.\d+)?)[ij]$/i);if(e)return{re:parseFloat(e[1]),im:parseFloat(e[2])};var n=t.match(/^([+-]?\d+(?:\.\d+)?)[ij]$/i);if(n)return{re:0,im:parseFloat(n[1])};var i=t.match(/^(-?\d+(?:\.\d+)?)$/);return i?{re:parseFloat(i[1]),im:0}:null}function v(r,t,e){if(void 0===e&&(e="i"),0===t)return r.toString();if(0===r)return t.toString()+e;var n=t>=0?"+":"-";return r.toString()+n+Math.abs(t).toString()+e}function N(r){if(r<0||r>170)return NaN;for(var t=1,e=2;e<=r;e++)t*=e;return t}function E(r,t){if(t<0||t>r)return 0;t=Math.min(t,r-t);for(var e=1,n=1;n<=t;n++)e=e*(r-t+n)/n;return e}function S(r){if(r<=0)return NaN;var t=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,Number("9.984369578019571e-6"),1.5056327351493116e-7];if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-S(1-r);r-=1;for(var e=t[0],n=1;n<9;n++)e+=t[n]/(r+n);var i=r+7+.5;return.5*Math.log(2*Math.PI)+(r+.5)*Math.log(i)-i+Math.log(e)}function y(r){var t=S(r);return isFinite(t)?Math.exp(t):NaN}function C(r,t){if(t<0||r<=0)return NaN;if(0===t)return 0;if(t>1e6)return 1;for(var e=1/r,n=e,i=1;i<200&&(n*=t/(r+i),e+=n,!(Math.abs(n)<1e-12*Math.abs(e)));i++);return e*Math.exp(-t+r*Math.log(t)-S(r))}function b(r,t){return r<0||t<=0?NaN:C(t/2,r/2)}function A(r,t){if(r<=0||r>=1||t<=0)return NaN;for(var e=0,n=Math.max(100,t+10*Math.sqrt(2*t)),i=0;i<100;i++){var o=(e+n)/2;b(o,t)<r?e=o:n=o}return(e+n)/2}function O(r,t,e){return r<0||t<=0||e<=0?NaN:F(t/2,e/2,t*r/(t*r+e))}function F(r,t,e){if(e<=0)return 0;if(e>=1)return 1;for(var n=S(r)+S(t)-S(r+t),i=Math.exp(r*Math.log(e)+t*Math.log(1-e)-n)/r,o=1,s=1,a=0,u=0;u<=200;u++){var l=2*u,h=u*(t-u)*e/((r+l-1)*(r+l));a=1+h*a,Math.abs(a)<1e-30&&(a=1e-30),s=1+h/s,Math.abs(s)<1e-30&&(s=1e-30),o*=(a=1/a)*s,a=1+(h=-(r+u)*(r+t+u)*e/((r+l)*(r+l+1)))*a,Math.abs(a)<1e-30&&(a=1e-30),s=1+h/s,Math.abs(s)<1e-30&&(s=1e-30);var p=(a=1/a)*s;if(o*=p,Math.abs(p-1)<1e-10)break}return i*(o-1)}function x(r,t,e){if(r<=0||r>=1||t<=0||e<=0)return NaN;for(var n=0,i=1e3;O(i,t,e)<r&&!((i*=2)>1e12););for(var o=0;o<100;o++){var s=(n+i)/2;O(s,t,e)<r?n=s:i=s}return(n+i)/2}function V(r,t){if(t<0)return V(r,-t);for(var e=Math.abs(Math.floor(r)),n=0,i=0;i<100;i++){var o=Math.pow(t/2,2*i+e)/(N(i)*N(i+e));if(n+=o,i>10&&o<1e-15*n)break}return n}function R(r,t){for(var e=Math.abs(Math.floor(r)),n=0,i=0;i<100;i++){var o=(i%2==0?1:-1)*Math.pow(t/2,2*i+e)/(N(i)*N(i+e));if(n+=o,i>10&&Math.abs(o)<1e-15*Math.abs(n))break}return n}function I(r,t){if(t<=0)return NaN;var e=Math.abs(Math.floor(r));return 0===e?Math.PI/2*(V(0,t)-R(0,t)):Math.PI/2*(V(e,t)-R(e,t))}function T(r){for(var t=R(0,r),e=0,n=1;n<100;n++){for(var i=0,o=1;o<=n;o++)i+=1/o;e+=Math.pow(r/2,2*n)/(N(n)*N(n))*i}return 2/Math.PI*(t*(Math.log(r/2)+.5772156649)-e)}function M(r){for(var t=R(1,r),e=0,n=0;n<100;n++)e+=(n%2==0?1:-1)*Math.pow(r/2,2*n+1)/(N(n)*N(n+1)*(2*n+1));return 2/Math.PI*(t*Math.log(r/2)-1/(r/2)+e)}function D(r,t){if(t<=0)return NaN;var e=Math.abs(Math.floor(r));if(0===e)return T(t);var n=T(t),i=M(t);if(1===e)return i;for(var o=1;o<e;o++){var s=2*o/t*i-n;n=i,i=s}return i}function U(r,t,e){return r<=0||e<=0?NaN:m(Math.log(r),t,e)}function w(r,t,e){return Math.exp(c(r,t,e))}function j(r,t){if(t<=0)return NaN;var e=F(t/2,.5,t/(t+r*r));return r>=0?1-.5*e:.5*e}function L(r,t){if(r<=0||r>=1||t<=0)return NaN;for(var e=-100,n=100,i=0;i<100;i++){var o=(e+n)/2;j(o,t)<r?e=o:n=o}return(e+n)/2}function k(r,t,e){return r<0||r>1||t<=0||e<=0?NaN:F(t,e,r)}function P(r,t,e){if(r<=0||r>=1||t<=0||e<=0)return NaN;for(var n=0,i=1,o=0;o<100;o++){var s=(n+i)/2;F(t,e,s)<r?n=s:i=s}return(n+i)/2}function _(r){for(var t=0,e=(r=r.split("").reverse().join("")).length-1;e>=0;e--)t+=(r[e].charCodeAt(0)-64)*Math.pow(26,e);return t-1}function W(r){return r/26>1?W(r%26==0?r/26-1:Math.floor(r/26))+String.fromCharCode(r%26==0?"Z".charCodeAt(0):64+r%26):String.fromCharCode(64+r)}function q(r){return[parseInt(r.match(/\d+/)[0],10)-1,_(r.match(/[A-Z]+/i)[0].toUpperCase())]}function B(r,t){return W(t+1)+(r+1)}function X(r){return B(r[0],r[1])+":"+(t.isNullOrUndefined(r[2])?B(r[0],r[1]):B(r[2],r[3]))}function Y(r,e){var n,i=[];if(r){if(r=-1===(r=r.lastIndexOf("!")>-1?r.substring(r.lastIndexOf("!")+1):r).indexOf(":")?r+":"+r:r,!new RegExp(/^(?=.*[a-zA-Z])(?=.*\d)/g).test(r)){var o=r.split(":"),s=e&&e.rowCount?e.rowCount-1:1,a=e&&e.colCount?W(e.colCount):"A";r=t.isNullOrUndefined(r.match(/[0-9]/))?o[0]+"1:"+o[1]+s:"A"+o[0]+":"+a+o[1]}r.split(":").forEach(function(r){n=q(r),i.push(n[0]),i.push(n[1])})}return i}function H(r){var t="Descending"===r;return function(r,e){if(r===e)return 0;if(null===r||void 0===r)return 1;if(null===e||void 0===e)return-1;var n=0;return"string"==typeof r?n=r.localeCompare(e):r>e?n=1:r<e&&(n=-1),t?-n:n}}function G(r,t){var e=H(t);return r.slice().sort(e)}function Z(r,t){for(var e=t.length,n=0;n<e;n++)if(t[n].sheet.toUpperCase()===r.toUpperCase())return t[n].index;return-1}function K(r){for(var t=[],e=0;r>0&&e<9;){r--;var n="A".charCodeAt(0);t[e]=String.fromCharCode(r%26+n),r=parseInt((r/26).toString(),10),e++}for(var i=[],o=0;o<e;o++)i[e-o-1]=t[o];return i.join("")}!function(r){r[r.NA=0]="NA",r[r.Value=1]="Value",r[r.Ref=2]="Ref",r[r.DivZero=3]="DivZero",r[r.Num=4]="Num",r[r.Name=5]="Name",r[r.Null=6]="Null",r[r.Calc=7]="Calc"}(r.CommonErrors||(r.CommonErrors={})),function(r){r[r.OperatorsCannotStartWithExpression=0]="OperatorsCannotStartWithExpression",r[r.ReservedWordAND=1]="ReservedWordAND",r[r.ReservedWordXOR=2]="ReservedWordXOR",r[r.ReservedWordIf=3]="ReservedWordIf",r[r.NumberContains2DecimalPoints=4]="NumberContains2DecimalPoints",r[r.ReservedWordElse=5]="ReservedWordElse",r[r.ReservedWordNOT=6]="ReservedWordNOT",r[r.InvalidCharInNumber=7]="InvalidCharInNumber",r[r.InvalidCharactersFollowingWithOperator=6]="InvalidCharactersFollowingWithOperator",r[r.MismatchedParentheses=8]="MismatchedParentheses",r[r.UnknownFormulaName=9]="UnknownFormulaName",r[r.RequiresASingleArgument=10]="RequiresASingleArgument",r[r.Requires3Args=11]="Requires3Args",r[r.InvalidMathArgument=12]="InvalidMathArgument",r[r.Requires2Args=13]="Requires2Args",r[r.BadIndex=14]="BadIndex",r[r.TooComplex=15]="TooComplex",r[r.CircularReference=16]="CircularReference",r[r.MissingFormula=17]="MissingFormula",r[r.ImproperFormula=18]="ImproperFormula",r[r.InvalidExpression=19]="InvalidExpression",r[r.CellEmpty=20]="CellEmpty",r[r.BadFormula=21]="BadFormula",r[r.EmptyExpression=22]="EmptyExpression",r[r.VirtualModeRequired=23]="VirtualModeRequired",r[r.MismatchedTics=24]="MismatchedTics",r[r.WrongNumberArguments=25]="WrongNumberArguments",r[r.InvalidArguments=26]="InvalidArguments",r[r.IterationsDoNotConverge=27]="IterationsDoNotConverge",r[r.CalculationOverflow=29]="CalculationOverflow",r[r.AlreadyRegistered=28]="AlreadyRegistered",r[r.MissingSheet=30]="MissingSheet",r[r.CannotParse=31]="CannotParse",r[r.ExpressionCannotEndWithAnOperator=32]="ExpressionCannotEndWithAnOperator",r[r.Spill=33]="Spill",r[r.Div=34]="Div"}(r.FormulasErrorsStrings||(r.FormulasErrorsStrings={})),function(r){r.xlsx="xlsx",r.xlsm="xlsm",r.xlsb="xlsb",r.xltx="xltx",r.xltm="xltm",r.xls="xls",r.xml="xml",r.xlam="xlam",r.xla="xla",r.xlw="xlw",r.xlr="xlr",r.prn="prn",r.txt="txt",r.csv="csv",r.dif="dif",r.slk="slk"}(r.ExcelFileFormats||(r.ExcelFileFormats={}));var $=function(){function r(r){this.parent=r}return r.prototype.getModuleName=function(){return"calc-common"},r}(),z={OperatorsCannotStartWithExpression:"binary operators cannot start an expression",CannotParse:"cannot parse",BadLibrary:"bad library",InvalidCharInFrontOf:"invalid char in front of",NumberContains2DecimalPoints:"number contains 2 decimal points",ExpressionCannotEndWithAnOperator:"expression cannot end with an operator",InvalidCharactersFollowingWithOperator:"invalid characters following an operator",InvalidCharInNumber:"invalid character in number",MismatchedParentheses:"mismatched parentheses",UnknownFormulaName:"unknown formula name",RequiresASingleArgument:"requires a single argument",Requires3Args:"requires 3 arguments",InvalidMathArgument:"invalid Math argument",Requires2Args:"requires 2 arguments",TooComplex:"too complex",MissingFormula:"missing formula",ImproperFormula:"improper formula",InvalidExpression:"invalid expression",CellEmpty:"cell empty",BadFormula:"bad formula",EmptyExpression:"empty expression",MismatchedTics:"mismatched string quotes",WrongNumberArguments:"wrong number of arguments",InvalidArguments:"invalid arguments",IterationsDoNotConverge:"iterations do not converge",AlreadyRegistered:"Control is already registered",CalculationOverflow:"Calculation overflow",MissingSheet:"Missing sheet",CannotParseUnderscore:"cannot_parse",ExpressionCannotEndWithAnOperatorUnderscore:"expression_cannot_end_with_an_operator",CategoryAll:"All"},Q=function(){function e(r){this.owner=r,this.parent=r.parent}return e.prototype.parseDouble=function(r){var t=this.parent.parseFloat(r.toString());return isNaN(t)?NaN:t},e.prototype.getSheetReference=function(r){return 0===r.indexOf(this.parent.sheetToken)&&r.lastIndexOf(this.parent.sheetToken)>r.indexOf(this.parent.sheetToken)?r.substring(0,r.lastIndexOf(this.parent.sheetToken)+1):""},e.prototype.calculateIFS=function(e,n){var i=this;if(t.isNullOrUndefined(e)||""===e[0]||e.length<2||e.length>127||e.length%2==0)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(3===e.length&&'""'!==e[2]&&e[2].includes(this.parent.tic+this.parent.tic)){var o,s="",a=this.parent.getParseArgumentSeparator();return e[2].split(this.parent.tic+this.parent.tic).forEach(function(r){(r=r.trim().split(i.parent.tic).join(""))&&(o=i.parent.computeIfsFormulas([e[0],e[1],r],i.parent.falseValue,n).toString(),s+=(s?a:"")+o)}),s}return this.parent.computeIfsFormulas(e,this.parent.falseValue,n)},e.prototype.resolveTextArg=function(r){if(t.isNullOrUndefined(r))return"";var e=this.parent.getValueFromArg(r);return this.parent.getErrorStrings().indexOf(e)>-1?e:(this.parent.isCellReference(r)||(e=this.parent.removeTics(e)),e)},e.prototype.resolveNumberArg=function(t){var e=this.parent.getErrorStrings(),n=this.parent.getValueFromArg(t);if(e.indexOf(n)>-1)return n;if(""===n)return 0;var i=n.toUpperCase();if(i===this.parent.trueValue)return 1;if(i===this.parent.falseValue)return 0;if(this.parent.isCellReference(t)||(n=this.parent.removeTics(n)),n.indexOf("%")>-1){var o=n.replace("%","");if(this.parent.isNumber(o))return this.parent.parseFloat(o)/100}var s=this.parent.parseFloat(n);return isNaN(s)?e[r.CommonErrors.Value]:s},e}(),J=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),rr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SUM",category:"Math & Trig",description:"Sums individual values, cell references or ranges."},{formulaName:"SUMIF",category:"Math & Trig",description:"It will sum up cells that meet the given criteria."},{formulaName:"SUMIFS",category:"Math & Trig",description:"Sums the cells specified by a given set of conditionsor criteria."},{formulaName:"SUMPRODUCT",category:"Math & Trig",description:"Returns sum of the product of given ranges of arrays."},{formulaName:"PRODUCT",category:"Math & Trig",description:"Multiplies all the numbers given as arguments and returns the product."}],t}return J(n,e),n.prototype.ComputeSUM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o,s,a=0,u=0;if(!t.isNullOrUndefined(e))for(var l=e,h=function(r){r.toString().indexOf(".")>-1&&(u=Math.max(u,r.split(".")[1].length))},p=0;p<l.length;p++){var g=l[p].toString();if(g.indexOf(":")>-1&&this.parent.isCellReference(g)){for(var f=this.parent.getCellCollection(g.split(this.parent.tic).join("")),m=0;m<f.length;m++)if(o=i?this.parent.getValueFromArg(f[m],null,null,!0):this.parent.getValueFromArg(f[m]),!i||!o.includes("SUBTOTAL(")){if(this.parent.getErrorStrings().indexOf(o)>-1)return o;t.isNullOrUndefined(o[0])||isNaN(this.parent.parseFloat(o))||(h(o),a+=this.parent.parseFloat(o))}}else{if(l[p].indexOf(this.parent.tic)>-1&&(isNaN(this.parent.parseFloat(l[p].split(this.parent.tic).join("")))||""===l[p].split(this.parent.tic).join("").trim()))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(l[p].split(this.parent.tic).join("")===this.parent.trueValue&&(l[p]="1"),l[p].split(this.parent.tic).join("")===this.parent.falseValue&&(l[p]="0"),s=i?this.parent.getValueFromArg(l[p].split(this.parent.tic).join(""),null,null,!0):this.parent.getValueFromArg(l[p].split(this.parent.tic).join("")),i&&s.includes("SUBTOTAL("))continue;if(this.parent.getErrorStrings().indexOf(s)>-1)return s;if(t.isNullOrUndefined(s)||isNaN(this.parent.parseFloat(s)))continue;s.length>0&&(h(s),a+=this.parent.parseFloat(s+""))}}return a.toString().indexOf(".")>-1?a.toFixed(u):a},n.prototype.ComputeSUMIF=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t;if(n[0].indexOf(":")<0&&!this.parent.isCellReference(n[0])||n[2]&&n[2].indexOf(":")<0&&!this.parent.isCellReference(n[2]))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];if(n.length>3||n.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.computeSumIfAndAvgIf(t,!1);return"string"==typeof i&&(this.parent.formulaErrorStrings.indexOf(i)||this.parent.getErrorStrings().indexOf(i))?i:i[0]},n.prototype.ComputeSUMIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.calculateIFS(r)},n.prototype.ComputeSUMPRODUCT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o;if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var s,a=0,u=0,l=null,h=e,p=[],g=0;g<h.length;g++){var f=this.parent.getCellCollection(h[g]);if("#REF!"===f[0])return this.parent.getErrorStrings()[r.CommonErrors.Name];p.push(f.length)}for(var m=0;m<p.length;m++)if(p[m]&&p[m+1]&&p[m]!==p[m+1])return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var c=0;c<h.length;++c){var d=h[c];if(d.startsWith(this.parent.tic)||!this.parent.isCellReference(d)){var v=this.parent.getValueFromArg(d);return s=v.indexOf('"'),this.parent.getErrorStrings().indexOf(v)>-1?v:s>-1?0:this.parent.getErrorStrings()[r.CommonErrors.Value]}var g=d.indexOf(":"),N=this.parent.rowIndex(d.substr(0,g)),E=this.parent.rowIndex(d.substr(g+1));if(!(-1!==N||-1===E)==(-1===N||-1!==E))return this.parent.getErrorStrings()[r.CommonErrors.Name];N>E&&(N=(i=[E,N])[0],E=i[1]);var S=this.parent.colIndex(d.substr(0,g)),y=this.parent.colIndex(d.substr(g+1));if(S>y&&(S=(o=[y,S])[0],y=o[1]),null===l)for(u=(E-N+1)*(y-S+1),l=[],g=0;g<u;++g)l[g]=1;g=0;for(var C=N;C<=E;++C)for(var b=S;b<=y;++b){var A=this.getSheetReference(d)+this.parent.convertAlpha(b)+C,O=this.parent.getValueFromArg(A);if(this.parent.getErrorStrings().indexOf(O)>-1)return O;if(isNaN(this.parent.parseFloat(O)))l[g]=0;else{if(isNaN(l[g]))return this.parent.getErrorStrings()[r.CommonErrors.Name];l[g]=l[g]*this.parent.parseFloat(O)}g++}}for(g=0;g<u;++g)a+=l[g];return a},n.prototype.ComputePRODUCT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o,a,u,l=1,h=!0;if(!t.isNullOrUndefined(e))for(var p=e,g=0;g<p.length;g++){var f=p[g];if(f.indexOf(":")>-1&&this.parent.isCellReference(f)){for(var m=this.parent.getCellCollection(f),c=0;c<m.length;c++)if(o=i?this.parent.getValueFromArg(m[c],null,null,!0):this.parent.getValueFromArg(m[c]),(!i||!o.includes("SUBTOTAL("))&&s(o)){if(this.parent.getErrorStrings().indexOf(o)>-1)return o;u=this.parent.parseFloat(o),isNaN(u)||o.length>0&&(l*=u,h=!1)}}else if(-1===f.indexOf(":")&&this.parent.isCellReference(f)){if(a=i?this.parent.getValueFromArg(p[g],null,null,!0):this.parent.getValueFromArg(p[g]),i&&a.includes("SUBTOTAL("))continue;if(!s(a))continue;if(this.parent.getErrorStrings().indexOf(a)>-1)return a}else{if((a=p[g]).indexOf(this.parent.tic)>-1&&""===a.split(this.parent.tic).join("").trim()||p[g].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(a.split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(a=this.parent.getValueFromArg(p[g].split(this.parent.tic).join("")),a=a===this.parent.trueValue?"1":a===this.parent.falseValue?"0":a.split(this.parent.tic).join(""),this.parent.getErrorStrings().indexOf(a)>-1)return a}u=this.parent.parseFloat(a),isNaN(u)||a.length>0&&(l*=u,h=!1)}return h?"0":l.toString()},n}(Q),tr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),er=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ROUND",category:"Math & Trig",description:"Rounds a number to a specified number of digits."},{formulaName:"ROUNDUP",category:"Math & Trig",description:"Rounds a number away from zero."},{formulaName:"ROUNDDOWN",category:"Math & Trig",description:"Rounds a number down, toward zero."},{formulaName:"FLOOR",category:"Math & Trig",description:"Returns the round a number down to the nearest integer."},{formulaName:"CEILING",category:"Math & Trig",description:"Returns a number rounded up to a multiple of another number."},{formulaName:"INT",category:"Math & Trig",description:"Returns a number to the nearest integer."},{formulaName:"TRUNC",category:"Math & Trig",description:"Returns the truncated value of a number to a specified number of decimal places."},{formulaName:"ODD",category:"Math & Trig",description:"Rounds a positive number up and negative number down to the nearest odd integer."},{formulaName:"EVEN",category:"Math & Trig",description:"Rounds a positive number up and negative number down to the nearest even integer."}],t}return tr(n,e),n.prototype.ComputeROUND=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!t.length||1===t.length||t.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var n=t;if(1===t.length){var i="TRUE"===n[0].split(this.parent.tic).join("")?"1":"FALSE"===n[0].split(this.parent.tic).join("")?"0":n[0];return isNaN(this.parent.parseFloat(i))?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:Math.round(this.parent.parseFloat(i)).toString()}var o=this.parent.getValueFromArg(n[0]);if(this.parent.getErrorStrings().indexOf(o)>-1)return o;var s=this.parent.getValueFromArg(n[1]);if(this.parent.getErrorStrings().indexOf(s)>-1)return s;o="TRUE"===o?"1":"FALSE"===o?"0":o,s="TRUE"===s?"1":"FALSE"===s?"0":s,o=o.split(this.parent.tic).join(""),s=s.split(this.parent.tic).join("");var a=isNaN(Number(o))||""===o.trim(),u=isNaN(Number(s))||""===s.trim();if((n[0].indexOf('"')>-1||this.parent.isCellReference(n[0]))&&a||(n[1].indexOf('"')>-1||this.parent.isCellReference(n[1]))&&u)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(""===o&&""===s||""===o)return 0;var l,h=this.parent.parseFloat(o),p=this.parent.parseFloat(s);if(!isNaN(p)&&!isNaN(h)&&p>0)l=this.parent.parseFloat(this.preciseRound(h,p,"ROUND"));else{var g=Math.pow(10,-p);l=Math.round(h/g)*g}return l.toString()},n.prototype.preciseRound=function(r,t,e){var n=Math.pow(10,t),i=Math.abs(r)*n;return((r>=0?1:-1)*(("ROUND"===e?Math.round(i):"ROUNDDOWN"===e?Math.floor(i):Math.ceil(i))/n)).toFixed(t)},n.prototype.ComputeROUNDUP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i,o,s,a=t.length;if(1===a&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==a)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(this.parent.isCellReference(t[0]))i=this.parent.getValueFromArg(t[0])||"0";else{if(t[0].indexOf(this.parent.tic)>-1&&(t[0].split(this.parent.tic).join("")===this.parent.trueValue||t[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(t[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.isCellReference(t[1]))o=this.parent.getValueFromArg(t[1])||"0";else{if(t[1].indexOf(this.parent.tic)>-1&&(t[1].split(this.parent.tic).join("")===this.parent.trueValue||t[1].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(t[1]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(o)>-1)return o;i="TRUE"===i.toUpperCase()?"1":"FALSE"===i?"0":i,o="TRUE"===o.toUpperCase()?"1":"FALSE"===o?"0":o;var u=isNaN(Number(i))||""===i.trim(),l=isNaN(Number(o))||""===o.trim();if((t[0].indexOf('"')>-1||this.parent.isCellReference(t[0]))&&u||(t[1].indexOf('"')>-1||this.parent.isCellReference(t[1]))&&l)return this.parent.getErrorStrings()[r.CommonErrors.Value];var h=Math.ceil(this.parent.parseFloat(o));if(s=this.parent.parseFloat(i),h>0){var p=i.split("."),g=2===p.length?p[1].length>=h?h:p[1].length:0;n=(s=this.parent.parseFloat(this.preciseRound(s,g,"ROUNDUP"))).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:this.parent.getErrorStrings()[r.CommonErrors.Name])}else s>0?s=s/Math.pow(10,-h)+.49999:s<0&&(s=s/Math.pow(10,-h)-.49999),n=(s=s>0&&h<-9?1*Math.pow(10,-h):this.parent.parseFloat(s.toFixed(0))*Math.pow(10,-h)).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:n=this.parent.getErrorStrings()[r.CommonErrors.Name]);return n},n.prototype.ComputeROUNDDOWN=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i,o,s,a=t.length;if(1===a&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==a)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(this.parent.isCellReference(t[0]))i=this.parent.getValueFromArg(t[0])||"0";else{if(t[0].indexOf(this.parent.tic)>-1&&(t[0].split(this.parent.tic).join("")===this.parent.trueValue||t[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(t[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.isCellReference(t[1]))o=this.parent.getValueFromArg(t[1])||"0";else{if(t[1].indexOf(this.parent.tic)>-1&&(t[1].split(this.parent.tic).join("")===this.parent.trueValue||t[1].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(t[1]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(o)>-1)return o;i="TRUE"===i.toUpperCase()?"1":"FALSE"===i?"0":i,o="TRUE"===o.toUpperCase()?"1":"FALSE"===o?"0":o;var u=isNaN(Number(i))||""===i.trim(),l=isNaN(Number(o))||""===o.trim();if((t[0].indexOf('"')>-1||this.parent.isCellReference(t[0]))&&u||(t[1].indexOf('"')>-1||this.parent.isCellReference(t[1]))&&l)return this.parent.getErrorStrings()[r.CommonErrors.Value];var h=Math.ceil(this.parent.parseFloat(o));if(s=this.parent.parseFloat(i),h>0){var p=i.indexOf("."),g=0;-1!==p&&(g=(g=i.length-p-1)>=h?h:g),n=(s=this.parent.parseFloat(this.preciseRound(s,g,"ROUNDDOWN"))).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:this.parent.getErrorStrings()[r.CommonErrors.Name])}else s>0?s=s/Math.pow(10,-h)-.49999:s<0&&(s=s/Math.pow(10,-h)+.49999),n=(s=s>0&&h<-9?1*Math.pow(10,-h):this.parent.parseFloat(s.toFixed(0))*Math.pow(10,-h)).toString(),isNaN(s)&&(n=h.toString().indexOf('"')>-1?this.parent.getErrorStrings()[r.CommonErrors.Value]:n=this.parent.getErrorStrings()[r.CommonErrors.Name]);return n},n.prototype.ComputeFLOOR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i,o=e;if(2!==o.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===o[0]&&""===o[1]||""===o[0]&&!o[1].includes('"'))return 0;""!==o[1]||o[0].includes('"')||(o[1]="0");for(var s=0;s<o.length;s++){var a=o[s].split(this.parent.tic).join("").trim();if(""===a||o[s].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(a)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(p(o[s])){if(i=this.parent.getValueFromArg(o[s])||"0",(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(i=this.parent.getValueFromArg(o[s].split(this.parent.tic).join("")),(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value];o[s]=i}var u=this.parent.parseFloat(o[0]),l=this.parent.parseFloat(o[1]);return u>0&&l<0?this.parent.getErrorStrings()[r.CommonErrors.Num]:(u>0||u<0)&&0===l?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:isNaN(u)?this.parent.getErrorStrings()[r.CommonErrors.Name]:0===u&&0===l?0:Math.floor(u/l)*l},n.prototype.ComputeCEILING=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i,o=e;if(2!==o.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===o[0]&&""===o[1]||""===o[0]&&!o[1].includes('"'))return 0;""!==o[1]||o[0].includes('"')||(o[1]="0");for(var s=0;s<o.length;s++){var a=o[s].split(this.parent.tic).join("").trim();if(""===a||o[s].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(a)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(p(o[s])){if(i=this.parent.getValueFromArg(o[s])||"0",(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(i=this.parent.getValueFromArg(o[s].split(this.parent.tic).join("")),(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value];o[s]=i}var u=this.parent.parseFloat(o[0]),l=this.parent.parseFloat(o[1]);return u>0&&l<0?this.parent.getErrorStrings()[r.CommonErrors.Num]:isNaN(u)?this.parent.getErrorStrings()[r.CommonErrors.Name]:(u>0||0===u)&&0===l?0:Math.ceil(u/l)*l},n.prototype.ComputeINT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=this.parent.getErrorStrings();return""===t[0]&&1===t.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:t.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(n=this.parent.getValueFromArg(t[0]),i.indexOf(n)>-1?n:(n.toUpperCase()===this.parent.trueValue?n="1":n.toUpperCase()===this.parent.falseValue&&(n="0"),this.parent.isCellReference(t[0])||(-1===t[0].indexOf(this.parent.tic+this.parent.tic)&&(n=n.split(this.parent.tic).join("")),""!==n.trim())?(n.indexOf("%")>-1&&(n=(.01*Number(n.split("%")[0])).toString()),isNaN(this.parent.parseFloat(n))?i[r.CommonErrors.Value]:(n=this.parent.parseFloat(n),n=Math.floor(n))):i[r.CommonErrors.Value]))},n.prototype.ComputeTRUNC=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s=0,a=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||""===n[0]&&1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(0===n.length||n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var u=function(t){var n=e.parent.getValueFromArg(t);if(a.indexOf(n)>-1)return n;if(n===e.parent.trueValue)n="1";else if(n===e.parent.falseValue)n="0";else if(!e.parent.isCellReference(t)){if(t.indexOf(e.parent.tic)>-1&&e.parent.removeTics(t).match(/^(\d*\.\d+|\d+)\s*[*]\s*(\d*\.\d+|\d+)$/))n=e.parent.getValueFromArg(e.parent.removeTics(t));else if(n.indexOf(e.parent.tic)>-1){if(""===(n=e.parent.removeTics(n)).trim())return a[r.CommonErrors.Value];if(n.indexOf(":")>-1){var i=n.split(":");if(!(i.length<=3))return a[r.CommonErrors.Value];if(!e.parent.isNumber(i[0])||!e.parent.isNumber(i[1]))return a[r.CommonErrors.Value];var o=Number(i[0])+Number(Number(i[1])/60);if(3===i.length){if(!e.parent.isNumber(i[2]))return a[r.CommonErrors.Value];o+=Number(Number(i[2])/3600)}n=(o/24).toString()}}2===n.split("%").length&&e.parent.isNumber(n.split("%")[0])&&(n=(.01*Number(n.split("%")[0])).toString())}return n};if(!t.isNullOrUndefined(n[0])){if(o=u(n[0]),a.indexOf(o)>-1)return o;if(o=this.parent.parseFloat(o),isNaN(o))return a[r.CommonErrors.Value]}if(!t.isNullOrUndefined(n[1])){if(s=u(n[1]),a.indexOf(s)>-1)return s;if(s=this.parent.parseFloat(s),isNaN(s))return a[r.CommonErrors.Value]}return s=Math.pow(10,Math.floor(s)),o=Number(o),((o<0?-1:1)*Math.floor(s*Math.abs(o))/s).toString()},n.prototype.ComputeODD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=e[0].split(this.parent.tic).join("").trim();if(""===i||e[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(i)))return this.parent.getErrorStrings()[r.CommonErrors.Value];var o;if(p(e[0])){if(o=this.parent.getValueFromArg(e[0]),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||o.includes('"')||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if("#NAME?"===(o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Name];if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}var s=Math.ceil(parseInt(o,10)),a=0===s;return s=s%2==0?s>0?s+1:s-1:s,Math.ceil(parseInt(o,10))%2!=0&&(parseInt(o,10)>0&&parseFloat(o)>parseInt(o,10)?s+=2:parseInt(o,10)<0&&parseFloat(o)<parseInt(o,10)&&(s-=2)),isNaN(s)?this.parent.getErrorStrings()[r.CommonErrors.Name]:a?1:s},n.prototype.ComputeEVEN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=e[0].split(this.parent.tic).join("").trim();if(""===i||e[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(i)))return this.parent.getErrorStrings()[r.CommonErrors.Value];var o;if(p(e[0])){if(o=this.parent.getValueFromArg(e[0]),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||o.includes('"')||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if("#NAME?"===(o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Name];if(o===this.parent.trueValue)o="1";else if(""===o||o===this.parent.falseValue)o="0";else if(o.toUpperCase().match(/[A-Z]/)||!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}var s=Math.ceil(parseInt(o,10));return s=s%2==0?s:s>0?s+1:s-1,Math.ceil(parseInt(o,10))%2==0&&(parseInt(o,10)>0&&parseFloat(o)>parseInt(o,10)?s+=2:parseInt(o,10)<0&&parseFloat(o)<parseInt(o,10)&&(s-=2)),isNaN(s)?this.parent.getErrorStrings()[r.CommonErrors.Name]:s},n}(Q),nr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ir=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ABS",category:"Math & Trig",description:"Returns the absolute value of a number."},{formulaName:"RAND",category:"Math & Trig",description:"Return a random number between 0 and 1."},{formulaName:"RANDBETWEEN",category:"Math & Trig",description:"Returns an integer random number in a specified range."},{formulaName:"RADIANS",category:"Math & Trig",description:"Converts degrees to radians."},{formulaName:"DEGREES",category:"Math & Trig",description:"Converts radians to degrees."},{formulaName:"PI",category:"Math & Trig",description:"Returns the value of pi."},{formulaName:"MOD",category:"Math & Trig",description:"Returns a remainder after a number is divided by divisor."},{formulaName:"FACT",category:"Math & Trig",description:"Returns the factorial of a number."},{formulaName:"DECIMAL",category:"Math & Trig",description:"Converts a text representation of a number in a given base into a decimal number."},{formulaName:"LN",category:"Math & Trig",description:"Returns the natural logarithm of a number."},{formulaName:"LOG",category:"Math & Trig",description:"Returns the logarithm of a number to the base that you specify."},{formulaName:"POWER",category:"Math & Trig",description:"Returns the result of a number raised to power."},{formulaName:"SQRT",category:"Math & Trig",description:"Returns the square root of a positive number."},{formulaName:"EXP",category:"Math & Trig",description:"Returns e raised to the power of the given number."}],t}return nr(n,e),n.prototype.ComputeABS=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=t,o="";if(0===t.length||t.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var s=i[0].split(this.parent.tic).join("").trim();if(""===s||i[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(s)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(i[0])){if(o=this.parent.getValueFromArg(i[0]),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o===this.parent.trueValue&&(o="1"),""!==o&&o!==this.parent.falseValue||(o="0"),n=this.parent.parseFloat(o),isNaN(n)&&!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if((o=this.parent.getValueFromArg(i[0]).split(this.parent.tic).join())===this.parent.trueValue&&(o="1"),o===this.parent.falseValue&&(o="0"),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(n=this.parent.parseFloat(o),isNaN(n)&&!this.parent.isNumber(o))return this.parent.getErrorStrings()[r.CommonErrors.Value]}return Math.abs(n)},n.prototype.ComputeRAND=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===t.length&&""===t[0]&&(t.length=0),t.length>0?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:Math.random().toString()},n.prototype.ComputeRANDBETWEEN=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o;if(1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.parent.getErrorStrings(),a=function(e){var n;if(n=t.parent.getValueFromArg(e),s.indexOf(n)>-1)return n;if(t.parent.isCellReference(e)){if(""===n)n="0";else if(e.indexOf(":")>-1||n.match(/^(\d*\.\d+|\d+)\s*[+\-*/]\s*(\d*\.\d+|\d+)$/))return s[r.CommonErrors.Value]}else{if(""===n)return s[r.CommonErrors.NA];if(e.indexOf(t.parent.tic)>-1&&t.parent.removeTics(e).match(/^(\d*\.\d+|\d+)\s*[+*]\s*(\d*\.\d+|\d+)$/))return s[r.CommonErrors.Value];if(n.indexOf(t.parent.tic)>-1&&(n=t.parent.removeTics(n)).indexOf(":")>-1){var i=n.split(":");if(!(i.length<=3))return s[r.CommonErrors.Value];if(!t.parent.isNumber(i[0])||!t.parent.isNumber(i[1]))return s[r.CommonErrors.Value];var o=Number(i[0])+Number(Number(i[1])/60);if(3===i.length){if(!t.parent.isNumber(i[2]))return s[r.CommonErrors.Value];o+=Number(Number(i[2])/3600)}n=(o/24).toString()}2===n.split("%").length&&t.parent.isNumber(n.split("%")[0])&&(n=(.01*Number(n.split("%")[0])).toString())}return n=parseFloat(n),isNaN(n)?s[r.CommonErrors.Value]:n};return o=a(e[1]),s.indexOf(o)>-1?o:(i=a(e[0]),s.indexOf(i)>-1?i:0===i&&0===o?"0":o<i?s[r.CommonErrors.Num]:(i=Math.ceil(i),o=Math.floor(o),Math.floor(Math.random()*(o-i+1)+i)))},n.prototype.ComputeRADIANS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||""===e[0]&&1===e.length||2===e[0].split("!").length&&-1===e[0].indexOf(this.parent.tic)?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:e[0].indexOf(":")>-1||""===e[0].split(this.parent.tic).join("").trim()||"!"===e[0].split(this.parent.tic).join("").trim()||2===e[0].split("!").length?o[r.CommonErrors.Value]:(i=this.parent.getValueFromArg(e[0]).trim(),o.indexOf(i)>-1?i:i.indexOf(this.parent.tic)>-1&&-1===e[0].indexOf(this.parent.tic)||i.split(this.parent.tic).length>3?o[r.CommonErrors.Value]:(i.toUpperCase()===this.parent.trueValue?i="1":i.toUpperCase()===this.parent.falseValue?i="0":2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),i=this.parent.parseFloat(i.split(this.parent.tic).join("")),isNaN(i)?this.parent.isCellReference(e[0])||e[0].indexOf(this.parent.tic)>-1?o[r.CommonErrors.Value]:o[r.CommonErrors.Name]:i=Math.PI*i/180))},n.prototype.ComputeDEGREES=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||""===e[0]&&1===e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]).trim();if(i.indexOf(o)>-1)return o;if(this.parent.isCellReference(e[0])){if(""===o||o.indexOf(":")>-1)return 0;if(o.indexOf(this.parent.tic)>-1||isNaN(Number(o))&&!isNaN(parseInt(o,10)))return i[r.CommonErrors.Value]}else if(o.indexOf('"TRUE"')>-1)return i[r.CommonErrors.Value];if((o=o.split(this.parent.tic).join("")).toUpperCase()===this.parent.trueValue)o="1";else if(o.toUpperCase()===this.parent.falseValue)o="0";else if(o.indexOf("%")>-1)o=(Number(o.split("%")[0])/100).toString();else if(o.toUpperCase().match(/[A-Z]/)||isNaN(parseInt(o,10)))return i[r.CommonErrors.Value];return parseFloat(o)*(180/Math.PI)},n.prototype.ComputePI=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&""!==t[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:Math.PI},n.prototype.ComputeMOD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[1]&&!e[0].includes('"'))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Div];if(""===e[0]&&!e[1].includes('"'))return 0;for(var o=0;o<e.length;o++){var s=e[o].split(this.parent.tic).join("").trim();if(""===s||e[o].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(s)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(p(e[o])){if(i=this.parent.getValueFromArg(e[o])||"0",(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i).toUpperCase().match(/[A-Z]/)||i.includes('"')||!this.parent.isNumber(i))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(i=this.parent.getValueFromArg(e[o].split(this.parent.tic).join("")),i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i,this.parent.getErrorStrings().indexOf(i)>-1)return i;e[o]=i}var a=e[0],u=e[1];if("0"===u||""===u)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Div];if("0"===a||""===a)return 0;var l=((a=parseFloat(a))%(u=parseFloat(u))+u)%u;return isNaN(l)?this.parent.getErrorStrings()[r.CommonErrors.Name]:l},n.prototype.ComputeFACT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=1,i=this.parent.getErrorStrings();if(""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=t[0];if(this.parent.isCellReference(t[0])||isNaN(Number(o.split(this.parent.tic).join("")))){if(o=this.parent.getValueFromArg(t[0]),i.indexOf(o)>-1)return o;if(o.startsWith(this.parent.tic)||o.match(/^(\d*\.\d+|\d+)\s*[+\-*/]\s*(\d*\.\d+|\d+)$/))return i[r.CommonErrors.Value];if(""===o)return 1}if(o=o.split(this.parent.tic).join("").trim(),i.indexOf(o)>-1)return o;if(o.toUpperCase()===this.parent.trueValue||o.toUpperCase()===this.parent.falseValue)return 1;o.indexOf("%")>-1&&(o=(Number(o.split("%")[0])/100).toString());var s=parseInt(o,10);if(s<0||s>170)return i[r.CommonErrors.Num];if(o.toUpperCase().match(/[A-Z]/)||""===o)return i[r.CommonErrors.Value];if(o.indexOf(":")>-1)return 0;for(var a=1;a<=s;a++)n*=a;return n},n.prototype.ComputeDECIMAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e[0].match(/[@#$%^&*()?:{}|<>+-]/g))return this.parent.getErrorStrings()[r.CommonErrors.Num];if(e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var o=void 0,s=void 0;o=this.parent.isCellReference(e[0].toString())?this.parent.getValueFromArg(e[0]):this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),s=this.parent.isCellReference(e[1].toString())?this.parent.getValueFromArg(e[1]):this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");var a=parseInt(o,10),u=parseInt(s,10);return this.parent.getErrorStrings().indexOf(o)>-1?o:this.parent.getErrorStrings().indexOf(s)>-1?s:""===o&&""!==s?0:""===o||a<0||!isNaN(a)&&!Number.isInteger(parseFloat(o))?this.parent.getErrorStrings()[r.CommonErrors.Num]:""===s||u<2||u>36||isNaN(u)?this.parent.getErrorStrings()[r.CommonErrors.Num]:isNaN(this.parent.parseFloat(o))&&this.parent.parseFloat(s)<=10?this.parent.getErrorStrings()[r.CommonErrors.Num]:(i=parseInt(o,parseInt(s,10)),isNaN(i)?this.parent.getErrorStrings()[r.CommonErrors.Num]:i)},n.prototype.ComputeLN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||""===e[0]&&1===e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:0===e.length||e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]),o.indexOf(i)>-1?i:(i.toUpperCase()===this.parent.trueValue?i="1":i.toUpperCase()===this.parent.falseValue&&(i="0"),this.parent.isCellReference(e[0])||""!==(i=this.parent.removeTics(i)).trim()?(2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(.01*Number(i.split("%")[0])).toString()),i=this.parent.parseFloat(i),i<=0?o[r.CommonErrors.Num]:isNaN(i)?o[r.CommonErrors.Value]:Math.log(i)):o[r.CommonErrors.Value]))},n.prototype.ComputeLOG=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s,a=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var u=function(t){var n=e.parent.getValueFromArg(t);if(n===e.parent.trueValue?n="1":n===e.parent.falseValue&&(n="0"),!e.parent.isCellReference(t)&&""!==n){if(n.indexOf(e.parent.tic)>-1&&-1===a.indexOf(n.split(e.parent.tic).join(""))){if(""===(n=e.parent.removeTics(n)).trim())return a[r.CommonErrors.Value];if(n.indexOf(":")>-1){var i=n.split(":");if(!(i.length<=3))return a[r.CommonErrors.Value];if(!e.parent.isNumber(i[0])||!e.parent.isNumber(i[1]))return a[r.CommonErrors.Value];var o=Number(i[0])+Number(Number(i[1])/60);if(3===i.length){if(!e.parent.isNumber(i[2]))return a[r.CommonErrors.Value];o+=Number(Number(i[2])/3600)}n=(o/24).toString()}}2===n.split("%").length&&e.parent.isNumber(n.split("%")[0])&&(n=(.01*Number(n.split("%")[0])).toString())}return n};if(!t.isNullOrUndefined(n[0])){if(o=u(n[0]),a.indexOf(o)>-1)return o;o=this.parent.parseFloat(o)}if(s=10,!t.isNullOrUndefined(n[1])){if(s=u(n[1]),a.indexOf(s)>-1)return s;s=this.parent.parseFloat(s)}return o=Number(o),isNaN(o)||isNaN(s)?a[r.CommonErrors.Value]:o<=0||s<=0?a[r.CommonErrors.Num]:1===s?a[r.CommonErrors.DivZero]:(Math.log(o)/Math.LN10/(Math.log(s)/Math.LN10)).toString()},n.prototype.ComputePOWER=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0].trim()&&""===n[1].trim())return s[r.CommonErrors.Num];var a=function(t){var n=e.parent.getValueFromArg(t);if(s.indexOf(n)>-1)return n;if(n.toUpperCase()===e.parent.trueValue?n="1":n.toUpperCase()===e.parent.falseValue&&(n="0"),n.indexOf(e.parent.tic)>-1&&(n=e.parent.removeTics(n),-1===t.indexOf(e.parent.tic)||""===n.trim()))return s[r.CommonErrors.Value];if(2===n.split("%").length&&e.parent.isNumber(n.split("%")[0]))n=(Number(n.split("%")[0])/100).toString();else if(n.indexOf("/")>-1&&e.parent.isNumber(n.split("/").join("")))return s[r.CommonErrors.Num];return n=e.parent.parseFloat(n),isNaN(n)?s[r.CommonErrors.Value]:n},u=a(n[0]);if(s.indexOf(u)>-1)return u;var l=a(n[1]);return s.indexOf(l)>-1?l:isNaN(u)||isNaN(l)?s[r.CommonErrors.Value]:0===u&&l<0?s[r.CommonErrors.DivZero]:0===u&&0===l?s[r.CommonErrors.Num]:(o=Math.pow(u,l),isNaN(o)||o===1/0?s[r.CommonErrors.Num]:o.toString())},n.prototype.ComputeSQRT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=t[0];if(0===t.length||t.length>1||""===i)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i.split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(i)){if((n=this.parent.getValueFromArg(i)||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(i.indexOf(this.parent.tic)>-1&&(i.split(this.parent.tic).join("")===this.parent.trueValue||i.split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];n=this.parent.getValueFromArg(i).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(n)>-1)return n;n=n===this.parent.trueValue?"1":n===this.parent.falseValue?"0":n;var o=this.parent.parseFloat(n);if(o<0)return this.parent.getErrorStrings()[r.CommonErrors.Num];if(isNaN(o)||i.indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(i))){var s=this.parent.hostParseDate(isNaN(o)?n:i.split(this.parent.tic).join(""));if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];n=s.value}return Math.sqrt(this.parent.parseFloat(n))},n.prototype.ComputeEXP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=this.parent.getErrorStrings();if(""===t[0]&&1===t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===t[0].split(this.parent.tic).join("").trim())return i[r.CommonErrors.Value];if(n=this.parent.getValueFromArg(t[0]),i.indexOf(n)>-1)return n;if(n.indexOf(this.parent.tic)>-1&&(this.parent.isCellReference(t[0])||isNaN(Number(n.split(this.parent.tic).join("")))))return i[r.CommonErrors.Value];if((n=n.split(this.parent.tic).join(""))===this.parent.trueValue)n="1";else if(n===this.parent.falseValue||""===n)n="0";else if(n.indexOf("%")>-1)n=(Number(n.split("%")[0])/100).toString();else if(n.indexOf(":")>-1)return"0";var o=this.parent.parseFloat(n);return isNaN(o)?i[r.CommonErrors.Value]:o>709?i[r.CommonErrors.Num]:Math.exp(o).toString()},n}(Q),or=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),sr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SIN",category:"Math & Trig",description:"Returns the sine of an angle."},{formulaName:"COS",category:"Math & Trig",description:"Returns the cosine of an angle."},{formulaName:"TAN",category:"Math & Trig",description:"Returns the tangent of an angle."},{formulaName:"ASIN",category:"Math & Trig",description:"Returns the arcsine of a number."},{formulaName:"ACOS",category:"Math & Trig",description:"Returns the arccosine of a number."},{formulaName:"ATAN",category:"Math & Trig",description:"Returns the arctangent of a number."},{formulaName:"ATAN2",category:"Math & Trig",description:"Returns the arctangent from x- and y-coordinates."},{formulaName:"SINH",category:"Math & Trig",description:"Returns the hyperbolic sine of a number."},{formulaName:"COSH",category:"Math & Trig",description:"Returns the hyperbolic cosine of a number."},{formulaName:"TANH",category:"Math & Trig",description:"Returns the hyperbolic tangent of a number."},{formulaName:"SIGN",category:"Math & Trig",description:"Returns the sign of a number."},{formulaName:"LOG10",category:"Math & Trig",description:"Returns the base-10 logarithm of a number."},{formulaName:"QUOTIENT",category:"Math & Trig",description:"Returns the integer portion of a division."},{formulaName:"SQRTPI",category:"Math & Trig",description:"Returns the square root of a number multiplied by pi."}],t}return or(n,e),n.prototype.unaryMath=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.resolveNumberArg(e[0]);return"string"==typeof s?s:i&&!i(s)?o[r.CommonErrors.Num]:n(s).toString()},n.prototype.ComputeSIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.sin)},n.prototype.ComputeCOS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.cos)},n.prototype.ComputeTAN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.tan)},n.prototype.ComputeASIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.asin,function(r){return r>=-1&&r<=1})},n.prototype.ComputeACOS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.acos,function(r){return r>=-1&&r<=1})},n.prototype.ComputeATAN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.atan)},n.prototype.ComputeSINH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.sinh)},n.prototype.ComputeCOSH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.cosh)},n.prototype.ComputeTANH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.tanh)},n.prototype.ComputeLOG10=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.log10,function(r){return r>0})},n.prototype.ComputeSQRTPI=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,function(r){return Math.sqrt(r*Math.PI)},function(r){return r>=0})},n.prototype.ComputeATAN2=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:0===o&&0===s?i[r.CommonErrors.DivZero]:Math.atan2(s,o).toString()},n.prototype.ComputeSIGN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:(i>0?1:i<0?-1:0).toString()},n.prototype.ComputeQUOTIENT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:0===s?i[r.CommonErrors.DivZero]:Math.trunc(o/s).toString()},n}(Q),ar=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ur=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ACOSH",category:"Math & Trig",description:"Returns the inverse hyperbolic cosine of a number."},{formulaName:"ASINH",category:"Math & Trig",description:"Returns the inverse hyperbolic sine of a number."},{formulaName:"ATANH",category:"Math & Trig",description:"Returns the inverse hyperbolic tangent of a number."}],t}return ar(n,e),n.prototype.unaryMath=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.resolveNumberArg(e[0]);if("string"==typeof s)return s;if(i&&!i(s))return o[r.CommonErrors.Num];var a=n(s);return isFinite(a)?a.toString():o[r.CommonErrors.Num]},n.prototype.ComputeACOSH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.acosh,function(r){return r>=1})},n.prototype.ComputeASINH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.asinh)},n.prototype.ComputeATANH=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.unaryMath(r,Math.atanh,function(r){return r>-1&&r<1})},n}(Q),lr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),hr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"FACTDOUBLE",category:"Math & Trig",description:"Returns the double factorial of a number."},{formulaName:"MULTINOMIAL",category:"Math & Trig",description:"Returns the multinomial of a set of numbers."},{formulaName:"PERMUT",category:"Math & Trig",description:"Returns the number of permutations for a given number of objects."},{formulaName:"SERIESSUM",category:"Math & Trig",description:"Returns the sum of a power series."},{formulaName:"ROMAN",category:"Math & Trig",description:"Converts an Arabic numeral to Roman, as text."}],t}return lr(n,e),n.prototype.ComputeFACTDOUBLE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=Math.floor(o);if(s<0||s>300)return i[r.CommonErrors.Num];for(var a=1,u=s;u>0;u-=2)a*=u;return a.toString()},n.prototype.ComputeMULTINOMIAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=[],s=0;s<e.length;s++){var a=this.resolveNumberArg(e[s]);if("string"==typeof a)return a;var u=Math.floor(a);if(u<0)return i[r.CommonErrors.Num];o.push(u)}for(var l=o.reduce(function(r,t){return r+t},0),h=1,s=0;s<o.length;s++)h*=N(o[s]);return(N(l)/h).toString()},n.prototype.ComputePERMUT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(o),u=Math.floor(s);if(a<0||u<0||a<u)return i[r.CommonErrors.Num];for(var l=1,h=0;h<u;h++)l*=a-h;return l.toString()},n.prototype.ComputeSERIESSUM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;for(var a=[],u=3;u<e.length;u++){var l=this.resolveNumberArg(e[u]);if("string"==typeof l)return l;a.push(l)}for(var h=0,u=0;u<a.length;u++){var p=o+u*s;h+=a[u]*Math.pow(i,p)}return h.toString()},n.prototype.ComputeROMAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=0;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;if((s=Math.floor(a))<0||s>4)return i[r.CommonErrors.Value]}var u=Math.floor(o);return u<0||u>3999?i[r.CommonErrors.Value]:0===u?"":this.toRoman(u,s)},n.prototype.toRoman=function(r,t){var e=["","M","MM","MMM"],n=[["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]],i=[["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"]],o=[["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"],["","I","II","III","IV","V","VI","VII","VIII","IX"]],s=Math.min(t,4),a=e[Math.floor(r/1e3)];return a+=n[s][Math.floor(r%1e3/100)],a+=i[s][Math.floor(r%100/10)],a+=o[s][r%10],1===t?a=a.replace(/XLV/g,"VL").replace(/XCV/g,"VC").replace(/CDL/g,"LD").replace(/CML/g,"LM").replace(/CMVC/g,"LMVL"):2===t?a=a.replace(/IV/g,"IIII").replace(/IX/g,"VIIII").replace(/XL/g,"XXXX").replace(/XC/g,"LXXXX").replace(/CD/g,"CCCC").replace(/CM/g,"DCCCC"):3===t?a=a.replace(/IV/g,"IIII").replace(/IX/g,"VIIII").replace(/XL/g,"XXXX").replace(/XC/g,"LXXXX").replace(/CD/g,"CCCC").replace(/CM/g,"DCCCC"):4===t&&(a=a.replace(/V/g,"IV").replace(/L/g,"XL").replace(/D/g,"CD")),a},n}(Q),pr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),gr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"GCD",category:"Math & Trig",description:"Returns the greatest common divisor."},{formulaName:"LCM",category:"Math & Trig",description:"Returns the least common multiple."},{formulaName:"MROUND",category:"Math & Trig",description:"Returns a number rounded to the desired multiple."},{formulaName:"COMBIN",category:"Math & Trig",description:"Returns the number of combinations for a given number of objects."},{formulaName:"SUMSQ",category:"Math & Trig",description:"Returns the sum of the squares of the arguments."}],t}return pr(n,e),n.prototype.collectNumbers=function(r){for(var t=this.parent.getErrorStrings(),e=[],n=0;n<r.length;n++){var i=r[n];if(""!==i)if(this.parent.isCellReference(i)&&i.indexOf(":")>-1)for(var o=this.parent.getCellCollection(i),s=Array.isArray(o)?o:[o],a=0;a<s.length;a++){var u=this.parent.getValueFromArg(s[a]);if(t.indexOf(u)>-1)return u;""!==u&&this.parent.isNumber(u)&&e.push(this.parent.parseFloat(u))}else{var l=this.resolveNumberArg(i);if("string"==typeof l)return l;e.push(l)}}return e},n.prototype.gcd2=function(r,t){for(var e=Math.abs(Math.floor(r)),n=Math.abs(Math.floor(t));n;){var i=n;n=e%n,e=i}return e},n.prototype.ComputeGCD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectNumbers(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.Value];for(a=0;a<o.length;a++)if(o[a]<0)return i[r.CommonErrors.Num];for(var s=Math.floor(o[0]),a=1;a<o.length;a++)s=this.gcd2(s,o[a]);return s.toString()},n.prototype.ComputeLCM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectNumbers(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.Value];for(a=0;a<o.length;a++)if(o[a]<0)return i[r.CommonErrors.Num];for(var s=Math.floor(o[0]),a=1;a<o.length;a++){var u=Math.floor(o[a]);s=0===s||0===u?0:Math.abs(s*u)/this.gcd2(s,u)}return s.toString()},n.prototype.ComputeMROUND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:0===s?"0":o>0&&s<0||o<0&&s>0?i[r.CommonErrors.Num]:(Math.round(o/s)*s).toString()},n.prototype.ComputeCOMBIN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(o),u=Math.floor(s);if(a<0||u<0||a<u)return i[r.CommonErrors.Num];for(var l=1,h=1;h<=u;h++)l=l*(a-u+h)/h;return Math.round(l).toString()},n.prototype.ComputeSUMSQ=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=this.collectNumbers(e);if("string"==typeof i)return i;for(var o=0,s=0;s<i.length;s++)o+=i[s]*i[s];return o.toString()},n}(Q),fr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),mr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return fr(e,t),e.prototype.readMatrix=function(t){var e=this.parent.getErrorStrings(),n=t.split("$").join("");if(!this.parent.isCellReference(n.split(":")[0]))return e[r.CommonErrors.Value];var i=Y(n),o=i[2]-i[0]+1,s=i[3]-i[1]+1,a=this.parent.getCellCollection(n),u=Array.isArray(a)?a:[a];if(u.length!==o*s)return e[r.CommonErrors.Value];for(var l=[],h=0;h<o;h++){for(var p=[],g=0;g<s;g++){var f=this.parent.getValueFromArg(u[h*s+g]);if(e.indexOf(f)>-1)return f;if(""===f||!this.parent.isNumber(f))return e[r.CommonErrors.Value];p.push(this.parent.parseFloat(f))}l.push(p)}return l},e.prototype.flattenMatrix=function(r,t){void 0===t&&(t=!1);var e=this.parent.getParseArgumentSeparator(),n=r.length,i=r[0].length,o=[];if(t)for(a=0;a<i;a++)for(s=0;s<n;s++)o.push(r[s][a].toString());else for(var s=0;s<n;s++)for(var a=0;a<i;a++)o.push(r[s][a].toString());return o.join(e)},e.prototype.determinant=function(r){var t=r.length;if(1===t)return r[0][0];if(2===t)return r[0][0]*r[1][1]-r[0][1]*r[1][0];for(var e=0,n=0;n<t;n++){for(var i=[],o=1;o<t;o++){for(var s=[],a=0;a<t;a++)a!==n&&s.push(r[o][a]);i.push(s)}e+=(n%2==0?1:-1)*r[0][n]*this.determinant(i)}return e},e.prototype.inverse=function(r){for(var t=r.length,e=[],n=0;n<t;n++){e.push(r[n].slice());for(l=0;l<t;l++)e[n].push(n===l?1:0)}for(n=0;n<t;n++){for(var i=n,o=n+1;o<t;o++)Math.abs(e[o][n])>Math.abs(e[i][n])&&(i=o);var s=e[n];e[n]=e[i],e[i]=s;var a=e[n][n];if(Math.abs(a)<1e-12)return null;for(l=0;l<2*t;l++)e[n][l]/=a;for(o=0;o<t;o++)if(o!==n)for(var u=e[o][n],l=0;l<2*t;l++)e[o][l]-=u*e[n][l]}for(var h=[],n=0;n<t;n++)h.push(e[n].slice(t));return h},e.prototype.multiply=function(r,t){if(r[0].length!==t.length)return null;for(var e=r.length,n=t[0].length,i=t.length,o=[],s=0;s<e;s++){for(var a=[],u=0;u<n;u++){for(var l=0,h=0;h<i;h++)l+=r[s][h]*t[h][u];a.push(l)}o.push(a)}return o},e}(Q),cr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),dr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"MDETERM",category:"Math & Trig",description:"Returns the matrix determinant of an array."},{formulaName:"MINVERSE",category:"Math & Trig",description:"Returns the matrix inverse of an array."},{formulaName:"MMULT",category:"Math & Trig",description:"Returns the matrix product of two arrays."},{formulaName:"TRANSPOSE",category:"Math & Trig",description:"Returns the transpose of an array."}],t}return cr(n,e),n.prototype.ComputeMDETERM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.readMatrix(e[0]);return"string"==typeof o?o:o.length!==o[0].length?i[r.CommonErrors.Value]:this.determinant(o).toString()},n.prototype.ComputeMINVERSE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.readMatrix(e[0]);if("string"==typeof o)return o;if(o.length!==o[0].length)return i[r.CommonErrors.Value];var s=this.inverse(o);return s?this.flattenMatrix(s):i[r.CommonErrors.Num]},n.prototype.ComputeMMULT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.readMatrix(e[0]),s=this.readMatrix(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.multiply(o,s);return a?this.flattenMatrix(a):i[r.CommonErrors.Value]},n.prototype.ComputeTRANSPOSE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.readMatrix(e[0]);return"string"==typeof i?i:this.flattenMatrix(i,!0)},n}(mr),vr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Nr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"BIN2DEC",category:"Engineering",description:"Converts a binary number to decimal."},{formulaName:"BIN2HEX",category:"Engineering",description:"Converts a binary number to hexadecimal."},{formulaName:"BIN2OCT",category:"Engineering",description:"Converts a binary number to octal."},{formulaName:"DEC2BIN",category:"Engineering",description:"Converts a decimal number to binary."},{formulaName:"DEC2HEX",category:"Engineering",description:"Converts a decimal number to hexadecimal."},{formulaName:"DEC2OCT",category:"Engineering",description:"Converts a decimal number to octal."},{formulaName:"HEX2BIN",category:"Engineering",description:"Converts a hexadecimal number to binary."},{formulaName:"HEX2DEC",category:"Engineering",description:"Converts a hexadecimal number to decimal."},{formulaName:"HEX2OCT",category:"Engineering",description:"Converts a hexadecimal number to octal."},{formulaName:"OCT2BIN",category:"Engineering",description:"Converts an octal number to binary."},{formulaName:"OCT2DEC",category:"Engineering",description:"Converts an octal number to decimal."},{formulaName:"OCT2HEX",category:"Engineering",description:"Converts an octal number to hexadecimal."}],t}return vr(n,e),n.prototype.parseBaseNumber=function(t,e){var n=this.parent.getErrorStrings(),i=t.trim().toUpperCase();if(""===i)return n[r.CommonErrors.Num];if(!(16===e?/^[0-9A-F]+$/:2===e?/^[01]+$/:/^[0-7]+$/).test(i))return n[r.CommonErrors.Num];var o=parseInt(i,e);return isNaN(o)?n[r.CommonErrors.Num]:o},n.prototype.resolveBaseArg=function(r,t){var e=this.parent.getErrorStrings(),n=this.resolveTextArg(r);return e.indexOf(n)>-1?n:this.parseBaseNumber(n,t)},n.prototype.formatToBase=function(t,e,n){var i=this.parent.getErrorStrings(),o=Math.trunc(t),s={2:{min:-512,max:511,maxPlaces:10},8:{min:-536870912,max:536870911,maxPlaces:10},10:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,maxPlaces:0},16:{min:-549755813888,max:549755813887,maxPlaces:10}}[e];if(o<s.min||o>s.max)return i[r.CommonErrors.Num];o<0&&(!0,o=(1<<(n&&n>0?n:10))+o);var a=o.toString(e).toUpperCase();if(void 0!==n&&n>0){if(n>s.maxPlaces)return i[r.CommonErrors.Num];for(;a.length<n;)a="0"+a}return a},n.prototype.ComputeBIN2DEC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveBaseArg(e[0],2);if("string"==typeof i)return i;var o=this.resolveTextArg(e[0]).trim();if(o.length>10)return this.parent.getErrorStrings()[r.CommonErrors.Num];var s=i;return 10===o.length&&"1"===o.charAt(0)&&(s=parseInt(o,2)-1024),s.toString()},n.prototype.ComputeBIN2HEX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.binTo(r,16)},n.prototype.ComputeBIN2OCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.binTo(r,8)},n.prototype.binTo=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.ComputeBIN2DEC(e[0]);if("string"==typeof o&&i.indexOf(o)>-1)return o;var s;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=Math.floor(a)}return this.formatToBase(parseInt(o.toString(),10),n,s)},n.prototype.ComputeDEC2BIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.decTo(r,2)},n.prototype.ComputeDEC2HEX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.decTo(r,16)},n.prototype.ComputeDEC2OCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.decTo(r,8)},n.prototype.decTo=function(e,n){if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o;if(2===e.length){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=Math.floor(s)}return this.formatToBase(Math.trunc(i),n,o)},n.prototype.ComputeHEX2DEC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveTextArg(e[0]).trim().toUpperCase(),o=this.parseBaseNumber(i,16);if("string"==typeof o)return o;if(i.length>10)return this.parent.getErrorStrings()[r.CommonErrors.Num];var s=o;return 10===i.length&&parseInt(i.charAt(0),16)>=8&&(s=parseInt(i,16)-256),s.toString()},n.prototype.ComputeHEX2BIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,2,this.ComputeHEX2DEC.bind(this))},n.prototype.ComputeHEX2OCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,8,this.ComputeHEX2DEC.bind(this))},n.prototype.ComputeOCT2DEC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveTextArg(e[0]).trim(),o=this.parseBaseNumber(i,8);if("string"==typeof o)return o;if(i.length>10)return this.parent.getErrorStrings()[r.CommonErrors.Num];var s=o;return 10===i.length&&i.charAt(0)>="4"&&(s=parseInt(i,8)-(1<<30)),s.toString()},n.prototype.ComputeOCT2BIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,2,this.ComputeOCT2DEC.bind(this))},n.prototype.ComputeOCT2HEX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.hexOctTo(r,16,this.ComputeOCT2DEC.bind(this))},n.prototype.hexOctTo=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=i(e[0]);if("string"==typeof s&&o.indexOf(s)>-1)return s;var a;if(2===e.length){var u=this.resolveNumberArg(e[1]);if("string"==typeof u)return u;a=Math.floor(u)}return this.formatToBase(parseInt(s.toString(),10),n,a)},n}(Q),Er=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Sr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DELTA",category:"Engineering",description:"Tests whether two values are equal."},{formulaName:"GESTEP",category:"Engineering",description:"Tests whether a number is greater than a threshold."},{formulaName:"ERF",category:"Engineering",description:"Returns the error function."},{formulaName:"ERFC",category:"Engineering",description:"Returns the complementary error function."}],t}return Er(n,e),n.prototype.ComputeDELTA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=0;if(2===e.length){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=s}return(i===o?1:0).toString()},n.prototype.ComputeGESTEP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=0;if(2===e.length){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=s}return(i>=o?1:0).toString()},n.prototype.ComputeERF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(1===e.length){var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:g(i).toString()}var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:(g(s)-g(o)).toString()},n.prototype.ComputeERFC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:f(i).toString()},n}(Q),yr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Cr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CONVERT",category:"Engineering",description:"Converts a number from one measurement system to another."}],t}return yr(n,e),n.prototype.ComputeCONVERT=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=this.resolveNumberArg(e[0]);if("string"==typeof s)return s;var a=this.resolveTextArg(e[1]).toLowerCase(),u=this.resolveTextArg(e[2]).toLowerCase();if(o.indexOf(a)>-1)return a;if(o.indexOf(u)>-1)return u;if(a===u)return s.toString();if("c"===a&&"f"===u)return(9*s/5+32).toString();if("f"===a&&"c"===u)return(5*(s-32)/9).toString();for(var l=0,h=n.UNITS;l<h.length;l++){var p=h[l];if(p.from===a&&p.to===u&&!isNaN(p.factor))return(s*p.factor).toString()}var g=n.UNITS.find(function(r){return r.from===a&&!isNaN(r.factor)}),f=g?g.to:void 0,m=n.UNITS.find(function(r){return r.to===u&&r.from===f&&!isNaN(r.factor)});return g&&m?(s*g.factor*m.factor).toString():o[r.CommonErrors.NA]},n.UNITS=[{from:"g",to:"kg",factor:.001},{from:"kg",to:"g",factor:1e3},{from:"lbm",to:"kg",factor:.45359237},{from:"kg",to:"lbm",factor:2.2046226218},{from:"m",to:"ft",factor:3.280839895},{from:"ft",to:"m",factor:.3048},{from:"in",to:"m",factor:.0254},{from:"m",to:"in",factor:39.37007874},{from:"mi",to:"m",factor:1609.344},{from:"m",to:"mi",factor:1/1609.344},{from:"yr",to:"day",factor:365.25},{from:"day",to:"yr",factor:1/365.25},{from:"hr",to:"sec",factor:3600},{from:"sec",to:"hr",factor:1/3600},{from:"C",to:"F",factor:NaN},{from:"F",to:"C",factor:NaN},{from:"l",to:"m3",factor:.001},{from:"m3",to:"l",factor:1e3},{from:"N",to:"lbf",factor:.224808943},{from:"lbf",to:"N",factor:4.4482216153}],n}(Q),br=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ar=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"BESSELI",category:"Engineering",description:"Returns the modified Bessel function In(x)."},{formulaName:"BESSELJ",category:"Engineering",description:"Returns the Bessel function Jn(x)."},{formulaName:"BESSELK",category:"Engineering",description:"Returns the modified Bessel function Kn(x)."},{formulaName:"BESSELY",category:"Engineering",description:"Returns the Bessel function Yn(x)."}],t}return br(n,e),n.prototype.besselArgs=function(e){var n=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);return"string"==typeof i?i:"string"==typeof o?o:o<0?n[r.CommonErrors.Num]:{x:i,n:Math.floor(o)}},n.prototype.ComputeBESSELI=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.besselArgs(t);if("string"==typeof n)return n;var i=V(n.n,n.x);return isFinite(i)?i.toString():this.parent.getErrorStrings()[r.CommonErrors.Num]},n.prototype.ComputeBESSELJ=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.besselArgs(r);return"string"==typeof e?e:R(e.n,e.x).toString()},n.prototype.ComputeBESSELK=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.besselArgs(t);if("string"==typeof i)return i;if(i.x<=0)return n[r.CommonErrors.Num];var o=I(i.n,i.x);return isFinite(o)?o.toString():n[r.CommonErrors.Num]},n.prototype.ComputeBESSELY=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.besselArgs(t);if("string"==typeof i)return i;if(i.x<=0)return n[r.CommonErrors.Num];var o=D(i.n,i.x);return isFinite(o)?o.toString():n[r.CommonErrors.Num]},n}(Q),Or=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Fr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"FV",category:"Financial",description:"Returns the future value of an investment."},{formulaName:"PV",category:"Financial",description:"Returns the present value of an investment."},{formulaName:"PMT",category:"Financial",description:"Returns the periodic payment for an annuity."},{formulaName:"NPER",category:"Financial",description:"Returns the number of periods for an investment."},{formulaName:"IPMT",category:"Financial",description:"Returns the interest payment for an investment for a given period."},{formulaName:"PPMT",category:"Financial",description:"Returns the payment on the principal for an investment for a given period."},{formulaName:"NPV",category:"Financial",description:"Returns the net present value of an investment based on periodic cash flows."},{formulaName:"RATE",category:"Financial",description:"Returns the interest rate per period of an annuity."}],t}return Or(n,e),n.prototype.resolveOptional=function(r,t,e){return r.length<=t||""===r[t]?e:this.resolveNumberArg(r[t])},n.prototype.ComputeFV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveOptional(e,3,0),u=this.resolveOptional(e,4,0);if("string"==typeof a)return a;if("string"==typeof u)return u;if(0===i)return(-a-s*o).toString();var l=Math.pow(1+i,o);return(-a*l-s*(1+i*(u?1:0))*(l-1)/i).toString()},n.prototype.ComputePV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveOptional(e,3,0),u=this.resolveOptional(e,4,0);if("string"==typeof a)return a;if("string"==typeof u)return u;if(0===i)return(-a-s*o).toString();var l=Math.pow(1+i,o);return((-a-s*(1+i*(u?1:0))*(l-1)/i)/l).toString()},n.prototype.ComputePMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveOptional(e,3,0),u=this.resolveOptional(e,4,0);if("string"==typeof a)return a;if("string"==typeof u)return u;if(0===i)return(-s-a)/o;var l=Math.pow(1+i,o);return(i*(a+s*l)/((1+i*(u?1:0))*(1-l))).toString()},n.prototype.ComputeNPER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=this.resolveOptional(e,3,0),l=this.resolveOptional(e,4,0);if("string"==typeof u)return u;if("string"==typeof l)return l;if(0===o)return 0===s?i[r.CommonErrors.Num]:(-(a+u)/s).toString();var h=l?1:0,p=s*(1+o*h)/o-u,g=a+s*(1+o*h)/o;return 0===g||p/g<=0?i[r.CommonErrors.Num]:(Math.log(p/g)/Math.log(1+o)).toString()},n.prototype.ComputeIPMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=this.resolveOptional(e,4,0),l=this.resolveOptional(e,5,0);if("string"==typeof u)return u;if("string"==typeof l)return l;var h=this.ComputePMT(i.toString(),s.toString(),a.toString(),u.toString(),l.toString());if("string"==typeof h&&this.parent.getErrorStrings().indexOf(h)>-1)return h;for(var p=parseFloat(h.toString()),g=a,f=1;f<o;f++)g=g*(1+i)+p;return(g*i).toString()},n.prototype.ComputePPMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.ComputeIPMT.apply(this,e);if("string"==typeof i&&this.parent.getErrorStrings().indexOf(i)>-1)return i;var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveOptional(e,4,0),l=this.resolveOptional(e,5,0),h=this.ComputePMT(o.toString(),s.toString(),a.toString(),("number"==typeof u?u:0).toString(),("number"==typeof l?l:0).toString());return(parseFloat(h.toString())-parseFloat(i.toString())).toString()},n.prototype.ComputeNPV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;for(var o=0,s=1;s<e.length;s++){var a=this.resolveNumberArg(e[s]);if("string"==typeof a)return a;o+=a/Math.pow(1+i,s)}return o.toString()},n.prototype.ComputeRATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=this.resolveOptional(e,3,0),l=this.resolveOptional(e,4,0),h=this.resolveOptional(e,5,.1);if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;for(var p=h,g=0;g<100;g++){var f=l?1:0,m=Math.pow(1+p,o),c=a*m+s*(1+p*f)*(m-1)/p+u,d=o*a*Math.pow(1+p,o-1)+s*(1+p*f)*(o*Math.pow(1+p,o-1)*p-(m-1))/(p*p)+s*f*(m-1)/p;if(Math.abs(d)<1e-12)break;var v=p-c/d;if(Math.abs(v-p)<1e-10)return v.toString();p=v}return i[r.CommonErrors.Num]},n}(Q),xr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Vr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SLN",category:"Financial",description:"Returns the straight-line depreciation of an asset for one period."},{formulaName:"SYD",category:"Financial",description:"Returns the sum-of-years digits depreciation for a specified period."},{formulaName:"DB",category:"Financial",description:"Returns the depreciation of an asset for a period using fixed-declining balance."},{formulaName:"DDB",category:"Financial",description:"Returns the depreciation of an asset for a period using double-declining balance."}],t}return xr(n,e),n.prototype.ComputeSLN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);return"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:0===a?i[r.CommonErrors.DivZero]:((o-s)/a).toString()},n.prototype.ComputeSYD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||4!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);return"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:"string"==typeof u?u:a<=0||u<=0||u>a?i[r.CommonErrors.Num]:((o-s)*(a-u+1)/(a*(a+1)/2)).toString()},n.prototype.ComputeDB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=12;if(5===e.length){var h=this.resolveNumberArg(e[4]);if("string"==typeof h)return h;l=Math.floor(h)}if(a<=0||u<=0)return i[r.CommonErrors.Num];for(var p=1-Math.pow(s/o,1/a),g=0,f=1;f<=Math.floor(u);f++)g+=d=(o-g)*p*(1===f?l/12:1);var m=u-Math.floor(u);if(m>0&&(g+=(o-g)*p*m),1===Math.floor(u))return g.toString();for(var c=0,f=1;f<Math.floor(u);f++){var d=(o-c)*p*(1===f?l/12:1);c+=d}return(g-c).toString()},n.prototype.ComputeDDB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=2;if(5===e.length){var h=this.resolveNumberArg(e[4]);if("string"==typeof h)return h;l=h}if(a<=0||u<=0)return i[r.CommonErrors.Num];for(var p=l/a,g=o,f=0,m=1;m<=Math.floor(u);m++)g-=f=Math.min(g*p,g-s);var c=u-Math.floor(u);return c>0&&(f=Math.min(g*p*c,(g-s)*c)),f.toString()},n}(Q),Rr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ir=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"EFFECT",category:"Financial",description:"Returns the effective annual interest rate."},{formulaName:"NOMINAL",category:"Financial",description:"Returns the nominal annual interest rate."},{formulaName:"FVSCHEDULE",category:"Financial",description:"Returns the future value of an initial principal after applying compound interest rates."}],t}return Rr(n,e),n.prototype.ComputeEFFECT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:s<1?i[r.CommonErrors.Num]:(Math.pow(1+o/s,s)-1).toString()},n.prototype.ComputeNOMINAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);return"string"==typeof o?o:"string"==typeof s?s:s<1?i[r.CommonErrors.Num]:(s*(Math.pow(1+o,1/s)-1)).toString()},n.prototype.ComputeFVSCHEDULE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;for(var o=i,s=1;s<e.length;s++){var a=this.resolveNumberArg(e[s]);if("string"==typeof a)return a;o*=1+a}return o.toString()},n}(Q),Tr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Mr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"IRR",category:"Financial",description:"Returns the internal rate of return for a series of cash flows."},{formulaName:"MIRR",category:"Financial",description:"Returns the modified internal rate of return for cash flows."}],t}return Tr(n,e),n.prototype.collectCashflows=function(r){for(var t=this.parent.getErrorStrings(),e=[],n=0;n<r.length;n++){var i=r[n];if(""!==i)if(this.parent.isCellReference(i)&&i.indexOf(":")>-1)for(var o=this.parent.getCellCollection(i),s=Array.isArray(o)?o:[o],a=0;a<s.length;a++){var u=this.parent.getValueFromArg(s[a]);if(t.indexOf(u)>-1)return u;""!==u&&this.parent.isNumber(u)&&e.push(this.parent.parseFloat(u))}else{var l=this.resolveNumberArg(i);if("string"==typeof l)return l;e.push(l)}}return e},n.prototype.npvAtRate=function(r,t){for(var e=0,n=0;n<r.length;n++)e+=r[n]/Math.pow(1+t,n);return e},n.prototype.npvDerivative=function(r,t){for(var e=0,n=1;n<r.length;n++)e-=n*r[n]/Math.pow(1+t,n+1);return e},n.prototype.ComputeIRR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=.1,s=e;if(2===e.length&&this.parent.isCellReference(e[0])){var a=this.resolveNumberArg(e[1]);"number"==typeof a&&(o=a,s=[e[0]])}var u=this.collectCashflows(s);if("string"==typeof u)return u;if(u.length<2)return i[r.CommonErrors.Num];for(var l=!1,h=!1,p=0;p<u.length;p++)u[p]>0&&(l=!0),u[p]<0&&(h=!0);if(!l||!h)return i[r.CommonErrors.Num];for(var g=o,f=0;f<100;f++){var m=this.npvAtRate(u,g),c=this.npvDerivative(u,g);if(Math.abs(c)<1e-12)break;var d=g-m/c;if(Math.abs(d-g)<1e-10)return d.toString();g=d}return i[r.CommonErrors.Num]},n.prototype.ComputeMIRR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.collectCashflows([e[0]]);if("string"==typeof a)return a;if(a.length<2)return i[r.CommonErrors.Num];for(var u=a.length-1,l=0,h=0,p=0;p<a.length;p++){var g=a[p];g>=0?h+=g*Math.pow(1+s,u-p):l+=g/Math.pow(1+o,p)}return 0===l||0===h?i[r.CommonErrors.DivZero]:(Math.pow(-h/l,1/u)-1).toString()},n}(Q),Dr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ur=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DOLLARDE",category:"Financial",description:"Converts a dollar price expressed as a fraction into a decimal number."},{formulaName:"DOLLARFR",category:"Financial",description:"Converts a dollar price expressed as a decimal number into a fraction."},{formulaName:"DISC",category:"Financial",description:"Returns the discount rate for a security."},{formulaName:"DURATION",category:"Financial",description:"Returns the annual duration of a security with periodic interest payments."},{formulaName:"INTRATE",category:"Financial",description:"Returns the interest rate for a fully invested security."},{formulaName:"RECEIVED",category:"Financial",description:"Returns the amount received at maturity for a fully invested security."},{formulaName:"CUMIPMT",category:"Financial",description:"Returns the cumulative interest paid between two periods."},{formulaName:"CUMPRINC",category:"Financial",description:"Returns the cumulative principal paid on a loan between two periods."},{formulaName:"VDB",category:"Financial",description:"Returns the depreciation of an asset for a period using the declining balance method."},{formulaName:"XIRR",category:"Financial",description:"Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic."}],t}return Dr(n,e),n.prototype.ComputeDOLLARDE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(s);if(a<=0)return i[r.CommonErrors.Num];var u=Math.trunc(o);return(u+(o-u)*Math.pow(10,Math.ceil(Math.log10(a)))/a).toString()},n.prototype.ComputeDOLLARFR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(s);if(a<=0)return i[r.CommonErrors.Num];var u=Math.trunc(o);return(u+(o-u)*a/Math.pow(10,Math.ceil(Math.log10(a)))).toString()},n.prototype.ComputeDISC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.max(s-o,1),l=3===(e.length>=5?this.resolveNumberArg(e[4]):0)?365:360;return a<=0?i[r.CommonErrors.Num]:((1-a/100)*l/u).toString()},n.prototype.ComputeDURATION=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<5||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[3]),o=this.resolveNumberArg(e[4]);return"string"==typeof i?i:"string"==typeof o?o:(1/(e.length>=6?this.resolveNumberArg(e[5]):2)).toString()},n.prototype.ComputeINTRATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=Math.max(s-o,1),h=3===(e.length>=5?this.resolveNumberArg(e[4]):0)?365:360;return a<=0?i[r.CommonErrors.Num]:((u-a)/a*h/l).toString()},n.prototype.ComputeRECEIVED=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);return"string"==typeof i?i:"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:(s*(1+a*Math.max(o-i,1)/(3===(e.length>=5?this.resolveNumberArg(e[4]):0)?365:360))).toString()},n.prototype.ComputeCUMIPMT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.cumIpmtPrinc(r,!0)},n.prototype.ComputeCUMPRINC=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.cumIpmtPrinc(r,!1)},n.prototype.cumIpmtPrinc=function(e,n){if(t.isNullOrUndefined(e)||6!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]),l=this.resolveNumberArg(e[5]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;for(var h=parseFloat(this.computePmt(i,o,s,l)),p=s,g=0,f=1;f<=u;f++){var m=p*i,c=h-m;f>=a&&(g+=n?m:c),p+=h}return g.toString()},n.prototype.computePmt=function(r,t,e,n){if(0===r)return(-e/t).toString();var i=Math.pow(1+r,t);return(r*e*i/((1+r*(n?1:0))*(1-i))).toString()},n.prototype.ComputeVDB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<5||e.length>7)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=2;if(e.length>=6&&""!==e[5]){var h=this.resolveNumberArg(e[5]);if("string"==typeof h)return h;l=h}for(var p=l/s,g=i,f=0,m=1;m<=Math.floor(u);m++)g-=f=Math.min(g*p,g-o);var c=0;g=i;for(m=1;m<=u;m++)f=Math.min(g*p,g-o),m>a&&(c+=f),g-=f;return c.toString()},n.prototype.ComputeXIRR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=[],s=[],a=.1,u=e[e.length-1];if(e.length>=3&&!this.parent.isCellReference(u)){var l=this.resolveNumberArg(u);"number"==typeof l&&(a=l)}var h=e[0],p=e[1],g=this.parent.getCellCollection(h),f=this.parent.getCellCollection(p),m=Array.isArray(g)?g:[g],c=Array.isArray(f)?f:[f];if(m.length!==c.length||m.length<2)return i[r.CommonErrors.Num];for(var d=0;d<m.length;d++){var v=this.parent.getValueFromArg(m[d]),N=this.parent.getValueFromArg(c[d]);if(i.indexOf(v)>-1)return v;if(i.indexOf(N)>-1)return N;o.push(this.parent.parseFloat(v)),s.push(this.parent.parseFloat(N))}for(var E=s[0],S=function(r){for(var t=0,e=0;e<o.length;e++)t+=o[e]/Math.pow(1+r,(s[e]-E)/365);return t},y=a,C=0;C<100;C++){var b=S(y),A=(S(y+1e-7)-b)/1e-7;if(Math.abs(A)<1e-12)break;var O=y-b/A;if(Math.abs(O-y)<1e-10)return O.toString();y=O}return i[r.CommonErrors.Num]},n}(Q),wr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),jr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"AVERAGE",category:"Statistical",description:"The sum of the numbers divided by how many numbers are being averaged."},{formulaName:"AVERAGEIF",category:"Statistical",description:"Computes the average of the numbers in a range that meet the supplied criteria."},{formulaName:"AVERAGEA",category:"Statistical",description:"Calculates the average of values in the list of arguments.Arguments can be numbers, names, arrays or references."},{formulaName:"AVERAGEIFS",category:"Statistical",description:"Conditionally returns the average of the contents of cells for the set of ranges."},{formulaName:"COUNT",category:"Statistical",description:"Counts the numbers in the list of arguments, exclude text entries."},{formulaName:"COUNTA",category:"Statistical",description:"Counts the non-empty values in the list of arguments."},{formulaName:"COUNTIF",category:"Statistical",description:"Counts the number of cells in a range that meet a specified condition."},{formulaName:"COUNTIFS",category:"Statistical",description:"Counts the number of times each cells in all the ranges that meet the specific conditions."},{formulaName:"COUNTBLANK",category:"Statistical",description:"Returns the number of empty cells in a specified range of cells."},{formulaName:"MIN",category:"Statistical",description:"Returns the smaller number in set of arguments."},{formulaName:"MAX",category:"Statistical",description:"Returns the largest number in set of arguments."}],t}return wr(n,e),n.prototype.ComputeAVERAGE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=e,s=0;s<o.length;s++)if(o[s].indexOf(":")>-1&&o[s].indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];return this.parent.calculateAvg(o,i)},n.prototype.ComputeAVERAGEIF=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t;if(n[0].indexOf(":")<0&&!this.parent.isCellReference(n[0]))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];var i=this.parent.computeSumIfAndAvgIf(t,!0);return 0===i[1]||"NaN"===i[0].toString()?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Div]:"string"==typeof i&&(this.parent.formulaErrorStrings.indexOf(i)||this.parent.getErrorStrings().indexOf(i))?i:this.parent.parseFloat(i[0])/this.parent.parseFloat(i[1])},n.prototype.ComputeAVERAGEA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var i,o,s,a,u=e,l=0,h=0,p=0;p<u.length;p++)if(this.parent.isCellReference(u[p]))if(u[p].indexOf(":")>-1){i=this.parent.getCellCollection(u[p].split(this.parent.tic).join(""));for(var g=0;g<i.length;g++){if(o=this.parent.getValueFromArg(i[g]),o=this.processLogicalCellValue(o),this.parent.getErrorStrings().indexOf(o)>-1)return o;t.isNullOrUndefined(o)||""===o||(a=this.parent.parseFloat(o),l+=o=isNaN(a)?0:a,h+=1)}}else{if(o=this.parent.getValueFromArg(u[p]),o=this.processLogicalCellValue(o),this.parent.getErrorStrings().indexOf(o)>-1)return o;if(t.isNullOrUndefined(o)||""===o)continue;a=this.parent.parseFloat(o),l+=o=isNaN(a)?0:a,h+=1}else{if(u[p].indexOf(this.parent.tic)>-1&&(isNaN(this.parent.parseFloat(u[p].split(this.parent.tic).join("")))||""===u[p].split(this.parent.tic).join("").trim()))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(u[p]=this.processLogicalCellValue(u[p]),s=this.parent.getValueFromArg(u[p].split(this.parent.tic).join("")),this.parent.getErrorStrings().indexOf(s)>-1)return s;l+=this.parent.parseFloat(s),h+=1}return 0===h?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:l/h},n.prototype.processLogicalCellValue=function(r){var t=r;return t.toUpperCase()===this.parent.trueValue?t="1":t.toUpperCase()===this.parent.falseValue&&(t="0"),t},n.prototype.ComputeAVERAGEIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.calculateIFS(r,this.parent.trueValue)},n.prototype.ComputeCOUNT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o,s,a,u,l=e,h=0,p=0;p<l.length;p++)if(o=l[p],this.parent.isCellReference(o))if(o.indexOf(":")>-1){s=this.parent.getCellCollection(o.split(this.parent.tic).join(""));for(var g=0;g<s.length;g++)a=i?this.parent.getValueFromArg(s[g],null,null,!0):this.parent.getValueFromArg(s[g]),i&&a.includes("SUBTOTAL(")||isNaN(this.parent.parseFloat(a))||o.length>0&&""!==a.trim()&&h++}else{if(a=i?this.parent.getValueFromArg(o,null,null,!0):this.parent.getValueFromArg(o),i&&a.includes("SUBTOTAL("))continue;isNaN(this.parent.parseFloat(a))||o.length>0&&""!==a.trim()&&h++}else u=this.parent.getValueFromArg(o).split(this.parent.tic).join(""),0===o.length&&""===u.trim()?h++:isNaN(this.parent.parseFloat(u))&&o!==this.parent.trueValue&&o!==this.parent.falseValue||o.length>0&&""!==o.trim()&&""!==u.trim()&&h++;return h},n.prototype.ComputeCOUNTA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o,s,a,u=e,l=0,h=0;h<u.length;h++)if(this.parent.isCellReference(u[h]))if(u[h].indexOf(":")>-1){o=this.parent.getCellCollection(u[h].split(this.parent.tic).join(""));for(var p=0;p<o.length;p++)s=i?this.parent.getValueFromArg(o[p],null,null,!0):this.parent.getValueFromArg(o[p]),i&&s.includes("SUBTOTAL(")||s.length>0&&l++}else{if(s=i?this.parent.getValueFromArg(u[h],null,null,!0):this.parent.getValueFromArg(u[h]),i&&s.includes("SUBTOTAL("))continue;s.length>0&&l++}else(a=this.parent.getValueFromArg(u[h]).split(this.parent.tic).join("")).length>0?l++:0===a.length&&""===a.trim()&&l++;return l},n.prototype.ComputeCOUNTIF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;if(t.isNullOrUndefined(e)||""===e[0]||2!==i.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(i[0].indexOf(":")<0&&!this.parent.isCellReference(i[0]))return this.parent.getErrorStrings()[r.CommonErrors.Name];var o,s,a=0,u=[],l="equal";if(""===i[1])return 0;var h=i[1].startsWith(this.parent.tic)&&i[1].endsWith(this.parent.tic),p=this.parent.getANDComputedValue(i[1]),g=p.includes("*"),f="*"===p||"<>*"===p,m=g&&!f?p.replace(/\*/g,"").trim():p,c=!1;if(!h&&this.parent.isCellReference(m)&&(m=this.parent.getValueFromArg(m),c=!0),g&&!f){var d=p.indexOf("*");"*"===p[0]&&(m="*"+m),"*"===p[p.length-1]&&(m+="*"),d>0&&d<p.length-1&&(m=p.substring(0,d)+"*"+p.substring(d+1))}(p=m).startsWith("<=")?(l="lessEq",p=p.substring(2)):p.startsWith(">=")?(l="greaterEq",p=p.substring(2)):p.startsWith("<>")?(l="notEq",p=p.substring(2)):p.startsWith("<")?(l="less",p=p.substring(1)):p.startsWith(">")?(l="greater",p=p.substring(1)):p.startsWith("=")&&(l="equal",p=p.substring(1));var v=p.indexOf("*")>-1||p.indexOf("?")>-1;if((!h&&this.parent.isCellReference(p)&&!c||p.includes(this.parent.arithMarker)||p.includes(this.parent.getParseDecimalSeparator())&&!v)&&(p=this.parent.getValueFromArg(p)),this.parent.isCellReference(i[0])){o=this.parent.getCellCollection(i[0].split(this.parent.tic).join(""));for(var N=0;N<o.length;N++)s=this.parent.getValueFromArg(o[N]),v&&(s=this.parent.findWildCardValue(p.toLowerCase(),s.toLowerCase())),u.push(s),u.push(p),this.parent.processLogical(u,l)===this.parent.trueValue&&a++}return a},n.prototype.ComputeCOUNTIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parent.computeCountIfsFormulas(r)},n.prototype.ComputeCOUNTBLANK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=0;if(1!==e.length||t.isNullOrUndefined(e)||!this.parent.isCellReference(e[0]))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0])return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var o=this.parent.getCellCollection(e[0]),s=0;s<o.length;s++)""===this.parent.getValueFromArg(o[s])&&i++;return i},n.prototype.ComputeMIN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parent.computeMinMax(r,"min")},n.prototype.ComputeMAX=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parent.computeMinMax(r,"max")},n}(Q),Lr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),kr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"SMALL",category:"Statistical",description:"Returns the k-th smallest value in a given array."},{formulaName:"LARGE",category:"Statistical",description:"Returns the k-th largest value in a given array."},{formulaName:"MEDIAN",category:"Statistical",description:"Returns the median of the given set of numbers."},{formulaName:"SLOPE",category:"Statistical",description:"Returns the slope of the line from linear regression of the data points."},{formulaName:"INTERCEPT",category:"Statistical",description:"Calculates the point of the Y-intercept line via linear regression."},{formulaName:"RSQ",category:"Statistical",description:"Returns the square of the Pearson product moment correlation coefficient based on data points in known_ys and known_xs."},{formulaName:"GEOMEAN",category:"Statistical",description:"Returns the geometric mean of an array or range of positive data."}],t}return Lr(n,e),n.prototype.ComputeMEDIAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=[];if(t.isNullOrUndefined(e)||""===e[0]&&1===e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var s=0;s<e.length;s++)if(this.parent.isCellReference(e[s]))if(e[s].indexOf(":")>-1)for(var a=this.parent.getCellCollection(e[s]),u=0;u<a.length;u++){var l=this.parent.getValueFromArg(a[u]);if(this.parent.getErrorStrings().indexOf(l)>-1)return l;""!==l.trim()&&o.push(this.parent.parseFloat(l))}else{var h=this.parent.getValueFromArg(e[s]);if(this.parent.getErrorStrings().indexOf(h)>-1)return h;""!==h.trim()&&o.push(this.parent.parseFloat(h))}else if(""===e[s]||e[s]===this.parent.falseValue&&!this.parent.isCellReference(e[s]))o.push(0);else if(e[s]!==this.parent.trueValue||this.parent.isCellReference(e[s])){if(e[s].indexOf(this.parent.tic)>-1&&isNaN(parseFloat(e[s].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var p=this.parent.getValueFromArg(e[s]).split(this.parent.tic).join("");if(this.parent.getErrorStrings().indexOf(p)>-1)return p;o.push(this.parent.parseFloat(p))}else o.push(1);for(var g=(o=o.sort(function(r,t){return r-t})).length,f=0;f<g&&(!isNaN(o[f])||(o.splice(f,1),g=o.length,f--,0!==o.length));f++);if(o.length%2==0||isNaN(o[parseInt((o.length/2).toString(),10)])){if(isNaN(o[o.length/2])||isNaN(o[o.length/2-1]))return this.parent.getErrorStrings()[r.CommonErrors.Num];i=(o[o.length/2]+o[o.length/2-1])/2}else i=o[parseInt((o.length/2).toString(),10)];return i},n.prototype.ComputeSMALL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length||""===e[0])return""===e[0]&&""===e[1]?i[r.CommonErrors.Num]:this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=[],s=[],a=[];if(!t.isNullOrUndefined(e[0])){var u=void 0;if(this.parent.isCellReference(e[0])){o=this.parent.getCellCollection(e[0]);for(l=0;l<o.length;l++){if(u=this.parent.getValueFromArg(o[l]),i.indexOf(u)>-1)return u;s.push(u)}}else{if(u=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),i.indexOf(u)>-1)return u;s.push(u)}for(var l=0;l<s.length;l++)""===s[l]||isNaN(this.parent.parseFloat(s[l]))||a.push(this.parent.parseFloat(s[l]));if(0===a.length&&(t.isNullOrUndefined(s[0])||e[0].indexOf(this.parent.tic)>-1))return i[r.CommonErrors.Value]}a=a.sort(function(r,t){return r-t});var h;if(!t.isNullOrUndefined(e[1])){if(this.parent.isCellReference(e[1])){if(""===(h=this.parent.getValueFromArg(e[1])))return i[r.CommonErrors.Num];if(""===h.trim())return i[r.CommonErrors.Value];h.toUpperCase()===this.parent.trueValue?h="1":h.toUpperCase()===this.parent.falseValue&&(h="0")}else h=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");if(i.indexOf(h)>-1)return h;if(""===h.trim())return e[1].length>0?i[r.CommonErrors.Value]:i[r.CommonErrors.Num];if(isNaN(this.parent.parseFloat(h)))if(e[1].toUpperCase()===this.parent.trueValue)h="1";else{if(e[1].toUpperCase()!==this.parent.falseValue)return i[r.CommonErrors.Value];h="0"}}var p=Number(h)<1?0:Math.floor(Number(h));return t.isNullOrUndefined(a[p-1])&&!isNaN(Number(p))?i[r.CommonErrors.Num]:a[p-1]},n.prototype.ComputeLARGE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length||""===e[0])return""===e[0]&&""===e[1]?i[r.CommonErrors.Num]:this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=[],s=[],a=[];if(!t.isNullOrUndefined(e[0])){var u=void 0;if(this.parent.isCellReference(e[0])){o=this.parent.getCellCollection(e[0]);for(l=0;l<o.length;l++){if(u=this.parent.getValueFromArg(o[l]),i.indexOf(u)>-1)return u;s.push(u)}}else{if(u=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),i.indexOf(u)>-1)return u;s.push(u)}for(var l=0;l<s.length;l++)""===s[l]||isNaN(this.parent.parseFloat(s[l]))||a.push(this.parent.parseFloat(s[l]));if(0===a.length&&(t.isNullOrUndefined(s[0])||e[0].indexOf(this.parent.tic)>-1))return i[r.CommonErrors.Value]}a=a.sort(function(r,t){return t-r});var h;if(!t.isNullOrUndefined(e[1])){if(this.parent.isCellReference(e[1])){if(""===(h=this.parent.getValueFromArg(e[1])))return i[r.CommonErrors.Num];if(""===h.trim())return i[r.CommonErrors.Value];h.toUpperCase()===this.parent.trueValue?h="1":h.toUpperCase()===this.parent.falseValue&&(h="0")}else h=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");if(i.indexOf(h)>-1)return h;if(""===h.trim())return e[1].length>0?i[r.CommonErrors.Value]:i[r.CommonErrors.Num];if(isNaN(this.parent.parseFloat(h)))if(e[1].toUpperCase()===this.parent.trueValue)h="1";else{if(e[1].toUpperCase()!==this.parent.falseValue)return i[r.CommonErrors.Value];h="0"}}var p=Number(h)<1?0:Math.ceil(Number(h));return t.isNullOrUndefined(a[p-1])&&!isNaN(Number(p))?i[r.CommonErrors.Num]:a[p-1]},n.prototype.ComputeSLOPE=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0]||""===n[1])return o[r.CommonErrors.Value];var s=function(r){return r=-1===r.indexOf(e.parent.tic)?e.parent.getCellCollection(r.split(e.parent.tic).join("")):void 0},a=s(n[0].trim()),u=s(n[1].trim());if(t.isNullOrUndefined(a)||t.isNullOrUndefined(u)||a.length<2&&u.length<2)return o[r.CommonErrors.DivZero];if(a.length!==u.length)return o[r.CommonErrors.NA];var l=function(r){r=e.getDataCollection(r);for(var t=0;t<r.length;t++)if(o.indexOf(r[t])>-1)return r[t].toString();return r};if(a=l(a),o.indexOf(a.toString())>-1)return a.toString();if(u=l(u),o.indexOf(u.toString())>-1)return u.toString();for(var h=0,p=0,g=0,f=0,m=0,c=0,d=u.length;c<d;++c)""!==u[c]&&"NaN"!==Number(u[c]).toString()&&""!==a[c]&&"NaN"!==Number(a[c]).toString()&&(h+=Number(u[c])*Number(a[c]),g+=Number(u[c]),f+=Number(a[c]),p+=Number(u[c])*Number(u[c]),m++);var v=((h-g*f/m)/(p-g*g/m)).toString();return"NaN"===v?o[r.CommonErrors.DivZero]:v},n.prototype.ComputeINTERCEPT=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0]||""===n[1])return o[r.CommonErrors.Value];var s=function(r){return r=-1===r.indexOf(e.parent.tic)?e.parent.getCellCollection(r.split(e.parent.tic).join("")):void 0},a=s(n[0].trim()),u=s(n[1].trim());if(t.isNullOrUndefined(a)||t.isNullOrUndefined(u)||a.length<2&&u.length<2)return o[r.CommonErrors.DivZero];if(a.length!==u.length)return o[r.CommonErrors.NA];var l=function(r){r=e.getDataCollection(r);for(var t=0;t<r.length;t++)if(o.indexOf(r[t])>-1)return r[t];return r};if(a=l(a),o.indexOf(a.toString())>-1)return a.toString();if(u=l(u),o.indexOf(u.toString())>-1)return u.toString();var h,p=0,g=0,f=0,m=0,c=0,d=function(r){for(var t=0,e=u.length;t<e;++t)""!==a[t]&&"NaN"!==Number(a[t]).toString()&&""!==u[t]&&"NaN"!==Number(u[t]).toString()&&(r?(p+=Number(a[t]),g+=Number(u[t]),f++):(h=Number(u[t])-g,m+=h*(Number(a[t])-p),c+=h*h))};d(!0),p/=f,g/=f,d(!1);var v=(p-m/c*g).toString();return"NaN"===v?o[r.CommonErrors.DivZero]:v},n.prototype.ComputeGEOMEAN=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i,o,s,a=t,u=1,l=0,h=0,p=0;if(0===t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(1===a.length&&""===a[0])return u.toString();var g;for(i=0;i<a.length;i++)if(a[i].indexOf(":")>-1){if(a[0]===this.parent.tic)return this.parent.getErrorStrings()[r.CommonErrors.Value];for(s=this.parent.getCellCollection(a[i].split(this.parent.tic).join("")),o=0;o<s.length;o++){if(h=this.parent.getValueFromArg(s[o]),p=h.split(this.parent.tic).join(""),g=p===this.parent.trueValue||p===this.parent.falseValue,(n=this.parent.parseFloat(h))<=0)return this.parent.getErrorStrings()[r.CommonErrors.Num];g||this.parent.getErrorStrings().indexOf(h)>-1||(isNaN(n)||(l++,u*=n))}}else{if(h=this.parent.getValueFromArg(a[i]),this.parent.getErrorStrings().indexOf(h)>-1)return h;var f=h.split(this.parent.tic).join("");if(h.indexOf('"')>-1&&isNaN(this.parent.parseFloat(f)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(a[i]=a[i].startsWith("n")?a[i].slice(1):a[i],""===h&&""===a[i])return this.parent.getErrorStrings()[r.CommonErrors.Num];if(("TRUE"===f||"FALSE"===f)&&this.parent.isCellReference(a[i]))continue;if(h.length>0){if(h=h.indexOf('"')>-1?f:h,h="TRUE"===h.split(this.parent.tic).join("")?"1":"FALSE"===h.split(this.parent.tic).join("")?"0":h,!this.parent.isCellReference(a[i])&&isNaN(this.parent.parseFloat(h)))return this.parent.getErrorStrings()[r.CommonErrors.Value];if((n=this.parent.parseFloat(h))<=0)return this.parent.getErrorStrings()[r.CommonErrors.Num];isNaN(n)||(l++,u*=n)}}return l>0&&(u=Math.pow(u,1/l)),u.toString()},n.prototype.ComputeRSQ=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=0,i=t;if(2!==i.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i[0]||""===i[1])return this.parent.getErrorStrings()[r.CommonErrors.Value];if(i[0].includes('"')||i[1].includes('"'))return this.parent.getErrorStrings()[r.CommonErrors.NA];if(-1===i[0].indexOf(":")&&p(i[0])&&-1===i[1].indexOf(":")&&p(i[1]))return this.parent.getErrorStrings()[r.CommonErrors.DivZero];var o=this.parent.getCellCollection(i[0]),a=this.parent.getCellCollection(i[1]);if(o.length!==a.length)return this.parent.getErrorStrings()[r.CommonErrors.NA];for(var u=this.getDataCollection(a),l=0;l<u.length;l++)if(this.parent.getErrorStrings().indexOf(u[l])>-1)return u[l];for(var h=this.getDataCollection(o),g=0;g<h.length;g++)if(this.parent.getErrorStrings().indexOf(h[g])>-1)return h[g];for(var f,m,c=0;c<u.length;c++)f=Number(u[c]),m=Number(h[c]),s(f)&&s(m)&&n++;if(n<=1)return this.parent.getErrorStrings()[r.CommonErrors.DivZero];if(2===n)return 1;var d=this.getMeanArray(u,h),v=d[0],N=d[1],E=this.getCorrelation(u,h,v,N);return Math.pow(E,2)},n.prototype.getCorrelation=function(r,t,e,n){for(var i,o,a=0,u=0,l=0,h=0;h<r.length;h++)s(r[h])&&s(t[h])&&(a+=(o=Number(r[h])-e)*(i=Number(t[h])-n),u+=Math.pow(o,2),l+=Math.pow(i,2));return a/Math.sqrt(u*l)},n.prototype.getMeanArray=function(r,t){for(var e=0,n=0,i=0,o=0,a=0,u=0;u<r.length;u++)s(r[u])&&s(t[u])&&(n+=Number(r[u]),i+=Number(t[u]),e++);return o=n/e,a=i/e,[o,a]},n.prototype.getDataCollection=function(r){for(var t=[],e=0,n=r.length;e<n;e++)t.push(this.parent.getValueFromArg(r[e]));return t},n}(Q),Pr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),_r=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"STDEV",category:"Statistical",description:"Estimates standard deviation based on a sample."},{formulaName:"STDEVP",category:"Statistical",description:"Calculates standard deviation based on the entire population."},{formulaName:"VAR",category:"Statistical",description:"Estimates variance based on a sample."},{formulaName:"VARP",category:"Statistical",description:"Calculates variance based on the entire population."},{formulaName:"MODE",category:"Statistical",description:"Returns the most common value in a data set."},{formulaName:"RANK",category:"Statistical",description:"Returns the rank of a number in a list of numbers."},{formulaName:"MAXA",category:"Statistical",description:"Returns the maximum value in a list of arguments, including text and logicals."},{formulaName:"MINA",category:"Statistical",description:"Returns the minimum value in a list of arguments, including text and logicals."}],t}return Pr(n,e),n.prototype.collectSample=function(t,e){for(var n=this.parent.getErrorStrings(),i=[],o=0;o<t.length;o++){var s=t[o];if(""!==s)if(this.parent.isCellReference(s)&&s.indexOf(":")>-1)for(var a=this.parent.getCellCollection(s),u=Array.isArray(a)?a:[a],l=0;l<u.length;l++){h=this.parent.getValueFromArg(u[l]);if(n.indexOf(h)>-1)return h;""!==h&&((p=h.toUpperCase())===this.parent.trueValue?i.push(1):p===this.parent.falseValue?i.push(0):this.parent.isNumber(h)?i.push(this.parent.parseFloat(h)):e&&i.push(0))}else{var h=this.parent.getValueFromArg(s);if(n.indexOf(h)>-1)return h;var p=h.toUpperCase();if(p===this.parent.trueValue)i.push(1);else if(p===this.parent.falseValue)i.push(0);else{if(""===h)continue;if(this.parent.isNumber(this.parent.removeTics(h)))i.push(this.parent.parseFloat(this.parent.removeTics(h)));else{if(!e)return n[r.CommonErrors.Value];i.push(0)}}}}return i},n.prototype.variance=function(r,t){for(var e=r.reduce(function(r,t){return r+t},0)/r.length,n=0,i=0;i<r.length;i++){var o=r[i]-e;n+=o*o}return n/(t?r.length:r.length-1)},n.prototype.ComputeSTDEV=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!1,!1)},n.prototype.ComputeSTDEVP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!0,!1)},n.prototype.ComputeVAR=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!1,!0)},n.prototype.ComputeVARP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVar(r,!0,!0)},n.prototype.stdevVar=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var s=this.collectSample(e,!1);if("string"==typeof s)return s;if(s.length<(n?1:2))return o[r.CommonErrors.DivZero];var a=this.variance(s,n);return(i?a:Math.sqrt(a)).toString()},n.prototype.ComputeMODE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e,!1);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.Value];for(var s=new Map,a=o[0],u=0,l=0;l<o.length;l++){var h=o[l],p=(s.get(h)||0)+1;s.set(h,p),p>u&&(u=p,a=h)}return u<2?i[r.CommonErrors.NA]:a.toString()},n.prototype.ComputeRANK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=this.collectSample([e[1]],!1);if("string"==typeof s)return s;var a=0;if(3===e.length&&""!==e[2]){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a=u}var l=s.slice().sort(function(r,t){return a?r-t:t-r}).indexOf(o);return l<0?i[r.CommonErrors.NA]:(l+1).toString()},n.prototype.ComputeMAXA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.minMaxA(r,!0)},n.prototype.ComputeMINA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.minMaxA(r,!1)},n.prototype.minMaxA=function(e,n){if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i=this.collectSample(e,!0);if("string"==typeof i)return i;if(0===i.length)return"0";for(var o=i[0],s=1;s<i.length;s++)(n?i[s]>o:i[s]<o)&&(o=i[s]);return o.toString()},n}(Q),Wr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),qr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Wr(e,t),e.prototype.collectSample=function(t,e){void 0===e&&(e=!1);for(var n=this.parent.getErrorStrings(),i=[],o=0;o<t.length;o++){var s=t[o];if(""!==s)if(this.parent.isCellReference(s)&&s.indexOf(":")>-1)for(var a=this.parent.getCellCollection(s),u=Array.isArray(a)?a:[a],l=0;l<u.length;l++){h=this.parent.getValueFromArg(u[l]);if(n.indexOf(h)>-1)return h;""!==h&&((p=h.toUpperCase())===this.parent.trueValue?i.push(1):p===this.parent.falseValue?i.push(0):this.parent.isNumber(h)?i.push(this.parent.parseFloat(h)):e&&i.push(0))}else{var h=this.parent.getValueFromArg(s);if(n.indexOf(h)>-1)return h;var p=h.toUpperCase();if(p===this.parent.trueValue)i.push(1);else if(p===this.parent.falseValue)i.push(0);else{if(""===h)continue;if(this.parent.isNumber(this.parent.removeTics(h)))i.push(this.parent.parseFloat(this.parent.removeTics(h)));else{if(!e)return n[r.CommonErrors.Value];i.push(0)}}}}return i},e.prototype.collectPair=function(t){var e=this.parent.getErrorStrings();if(2!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var n=this.parent.getCellCollection(t[0]),i=this.parent.getCellCollection(t[1]),o=Array.isArray(n)?n:[n],s=Array.isArray(i)?i:[i];if(o.length!==s.length)return e[r.CommonErrors.NA];for(var a=[],u=[],l=0;l<o.length;l++){var h=this.parent.getValueFromArg(o[l]),p=this.parent.getValueFromArg(s[l]);if(e.indexOf(h)>-1)return h;if(e.indexOf(p)>-1)return p;""!==h&&""!==p&&this.parent.isNumber(h)&&this.parent.isNumber(p)&&(a.push(this.parent.parseFloat(h)),u.push(this.parent.parseFloat(p)))}return{x:a,y:u}},e.prototype.mean=function(r){return r.reduce(function(r,t){return r+t},0)/r.length},e}(Q),Br=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Xr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"AVEDEV",category:"Statistical",description:"Returns the average of the absolute deviations of data points from their mean."},{formulaName:"DEVSQ",category:"Statistical",description:"Returns the sum of squares of deviations."},{formulaName:"HARMEAN",category:"Statistical",description:"Returns the harmonic mean."},{formulaName:"SKEW",category:"Statistical",description:"Returns the skewness of a distribution."},{formulaName:"KURT",category:"Statistical",description:"Returns the kurtosis of a data set."},{formulaName:"STANDARDIZE",category:"Statistical",description:"Returns a normalized value from a distribution."}],t}return Br(n,e),n.prototype.ComputeAVEDEV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.DivZero];for(var s=this.mean(o),a=0,u=0;u<o.length;u++)a+=Math.abs(o[u]-s);return(a/o.length).toString()},n.prototype.ComputeDEVSQ=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.DivZero];for(var s=this.mean(o),a=0,u=0;u<o.length;u++){var l=o[u]-s;a+=l*l}return a.toString()},n.prototype.ComputeHARMEAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;if(0===o.length)return i[r.CommonErrors.DivZero];for(var s=0,a=0;a<o.length;a++){if(o[a]<=0)return i[r.CommonErrors.Num];s+=1/o[a]}return(o.length/s).toString()},n.prototype.ComputeSKEW=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;var s=o.length;if(s<3)return i[r.CommonErrors.DivZero];for(var a=this.mean(o),u=0,l=0,h=0;h<s;h++){var p=o[h]-a;u+=p*p,l+=p*p*p}return u/=s,l/=s,0===u?i[r.CommonErrors.DivZero]:(l/Math.pow(u,1.5)*Math.sqrt(s*(s-1))/(s-2)).toString()},n.prototype.ComputeKURT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var o=this.collectSample(e);if("string"==typeof o)return o;var s=o.length;if(s<4)return i[r.CommonErrors.DivZero];for(var a=this.mean(o),u=0,l=0,h=0;h<s;h++){var p=o[h]-a;u+=p*p,l+=p*p*p*p}return u/=s,l/=s,0===u?i[r.CommonErrors.DivZero]:(s*(s+1)/((s-1)*(s-2)*(s-3))*(l/(u*u))-3*(s-1)*(s-1)/((s-2)*(s-3))).toString()},n.prototype.ComputeSTANDARDIZE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);return"string"==typeof o?o:"string"==typeof s?s:"string"==typeof a?a:a<=0?i[r.CommonErrors.Num]:((o-s)/a).toString()},n}(qr),Yr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Hr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CORREL",category:"Statistical",description:"Returns the correlation coefficient between two data sets."},{formulaName:"COVAR",category:"Statistical",description:"Returns covariance, the average of the products of paired deviations."},{formulaName:"PEARSON",category:"Statistical",description:"Returns the Pearson product moment correlation coefficient."},{formulaName:"FORECAST",category:"Statistical",description:"Returns a value along a linear trend."},{formulaName:"STEYX",category:"Statistical",description:"Returns the standard error of the predicted y-value for each x in the regression."}],t}return Yr(n,e),n.prototype.regressionStats=function(e){var n=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.collectPair(e);if("string"==typeof i)return i;var o=i.x,s=i.y;if(o.length<2)return n[r.CommonErrors.DivZero];for(var a=this.mean(o),u=this.mean(s),l=0,h=0,p=0,g=0;g<o.length;g++){var f=o[g]-a,m=s[g]-u;l+=f*f,h+=m*m,p+=f*m}return{n:o.length,meanX:a,meanY:u,sxx:l,syy:h,sxy:p}},n.prototype.ComputeCORREL=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.regressionStats(t);return"string"==typeof i?i:0===i.sxx||0===i.syy?n[r.CommonErrors.DivZero]:(i.sxy/Math.sqrt(i.sxx*i.syy)).toString()},n.prototype.ComputePEARSON=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeCORREL.apply(this,r)},n.prototype.ComputeCOVAR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.regressionStats(t);return"string"==typeof i?i:i.n<2?n[r.CommonErrors.DivZero]:(i.sxy/(i.n-1)).toString()},n.prototype.ComputeFORECAST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=this.regressionStats([e[2],e[1]]);if("string"==typeof s)return s;if(0===s.sxx)return i[r.CommonErrors.DivZero];var a=s.sxy/s.sxx;return(s.meanY-a*s.meanX+a*o).toString()},n.prototype.ComputeSTEYX=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.regressionStats([t[1],t[0]]);if("string"==typeof i)return i;if(i.n<=2||0===i.sxx)return n[r.CommonErrors.DivZero];var o=i.syy-i.sxy*i.sxy/i.sxx;return Math.sqrt(o/(i.n-2)).toString()},n}(qr),Gr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Zr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"PERCENTILE",category:"Statistical",description:"Returns the k-th percentile of values in a range."},{formulaName:"PERCENTRANK",category:"Statistical",description:"Returns the percentage rank of a value in a data set."},{formulaName:"QUARTILE",category:"Statistical",description:"Returns the quartile of a data set."}],t}return Gr(n,e),n.prototype.sortedSample=function(e){if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var n=this.collectSample(e);return"string"==typeof n?n:n.slice().sort(function(r,t){return r-t})},n.prototype.percentile=function(t,e){var n=this.parent.getErrorStrings();if(e<0||e>1)return n[r.CommonErrors.Num];if(0===t.length)return n[r.CommonErrors.Num];var i=t.length,o=e*(i-1),s=Math.floor(o),a=o-s;return s>=i-1?t[i-1]:t[s]+a*(t[s+1]-t[s])},n.prototype.ComputePERCENTILE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;var o=this.sortedSample([e[0]]);if("string"==typeof o)return o;var s=this.percentile(o,i);return"string"==typeof s?s:s.toString()},n.prototype.ComputePERCENTRANK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=this.sortedSample([e[1]]);if("string"==typeof s)return s;if(0===s.length)return i[r.CommonErrors.Num];var a=0,u=1;if(3===e.length){var l=this.resolveNumberArg(e[2]);if("string"==typeof l)return l;a=l,u=1-l}if(o<s[0])return a.toString();if(o>s[s.length-1])return u.toString();for(var h=0,p=0;p<s.length;p++){if(s[p]===o){h=p/(s.length-1||1);break}if(s[p]>o){h=(p-1+(o-s[p-1])/(s[p]-s[p-1]))/(s.length-1);break}}return h.toString()},n.prototype.ComputeQUARTILE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;var s=Math.floor(o);if(s<0||s>4)return i[r.CommonErrors.Num];var a={0:0,1:.25,2:.5,3:.75,4:1},u=this.sortedSample([e[0]]);if("string"==typeof u)return u;var l=this.percentile(u,a[s]);return"string"==typeof l?l:l.toString()},n}(qr),Kr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),$r=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"NORMDIST",category:"Statistical",description:"Returns the normal cumulative distribution."},{formulaName:"NORMSDIST",category:"Statistical",description:"Returns the standard normal cumulative distribution."},{formulaName:"NORMINV",category:"Statistical",description:"Returns the inverse of the normal cumulative distribution."},{formulaName:"NORMSINV",category:"Statistical",description:"Returns the inverse of the standard normal cumulative distribution."},{formulaName:"POISSON",category:"Statistical",description:"Returns the Poisson distribution."},{formulaName:"BINOMDIST",category:"Statistical",description:"Returns the individual term binomial distribution probability."},{formulaName:"EXPONDIST",category:"Statistical",description:"Returns the exponential distribution."},{formulaName:"CONFIDENCE",category:"Statistical",description:"Returns the confidence interval for a population mean."}],t}return Kr(n,e),n.prototype.ComputeNORMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(a<=0)return i[r.CommonErrors.Num];var u=!0;if(4===e.length){var l=this.resolveNumberArg(e[3]);if("string"==typeof l)return l;u=0!==l}if(u)return m(o,s,a).toString();var h=(o-s)/a;return(Math.exp(-.5*h*h)/(a*Math.sqrt(2*Math.PI))).toString()},n.prototype.ComputeNORMSDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);return"string"==typeof i?i:m(i).toString()},n.prototype.ComputeNORMINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=c(o,s,a);return isNaN(u)?i[r.CommonErrors.Num]:u.toString()},n.prototype.ComputeNORMSINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=c(o);return isNaN(s)?i[r.CommonErrors.Num]:s.toString()},n.prototype.ComputePOISSON=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(o);if(a<0||s<0)return i[r.CommonErrors.Num];var u=!0;if(3===e.length){var l=this.resolveNumberArg(e[2]);if("string"==typeof l)return l;u=0!==l}if(!u)return(Math.exp(-s)*Math.pow(s,a)/N(a)).toString();for(var h=0,p=0;p<=a;p++)h+=Math.exp(-s)*Math.pow(s,p)/N(p);return h.toString()},n.prototype.ComputeBINOMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(o),l=Math.floor(s);if(u<0||l<0||u>l||a<0||a>1)return i[r.CommonErrors.Num];var h=!0;if(4===e.length){var p=this.resolveNumberArg(e[3]);if("string"==typeof p)return p;h=0!==p}var g=E(l,u)*Math.pow(a,u)*Math.pow(1-a,l-u);if(!h)return g.toString();for(var f=0,m=0;m<=u;m++)f+=E(l,m)*Math.pow(a,m)*Math.pow(1-a,l-m);return f.toString()},n.prototype.ComputeEXPONDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;if(o<0||s<=0)return i[r.CommonErrors.Num];var a=!0;if(3===e.length){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a=0!==u}return a?(1-Math.exp(-s*o)).toString():(s*Math.exp(-s*o)).toString()},n.prototype.ComputeCONFIDENCE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<=0||o>=1||s<=0||a<1)return i[r.CommonErrors.Num];var u=c(1-o/2);return isNaN(u)?i[r.CommonErrors.Num]:(u*s/Math.sqrt(a)).toString()},n}(qr),zr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Qr=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"MAXIFS",category:"Statistical",description:"Returns the maximum value among cells specified by criteria."},{formulaName:"MINIFS",category:"Statistical",description:"Returns the minimum value among cells specified by criteria."}],t}return zr(n,e),n.prototype.ComputeMAXIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.aggregateIfs(r,!0)},n.prototype.ComputeMINIFS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.aggregateIfs(r,!1)},n.prototype.aggregateIfs=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length%2==0)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o=e[0],s=this.parent.getCellCollection(o),a=Array.isArray(s)?s:[s],u=[],l=1;l<e.length;l+=2)u.push([e[l],e[l+1]]);for(var h=[],p=0;p<u.length;p++){var g=this.parent.getCellCollection(u[p][0]),f=Array.isArray(g)?g:[g];if(f.length!==a.length)return i[r.CommonErrors.Value];h.push(f)}for(var m=null,c=!1,l=0;l<a.length;l++){for(var d=!0,p=0;p<u.length;p++){var v=this.parent.getValueFromArg(h[p][l]);if(!this.matchesCriteria(v,u[p][1])){d=!1;break}}if(d){var N=this.parent.getValueFromArg(a[l]);if(i.indexOf(N)>-1)return N;if(""!==N&&this.parent.isNumber(N)){var E=this.parent.parseFloat(N);c=!0,null===m?m=E:(n?E>m:E<m)&&(m=E)}}}return c&&null!==m?m.toString():"0"},n.prototype.matchesCriteria=function(r,t){var e=t.trim();e.startsWith(this.parent.tic)&&e.endsWith(this.parent.tic)?e=this.parent.removeTics(e):this.parent.isCellReference(e)?e=this.parent.getValueFromArg(e):(e=this.parent.getValueFromArg(e),this.parent.isCellReference(t)||(e=this.parent.removeTics(e)));var n="equal";return e.startsWith("<=")?(n="lessEq",e=e.substring(2)):e.startsWith(">=")?(n="greaterEq",e=e.substring(2)):e.startsWith("<>")?(n="notEq",e=e.substring(2)):e.startsWith("<")?(n="less",e=e.substring(1)):e.startsWith(">")?(n="greater",e=e.substring(1)):e.startsWith("=")&&(n="equal",e=e.substring(1)),(e=e.trim()).startsWith(this.parent.tic)&&(e=this.parent.removeTics(e)),this.parent.processLogical([r.toLowerCase(),e.toLowerCase()],n)===this.parent.trueValue},n}(Q),Jr=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),rt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"STDEVA",category:"Statistical",description:"Estimates standard deviation based on a sample, including text and logicals."},{formulaName:"STDEVPA",category:"Statistical",description:"Calculates standard deviation based on the entire population, including text and logicals."},{formulaName:"VARA",category:"Statistical",description:"Estimates variance based on a sample, including text and logicals."},{formulaName:"VARPA",category:"Statistical",description:"Calculates variance based on the entire population, including text and logicals."},{formulaName:"TRIMMEAN",category:"Statistical",description:"Returns the mean of the interior of a data set."},{formulaName:"FISHER",category:"Statistical",description:"Returns the Fisher transformation."},{formulaName:"FISHERINV",category:"Statistical",description:"Returns the inverse of the Fisher transformation."},{formulaName:"GAMMALN",category:"Statistical",description:"Returns the natural logarithm of the gamma function."},{formulaName:"SUMX2MY2",category:"Statistical",description:"Returns the sum of the difference of squares of corresponding values in two arrays."},{formulaName:"SUMX2PY2",category:"Statistical",description:"Returns the sum of the sum of squares of corresponding values in two arrays."},{formulaName:"SUMXMY2",category:"Statistical",description:"Returns the sum of squares of differences of corresponding values in two arrays."}],t}return Jr(n,e),n.prototype.stdevVarA=function(e,n,i){var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var s=this.collectSample(e,!0);if("string"==typeof s)return s;if(s.length<(n?1:2))return o[r.CommonErrors.DivZero];for(var a=this.mean(s),u=0,l=0;l<s.length;l++){var h=s[l]-a;u+=h*h}var p=u/(n?s.length:s.length-1);return(i?p:Math.sqrt(p)).toString()},n.prototype.ComputeSTDEVA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!1,!1)},n.prototype.ComputeSTDEVPA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!0,!1)},n.prototype.ComputeVARA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!1,!0)},n.prototype.ComputeVARPA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.stdevVarA(r,!0,!0)},n.prototype.ComputeTRIMMEAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if(o<0||o>=1)return i[r.CommonErrors.Num];var s=this.collectSample([e[0]],!1);if("string"==typeof s)return s;if(0===s.length)return i[r.CommonErrors.DivZero];var a=s.slice().sort(function(r,t){return r-t}),u=Math.floor(a.length*o/2),l=a.slice(u,a.length-u);return 0===l.length?i[r.CommonErrors.DivZero]:this.mean(l).toString()},n.prototype.ComputeFISHER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);return"string"==typeof o?o:o<=-1||o>=1?i[r.CommonErrors.Num]:(.5*Math.log((1+o)/(1-o))).toString()},n.prototype.ComputeFISHERINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=Math.exp(2*i);return((o-1)/(o+1)).toString()},n.prototype.ComputeGAMMALN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;if(o<=0)return i[r.CommonErrors.Num];var s=S(o);return isFinite(s)?s.toString():i[r.CommonErrors.Num]},n.prototype.sumSquaresPair=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectPair(e);if("string"==typeof o)return o;var s=o.x,a=o.y;if(0===s.length)return i[r.CommonErrors.DivZero];for(var u=0,l=0;l<s.length;l++)if("x2my2"===n)u+=s[l]*s[l]-a[l]*a[l];else if("x2py2"===n)u+=s[l]*s[l]+a[l]*a[l];else{var h=s[l]-a[l];u+=h*h}return u.toString()},n.prototype.ComputeSUMX2MY2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.sumSquaresPair(r,"x2my2")},n.prototype.ComputeSUMX2PY2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.sumSquaresPair(r,"x2py2")},n.prototype.ComputeSUMXMY2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.sumSquaresPair(r,"xmy2")},n}(qr),tt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),et=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CRITBINOM",category:"Statistical",description:"Returns the smallest value for which the cumulative binomial distribution is less than or equal to a criterion value."},{formulaName:"NEGBINOMDIST",category:"Statistical",description:"Returns the negative binomial distribution."},{formulaName:"HYPGEOMDIST",category:"Statistical",description:"Returns the hypergeometric distribution."},{formulaName:"WEIBULL",category:"Statistical",description:"Returns the Weibull distribution."},{formulaName:"LOGNORMDIST",category:"Statistical",description:"Returns the cumulative log-normal distribution."},{formulaName:"LOGINV",category:"Statistical",description:"Returns the inverse of the log-normal cumulative distribution."},{formulaName:"GAMMADIST",category:"Statistical",description:"Returns the gamma distribution."},{formulaName:"GAMMAINV",category:"Statistical",description:"Returns the inverse of the gamma cumulative distribution."},{formulaName:"CHIDIST",category:"Statistical",description:"Returns the one-tailed probability of the chi-squared distribution."},{formulaName:"CHIINV",category:"Statistical",description:"Returns the inverse of the one-tailed probability of the chi-squared distribution."},{formulaName:"CHITEST",category:"Statistical",description:"Returns the test for independence."},{formulaName:"FDIST",category:"Statistical",description:"Returns the F probability distribution."},{formulaName:"FINV",category:"Statistical",description:"Returns the inverse of the F probability distribution."},{formulaName:"ZTEST",category:"Statistical",description:"Returns the one-tailed probability-value of a z-test."},{formulaName:"PROB",category:"Statistical",description:"Returns the probability that values in a range are between two limits."}],t}return tt(n,e),n.prototype.parseCumulative=function(r,t){if(r.length<=t)return!0;var e=this.resolveNumberArg(r[t]);return"string"==typeof e?e:0!==e},n.prototype.ComputeCRITBINOM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(o),l=s;if(u<0||l<0||l>1||a<0||a>1)return i[r.CommonErrors.Num];for(var h=0,p=0;p<=u;p++)if((h+=E(u,p)*Math.pow(l,p)*Math.pow(1-l,u-p))>=a)return p.toString();return u.toString()},n.prototype.ComputeNEGBINOMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(o),l=Math.floor(s);return u<0||l<1||a<=0||a>1?i[r.CommonErrors.Num]:(E(u+l-1,l-1)*Math.pow(a,l)*Math.pow(1-a,u)).toString()},n.prototype.ComputeHYPGEOMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=Math.floor(o),h=Math.floor(s),p=Math.floor(a),g=Math.floor(u);if(l<0||l>h||h>g||p>g)return i[r.CommonErrors.Num];var f=this.parseCumulative(e,4);if("string"==typeof f)return f;var m=E(p,l)*E(g-p,h-l)/E(g,h);if(!f)return m.toString();for(var c=0,d=0;d<=l;d++)c+=E(p,d)*E(g-p,h-d)/E(g,h);return c.toString()},n.prototype.ComputeWEIBULL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<0||s<=0||a<=0)return i[r.CommonErrors.Num];var u=this.parseCumulative(e,3);return"string"==typeof u?u:u?(1-Math.exp(-Math.pow(o/a,s))).toString():(s/Math.pow(a,s)*Math.pow(o,s-1)*Math.exp(-Math.pow(o/a,s))).toString()},n.prototype.ComputeLOGNORMDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=U(i,o,s);return isNaN(a)?this.parent.getErrorStrings()[r.CommonErrors.Num]:a.toString()},n.prototype.ComputeLOGINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=w(i,o,s);return isNaN(a)?this.parent.getErrorStrings()[r.CommonErrors.Num]:a.toString()},n.prototype.ComputeGAMMADIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<0||s<=0||a<=0)return i[r.CommonErrors.Num];var u=this.parseCumulative(e,3);if("string"==typeof u)return u;var l=o/a;return u?C(s,l).toString():(Math.pow(l,s-1)*Math.exp(-l)/(a*y(s))).toString()},n.prototype.ComputeGAMMAINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if(o<=0||o>=1||s<=0||a<=0)return i[r.CommonErrors.Num];for(var u=0,l=s*a*20+1,h=0;h<100;h++){var p=(u+l)/2;C(s,p/a)<o?u=p:l=p}return((u+l)/2).toString()},n.prototype.ComputeCHIDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);return"string"==typeof i?i:"string"==typeof o?o:(1-b(i,o)).toString()},n.prototype.ComputeCHIINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=A(1-i,o);return isNaN(s)?this.parent.getErrorStrings()[r.CommonErrors.Num]:s.toString()},n.prototype.ComputeCHITEST=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.chiSquareTest(r)},n.prototype.chiSquareTest=function(e){var n=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.collectSample([e[0]],!1),o=this.collectSample([e[1]],!1);if("string"==typeof i)return i;if("string"==typeof o)return o;if(i.length!==o.length||0===i.length)return n[r.CommonErrors.NA];for(var s=0,a=0;a<i.length;a++){if(0===o[a])return n[r.CommonErrors.DivZero];var u=i[a]-o[a];s+=u*u/o[a]}return(1-b(s,i.length-1)).toString()},n.prototype.ComputeFDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);return"string"==typeof i?i:"string"==typeof o?o:"string"==typeof s?s:(1-O(i,o,s)).toString()},n.prototype.ComputeFINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=x(1-i,o,s);return isNaN(a)?this.parent.getErrorStrings()[r.CommonErrors.Num]:a.toString()},n.prototype.ComputeZTEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1);if("string"==typeof o)return o;if(o.length<2)return i[r.CommonErrors.DivZero];var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;for(var a=this.mean(o),u=0,l=0;l<o.length;l++){var h=o[l]-a;u+=h*h}var p=Math.sqrt(u/(o.length-1));if(0===p)return i[r.CommonErrors.DivZero];var g=p/Math.sqrt(o.length);if(3===e.length){var f=this.resolveNumberArg(e[2]);if("string"==typeof f)return f;g=f/Math.sqrt(o.length)}return(1-m((a-s)/g)).toString()},n.prototype.ComputePROB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1);if("string"==typeof o)return o;var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof s)return s;if("string"==typeof a)return a;if(0===o.length)return i[r.CommonErrors.Num];for(var u=0,l=0,h=0;h<o.length;h++)u+=1,o[h]>=s&&o[h]<=a&&(l+=1);return(l/u).toString()},n}(qr),nt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),it=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"COMPLEX",category:"Engineering",description:"Converts real and imaginary coefficients into a complex number."},{formulaName:"IMABS",category:"Engineering",description:"Returns the absolute value (modulus) of a complex number."},{formulaName:"IMAGINARY",category:"Engineering",description:"Returns the imaginary coefficient of a complex number."},{formulaName:"IMREAL",category:"Engineering",description:"Returns the real coefficient of a complex number."},{formulaName:"IMCONJUGATE",category:"Engineering",description:"Returns the complex conjugate of a complex number."},{formulaName:"IMSUM",category:"Engineering",description:"Returns the sum of complex numbers."},{formulaName:"IMSUB",category:"Engineering",description:"Returns the difference between two complex numbers."},{formulaName:"IMPRODUCT",category:"Engineering",description:"Returns the product of complex numbers."},{formulaName:"IMDIV",category:"Engineering",description:"Returns the quotient of two complex numbers."},{formulaName:"IMSIN",category:"Engineering",description:"Returns the sine of a complex number."},{formulaName:"IMCOS",category:"Engineering",description:"Returns the cosine of a complex number."},{formulaName:"IMEXP",category:"Engineering",description:"Returns the exponential of a complex number."},{formulaName:"IMLN",category:"Engineering",description:"Returns the natural logarithm of a complex number."},{formulaName:"IMSQRT",category:"Engineering",description:"Returns the square root of a complex number."},{formulaName:"IMPOWER",category:"Engineering",description:"Returns a complex number raised to an integer power."},{formulaName:"IMARGUMENT",category:"Engineering",description:"Returns the argument theta of a complex number in radians."},{formulaName:"IMLOG10",category:"Engineering",description:"Returns the base-10 logarithm of a complex number."},{formulaName:"IMLOG2",category:"Engineering",description:"Returns the base-2 logarithm of a complex number."}],t}return nt(n,e),n.prototype.resolveComplex=function(t){var e=this.parent.getErrorStrings(),n=this.resolveTextArg(t);if(e.indexOf(n)>-1)return n;var i=d(n);return i||e[r.CommonErrors.Num]},n.prototype.ComputeCOMPLEX=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s="i";return 3===e.length&&"i"!==(s=this.resolveTextArg(e[2]))&&"j"!==s?this.parent.getErrorStrings()[r.CommonErrors.Value]:v(i,o,s)},n.prototype.ComputeIMABS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:Math.sqrt(i.re*i.re+i.im*i.im).toString()},n.prototype.ComputeIMAGINARY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:i.im.toString()},n.prototype.ComputeIMREAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:i.re.toString()},n.prototype.ComputeIMCONJUGATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:v(i.re,-i.im)},n.prototype.ComputeIMSUM=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.complexReduce(r,function(r,t){return{re:r.re+t.re,im:r.im+t.im}})},n.prototype.ComputeIMSUB=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]),o=this.resolveComplex(e[1]);return"string"==typeof i?i:"string"==typeof o?o:v(i.re-o.re,i.im-o.im)},n.prototype.ComputeIMPRODUCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.complexReduce(r,function(r,t){return{re:r.re*t.re-r.im*t.im,im:r.re*t.im+r.im*t.re}},{re:1,im:0})},n.prototype.ComputeIMDIV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveComplex(e[0]),s=this.resolveComplex(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=s.re*s.re+s.im*s.im;return 0===a?i[r.CommonErrors.DivZero]:v((o.re*s.re+o.im*s.im)/a,(o.im*s.re-o.re*s.im)/a)},n.prototype.complexReduce=function(e,n,i){if(t.isNullOrUndefined(e)||e.length<1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=void 0!==i?i:this.resolveComplex(e[0]);if("string"==typeof o)return o;for(var s=i?0:1;s<e.length;s++){var a=this.resolveComplex(e[s]);if("string"==typeof a)return a;o=n(o,a)}return v(o.re,o.im)},n.prototype.ComputeIMEXP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);if("string"==typeof i)return i;var o=Math.exp(i.re);return v(o*Math.cos(i.im),o*Math.sin(i.im))},n.prototype.ComputeIMLN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);if("string"==typeof i)return i;var o=Math.sqrt(i.re*i.re+i.im*i.im);return 0===o?this.parent.getErrorStrings()[r.CommonErrors.Num]:v(Math.log(o),Math.atan2(i.im,i.re))},n.prototype.ComputeIMLOG10=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeIMLN.apply(this,r);if("string"==typeof e&&this.parent.getErrorStrings().indexOf(e)>-1)return e;var n=d(e.toString());if(!n)return e;var i=1/Math.LN10;return v(n.re*i,n.im*i)},n.prototype.ComputeIMLOG2=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeIMLN.apply(this,r);if("string"==typeof e&&this.parent.getErrorStrings().indexOf(e)>-1)return e;var n=d(e.toString());if(!n)return e;var i=1/Math.LN2;return v(n.re*i,n.im*i)},n.prototype.ComputeIMSQRT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);if("string"==typeof i)return i;var o=Math.sqrt(i.re*i.re+i.im*i.im),s=Math.atan2(i.im,i.re),a=Math.sqrt(o);return v(a*Math.cos(s/2),a*Math.sin(s/2))},n.prototype.ComputeIMPOWER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveComplex(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.floor(s),u=Math.sqrt(o.re*o.re+o.im*o.im);if(0===u&&a<=0)return i[r.CommonErrors.Num];var l=Math.atan2(o.im,o.re),h=Math.pow(u,a),p=a*l;return v(h*Math.cos(p),h*Math.sin(p))},n.prototype.ComputeIMARGUMENT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:0===i.re&&0===i.im?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:Math.atan2(i.im,i.re).toString()},n.prototype.ComputeIMSIN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:v(Math.sin(i.re)*Math.cosh(i.im),Math.cos(i.re)*Math.sinh(i.im))},n.prototype.ComputeIMCOS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveComplex(e[0]);return"string"==typeof i?i:v(Math.cos(i.re)*Math.cosh(i.im),-Math.sin(i.re)*Math.sinh(i.im))},n}(Q),ot=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),st=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DATE",category:"Date",description:"Returns the date, given the year, month and day of the month."},{formulaName:"DAY",category:"Date",description:"Returns the day of a given date."},{formulaName:"TODAY",category:"Date",description:"Returns the current date as date value."},{formulaName:"DAYS",category:"Date",description:"Returns the number of days between two dates."},{formulaName:"WEEKDAY",category:"Date",description:"Returns the day of the week corresponding to a date."},{formulaName:"TIME",category:"Date & Time",description:"Converts hours, minutes, seconds to the time formatted text."},{formulaName:"EDATE",category:"Date & Time",description:"Returns a date with given number of months before or after the specified date."},{formulaName:"EOMONTH",category:"Date & Time",description:"Returns the last day of the month that is a specified number of months before or after an initially supplied start date."},{formulaName:"DATEVALUE",category:"Date & Time",description:"Converts a date string into date value."},{formulaName:"HOUR",category:"Date & Time",description:"Returns the number of hours in a specified time string."},{formulaName:"MINUTE",category:"Date & Time",description:"Returns the number of minutes in a specified time string."},{formulaName:"SECOND",category:"Date & Time",description:"Returns the number of seconds in a specified time string."},{formulaName:"NOW",category:"Date & Time",description:"Returns the current date and time."},{formulaName:"MONTH",category:"Date & Time",description:"Returns the number of months in a specified date string."}],t}return ot(n,e),n.prototype.ComputeDATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o=[],s=0;s<e.length;++s)o[s]=this.parent.getValueFromArg(e[s]);o[0]=o[0]===this.parent.trueValue?"1":o[0]===this.parent.falseValue?"0":o[0],o[1]=o[1]===this.parent.trueValue?"1":o[1]===this.parent.falseValue?"0":o[1],o[2]=o[2]===this.parent.trueValue?"1":o[2]===this.parent.falseValue?"0":o[2];for(var a=0;a<o.length;a++){var u=o[a];if(this.parent.getErrorStrings().indexOf(u)>-1)return u;if('""'===u||'"0"'===u&&'"0"'!==e[a]||'"TRUE"'===u||'"FALSE"'===u)return this.parent.getErrorStrings()[r.CommonErrors.Value].toString()}var l=Math.floor(this.parent.parseFloat(o[0].split(this.parent.tic).join(""))),h=Math.floor(this.parent.parseFloat(o[1].split(this.parent.tic).join(""))),p=Math.floor(this.parent.parseFloat(o[2].split(this.parent.tic).join(""))),g=0;if(isNaN(l)||isNaN(h)||isNaN(p))return this.parent.getErrorStrings()[r.CommonErrors.Value].toString();if(l<0&&h<=12||l>=1e4&&h>0)return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();for(;h>12;)h-=12,l++;if(0===(g=this.parent.getSerialDateFromDate(l,h,p)))return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();var f=this.parent.fromOADate(g);if("Invalid Date"!==f.toString()){if(f.getFullYear()<1900||1e4<=f.getFullYear())return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();if(!i)return new t.Internationalization(this.parent.parentObject.locale||"en-US").formatDate(f,{type:"date",skeleton:"yMd"})}return g.toString()},n.prototype.ComputeDAY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(e[0].startsWith(this.parent.tic)){if(""===(o=e[0].split(this.parent.tic).join(""))||o===this.parent.trueValue||o===this.parent.falseValue)return s[r.CommonErrors.Value]}else if(o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join("")),this.parent.isCellReference(e[0])&&o.indexOf(this.parent.tic)>-1)return s[r.CommonErrors.Value];return s.indexOf(o)>-1?o:Number(o)<0?s[r.CommonErrors.Num]:0===Math.floor(Number(o))||o===this.parent.falseValue?0:o===this.parent.trueValue?1:(i=this.parent.isNaN(Number(o))?this.parent.parseDate(o):this.parent.intToDate(o),"[object Date]"===Object.prototype.toString.call(i)&&(i=new Date(i).getFullYear()<1900||new Date(i).getFullYear()>9999?this.parent.isNumber(o)?"Num":"NaN":i.getDate()),"NaN"===i.toString()?s[r.CommonErrors.Value]:"Num"===i.toString()?s[r.CommonErrors.Num]:i)},n.prototype.ComputeTODAY=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n;if(1!==t.length||""!==t[0])n=this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];else{var i=new Date(Date.now());"spreadsheet"===this.parent.parentObject.getModuleName()?(n=a(i).toString(),0===this.parent.parser.storedStringText.toUpperCase().indexOf("TODAY")&&""!==this.parent.cell&&this.parent.parentObject.setDateFormat(this.parent.getSheetId(this.parent.grid),this.parent.rowIndex(this.parent.cell)-1,this.parent.colIndex(this.parent.cell)-1)):n=i.getFullYear()+"/"+this.parent.calculateDate((i.getMonth()+1).toString())+"/"+this.parent.calculateDate(i.getDate().toString())}return n},n.prototype.ComputeDAYS=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)&&1===n.length&&""===n[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=function(t){var n=e.parent.getValueFromArg(t).trim();if(n.indexOf(e.parent.tic)>-1&&(""===(n=n.split(e.parent.tic).join("").trim())||e.parent.isCellReference(t)||n.toUpperCase()===e.parent.trueValue||n.toUpperCase()===e.parent.falseValue))return o[r.CommonErrors.Value];if((n=n.split(e.parent.tic).join("")).toUpperCase()===e.parent.trueValue)n="1";else if(""===n||n.toUpperCase()===e.parent.falseValue)n="0";else if(Number(n)<0)return o[r.CommonErrors.Num];var i=e.parent.hostParseDate(n.toString());return(i.isDate||i.isTime)&&(n=(e.parent.parseDate(n).getTime()/864e5).toString()),n},a=s(n[0]);if(o.indexOf(a)>-1)return a;var u=s(n[1]);if(o.indexOf(u)>-1)return u;var l=Math.floor(Number(a))-Math.floor(Number(u));return isNaN(l)?o[r.CommonErrors.Value]:l},n.prototype.ComputeWEEKDAY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(""===e[0]&&t.isNullOrUndefined(e[1])||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0]&&""===e[1]||""===e[1])return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();if(1===e.length&&e.push("1"),e[0].indexOf(this.parent.tic)>-1&&""===e[0].split(this.parent.tic).join("").trim()||""===e[1].split(this.parent.tic).join("").trim()||e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var i,o,s;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else i=e[0].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[0].split(this.parent.tic).join("")))?this.parent.getValueFromArg(e[0]):this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0";if(o=this.parent.isCellReference(e[1])?this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0":this.parent.getValueFromArg(e[1].split(this.parent.tic).join("")),this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.getErrorStrings().indexOf(o)>-1)return o;if(i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i,o=o===this.parent.trueValue?"1":o===this.parent.falseValue?"0":o,s=this.parent.parseFloat(i),o=this.parent.parseFloat(o),isNaN(o)||isNaN(s))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(s<0||s>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num].toString();switch(o=parseInt(o.toString(),10),s=s<1?0:Math.floor(s)%7,o){case 1:case 17:s=s<=0?s+7:s;break;case 2:case 11:s=(s-=1)<=0?s+7:s;break;case 3:s=(s-=2)<0?s+7:s;break;case 12:s=(s+=5)>7?s-7:s;break;case 13:s=(s+=4)>7?s-7:s;break;case 14:s=(s+=3)>7?s-7:s;break;case 15:s=(s+=2)>7?s-7:s;break;case 16:s=(s+=1)>7?s-7:s;break;default:s=this.parent.getErrorStrings()[r.CommonErrors.Num].toString()}return s},n.prototype.ComputeTIME=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e[0].indexOf(this.parent.tic)>-1&&""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];if(e[1].indexOf(this.parent.tic)>-1&&""===e[1].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];if(e[2].indexOf(this.parent.tic)>-1&&""===e[2].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var o,s,a;if(this.parent.isCellReference(e[0])){if((o=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")||"0"}if(this.parent.getErrorStrings().indexOf(o)>-1)return o;if(isNaN(this.parent.parseFloat(o))&&o!==this.parent.trueValue&&o!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(e[1])){if((s=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[1].indexOf(this.parent.tic)>-1&&(e[1].split(this.parent.tic).join("")===this.parent.trueValue||e[1].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];s=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("")||"0"}if(this.parent.getErrorStrings().indexOf(s)>-1)return s;if(isNaN(this.parent.parseFloat(s))&&s!==this.parent.trueValue&&s!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.isCellReference(e[2])){if((a=this.parent.getValueFromArg(e[2].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[2].indexOf(this.parent.tic)>-1&&(e[2].split(this.parent.tic).join("")===this.parent.trueValue||e[2].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];a=this.parent.getValueFromArg(e[2]).split(this.parent.tic).join("")||"0"}if(this.parent.getErrorStrings().indexOf(a)>-1)return a;if(isNaN(this.parent.parseFloat(a))&&a!==this.parent.trueValue&&a!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(o=o===this.parent.trueValue?"1":o===this.parent.falseValue?"0":o,s=s===this.parent.trueValue?"1":s===this.parent.falseValue?"0":s,a=a===this.parent.trueValue?"1":a===this.parent.falseValue?"0":a,o=parseInt(this.parent.parseFloat(o).toString(),10),s=parseInt(this.parent.parseFloat(s).toString(),10),a=parseInt(this.parent.parseFloat(a).toString(),10),isNaN(o)||isNaN(s)||isNaN(a))return this.parent.getErrorStrings()[r.CommonErrors.Value];if(o>32767||s>32767||a>32767)return this.parent.getErrorStrings()[r.CommonErrors.Num];var u=new Date(1900,0,1,o,s,a);if(u.getFullYear()<1900)return this.parent.getErrorStrings()[r.CommonErrors.Num];var l=u.getHours(),h=u.getMinutes(),p=u.getSeconds();h=h<10?"0"+h:h,p=p<10?"0"+p:p,i=(l=l<10?"0"+l:l)+":"+h+":"+p;var g=this.parent.hostParseDate(i.toString());return g.isTime&&(i=g.value),i},n.prototype.ComputeEDATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2!==e.length||t.isNullOrUndefined(e))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0]||""===e[1])return this.parent.getErrorStrings()[r.CommonErrors.NA];if(""===e[0].split(this.parent.tic).join("")||""===e[1].split(this.parent.tic).join("")||e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var i,o;if(this.parent.isCellReference(e[0])){if(e[0].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(this.parent.getErrorStrings().indexOf(i.toString())>-1)return i.toString()}else i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""));if(this.parent.isCellReference(e[1])){if(e[1].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0"}else o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""));if(this.parent.getErrorStrings().indexOf(o)>-1)return o;o=parseInt(o,10);var s;if(this.parent.isNumber(i)){if((i=parseInt(i,10))<0||i>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];s=this.parent.fromOADate(i)}else s=this.parent.checkDateFormat(i);if(isNaN(o)||t.isNullOrUndefined(this.parent.isDate(s))||s.getFullYear()>9999)return this.parent.getErrorStrings()[r.CommonErrors.Value];var u=s.getDate();s.setMonth(s.getMonth()+o),u!==s.getDate()&&s.setDate(0);var l=a(s);return"0"===i.toString()&&(l-=1),l<0||l>2958465?this.parent.getErrorStrings()[r.CommonErrors.Num]:l.toString()},n.prototype.ComputeEOMONTH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2!==e.length||t.isNullOrUndefined(e))return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0]||""===e[1])return this.parent.getErrorStrings()[r.CommonErrors.NA];if(""===e[0].split(this.parent.tic).join("")||""===e[1].split(this.parent.tic).join("")||e[1].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[1].split(this.parent.tic).join(""))))return this.parent.getErrorStrings()[r.CommonErrors.Value];var i,o;if(this.parent.isCellReference(e[0])){if(e[0].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("");if(this.parent.getErrorStrings().indexOf(i)>-1)return i;if(this.parent.isCellReference(e[1])){if(e[1].indexOf(":")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""))||"0"}else o=this.parent.getValueFromArg(e[1].split(this.parent.tic).join(""));if(this.parent.getErrorStrings().indexOf(o)>-1)return o;o=parseInt(o,10);var s;if(this.parent.isNumber(i)){if((i=parseInt(i,10))<0||i>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];s=this.parent.fromOADate(i)}else s=this.parent.checkDateFormat(i);if(isNaN(o)||t.isNullOrUndefined(this.parent.isDate(s))||s.getFullYear()>9999)return this.parent.getErrorStrings()[r.CommonErrors.Value];var u=a(s=new Date(s.getFullYear(),s.getMonth()+(o+1),0));return u<0||u>2958465||s.getFullYear()<1900?this.parent.getErrorStrings()[r.CommonErrors.Num]:u.toString()},n.prototype.ComputeDATEVALUE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();if(""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(i=o=this.parent.getValueFromArg(e[0])||"0",s.indexOf(i)>-1)return i;if(this.parent.isCellReference(e[0])){if(e[0].indexOf(":")>-1||i.startsWith(this.parent.tic))return s[r.CommonErrors.Value]}else i=e[0].split(this.parent.tic).join("")||"0";if(this.parent.isNumber(i)||t.isNullOrUndefined(this.parent.isDate(i))){if(this.parent.isNumber(o)||!this.parent.isDate(o))return s[r.CommonErrors.Value];i=o}var a=this.parent.parseDate(i);return s.indexOf(i)>-1?i:t.isNullOrUndefined(a)||"Invalid Date"===a.toString()||a.getFullYear()<1900||a.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:(i=this.parent.toOADate(a).toString(),parseFloat(i).toFixed(0).toString())},n.prototype.ComputeHOUR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(1!==e.length||t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var i;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i;var o;if(this.parent.isNumber(i)){if(this.parent.parseFloat(i)<0||this.parent.parseFloat(i)>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];o=this.parent.intToTime(i)}else{var s=this.parent.hostParseDate(i.toString());if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=s.dateObj}if("Invalid Date"===o.toString()&&(o=new Date(Date.parse(i))),"Invalid Date"===o.toString()){var a=new Date(Date.now()).toLocaleDateString()+" "+i;o=new Date(Date.parse(a))}return"Invalid Date"===o.toString()&&(o=this.parent.fromOADate(this.parent.parseFloat(i))),"Invalid Date"===o.toString()?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getFullYear()<1900||o.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getHours()},n.prototype.ComputeMINUTE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(1!==e.length||t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var i;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i;var o;if(this.parent.isNumber(i)){if(this.parent.parseFloat(i)<0||this.parent.parseFloat(i)>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];o=this.parent.intToTime(i)}else{var s=this.parent.hostParseDate(i.toString());if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=s.dateObj}if("Invalid Date"===o.toString()&&(o=new Date(Date.parse(i))),"Invalid Date"===o.toString()){var a=new Date(Date.now()).toLocaleDateString()+" "+i;o=new Date(Date.parse(a))}return"Invalid Date"===o.toString()&&(o=this.parent.fromOADate(this.parent.parseFloat(i))),"Invalid Date"===o.toString()?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getFullYear()<1900||o.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getMinutes()},n.prototype.ComputeSECOND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(1!==e.length||t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(""===e[0].split(this.parent.tic).join("").trim())return this.parent.getErrorStrings()[r.CommonErrors.Value];var i;if(this.parent.isCellReference(e[0])){if((i=this.parent.getValueFromArg(e[0].split(this.parent.tic).join(""))||"0").indexOf(this.parent.tic)>-1)return this.parent.getErrorStrings()[r.CommonErrors.Value]}else{if(e[0].indexOf(this.parent.tic)>-1&&(e[0].split(this.parent.tic).join("")===this.parent.trueValue||e[0].split(this.parent.tic).join("")===this.parent.falseValue))return this.parent.getErrorStrings()[r.CommonErrors.Value];i=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join("")}if(this.parent.getErrorStrings().indexOf(i)>-1)return i;i=i===this.parent.trueValue?"1":i===this.parent.falseValue?"0":i;var o;if(this.parent.isNumber(i)){if(this.parent.parseFloat(i)<0||this.parent.parseFloat(i)>2958465)return this.parent.getErrorStrings()[r.CommonErrors.Num];o=this.parent.intToTime(i)}else{var s=this.parent.hostParseDate(i.toString());if(!s.isDate&&!s.isTime)return this.parent.getErrorStrings()[r.CommonErrors.Value];o=s.dateObj}if("Invalid Date"===o.toString()&&(o=new Date(Date.parse(i))),"Invalid Date"===o.toString()){var a=new Date(Date.now()).toLocaleDateString()+" "+i;o=new Date(Date.parse(a))}return"Invalid Date"===o.toString()&&(o=this.parent.fromOADate(this.parent.parseFloat(i))),"Invalid Date"===o.toString()?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getFullYear()<1900||o.getFullYear()>9999?this.parent.getErrorStrings()[r.CommonErrors.Value]:o.getSeconds()},n.prototype.ComputeNOW=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1!==t.length||""!==t[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:a(new Date(Date.now()),!0).toString()},n.prototype.ComputeMONTH=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings();if(1===t.length&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.getValueFromArg(t[0]).trim();if(n.indexOf(i)>-1)return i;if(this.parent.isCellReference(t[0])){if(i.indexOf(this.parent.tic)>-1)return n[r.CommonErrors.Value];if(""===i)return 1}else{if('"TRUE"'===i.toUpperCase()||'"FALSE"'===i.toUpperCase())return n[r.CommonErrors.Value];i=i.split(this.parent.tic).join("")}if(""===i)return n[r.CommonErrors.Value];if(i===this.parent.trueValue||i===this.parent.falseValue||Number(i)>-1&&Number(i)<32)return 1;if(Number(i)<0)return n[r.CommonErrors.Num];i.indexOf("%")>-1&&(i=(.01*Number(i.split("%")[0])).toString()),this.parent.isNumber(i)&&(i=parseInt(Math.floor(Number(i)).toString(),10));var o=this.parent.parseDate(i);return"Invalid Date"===o.toString()?this.parent.isNumber(i)?n[r.CommonErrors.Num]:n[r.CommonErrors.Value]:o.getFullYear()<1900||1e4<=o.getFullYear()?n[r.CommonErrors.Num]:(o.getMonth()+1).toString()},n}(Q),at=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ut=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"YEAR",category:"Date & Time",description:"Converts a serial number to a year."},{formulaName:"WEEKNUM",category:"Date & Time",description:"Converts a serial number to a number representing where the week falls numerically within a year."},{formulaName:"TIMEVALUE",category:"Date & Time",description:"Converts a time in the form of text to a serial number."},{formulaName:"DAYS360",category:"Date & Time",description:"Calculates the number of days between two dates based on a 360-day year."},{formulaName:"YEARFRAC",category:"Date & Time",description:"Returns the year fraction representing the number of whole days between start_date and end_date."},{formulaName:"NETWORKDAYS",category:"Date & Time",description:"Returns the number of whole workdays between two dates."},{formulaName:"WORKDAY",category:"Date & Time",description:"Returns the serial number of the date before or after a specified number of workdays."}],t}return at(n,e),n.prototype.toSerial=function(t){var e=this.parent.getErrorStrings(),n=this.parent.getValueFromArg(t);if(e.indexOf(n)>-1)return n;if(this.parent.isCellReference(t)||(n=this.parent.removeTics(n)),""===n)return e[r.CommonErrors.Value];if(this.parent.isNumber(n))return this.parent.parseFloat(n);var i=this.parent.isDate(new Date(n));return i?this.parent.toOADate(i):e[r.CommonErrors.Value]},n.prototype.ComputeYEAR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]);return"string"==typeof o?o:o<0?i[r.CommonErrors.Num]:this.parent.fromOADate(o).getFullYear().toString()},n.prototype.ComputeWEEKNUM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]);if("string"==typeof o)return o;var s=1;if(2===e.length&&""!==e[1]){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=Math.floor(a)}var u=this.parent.fromOADate(o),l=new Date(u.getFullYear(),0,1),h=0;2!==s&&11!==s||(h=1);var p=(l.getDay()+7-h)%7,g=Math.floor((u.getTime()-l.getTime())/864e5),f=Math.floor((g+p)/7)+1;return f<1?i[r.CommonErrors.Num]:f.toString()},n.prototype.ComputeTIMEVALUE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=o.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM)?$/i);if(!s){var a=this.parent.isDate(new Date(o));if(a){var u=this.parent.toOADate(a,!0);return(u-Math.floor(u)).toString()}return i[r.CommonErrors.Value]}var l=parseInt(s[1],10),h=parseInt(s[2],10),p=s[3]?parseInt(s[3],10):0,g=s[4]?s[4].toUpperCase():"";return"PM"===g&&l<12&&(l+=12),"AM"===g&&12===l&&(l=0),l>23||h>59||p>59?i[r.CommonErrors.Value]:((3600*l+60*h+p)/86400).toString()},n.prototype.ComputeDAYS360=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=!1;if(3===e.length&&""!==e[2]){var a=this.parent.getValueFromArg(e[2]).toUpperCase();s=a===this.parent.trueValue||0!==this.parent.parseFloat(a)}var u=this.parent.fromOADate(i),l=this.parent.fromOADate(o),h=u.getFullYear(),p=u.getMonth()+1,g=u.getDate(),f=l.getFullYear(),m=l.getMonth()+1,c=l.getDate();return s?(31===g&&(g=30),31===c&&(c=30)):(31===g&&(g=30),31===c&&30===g&&(c=30)),(360*(f-h)+30*(m-p)+(c-g)).toString()},n.prototype.ComputeYEARFRAC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=0;if(3===e.length&&""!==e[2]){var a=this.resolveNumberArg(e[2]);if("string"==typeof a)return a;s=Math.floor(a)}var u=Math.abs(o-i);switch(s){case 0:return(Math.abs(this.parent.parseFloat(this.ComputeDAYS360(e[0],e[1],"FALSE")))/360).toString();case 1:return(u/365.25).toString();case 2:return(u/360).toString();case 3:return(u/365).toString();case 4:return(Math.abs(this.parent.parseFloat(this.ComputeDAYS360(e[0],e[1],"TRUE")))/360).toString();default:return this.parent.getErrorStrings()[r.CommonErrors.Num]}},n.prototype.isWeekend=function(r){var t=r.getDay();return 0===t||6===t},n.prototype.holidaySet=function(r){var t=new Set;if(!r||""===r)return t;var e=this.parent.getErrorStrings();if(this.parent.isCellReference(r)&&r.indexOf(":")>-1){for(var n=this.parent.getCellCollection(r),i=Array.isArray(n)?n:[n],o=0;o<i.length;o++)if("string"!=typeof(s=this.toSerial(i[o])))t.add(Math.floor(s));else if(e.indexOf(s)>-1)return s}else{var s=this.toSerial(r);if("string"==typeof s)return s;t.add(Math.floor(s))}return t},n.prototype.ComputeNETWORKDAYS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=this.holidaySet(e[2]);if(!(s instanceof Set))return s;for(var a=i<=o?1:-1,u=0,l=Math.floor(i);a>0?l<=Math.floor(o):l>=Math.floor(o);l+=a){var h=this.parent.fromOADate(l);this.isWeekend(h)||s.has(l)||(u+=a)}return u.toString()},n.prototype.ComputeWORKDAY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=Math.trunc(s),u=this.holidaySet(e[2]);if(!(u instanceof Set))return u;for(var l=Math.floor(o),h=a>=0?1:-1,p=Math.abs(a);p>0;){l+=h;var g=this.parent.fromOADate(l);if(this.isWeekend(g)||u.has(l)||p--,l<0)return i[r.CommonErrors.Num]}return l.toString()},n}(Q),lt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ht=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"IF",category:"Logical",description:"Returns one value if a logical expression is TRUE and another if it is FALSE"},{formulaName:"AND",category:"Logical",description:"Returns TRUE if all the arguments are considered TRUE, and FALSE otherwise."},{formulaName:"OR",category:"Logical",description:"Returns TRUE if any arguments considered TRUE, and all the arguments are FALSE it will return FALSE."},{formulaName:"NOT",category:"Logical",description:"Returns the inverse of a given logical expression."},{formulaName:"IFS",category:"Logical",description:"Checks multiple conditions and returns a value corresponding to the first TRUE result."},{formulaName:"IFERROR",category:"Logical",description:"Returns a value you specify if a formula evaluates to an error; otherwise, it returns the result of the formula."}],t}return lt(n,e),n.prototype.ComputeIF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i;if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(i=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(this.parent.getErrorStrings().indexOf(e[0])>-1)return e[0];var o,a=e;4===a.length&&"nestedFormulaTrue"===a[3]&&(o=!0,a.pop());var u,l;if(a.length>3||1===a.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(a.length<=3){var h=void 0,p=void 0,g="";if(u=this.parent.getValueFromArg(a[0]),this.parent.getErrorStrings().indexOf(u)>-1)return u;var f=u.toUpperCase(),m=this.parent.parseFloat(u);if(f===this.parent.trueValue||m<0||m>0){if(i&&a[1].includes(":")){h=this.parent.getCellCollection(a[1]);for(c=0;c<h.length;c++)p=this.parent.getValueFromArg(h[c]),isNaN(this.parent.parseFloat(p))||(g+=p+",");return g.slice(0,g.length-1)}l=""===a[1]?"0":this.parent.getValueFromArg(a[1],void 0,void 0,void 0,!0)}else{if(f!==this.parent.falseValue&&0!==m)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Requires3Args];if(t.isNullOrUndefined(a[2]))return this.parent.falseValue;if(i&&a[2].includes(":")){h=this.parent.getCellCollection(a[2]);for(var c=0;c<h.length;c++)p=this.parent.getValueFromArg(h[c]),isNaN(this.parent.parseFloat(p))||(g+=p+",");return g.slice(0,g.length-1)}l=""===a[2]?"0":this.parent.getValueFromArg(a[2],void 0,void 0,void 0,!0)}}var d=l.indexOf(this.parent.tic);return!o&&d>-1?l.split(this.parent.tic).join(""):!o||s(l)||-1!==d||l===this.parent.trueValue||l===this.parent.falseValue||this.parent.isCellReference(l)?""===l?"0":l:'"'+l+'"'},n.prototype.ComputeAND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(e)||1===i.length&&""===i[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:this.parent.computeAndOrNot(i,"and")},n.prototype.ComputeOR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(e)||1===i.length&&""===i[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:this.parent.computeAndOrNot(i,"or")},n.prototype.ComputeNOT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(e)||e.length>1||""===e[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.computeAndOrNot(i,"not")},n.prototype.ComputeIFS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;if(t.isNullOrUndefined(e)||1===i.length&&""===i[0]||i.length%2!=0)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o="",s="",a=0;a<i.length;a++){if(o=this.parent.getValueFromArg(i[a]),""===i[a])return this.parent.getErrorStrings()[r.CommonErrors.NA];if(this.parent.getErrorStrings().indexOf(o)>-1)return o;if(o!==this.parent.trueValue&&o!==this.parent.falseValue)return this.parent.getErrorStrings()[r.CommonErrors.Value];if(o===this.parent.trueValue)return this.parent.isCellReference(i[a+1].split(this.parent.tic).join(""))||i[a+1].includes(this.parent.arithMarker)?s=""===(s=this.parent.getValueFromArg(i[a+1]))?"0":s:(s=""===i[a+1]?"0":this.parent.getValueFromArg(i[a+1])).indexOf(this.parent.tic)>-1&&(s=s.split(this.parent.tic).join("")),a+=1,s;o===this.parent.falseValue&&(a+=1)}return this.parent.getErrorStrings()[r.CommonErrors.NA]},n.prototype.ComputeIFERROR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];var i,o=e;if(2!==o.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(this.parent.isCellReference(o[0])){if(i=this.parent.getValueFromArg(o[0])||"0",-1===this.parent.getErrorStrings().indexOf(i)&&"NaN"!==i)return i}else if(i=this.parent.getValueFromArg(o[0],null,!0)||"0",-1===this.parent.getErrorStrings().indexOf(i)&&"NaN"!==i)return i=i.split(this.parent.tic).join("").trim();return i=this.parent.isCellReference(o[1])?this.parent.getValueFromArg(o[1])||"0":(i=this.parent.getValueFromArg(o[1])||"0").split(this.parent.tic).join("").trim()},n}(Q),pt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),gt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"TRUE",category:"Logical",description:"Returns the logical value TRUE."},{formulaName:"FALSE",category:"Logical",description:"Returns the logical value FALSE."},{formulaName:"XOR",category:"Logical",description:"Returns a logical exclusive OR of all arguments."},{formulaName:"IFNA",category:"Logical",description:"Returns the value you specify if the expression resolves to #N/A; otherwise returns the result of the expression."},{formulaName:"SWITCH",category:"Logical",description:"Evaluates an expression against a list of values and returns the result corresponding to the first matching value."}],t}return pt(n,e),n.prototype.ComputeTRUE=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&1===t.length&&""===t[0]?this.parent.trueValue:t&&t.length>0&&(1!==t.length||""!==t[0])?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.trueValue},n.prototype.ComputeFALSE=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&1===t.length&&""===t[0]?this.parent.falseValue:t&&t.length>0&&(1!==t.length||""!==t[0])?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.falseValue},n.prototype.isTruthy=function(r){var t=r.toUpperCase();if(t===this.parent.trueValue)return!0;if(t===this.parent.falseValue||""===r)return!1;var e=this.parent.parseFloat(r);return!isNaN(e)&&0!==e},n.prototype.ComputeXOR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=0,s=0;s<e.length;s++){var a=e[s];if(this.parent.isCellReference(a)&&a.indexOf(":")>-1)for(var u=this.parent.getCellCollection(a),l=Array.isArray(u)?u:[u],h=0;h<l.length;h++){p=this.parent.getValueFromArg(l[h]);if(i.indexOf(p)>-1)return p;this.isTruthy(p)&&o++}else{var p=this.parent.getValueFromArg(a);if(i.indexOf(p)>-1)return p;this.isTruthy(p)&&o++}}return o%2==1?this.parent.trueValue:this.parent.falseValue},n.prototype.ComputeIFNA=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.getValueFromArg(e[0]);return i===this.parent.getErrorStrings()[r.CommonErrors.NA]||"#N/A"===i?this.parent.getValueFromArg(e[1]):""===i?"0":i},n.prototype.ComputeSWITCH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;var s=Math.floor((e.length-1)/2),a=i[r.CommonErrors.NA];(e.length-1)%2==1&&(a=this.parent.getValueFromArg(e[e.length-1]));for(var u=0;u<s;u++){var l=1+2*u,h=l+1,p=this.parent.getValueFromArg(e[l]);if(i.indexOf(p)>-1)return p;if(p===o||!isNaN(this.parent.parseFloat(p))&&this.parent.parseFloat(p)===this.parent.parseFloat(o)){var g=this.parent.getValueFromArg(e[h]);return""===g?"0":this.parent.removeTics(g)}}return""===a?"0":this.parent.removeTics(a)},n}(Q),ft=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),mt=function(e){function i(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"CHOOSE",category:"Lookup & Reference",description:"Returns a value from a list, given an index number."},{formulaName:"INDEX",category:"Lookup & Reference",description:"Returns a value from a table, given a row and column number."},{formulaName:"MATCH",category:"Lookup & Reference",description:"Returns the relative position of an checked item in range that matches a specified value in a specified order"},{formulaName:"LOOKUP",category:"Lookup & Reference",description:"Looks for a value in a one-row or one-column range, then returns a value from the same position in a second one-row or one-column range."},{formulaName:"VLOOKUP",category:"Lookup & Reference",description:"Looks for a specific value in the first column of a lookup range and returns a corresponding value from a different column within the same row."},{formulaName:"HLOOKUP",category:"Lookup & Reference",description:"Looks for a value in the top row of the array of values and then returns a value in the same column from a row in the array that you specify."},{formulaName:"ADDRESS",category:"Lookup & Reference",description:"Returns a cell reference as text, given specified row and column numbers."},{formulaName:"SUBTOTAL",category:"Lookup & Reference",description:"Returns a subtotal in a list or database."},{formulaName:"TEXT",category:"Lookup & Reference",description:"Converts a value to text in specified number format."}],t}return ft(i,e),i.prototype.ComputeCHOOSE=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(t.isNullOrUndefined(n)||""===n[0]&&1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o,s=this.parent.getErrorStrings();if(o=function(r){return r=e.parent.getValueFromArg(r),r.toUpperCase()===e.parent.trueValue?r="1":r.toUpperCase()===e.parent.falseValue&&(r="0"),r}(n[0]),s.indexOf(o)>-1)return o;if(this.parent.isCellReference(n[0])){if(n[0].indexOf(":")>-1)return s[r.CommonErrors.Value]}else 2===(o=this.parent.removeTics(o)).split("%").length&&this.parent.isNumber(o.split("%")[0])&&(o=(.01*Number(o.split("%")[0])).toString());return(o=Math.floor(this.parent.parseFloat(o)))<1||isNaN(o)||t.isNullOrUndefined(n[o])?s[r.CommonErrors.Value]:(""===(o=n[o])&&(o="0"),this.parent.isCellReference(o)?o.indexOf(":")>-1?s[r.CommonErrors.Value]:this.parent.getValueFromArg(o):(o.indexOf(this.parent.tic)>-1&&(s.indexOf(o.split(this.parent.tic).join(""))>-1||this.parent.removeTics(o).match(/^(\d*\.\d+|\d+)\s*[-*/]\s*(\d*\.\d+|\d+)$/))&&(o=this.parent.removeTics(o)),(o=this.parent.removeTics(this.parent.getValueFromArg(o))).indexOf(this.parent.tic+this.parent.tic)>-1?o.replace(/""/g,this.parent.tic):(2===o.split("%").length&&this.parent.isNumber(o.split("%")[0])&&(o=(.01*Number(o.split("%")[0])).toString()),o)))},i.prototype.ComputeINDEX=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s,a=this.parent.getErrorStrings();if(n.length&&"nestedFormulaTrue"===n[n.length-1]&&(o=!0,n.pop()),t.isNullOrUndefined(n)||1===n.length&&""===n[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length<2||n.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0]||""===n[3]||n[3]&&("0"===n[3]||"FALSE"===n[3]))return a[r.CommonErrors.Value];var u,l,h,p=function(n){if(t.isNullOrUndefined(n)||""===n)return 1;var i=e.parent.getValueFromArg(n);return a.indexOf(i)>-1?i:(i.toUpperCase()===e.parent.trueValue?i="1":i.toUpperCase()===e.parent.falseValue&&(i="0"),i.indexOf(e.parent.tic)>-1&&(i=e.parent.removeTics(i),-1===n.indexOf(e.parent.tic)||""===i.trim())?a[r.CommonErrors.Value]:(2===i.split("%").length&&e.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),i=parseInt(Number(i).toString(),10),isNaN(i)||i<0?a[r.CommonErrors.Value]:(0===i&&(i=1),i)))};if(n[3]&&(h=p(n[3]),a.indexOf(h.toString())>-1))return h.toString();n[0].startsWith(this.parent.tic)&&n[0].endsWith(this.parent.tic)&&(n[0]=n[0].substring(1,n[0].length-1));var g=n[0].split(this.parent.getParseArgumentSeparator());if(n[0]=g[h?h-1:0],!n[0])return a[r.CommonErrors.Ref];if(s=n[0],u=p(n[1]),a.indexOf(u.toString())>-1)return u.toString();if(l=p(n[2]),a.indexOf(l.toString())>-1)return l.toString();var f=s.indexOf(":");if(-1===f){if(u>1||l>1)return a[r.CommonErrors.Ref];s=this.parent.isCellReference(s)?this.parent.getValueFromArg(s):s}else{var m=this.parent.rowIndex(s.substring(0,f)),c=this.parent.rowIndex(s.substring(f+1)),d=this.parent.colIndex(s.substring(0,f)),v=this.parent.colIndex(s.substring(f+1));if(u>c-m+1||l>v-d+1)return a[r.CommonErrors.Ref];u=m+u-1,l=d+l-1,s=this.parent.getValueFromArg(this.getSheetReference(s)+this.parent.convertAlpha(l)+u)}return""===s?0:o&&-1===a.indexOf(s)&&!this.parent.isNumber(s)&&s!==this.parent.trueValue&&s!==this.parent.falseValue?this.parent.tic+s+this.parent.tic:s},i.prototype.ComputeMATCH=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=n.slice(),s=this.parent.getErrorStrings();if(t.isNullOrUndefined(o)||1===o.length&&""===o[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(o.length<2||o.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];o[0]=this.parent.getValueFromArg(n[0]);var a=o[0].indexOf(this.parent.tic)>-1;if(o[0]=o[0].split(this.parent.tic).join(""),s.indexOf(o[0])>-1)return o[0];if(""===o[0])return s[r.CommonErrors.NA];isNaN(Number(o[0]))&&(a=!0);var u;if(t.isNullOrUndefined(n[2]))o[2]="1";else{if(o[2]=this.parent.getValueFromArg(o[2]),o[2].indexOf(this.parent.tic)>-1&&isNaN(Number(o[2].split(this.parent.tic).join(""))))return s[r.CommonErrors.Value];o[2].toUpperCase()===this.parent.trueValue?o[2]="1":o[2].toUpperCase()===this.parent.falseValue&&(o[2]="0")}u=parseFloat(o[2]),-1===[-1,0,1].indexOf(u)&&(u=0);var l,h=[],p=!1,g=this.parent.grid,f=this.parent.grid;if(o[1].indexOf(":")>-1||this.parent.isCellReference(o[1])){var m=Y(o[1]),c=m[0],d=m[1],v=m[2],N=m[3];if(c>=1048576||v>=1048576||d>=16384||N>=16384)return s[r.CommonErrors.Name];if(c!==v&&d!==N)return s[r.CommonErrors.NA];var E="",S=this.parent.getSheetFamilyItem(g);o[1].startsWith("!")?(E=o[1].substring(0,o[1].replace("!","").indexOf("!")+2),null!==S.tokenToParentObject&&(g=S.tokenToParentObject.get(E))):null!==S.parentObjectToToken&&(E=S.parentObjectToToken.get(g));var y,C,b=this.parent.getSheetId(g),A=this.parent.getCellValueFn(g,this.parent.cell,b,!0),O=0,F=void 0;0===u?(l=o[0].indexOf("*")>-1||o[0].indexOf("?")>-1,F=function(){if(l&&(y=e.parent.findWildCardValue(o[0],y)),o[0]===y)return N=-2,v=-2,void(C=O+1);O++}):F=function(){h[O]=y,O++};for(var x=c;x<=v;x++)for(var V=d;V<=N;V++)y=A(x+1,V+1,B(x,V)),!p&&isNaN(Number(y))&&(p=!0),F();if(C)return this.parent.grid=f,C;if(a!==p)return this.parent.grid=f,s[r.CommonErrors.NA]}else!t.isNullOrUndefined(o[1])&&o[1].includes(this.parent.tic+this.parent.tic)&&o[1].split(this.parent.tic+this.parent.tic).forEach(function(r){(r=r.trim().split(e.parent.tic).join(""))&&h.push(r)});for(var R=0,I="",T=!1,M=isNaN(Number(o[0]))?o[0]:Number(o[0]),D=0;D<h.length;D++)if(""!==h[D]){if(-1===u&&(a||p))break;var U=isNaN(Number(h[D]))?h[D]:Number(h[D]);if(1===u)M===U?(R=D+1,T=!0,isNaN(Number(o[0]))&&(a=!1)):M>U&&!a&&!T&&(!I||U>(isNaN(Number(I))?I:Number(I)))&&(R=D+1,I=h[D]);else if(0===u){if(l&&(h[D]=this.parent.findWildCardValue(o[0],h[D])),o[0]===h[D])return D+1}else if(-1===u){if(!(Number(h[D])>Number(h[D+1])||D===h.length-1))return this.parent.grid=f,s[r.CommonErrors.NA];M===U?(R=D+1,M=void 0):M<U&&(!I||U<(isNaN(Number(I))?I:Number(I)))&&(R=D+1,I=h[D])}}else D===h.length-1&&h.pop();return a&&p&&1===u&&(R=h.length),this.parent.grid=f,R||s[r.CommonErrors.NA]},i.prototype.ComputeLOOKUP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e;return t.isNullOrUndefined(i)||1===i.length&&""===i[0]?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.computeLookup(i)},i.prototype.ComputeVLOOKUP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=r;return this.parent.computeVHLookup(e,!0)},i.prototype.ComputeHLOOKUP=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=r;return this.parent.computeVHLookup(e)},i.prototype.ComputeADDRESS=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length&&""===n[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length<2||n.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===n[0].split(this.parent.tic).join("").trim()||""===n[1].split(this.parent.tic).join("").trim())return s[r.CommonErrors.Value];var a=function(t){var n=e.parent.getValueFromArg(t).trim();return s.indexOf(n)>-1?n:(n.toUpperCase()===e.parent.trueValue?n="1":n.toUpperCase()===e.parent.falseValue&&(n="0"),e.parent.isCellReference(t)&&n.indexOf(e.parent.tic)>-1?s[r.CommonErrors.Value]:(2===(n=e.parent.removeTics(n)).split("%").length&&e.parent.isNumber(n.split("%")[0])&&(n=(Number(n.split("%")[0])/100).toString()),n))},u=a(n[0]);if(s.indexOf(u)>-1)return u;if(u=Number(u),isNaN(u)||u<1)return s[r.CommonErrors.Value];u=u.toString();var l=a(n[1]);if(s.indexOf(l)>-1)return l;if(l=Number(l),isNaN(l)||l<1)return s[r.CommonErrors.Value];l=l.toString();var h,p;if(t.isNullOrUndefined(n[2])||""===n[2].trim())h="1";else{if(h=a(n[2]),s.indexOf(h)>-1)return h;if(h=Number(h),isNaN(h)||h<1||h>4)return s[r.CommonErrors.Value];h=h.toString()}if(t.isNullOrUndefined(n[3])||""===n[3].trim())p="1";else{if(p=a(n[3]),s.indexOf(p)>-1)return p;p.toUpperCase()===this.parent.trueValue||Number(p)>1?p="1":""!==p&&p.toUpperCase()!==this.parent.falseValue||(p="0")}if("1"===p)"1"===h?o="$"+K(parseInt(l,10))+"$"+parseInt(u,10):"2"===h?o=K(parseInt(l,10))+"$"+parseInt(u,10):"3"===h?o="$"+K(parseInt(l,10))+parseInt(u,10):"4"===h&&(o=K(parseInt(l,10))+parseInt(u,10));else{if("0"!==p)return s[r.CommonErrors.Name];"1"===h?o="R"+parseInt(u,10)+"C"+parseInt(l,10):"2"===h?o="R"+parseInt(u,10)+"C["+parseInt(l,10)+"]":"3"===h?o="R["+parseInt(u,10)+"]C"+parseInt(l,10):"4"===h&&(o="R["+parseInt(u,10)+"]C["+parseInt(l,10)+"]")}var g;return!t.isNullOrUndefined(n[4])&&""!==n[4]&&(g=this.parent.getValueFromArg(n[4]).split(this.parent.tic).join(""),s.indexOf(g)>-1)?g:(t.isNullOrUndefined(g)||(o=g+"!"+o),o)},i.prototype.ComputeSUBTOTAL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s,a,u,l,h,p,g,f,m,c,d=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(c=this.parent.getValueFromArg(e[0]).trim(),d.indexOf(c)>-1)return c;if(""===c.split(this.parent.tic).join("").trim())return d[r.CommonErrors.Value];if(this.parent.isCellReference(e[0])||(c=this.parent.removeTics(c)),c.toUpperCase()===this.parent.trueValue?c="1":c.toUpperCase()===this.parent.falseValue?c="0":2===c.split("%").length&&this.parent.isNumber(c.split("%")[0])&&(c=(Number(c.split("%")[0])/100).toString()),c=this.parent.parseFloat(c),isNaN(c)||(1>c||c>11)&&(101>c||c>111))return d[r.CommonErrors.Value];var v=e.slice(1,e.length);switch(c){case 1:case 101:c=(i=this.owner).ComputeAVERAGE.apply(i,v.concat(["isSubtotal"]));break;case 2:case 102:c=(o=this.owner).ComputeCOUNT.apply(o,v.concat(["isSubtotal"]));break;case 3:case 103:c=(s=this.owner).ComputeCOUNTA.apply(s,v.concat(["isSubtotal"]));break;case 4:case 104:c=(a=this.owner).ComputeMAX.apply(a,v.concat(["isSubtotal"]));break;case 5:case 105:c=(u=this.owner).ComputeMIN.apply(u,v.concat(["isSubtotal"]));break;case 6:case 106:c=(l=this.owner).ComputePRODUCT.apply(l,v.concat(["isSubtotal"]));break;case 7:case 107:c=(h=this.owner).ComputeDAY.apply(h,v);break;case 8:case 108:c=(p=this.owner).ComputeCONCAT.apply(p,v);break;case 9:case 109:c=(g=this.owner).ComputeSUM.apply(g,v.concat(["isSubtotal"]));break;case 10:case 110:c=(f=this.owner).ComputeAVERAGEA.apply(f,v);break;case 11:case 111:c=(m=this.owner).ComputeABS.apply(m,v);break;default:c=d[r.CommonErrors.Value]}return c},i.prototype.ComputeTEXT=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var o;e.length&&"nestedFormulaTrue"===e[e.length-1]&&(o=!0,e.pop());var u=e.length,l=e[0],h=e[1];if(2!==u)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var p=l,g=h;if(""===h)return this.parent.getValueFromArg(p);var f=new Date(1900,0,1,0,0,0),m=p+","+g,c=new t.Internationalization;if(this.parent.getErrorStrings().indexOf(m)>-1)return m;if(p=this.parent.getValueFromArg(p),s(p.split(this.parent.tic).join(""))&&(p=p.split(this.parent.tic).join("")),""===(g=h.startsWith('"')&&h.endsWith('"')?g.split(this.parent.tic).join(""):this.parent.getValueFromArg(g)))return"";""===p&&(g.length>0&&(g.toUpperCase().indexOf("M")>-1||g.toUpperCase().indexOf("D")>-1||g.toUpperCase().indexOf("Y")>-1||g.toUpperCase().indexOf("S")>-1||g.toUpperCase().indexOf("T")>-1)||g.toUpperCase().indexOf("H")>-1)&&(p=f.toString());var d=this.parseDouble(p);if(isNaN(d)&&null!==this.parent.isDate(new Date(p))&&(d=this.parent.toOADate(new Date(p))),f=Date.parse(p.split(this.parent.tic).join("")),!isNaN(d)||!isNaN(f))if(g.length>0&&-1===g.indexOf("#")&&(g.toUpperCase().indexOf("M")>-1||g.toUpperCase().indexOf("D")>-1||g.toUpperCase().indexOf("Y")>-1||g.toUpperCase().indexOf("S")>-1||g.toUpperCase().indexOf("T")>-1)||g.toUpperCase().indexOf("H")>-1){var v=(g=(g=g.split("Y").join("y").split("D").join("d").split("H").join("h")).split("S").join("s").split("m").join("M").split("AM/PM").join("tt")).split(""),N=!1,E=!1,S=0,y=0;for(S=0;S<v.length;){var C=v[S];"s"===C&&"M"===v[y]&&(v[y]="m","M"===v[y-1]&&(v[y-1]="m")),this.parent.isChar(C)&&(y=S),"M"===C&&N&&(v[S]="m",E=!0),"h"===C?N=!0:this.parent.isChar(C)&&"M"!==C&&"h"!==C&&!E&&(N=!1,E=!1),S++}g=(g=String(v)).split(",").join("").split("\n").join(" ");var b=this.parent.fromOADate(d);0===d&&(b=f);var A=n(g);if(""===A){var O=a(b);return this.parent.parentObject.getDisplayText({format:g,value:O})}p=c.getDateFormat({skeleton:A,type:"date"})(b)}else p=this.parent.parentObject.getDisplayText({format:g,value:d});return o?this.parent.tic+p+this.parent.tic:p},i}(Q),ct=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),dt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ROW",category:"Lookup & Reference",description:"Returns the row number of a reference."},{formulaName:"ROWS",category:"Lookup & Reference",description:"Returns the number of rows in a reference."},{formulaName:"COLUMN",category:"Lookup & Reference",description:"Returns the column number of a reference."},{formulaName:"COLUMNS",category:"Lookup & Reference",description:"Returns the number of columns in a reference."},{formulaName:"HYPERLINK",category:"Lookup & Reference",description:"Creates a shortcut that opens a document on a network server, intranet, or Internet."},{formulaName:"OFFSET",category:"Lookup & Reference",description:"Returns a reference offset from a given reference."}],t}return ct(n,e),n.prototype.ComputeROW=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0]){var i=this.parent.actCell||this.parent.cell||"A1",o=i.indexOf("!")>-1?i.substring(i.lastIndexOf("!")+1):i;return this.parent.rowIndex(o).toString()}if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=e[0].split("$").join("");if(!this.parent.isCellReference(s.split(":")[0]))return this.parent.getErrorStrings()[r.CommonErrors.Value];var a=s.indexOf(":")>-1?s.split(":")[0]:s,u=a.indexOf("!")>-1?a.substring(a.lastIndexOf("!")+1):a;return this.parent.rowIndex(u).toString()},n.prototype.ComputeCOLUMN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1===e.length&&""===e[0]){var i=this.parent.actCell||this.parent.cell||"A1",o=i.indexOf("!")>-1?i.substring(i.lastIndexOf("!")+1):i;return this.parent.colIndex(o).toString()}if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=e[0].split("$").join("");if(!this.parent.isCellReference(s.split(":")[0]))return this.parent.getErrorStrings()[r.CommonErrors.Value];var a=s.indexOf(":")>-1?s.split(":")[0]:s,u=a.indexOf("!")>-1?a.substring(a.lastIndexOf("!")+1):a;return this.parent.colIndex(u).toString()},n.prototype.ComputeROWS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=e[0].split("$").join("");if(-1===i.indexOf(":"))return this.parent.isCellReference(i)?"1":this.parent.getErrorStrings()[r.CommonErrors.Value];var o=i.split(":"),s=o[0].indexOf("!")>-1?o[0].substring(o[0].lastIndexOf("!")+1):o[0],a=o[1].indexOf("!")>-1?o[1].substring(o[1].lastIndexOf("!")+1):o[1];return(Math.abs(this.parent.rowIndex(a)-this.parent.rowIndex(s))+1).toString()},n.prototype.ComputeCOLUMNS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=e[0].split("$").join("");if(-1===i.indexOf(":"))return this.parent.isCellReference(i)?"1":this.parent.getErrorStrings()[r.CommonErrors.Value];var o=i.split(":"),s=o[0].indexOf("!")>-1?o[0].substring(o[0].lastIndexOf("!")+1):o[0],a=o[1].indexOf("!")>-1?o[1].substring(o[1].lastIndexOf("!")+1):o[1];return(Math.abs(this.parent.colIndex(a)-this.parent.colIndex(s))+1).toString()},n.prototype.ComputeHYPERLINK=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;if(2===e.length){var s=this.resolveTextArg(e[1]);return i.indexOf(s),s}return o},n.prototype.ComputeOFFSET=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");if(!this.parent.isCellReference(o.split(":")[0]))return i[r.CommonErrors.Value];var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof s)return s;if("string"==typeof a)return a;var u=1,l=1;if(e.length>=4&&""!==e[3]){var h=this.resolveNumberArg(e[3]);if("string"==typeof h)return h;u=Math.floor(h)}if(5===e.length&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;l=Math.floor(p)}if(u<1||l<1)return i[r.CommonErrors.Ref];var g=o.indexOf(":")>-1?o.split(":")[0]:o,f=g.indexOf("!")>-1?g.substring(0,g.lastIndexOf("!")+1):"",m=g.indexOf("!")>-1?g.substring(g.lastIndexOf("!")+1):g,c=this.parent.rowIndex(m)+Math.floor(s),d=this.parent.colIndex(m)+Math.floor(a);if(c<1||d<1)return i[r.CommonErrors.Ref];var v=f+K(d)+c;return 1===u&&1===l?this.parent.getValueFromArg(v):this.parent.getValueFromArg(v)||v},n}(Q),vt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Nt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"INDIRECT",category:"Lookup & Reference",description:"Returns a reference indicated by a text value."},{formulaName:"AREAS",category:"Lookup & Reference",description:"Returns the number of areas in a reference."},{formulaName:"FORMULATEXT",category:"Lookup & Reference",description:"Returns the formula in a cell as text."},{formulaName:"ISREF",category:"Information",description:"Returns TRUE if the value is a reference."}],t}return vt(n,e),n.prototype.ComputeINDIRECT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;o=o.split("$").join("");var s=!0;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=0!==a}if(!s)return i[r.CommonErrors.Value];if(!this.parent.isCellReference(o.split(":")[0]))return i[r.CommonErrors.Ref];if(o.indexOf(":")>-1){for(var u=this.parent.getCellCollection(o),l=Array.isArray(u)?u:[u],h=[],p=0;p<l.length;p++){var g=this.parent.getValueFromArg(l[p]);if(i.indexOf(g)>-1)return g;h.push(g)}return h.join(this.parent.getParseArgumentSeparator())}return this.parent.getValueFromArg(o)},n.prototype.ComputeAREAS=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");return this.parent.isCellReference(o.split(":")[0])||-1!==o.indexOf("(")?o.indexOf(",")>-1?o.split(",").length.toString():"1":i[r.CommonErrors.Value]},n.prototype.ComputeFORMULATEXT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");if(!this.parent.isCellReference(o))return i[r.CommonErrors.Value];var s=o.indexOf("!")>-1?o.substring(0,o.lastIndexOf("!")+1):"",a=o.indexOf("!")>-1?o.substring(o.lastIndexOf("!")+1):o,u="!"+this.parent.getSheetID(this.parent.grid)+"!"+a,l=s?o:u,h=this.parent.getFormulaInfoTable(),p=s?l:u;return h.has(p)?h.get(p).getFormulaText():i[r.CommonErrors.NA]},n.prototype.ComputeISREF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=e[0].split("$").join("");return this.parent.isCellReference(i.split(":")[0])},n}(Q),Et=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),St=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"XLOOKUP",category:"Lookup & Reference",description:"Searches a range for a match and returns the corresponding item."},{formulaName:"XMATCH",category:"Lookup & Reference",description:"Returns the relative position of an item in an array."},{formulaName:"TEXTSPLIT",category:"Text",description:"Splits text strings by using column and row delimiters."},{formulaName:"TOCOL",category:"Lookup & Reference",description:"Returns the array in a single column."},{formulaName:"TOROW",category:"Lookup & Reference",description:"Returns the array in a single row."},{formulaName:"CHOOSECOLS",category:"Lookup & Reference",description:"Returns the specified columns from an array."},{formulaName:"CHOOSEROWS",category:"Lookup & Reference",description:"Returns the specified rows from an array."}],t}return Et(n,e),n.prototype.flattenValues=function(r){var t=this.parent.getErrorStrings();if(this.parent.isCellReference(r)&&r.indexOf(":")>-1){for(var e=this.parent.getCellCollection(r),n=Array.isArray(e)?e:[e],i=[],o=0;o<n.length;o++){var s=this.parent.getValueFromArg(n[o]);if(t.indexOf(s)>-1)return s;i.push(s)}return i}var a=this.parent.isCellReference(r)?this.parent.getValueFromArg(r):this.resolveTextArg(r);return t.indexOf(a)>-1?a:[a]},n.prototype.valuesEqual=function(r,t){if(r===t)return!0;var e=this.parent.parseFloat(r),n=this.parent.parseFloat(t);return!isNaN(e)&&!isNaN(n)&&e===n},n.prototype.ComputeXLOOKUP=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.parent.removeTics(o),a=this.flattenValues(e[1]);if("string"==typeof a)return a;var u=this.flattenValues(e[2]);if("string"==typeof u)return u;if(a.length!==u.length)return i[r.CommonErrors.Value];var l=null;if(e.length>=4&&""!==e[3]&&(l=this.parent.getValueFromArg(e[3]),i.indexOf(l)>-1))return l;var h=0;if(e.length>=5&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;h=Math.floor(p)}for(var g=-1,f=0;f<a.length;f++){var m=a[f];if(this.valuesEqual(m,s)||m.toLowerCase()===s.toLowerCase()){g=f;break}if(0!==h&&m.toLowerCase().indexOf(s.toLowerCase())>-1){g=f;break}}if(g<0)return null!==l?this.parent.removeTics(l):i[r.CommonErrors.NA];var c=u[g];return""===c?"0":c},n.prototype.ComputeXMATCH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.flattenValues(e[1]);if("string"==typeof s)return s;for(var a=0;a<s.length;a++)if(this.valuesEqual(s[a],o)||s[a].toLowerCase()===this.parent.removeTics(o).toLowerCase())return(a+1).toString();return i[r.CommonErrors.NA]},n.prototype.ComputeTEXTSPLIT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]),s=this.resolveTextArg(e[1]);if(i.indexOf(o)>-1)return o;if(i.indexOf(s)>-1)return s;if(""===s)return o;var a=o.split(s);return void 0!==a[0]?a[0]:""},n.prototype.ComputeTOCOL=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.flattenJoin(r,!0)},n.prototype.ComputeTOROW=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.flattenJoin(r,!1)},n.prototype.flattenJoin=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.flattenValues(e[0]);if("string"==typeof o)return o;var s=0;if(e.length>=2&&""!==e[1]){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=Math.floor(a)}for(var u=[],l=0;l<o.length;l++){var h=o[l];(1!==s&&3!==s||""!==h)&&((2===s||3===s)&&i.indexOf(h)>-1||u.push(h))}return 0===u.length?i[r.CommonErrors.Calc]||"#CALC!":u[0]},n.prototype.ComputeCHOOSECOLS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.chooseAxis(r,!1)},n.prototype.ComputeCHOOSEROWS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.chooseAxis(r,!0)},n.prototype.chooseAxis=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=e[0].split("$").join("");if(!this.parent.isCellReference(o.split(":")[0]))return i[r.CommonErrors.Value];for(var s=[],a=1;a<e.length;a++){var u=this.resolveNumberArg(e[a]);if("string"==typeof u)return u;s.push(Math.floor(u))}var l=o.indexOf(":")>-1?o.split(":")[0]:o,h=o.indexOf(":")>-1?o.split(":")[1]:o,p=l.indexOf("!")>-1?l.substring(0,l.lastIndexOf("!")+1):"",g=l.indexOf("!")>-1?l.substring(l.lastIndexOf("!")+1):l,f=h.indexOf("!")>-1?h.substring(h.lastIndexOf("!")+1):h,m=this.parent.rowIndex(g),c=this.parent.colIndex(g),d=this.parent.rowIndex(f),v=this.parent.colIndex(f),N=Math.abs(d-m)+1,E=Math.abs(v-c)+1,S=s[0];if(0===S)return i[r.CommonErrors.Value];if(n){var y=S>0?S:N+S+1;if(y<1||y>N)return i[r.CommonErrors.Value];var C=Math.min(m,d)+y-1;return this.parent.getValueFromArg(p+K(Math.min(c,v))+C)}var b=S>0?S:E+S+1;if(b<1||b>E)return i[r.CommonErrors.Value];var A=Math.min(c,v)+b-1;return this.parent.getValueFromArg(p+K(A)+Math.min(m,d))},n}(Q),yt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ct=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"UNIQUE",category:"Lookup & Reference",description:"Returns a unique values from a range or array."},{formulaName:"SORT",category:"Lookup & Reference",description:"Sorts a range of an array."}],t}return yt(n,e),n.prototype.ComputeUNIQUE=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,s,a=this.parent.getErrorStrings();if("isComputeExp"===n[n.length-1]&&(s=!0,n.pop()),t.isNullOrUndefined(n)||""===n[0]&&1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var u=function(n){if(t.isNullOrUndefined(n))return e.parent.falseValue;var i=e.parent.getValueFromArg(n);return a.indexOf(i)>-1?i:0===Number(i)?e.parent.falseValue:Number(i)<0||Number(i)>0?e.parent.trueValue:(e.parent.isCellReference(n)||(i=e.parent.removeTics(i)),i.toUpperCase()===e.parent.trueValue||i.toUpperCase()===e.parent.falseValue?i.toUpperCase():i.indexOf(e.parent.tic)>-1||n.indexOf(e.parent.tic)>-1?a[r.CommonErrors.Value]:a[r.CommonErrors.Name])},l=u(n[1]);if(a.indexOf(l)>-1)return l;var h=u(n[2]);if(a.indexOf(h)>-1)return h;var p=[];if(n[0].indexOf(":")>-1){if(t.isNullOrUndefined(n[0].match(/[0-9]/))){g=n[0].split(":");n[0]=g[0]+"1:"+g[1]+(this.parent.spreadSheetUsedRange[0]+1)}else if(t.isNullOrUndefined(n[0].toUpperCase().match(/[A-Z]/))){var g=n[0].split(":");n[0]="A"+g[0]+":"+K(this.parent.spreadSheetUsedRange[1]+1)+g[1]}var f=n[0].split(":");if(this.parent.isCellReference(f[0])&&this.parent.isCellReference(f[1])){for(var m=this.parent.dependencyCollection,c=0;c<m.length&&!s;c++)m[c].split(":")[0]===n[0].split(":")[0]&&this.clearDependency(m[c]);-1===this.parent.dependencyCollection.indexOf(n[0])?s||this.parent.dependencyCollection.push(n[0]):this.clearDependency(n[0]);var d=n[0].indexOf(":"),v=void 0,N=this.parent.rowIndex(this.parent.substring(n[0],0,d)),E=this.parent.colIndex(this.parent.substring(n[0],0,d)),S=this.parent.rowIndex(this.parent.substring(n[0],d+1,d+n[0].length-d-1)),y=this.parent.colIndex(this.parent.substring(n[0],d+1,d+n[0].length-d-1));N>S&&(v=S,S=N,N=v),E>y&&(v=y,y=E,E=v);var C="";0===n[0].indexOf("!")&&(C=n[0].substring(0,n[0].replace("!","").indexOf("!")+2)),n[0]=C+K(E)+N+":"+K(y)+S;var b=y-E,A=this.parent.getCellCollection(n[0]),O=void 0,F=void 0;if(O=F=this.parent.actCell,l===this.parent.falseValue)if(0===b)for(c=0;c<A.length;c++)T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T,p.push(T);else for(var x="",V=b,c=0;c<A.length;c++)c===A.length-1&&(x=x+(T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T)+"++",p.push(x.substring(0,x.length-2))),c<=V?x=x+(T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T)+"++":(p.push(x.substring(0,x.length-2)),V=b+c,x=(T=""===(T=this.parent.getValueFromArg(A[c]))?"0":T)+"++");else for(var x="",V=b+1,R=S-N,c=0;c<V;c++){for(var I=0;I<=R;I++){var T=this.parent.getValueFromArg(A[I*V+c]);x=x+(T=""===T?"0":T)+"++"}p.push(x.substring(0,x.length-2)),x=""}for(var M=[],D=[],U=[],w=[],c=0;c<p.length;c++)-1===M.indexOf(p[c].toLowerCase())?(M.push(p[c].toLowerCase()),U.push(p[c])):(-1===D.indexOf(p[c].toLowerCase())&&D.push(p[c].toLowerCase()),w.push(p[c]));if(h===this.parent.trueValue){for(var j=[],c=0;c<U.length;c++)-1===D.indexOf(U[c].toLowerCase())&&j.push(U[c]);if(0===(U=j).length)return a[r.CommonErrors.Calc]}if(s){var L;return 0!==b?(L=[],U.forEach(function(r){L=L.concat(r.split("++"))})):L=l===this.parent.falseValue?U:U[0].split("++"),L}O.indexOf("!")>-1&&(O=O.substring(O.lastIndexOf("!")+1));var k=this.parent.rowIndex(O),P=this.parent.colIndex(O);if(0===this.parent.dependencyLevel){var _=!1;if(l===this.parent.falseValue)for(var c=k,V=U.length+k;c<V;c++)for(var W=P,q=(Z=U[0].split("++")).length+P;W<q;W++)c===V-1&&W===q-1&&-1===this.parent.uniqueRange.indexOf(F+":"+K(W)+c)&&this.parent.uniqueRange.push(F+":"+K(W)+c),this.checkSpill(W,c)&&(_=!0);else for(var c=P,V=U.length+P;c<V;c++)for(var B=k,q=(Z=U[0].split("++")).length+k;B<q;B++)c===V-1&&B===q-1&&-1===this.parent.uniqueRange.indexOf(this.parent.actCell+":"+K(c)+B)&&this.parent.uniqueRange.push(this.parent.actCell+":"+K(c)+B),this.checkSpill(c,B)&&(_=!0);if(_)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill]}else if(this.parent.dependencyLevel>0&&this.parent.getValueFromArg(K(P)+k,!0).indexOf("#SPILL!")>-1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill];if(l===this.parent.falseValue){var X=this.parent.getSheetFamilyItem(this.parent.grid),Y="",H=void 0;null!==X.sheetNameToParentObject&&X.sheetNameToParentObject.size>0&&(H=(Y=X.parentObjectToToken.get(this.parent.grid))+O);for(c=0;c<U.length;c++){Z=U[c].split("++");c>0&&(k++,P=this.parent.colIndex(O));for(var G=0;G<Z.length;G++)this.setValueRefresh(Z[G],k,P),(c>0||G>0)&&this.parent.refreshDependentCells(Y+K(P)+k.toString(),H),Z[G+1]&&P++}o=U[0].split("++")[0]}else{for(c=0;c<U.length;c++)for(var Z=U[c].split("++"),$=0;$<Z.length;$++)this.setValueRefresh(Z[$],k,P),Z[$+1]?k++:(P++,k=this.parent.rowIndex(O));o=U[0].split("++")[0]}}}else if(this.parent.isCellReference(n[0]))-1===this.parent.dependencyCollection.indexOf(n[0])?s||this.parent.dependencyCollection.push(n[0]):this.clearDependency(n[0]),o=this.parent.getValueFromArg(n[0]);else{if(o=this.parent.getValueFromArg(n[0].trim()),a.indexOf(o)>-1)return o;o=this.parent.removeTics(o)}return o},n.prototype.setValueRefresh=function(r,t,e){this.parent.parentObject.setValueRowCol(this.parent.getSheetId(this.parent.grid),r,t,e)},n.prototype.checkSpill=function(t,e){var n,i=!1,o=this.parent.getValueFromArg(K(t)+e,!0),s="!"+this.parent.getSheetID(this.parent.grid)+"!"+K(t)+e;return this.parent.getFormulaInfoTable().get(s)&&(n=this.parent.getFormulaInfoTable().get(s).formulaText),o&&(o.toUpperCase().indexOf("UNIQUE")<0||n&&!n.toUpperCase().includes("UNIQUE"))&&(o.toUpperCase().indexOf("SORT")<0||n&&!n.toUpperCase().includes("SORT"))&&o!==this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]&&(i=!0),i},n.prototype.clearDependency=function(r){var t=this.parent.actCell,e="";if(t.lastIndexOf("!")>-1){var n=t;t=n.substring(n.lastIndexOf("!")+1),e=n.substring(0,n.lastIndexOf("!"))+"!"}for(var i=this.parent.rowIndex(t),o=this.parent.colIndex(t),s=r.indexOf(":"),a=this.parent.rowIndex(this.parent.substring(r,0,s)),u=this.parent.colIndex(this.parent.substring(r,0,s)),l=this.parent.rowIndex(this.parent.substring(r,s+1,s+r.length-s-1))-a+i,h=this.parent.colIndex(this.parent.substring(r,s+1,s+r.length-s-1))-u+o,p=this.parent.getFormulaInfoTable().get("!"+this.parent.getSheetID(this.parent.grid)+"!"+t)?this.parent.getFormulaInfoTable().get("!"+this.parent.getSheetID(this.parent.grid)+"!"+t).getFormulaText():"",g=i;g<=l;g++)for(var f=o;f<=h;f++)if(this.parent.dependencyLevel>0||p.indexOf("UNIQUE")>-1||p.indexOf("SORT")>-1){if(this.parent.getValueFromArg("!"+this.parent.getSheetID(this.parent.grid)+"!"+K(o)+i,!0).indexOf("#SPILL!")>-1)return;this.parent.parentObject.setValueRowCol(this.parent.getSheetID(this.parent.grid)+1,"",g,f),this.parent.refreshDependentCells("!"+this.parent.getSheetID(this.parent.grid)+"!"+K(f)+g,t),this.parent.actCell=e+t}},n.prototype.ComputeSORT=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o,a;n.length&&"nestedFormulaTrue"===n[n.length-1]&&(o=!0,n.pop());var u,l=n,h=[];if(t.isNullOrUndefined(n)||""===n[0]||l.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];l[1]=l[1]?l[1]:"1",l[2]=l[2]?l[2]:"1",l[3]=l[3]?l[3]:"FALSE",l[0]=l[0].split("$").join("");var p,g=[];if(l[0].indexOf(":")>-1){if(t.isNullOrUndefined(l[0].match(/[0-9]/))){f=l[0].split(":");l[0]=f[0]+"1:"+f[1]+(this.parent.spreadSheetUsedRange[0]+1)}else if(t.isNullOrUndefined(l[0].toUpperCase().match(/[A-Z]/))){var f=l[0].split(":");l[0]="A"+f[0]+":"+K(this.parent.spreadSheetUsedRange[1]+1)+f[1]}var m=l[0].split(":");if(this.parent.isCellReference(m[0])&&this.parent.isCellReference(m[1])){for(var c=this.parent.dependencyCollection,d=0;d<c.length&&!o;d++)c[d].split(":")[0]===l[0].split(":")[0]&&this.clearDependency(c[d]);-1===this.parent.dependencyCollection.indexOf(l[0])?o||this.parent.dependencyCollection.push(l[0]):this.clearDependency(l[0]);var v=l[0].indexOf(":"),N=void 0,E=this.parent.rowIndex(this.parent.substring(l[0],0,v)),S=this.parent.colIndex(this.parent.substring(l[0],0,v)),y=this.parent.rowIndex(this.parent.substring(l[0],v+1,v+l[0].length-v-1)),C=this.parent.colIndex(this.parent.substring(l[0],v+1,v+l[0].length-v-1));if(E>y&&(N=y,y=E,E=N),S>C&&(N=C,C=S,S=N),this.parent.isCellReference(l[3])){if(l[3]=this.parent.getValueFromArg(l[3]).toUpperCase(),l[3]!==this.parent.trueValue&&l[3]!==this.parent.falseValue)if(s(l[3]))l[3]=0===Number(l[3])?this.parent.falseValue:this.parent.trueValue;else{if(""!==l[3])return this.parent.getErrorStrings()[r.CommonErrors.Value];l[3]=this.parent.falseValue}}else if(a=l[3].startsWith(this.parent.tic)&&l[3].endsWith(this.parent.tic),l[3]=this.parent.getValueFromArg(l[3]),l[3]=s(l[3])?0===Number(l[3])?this.parent.falseValue:this.parent.trueValue:l[3].split(this.parent.tic).join("").toUpperCase(),l[3]!==this.parent.trueValue&&l[3]!==this.parent.falseValue)return this.parent.getErrorStrings()[a?r.CommonErrors.Value:r.CommonErrors.Name];if(this.parent.isCellReference(l[2])?(l[2]=this.parent.getValueFromArg(l[2]),l[2]=l[2]===this.parent.trueValue?"1":l[2]):(l[2]=this.parent.getValueFromArg(l[2]),l[2]=l[2]===this.parent.trueValue?"1":l[2].split(this.parent.tic).join("")),l[2]=s(l[2])?Math.floor(Number(l[2])).toString():l[2],"1"!==l[2]&&"-1"!==l[2])return this.parent.getErrorStrings().indexOf(l[2])>-1?this.parent.getErrorStrings()[r.CommonErrors.Name]:this.parent.getErrorStrings()[r.CommonErrors.Value];var b="1"===l[2]?"Ascending":"Descending";if(this.parent.isCellReference(l[1])){if(l[1]=this.parent.getValueFromArg(l[1]),l[1]=s(l[1])?Math.floor(Number(l[1])).toString():l[1]===this.parent.trueValue?"1":l[1]===this.parent.falseValue?"0":l[1],isNaN(this.parseDouble(l[1]))||(this.parseDouble(l[1])<1||(l[3]===this.parent.trueValue?y-E+1<this.parseDouble(l[1]):C-S+1<this.parseDouble(l[1]))))return this.parent.getErrorStrings()[r.CommonErrors.Value]}else if(a=l[1].startsWith(this.parent.tic)&&l[1].endsWith(this.parent.tic),l[1]=this.parent.getValueFromArg(l[1]),l[1]=s(l[1])?Math.floor(Number(l[1])).toString():l[1]===this.parent.trueValue?"1":l[1]===this.parent.falseValue?"0":l[1].split(this.parent.tic).join(""),isNaN(this.parseDouble(l[1]))?a:this.parseDouble(l[1])<1||(l[3]===this.parent.trueValue?y-E+1<this.parseDouble(l[1]):C-S+1<this.parseDouble(l[1])))return this.parent.getErrorStrings()[r.CommonErrors.Value];var A="";0===l[0].indexOf("!")&&(A=(A=(A=l[0]).replace("!","")).indexOf("!"),A=l[0].substring(0,A+2)),l[0]=A+K(S)+E+":"+K(C)+y,p=this.parent.getCellCollection(l[0]);for(d=0;d<p.length;d++)g.push(this.parent.getValueFromArg(p[d]));var O=[],F=[],x=[],V=[],R=[],I=C-S+1,T=function(r){r?"TRUE"===r.toUpperCase()||"FALSE"===r.toUpperCase()?(V.push(r),O.push(r)):isNaN(e.parseDouble(r))?(x.push(r),O.push(r)):(F.push(e.parseDouble(r)),O.push(e.parseDouble(r))):""===r&&(R.push(e.parseDouble(r).toString()),O.push(e.parseDouble(r).toString()))};if("TRUE"===l[3])for(d=0;d<I;d++)T(g[d+(this.parseDouble(l[1])-1)*I]);if("FALSE"===l[3])for(d=0;d<g.length;d++)T(g[d*I+this.parseDouble(l[1])-1]);for(var M=F.length>0?G(F,b):[],D=x.length>0?G(x,b):[],U=V.length>0?G(V,b):[],w="Ascending"===b?M.concat(D,U,R):U.concat(D,M,R),j=[],L=0;L<w.length;L++)for(var k=0;k<O.length;k++)JSON.stringify(w[L])===JSON.stringify(O[k])&&-1===j.indexOf(k)&&j.push(k);var P=void 0,_=void 0;P=(P=_=this.parent.actCell)?P.indexOf("!")>-1?P.substring(P.lastIndexOf("!")+1):P:this.parent.actCell;var W=this.parent.rowIndex(P),q=this.parent.colIndex(P);if(0===this.parent.dependencyLevel){for(var B=!1,X="TRUE"===l[3]?y-E+1:j.length,Y="TRUE"===l[3]?j.length:C-S+1,H=0;H<X;H++)for(var Z=0;Z<Y;Z++)if(this.checkSpill(q+Z,W+H)&&(B=!0),H===X-1&&Z===Y-1){var $=K(q+Z)+(W+H);-1===this.parent.sortRange.indexOf(_+":"+$)&&this.parent.sortRange.push(_+":"+$)}if(B)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill]}else if(this.parent.dependencyLevel>0&&this.parent.getValueFromArg(K(q)+W,!0).indexOf("#SPILL!")>-1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.Spill];if("TRUE"===l[3]){for(var z=E,Q=0;z<=y;z++,Q++)for(var L=0,J=0;L<j.length;L++,J++){var rr=this.parent.getValueFromArg(A+K(j[L]+S)+z);if(o&&""!==rr)h.push(rr);else{rr=""===rr?"0":rr;var tr=this.parent.cell;if(tr){tr=tr.indexOf("!")>-1?tr.substring(tr.lastIndexOf("!")+1):tr;var er=this.parent.rowIndex(tr),nr=this.parent.colIndex(tr);this.parent.parentObject.setValueRowCol(this.parent.getSheetID(this.parent.grid)+1,rr,er+Q,nr+J)}}}u=this.parent.getValueFromArg(A+K(j[0]+S)+E)}if("FALSE"===l[3]){for(var L=0,Q=0;L<j.length;L++,Q++)for(var ir=S,J=0;ir<=C;ir++,J++){var or=this.parent.getValueFromArg(A+K(ir)+(j[L]+E));if(o&&""!==or)h.push(or);else{or=""===or?"0":or;var sr=this.parent.cell;if(sr){sr=sr.indexOf("!")>-1?sr.substring(sr.lastIndexOf("!")+1):sr;var ar=this.parent.colIndex(sr),ur=this.parent.rowIndex(sr);this.parent.parentObject.setValueRowCol(this.parent.getSheetID(this.parent.grid)+1,or,ur+Q,ar+J)}}}u=this.parent.getValueFromArg(A+K(S)+(j[0]+E))}}}else if(this.parent.isCellReference(l[0]))-1===this.parent.dependencyCollection.indexOf(l[0])?o||this.parent.dependencyCollection.push(l[0]):this.clearDependency(l[0]),u=this.parent.getValueFromArg(l[0]);else{if(u=l[0].trim(),this.parent.getErrorStrings().indexOf(u)>-1)return u;u=this.parent.removeTics(u)}return o?h.join(","):""===u?"0":u},n}(Q),bt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),At=function(e){function n(r){var t=e.call(this,r)||this;return t.isConcat=!1,t.formulas=[{formulaName:"FIND",category:"Text",description:"Returns the position of a string of text within another string."},{formulaName:"CONCATENATE",category:"Text",description:" Used to join two or more strings together."},{formulaName:"CONCAT",category:"Text",description:"Concatenates a list or range of text strings."},{formulaName:"T",category:"Text",description:"Checks whether a value is text or not and returns the text."},{formulaName:"EXACT",category:"Text",description:"Checks whether a two text strings are exactly same and returns TRUE or FALSE."},{formulaName:"LEN",category:"Text",description:"Returns a number of characters in a given string."},{formulaName:"CHAR",category:"Text",description:"Returns the character from the specified number."},{formulaName:"CODE",category:"Text",description:"Returns the numeric code for the first character in a given string."},{formulaName:"DOLLAR",category:"Text",description:"Converts the number to currency formatted text."},{formulaName:"PROPER",category:"Text",description:"Converts a text to proper case; first letter to uppercase and other letters to lowercase."}],t}return bt(n,e),n.prototype.ComputeFIND=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=this.parent.getErrorStrings();if(t.isNullOrUndefined(n)||1===n.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(n.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s=function(r){var n=e.parent.getValueFromArg(r);return n=t.isNullOrUndefined(n)?"":n.toString(),o.indexOf(n)>-1?n:(e.parent.isCellReference(r)||(2===n.split("%").length&&e.parent.isNumber(n.split("%")[0])?n=(.01*Number(n.split("%")[0])).toString():r.indexOf(e.parent.tic)>-1&&(e.parent.removeTics(r).match(/^(\d*\.\d+|\d+)\s*[-*/]\s*(\d*\.\d+|\d+)$/)?(n=e.parent.getValueFromArg(e.parent.removeTics(r)),n=t.isNullOrUndefined(n)?"":n.toString()):n.indexOf(e.parent.tic+e.parent.tic)>-1&&(n=n.replace(/""/g,e.parent.tic)))),n)},a="";if(!t.isNullOrUndefined(n[0])){if(a=s(n[0]),o.indexOf(a)>-1)return a;this.parent.isCellReference(n[0])||(a=this.parent.removeTics(a))}var u="";if(!t.isNullOrUndefined(n[1])){if(u=s(n[1]),o.indexOf(u)>-1)return u;this.parent.isCellReference(n[1])||(u=this.parent.removeTics(u))}var l=1;if(!t.isNullOrUndefined(n[2])){if(l=s(n[2]),o.indexOf(l)>-1)return l;if(l.toUpperCase()===this.parent.trueValue?l="1":l.toUpperCase()===this.parent.falseValue&&(l="0"),this.parent.isCellReference(n[2])||(l=this.parent.removeTics(l)),l=this.parent.parseFloat(l),isNaN(l)||l<=0)return o[r.CommonErrors.Value]}return l=u.indexOf(a,l-1),l<0?o[r.CommonErrors.Value]:(Number(l)+Number(1)).toString()},n.prototype.ComputeCONCATENATE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var o=e,s="",a="",u=0;u<o.length;u++){var l=o[u];if(this.parent.isCellReference(l)){if(l.indexOf(":")>-1){if(!this.isConcat)return i[r.CommonErrors.Value];for(var p=this.parent.getCellCollection(l),g=0;g<p.length;g++)s+=this.parent.getValueFromArg(p[g])}else{if(1===o.length&&o[0].indexOf(this.parent.tic)<0&&!h(o[0]))return i[r.CommonErrors.Name];a=this.parent.getValueFromArg(l)}if(i.indexOf(a)>-1)return a}else if(l.startsWith(this.parent.tic)&&l.endsWith(this.parent.tic)&&l.indexOf('""')>-1?a=(a=l.substring(1,l.length-1)).replace(/""/g,'"'):(a=l.split(this.parent.tic).join(""),(this.parent.isNumber(a)||t.isNullOrUndefined(this.parent.isDate(a))||l.startsWith(" n"))&&(a=this.parent.getValueFromArg(l).split(this.parent.tic).join(""))),i.indexOf(a)>-1)return a;s+=a}return this.isConcat=!1,s},n.prototype.ComputeCONCAT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e;return this.isConcat=!0,(e=this.owner).ComputeCONCATENATE.apply(e,r)},n.prototype.ComputeT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(o=!0,e.pop()),t.isNullOrUndefined(e)||1===e.length&&""===e[0].trim())return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>1)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(i=this.parent.getValueFromArg(e[0]).trim(),s.indexOf(i)>-1)return i;if(e[0].indexOf(this.parent.tic)>-1)(i=this.parent.removeTics(e[0].trim())).indexOf(this.parent.tic+this.parent.tic)>-1&&(i=i.replace(/""/g,this.parent.tic));else if(2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),this.parent.isNumber(i)||i.toUpperCase()===this.parent.trueValue||i.toUpperCase()===this.parent.falseValue)return"";return o&&(i=this.parent.tic+i+this.parent.tic),i},n.prototype.ComputeEXACT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=!1,i=t.length&&"nestedFormulaTrue"===t[t.length-1],o=this.parent.getErrorStrings();if(i&&t.pop(),!t||!t[0]&&1===t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(2!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var s,a,u;if(t[0]){if(s=this.parent.getValueFromArg(t[0]),o.indexOf(s)>-1)return s;-1===s.indexOf(this.parent.tic)&&s.includes("%")&&(s=(Number(s.split("%")[0])/100).toString()),this.parent.isCellReference(t[0])?u=!0:s=s.split(this.parent.tic).join("")}if(t[1]){if(a=this.parent.getValueFromArg(t[1]),o.indexOf(a)>-1)return a;-1===a.indexOf(this.parent.tic)&&a.includes("%")&&(a=(Number(a.split("%")[0])/100).toString()),this.parent.isCellReference(t[1])?u||0!==s.trim().length||0!==a.trim().length||(n=!1):(a=a.split(this.parent.tic).join(""),u&&0===s.trim().length&&0===a.trim().length&&(n=!1))}return s===a&&(n=!0),i?n?"1":"0":n},n.prototype.ComputeLEN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||""===e[0].trim()&&1===e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]),o.indexOf(i)>-1?i:(e[0].indexOf(this.parent.tic)>-1?e[0]!==i&&e[0].startsWith("n")?i=this.parent.removeTics(i.trim()):(i=this.parent.removeTics(e[0].trim())).indexOf(this.parent.tic+this.parent.tic)>-1&&(i=i.replace(/""/g,this.parent.tic)):!e[0].startsWith("n")&&2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])?i=(Number(i.split("%")[0])/100).toString():this.parent.isNumber(i)&&(i=i.trim()),i.length))},n.prototype.ComputeCHAR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]).trim();if(i.indexOf(o)>-1)return o;if(o.indexOf('"TRUE"')>-1||this.parent.isCellReference(e[0])&&o.startsWith(this.parent.tic))return i[r.CommonErrors.Value];if(o=o.split(this.parent.tic).join(""),this.parent.isNumber(o)?o=Math.floor(Number(o)).toString():o.indexOf("%")>-1?o=Math.floor(Number(o.split("%")[0])/100).toString():o===this.parent.trueValue&&(o="1"),!o.toUpperCase().match(/^[0-9]+$/))return i[r.CommonErrors.Value];var s=parseInt(o,10);return s>255||s<=0?i[r.CommonErrors.Value]:String.fromCharCode(s)},n.prototype.ComputeCODE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o=this.parent.getErrorStrings();return t.isNullOrUndefined(e)||1===e.length&&""===e[0].trim()?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]).trim(),o.indexOf(i)>-1?i:(e[0].indexOf(this.parent.tic)>-1?i=e[0]!==i&&e[0].startsWith("n")?this.parent.removeTics(i.trim()):this.parent.removeTics(e[0].trim()):!e[0].startsWith("n")&&2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),""===i?o[r.CommonErrors.Value]:i=i.charCodeAt(0)))},n.prototype.ComputeDOLLAR=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s;if(e.length&&"nestedFormulaTrue"===e[e.length-1]&&(s=!0,e.pop()),1===e.length&&(""===e[0]&&(o=!0),e.push("2")),t.isNullOrUndefined(e)||2!==e.length||o)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];for(var a=0;a<e.length;a++)if(e[a].indexOf(this.parent.tic)>-1&&isNaN(this.parent.parseFloat(e[a])))return this.parent.getErrorStrings()[r.CommonErrors.Value];var u=this.parent.getValueFromArg(e[0]).split(this.parent.tic).join(""),l=this.parent.getValueFromArg(e[1]).split(this.parent.tic).join("");if(u=""===u||u===this.parent.falseValue?"0":u===this.parent.trueValue?"1":u,l=""===l||l===this.parent.falseValue?"0":l===this.parent.trueValue?"1":l,"#NAME?"===u||"#NAME?"===l)return this.parent.getErrorStrings()[r.CommonErrors.Name];if(!u.toUpperCase().match(/^[-]?[0-9.]+$/)||!l.toUpperCase().match(/^[-]?[0-9.]+$/))return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var h=new t.Internationalization,p=parseInt(l,10),g=Math.pow(10,-1*p),f="",m=1;m<=p;m++)f+="0";var c=Math.round(this.parent.parseFloat(u)/g)*g;return i=isNaN(c)?this.parent.getErrorStrings()[r.CommonErrors.Value]:h.formatNumber(c,{format:"$#,##0."+f+";($#,##0."+f+");$0."+f}),s&&(i=this.parent.tic+i+this.parent.tic),i},n.prototype.ComputePROPER=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i,o,s=this.parent.getErrorStrings();return e.length&&"nestedFormulaTrue"===e[e.length-1]&&(o=!0,e.pop()),t.isNullOrUndefined(e)||""===e[0].trim()&&1===e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]:e.length>1?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:(i=this.parent.getValueFromArg(e[0]).trim(),s.indexOf(i)>-1?i:(e[0].indexOf(this.parent.tic)>-1?e[0]!==i&&e[0].startsWith("n")?i=this.parent.removeTics(i.trim()):(i=this.parent.removeTics(e[0].trim())).indexOf(this.parent.tic+this.parent.tic)>-1&&(i=i.replace(/""/g,this.parent.tic)):!e[0].startsWith("n")&&2===i.split("%").length&&this.parent.isNumber(i.split("%")[0])&&(i=(Number(i.split("%")[0])/100).toString()),i=i.toLowerCase().replace(/\b\w/g,function(r){return r.toUpperCase()}).replace(/(\d)([a-z])/g,function(r,t,e){return t+e.toUpperCase()}),o&&(i=this.parent.tic+i+this.parent.tic),i))},n}(Q),Ot=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ft=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"LEFT",category:"Text",description:"Returns the leftmost characters from a text value."},{formulaName:"RIGHT",category:"Text",description:"Returns the rightmost characters from a text value."},{formulaName:"MID",category:"Text",description:"Returns a specific number of characters from a text string starting at the position you specify."},{formulaName:"UPPER",category:"Text",description:"Converts text to uppercase."},{formulaName:"LOWER",category:"Text",description:"Converts text to lowercase."},{formulaName:"TRIM",category:"Text",description:"Removes spaces from text except for single spaces between words."},{formulaName:"REPLACE",category:"Text",description:"Replaces characters within text."},{formulaName:"SUBSTITUTE",category:"Text",description:"Substitutes new text for old text in a text string."},{formulaName:"REPT",category:"Text",description:"Repeats text a given number of times."},{formulaName:"SEARCH",category:"Text",description:"Finds one text value within another (not case-sensitive)."},{formulaName:"VALUE",category:"Text",description:"Converts a text argument to a number."},{formulaName:"CLEAN",category:"Text",description:"Removes all nonprintable characters from text."},{formulaName:"FIXED",category:"Text",description:"Formats a number as text with a fixed number of decimals."},{formulaName:"TEXTJOIN",category:"Text",description:"Combines text from multiple ranges/strings with a delimiter."},{formulaName:"LEFTB",category:"Text",description:"Returns the leftmost characters from a text value (byte count alias)."},{formulaName:"RIGHTB",category:"Text",description:"Returns the rightmost characters from a text value (byte count alias)."},{formulaName:"MIDB",category:"Text",description:"Returns characters from a text string (byte count alias)."},{formulaName:"REPLACEB",category:"Text",description:"Replaces characters within text (byte count alias)."},{formulaName:"SEARCHB",category:"Text",description:"Finds one text value within another (byte count alias)."}],t}return Ot(n,e),n.prototype.ComputeLEFT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.substringSide(r,!0)},n.prototype.ComputeRIGHT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.substringSide(r,!1)},n.prototype.substringSide=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1===e.length&&""===e[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=1;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;if((s=Math.floor(a))<0)return i[r.CommonErrors.Value]}return n?o.substring(0,s):s>=o.length?o:o.substring(o.length-s)},n.prototype.ComputeMID=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof s)return s;if("string"==typeof a)return a;var u=Math.floor(s),l=Math.floor(a);return u<1||l<0?i[r.CommonErrors.Value]:o.substring(u-1,u-1+l)},n.prototype.ComputeUPPER=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.caseTransform(r,!0)},n.prototype.ComputeLOWER=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.caseTransform(r,!1)},n.prototype.caseTransform=function(e,n){var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);return i.indexOf(o)>-1?o:n?o.toUpperCase():o.toLowerCase()},n.prototype.ComputeTRIM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);return i.indexOf(o)>-1?o:o.trim().replace(/\s+/g," ")},n.prototype.ComputeREPLACE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||4!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveTextArg(e[3]);if("string"==typeof s)return s;if("string"==typeof a)return a;if(i.indexOf(u)>-1)return u;var l=Math.floor(s),h=Math.floor(a);return l<1||h<0?i[r.CommonErrors.Value]:o.substring(0,l-1)+u+o.substring(l-1+h)},n.prototype.ComputeSUBSTITUTE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]),s=this.resolveTextArg(e[1]),a=this.resolveTextArg(e[2]);if(i.indexOf(o)>-1)return o;if(i.indexOf(s)>-1)return s;if(i.indexOf(a)>-1)return a;if(""===s)return o;if(3===e.length)return o.split(s).join(a);var u=this.resolveNumberArg(e[3]);if("string"==typeof u)return u;var l=Math.floor(u);if(l<1)return i[r.CommonErrors.Value];for(var h=0,p=o.indexOf(s);p>-1;){if(++h===l)return o.substring(0,p)+a+o.substring(p+s.length);p=o.indexOf(s,p+s.length)}return o},n.prototype.ComputeREPT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;var a=Math.floor(s);return a<0?i[r.CommonErrors.Value]:0===a||""===o?"":new Array(a+1).join(o)},n.prototype.ComputeSEARCH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]).toLowerCase(),s=this.resolveTextArg(e[1]).toLowerCase();if(i.indexOf(o)>-1)return o;if(i.indexOf(s)>-1)return s;var a=1;if(3===e.length){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;if((a=Math.floor(u))<1)return i[r.CommonErrors.Value]}var l=s.indexOf(o,a-1);return l<0?i[r.CommonErrors.Value]:(l+1).toString()},n.prototype.ComputeVALUE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;if(""===o)return"0";var s=o.replace(/,/g,"").replace(/\$/g,"").trim(),a=this.parent.parseFloat(s);return isNaN(a)?i[r.CommonErrors.Value]:a.toString()},n.prototype.ComputeCLEAN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;for(var s="",a=0;a<o.length;a++)o.charCodeAt(a)>=32&&(s+=o.charAt(a));return s},n.prototype.ComputeFIXED=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=2;if(e.length>=2&&""!==e[1]){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=Math.floor(s)}var a=!1;if(3===e.length&&""!==e[2]){var u=this.parent.getValueFromArg(e[2]).toUpperCase();a=u===this.parent.trueValue||0!==this.parent.parseFloat(u)}if(o<0){var l=Math.pow(10,-o),h=Math.round(i/l)*l;return a?h.toString():h.toLocaleString("en-US")}var p=i.toFixed(o);if(a)return p;var g=p.split("."),f=g[0],m="-"===f.charAt(0)?"-":"";m&&(f=f.substring(1));for(var c="",d=0;d<f.length;d++){var v=f.length-d;d>0&&v%3==0&&(c+=","),c+=f.charAt(d)}return g[0]=m+c,g.join(".")},n.prototype.ComputeTEXTJOIN=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;for(var s=this.parent.getValueFromArg(e[1]).toUpperCase(),a=s===this.parent.trueValue||!isNaN(this.parent.parseFloat(s))&&0!==this.parent.parseFloat(s),u=[],l=2;l<e.length;l++){var h=e[l];if(this.parent.isCellReference(h)&&h.indexOf(":")>-1)for(var p=this.parent.getCellCollection(h),g=Array.isArray(p)?p:[p],f=0;f<g.length;f++){m=this.parent.getValueFromArg(g[f]);if(i.indexOf(m)>-1)return m;a&&""===m||u.push(m)}else{var m=this.resolveTextArg(h);if(i.indexOf(m)>-1)return m;a&&""===m||u.push(m)}}return u.join(o)},n.prototype.ComputeLEFTB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeLEFT.apply(this,r)},n.prototype.ComputeRIGHTB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeRIGHT.apply(this,r)},n.prototype.ComputeMIDB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeMID.apply(this,r)},n.prototype.ComputeREPLACEB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeREPLACE.apply(this,r)},n.prototype.ComputeSEARCHB=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.ComputeSEARCH.apply(this,r)},n}(Q),xt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Vt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ASC",category:"Text",description:"Changes full-width characters to half-width."},{formulaName:"TEXTBEFORE",category:"Text",description:"Returns text before a given character or string."},{formulaName:"VALUETOTEXT",category:"Text",description:"Returns text from any specified value."},{formulaName:"ARRAYTOTEXT",category:"Text",description:"Returns the text representation of an array."}],t}return xt(n,e),n.prototype.ComputeASC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveTextArg(e[0]);if(this.parent.getErrorStrings().indexOf(i)>-1)return i;for(var o="",s=0;s<i.length;s++){var a=i.charCodeAt(s);o+=a>=65281&&a<=65374?String.fromCharCode(a-65248):12288===a?" ":i.charAt(s)}return o},n.prototype.ComputeTEXTBEFORE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]);if(i.indexOf(o)>-1)return o;var s=this.resolveTextArg(e[1]);if(i.indexOf(s)>-1)return s;var a=1;if(e.length>=3&&""!==e[2]){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;if((a=Math.floor(u))<1)return i[r.CommonErrors.Value]}for(var l=0,h=0;h<a;h++){var p=o.indexOf(s,l);if(p<0)return e.length>=6&&""!==e[5]?this.resolveTextArg(e[5]):i[r.CommonErrors.NA];if(h===a-1)return o.substring(0,p);l=p+s.length}return o},n.prototype.ComputeVALUETOTEXT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.parent.getErrorStrings(),o=this.parent.getValueFromArg(e[0]);if(i.indexOf(o)>-1)return o;if(""===o)return"";var s=!0;if(2===e.length){var a=this.resolveNumberArg(e[1]);if("string"==typeof a)return a;s=0===a}return!s&&!this.parent.isCellReference(e[0])&&e[0].indexOf(this.parent.tic)>-1?this.parent.removeTics(o):o},n.prototype.ComputeARRAYTOTEXT=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(t.isNullOrUndefined(n)||n.length<1||n.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getErrorStrings(),s=[],a=function(r){if(e.parent.isCellReference(r)&&r.indexOf(":")>-1)for(var t=e.parent.getCellCollection(r),n=Array.isArray(t)?t:[t],i=0;i<n.length;i++){a=e.parent.getValueFromArg(n[i]);if(o.indexOf(a)>-1)return a;s.push(a)}else{var a=e.resolveTextArg(r);if(o.indexOf(a)>-1)return a;s.push(a)}return null}(n[0]);return a||s.join(this.parent.getParseArgumentSeparator())},n}(Q),Rt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),It=function(t){function e(r){var e=t.call(this,r)||this;return e.formulas=[{formulaName:"ISNUMBER",category:"Information",description:"Returns TRUE, if the argument is number and FALSE otherwise."}],e}return Rt(e,t),e.prototype.ComputeISNUMBER=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n,i=t;if(i&&"nestedFormulaTrue"===i[i.length-1]&&(n=!0,i.pop()),1===t.length&&""===t[0])return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments];if(1!==t.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.isCellReference(i[0])?this.parent.getValueFromArg(i[0]):this.parent.getValueFromArg(i[0].split(this.parent.tic).join(""));if(""===o.toString()||t.toString().startsWith(this.parent.tic))return!!n&&"0";var s=!isNaN(this.parent.parseFloat(o));return n?s?"1":"0":s},e}(Q),Tt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Mt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ISBLANK",category:"Information",description:"Returns TRUE if the value is blank."},{formulaName:"ISTEXT",category:"Information",description:"Returns TRUE if the value is text."},{formulaName:"ISNONTEXT",category:"Information",description:"Returns TRUE if the value is not text."},{formulaName:"ISLOGICAL",category:"Information",description:"Returns TRUE if the value is a logical value."},{formulaName:"ISERROR",category:"Information",description:"Returns TRUE if the value is any error value."},{formulaName:"ISERR",category:"Information",description:"Returns TRUE if the value is any error value except #N/A."},{formulaName:"ISNA",category:"Information",description:"Returns TRUE if the value is the #N/A error value."},{formulaName:"ISEVEN",category:"Information",description:"Returns TRUE if the number is even."},{formulaName:"ISODD",category:"Information",description:"Returns TRUE if the number is odd."},{formulaName:"N",category:"Information",description:"Returns a value converted to a number."},{formulaName:"NA",category:"Information",description:"Returns the error value #N/A."},{formulaName:"TYPE",category:"Information",description:"Returns a number indicating the data type of a value."}],t}return Tt(n,e),n.prototype.requireOne=function(e){return t.isNullOrUndefined(e)||1!==e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:null},n.prototype.ComputeISBLANK=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);return e||(this.parent.isCellReference(r[0]),""===this.parent.getValueFromArg(r[0]))},n.prototype.ComputeISTEXT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]);return!(this.parent.getErrorStrings().indexOf(n)>-1)&&(""!==n&&(n.toUpperCase()!==this.parent.trueValue&&n.toUpperCase()!==this.parent.falseValue&&(isNaN(this.parent.parseFloat(n))||!this.parent.isCellReference(r[0])&&r[0].indexOf(this.parent.tic)>-1)))},n.prototype.ComputeISNONTEXT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeISTEXT.apply(this,r);return"string"==typeof e?e:!e},n.prototype.ComputeISLOGICAL=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]).toUpperCase();return n===this.parent.trueValue||n===this.parent.falseValue},n.prototype.ComputeISERROR=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]);return this.parent.getErrorStrings().indexOf(n)>-1||/^#[A-Z/?!]+$/.test(n)},n.prototype.ComputeISERR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireOne(t);if(n)return n;var i=this.parent.getValueFromArg(t[0]);return i!==this.parent.getErrorStrings()[r.CommonErrors.NA]&&"#N/A"!==i&&(this.parent.getErrorStrings().indexOf(i)>-1||/^#[A-Z/?!]+$/.test(i))},n.prototype.ComputeISNA=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireOne(t);if(n)return n;var i=this.parent.getValueFromArg(t[0]);return i===this.parent.getErrorStrings()[r.CommonErrors.NA]||"#N/A"===i},n.prototype.ComputeISEVEN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parity(r,!0)},n.prototype.ComputeISODD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.parity(r,!1)},n.prototype.parity=function(t,e){var n=this.parent.getErrorStrings(),i=this.requireOne(t);if(i)return i;var o=this.resolveNumberArg(t[0]);if("string"==typeof o)return n[r.CommonErrors.Value];var s=(o<0?Math.ceil(o):Math.floor(o))%2==0;return e?s:!s},n.prototype.ComputeN=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.parent.getErrorStrings(),n=this.requireOne(r);if(n)return n;var i=this.parent.getValueFromArg(r[0]);if(e.indexOf(i)>-1)return i;if(i.toUpperCase()===this.parent.trueValue)return"1";if(i.toUpperCase()===this.parent.falseValue||""===i)return"0";var o=this.parent.parseFloat(i);return isNaN(o)?"0":o.toString()},n.prototype.ComputeNA=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t&&1===t.length&&""===t[0]?this.parent.getErrorStrings()[r.CommonErrors.NA]:t&&t.length>0&&(1!==t.length||""!==t[0])?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.parent.getErrorStrings()[r.CommonErrors.NA]},n.prototype.ComputeTYPE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireOne(r);if(e)return e;var n=this.parent.getValueFromArg(r[0]);return this.parent.getErrorStrings().indexOf(n)>-1||/^#[A-Z/?!]+$/.test(n)?"16":n.toUpperCase()===this.parent.trueValue||n.toUpperCase()===this.parent.falseValue?"4":""===n||isNaN(this.parent.parseFloat(n))||!this.parent.isCellReference(r[0])&&-1!==r[0].indexOf(this.parent.tic)?"2":"1"},n}(Q),Dt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Ut=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"INFO",category:"Information",description:"Returns information about the current operating environment."},{formulaName:"CELL",category:"Information",description:"Returns information about the formatting, location, or contents of a cell."}],t}return Dt(n,e),n.prototype.ComputeINFO=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]).toLowerCase();if(i.indexOf(o)>-1)return o;if(-1===["system","release","numfile","directory","origin","recalc","memavail","memused"].indexOf(o))return i[r.CommonErrors.NA];var s=o;switch(s){case"system":return"pcdos";case"release":return"16.0";case"numfile":return"1";case"directory":return"/";case"origin":return"A1";case"recalc":return"Manual"===this.parent.parentObject.calculationMode?"Manual":"Automatic";case"memavail":return"1048576";case"memused":return"0";default:return s}},n.prototype.ComputeCELL=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveTextArg(e[0]).toLowerCase();if(i.indexOf(o)>-1)return o;var s=2===e.length?e[1]:this.parent.actCell||this.parent.cell||"A1";if(s=s.split("$").join(""),!this.parent.isCellReference(s.split(":")[0]))return i[r.CommonErrors.Value];var a=s.indexOf(":")>-1?s.split(":")[0]:s,u=a.indexOf("!")>-1?a.substring(a.lastIndexOf("!")+1):a,l=this.parent.getValueFromArg(a);switch(o){case"address":return"$"+u.replace(/([A-Z]+)(\d+)/,"$1$$$2");case"col":return this.parent.colIndex(u).toString();case"row":return this.parent.rowIndex(u).toString();case"contents":return l;case"format":return"G";case"prefix":return"";case"protect":return"0";case"type":return""===l?"b":this.parent.isNumber(l)?"v":"l";case"width":return"8";case"parentheses":return"0";default:return i[r.CommonErrors.NA]}},n}(Q),wt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),jt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DATEDIF",category:"Date & Time",description:"Calculates the number of days, months, or years between two dates."},{formulaName:"NETWORKDAYS.INTL",category:"Date & Time",description:"Returns workdays between dates for a custom weekend."},{formulaName:"WORKDAY.INTL",category:"Date & Time",description:"Returns the date before or after a number of workdays with a custom weekend."}],t}return wt(n,e),n.prototype.toSerial=function(t){var e=this.parent.getErrorStrings(),n=this.parent.getValueFromArg(t);if(e.indexOf(n)>-1)return n;if(this.parent.isCellReference(t)||(n=this.parent.removeTics(n)),""===n)return e[r.CommonErrors.Value];if(this.parent.isNumber(n))return Math.floor(this.parent.parseFloat(n));var i=this.parent.isDate(new Date(n));return i?Math.floor(this.parent.toOADate(i)):e[r.CommonErrors.Value]},n.prototype.holidaySet=function(r){var t=new Set;if(!r||""===r)return t;var e=this.parent.getErrorStrings();if(this.parent.isCellReference(r)&&r.indexOf(":")>-1){for(var n=this.parent.getCellCollection(r),i=Array.isArray(n)?n:[n],o=0;o<i.length;o++)if("string"!=typeof(s=this.toSerial(i[o])))t.add(s);else if(e.indexOf(s)>-1)return s}else{var s=this.toSerial(r);if("string"==typeof s)return s;t.add(s)}return t},n.prototype.weekendMask=function(t){var e=[!1,!1,!1,!1,!1,!0,!0];if(!t||""===t)return e;var n=this.parent.getErrorStrings(),i=this.resolveTextArg(t);if(n.indexOf(i)>-1)return i;if(7===i.length&&/^[01]+$/.test(i)){for(var o=[],s=0;s<7;s++)o.push("1"===i.charAt(s));return o}var a=this.resolveNumberArg(t);return"string"==typeof a?a:{1:[!1,!1,!1,!1,!1,!0,!0],2:[!0,!1,!1,!1,!1,!1,!0],3:[!0,!0,!1,!1,!1,!1,!1],4:[!1,!0,!0,!1,!1,!1,!1],5:[!1,!1,!0,!0,!1,!1,!1],6:[!1,!1,!1,!0,!0,!1,!1],7:[!1,!1,!1,!1,!0,!0,!1],11:[!0,!1,!1,!1,!1,!1,!1],12:[!1,!0,!1,!1,!1,!1,!1],13:[!1,!1,!0,!1,!1,!1,!1],14:[!1,!1,!1,!0,!1,!1,!1],15:[!1,!1,!1,!1,!0,!1,!1],16:[!1,!1,!1,!1,!1,!0,!1],17:[!1,!1,!1,!1,!1,!1,!0]}[Math.floor(a)]||n[r.CommonErrors.Num]},n.prototype.isWeekendMask=function(r,t){return t[(r.getDay()+6)%7]},n.prototype.ComputeDATEDIF=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]),s=this.toSerial(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.resolveTextArg(e[2]).toUpperCase();if(o>s)return i[r.CommonErrors.Num];var u=this.parent.fromOADate(o),l=this.parent.fromOADate(s);switch(a){case"Y":return(l.getFullYear()-u.getFullYear()-(l.getMonth()<u.getMonth()||l.getMonth()===u.getMonth()&&l.getDate()<u.getDate()?1:0)).toString();case"M":var h=12*(l.getFullYear()-u.getFullYear())+(l.getMonth()-u.getMonth());return l.getDate()<u.getDate()&&h--,h.toString();case"D":return(s-o).toString();case"MD":var p=l.getDate()-u.getDate();return p<0&&(p+=new Date(l.getFullYear(),l.getMonth(),0).getDate()),p.toString();case"YM":var g=l.getMonth()-u.getMonth();return l.getDate()<u.getDate()&&g--,g<0&&(g+=12),g.toString();case"YD":var f=new Date(l.getFullYear(),u.getMonth(),u.getDate()),m=Math.round((l.getTime()-f.getTime())/864e5);return m<0&&(m+=this.isLeapYear(l.getFullYear())?366:365),m.toString();default:return i[r.CommonErrors.Num]}},n.prototype.isLeapYear=function(r){return r%4==0&&r%100!=0||r%400==0},n.prototype["ComputeNETWORKDAYS.INTL"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.toSerial(e[0]),o=this.toSerial(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=this.weekendMask(e[2]);if(!(s instanceof Array))return s;var a=this.holidaySet(e[3]);if(!(a instanceof Set))return a;for(var u=i<=o?1:-1,l=0,h=i;u>0?h<=o:h>=o;h+=u){var p=this.parent.fromOADate(h);this.isWeekendMask(p,s)||a.has(h)||(l+=u)}return l.toString()},n.prototype["ComputeWORKDAY.INTL"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.toSerial(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=this.weekendMask(e[2]);if(!(a instanceof Array))return a;var u=this.holidaySet(e[3]);if(!(u instanceof Set))return u;for(var l=o,h=s>=0?1:-1,p=Math.abs(Math.trunc(s));p>0;){l+=h;var g=this.parent.fromOADate(l);if(this.isWeekendMask(g,a)||u.has(l)||p--,l<0)return i[r.CommonErrors.Num]}return l.toString()},n}(Q),Lt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),kt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ISO.CEILING",category:"Math & Trig",description:"Rounds a number up to the nearest integer or multiple of significance."},{formulaName:"ECMA.CEILING",category:"Math & Trig",description:"Rounds a number up, away from zero, to the nearest multiple of significance."}],t}return Lt(n,e),n.prototype["ComputeISO.CEILING"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<1||e.length>2)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]);if("string"==typeof i)return i;var o=1;if(2===e.length&&""!==e[1]){var s=this.resolveNumberArg(e[1]);if("string"==typeof s)return s;o=Math.abs(s)}return 0===i||0===o?"0":(Math.ceil(i/o)*o).toString()},n.prototype["ComputeECMA.CEILING"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;if(0===o||0===s)return"0";if(o>0&&s<0)return i[r.CommonErrors.Num];return(o>0?Math.ceil(o/s)*s:s>0?Math.ceil(o/s)*s:Math.floor(o/s)*s).toString()},n}(Q),Pt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),_t=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"ERROR.TYPE",category:"Information",description:"Returns a number corresponding to an error type."}],t}return Pt(n,e),n.prototype["ComputeERROR.TYPE"]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||1!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.parent.getValueFromArg(e[0]),s={"#NULL!":1,"#DIV/0!":2,"#VALUE!":3,"#REF!":4,"#NAME?":5,"#NUM!":6,"#N/A":7,"#GETTING_DATA":8};if(void 0!==s[o])return s[o].toString();for(var a=0;a<i.length;a++)if(o===i[a]){var u=a+1;if(u>=1&&u<=8)return u.toString()}return i[r.CommonErrors.NA]},n}(Q),Wt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),qt=function(t){function e(r){var e=t.call(this,r)||this;return e.formulas=[{formulaName:"USDOLLAR",category:"Text",description:"Converts a number to text using currency format (US dollar)."},{formulaName:"FINDB",category:"Text",description:"Finds text within another string (byte-count alias of FIND)."},{formulaName:"LENB",category:"Text",description:"Returns the length of a text string (byte-count alias of LEN)."}],e}return Wt(e,t),e.prototype.ComputeUSDOLLAR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.owner.ComputeDOLLAR;return n?n.apply(void 0,t):this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]},e.prototype.ComputeFINDB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.owner.ComputeFIND;return n?n.apply(void 0,t):this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]},e.prototype.ComputeLENB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.owner.ComputeLEN;return n?n.apply(void 0,t):this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidArguments]},e}(Q),Bt=function(){function r(r){this.parent=r}return r.prototype.yearDays=function(r){switch(r){case 1:case 3:return 365;default:return 360}},r.prototype.toDate=function(r){return this.parent.fromOADate(r)},r.prototype.toSerial=function(r){return this.parent.toOADate(r)},r.prototype.coupPCD=function(r,t,e){for(var n=this.toDate(t),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=12/e;this.toSerial(i)>r;)i=this.addMonths(i,-o);return this.toSerial(i)>r?r:this.toSerial(i)},r.prototype.coupNCD=function(r,t,e){var n=this.coupPCD(r,t,e);if(n<=r){var i=12/e;n=this.toSerial(this.addMonths(this.toDate(n),i))}return n},r.prototype.coupDays=function(r,t,e,n){void 0===n&&(n=0);var i=this.coupPCD(r,t,e),o=this.coupNCD(r,t,e);return this.daysBetween(i,o,n)},r.prototype.coupDayBS=function(r,t,e,n){void 0===n&&(n=0);var i=this.coupPCD(r,t,e);return this.daysBetween(i,r,n)},r.prototype.coupDaysNC=function(r,t,e,n){void 0===n&&(n=0);var i=this.coupNCD(r,t,e);return this.daysBetween(r,i,n)},r.prototype.coupNum=function(r,t,e,n){for(var i=12/e,o=this.toDate(t),s=new Date(o.getFullYear(),o.getMonth(),o.getDate()),a=0;this.toSerial(s)>r;)a++,s=this.addMonths(s,-i);return a},r.prototype.daysBetween=function(r,t,e){if(1===e)return Math.round(t-r);var n=this.toDate(r),i=this.toDate(t);if(3===e)return Math.abs(Math.round((i.getTime()-n.getTime())/864e5));var o=n.getFullYear(),s=n.getMonth()+1,a=n.getDate(),u=i.getFullYear(),l=i.getMonth()+1,h=i.getDate();return 31===a&&(a=30),31===h&&(h=30),360*(u-o)+30*(l-s)+(h-a)},r.prototype.addMonths=function(r,t){var e=new Date(r.getTime());return e.setMonth(e.getMonth()+t),e},r}(),Xt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Yt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"COUPDAYBS",category:"Financial",description:"Returns the number of days from the beginning of the coupon period to the settlement date."},{formulaName:"COUPDAYS",category:"Financial",description:"Returns the number of days in the coupon period that contains the settlement date."},{formulaName:"COUPDAYSNC",category:"Financial",description:"Returns the number of days from the settlement date to the next coupon date."},{formulaName:"COUPNCD",category:"Financial",description:"Returns the next coupon date after the settlement date."},{formulaName:"COUPNUM",category:"Financial",description:"Returns the number of coupons payable between settlement and maturity."},{formulaName:"COUPPCD",category:"Financial",description:"Returns the previous coupon date before the settlement date."},{formulaName:"ACCRINT",category:"Financial",description:"Returns the accrued interest for a security that pays periodic interest."},{formulaName:"ACCRINTM",category:"Financial",description:"Returns the accrued interest for a security that pays interest at maturity."},{formulaName:"ISPMT",category:"Financial",description:"Returns the interest paid during a specific period of an investment."},{formulaName:"MDURATION",category:"Financial",description:"Returns the modified Macauley duration for a security with an assumed par value of $100."},{formulaName:"PRICE",category:"Financial",description:"Returns the price per $100 face value of a security that pays periodic interest."},{formulaName:"PRICEDISC",category:"Financial",description:"Returns the price per $100 face value of a discounted security."},{formulaName:"PRICEMAT",category:"Financial",description:"Returns the price per $100 face value of a security that pays interest at maturity."},{formulaName:"TBILLEQ",category:"Financial",description:"Returns the bond-equivalent yield for a Treasury bill."},{formulaName:"TBILLPRICE",category:"Financial",description:"Returns the price per $100 face value for a Treasury bill."},{formulaName:"TBILLYIELD",category:"Financial",description:"Returns the yield for a Treasury bill."},{formulaName:"XNPV",category:"Financial",description:"Returns the net present value for a schedule of cash flows that is not necessarily periodic."},{formulaName:"YIELD",category:"Financial",description:"Returns the yield on a security that pays periodic interest."},{formulaName:"YIELDDISC",category:"Financial",description:"Returns the annual yield for a discounted security."},{formulaName:"YIELDMAT",category:"Financial",description:"Returns the annual yield of a security that pays interest at maturity."}],t.bond=new Bt(t.parent),t}return Xt(n,e),n.prototype.parseBondArgs=function(e,n,i){if(t.isNullOrUndefined(e)||e.length<n||e.length>i)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a={settlement:o,maturity:s};if(e.length>=3){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a.rate=u}if(e.length>=4){var l=this.resolveNumberArg(e[3]);if("string"==typeof l)return l;a.yld=l}if(e.length>=5){var h=this.resolveNumberArg(e[4]);if("string"==typeof h)return h;a.redemption=h}return a.frequency=e.length>=6&&""!==e[5]?this.resolveNumberArg(e[5]):2,"string"==typeof a.frequency?a.frequency:(a.basis=e.length>=7&&""!==e[6]?this.resolveNumberArg(e[6]):0,"string"==typeof a.basis?a.basis:a)},n.prototype.coupArgs=function(e){if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var n=this.resolveNumberArg(e[0]),i=this.resolveNumberArg(e[1]),o=this.resolveNumberArg(e[2]);if("string"==typeof n)return n;if("string"==typeof i)return i;if("string"==typeof o)return o;var s=0;if(4===e.length&&""!==e[3]){var a=this.resolveNumberArg(e[3]);if("string"==typeof a)return a;s=Math.floor(a)}return{settlement:n,maturity:i,frequency:Math.floor(o),basis:s}},n.prototype.ComputeCOUPDAYBS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupDayBS(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPDAYS=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupDays(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPDAYSNC=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupDaysNC(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPNCD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupNCD(e.settlement,e.maturity,e.frequency).toString()},n.prototype.ComputeCOUPNUM=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupNum(e.settlement,e.maturity,e.frequency,e.basis).toString()},n.prototype.ComputeCOUPPCD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.coupArgs(r);return"string"==typeof e?e:this.bond.coupPCD(e.settlement,e.maturity,e.frequency).toString()},n.prototype.ComputeACCRINT=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.parent.getErrorStrings(),i=this.parseBondArgs(t,6,8);if("string"==typeof i)return i;var o=t.length>=8?this.resolveNumberArg(t[7]):i.settlement;if("string"==typeof o)return o;var s=i.rate,a=i.frequency,u=i.basis,l=this.bond.coupDayBS(i.settlement,i.maturity,a,u),h=this.bond.coupDays(i.settlement,i.maturity,a,u);return 0===h?n[r.CommonErrors.Num]:((t.length>=7&&""!==t[6]?this.resolveNumberArg(t[6]):1e3)*s/a*l/h).toString()},n.prototype.ComputeACCRINTM=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0;if(5===e.length&&""!==e[4]){var l=this.resolveNumberArg(e[4]);if("string"==typeof l)return l;u=Math.floor(l)}return(a*s*this.bond.daysBetween(i,o,u)/this.bond.yearDays(u)).toString()},n.prototype.ComputeISPMT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||4!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=Math.floor(s);return l<1||l>a?i[r.CommonErrors.Num]:(-u*o*(1-(l-1)/a)).toString()},n.prototype.ComputeMDURATION=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.parseBondArgs(r,5,7);if("string"==typeof e)return e;var n=e.frequency;return(1/n/(1+e.yld/n)).toString()},n.prototype.ComputePRICE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.parseBondArgs(r,6,7);if("string"==typeof e)return e;for(var n=e.rate,i=e.yld,o=e.redemption,s=e.frequency,a=e.basis,u=this.bond.coupNum(e.settlement,e.maturity,s,a),l=this.bond.coupDaysNC(e.settlement,e.maturity,s,a),h=this.bond.coupDays(e.settlement,e.maturity,s,a),p=this.bond.coupDayBS(e.settlement,e.maturity,s,a),g=100*n/s,f=o/Math.pow(1+i/s,u-1+l/h),m=1;m<=u;m++)f+=g/Math.pow(1+i/s,m-1+l/h);return(f-=g*p/h).toString()},n.prototype.ComputePRICEDISC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0;if(5===e.length&&""!==e[4]){var l=this.resolveNumberArg(e[4]);if("string"==typeof l)return l;u=Math.floor(l)}return(a*(1-s*this.bond.daysBetween(i,o,u)/this.bond.yearDays(u))).toString()},n.prototype.ComputePRICEMAT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<5||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;var l=0;if(6===e.length&&""!==e[5]){var h=this.resolveNumberArg(e[5]);if("string"==typeof h)return h;l=Math.floor(h)}var p=this.bond.yearDays(l),g=this.bond.daysBetween(s,i,l);return((100+a*this.bond.daysBetween(s,o,l)/p)/(1+u*g/p)).toString()},n.prototype.ComputeTBILLPRICE=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=o-i;return a<=0?this.parent.getErrorStrings()[r.CommonErrors.Num]:(100*(1-s*a/360)).toString()},n.prototype.ComputeTBILLYIELD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||3!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;var a=o-i;return a<=0||s<=0?this.parent.getErrorStrings()[r.CommonErrors.Num]:((100-s)/s*360/a).toString()},n.prototype.ComputeTBILLEQ=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputeTBILLYIELD.apply(this,r),n=this.parent.getErrorStrings();if("string"==typeof e&&n.indexOf(e)>-1)return e;var i=this.parent.parseFloat(e);return(365*i/(360-i*(this.resolveNumberArg(r[1])-this.resolveNumberArg(r[0])))).toString()},n.prototype.ComputeXNPV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]);if("string"==typeof o)return o;var s=[],a=[],u=this.parent.getCellCollection(e[1]),l=this.parent.getCellCollection(e[2]),h=Array.isArray(u)?u:[u],p=Array.isArray(l)?l:[l];if(h.length!==p.length||h.length<1)return i[r.CommonErrors.Num];for(d=0;d<h.length;d++){var g=this.parent.getValueFromArg(h[d]),f=this.parent.getValueFromArg(p[d]);if(i.indexOf(g)>-1)return g;if(i.indexOf(f)>-1)return f;s.push(this.parent.parseFloat(g)),a.push(this.parent.parseFloat(f))}for(var m=a[0],c=0,d=0;d<s.length;d++)c+=s[d]/Math.pow(1+o,(a[d]-m)/365);return c.toString()},n.prototype.ComputeYIELD=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.ComputePRICE.apply(this,r),n=this.parent.getErrorStrings();if("string"==typeof e&&(n.indexOf(e)>-1||e.match(/arguments/i)))return e;var i=this.parseBondArgs(r,6,7);if("string"==typeof i)return i;for(var o=this.parent.parseFloat(e),s=i.yld||.05,a=0;a<50;a++){i.yld=s;var u=this.parent.parseFloat(this.ComputePRICE(r[0],r[1],r[2],s.toString(),r[4],r[5],r[6]))-o;if(Math.abs(u)<1e-8)return s.toString();s+=1e-4*u}return s.toString()},n.prototype.ComputeYIELDDISC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<4||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0;if(5===e.length&&""!==e[4]){var l=this.resolveNumberArg(e[4]);if("string"==typeof l)return l;u=Math.floor(l)}var h=this.bond.daysBetween(i,o,u),p=this.bond.yearDays(u);return h<=0?this.parent.getErrorStrings()[r.CommonErrors.Num]:((a-s)/s*p/h).toString()},n.prototype.ComputeYIELDMAT=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<5||e.length>6)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]),l=this.resolveNumberArg(e[4]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;var h=0;if(6===e.length&&""!==e[5]){var p=this.resolveNumberArg(e[5]);if("string"==typeof p)return p;h=Math.floor(p)}var g=this.bond.yearDays(h),f=this.bond.daysBetween(a,o,h),m=100+u*this.bond.daysBetween(a,s,h)/g-l,c=l*f/g;return 0===c?i[r.CommonErrors.Num]:(m/c).toString()},n}(Q),Ht=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Gt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"AMORDEGRC",category:"Financial",description:"Returns the depreciation for each accounting period using a depreciation coefficient."},{formulaName:"AMORLINC",category:"Financial",description:"Returns the depreciation for each accounting period."},{formulaName:"ODDFPRICE",category:"Financial",description:"Returns the price per $100 face value of a security with an odd first period."},{formulaName:"ODDFYIELD",category:"Financial",description:"Returns the yield of a security with an odd first period."},{formulaName:"ODDLPRICE",category:"Financial",description:"Returns the price per $100 face value of a security with an odd last period."},{formulaName:"ODDLYIELD",category:"Financial",description:"Returns the yield of a security with an odd last period."}],t.bond=new Bt(t.parent),t}return Ht(n,e),n.prototype.ComputeAMORLINC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<6||e.length>7)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]),u=this.resolveNumberArg(e[3]),l=this.resolveNumberArg(e[4]),h=this.resolveNumberArg(e[5]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;var p=Math.floor(l);return p<0?i[r.CommonErrors.Num]:Math.min((o-u)*h*(p+1),o-u).toString()},n.prototype.ComputeAMORDEGRC=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<7||e.length>8)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]),l=this.resolveNumberArg(e[5]),h=e.length>=8?this.resolveNumberArg(e[7]):0;if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;var p=l<.03?1:l<.05?1.5:l<.1?2:2.5;return this.ComputeAMORLINC(e[0],e[1],e[2],e[3],e[4],(l*p).toString())},n.prototype.oddBondPrice=function(e,n){if(t.isNullOrUndefined(e)||e.length<7||e.length>9)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]),s=this.resolveNumberArg(e[2]),a=this.resolveNumberArg(e[3]),u=this.resolveNumberArg(e[4]),l=this.resolveNumberArg(e[5]),h=this.resolveNumberArg(e[6]);if("string"==typeof i)return i;if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;if("string"==typeof u)return u;if("string"==typeof l)return l;if("string"==typeof h)return h;var p=e.length>=8&&""!==e[7]?this.resolveNumberArg(e[7]):2,g=e.length>=9&&""!==e[8]?this.resolveNumberArg(e[8]):0;if("string"==typeof p)return p;if("string"==typeof g)return g;var f=this.bond.coupNum(i,o,p,g),m=100*u/p,c=n?a:o,d=this.bond.daysBetween(i,c,g),v=this.bond.coupDays(i,o,p,g)||180,N=h/Math.pow(1+l/p,f+d/v);N+=m*d/v;for(var E=1;E<=f;E++)N+=m/Math.pow(1+l/p,E-1+d/v);return N.toString()},n.prototype.ComputeODDFPRICE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.oddBondPrice(r,!0)},n.prototype.ComputeODDLPRICE=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return this.oddBondPrice(r,!1)},n.prototype.oddBondYield=function(r,t){for(var e=t[6],n=.05,i=this.parent.parseFloat(this.resolveNumberArg(e)),o=0;o<50;o++){var s=t.slice(0,6).concat([n.toString()],t.slice(7)),a=this.parent.parseFloat(r.apply(void 0,s))-i;if(Math.abs(a)<1e-6)return n.toString();n-=1e-4*a}return n.toString()},n.prototype.ComputeODDFYIELD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.isNullOrUndefined(e)||e.length<8||e.length>9?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.oddBondYield(this.ComputeODDFPRICE.bind(this),e)},n.prototype.ComputeODDLYIELD=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.isNullOrUndefined(e)||e.length<8||e.length>9?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:this.oddBondYield(this.ComputeODDLPRICE.bind(this),e)},n}(Q),Zt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Kt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"BETADIST",category:"Statistical",description:"Returns the beta cumulative distribution function."},{formulaName:"BETAINV",category:"Statistical",description:"Returns the inverse of the beta cumulative distribution function."},{formulaName:"TDIST",category:"Statistical",description:"Returns the Student t-distribution."},{formulaName:"TINV",category:"Statistical",description:"Returns the inverse of the Student t-distribution."},{formulaName:"TTEST",category:"Statistical",description:"Returns the probability associated with a Student t-test."},{formulaName:"FTEST",category:"Statistical",description:"Returns the result of an F-test."},{formulaName:"FREQUENCY",category:"Statistical",description:"Returns the frequency distribution of a range of values."}],t}return Zt(n,e),n.prototype.ComputeBETADIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0,l=1;if(e.length>=4&&""!==e[3]){var h=this.resolveNumberArg(e[3]);if("string"==typeof h)return h;u=h}if(e.length>=5&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;l=p}if(o<u||o>l||s<=0||a<=0||u>=l)return i[r.CommonErrors.Num];var g=k((o-u)/(l-u),s,a);return isNaN(g)?i[r.CommonErrors.Num]:g.toString()},n.prototype.ComputeBETAINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>5)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]),a=this.resolveNumberArg(e[2]);if("string"==typeof o)return o;if("string"==typeof s)return s;if("string"==typeof a)return a;var u=0,l=1;if(e.length>=4&&""!==e[3]){var h=this.resolveNumberArg(e[3]);if("string"==typeof h)return h;u=h}if(e.length>=5&&""!==e[4]){var p=this.resolveNumberArg(e[4]);if("string"==typeof p)return p;l=p}var g=P(o,s,a);return isNaN(g)?i[r.CommonErrors.Num]:(u+g*(l-u)).toString()},n.prototype.ComputeTDIST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.resolveNumberArg(e[0]),o=this.resolveNumberArg(e[1]);if("string"==typeof i)return i;if("string"==typeof o)return o;var s=1;if(3===e.length&&""!==e[2]){var a=this.resolveNumberArg(e[2]);if("string"==typeof a)return a;s=Math.floor(a)}var u=j(Math.abs(i),o);return(1===s?1-u:2*(1-u)).toString()},n.prototype.ComputeTINV=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.resolveNumberArg(e[0]),s=this.resolveNumberArg(e[1]);if("string"==typeof o)return o;if("string"==typeof s)return s;var a=2;if(3===e.length&&""!==e[2]){var u=this.resolveNumberArg(e[2]);if("string"==typeof u)return u;a=Math.floor(u)}var l=L(1===a?1-o:1-o/2,s);return isNaN(l)?i[r.CommonErrors.Num]:l.toString()},n.prototype.ComputeTTEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||e.length<3||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1),s=this.collectSample([e[1]],!1);if("string"==typeof o)return o;if("string"==typeof s)return s;if(o.length<2||s.length<2)return i[r.CommonErrors.DivZero];for(var a=this.mean(o),u=this.mean(s),l=0,h=0,p=0;p<o.length;p++)l+=Math.pow(o[p]-a,2);for(p=0;p<s.length;p++)h+=Math.pow(s[p]-u,2);l/=o.length-1,h/=s.length-1;var g=Math.sqrt(l/o.length+h/s.length);if(0===g)return i[r.CommonErrors.DivZero];var f=Math.abs(a-u)/g,m=o.length+s.length-2,c=2;if(4===e.length&&""!==e[3]){var d=this.resolveNumberArg(e[3]);if("string"==typeof d)return d;c=Math.floor(d)}var v=j(f,m);return(1===c?1-v:2*(1-v)).toString()},n.prototype.ComputeFTEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1),s=this.collectSample([e[1]],!1);if("string"==typeof o)return o;if("string"==typeof s)return s;if(o.length<2||s.length<2)return i[r.CommonErrors.DivZero];var a=this.sampleVar(o),u=this.sampleVar(s);if(0===u)return i[r.CommonErrors.DivZero];var l=a/u,h=o.length-1,p=s.length-1;return(2*Math.min(O(l,h,p),O(1/l,p,h))).toString()},n.prototype.sampleVar=function(r){for(var t=this.mean(r),e=0,n=0;n<r.length;n++)e+=Math.pow(r[n]-t,2);return e/(r.length-1)},n.prototype.ComputeFREQUENCY=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=this.parent.getErrorStrings();if(t.isNullOrUndefined(e)||2!==e.length)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var o=this.collectSample([e[0]],!1),s=this.collectSample([e[1]],!1);if("string"==typeof o)return o;if("string"==typeof s)return s;if(0===s.length)return i[r.CommonErrors.Num];for(var a=s.slice().sort(function(r,t){return r-t}),u=new Array(a.length+1).fill(0),l=0;l<o.length;l++){for(var h=o[l],p=!1,g=0;g<a.length;g++)if(h<=a[g]){u[g]++,p=!0;break}p||u[u.length-1]++}var f=this.parent.getParseArgumentSeparator();return u.join(f)},n}(qr),$t=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),zt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"DAVERAGE",category:"Database",description:"Averages the values in a column of a list or database that match criteria."},{formulaName:"DCOUNT",category:"Database",description:"Counts the cells that contain numbers in a column of a list or database that match criteria."},{formulaName:"DCOUNTA",category:"Database",description:"Counts nonblank cells in a column of a list or database that match criteria."},{formulaName:"DGET",category:"Database",description:"Extracts a single value from a column of a list or database that matches criteria."},{formulaName:"DMAX",category:"Database",description:"Returns the maximum value from a column of a list or database that matches criteria."},{formulaName:"DMIN",category:"Database",description:"Returns the minimum value from a column of a list or database that matches criteria."},{formulaName:"DPRODUCT",category:"Database",description:"Multiplies values in a column of a list or database that match criteria."},{formulaName:"DSTDEV",category:"Database",description:"Estimates the standard deviation of a population based on a sample of entries that match criteria."},{formulaName:"DSTDEVP",category:"Database",description:"Calculates the standard deviation of a population based on entries that match criteria."},{formulaName:"DSUM",category:"Database",description:"Adds the numbers in the field column of records in the database that match the criteria."},{formulaName:"DVAR",category:"Database",description:"Estimates variance based on a sample of entries that match criteria."},{formulaName:"DVARP",category:"Database",description:"Calculates variance based on the entire population of entries that match criteria."}],t}return $t(n,e),n.prototype.readRange=function(t){var e=this.parent.getErrorStrings();if(!this.parent.isCellReference(t))return e[r.CommonErrors.Value];for(var n=t.indexOf(":")>-1?t.split(":"):[t,t],i=this.parent.rowIndex(n[0]),o=this.parent.colIndex(n[0]),s=this.parent.rowIndex(n[1]),a=this.parent.colIndex(n[1]),u=Math.min(i,s),l=Math.max(i,s),h=Math.min(o,a),p=Math.max(o,a),g=[],f=u;f<=l;f++){for(var m=[],c=h;c<=p;c++){var d=K(c)+f;m.push(this.parent.getValueFromArg(d))}g.push(m)}return g},n.prototype.fieldIndex=function(t,e){var n=this.parent.getErrorStrings(),i=this.resolveTextArg(t);if(n.indexOf(i)>-1)return i;var o=this.parent.parseFloat(i);if(!isNaN(o)&&o>=1&&o<=e.length)return Math.floor(o)-1;for(var s=i.toUpperCase(),a=0;a<e.length;a++)if(e[a].toUpperCase()===s)return a;return n[r.CommonErrors.Value]},n.prototype.matchCriteria=function(r,t,e){for(var n=0;n<t.length;n++){for(var i=t[n],o=!0,s=0;s<e.length;s++){var a=i[s];if(void 0!==a&&""!==a){var u=r[s];if(!this.matchesCriterion(u,a)){o=!1;break}}}if(o)return!0}return!1},n.prototype.matchesCriterion=function(r,t){var e=t.trim();if(""===e)return!0;for(var n=[">=","<=","<>",">","<","="],i=0;i<n.length;i++){var o=n[i];if(e.startsWith(o)){var s=e.substring(o.length).trim(),a=this.parent.parseFloat(r),u=this.parent.parseFloat(s);if(!isNaN(a)&&!isNaN(u))switch(o){case">=":return a>=u;case"<=":return a<=u;case"<>":return a!==u;case">":return a>u;case"<":return a<u;case"=":return a===u;default:return o}return"="===o||""===o?r.toUpperCase()===s.toUpperCase():"<>"===o&&r.toUpperCase()!==s.toUpperCase()}}return e.includes("*")||e.includes("?")?new RegExp("^"+e.replace(/\*/g,".*").replace(/\?/g,".")+"$","i").test(r):r.toUpperCase()===e.toUpperCase()},n.prototype.collectMatching=function(t,e,n,i){var o=this.readRange(t);if("string"==typeof o)return o;if(o.length<2)return this.parent.getErrorStrings()[r.CommonErrors.Value];var s=o[0],a=this.fieldIndex(e,s);if("string"==typeof a)return a;var u=this.readRange(n);if("string"==typeof u)return u;if(u.length<2)return this.parent.getErrorStrings()[r.CommonErrors.Value];for(var l=u[0],h=u.slice(1),p=[],g=this,f=1;f<o.length;f++)!function(r){var t=o[r],e=s.map(function(r,e){return t[e]||""}),n=h.map(function(r){return l.map(function(t,e){return r[e]||""})});if(!g.matchCriteria(e,n,s))return"continue";var i=t[a]||"";""!==i&&g.parent.isNumber(i)&&p.push(g.parent.parseFloat(i))}(f);return p},n.prototype.requireThree=function(e){return t.isNullOrUndefined(e)||3!==e.length?this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments]:null},n.prototype.mean=function(r){return r.reduce(function(r,t){return r+t},0)/r.length},n.prototype.variance=function(r,t){for(var e=this.mean(r),n=0,i=0;i<r.length;i++)n+=Math.pow(r[i]-e,2);return n/(t?r.length:r.length-1)},n.prototype.ComputeDAVERAGE=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof i?i:0===i.length?this.parent.getErrorStrings()[r.CommonErrors.DivZero]:this.mean(i).toString()},n.prototype.ComputeDCOUNT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.collectMatching(r[0],r[1],r[2],!0);return"string"==typeof n?n:n.length.toString()},n.prototype.ComputeDCOUNTA=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.readRange(r[0]);if("string"==typeof n)return n;var i=n[0],o=this.fieldIndex(r[1],i);if("string"==typeof o)return o;var s=this.readRange(r[2]);if("string"==typeof s)return s;for(var a=s.slice(1),u=0,l=1;l<n.length;l++){var h=n[l],p=a.map(function(r){return s[0].map(function(t,e){return r[e]||""})});this.matchCriteria(h,p,i)&&""!==(h[o]||"")&&u++}return u.toString()},n.prototype.ComputeDGET=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!1);return"string"==typeof o?o:0===o.length?i[r.CommonErrors.NA]:o.length>1?i[r.CommonErrors.Num]:o[0].toString()},n.prototype.ComputeDMAX=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof i?i:0===i.length?this.parent.getErrorStrings()[r.CommonErrors.NA]:Math.max.apply(Math,i).toString()},n.prototype.ComputeDMIN=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof i?i:0===i.length?this.parent.getErrorStrings()[r.CommonErrors.NA]:Math.min.apply(Math,i).toString()},n.prototype.ComputeDPRODUCT=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.collectMatching(r[0],r[1],r[2],!0);return"string"==typeof n?n:0===n.length?"0":n.reduce(function(r,t){return r*t},1).toString()},n.prototype.ComputeDSUM=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=this.requireThree(r);if(e)return e;var n=this.collectMatching(r[0],r[1],r[2],!0);return"string"==typeof n?n:n.reduce(function(r,t){return r+t},0).toString()},n.prototype.ComputeDSTDEV=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<2?i[r.CommonErrors.DivZero]:Math.sqrt(this.variance(o,!1)).toString()},n.prototype.ComputeDSTDEVP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<1?i[r.CommonErrors.DivZero]:Math.sqrt(this.variance(o,!0)).toString()},n.prototype.ComputeDVAR=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<2?i[r.CommonErrors.DivZero]:this.variance(o,!1).toString()},n.prototype.ComputeDVARP=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.requireThree(t);if(n)return n;var i=this.parent.getErrorStrings(),o=this.collectMatching(t[0],t[1],t[2],!0);return"string"==typeof o?o:o.length<1?i[r.CommonErrors.DivZero]:this.variance(o,!0).toString()},n}(Q),Qt=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Jt=function(e){function n(r){var t=e.call(this,r)||this;return t.formulas=[{formulaName:"LINEST",category:"Statistical",description:"Returns statistics that describe a linear trend."},{formulaName:"LOGEST",category:"Statistical",description:"Returns statistics that describe an exponential curve."},{formulaName:"GROWTH",category:"Statistical",description:"Returns numbers in an exponential growth trend."},{formulaName:"TREND",category:"Statistical",description:"Returns numbers in a linear trend."}],t}return Qt(n,e),n.prototype.linearRegression=function(t,e){var n=this.collectPair([e,t]);if("string"==typeof n)return n;var i=n.x,o=n.y;if(i.length<2)return this.parent.getErrorStrings()[r.CommonErrors.NA];for(var s=this.mean(i),a=this.mean(o),u=0,l=0,h=0;h<i.length;h++){var p=i[h]-s;u+=p*p,l+=p*(o[h]-a)}if(0===u)return this.parent.getErrorStrings()[r.CommonErrors.DivZero];var g=l/u;return{slope:g,intercept:a-g*s}},n.prototype.expRegression=function(t,e){var n=this.collectPair([e,t]);if("string"==typeof n)return n;var i=n.x,o=n.y,s=this.parent.getErrorStrings();if(i.length<2)return s[r.CommonErrors.NA];for(var a=[],u=0;u<o.length;u++){if(o[u]<=0)return s[r.CommonErrors.Num];a.push(Math.log(o[u]))}for(var l=this.mean(i),h=this.mean(a),p=0,g=0,u=0;u<i.length;u++){var f=i[u]-l;p+=f*f,g+=f*(a[u]-h)}if(0===p)return s[r.CommonErrors.DivZero];var m=g/p;return{b:Math.exp(h-m*l),m:m}},n.prototype.ComputeLINEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.linearRegression(e[0],e[1]);return"string"==typeof i?i:i.slope.toString()},n.prototype.ComputeLOGEST=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>4)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.expRegression(e[0],e[1]);return"string"==typeof i?i:i.b.toString()},n.prototype.ComputeTREND=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.linearRegression(e[0],e[1]);if("string"==typeof i)return i;var o;if(3===e.length&&""!==e[2]){var s=this.collectSample([e[2]],!1);if("string"==typeof s)return s;if(0===s.length)return this.parent.getErrorStrings()[r.CommonErrors.NA];o=s[0]}else{var a=this.collectSample([e[1]],!1);if("string"==typeof a)return a;o=a[a.length-1]+1}return(i.intercept+i.slope*o).toString()},n.prototype.ComputeGROWTH=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t.isNullOrUndefined(e)||e.length<2||e.length>3)return this.parent.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];var i=this.expRegression(e[0],e[1]);if("string"==typeof i)return i;var o;if(3===e.length&&""!==e[2]){var s=this.collectSample([e[2]],!1);if("string"==typeof s)return s;if(0===s.length)return this.parent.getErrorStrings()[r.CommonErrors.NA];o=s[0]}else{var a=this.collectSample([e[1]],!1);if("string"==typeof a)return a;o=a[a.length-1]+1}return(i.b*Math.pow(Math.E,i.m*o)).toString()},n}(qr),re=function(){function r(r){this.formulas=[],this.isConcat=!1,this.parent=r;for(var e=[new rr(this),new er(this),new ir(this),new sr(this),new ur(this),new hr(this),new gr(this),new dr(this),new Nr(this),new Sr(this),new Cr(this),new Ar(this),new Fr(this),new Vr(this),new Ir(this),new Mr(this),new Ur(this),new jr(this),new kr(this),new _r(this),new Xr(this),new Hr(this),new Zr(this),new $r(this),new Qr(this),new rt(this),new et(this),new it(this),new st(this),new ut(this),new ht(this),new gt(this),new mt(this),new dt(this),new Nt(this),new St(this),new Ct(this),new At(this),new Ft(this),new Vt(this),new It(this),new Mt(this),new Ut(this),new jt(this),new kt(this),new _t(this),new qt(this),new Yt(this),new Gt(this),new Kt(this),new zt(this),new Jt(this)],n=0;n<e.length;n++)for(var i=e[n],o=0;o<i.formulas.length;o++){var s=i.formulas[o];this.formulas.push(s);var a="Compute"+s.formulaName,u=s.formulaName.indexOf(".")>-1?i[a]:t.getValue(a,i);u&&(this[a]=u.bind(i))}this.init()}return r.prototype.init=function(){for(var r=0;r<this.formulas.length;r++){var t=this.formulas[r],e=this["Compute"+t.formulaName];this.addFormulaCollection(t.formulaName.toUpperCase(),e,t.category,t.description)}},r.prototype.addFormulaCollection=function(r,t,e,n){this.parent.libraryFormulas={fName:r,handler:t,category:e,description:n}},r}(),te=function(){function e(r){this.emptyStr="",this.storedStringText=this.emptyStr,this.sheetToken="!",this.tokenAdd="a",this.tokenSubtract="s",this.tokenMultiply="m",this.tokenDivide="d",this.tokenLess="l",this.charEm="r",this.charEp="x",this.tokenGreater="g",this.tokenEqual="e",this.tokenLessEq="k",this.tokenGreaterEq="j",this.tokenNotEqual="o",this.tokenAnd="c",this.tokenEm="v",this.tokenEp="t",this.tokenOr=String.fromCharCode(126),this.charAnd="i",this.charLess="<",this.charGreater=">",this.charEqual="=",this.charLessEq="f",this.charGreaterEq="h",this.charNoEqual="z",this.stringGreaterEq=">=",this.stringLessEq="<=",this.stringNoEqual="<>",this.stringAnd="&",this.stringOr="^",this.charOr="w",this.charAdd="+",this.charSubtract="-",this.charMultiply="*",this.charDivide="/",this.fixedReference="$",this.spaceString=" ",this.ignoreBracet=!1,this.isError=!1,this.isFormulaParsed=!1,this.findNamedRange=!1,this.stringsColl=new Map,this.tokens=[this.tokenAdd,this.tokenSubtract,this.tokenMultiply,this.tokenDivide,this.tokenLess,this.tokenGreater,this.tokenEqual,this.tokenLessEq,this.tokenGreaterEq,this.tokenNotEqual,this.tokenAnd,this.tokenOr],this.charNOTop=String.fromCharCode(167),this.specialSym=["~","@","#","?"],this.isFailureTriggered=!1,this.parent=r}return e.prototype.parse=function(e,n){var o=this;if(this.parent.isTextEmpty(e))return e;if(i(e))return this.parent.getErrorStrings()[r.CommonErrors.Ref];this.parent.getFormulaCharacter()!==String.fromCharCode(0)&&this.parent.getFormulaCharacter()===e[0]&&(e=e.substring(1)),(this.parent.namedRanges.size>0||this.parent.storedData.size>0)&&(e=this.checkForNamedRangeAndKeyValue(e),this.findNamedRange=!1);var s=this.storeStrings(e);e=(e=(e=this.storedStringText).replace(/[-+*/&^]+/g,function(t){for(var e="";1<t.length;)switch(t.substring(0,2)){case"++":case"--":t="+"+t.substring(2);break;case"+-":case"-+":t="-"+t.substring(2);break;case"*+":t="*"+t.substring(2);break;case"/+":t="/"+t.substring(2);break;case"^+":t="^"+t.substring(2);break;case"&+":t="&"+t.substring(2);break;case"*-":case"/-":case"^-":case"&-":e=t.substring(0,1),t=t.substring(1);break;default:throw new oe(o.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression],!0)}return e+t})).split("-(-").join("(");var a=0;if(t.isNullOrUndefined(s)&&(e=e.split(" ").join("")),e=e.split("=>").join(">="),(e=e.split("=<").join("<="))[e.length-1]===this.parent.arithMarker&&this.indexOfAny(e,this.tokens)===e.length-2||(e=e.toUpperCase()),e.indexOf(this.sheetToken)>-1){var u=this.parent.getSheetFamilyItem(this.parent.grid);if(null!=u.sheetNameToParentObject&&u.sheetNameToParentObject.size>0){e[0]!==this.sheetToken.toString()&&(e=this.parent.setTokensForSheets(e));var l=this.parent.getSheetToken(e.split(this.parent.tic).join(this.emptyStr)),h=this.checkScopedRange(e.split('"').join(this.emptyStr).split(this.sheetToken).join(""));t.isNullOrUndefined(l)&&""!==l&&this.parent.namedRanges.size>0&&""!==h&&(e=h)}}e=this.processIndexArg(e),e=this.markLibraryFormulas(e);try{e=this.formulaAutoCorrection(e)}catch(t){if(!(f={message:t.message,exception:t,isForceCalculable:t.formulaCorrection,computeForceCalculate:!1}).isForceCalculable)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression];if(this.isFailureTriggered||(this.parent.trigger("onFailure",f),this.isFailureTriggered=!0),!f.isForceCalculable||!f.computeForceCalculate)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression];e=this.formulaAutoCorrection(e,f),this.parent.storedData.get(n).formulaText="="+e}if(!this.ignoreBracet)for(a=e.indexOf(")");a>-1;){var p=e.substring(0,a).lastIndexOf("(");if(-1===p)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedParentheses]);if(p===a-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.EmptyExpression]);var g=this.emptyStr;g=this.ignoreBracet?this.parent.substring(e,p,a-p+1):this.parent.substring(e,p+1,a-p-1);try{e=e.substring(0,p)+this.parseSimple(g)+e.substring(a+1)}catch(t){if(t===this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference])throw t;var f=this.exceptionArgs(t);this.isFailureTriggered||(this.parent.trigger("onFailure",f),this.isFailureTriggered=!0);var m="string"==typeof f.exception?f.exception:f.message;return(this.parent.getErrorLine(t)?"":"#"+this.parent.getErrorLine(t)+": ")+m}a=e.indexOf(")")}if(!this.ignoreBracet&&e.indexOf("(")>-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedParentheses]);return e=this.parseSimple(e),null!==s&&s.size>0&&(e=this.setStrings(e,s)),e},e.prototype.exceptionArgs=function(r){return{message:r.message,exception:r,isForceCalculable:r.formulaCorrection,computeForceCalculate:!1}},e.prototype.formulaAutoCorrection=function(e,n,i){var o=["*","+","-","/","^","&"],s=[">","=","<"],a=0,u="",l="",h="",p="",g="",f="",m="",c=0;if(this.parent.formulaErrorStrings.indexOf(e)>-1)return e;if(this.indexOfAny(e,this.specialSym)>-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression],!1);for(e=e.split("-*").join("-").split("/*").join("/").split("*/").join("*").split("-/").join("-").split("*+").join("*").split("+*").join("+");a<e.length;)if(this.parent.isDigit(e[a])&&e.length>a+1&&this.indexOfAny(e[a+1],o)>-1&&e.length>a+2&&!t.isNullOrUndefined(e[a+2])&&this.indexOfAny(e[a+2],o)>-1&&("-"!==e[a+2]||"*"!==e[a+1]&&"/"!==e[a+1]&&"^"!==e[a+1]&&"&"!==e[a+1])){if(!n||!n.computeForceCalculate)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];this.parent.isDigit(e[a])?(c<1?(f=e[a],h=e[a+1],t.isNullOrUndefined(h)&&(h=this.emptyStr),c+=1,u=u+f+(h="&"===h?"":h)):c<2&&(m=e[a],p=e[a-1],g=e[a+1],c=0,u="-"===p?u+p+m+(g="&"===(g=t.isNullOrUndefined(g)?this.emptyStr:g)?"":g):u+m+(g=t.isNullOrUndefined(g)?this.emptyStr:g)),a+=2):(u="-"===e[a]?u+e[a]:u,a+=1)}else if((this.parent.isDigit(e[a])||e[a]===this.parent.rightBracket||this.parent.storedData.has(e[a].toUpperCase()))&&(t.isNullOrUndefined(e[a+1])||this.indexOfAny(e[a+1],o)>-1&&"&"!==e[a+1]))l="&"===(l=t.isNullOrUndefined(e[a+1])?this.emptyStr:e[a+1])&&"-"!==e[a+2]?"":l,u="-"===e[a-1]?u+e[a-1]+e[a]+l:u+e[a]+l,a+=2;else if(this.indexOfAny(e[a],s)>-1&&!t.isNullOrUndefined(e[a-1])&&!t.isNullOrUndefined(e[a+1]))u+=e[a],a+=1;else if("q"===e[a])for(;e[a]!==this.parent.leftBracket;)u+=e[a],a+=1;else e[a]===this.parent.leftBracket||e[a]===this.parent.rightBracket||"{"===e[a]||"}"===e[a]||"("===e[a]||")"===e[a]?(u+=e[a],a+=1):this.parent.isUpperChar(e[a])||e[a].indexOf(":")>-1||e[a]===this.parent.getParseArgumentSeparator()||"%"===e[a]&&this.parent.isDigit(e[a-1])||this.isOtherLangChar(e[a])?(u+=e[a],a+=1):e[a]===this.parent.tic||" "===e[a]||e[a]===this.parent.getParseDecimalSeparator()||e[a]===this.sheetToken||"$"===e[a]||"_"===e[a]?(u+=e[a],a+=1):(this.parent.isDigit(e[a])&&(u="-"===e[a-1]?u+e[a-1]+e[a]:u+e[a]),"-"!==e[a]&&"+"!==e[a]||(u=(u+=e[a]).split("++").join("+").split("+-").join("-").split("-+").join("-")),"/"!==e[a]&&"*"!==e[a]&&"^"!==e[a]||(u+=e[a]),"&"!==e[a]||!i&&"q"===e.substring(a+1).trim()[0]||(u+=e[a]),a+=1);return u=u===this.emptyStr?e:u,this.indexOfAny(u[u.length-1],o)>-1&&(u=u.substring(0,u.length-1)),u=u.split("--").join("-").split("-+").join("-").split("+-").join("-")},e.prototype.checkScopedRange=function(r){var e=this,n=this.emptyStr,i="NaN",o=this.parent.getSheetID(this.parent.grid),s=this.parent.getSheetFamilyItem(this.parent.grid);if(r[0]===this.sheetToken.toString()){var a=r.indexOf(this.sheetToken,1),u=parseInt(r.substr(1,a-1),10);a>1&&!this.parent.isNaN(u)&&(r=r.substring(a+1),o=u)}var l="!"+o.toString();return null===s||null==s.sheetNameToToken?i:(s.sheetNameToToken.forEach(function(o,a){if(s.sheetNameToToken.get(a).toString()===l+"!"){var u=e.emptyStr;e.parent.namedRanges.forEach(function(o,a){u=t.isNullOrUndefined(e.parent.parentObject)?s.sheetNameToToken.get(a).toUpperCase():e.parent.parentObject.getActiveSheet().name+e.sheetToken+r.toUpperCase(),e.parent.getNamedRanges().has(u)&&(n=e.parent.getNamedRanges().get(u).toUpperCase(),i=n)})}}),i)},e.prototype.storeStrings=function(t){var e,n=0,i=0,o=0,s="",a=null;if(t.indexOf(this.parent.tic)>-1)for(n=t.indexOf(this.parent.tic);n>-1&&t.length>0;){if(null===a&&(a=this.stringsColl),-1===(i=n+1<t.length?t.indexOf(this.parent.tic,n+1):-1))throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedTics]);e=this.parent.substring(t,n,i-n+1),s=this.parent.tic+this.spaceString+o.toString()+this.parent.tic,a=a.set(s,e),t=t.substring(0,n)+s+t.substring(i+1),(n+=s.length)<=t.length&&(n=t.indexOf(this.parent.tic,n)),o++}return this.storedStringText=t,a},e.prototype.setStrings=function(r,t){return t.forEach(function(t,e){r=r.split(e).join(t)}),r},e.prototype.parseSimple=function(r){var t=r;if(t.length>0&&"+"===t[0]&&(t=t.substring(1)),"#DIV/0!"===t)return"#DIV/0!";if("#NAME?"===t)return"#NAME?";if(""===t)return t;if(this.parent.formulaErrorStrings.indexOf(t)>-1)return t;t=(t=(t=(t=(t=(t=t.split(this.stringLessEq).join(this.charLessEq)).split(this.stringGreaterEq).join(this.charGreaterEq)).split(this.stringNoEqual).join(this.charNoEqual)).split(this.stringAnd).join(this.charAnd)).split(this.stringOr).join(this.charOr)).split(this.fixedReference).join(this.emptyStr);var e=[this.tokenEp,this.tokenEm],n=[this.tokenMultiply,this.tokenDivide],i=[this.tokenAdd,this.tokenSubtract],o=[this.charMultiply,this.charDivide],s=[this.charAdd,this.charSubtract],a=[this.tokenLess,this.tokenGreater,this.tokenEqual,this.tokenLessEq,this.tokenGreaterEq,this.tokenNotEqual],u=[this.charLess,this.charGreater,this.charEqual,this.charLessEq,this.charGreaterEq,this.charNoEqual],l=[this.charEp,this.charEm],h=[this.tokenAnd],p=[this.charAnd],g=[this.charOr],f=[this.tokenOr];return t=this.parseSimpleOperators(t,e,l),t=this.parseSimpleOperators(t,f,g),t=this.parseSimpleOperators(t,n,o),t=this.parseSimpleOperators(t,i,s),t=this.parseSimpleOperators(t,a,u),t=this.parseSimpleOperators(t,h,p)},e.prototype.parseSimpleOperators=function(e,n,i){if(this.parent.getErrorStrings().indexOf(e)>-1)return e;for(var o=e,s=0,a="",u=0;u<i.length;u++)a+=i[u];if(o=o.split("---").join("-").split("--").join("+").split(this.parent.getParseArgumentSeparator()+"-").join(this.parent.getParseArgumentSeparator()+"u").split(this.parent.leftBracket+"-").join(this.parent.leftBracket+"u").split("=-").join("=u"),o=o.split(",+").join(",").split(this.parent.leftBracket+"+").join(this.parent.leftBracket).split("=+").join("=").split(">+").join(">").split("<+").join("<").split("/+").join("/").split("*+").join("*").split("++").join("+").split("*-").join("*u").split("/-").join("/u").split("w-").join("wu").split("i-").join("iu").toString(),(o=o.split(">-").join(">u").split("<-").join("<u").split("h-").join("hu").split("f-").join("fu").split("z-").join("zu")).length>0&&"-"===o[0]){var l=String.fromCharCode(132);o="0-"+(o=o.substring(1).split("-").join(l)),o=(o=this.parseSimpleOperators(o,[this.tokenSubtract],[this.charSubtract])).split(l).join("-")}else o.length>0&&"+"===o[0]?o=o.substring(1):o.length>0&&"+"===o[o.length-1]&&(o=o.substring(0,o.length-1));try{if(this.indexOfAny(o,i)>-1){if(o.includes(" ")){for(var h="",p=0;p<o.length;p++){var g=o[p];if(i.indexOf(g)>=0)h=h.trim()+g;else{if(" "===g&&i.indexOf(h[h.length-1])>=0)continue;h+=g}}o=h}s=this.indexOfAny(o,i);for(var f=this.parent.getParseDecimalSeparator();s>-1;){var m="",c="",d=0,v=0,N=!1,E=["*","+","-","/","w","=","<",">"],S=0;if(o[s]===this.charNOTop)d=s;else if(S=s-1,o[S]===this.parent.arithMarker){if((C=this.findLeftMarker(o.substring(0,S-1)))<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);m=this.parent.substring(o,C+1,S-C-1),d=C+1}else if(o[S]===this.parent.rightBracket){for(var y=0,C=S-1;C>0&&("q"!==o[C]||0!==y);)"q"===o[C]?y--:o[C]===this.parent.rightBracket&&y++,C--;if(C<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);m=this.parent.substring(o,C,S-C+1),d=C}else if(o[S]===this.parent.tic[0]){var b=o.substring(0,S-1).lastIndexOf(this.parent.tic);if(b<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);m=this.parent.substring(o,b,S-b+1),d=b}else{for(O=!1;S>-1&&(this.parent.isDigit(o[S])||!O&&(o[S]===f||"%"===o[S]));)this.parent.isDigit(o[S])||"%"===o[S]||(O=!0),S-=1;if(S>-1&&O&&o[S]===f)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.NumberContains2DecimalPoints]);if(0===(S+=1)||S>0&&!this.parent.isUpperChar(o[S-1]))m="n"+this.parent.substring(o,S,s-S),d=S;else if(S>0&&"E"===o[S-1]&&("TRUE"===o.substring(S-4,S)&&(t.isNullOrUndefined(o[S-5])||E.indexOf(o[S-5])>-1)||"FALSE"===o.substring(S-5,S)&&(t.isNullOrUndefined(o[S-6])||E.indexOf(o[S-6])>-1))&&("TRUE"===o.substring(S+1,S+5)||"FALSE"===o.substring(S+1,S+6)))S="TRUE"===o.substring(S-4,S)?S-4:S-5,m="TRUE"===o.substring(S,s)?"n1":"FALSE"===o.substring(S,s)?"n0":m,d=S,N=!0;else{for(S-=1;S>-1&&(this.parent.isUpperChar(o[S])||this.parent.isDigit(o[S])||"_"===o[S]);)S-=1;if(S>-1&&o[S]===this.sheetToken){for(S-=1;S>-1&&o[S]!==this.sheetToken;)S-=1;S>-1&&o[S]===this.sheetToken&&(S-=1)}if(S>-1&&":"===o[S]){for(S-=1;S>-1&&this.parent.isDigit(o[S]);)S-=1;for(;S>-1&&this.parent.isUpperChar(o[S]);)S-=1;if(S>-1&&o[S]===this.sheetToken){for(S--;S>-1&&o[S]!==this.sheetToken;)S--;S>-1&&o[S]===this.sheetToken&&S--}S+=1,m=this.parent.substring(o,S,s-S),m=this.parent.getCellFrom(m)}else{var A=!1;S>0&&!this.parent.isUpperChar(o[S])&&(A="u"===o[S]&&o[S-1]===this.parent.getParseArgumentSeparator()),A||(S+=1),m=this.parent.substring(o,S,s-S)}this.parent.updateDependentCell(m),d=S}(this.parent.namedRanges.size>0&&this.parent.namedRanges.has(m.toUpperCase())||this.parent.storedData.has(m.toUpperCase()))&&(m="n"+this.checkForNamedRangeAndKeyValue(m))}if(s===o.length-1)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.ExpressionCannotEndWithAnOperator]);if((A="u"===o[S=s+1])&&(S+=1),o[S]===this.parent.tic[0]){if((C=o.substring(S+1).indexOf(this.parent.tic))<0)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse];c=this.parent.substring(o,S,C+2),v=C+S+2}else if(o[S]===this.parent.arithMarker){if((C=this.findRightMarker(o.substring(S+1)))<0)throw new oe(this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse]);c=this.parent.substring(o,S+1,C),v=C+S+2}else if("q"===o[S]){for(var y=0,C=S+1;C<o.length&&(o[C]!==this.parent.rightBracket||0!==y);)o[C]===this.parent.rightBracket?y++:"q"===o[C]&&y--,C++;if(C===o.length)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CannotParse];c=this.parent.substring(o,S,C-S+1),A&&(c="u"+c),v=C+1}else if(this.parent.isDigit(o[S])||o[S]===f){var O=o[S]===f;for(S+=1;S<o.length&&(this.parent.isDigit(o[S])||!O&&o[S]===f);)o[S]===f&&(O=!0),S+=1;if(S<o.length&&"%"===o[S]&&(S+=1),O&&S<o.length&&o[S]===f)throw this.parent.formulaErrorStrings[r.FormulasErrorsStrings.NumberContains2DecimalPoints];c="n"+this.parent.substring(o,s+1,S-s-1),v=S}else if(this.parent.isUpperChar(o[S])||o[S]===this.sheetToken||"u"===o[S]){if(o[S]===this.sheetToken)for(S+=1;S<o.length&&o[S]!==this.sheetToken;)S+=1;S+=1;for(var F=0,x=!1;S<o.length&&(this.parent.isUpperChar(o[S])||"_"===o[S]||o[S]===f||"["===o[S]||"]"===o[S]||"#"===o[S]||" "===o[S]||"%"===o[S]||o[S]===f&&x);)S!==o.length-1&&"["===o[S]&&"["===o[S+1]&&(x=!0),S!==o.length-1&&"]"===o[S]&&"]"===o[S+1]&&(x=!1),S++,F++;var V=S===o.length||!this.parent.isDigit(o[S]);if(F>1){for(;S<o.length&&(this.parent.isUpperChar(o[S])||this.parent.isDigit(o[S])||" "===o[S]||"_"===o[S]);)S++;V=!0}for(;S<o.length&&this.parent.isDigit(o[S]);)S+=1;if(S<o.length&&":"===o[S]){if((S+=1)<o.length&&o[S]===this.sheetToken){for(S++;S<o.length&&o[S]!==this.sheetToken;)S+=1;S<o.length&&o[S]===this.sheetToken&&S++}for(;S<o.length&&this.parent.isUpperChar(o[S]);)S+=1;for(;S<o.length&&this.parent.isDigit(o[S]);)S+=1;S-=1,c=this.parent.substring(o,s+1,S-s),c=this.parent.getCellFrom(c)}else S-=1,c=this.parent.substring(o,s+1,S-s),(A="u"===o[S])&&(c="u"+c);V&&c.startsWith(this.sheetToken)&&(V=!this.parent.isCellReference(c)),V||this.parent.updateDependentCell(c),(this.parent.namedRanges.size>0&&this.parent.namedRanges.has(c.toUpperCase())||this.parent.storedData.has(c.toUpperCase()))&&(c="n"+this.checkForNamedRangeAndKeyValue(c));var R=["*","+","-","/","w"].indexOf(o[S-c.length])>-1;c="TRUE"===c&&(N||R)?"n1":"FALSE"===c&&(N||R)?"n0":c,v=S+1}var I=a.indexOf(o[s]),T=this.parent.arithMarker+m+c+n[I]+this.parent.arithMarker;d>0&&(T=o.substring(0,d)+T),v<o.length&&(T+=o.substring(v)),o=T=T.split(this.parent.arithMarker2).join(this.parent.arithMarker.toString()),s=this.indexOfAny(o,i)}}else if(o.length>0&&(this.parent.isUpperChar(o[0])||o[0]===this.sheetToken)){for(var M=!0,D=!0,U=!1,w=o.length,C=0;C<w;++C)if(o[C]===this.sheetToken){if(C>0&&!U)throw this.parent.getErrorStrings()[r.CommonErrors.Ref];for(U=!0,C++;C<w&&this.parent.isDigit(o[C]);)C++;if(C===w||o[C]!==this.sheetToken){M=!1;break}}else{if(!D&&this.parent.isChar(o[C])){M=!1;break}if(!this.parent.isChar(o[C])&&!this.parent.isDigit(o[C])&&o[C]!==this.sheetToken){M=!1;break}D=this.parent.isUpperChar(o[C])}M&&this.parent.updateDependentCell(o)}return o}catch(t){if(t===this.parent.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference])throw t;throw t}},e.prototype.indexOfAny=function(r,t){for(var e=0;e<r.length;e++)if(t.indexOf(r[e])>-1)return e;return-1},e.prototype.findLeftMarker=function(r){var t=-1;if(r.indexOf(this.parent.arithMarker)>-1)for(var e=0,n=r.length-1;n>=0;--n)if(r[n]===this.parent.rightBracket)e--;else if(r[n]===this.parent.leftBracket)e++;else if(r[n]===this.parent.arithMarker&&0===e){t=n;break}return t},e.prototype.findRightMarker=function(r){var t=-1;if(r.indexOf(this.parent.arithMarker)>-1)for(var e=0,n=0;n<r.length;++n)if(r[n]===this.parent.rightBracket)e--;else if(r[n]===this.parent.leftBracket)e++;else if(r[n]===this.parent.arithMarker&&0===e){t=n;break}return t},e.prototype.parseFormula=function(e,n){if(e.length>0&&e[0]===this.parent.getFormulaCharacter()&&(e=e.substring(1)),e.indexOf("#REF!")>-1)return this.parent.getErrorStrings()[r.CommonErrors.Ref];e.length>0&&"+"===e[0]&&(e=e.substring(1));try{this.isFailureTriggered=!1,this.isError=!1,e=this.parse(e.trim(),n),this.isFormulaParsed=!0}catch(r){var i=this.exceptionArgs(r);this.isFailureTriggered||(this.parent.trigger("onFailure",i),this.isFailureTriggered=!0);var o="string"==typeof i.exception?i.exception:i.message;e=(t.isNullOrUndefined(this.parent.getErrorLine(r))?"":"#"+this.parent.getErrorLine(r)+": ")+o,this.isError=!0}return e},e.prototype.markLibraryFormulas=function(e){var n=0,i=e.indexOf(")");if(-1===i)e=this.markNamedRanges(e);else for(var o=this;i>-1;){var s=function(){for(var s=0,a=i-1;a>-1&&("("!==e[a]||0!==s);)")"===e[a]&&s++,a--;if(-1===a)throw new oe(o.parent.formulaErrorStrings[r.FormulasErrorsStrings.MismatchedParentheses]);for(var u=a-1;u>-1&&(o.parent.isChar(e[u])||o.parent.isDigit(e[u])||"."===e[u]);)u--;var l=a-u-1,h=o.parent.substring(e,u+1,l);if(l>0&&!t.isNullOrUndefined(o.parent.getFunction(h))&&(!h.includes(".")||o.isValidDotFormulaName(h))){var p=o.parent.substring(e,a,i-a+1),g=o.parent.getParseArgumentSeparator();if("AREAS"===h)o.ignoreBracet=!0;else if(o.ignoreBracet=!1,(h.includes("IFS")&&"COUNTIFS"!==h||"MATCH"===h)&&p.includes("{")){var f=p.indexOf("{"),m=o.parent.substring(p,f,p.indexOf("}")-f+1);p=p.split(m).join(m.split(g).join(o.parent.tic+o.parent.tic))}else if(("VLOOKUP"===h||"HLOOKUP"===h)&&p.includes("{")){var f=p.indexOf("{"),c=(m=o.parent.substring(p,f,p.indexOf("}")-f+1)).split(";").join(o.parent.tic+"RSEP"+o.parent.tic).split(g).join(o.parent.tic+"CSEP"+o.parent.tic);p=p.split(m).join(c)}try{var d=void 0;p=p.split("(").join("").split(")").join(""),p="("+o.formulaAutoCorrection(p,d,!0)+")"}catch(t){if(!(d={message:t.message,exception:t,isForceCalculable:t.formulaCorrection,computeForceCalculate:!1}).isForceCalculable)throw o.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];if(o.isFailureTriggered||(o.parent.trigger("onFailure",d),o.isFailureTriggered=!0,n+=1),d.computeForceCalculate=n>0||d.computeForceCalculate,!d.isForceCalculable)throw o.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];if(!d.computeForceCalculate)throw o.parent.formulaErrorStrings[r.FormulasErrorsStrings.ImproperFormula];p=p.split("(").join("").split(")").join(""),p="("+o.formulaAutoCorrection(p,d)+")"}p=o.markNamedRanges(p),p=o.swapInnerParens(p),-1===(p=o.addParensToArgs(p)).lastIndexOf(g)&&p.length>2&&"("===p[0]&&")"===p[p.length-1]&&"{"!==p[1]&&"("!==p[1]&&(p=(p=p.substring(0,p.length-1)+"}"+p.substring(p.length-1))[0]+"{"+p.substring(1)),e=e.substring(0,u+1)+"q"+o.parent.substring(e,u+1,l)+p.split("(").join(o.parent.leftBracket).split(")").join(o.parent.rightBracket)+e.substring(i+1)}else{var v=function(r){if(r.includes("IFERROR(")){var t=r.lastIndexOf("(");return"IFERROR"===r.substring(t-7,t)||v(r.substring(0,t))}return!1};if(l>0&&!v(e.substring(0,u+1)))return{value:o.parent.getErrorStrings()[r.CommonErrors.Name]};var N=o.emptyStr;a>0&&(N=e.substring(0,a)),N=N+"{"+o.parent.substring(e,a+1,i-a-1)+"}",i<e.length&&(N+=e.substring(i+1)),N=o.markNamedRanges(N),e=N}i=e.indexOf(")")}();if("object"==typeof s)return s.value}return e=e.split("{").join("(").split("}").join(")")},e.prototype.swapInnerParens=function(r){return r.length>2&&(r=r[0]+r.substr(1,r.length-2).split("(").join("{").split(")").join("}")+r[r.length-1]),r},e.prototype.addParensToArgs=function(r){if(0===r.length)return this.emptyStr;var t=[];t.push(this.parent.getParseArgumentSeparator()),t.push(this.parent.rightBracket);var e=r.lastIndexOf(this.parent.getParseArgumentSeparator()),n=0;if(-1===e){if(r.length>2&&"("===r[0]&&")"===r[r.length-1])if("{"!==r[1]&&"("!==r[1])r=(r=r.substring(0,r.length-1)+"}"+r.substring(r.length-1))[0]+"{"+r.substring(1);else{var i=["+","-","*","/"];e=this.lastIndexOfAny(r,i),0===n&&")"===r[r.length-1]&&(n=r.length-1),n>0&&"{"!==r[e+1]&&"}"===r[e-1]&&(r=(r=r.substr(0,n)+"}"+r.substr(n)).substr(0,e+1)+"{"+r.substr(e+1))}}else for(var o=!0;e>-1;){var s=this.indexOfAny(r.substring(e+1,r.length),t);s>=0?s=e+s+1:-1===s&&")"===r[r.length-1]&&(s=r.length-1),s>0&&"{"!==r[e+1]&&"}"!==r[s-1]&&"¢"!==r[s-1]&&(r=(r=r.substr(0,s).trim()+"}"+r.substr(s)).substr(0,e+1)+"{"+r.substr(e+1).trim()),e=r.substr(0,e).lastIndexOf(this.parent.getParseArgumentSeparator()),o&&-1===e&&"("===r[0]&&(e=0,o=!1)}return r=r.split("{}").join(this.emptyStr)},e.prototype.lastIndexOfAny=function(r,t){for(var e=r.length-1;e>-1;e--)if(t.indexOf(r[e])>-1)return e;return-1},e.prototype.markNamedRanges=function(r){var e=[")",this.parent.getParseArgumentSeparator(),"}","+","-","*","/","<",">","=","&",":"],n=r.length>0&&("("===r[0]||"{"===r[0])?1:0;r.indexOf("#N/A")>-1&&(r=r.split("#N/A").join("#N~A")),r.indexOf("#DIV/0!")>-1&&(r=r.split("#DIV/0!").join("#DIV~0!"));for(var i=this.indexOfAny(r.substring(n),e);i>-1&&i+n<r.length;){var o=this.emptyStr,s=null;if(this.parent.substring(r,n,i).indexOf("[")>-1?s=this.getTableRange(this.parent.substring(r,n,i)):this.parent.storedData.has(this.parent.substring(r,n,i))?s=this.checkForNamedRangeAndKeyValue(this.parent.substring(r,n,i)):this.parent.namedRanges.has(this.parent.substring(r,n,i))&&(s=this.checkForNamedRangeAndKeyValue(this.parent.substring(r,n,i))),t.isNullOrUndefined(s)&&("NaN"!==(o=this.checkScopedRange(this.parent.substring(r,n,i)))?(this.findNamedRange=!0,s=o):this.parent.substring(r,n,i).startsWith(this.sheetToken.toString()),!t.isNullOrUndefined(s)&&this.findNamedRange&&s.indexOf(this.fixedReference)>-1&&(s=s.split(this.fixedReference).join(this.emptyStr))),t.isNullOrUndefined(s)||(s=s.toUpperCase(),s=this.parent.setTokensForSheets(s),s=this.markLibraryFormulas(s)),t.isNullOrUndefined(s)||s===this.emptyStr)for(n+=i+1;n<r.length&&!this.parent.isUpperChar(r[n])&&r[n]!==this.sheetToken;)n++;else r=r.substring(0,n)+s+r.substring(n+i),n+=s.length+1;for(i=n,n<r.length-1&&"{"===r[n]&&(n+=1),i=this.indexOfAny(r.substring(n),e);0===i&&n<r.length-1;)n++,i=this.indexOfAny(r.substring(n),e);if((-1===i||r.substring(n).indexOf("[")>-1)&&n<r.length){if(s=r.substring(n).indexOf("[")>-1?this.getTableRange(r.substring(n)):this.parent.storedData.has(r.substring(n))?this.parent.storedData.size>0?this.checkForNamedRangeAndKeyValue(r.substring(n)):s:this.parent.namedRanges.size>0?this.checkForNamedRangeAndKeyValue(r.substring(n)):s,t.isNullOrUndefined(s)&&"NaN"!==(o=this.checkScopedRange(r.substring(n)))&&(s=o),!t.isNullOrUndefined(s)&&s!==this.emptyStr&&(s=s.toUpperCase(),s=this.parent.setTokensForSheets(s),null!=(s=this.markLibraryFormulas(s)))){var a=r.substring(n);r=")"===a[a.length-1]?r.substring(0,n)+s+")":r.substring(0,n)+s,n+=s.toString().length+1}i=n<r.length?this.indexOfAny(r.substring(n),e):-1}}return r.indexOf("#N~A")>-1&&(r=r.split("#N~A").join("#N/A")),r.indexOf("#DIV~0!")>-1&&(r=r.split("#DIV~0!").join("#DIV/0!")),r},e.prototype.checkForNamedRangeAndKeyValue=function(r){var e=this.emptyStr;if(r.indexOf("[")>-1){var n=this.getTableRange(r);t.isNullOrUndefined(n)||(this.findNamedRange=!0,r=n)}if("NaN"!==(e=this.checkScopedRange(r)))this.findNamedRange=!0,r=e;else{if(r.indexOf(this.sheetToken)>-1){var i=this.parent.getSheetFamilyItem(this.parent.grid),o=r.split('"').join(this.emptyStr);if(o=o.substr(0,o.indexOf(this.sheetToken)),i.sheetNameToToken.has(o.toUpperCase()))parseInt(i.sheetNameToToken.get(o.toUpperCase()).split(this.sheetToken).join(this.emptyStr))}this.parent.storedData.size>0&&this.parent.storedData.has(r)&&(r="A"+this.parent.colIndex(r)),this.parent.namedRanges.size>0&&this.parent.namedRanges.has(r.toUpperCase())&&(t.isNullOrUndefined(this.parent.parentObject)?(r=this.parse(this.parent.namedRanges.get(r.toUpperCase())),(r=this.parent.setTokensForSheets(r)).indexOf(this.fixedReference)>-1&&r.split(this.fixedReference).join(this.emptyStr),this.findNamedRange=!0):r=this.parse(this.parent.namedRanges.get(r.toUpperCase()))),this.findNamedRange&&"!"!==r[0]&&"q"!==r[0]&&"bq"!==r[0]&&(r=this.parent.setTokensForSheets(r)).indexOf(this.fixedReference)>-1&&(r=r.split(this.fixedReference).join(this.emptyStr))}return r},e.prototype.getTableRange=function(r){var t=(r=r.replace(" ",this.emptyStr).toUpperCase()).replace("]",this.emptyStr).replace("#DATA",this.emptyStr);t.indexOf(this.parent.getParseArgumentSeparator())>-1&&(t.substring(0,t.indexOf(this.parent.getParseArgumentSeparator())).replace("[",this.emptyStr),t=t.replace("[",this.emptyStr).replace(this.parent.getParseArgumentSeparator(),"_"));this.emptyStr;return t.toUpperCase()},e.prototype.findNextEndIndex=function(r,t){for(var e=0,n=t,i=!1;!i&&t<r.length;)"["===r[n]?e++:"]"===r[n]&&0===--e&&(i=!0),t++;return t-=n},e.prototype.processIndexArg=function(r){var t=r.indexOf("INDEX((");if(-1!==t){var e=t+("INDEX((".length-1);if(-1!==e){for(var n=0,i=-1,o=e;o<r.length;o++)if("("===r[o]?n++:")"===r[o]&&n--,0===n){i=o;break}i>e&&(r=r.slice(0,e)+this.parent.tic+r.slice(e+1,i)+this.parent.tic+r.slice(i+1))}}return r},e.prototype.isValidDotFormulaName=function(r){return r=r.toUpperCase(),["STDEV.P","STDEV.S","VAR.S","VAR.P","T.TEST","F.TEST","Z.TEST","CHISQ.TEST","COVARIANCE.S","COVARIANCE.P","CHISQ.DIST","F.DIST","T.DIST","NETWORKDAYS.INTL","WORKDAY.INTL","ERROR.TYPE","ECMA.CEILING","ISO.CEILING"].some(function(t){return r===t})},e.prototype.isOtherLangChar=function(r){var t=r.charCodeAt(0);return t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=255},e.prototype.destroy=function(){this.stringsColl.clear(),this.storedStringText=this.emptyStr,this.isError=!1,this.isFormulaParsed=!1,this.parent=null},e}(),ee=function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),ne=function(r,t,e,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,t,e,n);else for(var a=r.length-1;a>=0;a--)(i=r[a])&&(s=(o<3?i(s):o>3?i(t,e,s):i(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s},ie=function(e){function n(r){var n=e.call(this,null,null)||this;n.lFormulas=new Map,n.storedData=new Map,n.keyToRowsMap=new Map,n.rowsToKeyMap=new Map,n.rightBracket=String.fromCharCode(161),n.leftBracket=String.fromCharCode(162),n.sheetToken="!",n.cell="",n.cellPrefix="!0!A",n.treatEmptyStringAsZero=!1,n.tic='"',n.singleTic="'",n.trueValue="TRUE",n.falseValue="FALSE",n.parseDecimalSeparator=".",n.arithMarker=String.fromCharCode(180),n.arithMarker2=n.arithMarker+n.arithMarker,n.dependentCells=null,n.dependentFormulaCells=null,n.minValue=Number.MIN_SAFE_INTEGER,n.maxValue=Number.MAX_SAFE_INTEGER,n.categoryCollection=["All"],n.dependencyLevel=0,n.randomValues=new Map,n.isRandomVal=!1,n.randCollection=[],n.dependencyCollection=[],n.uniqueRange=[],n.sortRange=[],n.formulaErrorStrings=[],n.errorStrings=null,n.parseArgumentSeparator=",",n.dateTime1900=new Date(1900,0,1,0,0,0),n.isParseDecimalSeparatorChanged=!1,n.isArgumentSeparatorChanged=!1,n.sheetFamilyID=0,n.defaultFamilyItem=null,n.sheetFamiliesList=null,n.modelToSheetID=null,n.tokenCount=0,n.sortedSheetNames=null,n.tempSheetPlaceHolder=String.fromCharCode(133),n.namedRanges=new Map,n.formulaInfoTable=null,n.millisecondsOfaDay=864e5,n.parseDateTimeSeparator="/",n.evaluatingKeys=new Set;var i=r,o=i&&i.locale?i.locale:"en-US";return n.l10n=new t.L10n("calculate",z,o),n.refreshLocalizedStrings(),new re(n),n.parentObject=t.isNullOrUndefined(r)?n:r,n.grid=n.parentObject,n.parser=new te(n),n}return ee(n,e),Object.defineProperty(n.prototype,"libraryFormulas",{get:function(){return this.lFormulas},set:function(r){this.lFormulas.set(r.fName,{handler:r.handler,category:r.category,description:r.description})},enumerable:!0,configurable:!0}),n.prototype.setLocale=function(r){var t=this.parentObject,e=r||t&&t.locale||"en-US";this.l10n.setLocale(e),this.refreshLocalizedStrings()},n.prototype.refreshLocalizedStrings=function(){var r=this,t=function(t){return r.l10n.getConstant(t)};this.formulaErrorStrings=[t("OperatorsCannotStartWithExpression"),t("CannotParse"),t("BadLibrary"),t("InvalidCharInFrontOf"),t("NumberContains2DecimalPoints"),t("ExpressionCannotEndWithAnOperator"),t("InvalidCharactersFollowingWithOperator"),t("InvalidCharInNumber"),t("MismatchedParentheses"),t("UnknownFormulaName"),t("RequiresASingleArgument"),t("Requires3Args"),t("InvalidMathArgument"),t("Requires2Args"),"#NAME?",t("TooComplex"),"#CIRCULARREF!",t("MissingFormula"),t("ImproperFormula"),t("InvalidExpression"),t("CellEmpty"),t("BadFormula"),t("EmptyExpression"),"",t("MismatchedTics"),t("WrongNumberArguments"),t("InvalidArguments"),t("IterationsDoNotConverge"),t("AlreadyRegistered"),t("CalculationOverflow"),t("MissingSheet"),t("CannotParseUnderscore"),t("ExpressionCannotEndWithAnOperatorUnderscore"),"#SPILL!","#DIV/0!"],this.categoryCollection=[t("CategoryAll")]},n.prototype.getHostSheetInfo=function(){var r=this.parentObject;return r&&"function"==typeof r.getSheetInfo?r.getSheetInfo()||[]:[]},n.prototype.hostParseDate=function(r){var t=this.parentObject;return t&&"function"==typeof t.parseDate?t.parseDate(r)||{}:{}},n.prototype.getParseArgumentSeparator=function(){return this.isArgumentSeparatorChanged||","===this.parseArgumentSeparator||(this.parseArgumentSeparator=","),this.parseArgumentSeparator},n.prototype.setParseArgumentSeparator=function(r){this.parseArgumentSeparator=r,this.isArgumentSeparatorChanged=!0},n.prototype.getParseDateTimeSeparator=function(){return this.parseDateTimeSeparator},n.prototype.setTreatEmptyStringAsZero=function(r){this.treatEmptyStringAsZero=r},n.prototype.getTreatEmptyStringAsZero=function(){return this.treatEmptyStringAsZero},n.prototype.setParseDateTimeSeparator=function(r){this.parseDateTimeSeparator=r},n.prototype.onPropertyChanged=function(r,t){},n.prototype.getModuleName=function(){return"calculate"},n.prototype.getFormulaCharacter=function(){return"="},n.prototype.isUpperChar=function(r){var t=r.charCodeAt(0);return t>64&&t<91},n.prototype.resetKeys=function(){this.storedData.clear(),this.keyToRowsMap.clear(),this.rowsToKeyMap.clear()},n.prototype.updateDependentCell=function(t){var e=this,n=this.cell;if(""!==n){var i=this.getSheetFamilyItem(this.grid);if(i.sheetNameToParentObject&&(n.includes(this.sheetToken)||(n=i.parentObjectToToken.get(this.grid)+n),t.includes(this.sheetToken)||(t=i.parentObjectToToken.get(this.grid)+t)),n!==t){var o=this.getDependentCells();o.has(t)||o.set(t,[]);var s=o.get(t);if(-1===s.indexOf(n)){var a=this.getDependentFormulaCells(),u={},l=function(t){if(a.has(t)){var i=a.get(t);if(i.has(n))throw e.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference];u[t]||(u[t]=!0,i.forEach(function(r){l(r)}))}};l(t),s.push(n),a.has(n)?a.get(n).has(t)||a.get(n).set(t,t):(a.set(n,new Map),a.get(n).set(t,t))}}}},n.prototype.getDependentCells=function(){return null==this.dependentCells&&(this.dependentCells=new Map),this.dependentCells},n.prototype.getDependentFormulaCells=function(){if(this.isSheetMember()){var r=this.getSheetFamilyItem(this.grid);return null==r.sheetDependentFormulaCells&&(r.sheetDependentFormulaCells=new Map),r.sheetDependentFormulaCells}return null==this.dependentFormulaCells&&(this.dependentFormulaCells=new Map),this.dependentFormulaCells},n.prototype.getLibraryFormulas=function(){return this.lFormulas},n.prototype.getFunction=function(r){return this.getLibraryFormulas().has(r.toUpperCase())?this.getLibraryFormulas().get(r.toUpperCase()).handler:null},n.prototype.intToDate=function(r){var t=Number(r);(t=t>0&&t<1?1+t:0===t?1:t)>60&&(t-=1);var e=new Date("01/01/1900"),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());return new Date(new Date(864e5*(t-1)+n).toUTCString().replace(" GMT",""))},n.prototype.getFormulaInfoTable=function(){if(this.isSheetMember()){var r=this.getSheetFamilyItem(this.grid);return null===r.sheetFormulaInfotable&&(r.sheetFormulaInfotable=new Map),r.sheetFormulaInfotable}return null===this.formulaInfoTable&&(this.formulaInfoTable=new Map),this.formulaInfoTable},n.prototype.getParseDecimalSeparator=function(){return this.isParseDecimalSeparatorChanged||"."===this.parseDecimalSeparator||(this.parseDecimalSeparator="."),this.parseDecimalSeparator},n.prototype.setParseDecimalSeparator=function(r){this.parseDecimalSeparator=r,this.isParseDecimalSeparatorChanged=!0},n.prototype.getSheetToken=function(t){var e=0,n="";if(e<t.length&&t[e]===this.sheetToken){for(e++;e<t.length&&t[e]!==this.sheetToken;)e++;n=t.substring(0,e+1)}if(e<t.length)return n;throw this.formulaErrorStrings[r.FormulasErrorsStrings.BadIndex]},n.prototype.getSheetID=function(r){var t=this.getSheetFamilyItem(r);if(null!=t.sheetNameToParentObject&&t.sheetNameToParentObject.size>0){var e=t.parentObjectToToken.get(r);if(e){e=e.split(this.sheetToken).join("");var n=this.parseFloat(e);if(!this.isNaN(n))return n}}return-1},n.prototype.parseFloat=function(r){var t=Number(r);return isNaN(t)&&"string"==typeof r&&r.includes(",")&&(t=Number(r.split(",").join(""))),t},n.prototype.rowIndex=function(t){var e=0,n=!1;if(e<t.length&&t[e]===this.sheetToken){for(e++;e<t.length&&t[e]!==this.sheetToken;)e++;e++}for(;e<t.length&&this.isChar(t[e]);)n=!0,e++;var i=parseInt(t.substring(e),10);if(e<t.length&&!this.isNaN(i))return i;if(n)return-1;throw this.formulaErrorStrings[r.FormulasErrorsStrings.BadIndex]},n.prototype.colIndex=function(r){var t=0,e=0;if(r=r.toUpperCase(),t<r.length&&r[t]===this.sheetToken){for(t++;t<r.length&&r[t]!==this.sheetToken;)t++;t++}for(;t<r.length&&this.isChar(r[t]);)e=26*e+r[t].charCodeAt(0)-64,t++;return 0===e?-1:e},n.prototype.getErrorStrings=function(){return null===this.errorStrings&&(this.errorStrings=["#N/A","#VALUE!","#REF!","#DIV/0!","#NUM!","#NAME?","#NULL!","#CALC!"]),this.errorStrings},n.prototype.substring=function(r,t,e){return r.substring(t,e+t)},n.prototype.isChar=function(r){return r.charCodeAt(0)>=65&&r.charCodeAt(0)<=90||r.charCodeAt(0)>=97&&r.charCodeAt(0)<=122},n.prototype.getSheetFamilyItem=function(r,t){return 0===this.sheetFamilyID?(null==this.defaultFamilyItem&&(this.defaultFamilyItem=new ae),this.defaultFamilyItem):(null==this.sheetFamiliesList&&(this.sheetFamiliesList=new Map),void 0===t&&(t=this.modelToSheetID.get(r)),this.sheetFamiliesList.has(t)||this.sheetFamiliesList.set(t,new ae),this.sheetFamiliesList.get(t))},n.prototype.setKeyValue=function(r,t){r=r.toUpperCase();var e=t.toString().trim();this.storedData.get(r)&&0!==e.indexOf("{")||(this.storedData.set(r,new se),this.keyToRowsMap.set(r,this.keyToRowsMap.size+1),this.rowsToKeyMap.set(this.rowsToKeyMap.size+1,r));var n=this.storedData.get(r);if(null!=n.getFormulaText()&&n.getFormulaText().length>0&&n.getFormulaText()!==e){var i=this.cellPrefix+this.keyToRowsMap.get(r).toString();null!=this.getDependentFormulaCells().get(i)&&this.clearFormulaDependentCells(i)}e.length>0&&e[0]===this.getFormulaCharacter()?n.setFormulaText(e):n.getFormulaValue()!==e&&(n.setFormulaText(""),n.setParsedFormula(""),n.setFormulaValue(e))},n.prototype.clearFormulaDependentCells=function(r){var t=this,e=this.getDependentFormulaCells().get(r);e&&(e.forEach(function(e,n){var i=n,o=t.getDependentCells().get(i);t.arrayRemove(o,r),0===o.length&&t.getDependentCells().delete(i)}),this.getDependentFormulaCells().delete(r))},n.prototype.clearKeys=function(){this.resetKeys()},n.prototype.arrayRemove=function(r,t){var e=r.indexOf(t);return-1!==e&&r.splice(e,1),r},n.prototype.getKeyValue=function(e){if(e=e.toUpperCase(),!this.storedData.has(e))return"";var n=this.storedData.get(e),i=n.getFormulaText();if(i.length>0&&i[0]===this.getFormulaCharacter()){if(this.evaluatingKeys.has(e))return this.getErrorStrings()[r.CommonErrors.Ref];this.evaluatingKeys.add(e),this.cell=this.cellPrefix+this.keyToRowsMap.get(e).toString(),i=i.substring(1);try{try{n.setParsedFormula(this.parser.parseFormula(i,e))}catch(r){o={message:r.message,exception:r,isForceCalculable:!1,computeForceCalculate:!1};return this.trigger("onFailure",o),n.setFormulaValue(o.message),this.storedData.get(e).getFormulaValue()}try{n.setFormulaValue(this.computeFormula(n.getParsedFormula()))}catch(r){var o={message:r.message,exception:r,isForceCalculable:!1,computeForceCalculate:!1};this.trigger("onFailure",o);var s="string"==typeof o.exception?o.exception:o.message;return(t.isNullOrUndefined(this.getErrorLine(r))?"":"#"+this.getErrorLine(r)+": ")+s}}finally{this.evaluatingKeys.delete(e)}}return this.storedData.get(e).getFormulaValue()},n.prototype.getNamedRanges=function(){return this.namedRanges},n.prototype.addNamedRange=function(r,t){var e=r.split(this.sheetToken);if(e.length>1){var n=this.getSheetId(this.grid).toString();if(!this.getSheetFamilyItem(n).parentObjectToToken.get(n))return!1;r=e[0]+this.sheetToken+e[1].toUpperCase()}else r=r.toUpperCase();return this.namedRanges.set(r,t),!0},n.prototype.updateNamedRange=function(r,t){var e=new Map;this.namedRanges.forEach(function(n,i){var o=i;if(i.includes(r)){var s=i.split("!");s[0]=t,o=s.join("!")}e.set(o,n)}),this.namedRanges=e},n.prototype.removeNamedRange=function(r){return r=r.toUpperCase(),null!=this.namedRanges.get(r)&&(this.namedRanges.delete(r),!0)},n.prototype.convertAlpha=function(r){for(var t=[],e=0;r>0;){r--;var n="A".charCodeAt(0);t[e]=String.fromCharCode(r%26+n),r=parseInt((r/26).toString(),10),e++}for(var i=[],o=0;o<e;o++)i[e-o-1]=t[o];return i.join("")},n.prototype.getCellCollection=function(t){if(t.indexOf(":")<0){if(!this.isCellReference(t))return t.split(this.getParseArgumentSeparator());t=t+":"+t}var e="",n=t.indexOf(this.sheetToken);if(n>-1)for(var i=n+1;i<t.length;){if(t[i]===this.sheetToken){e=t.substr(0,i+1);break}i++}var o,s,a,u,l=t.indexOf(":");if(l>0&&this.isChar(t[l-1]))for(var h=l-2;h>=0&&this.isDigit(t[h]);)h--;if(o=this.rowIndex(this.substring(t,0,l)),s=this.rowIndex(this.substring(t,l+1,l+t.length-l-1)),a=this.colIndex(this.substring(t,0,l)),u=this.colIndex(this.substring(t,l+1,l+t.length-l-1)),o>=1048576||s>=1048576||a>=16384||u>=16384)return[this.getErrorStrings()[r.CommonErrors.Ref]];o>s&&(l=s,s=o,o=l),a>u&&(l=u,u=a,a=l);var p,g=[],f=0;for(l=o;l<=s;l++)for(p=a;p<=u;p++)g[f]=e+""+this.convertAlpha(p)+l.toString(),f++;return g},n.prototype.computeFormula=function(r,t){return this.calculateFormula(r,!1,t)},n.prototype.calculateFormula=function(e,n,i){var o,s,a,u,l=this,h=!1;if(this.parser.isError)return e;o=this.parser.isFormulaParsed?e:this.parser.parseFormula(e),this.parser.isFormulaParsed=!1;try{if((s=this.findLastIndexOfq(o))>0&&(h=!0),""!==o&&s>-1)for(var p=s+1,g=this;p>-1&&"break"!==function(){if(o[p]!==g.rightBracket)return p++,"continue";var e=o.substring(s,p+1),f=e.split(g.leftBracket)[0].split("q").join(""),m=void 0;if(g.getLibraryFormulas().get(f.toUpperCase()).isCustom){m=e.substring(e.indexOf(g.leftBracket)+1,e.indexOf(g.rightBracket)).split(g.getParseArgumentSeparator());var c=0,d=[],v=void 0;for(c=0;c<m.length;c++)m[c].includes(":")&&g.isCellReference(m[c])&&(v=g.getCellCollection(m[c])).length>1?(d.push(m[c]),v.forEach(function(r){l.updateDependentCell(r)})):d.push(g.getValueFromArg(m[c]));m=d}else{var N=e.substring(e.indexOf(g.leftBracket)+1,e.indexOf(g.rightBracket));m=[];for(var E=g.getParseArgumentSeparator(),S="",y=void 0,C=0,b=N.length-1;C<=b;C++)'"'===N[C]&&(y=!y),N[C]!==E||y?(S+=N[C],C===b&&m.push(S)):(m.push(S),S="",C===b&&m.push(S));if(m.length||(m=[""]),h&&f&&(["IF","INDEX","SORT","T","EXACT","PROPER","DOLLAR","DATE","TEXT","ISNUMBER"].some(function(r){return r===f})&&m.push("nestedFormulaTrue"),"IF"===f&&m.push("nestedFormulaTrue"),"VLOOKUP"===f||"HLOOKUP"===f)){var A=o.lastIndexOf("q",s-1);if(-1!==A){var O=o.substring(A+1,o.lastIndexOf(g.leftBracket,s-1));["IF","IFS","AND","OR","NOT"].some(function(r){return r===O})&&m.push("conditionalFormulaTrue")}}i&&"UNIQUE"===f&&m.push("isComputeExp")}if(a=t.isNullOrUndefined(g.getFunction(f))?g.getErrorStrings()[r.CommonErrors.Name]:g.getFunction(f).apply(void 0,m),h){u=g.processNestedFormula(o,e,a);var F=g.findLastIndexOfq(u);return 0===F&&(h=!1),-1===F&&(a=g.computeValue(u,n)),s=p=F,o=u,"continue"}return"break"}(););else this.formulaErrorStrings.indexOf(o)>-1?a=o:""!==o&&-1===s&&(a=this.computeValue(o,n))}catch(r){var f={message:r.message,exception:r,isForceCalculable:!1,computeForceCalculate:!1};this.trigger("onFailure",f);var m="string"==typeof f.exception?f.exception:f.message;a=(t.isNullOrUndefined(this.getErrorLine(r))?"":"#"+this.getErrorLine(r)+": ")+m}return a},n.prototype.computeSumIfAndAvgIf=function(e,n){if(t.isNullOrUndefined(e)||""===e[0]||0===e.length)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var i=e,o=0;o<i.length;o++)if(this.isCellReference(i[o])&&t.isNullOrUndefined(i[o].match(/[0-9]/))&&i[o].indexOf("!")<0){var s=i[o].split(":");i[o]=s[0]+"1:"+s[1]+this.spreadSheetUsedRange[0]}var a=i.length;if(2!==a&&3!==a&&0===a)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===i[1])return n?this.getErrorStrings()[r.CommonErrors.DivZero]:"0";var u=i[0],l=i[1].startsWith(this.tic)&&i[1].endsWith(this.tic),h=this.getANDComputedValue(i[1]);if(h.length>255)return this.getErrorStrings()[r.CommonErrors.Value];var p=h.includes("*"),g=h.includes("?"),f=p?h.replace(/\*/g,"").trim():h,m=!1;if(!l&&this.isCellReference(f)&&(f=this.getValueFromArg(f),m=!0),p){var c=h.indexOf("*");"*"===h[0]&&(f="*"+f),"*"===h[h.length-1]&&(f+="*"),c>0&&c<h.length-1&&(f=h.substring(0,c)+"*"+h.substring(c+1))}h=f;var d=this.parser.tokenEqual;h.startsWith("<=")?(d=this.parser.tokenLessEq,h=h.substring(2)):h.startsWith(">=")?(d=this.parser.tokenGreaterEq,h=h.substring(2)):h.startsWith("<>")?(d=this.parser.tokenNotEqual,h=h.substring(2)):h.startsWith("<")?(d=this.parser.tokenLess,h=h.substring(1)):h.startsWith(">")?(d=this.parser.tokenGreater,h=h.substring(1)):h.startsWith("=")&&(d=this.parser.tokenEqual,h=h.substring(1)),(!l&&this.isCellReference(h)&&!m||h.includes(this.arithMarker)||h.includes(this.getParseDecimalSeparator())&&!p&&!g)&&(h=this.getValueFromArg(h));var v=this.parseFloat(h),N=i[0],E=this.getCellCollection(a>2?i[2]:u),S=this.getCellCollection(N);if("#REF!"===E[0]||"#REF!"===S[0])return this.getErrorStrings()[r.CommonErrors.Name];if(S.length>E.length){var y=this.colIndex(E[E.length-1])+this.colIndex(S[S.length-1])-this.colIndex(S[0]),C=i[2].split(":");if(C[1]=(this.convertAlpha(y)+this.rowIndex(S[S.length-1])).toString(),"#REF!"===(E=this.getCellCollection(C.join(":")))[0])return this.getErrorStrings()[r.CommonErrors.Name]}var b=this.getComputeSumIfValue(S,E,h.toLowerCase(),v,d,p,g);return[b[0],b[1]]},n.prototype.computeLookup=function(e){var n,i,o,s,a,u,l=[],h=[],p=[],g=[],f=[],m=e,c=m.length;if(1===c||c>3)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===m[1]||""===m[2])return this.getErrorStrings()[r.CommonErrors.Value];if(a=this.getValueFromArg(m[0]),m[0].indexOf(this.tic)>-1&&m[0].toUpperCase().split(this.tic).join("")!==this.trueValue&&m[0].toUpperCase().split(this.tic).join("")!==this.falseValue&&this.isNaN(this.parseFloat(m[0].split(this.tic).join("")))&&(a=a.split(this.tic).join("")),this.getErrorStrings().indexOf(a)>-1)return a;var d=m[1].split(":");if(2===d.length&&this.isCellReference(d[0])&&this.isCellReference(d[1])&&2===c){var v=m[1].indexOf(":"),N=this.rowIndex(this.substring(m[1],0,v)),E=this.colIndex(this.substring(m[1],0,v)),S=this.rowIndex(this.substring(m[1],v+1,v+m[1].length-v-1)),y=this.colIndex(this.substring(m[1],v+1,v+m[1].length-v-1));N>S&&(N=(n=[S,N])[0],S=n[1]),E>y&&(E=(i=[y,E])[0],y=i[1]);var C="";0===m[1].indexOf("!")&&(C=(C=(C=m[1]).replace("!","")).indexOf("!"),C=m[1].substring(0,C+2));var b=y-E+1,A=S-N+1;A>b||A===b?(o=C+K(E)+N+":"+K(E)+S,s=C+K(y)+N+":"+K(y)+S):A<b&&(o=C+K(E)+N+":"+K(y)+N,s=C+K(E)+S+":"+K(y)+S),N===S&&E===y||(u=!0)}if(u){if(l=this.getCellCollection(o),h=this.getCellCollection(s),"#REF!"===l[0]||"#REF!"===h[0])return this.getErrorStrings()[r.CommonErrors.Name]}else{l=this.getCellCollection(m[1]);var O=2===c?m[1]:m[2];if(h=this.getCellCollection(O),"#REF!"===l[0]||"#REF!"===h[0])return this.getErrorStrings()[r.CommonErrors.Name];var F=Y(m[1]),x=Y(O),V=F[1]===F[3]||F[0]===F[2],R=x[1]===x[3]||x[0]===x[2];if(!V||!R)return this.getErrorStrings()[r.CommonErrors.NA]}for(var I=0;I<l.length;I++)g.push(this.getValueFromArg(l[I]).split(this.tic).join(""));var T=g.map(function(r){return""===r?NaN:Number(r)}).sort(function(r,t){return r-t}),M=T[T.length-1],D=T[0],U=this.parseFloat(a);if(this.isNaN(U)){for(var w=0;w<l.length;w++)if(p[w]=this.getValueFromArg(l[w]).split(this.tic).join(""),!t.isNullOrUndefined(h[w])&&""!==a&&""!==p[w])if(a.toUpperCase()===p[w].toUpperCase())f.push(this.getValueFromArg(h[w]).split(this.tic).join("")||"0");else if(a.indexOf("*")>-1||a.indexOf("?")>-1){var j=a;if(a.indexOf("*")>-1){j=j.replace(/\*/g,"").trim(),this.isCellReference(j)&&(j=this.getValueFromArg(j));var L=a.indexOf("*");"*"===a[0]&&(j="*"+j),"*"===a[a.length-1]&&(j+="*"),L>0&&L<a.length-1&&(j=a.substring(0,L)+"*"+a.substring(L+1))}var k=[],P=this.findWildCardValue(j.toLowerCase(),p[w].toLowerCase());k.push(P),k.push(a),this.processLogical(k,"equal")===this.trueValue&&f.push(this.getValueFromArg(h[w]).split(this.tic).join("")||"0")}}else for(var _=0;_<T.length;_++)p[_]=T[_].toString().split(this.tic).join(""),t.isNullOrUndefined(h[_])||""===p[_]||U!==this.parseFloat(p[_])||f.push(this.getValueFromArg(h[_]).split(this.tic).join("")||"0");if(f.length>0)return f[f.length-1];if(U>M&&!t.isNullOrUndefined(h[l.length-1]))return this.getValueFromArg(h[l.length-1]).split(this.tic).join("")||"0";if(U<D)return this.getErrorStrings()[r.CommonErrors.NA];if(g.indexOf(a.split(this.tic).join(""))<0&&a!==this.trueValue&&a!==this.falseValue)if(this.isNaN(U)||this.isNaN(M)||this.isNaN(D)){if(this.isNaN(U)&&""!==a&&/^[a-zA-Z!@#$%^&*()_+{}[\]:;<>,.?~\\/-]/.test(a)){var W=g.sort(),v=this.findClosestMatch(a.split(this.tic).join(""),W);if(!t.isNullOrUndefined(h[v])&&v>=0)return this.getValueFromArg(h[v]).split(this.tic).join("")||"0"}}else{for(var q=[],B=0;B<T.length;B++)U>T[B]&&q.push(T[B]);v=q.length-1;if(!t.isNullOrUndefined(h[v])&&v>=0)return this.getValueFromArg(h[v]).split(this.tic).join("")||"0"}return this.getErrorStrings()[r.CommonErrors.NA]},n.prototype.computeVHLookup=function(e,n){var i,o,s,a=this,u=e;if(u&&"conditionalFormulaTrue"===u[u.length-1]&&(s=!0,u.pop()),t.isNullOrUndefined(u)||u.length<3||u.length>4)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];if(""===u[1])return this.getErrorStrings()[r.CommonErrors.NA];var l=this.getValueFromArg(u[0]);if(l){if(l.includes(this.tic)){var h=l.split(this.tic).join("");h&&!this.isNumber(h)&&(O=h.toUpperCase())!==this.trueValue&&O!==this.falseValue&&(l=h)}}else l="0";var p=this.getErrorStrings();if(p.indexOf(l)>-1)return l;var g=(this.getValueFromArg(u[2])||"0").split(this.tic).join("").toUpperCase(),f=this.parseFloat(g===this.trueValue?"1":g);if(f<1)return p[r.CommonErrors.Value];var m;if(u[3]){if(u[3]=this.getValueFromArg(u[3]).split(this.tic).join(""),p.indexOf(u[3])>-1)return u[3];var c=u[3].toUpperCase();if(c===this.falseValue||"0"===u[3])m=!0;else if(c!==this.trueValue&&"1"!==u[3])return p[r.CommonErrors.Value]}var d=u[1],v=this.tic+"RSEP"+this.tic;if(d.includes(v)||d.startsWith("(")&&d.endsWith(")")&&d.includes(v)){var N=d.startsWith("(")&&d.endsWith(")")?d.substring(1,d.length-1):d,E=this.tic+"RSEP"+this.tic,S=this.tic+"CSEP"+this.tic,y=N.split(E).map(function(r){return r.split(S).map(function(r){return r.startsWith(a.tic)&&r.endsWith(a.tic)?r.substring(1,r.length-1):a.isCellReference(r.trim())?a.getValueFromArg(r.trim()):r.trim()})}),C=y.length,b=y[0]?y[0].length:0,A=f-1;if(n&&b<=A)return p[r.CommonErrors.Ref];if(!n&&C<=A)return p[r.CommonErrors.Ref];for(var O=l.toUpperCase(),F=n?C:b,x=0;x<F;x++){var V=(n?y[x][0]:y[0][x])||"";if(this.isNumber(l)&&this.isNumber(V)?this.parseFloat(l)===this.parseFloat(V):V.toUpperCase()===O){var R=n?void 0!==y[x][A]?y[x][A]:"":void 0!==y[A]&&void 0!==y[A][x]?y[A][x]:"";return""!==R?R:""}}return p[r.CommonErrors.NA]}var I,T,M,D,U,w,j=d.split(":");if(!this.isCellReference(j[0])||!this.isCellReference(j[1]))return p[r.CommonErrors.Value];var L=this.rowIndex(j[0]),k=this.colIndex(j[0]),P=this.rowIndex(j[1]),_=this.colIndex(j[1]);if(L>P&&(L=(i=[P,L])[0],P=i[1]),k>_&&(k=(o=[_,k])[0],_=o[1]),!(L>0&&P<=1048576&&k>0&&_<=16384))return this.getErrorStrings()[r.CommonErrors.Name];D=this.grid;var W="",q=this.getSheetFamilyItem(D);u[1].startsWith("!")?(W=u[1].substring(0,u[1].replace("!","").indexOf("!")+2),null!==q.tokenToParentObject&&(this.grid=q.tokenToParentObject.get(W))):null!==q.parentObjectToToken&&(W=q.parentObjectToToken.get(D));var B=this.getSheetId(this.grid);if(-1===Z("Sheet"+B,this.getHostSheetInfo()))return this.grid=D,p[r.CommonErrors.Ref];var X=this.getCellValueFn(D,this.cell,B,!0);if(n){var Y=k+f-1;if(Y>_)return p[r.CommonErrors.Ref];I=L,T=P;var G=W+K(k);U=function(r){return X(r,k,G+r)};var $=W+K(Y);w=function(){return X(M,Y,$+M)||(s?'""':"0")}}else{var z=L+f-1;if(z>P)return p[r.CommonErrors.Ref];I=k,T=_;var Q;U=function(r){return Q=W+K(r),X(L,r,Q+L)},w=function(){return X(z,M,Q+z)||(s?'""':"0")}}var J,rr,tr=[];if(m){var er=void 0;if(this.isNumber(l)){var nr=this.parseFloat(l);er=function(){return nr===a.parseFloat(rr)}}else if(l.includes("*")||l.includes("?")){var ir=l,or=l.indexOf("*");or>-1&&(ir=ir.replace(/\*/g,"").trim(),this.isCellReference(ir)&&(ir=this.getValueFromArg(ir)),0===or?ir="*"+ir:or===l.length-1?ir+="*":ir=l.substring(0,or)+"*"+l.substring(or+1)),ir=ir.toLowerCase(),er=function(){return a.processLogical([a.findWildCardValue(ir,rr.toLowerCase()),l],"equal")===a.trueValue}}else{var sr=l.toUpperCase();er=function(){return sr===rr.toUpperCase()}}for(M=I;M<=T;M++)(rr=U(M))&&er()&&tr.push(w());J=tr.length?tr[0]:p[r.CommonErrors.NA]}else if(l.indexOf("*")>-1||l.indexOf("?")>-1)J=p[r.CommonErrors.NA];else{var ar,ur=void 0;if(this.isNumber(l)){var lr=this.parseFloat(l),hr=H("");ur=function(){ar=hr(a.isNumber(rr)?a.parseFloat(rr):rr||null,lr)}}else{var pr=new Intl.Collator(this.parentObject.locale||"en-US",{sensitivity:"base"});ur=function(){ar=!rr||a.isNumber(rr)?null:pr.compare(rr,l)}}var gr=void 0;for(M=I;M<=T;M++)rr=U(M),gr||(ur(),0===ar?tr.push(w()):ar<0?tr.push(w()):ar>0&&tr.length&&(gr=!0));J=tr.length?tr[tr.length-1]:p[r.CommonErrors.NA]}return this.grid=D,s&&"string"==typeof J&&-1!==J.indexOf(this.getParseArgumentSeparator())?this.tic+J+this.tic:J},n.prototype.findClosestMatch=function(r,t){for(var e=0,n=t.length-1;e<=n;){var i=Math.floor((e+n)/2),o=t[i],s=this.compareStrings(r.toLowerCase(),o.toLowerCase());if(0===s)return i;1===s?e=i+1:n=i-1}for(var a=e-1;a>=0;a--)if(-1!==this.compareStrings(r.toLowerCase(),t[a].toLowerCase()))return a;return-1},n.prototype.compareStrings=function(r,t){for(var e=Math.min(r.length,t.length),n=0;n<e;n++){var i=r.charCodeAt(n),o=t.charCodeAt(n);if(i<o)return-1;if(i>o)return 1}return r.length<t.length?-1:r.length>t.length?1:0},n.prototype.findWildCardValue=function(r,t){var e="";if(r.indexOf("?")>-1){var n=RegExp(r.replace(/\?/g,"[\\s\\S]"));e=t.length===r.length&&this.isNaN(this.parseFloat(t))&&t.match(n)?r:t}else if(r.indexOf("*")>-1){for(var i=r.indexOf("*"),o="",s="",a=this.falseValue,u=this.falseValue,l=i-1;l>=0;l--)o+=r[l],u=this.trueValue;for(l=i+1;l<r.length;l++)s+=r[l],a=this.trueValue;var h=""===o?-1:t.indexOf(o.split("").reverse().join("")),p=""===s?-1:t.indexOf(s);if(h>-1||p>-1){var g=o.split("").reverse().join("")===t.substr(0,o.length),f=s===t.substring(t.length-s.length,t.length);u===this.trueValue&&a===this.trueValue&&this.isNaN(this.parseFloat(o))&&this.isNaN(this.parseFloat(s))?e=g&&f?r:t:u===this.trueValue&&this.isNaN(this.parseFloat(o))?e=g?r:t:a===this.trueValue&&this.isNaN(this.parseFloat(s))&&(e=f?r:t)}else{if(r.startsWith("*")&&r.endsWith("*")){var m=r.slice(1,-1);""!==m&&t.includes(m)&&this.isNaN(this.parseFloat(m))&&(t=r)}e=t}}return e},n.prototype.getComputeSumIfValue=function(r,t,e,n,i,o,s){var a=0,u=0;switch(i){case this.parser.tokenEqual:for(var l=o?e.replace(/\*/g,""):e,h=0;h<r.length;h++){var p=this.getValueFromRange(t,h),g=this.getValueFromArg(r[h].split(this.tic).join("")).toLowerCase(),f=this.parseFloat(g);if(g===e&&f===n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}else if(g===e)this.isNaN(p)||(a+=p,u+=1);else if(o&&l&&g&&this.isNaN(this.parseFloat(g))){d=e.indexOf("*");"*"===e[0]&&l.length<=g.length&&l===g.slice(g.length-l.length,g.length)?this.isNaN(p)||(a+=p,u+=1):"*"===e[e.length-1]&&l.length<=g.length&&l===g.slice(0,l.length)?this.isNaN(p)||(a+=p,u+=1):d>-1&&g.startsWith(e.substr(0,d))&&g.endsWith(e.substr(d+1))&&(this.isNaN(p)||(a+=p,u+=1))}else if(o&&!l&&g&&this.isNaN(this.parseFloat(g)))this.isNaN(p)||(a+=p,u+=1);else if(s&&l&&g&&this.isNaN(this.parseFloat(g))){v=RegExp(l.replace(/\?/g,"[\\s\\S]"));g.length===e.length&&g.match(v)&&(this.isNaN(p)||(a+=p,u+=1))}}break;case this.parser.tokenLess:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))<n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenGreater:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))>n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenLessEq:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))<=n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenGreaterEq:for(h=0;h<r.length;h++){g=this.getValueFromArg(r[h].split(this.tic).join(""));if((f=this.parseFloat(g))>=n){var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}break;case this.parser.tokenNotEqual:for(var l=o?e.replace(/\*/g,""):e,h=0;h<r.length;h++){var p=this.getValueFromRange(t,h),g=this.getValueFromArg(r[h].split(this.tic).join("")).toLowerCase(),f=this.parseFloat(g);if(g===e||f===n||o||s)if(o&&l&&g&&this.isNaN(this.parseFloat(g))){var d=e.indexOf("*");"*"===e[0]&&l.length<=g.length&&l!==g.slice(g.length-l.length,g.length)?this.isNaN(p)||(a+=p,u+=1):"*"===e[e.length-1]&&l.length<=g.length&&l!==g.slice(0,l.length)?this.isNaN(p)||(a+=p,u+=1):(d>-1&&!g.startsWith(e.substr(0,d))||!g.endsWith(e.substr(d+1)))&&(this.isNaN(p)||(a+=p,u+=1))}else if(!o||l||this.isNaN(this.parseFloat(g))){if(s&&l&&g&&this.isNaN(this.parseFloat(g))){var v=RegExp(l.replace(/\?/g,"[\\s\\S]"));g.length===e.length&&g.match(v)||this.isNaN(p)||(a+=p,u+=1)}}else this.isNaN(p)||(a+=p,u+=1);else{var m=this.getValueFromArg(t[h].split(this.tic).join("")),c=this.parseFloat(m);this.isNaN(c)||(a+=c,u+=1)}}}return[a,u]},n.prototype.getValueFromRange=function(r,t){var e=r[t];return e=this.getValueFromArg(e),this.parseFloat(e.toString())},n.prototype.computeAndOrNot=function(t,e){for(var n,i,o=this,s="and"===e,a="or"===e,u="not"===e,l=!(!s&&!u),h=[],p=t,g=0;g<p.length;g++){if(p[g]===this.tic)return this.getErrorStrings()[r.CommonErrors.Value];if(p[g]=p[g].startsWith("n")?p[g].slice(1):p[g],this.isCellReference(p[g]))for(var f=this.getCellCollection(p[g]),m=0;m<f.length;m++){if(this.getErrorStrings().indexOf(f[m])>-1)return f[m];if(f[m][0]===this.tic)return this.getErrorStrings()[r.CommonErrors.Name];if(n=this.getValueFromArg(f[m]),this.getErrorStrings().indexOf(n)>-1)return n;i=this.parseFloat(n),n===this.falseValue||""!==n&&0===i||u&&""===n?h.push(this.falseValue):n===this.trueValue||!isNaN(i)&&""!==n?h.push(this.trueValue):(""===n||isNaN(i))&&h.push(this.getErrorStrings()[r.CommonErrors.Value])}else{if(n=this.getValueFromArg(p[g]).toUpperCase(),this.getErrorStrings().indexOf(n)>-1)return n;i=this.parseFloat(n),(n=n.split(this.tic).join(""))===this.falseValue||""===p[g]||""!==n&&0===i?h.push(this.falseValue):n===this.trueValue||!isNaN(i)&&""!==n?h.push(this.trueValue):(""===n||isNaN(i))&&h.push(this.getErrorStrings()[r.CommonErrors.Value])}}if(h.every(function(t){return t===o.getErrorStrings()[r.CommonErrors.Value]}))return this.getErrorStrings()[r.CommonErrors.Value];for(m=0;m<h.length;m++){if((s||u)&&h[m]===this.falseValue){l=!1;break}if(a&&h[m]===this.trueValue){l=!0;break}}return l=u?!l:l,l?this.trueValue:this.falseValue},n.prototype.removeTics=function(r){return r.length>1&&r[0]===this.tic[0]&&r[r.length-1]===this.tic[0]&&(r=this.substring(r,1,r.length-2)),r},n.prototype.getCellFrom=function(r){var t,e="",n=r.indexOf(":")>-1?r.split(":"):[r],i=n.length-1,o=this.rowIndex(n[0]);if(o===this.rowIndex(n[i])){var s=this.colIndex(n[0]),a=this.colIndex(n[i]),u=this.colIndex(this.cell);u>=s&&u<=a&&(e=K(u).toString()+o.toString())}else if(this.colIndex(n[0])===this.colIndex(n[i])){t=this.colIndex(n[0]);var l=this.rowIndex(n[i]),h=this.rowIndex(this.cell);h>=o&&h<=l&&(e=K(t).toString()+h.toString())}return e},n.prototype.computeValue=function(e,n,i){try{var o=[],s=0,a="";o.length=0;for(var u=[],l=this.getParseDecimalSeparator();s<e.length;){var h="u"===e[s];if(h&&(s+=1),e[s]!==this.arithMarker){if(this.isDigit(e[s])){for(p="";s<e.length&&(this.isDigit(e[s])||e[s]===l);)p+=e[s]===l?".":e[s],s+=1;if(o.push(p),!e[s])return o.toString()}if(e[s]===this.sheetToken){for(a=e[s],s+=1;s<e.length&&e[s]!==this.sheetToken;)a+=e[s],s+=1;s<e.length&&(a+=e[s],s+=1)}else if(this.isUpperChar(e[s])){for(var p="",g="";s<e.length&&this.isUpperChar(e[s]);)p+=e[s],s+=1;for(;s<e.length&&this.isDigit(e[s]);)p+=e[s],s+=1;if(s<e.length&&":"===e[s]){if(p+=e[s],(s+=1)<e.length&&e[s]===this.sheetToken)for(p+=e[s],s+=1;s<e.length&&e[s]!==this.sheetToken;)p+=e[s],s+=1;for(;s<e.length&&this.isUpperChar(e[s]);)p+=e[s],s+=1;for(;s<e.length&&this.isDigit(e[s]);)p+=e[s],s+=1;p=a+this.getCellFrom(p)}else p=a+p;var f=this.getParentObjectCellValue(p,n);if(g=t.isNullOrUndefined(f)?"":f.toString(),a="","string"==typeof g&&this.getErrorStrings().indexOf(g)>-1)return g;h&&(g=this.isNaN(this.parseFloat(g))?"-"+g:(-this.parseFloat(g)).toString()),o.push(g),""===g&&(u[o.length-1]="0")}else if("q"===e[s]){var m=e.substring(s+1).indexOf(this.leftBracket),c=e.substring(s+m+1).indexOf(this.rightBracket);e=this.substring(e,s+m+2,c-1)}else if(e[s]===this.tic[0]){for(var p=e[s].toString(),d="n"===e[(s+=1)-2]&&e[s]===this.tic[0];s<e.length&&e[s]!==this.tic[0];)p+=e[s],s+=1;(g=p.split(this.tic).join(""))===this.trueValue||g===this.falseValue||!this.isNaN(this.parseFloat(g))&&""!==g?o.push(this.tic+g+this.tic):(o.push(g),""===g&&d&&(u[o.length-1]="0")),s+=1}else if("%"===e[s]&&o.length>0){var v=o[0],N=this.parseFloat(v);this.isNaN(N)||(o.pop(),o.push((N/100).toString())),s+=1}else if(0===e.substring(s).indexOf(this.trueValue))o.push(this.trueValue),s+=this.trueValue.length;else if(0===e.substring(s).indexOf(this.falseValue))o.push(this.falseValue),s+=this.falseValue.length;else if(e[s]===this.tic[0]||"|"===e[s]){p=e[s].toString();for(s++;s<e.length&&e[s]!==this.tic[0];)p+=e[s],s+=1;o.push(p+this.tic),s+=1}else{if(" "===e[s]&&s<e.length-1){s+=1;continue}switch(e[s]){case"#":var E=0;this.getErrorStrings().indexOf(e.substring(s))>-1?(E=-1===e.indexOf("!")||-1===e.substring(s).indexOf("!")?e.indexOf("#N/A")>-1?e.indexOf("#N/A")+4+s:e.indexOf("?")+1+s:e.indexOf("!")+1+s,o.push(this.substring(e,s,E-s))):(E=s+1,o.push(this.substring(e,s,E-s))),s=E;break;case"n":p="";if("n"===e[s+=1])continue;if(0===e.substring(s).indexOf("Infinity"))s+=(p="Infinity").length;else{for(("u"===e[s]||h||"-"===e[s])&&(p="-",h?h=!1:s+=1);s<e.length&&(this.isDigit(e[s])||e[s]===l||"."===e[s]);)p+=e[s]===l?".":e[s],s+=1;if(s<e.length&&"%"===e[s])if(s+=1,""===p){if(o.length>0){var v=o[0],N=this.parseFloat(v);this.isNaN(N)||(o.pop(),o.push((N/100).toString()))}}else p=(this.parseFloat(p)/100).toString()}p&&o.push(p);break;case this.parser.tokenAdd:this.getValArithmetic(o,"add",i),s+=1;break;case this.parser.tokenSubtract:this.getValArithmetic(o,"sub",i),s+=1;break;case this.parser.tokenMultiply:this.getValArithmetic(o,"mul",i),s+=1;break;case this.parser.tokenDivide:this.getValArithmetic(o,"div",i),s+=1;break;case this.parser.tokenLess:this.processLogical(o,"less"),s+=1;break;case this.parser.tokenGreater:this.processLogical(o,"greater"),s+=1;break;case this.parser.tokenGreaterEq:this.processLogical(o,"greaterEq"),s+=1;break;case this.parser.tokenLessEq:this.processLogical(o,"lessEq"),s+=1;break;case this.parser.tokenNotEqual:this.processLogical(o,"notEq",u),u.length=0,s+=1;break;case this.parser.tokenOr:this.processLogical(o,"or"),s+=1;break;case this.parser.tokenAnd:this.processLogical(o,"and"),s+=1;break;case this.parser.tokenEqual:this.processLogical(o,"equal",u),u.length=0,s+=1;break;default:return this.getErrorStrings()[r.CommonErrors.Value]}}}else s+=1}if(0===o.length)return"";for(var p="",S=o.length;S>0;){var y=o.pop();if(this.getErrorStrings().indexOf(y)>-1)return y;if(""===(p=y+p)&&this.isCellReference(e)&&this.getTreatEmptyStringAsZero())return"0";S--}return p}catch(t){if(this.getErrorStrings().indexOf(t)>-1||this.formulaErrorStrings.indexOf(t)>-1)throw t;throw new oe(this.formulaErrorStrings[r.FormulasErrorsStrings.InvalidExpression])}},n.prototype.getValArithmetic=function(t,e,n){var i=!1,o=t.pop(),s=-1!==o.indexOf(".")?o.split(".")[1].length:0,a=Math.pow(10,s),u=t.pop(),l=-1!==u.indexOf(".")?u.split(".")[1].length:0,h=Math.pow(10,l),p=a>=h?a:h,g=a*h;o=""===(o=o===this.trueValue?"1":o===this.falseValue?"0":o)?"0":this.getErrorStrings().indexOf(o.toString())<0?this.parseFloat(o+"").toString():o;var f=Number(o);isNaN(f)&&!n&&(i=!0,o===this.getErrorStrings()[r.CommonErrors.DivZero]?t.push(this.getErrorStrings()[r.CommonErrors.DivZero]):t.push(this.getErrorStrings()[r.CommonErrors.Value])),u=""===(u=u===this.trueValue?"1":u===this.falseValue?"0":u)?"0":this.getErrorStrings().indexOf(u.toString())<0?this.parseFloat(u+"").toString():u,f=Number(u),isNaN(f)&&!n&&(i=!0,u===this.getErrorStrings()[r.CommonErrors.DivZero]?t.push(this.getErrorStrings()[r.CommonErrors.DivZero]):t.push(this.getErrorStrings()[r.CommonErrors.Value])),"add"!==e||i||t.push(((Number(u)*p+Number(o)*p)/p).toString()),"sub"!==e||i||t.push(((Number(u)*p-Number(o)*p)/p).toString()),"mul"!==e||i||t.push((Number(u)*h*(Number(o)*a)/g).toString()),"div"!==e||i||(this.isNaN(this.parseFloat(o))||this.isNaN(this.parseFloat(u))?t.push(this.getErrorStrings()[r.CommonErrors.Value]):0===this.parseFloat(o)?t.push(this.getErrorStrings()[r.CommonErrors.DivZero]):t.push((Number(u)*g/(Number(o)*g)).toString()))},n.prototype.processLogical=function(e,n,i){var o,s,a,u,l,h,p=!1;if("and"!==n&&"equal"!==n&&"notEq"!==n&&(o=e.pop(),s=e.pop(),this.getErrorStrings().indexOf(o)>-1?(h=o,p=!0):this.getErrorStrings().indexOf(s)>-1&&(h=s,p=!0),this.isNaN(this.parseFloat(o))&&this.isNaN(this.parseFloat(s))&&(o=o.toString().toLowerCase(),s=s.toString().toLowerCase()),t.isNullOrUndefined(o)||(a=o.indexOf(this.tic)>-1?o:this.parseFloat(o)),t.isNullOrUndefined(s)||(u=s.indexOf(this.tic)>-1?s:this.parseFloat(s)),"*"===o&&this.isNaN(this.parseFloat(s))&&""!==s&&(l=!0)),"less"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))<0?this.trueValue:this.falseValue:u<a?this.trueValue:this.falseValue),"greater"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))>0?this.trueValue:this.falseValue:u>a?this.trueValue:this.falseValue),"lessEq"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))<=0?this.trueValue:this.falseValue:u<=a?this.trueValue:this.falseValue),"greaterEq"!==n||p||(h=this.isNaN(a)||this.isNaN(u)?s.toUpperCase().split(this.tic).join("").localeCompare(o.toUpperCase().split(this.tic).join(""))>=0?this.trueValue:this.falseValue:u>=a?this.trueValue:this.falseValue),"and"!==n||p||(o=e.pop().toString(),s="",e.length>0&&(s=e.pop().toString()),h=this.getErrorStrings().indexOf(o)>-1?o:this.getErrorStrings().indexOf(s)>-1?s:(h=""+s+o).split(this.tic).join("")),("equal"===n||"notEq"===n)&&!p){var g=void 0,f=void 0;i?(g=i[e.length-1],o=e.pop(),f=i[e.length-1],s=e.pop()):(o=e.pop(),s=e.pop()),this.getErrorStrings().indexOf(o)>-1?h=o:this.getErrorStrings().indexOf(s)>-1?h=s:(o="TRUE"===o?"1":"FALSE"===o?"0":o,s="TRUE"===s?"1":"FALSE"===s?"0":s,this.isNaN(this.parseFloat(o))&&this.isNaN(this.parseFloat(s))&&(o=o.toString().toLowerCase(),s=s.toString().toLowerCase()),"*"===o&&this.isNaN(this.parseFloat(s))&&""!==s&&(l=!0),h="equal"===n?o===s||void 0!==g&&g===s||void 0!==f&&f===o||l?this.trueValue:this.falseValue:l?this.falseValue:s===o||g&&g===s||f&&f===o?this.falseValue:this.trueValue)}return"or"!==n||p||(h=Math.pow(this.parseFloat(u),this.parseFloat(a)).toString(),h=this.isNaN(this.parseFloat(h))?this.getErrorStrings()[r.CommonErrors.Value]:h),e.push(h),h},n.prototype.computeStoreCells=function(r){for(var t,e=r.cellValue,n=r.cellRange,i=r.criteria,o=r.argArray,s=r.isCriteria,a=r.storedCells,u=r.isCountIfS===this.trueValue,l=r.countVal||0,h=s===this.trueValue?a:e,p=[],g=0;g<h.length;g++){var f=[],m=this.getValueFromArg(e[g]),c=o[u?1+2*l:2+l],d=c.startsWith(this.tic)&&c.endsWith(this.tic),v=(t=this.getANDComputedValue(c.trim())).includes("*"),N="*"===t||"<>*"===t,E=v&&!N?t.replace(/\*/g,"").trim():t,S=!1;if(!d&&this.isCellReference(E)&&(E=this.getValueFromArg(E),S=!0),v&&!N){var y=t.indexOf("*");"*"===t[0]&&(E="*"+E),"*"===t[t.length-1]&&(E+="*"),y>0&&y<t.length-1&&(E=t.substring(0,y)+"*"+t.substring(y+1))}t=E;var C="";if((s=u?this.trueValue:s)===this.trueValue){var b="",A=0,O=0,F=void 0,x=void 0,V=void 0,R=void 0;a[g]=u&&!l?e[g]:a[g],b=a[g],l&&(x=Y((F=n[l-1]).indexOf("!")>-1?F.substring(F.lastIndexOf("!")+1):F),V=q(b.indexOf("!")>-1?b.substring(b.lastIndexOf("!")+1):b),R=Y(n[l].indexOf("!")>-1?n[l].substring(n[l].lastIndexOf("!")+1):n[l]));var I=b.indexOf("!")>-1,T=void 0,M="",D="";for(I&&(D=b.substring(0,b.lastIndexOf("!")+1),b=b.substring(b.lastIndexOf("!")+1));!this.isDigit(b[A]);)A+=1;if(this.isCellReference(n[l])&&n[l].indexOf(":")>-1)for(C=u&&!l?h[g].indexOf("!")>-1?h[g].substring(h[g].lastIndexOf("!")+1):h[g]:B(R[0]+(V[0]-x[0]),R[1]+(V[1]-x[1])),(T=n[l].indexOf("!")>-1)&&(M=n[l].substring(0,n[l].lastIndexOf("!")+1));!this.isDigit(C[O]);)O+=1;var U=this.substring(b,A),w=this.substring(C,O),j=this.substring(b,A,b.length-A),L=this.substring(C,O,C.length-A);I&&(U=D+U,w=D+w),j!==L&&(a[g]=this.substring(a[g],I?D.length+A:A)+L),C=a[g].split(U).join(w),T?(C.indexOf("!")>-1&&(C=C.substring(C.lastIndexOf("!")+1)),C=M+C):C=C.substring(C.lastIndexOf("!")+1),m=this.getValueFromArg(C),t=u?t:this.getANDComputedValue(i[l-1])}var k="equal",P=this.getOperatorAndCriteria(t,k);k=P.op,t=P.criteria,(!d&&this.isCellReference(t)&&(!S||""!==C&&!u)||t.includes(this.arithMarker))&&(t=this.getValueFromArg(t)),(t.indexOf("*")>-1||t.indexOf("?")>-1)&&(m=this.findWildCardValue(t.toLowerCase(),m.toLowerCase())),f.push(m.toLowerCase()),f.push(t.toLowerCase()),this.processLogical(f,k)===this.trueValue&&(s===this.falseValue?p.push(e[g]):p.push(C))}return a=p,p=[],a},n.prototype.computeIfsFormulas=function(e,n,i){if(n===this.trueValue&&(t.isNullOrUndefined(e)||""===e[0]||e.length<2||e.length>127||e.length%2!=0))return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var o=e,s=[],a=[],u=[],l=0,h=0;h<o.length;h++)0!==h&&h%2!=1||!this.isCellReference(o[h])?a.push(o[h].trim()):s.push(o[h].indexOf(":")>-1?o[h].trim():X(Y(o[h])));for(var p=[],h=0;h<s.length;h++)p.push(this.getCellCollection(s[h]).length);for(S=0;S<p.length;S++)if(p[S]&&p[S+1]&&p[S]!==p[S+1])return this.getErrorStrings()[r.CommonErrors.Value];for(var g=0;g<a.length;g++)if(""===a[g]||this.isCellReference(a[g])&&""===this.getValueFromArg(a[g]))return i===this.trueValue?this.getErrorStrings()[r.CommonErrors.DivZero]:0;var f,m;if(n===this.falseValue){m=this.falseValue;c={cellValue:f=this.getCellCollection(s[1]),cellRange:s,criteria:a,argArray:o,isCriteria:m,storedCells:u,isCountIfS:n};if(u=this.computeStoreCells(c),0===u.length)return i===this.trueValue?this.getErrorStrings()[r.CommonErrors.DivZero]:0}for(h=n===this.trueValue?0:2;h<s.length;h++){m=this.trueValue,m=n===this.trueValue&&0===h?this.falseValue:this.trueValue;var c={cellValue:f=this.getCellCollection(s[h]),cellRange:s,criteria:a,argArray:o,isCriteria:m,storedCells:u,isCountIfS:n,countVal:h};if(u=this.computeStoreCells(c),0===u.length)return i===this.trueValue?this.getErrorStrings()[r.CommonErrors.DivZero]:0}for(var d=0,v=Y(s[0].indexOf("!")>-1?s[0].substring(s[0].lastIndexOf("!")+1):s[0]),N=s[s.length-1],E=Y(N.indexOf("!")>-1?N.substring(N.lastIndexOf("!")+1):N),S=0;S<u.length;S++){var y="",C="",b=0,A=0,O=(y=u[S]).indexOf("!")>-1,F=void 0,x="",V="";for(O&&(V=y.substring(0,y.lastIndexOf("!")+1),y=y.substring(y.lastIndexOf("!")+1));!this.isDigit(y[b]);)b+=1;if(this.isCellReference(s[0])&&s[0].indexOf(":")>-1)for(C=B(v[0]+(q(y)[0]-E[0]),v[1]+(q(y)[1]-E[1])),(F=s[0].indexOf("!")>-1)&&(x=s[0].substring(0,s[0].lastIndexOf("!")+1));!this.isDigit(C[A]);)A+=1;var R=this.substring(y,b),I=this.substring(C,A),T=this.substring(y,b,y.length-b),M=this.substring(C,A,C.length-b);if(O&&(R=V+R,I=V+I),T!==M&&(u[S]=this.substring(u[S],O?V.length+b:b)+M),f=u[S].split(R).join(I),F?(f.indexOf("!")>-1&&(f=f.substring(f.lastIndexOf("!")+1)),f=x+f):f=f.substring(f.lastIndexOf("!")+1),n===this.trueValue)l+=1;else{var D=this.getValueFromArg(f),U=parseFloat(""===D&&i!==this.trueValue?"0":D);this.isNumber(U)&&(d++,l+=U)}}return i===this.trueValue&&(l/=d),l},n.prototype.computeCountIfsFormulas=function(e){var n=this.grid;if(t.isNullOrUndefined(e)||""===e[0]||e.length<2||e.length>127||e.length%2!=0)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];for(var i=e,o=[],s=[],a=0;a<i.length;a++)a%2==0&&this.isCellReference(i[a])?o.push(i[a].indexOf(":")>-1?i[a].trim():X(Y(i[a]))):s.push(i[a].trim());if(o.length!==s.length)return this.getErrorStrings()[r.CommonErrors.Value];for(var u=[],l=this.grid,a=0;a<o.length;a++){var h=Y(o[a]),p=h[0],g=h[1],f=h[2],m=h[3],c="",d=this.getSheetFamilyItem(l);o[a].startsWith("!")?(c=o[a].substring(0,o[a].replace("!","").indexOf("!")+2),null!==d.tokenToParentObject&&(l=d.tokenToParentObject.get(c))):null!==d.parentObjectToToken&&(c=d.parentObjectToToken.get(l)),this.grid=l;var v=this.getSheetId(l);if(-1===Z("Sheet"+v,this.getHostSheetInfo()))return this.grid=n,this.getErrorStrings()[r.CommonErrors.Ref];U=this.getCellValueFn(l,this.cell,v,!0);if(u.length>0){var N=u[u.length-1],E=N.endRow-N.startRow+1,S=N.endCol-N.startCol+1;if(f-p+1!==E||m-g+1!==S)return this.getErrorStrings()[r.CommonErrors.Value]}u.push({startRow:p,startCol:g,endRow:f,endCol:m,getCellValue:U,grid:l})}for(var y=0;y<s.length;y++)if(""===s[y])return this.grid=n,0;for(var C=[],a=0;a<u.length;a++){this.grid=n;var b=s[a],A=b.startsWith(this.tic)&&b.endsWith(this.tic),O=(b=this.getANDComputedValue(b.trim())).includes("*"),F="*"===b||"<>*"===b,x=O&&!F?b.replace(/\*/g,"").trim():b,V=!1;if(!A&&this.isCellReference(x)&&(x=this.getValueFromArg(x),V=!0),O&&!F){var R=b.indexOf("*");"*"===b[0]&&(x="*"+x),"*"===b[b.length-1]&&(x+="*"),R>0&&R<b.length-1&&(x=b.substring(0,R)+"*"+b.substring(R+1))}b=x;var I="equal",T=this.getOperatorAndCriteria(b,I);I=T.op,b=T.criteria,(!A&&this.isCellReference(b)&&!V||b.includes(this.arithMarker))&&(b=this.getValueFromArg(b));var M=b.indexOf("*")>-1||b.indexOf("?")>-1,D=u[a],p=D.startRow,g=D.startCol,f=D.endRow,m=D.endCol,U=D.getCellValue,w=u[a].grid;this.grid=w;var j=void 0;if(0===a)for(var L=p;L<=f;L++)for(var k=g;k<=m;k++)j=U(L+1,k+1,B(L,k)),M&&(j=this.findWildCardValue(b.toLowerCase(),j.toLowerCase())),this.processLogical([j.toLowerCase(),b.toLowerCase()],I)===this.trueValue&&C.push({rowIdx:L,colIdx:k});else{var P=C,_=u[a-1];C=[];for(var W=0;W<P.length;W++){var q=P[W];q.rowIdx=p+(q.rowIdx-_.startRow),q.colIdx=g+(q.colIdx-_.startCol),j=U(q.rowIdx+1,q.colIdx+1,B(q.rowIdx,q.colIdx)),M&&(j=this.findWildCardValue(b.toLowerCase(),j.toLowerCase())),this.processLogical([j.toLowerCase(),b.toLowerCase()],I)===this.trueValue&&C.push({rowIdx:q.rowIdx,colIdx:q.colIdx})}}if(0===C.length)return this.grid=n,0}return this.grid=n,C.length},n.prototype.getOperatorAndCriteria=function(r,t){var e=r;return e.startsWith("<=")?(t="lessEq",e=e.substring(2)):e.startsWith(">=")?(t="greaterEq",e=e.substring(2)):e.startsWith("<>")?(t="notEq",e=e.substring(2)):e.startsWith("<")?(t="less",e=e.substring(1)):e.startsWith(">")?(t="greater",e=e.substring(1)):e.startsWith("=")&&(t="equal",e=e.substring(1)),{op:t,criteria:e}},n.prototype.processNestedFormula=function(r,t,e){return!e.toString().includes('"')&&'"'===r[r.lastIndexOf(t)+t.length]&&this.getErrorStrings().indexOf(e.toString())<0&&!this.isNumber(e)&&e!==this.trueValue&&e!==this.falseValue?r.split(t).join('"'+e+'"'):r.split(t).join("n"+e)},n.prototype.isNaN=function(r){return"NaN"===r.toString()||"string"==typeof r},n.prototype.isNumber=function(r){return r-parseFloat(r)>=0},n.prototype.fromOADate=function(r){(r=r>0&&r<1?1+r:0===r?1:r)>60&&(r-=1);var t=new Date("01/01/1900"),e=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());return new Date(new Date((r-1)*this.millisecondsOfaDay+e).toUTCString().replace(" GMT",""))},n.prototype.getSerialDateFromDate=function(r,t,e){var n=0;r<1900&&(r+=1900);for(var i=!1;!i;){for(;t>12;)r++,t-=12;for(;t<1;)t+=12,r--;i=!0;for(var o=new Date(r,t,1,-1).getDate();e>o;)o=new Date(r,t,1,-1).getDate(),t++,e-=o,i=!1;e<1&&(--t<1&&(t=12,r--),e=(o=new Date(r,t,1,-1).getDate())+e,i=!1)}var s=Date.parse(r+"/"+t+"/"+e);return this.isNaN(s)||(n=this.toOADate(new Date(s))),n},n.prototype.intToTime=function(r){var e=r.toString().split(".");return t.isNullOrUndefined(e[1])||(r=parseFloat(e[0]+1+"."+e[1])||r),this.intToDate(r.toString())},n.prototype.toOADate=function(r,t,e){var n=new Date("01/01/1900"),i=o(r)?r:new Date(r),s=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),a=(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())-s)/864e5;return(t?a:parseInt(a.toString(),10))+(e?0:a>60?2:1)},n.prototype.calculateDate=function(r){return this.parseFloat(r)<10?"0"+r:r},n.prototype.isTextEmpty=function(r){return null===r||""===r},n.prototype.isDigit=function(r){var t=r.charCodeAt(0);return t>47&&t<58},n.prototype.getANDComputedValue=function(r){return r.startsWith(this.arithMarker)&&r.includes("c")&&(r=this.getValueFromArg(r)),r.split(this.tic).join("")},n.prototype.findLastIndexOfq=function(r){for(var t=r.lastIndexOf("q"),e=r.lastIndexOf(this.leftBracket);e<t;)t=r.substring(0,t).lastIndexOf("q");return t},n.prototype.getValueFromArg=function(e,n,i,o,s){if(!(e=e.trim())||this.getErrorStrings().indexOf(e)>-1)return e;var a=e[0];if(a===this.tic||a===this.singleTic){h=e.split(this.tic).join("");if(this.isNaN(this.parseFloat(h))&&(!s||a!==this.tic||!e.endsWith(this.tic))){var u=this.isDate(h);if(u&&!this.isNaN(u.getDate()))return this.toOADate(u,!0).toString()}return e.endsWith(this.tic)&&"."!==(l=this.getParseDecimalSeparator())&&h.includes(l)&&(h=h.replace(l,"."),this.isNumber(h)&&(e=h)),e}if("u"===a&&e.includes(this.arithMarker))e=this.parser.parseSimpleOperators(e.split("u").join("0-"),[this.parser.tokenSubtract],["-"]);else if(!this.isUpperChar(a)){var l=this.getParseDecimalSeparator();if(this.isDigit(a)||a===l||"-"===a||"n"===a){if("n"===a&&(e=e.substring(1)).indexOf('"n')>-1&&(e=e.replace('"n','"')),"."!==l&&e.includes(l)){var h=e.replace(l,".");this.isNumber(h)&&(e=h)}return e}}var p=a===this.sheetToken;if(p||this.isUpperChar(a)&&!["+","-","/","*",")",")","{"].some(function(r){return e.includes(r)})){var g=this.isCellReference(e);if(g&&!p){var f=this.getSheetFamilyItem(this.grid);null!==f.sheetNameToParentObject&&f.parentObjectToToken.has(this.grid)&&(e=f.parentObjectToToken.get(this.grid)+e)}if(e===this.cell){var m=this.getDependentCells().get(e);if(null!=m&&m.indexOf(e)>-1&&this.arrayRemove(m,e),this.getDependentFormulaCells().has(this.cell)||this.clearFormulaDependentCells(this.cell),!n)throw new oe(this.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference])}var c=this.getParentObjectCellValue(e,!1,n,o),d=t.isNullOrUndefined(c)?"":c.toString();return g&&this.updateDependentCell(e),d}return this.computeValue(e,!1,i)},n.prototype.isDate=function(r){if("object"==typeof r||null!==Date.parse(r)){var t=void 0;return t="string"==typeof r?this.checkDateFormat(r,!1,!0):new Date(Date.parse(r)),t>=this.dateTime1900?t:null}return null},n.prototype.parseDate=function(t){if(!this.isNaN(t)){if(t instanceof Date)return new Date(t);var e=parseInt(t,10);return e<0?this.getErrorStrings()[r.CommonErrors.Num]:e<=60?new Date(this.dateTime1900.getTime()+864e5*(e-1)):new Date(this.dateTime1900.getTime()+864e5*(e-2))}return"string"!=typeof t||(t=this.checkDateFormat(t,!0),this.isNaN(t))?this.getErrorStrings()[r.CommonErrors.Value]:t},n.prototype.checkDateFormat=function(r,t,e){var n=this.parentObject;if(n&&"function"==typeof n.getModuleName&&"spreadsheet"===n.getModuleName()){var i=this.hostParseDate(r);if(i.isDate)return i.dateObj;if(e&&!i.isTime)return new Date(NaN)}return this.getErrorStrings().indexOf(r)>-1?new Date(NaN):t?new Date(r):new Date(Date.parse(r))},n.prototype.isCellReference=function(r){if(""===(r=r.trim()))return!1;r=this.setTokensForSheets(r);var t=this.getSheetToken(r),e=!1;""!==t&&(r=r.split(t).join(""));var n=!1,i=!1;if(r.indexOf(":")!==r.lastIndexOf(":"))return!1;for(var o=r.split("").join(this.getParseArgumentSeparator()).split(this.getParseArgumentSeparator()),s=0;s<o.length;s++)if(this.isChar(o[s]))n=!0;else if(this.isDigit(o[s]))i=!0;else{if(":"!==o[s])return!1;n&&i&&(e=!0),n=!1,i=!1}return r.indexOf(":")>-1&&-1===r.indexOf(this.tic)?!!(e&&n&&i||(n&&!i||!n&&i)&&!e):!!(n&&i&&-1===r.indexOf(this.tic)&&this.isValidCell(r))},n.prototype.setTokensForSheets=function(r){var t=this.getSheetFamilyItem(this.grid),e=this.getSortedSheetNames();if(null!=e)for(var n=0;n<e.length;n++){var i=t.sheetNameToToken.get(e[n]);i=i.split(this.sheetToken).join(this.tempSheetPlaceHolder);var o=this.singleTic+"SHEET"+e[n]+this.singleTic+this.sheetToken;-1===r.indexOf(o)&&(o="SHEET"+e[n]+this.sheetToken),r=r.split(o).join(i),o=e[n]+this.sheetToken,r=r.split(o).join(i)}if((r=r.split(this.tempSheetPlaceHolder).join(this.sheetToken)).indexOf("!!")>-1){var s=(r=r.replace("!!","!")).split("!");s[1]=(parseInt(s[1],10)+1).toString(),r=s.join("!")}return r},n.prototype.getParentObjectCellValue=function(e,n,i,o){if(e===this.trueValue||e===this.falseValue)return e;var s,a=e.lastIndexOf(this.sheetToken),u=this.grid;if(a>-1){if(null===(h=this.getSheetFamilyItem(u)).tokenToParentObject)return this.getErrorStrings()[r.CommonErrors.Value];this.grid=h.tokenToParentObject.get(e.substring(0,a+1)),s=e.substring(a+1)}else{for(var l=0;l<e.length&&this.isChar(e[l]);)l++;if(l===e.length)return""===e?this.getErrorStrings()[r.CommonErrors.Value]:this.getErrorStrings()[r.CommonErrors.Name];s=e;var h=this.getSheetFamilyItem(u);h.isSheetMember&&null!=h.parentObjectToToken&&(e=h.parentObjectToToken.get(this.grid)+e)}if(this.isDigit(s[0])){var p=s.search(/[a-zA-Z]/);p>0&&(s=s.substring(p,s.length)+s.substring(0,p))}var g,f=this.rowIndex(s),m=this.colIndex(s);if(f>0&&f<=1048576&&m>0&&m<=16384){var c=this.getSheetId(this.grid),d=this.getHostSheetInfo();if(d.length&&-1===Z("Sheet"+c,d))return this.grid=u,this.getErrorStrings()[r.CommonErrors.Ref];g=this.getCellValueFn(u,this.cell,c,!1,n,i,o)(f,m,e)}else g=this.getErrorStrings()[r.CommonErrors.Name];return this.grid=u,t.isNullOrUndefined(g)?"":g},n.prototype.getCellValueFn=function(e,n,i,o,s,a,u){var l=this,h=n;h&&(h=e===this.grid?"":h+","+("string"==typeof e&&Number(e)>-1?e:this.getSheetID(e)));var p=this.parentObject.getValueRowCol.bind(this.parentObject)||this.getValueRowCol.bind(this);return function(e,g,f){if(n===f&&!a)throw l.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference];l.cell=f;var m=p(i,e,g,h,s,a,u);if(t.isNullOrUndefined(m))m="";else{m=m.toString();var c=l.getParseDecimalSeparator();if("."!==c&&m.includes(c)){var d=m.replace(c,".");l.isNumber(d)&&(m=d)}}return l.cell=n,o&&l.updateDependentCell(f),m}},n.prototype.isValidCell=function(r){if(0===r.search(/\d/)){var t=r.search(/[a-zA-Z]/);r=r.substring(t,r.length)+r.substring(0,t)}var e=this.rowIndex(r),n=this.colIndex(r);return e>0&&e<=1048576&&n>0&&n<=16384},n.prototype.getSheetId=function(r){return r&&"string"==typeof r&&Number(r)>-1?Number(r):this.getSheetID(r)+1},n.prototype.getValueRowCol=function(r,e,n){var i=(this.convertAlpha(n)+e.toString()).toUpperCase();if(this.storedData.has(i)){var o=this.getKeyValue(i);return t.isNullOrUndefined(o)?"":o.toString()}var s=this.rowsToKeyMap.get(e);if(t.isNullOrUndefined(s))return"";var a=s.toString(),u=a.toUpperCase();if(this.isCellReference(u)&&u!==i)return"";if(this.evaluatingKeys.has(u))return"";var l=this.getKeyValue(a);if(t.isNullOrUndefined(l))return"";if(""!==(l=l.toString())&&"%"===l[l.length-1]&&l.length>1){var h=this.parseFloat(l.substring(0,l.length-1));this.isNaN(h)&&(l=(Number(h)/100).toString())}return l},n.prototype.defineFunction=function(r,e,n,i){"string"==typeof e&&(e=t.getValue(e,window)),r=r.toUpperCase(),this.libraryFormulas.set(r,{handler:e,isCustom:!0,description:n,category:i})},n.prototype.valueChanged=function(e,n,i,o,s,a,u,l,h,p,g,f){var m=e;this.spreadSheetUsedRange=o,this.grid=e;var c=!0,d=!0,v=this.getSheetFamilyItem(m),N=K(n.getColIndex())+n.getRowIndex().toString();this.actCell=a+"!"+N,null!==v.sheetNameToParentObject&&v.sheetNameToParentObject.size>0&&(N=v.parentObjectToToken.get(m)+N);var E=n.getFormulaValue().toUpperCase();if(E.indexOf("=RAND()")>-1||E.indexOf("=NOW()")>-1||E.indexOf("NOW()")>-1||E.indexOf("RAND()")>-1||E.indexOf("=RANDBETWEEN(")>-1||E.indexOf("RANDBETWEEN(")>-1||this.randomValues.has(N)){var S=this.randCollection.toString();this.randomValues.has(N)?this.randomValues.has(N)&&(E.indexOf("=RAND()")>-1||E.indexOf("=NOW()")>-1||E.indexOf("NOW()")>-1||E.indexOf("RAND()")>-1||E.indexOf("=RANDBETWEEN(")>-1||E.indexOf("RANDBETWEEN(")>-1?this.randomValues.set(N,n.getFormulaValue()):n.getFormulaValue().toUpperCase()!==this.randomValues.get(N.toUpperCase())&&(this.randomValues.delete(N),S=S.split(N+this.parseArgumentSeparator).join("").split(this.parseArgumentSeparator+N).join("").split(N).join(""),this.randCollection=S.split(this.parseArgumentSeparator)),0===this.randomValues.size&&this.randCollection.length&&(this.isRandomVal=!1,this.randomValues.clear(),this.randCollection=[])):(this.randomValues.set(N,n.getFormulaValue()),this.randCollection.push(N),this.isRandomVal=!0)}if(n.getFormulaValue()&&n.getFormulaValue()[0]===this.getFormulaCharacter()){this.cell=N;var y=void 0;if(t.isNullOrUndefined(d)||(d=i),this.getFormulaInfoTable().has(N)){if(y=this.getFormulaInfoTable().get(N),n.getFormulaValue()!==y.getFormulaText()||null==y.getParsedFormula()){y.setFormulaText(n.getFormulaValue()),this.getDependentFormulaCells().has(this.cell)&&this.clearFormulaDependentCells(this.cell);try{y.setParsedFormula(this.parser.parseFormula(n.getFormulaValue()))}catch(r){y.setFormulaValue(r),d=!1}}else this.parser.isError=!1;d&&(this.parser.isFormulaParsed=!0,c=(C=this.calculateFormula(y.getParsedFormula(),s))!==y.getFormulaValue()&&(!this.parentObject.isEdit||C!==this.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference]),y.setFormulaValue(C))}else{(y=new se).setFormulaText(n.getFormulaValue()),this.getDependentFormulaCells().has(N)||this.getDependentFormulaCells().set(N,new Map),this.getFormulaInfoTable().set(N,y);try{y.setParsedFormula(this.parser.parseFormula(n.getFormulaValue()))}catch(r){y.setFormulaValue(r),d=!1}if(d){var C=this.calculateFormula(y.getParsedFormula(),s);c=C!==this.formulaErrorStrings[r.FormulasErrorsStrings.CircularReference],y.setFormulaValue(C)}}d&&(void 0===this.parentObject.setValueRowCol?this.setValueRowCol(this.getSheetID(m)+1,y.getFormulaValue(),n.getRowIndex(),n.getColIndex()):this.parentObject.setValueRowCol(this.getSheetId(m),y.getFormulaValue(),n.getRowIndex(),n.getColIndex(),y.getFormulaText(),u))}else this.getFormulaInfoTable().has(N)&&(this.getFormulaInfoTable().delete(N),this.getDependentFormulaCells().has(N)&&this.clearFormulaDependentCells(N));d&&c&&this.getDependentCells().has(N)&&("Automatic"===this.parentObject.calculationMode||!this.parentObject.isEdit||g)&&this.getDependentCells().get(N).toString()!==N&&this.refreshDependentCells(N,void 0,void 0,l,h,p,g,f)},n.prototype.setValueRowCol=function(r,t,e,n){},n.prototype.getSortedSheetNames=function(){var r=this.getSheetFamilyItem(this.grid);if(null!=r&&null!=r.sheetNameToToken){if(null!=this.sortedSheetNames)return this.sortedSheetNames;var t=[];r.sheetNameToToken.forEach(function(r,e){t.push(e)}),t.sort(function(r,t){return t.length-r.length}),this.sortedSheetNames=t}return this.sortedSheetNames},n.prototype.getErrorLine=function(r){var t=r.stack?r.stack.split("\n")[1].split(":"):null;return t?t[t.length-2]:null},n.prototype.createSheetFamilyID=function(){return this.sheetFamilyID===Number.MAX_SAFE_INTEGER&&(this.sheetFamilyID=Number.MIN_SAFE_INTEGER),this.sheetFamilyID++},n.prototype.computeMinMax=function(e,n){var i,o,s=!1;if(e.length&&"isSubtotal"===e[e.length-1]&&(s=!0,e.pop()),t.isNullOrUndefined(e)||0===e.length)return this.formulaErrorStrings[r.FormulasErrorsStrings.WrongNumberArguments];i="max"===n?this.minValue:this.maxValue;for(var a=0,u=e.length;a<u;a++)""===e[a].split(this.tic).join("").trim()&&(i=0);var l=e;if(l.length>255)return this.getErrorStrings()[r.CommonErrors.Value];for(var h=0;h<l.length;h++)if(l[h].indexOf(":")>-1&&this.isCellReference(l[h])){for(var p=this.getCellCollection(l[h]),g=0;g<p.length;g++)if(o=s?this.getValueFromArg(p[g],null,null,!0):this.getValueFromArg(p[g]),!s||!o.includes("SUBTOTAL(")){m=this.parseFloat(o);""===o||this.isNaN(this.parseFloat(m))||this.getErrorStrings().indexOf(o)>-1||(i="max"===n?Math.max(i,m):Math.min(i,m))}}else{var f=s?this.getValueFromArg(l[h],null,null,!0):this.getValueFromArg(l[h]);if(s&&f.includes("SUBTOTAL("))continue;var m=0,c=this.isCellReference(l[h]),d=""===f&&c,v=this.isNaN(this.parseFloat(f))&&c,N=f===(this.trueValue||this.falseValue)&&c;if(l[h]=l[h].startsWith("n")?l[h].slice(1):l[h],this.getErrorStrings().indexOf(f)>-1)return f;if(f===this.trueValue&&l[h]===this.trueValue)f="1";else if(f===this.falseValue&&l[h]===this.falseValue)f="0";else if(d||v||N)continue;if(f.indexOf('"')>-1&&(f=f.split(this.tic).join("")),this.isNaN(this.parseFloat(f)))return this.getErrorStrings()[r.CommonErrors.Value];m=this.parseFloat(f),i="max"===n?Math.max(i,m):Math.min(i,m)}return i!==this.minValue&&i!==this.maxValue||(i=0),i.toString()},n.prototype.calculateAvg=function(e,n){for(var i,o,s=e,a=[],u=0,l=0,h=0;h<s.length;h++)if(this.isCellReference(s[h]))if(s[h].indexOf(":")>-1){a=this.getCellCollection(s[h]);for(var p=0;p<a.length;p++)if(i=n?this.getValueFromArg(a[p],null,null,!0):this.getValueFromArg(a[p]),!n||!i.includes("SUBTOTAL(")){if(this.getErrorStrings().indexOf(i)>-1)return i;t.isNullOrUndefined(i)||isNaN(this.parseFloat(i))||""===i||(u+=this.parseFloat(i),l+=1)}}else{if(i=n?this.getValueFromArg(s[h],null,null,!0):this.getValueFromArg(s[h]),n&&i.includes("SUBTOTAL("))continue;if(this.getErrorStrings().indexOf(i)>-1)return i;if(t.isNullOrUndefined(i)||isNaN(this.parseFloat(i))||""===i)continue;u+=this.parseFloat(i),l+=1}else{if(s[h].indexOf(this.tic)>-1&&(isNaN(this.parseFloat(s[h].split(this.tic).join("")))||""===s[h].split(this.tic).join("").trim()))return this.getErrorStrings()[r.CommonErrors.Value];if(0!==s[h].length&&e[h]!==this.falseValue||(s[h]="0"),e[h]===this.trueValue&&(s[h]="1"),o=this.getValueFromArg(s[h].split(this.tic).join("")),this.getErrorStrings().indexOf(o)>-1)return o;u+=this.parseFloat(o),l+=1}return 0===l?this.getErrorStrings()[r.CommonErrors.DivZero]:(u/l).toString()},n.prototype.registerGridAsSheet=function(r,e,n){t.isNullOrUndefined(this.modelToSheetID)&&(this.modelToSheetID=new Map),t.isNullOrUndefined(this.modelToSheetID.get(e))&&this.modelToSheetID.set(e,n);var i=this.getSheetFamilyItem(e);i.isSheetMember=!0;var o=r.toUpperCase();if(0===i.parentObjectToToken.size&&(i.parentObjectToToken=new Map),0===i.sheetNameToParentObject.size&&(i.sheetNameToParentObject=new Map),0===i.sheetNameToToken.size&&(i.sheetNameToToken=new Map),0===i.tokenToParentObject.size&&(i.tokenToParentObject=new Map),t.isUndefined(i.sheetNameToParentObject.get(o))){s=this.sheetToken+this.tokenCount.toString()+this.sheetToken;this.tokenCount++,i.tokenToParentObject.set(s,e),i.parentObjectToToken.set(e,s),i.sheetNameToToken.set(o,s),i.sheetNameToParentObject.set(o,e)}else{var s=i.sheetNameToToken.get(o);i.tokenToParentObject.set(s,e),i.parentObjectToToken.set(e,s)}return this.sortedSheetNames=null,r},n.prototype.unregisterGridAsSheet=function(r,e,n){var i=this,o=[e];n&&(o=[],t.isNullOrUndefined(this.modelToSheetID)||this.modelToSheetID.forEach(function(r,t){o.push(t)})),o.forEach(function(t){var e=i.getSheetFamilyItem(t),o=(n?t:r).toUpperCase();if(null!=e.sheetNameToParentObject&&e.sheetNameToParentObject.has(o)){e.sheetNameToParentObject.delete(o);var s=e.sheetNameToToken.get(o);e.sheetNameToToken.delete(o),e.tokenToParentObject.delete(s),e.parentObjectToToken.delete(t)}i.modelToSheetID&&i.modelToSheetID.has(t)&&i.modelToSheetID.delete(t)}),this.sortedSheetNames=null},n.prototype.computeExpression=function(r,t){var e=this.parser.parseFormula(r);return this.computeFormula(e,t)},n.prototype.isSheetMember=function(){var r=this.getSheetFamilyItem(this.grid);return!t.isNullOrUndefined(r)&&r.isSheetMember},n.prototype.destroy=function(){if(this.resetKeys(),this.dependentCells&&(this.dependentCells.clear(),this.dependentCells=null),this.dependentFormulaCells&&(this.dependentFormulaCells.clear(),this.dependentFormulaCells=null),this.formulaInfoTable&&(this.formulaInfoTable.clear(),this.formulaInfoTable=null),this.namedRanges.clear(),this.randomValues.clear(),this.randCollection=[],this.dependencyCollection=[],this.uniqueRange=[],this.sortRange=[],this.sortedSheetNames=null,this.evaluatingKeys.clear(),this.sheetFamiliesList&&(this.sheetFamiliesList.forEach(function(r){r.sheetDependentFormulaCells&&r.sheetDependentFormulaCells.clear(),r.sheetFormulaInfotable&&r.sheetFormulaInfotable.clear(),r.tokenToParentObject&&r.tokenToParentObject.clear(),r.parentObjectToToken&&r.parentObjectToToken.clear(),r.sheetNameToParentObject&&r.sheetNameToParentObject.clear(),r.sheetNameToToken&&r.sheetNameToToken.clear()}),this.sheetFamiliesList.clear(),this.sheetFamiliesList=null),this.modelToSheetID&&(this.modelToSheetID.clear(),this.modelToSheetID=null),this.defaultFamilyItem=null,this.lFormulas.clear(),this.parser&&this.parser.destroy(),this.parentObject=null,this.grid=null,"function"==typeof this.destroy)try{this.destroy()}catch(r){}},n.prototype.refreshRandValues=function(r){var t,e,n,i,o="";if(this.randomValues.has(r)){this.randomValues.delete(r);var s=this.randCollection.indexOf(r);s>-1&&this.randCollection.splice(s,1),0!==this.randomValues.size||this.randCollection.length||(this.randomValues.clear(),this.randCollection=[])}for(var a=0;a<this.randomValues.size;a++)t=this.rowIndex(this.randCollection[a]),e=this.colIndex(this.randCollection[a]),o=(parseFloat(this.getSheetToken(this.randCollection[a]).split(this.sheetToken).join(""))+1).toString(),i=this.getSheetFamilyItem(o),this.grid=i.sheetNameToParentObject.get(o),n=this.randomValues.get(this.randCollection[a]),n=this.computeFormula(n),void 0===this.parentObject.setValueRowCol?this.setValueRowCol(this.getSheetID(this.grid)+1,n,t,e):this.parentObject.setValueRowCol(this.getSheetId(this.grid),n,t,e)},n.prototype.refreshDependentCells=function(r,t,e,n,i,o,s,a){var u,l=this;e||(u=!0,e=[]);var h=this.getSheetFamilyItem(this.grid);try{var p=this.getDependentCells().get(r);if(p&&0!==p.length&&("Automatic"===this.parentObject.calculationMode||s||"calculate"===a)){var g=void 0;for(g=0;g<p.length;g++){var f=p[g];if(!(t&&f.indexOf(t)>-1||f===r||e.indexOf(f)>-1)){var m=this.getSheetToken(f),c=this.parentObject.sheets,d=this.parentObject.activeSheetIndex;if(m.length){this.grid=h.tokenToParentObject.get(m);var v=Number(this.grid),N="";if(!this.isNaN(v)&&c)for(var E=0;E<c.length;E++)c[E].id===v&&(N=c[E].name,d=E);this.actCell=N+"!"+f.split(m)[1]}else this.actCell=f.split(m)[1];try{var S=function(r,t){t&&(l.cell=r,l.parser.isFormulaParsed=!0,t.setFormulaValue(l.calculateFormula(t.getParsedFormula(),!0)))},y=this.rowIndex(f),C=this.colIndex(f),b=this.getFormulaInfoTable().get(f);if(void 0===this.parentObject.setValueRowCol)S(f,b),this.setValueRowCol(this.getSheetID(this.grid)+1,b.getFormulaValue(),y,C);else{var A=void 0;if((I=c&&c[d].rows&&c[d].rows[y-1]&&c[d].rows[y-1].cells&&c[d].rows[y-1].cells[C-1])&&I.formula&&I.formula.toLowerCase().includes("unique")){if(this.uniqueCells&&-1!==this.uniqueCells.indexOf(f))continue;this.uniqueCells||(this.uniqueCells=[]),this.uniqueCells.push(f),S(f,b),A=b.getFormulaValue(),this.uniqueCells.splice(this.uniqueCells.indexOf(f),1),this.uniqueCells.length||(this.uniqueCells=null)}else if(I&&I.formula&&I.formula.toLowerCase().includes("sort")){if(this.sortCells&&-1!==this.sortCells.indexOf(f))continue;this.sortCells||(this.sortCells=[]),this.sortCells.push(f),S(f,b),A=b.getFormulaValue(),this.sortCells.splice(this.sortCells.indexOf(f),1),this.sortCells.length||(this.sortCells=null)}else-1===e.indexOf(f)&&e.push(f),A=null;this.parentObject.setValueRowCol(this.getSheetId(this.grid),A,y,C,b.getFormulaText())}this.refreshDependentCells(f,null,e,null,i)}catch(r){continue}}}}if(u){if(!i&&o&&4===o.length){for(var m=this.getSheetToken(r),O=[],F=o[0],x=o[2];F<=x;F++)for(var V=o[1],R=o[3];V<=R&&(F!==x||V!==R);V++){var I=m+B(F,V);this.refreshDependentCells(I,null,e,null,i),O.push(I)}var T=new Set(O);e&&(e=e.filter(function(r){return!T.has(r)}))}var M=this.parentObject.sheets;M||(e=[]),e.forEach(function(r){for(var t,e=l.getSheetId(h.tokenToParentObject.get(l.getSheetToken(r))),i=0;i<M.length;i++)if(M[i].id===e){t=i;break}var o=l.rowIndex(r)-1,s=l.colIndex(r)-1,u=M[t].rows[o]&&M[t].rows[o].cells[s];u&&l.parentObject.notify("calculateFormula",{cell:u,rowIdx:o,colIdx:s,sheetIndex:t,isDependentRefresh:!0,isRandomFormula:n,action:a})})}}finally{this.getDependentCells().has(r)&&(this.grid=h.tokenToParentObject.get(this.getSheetToken(r)))}},ne([t.Event()],n.prototype,"onFailure",void 0),n=ne([t.NotifyPropertyChanges],n)}(t.Base),oe=function(){function r(r,t){this.formulaCorrection=!1,this.message=r,this.formulaCorrection=t}return r}(),se=function(){function r(){this.calcID=Number.MIN_VALUE+1,this.calcID1=Number.MIN_VALUE+1}return r.prototype.getFormulaText=function(){return this.formulaText},r.prototype.setFormulaText=function(r){this.formulaText=r},r.prototype.getFormulaValue=function(){return this.formulaValue},r.prototype.setFormulaValue=function(r){this.formulaValue=r},r.prototype.getParsedFormula=function(){return this.parsedFormula},r.prototype.setParsedFormula=function(r){this.parsedFormula=r},r}(),ae=function(){function r(){this.isSheetMember=!1,this.parentObjectToToken=new Map,this.sheetDependentFormulaCells=new Map,this.sheetNameToParentObject=new Map,this.sheetNameToToken=new Map,this.tokenToParentObject=new Map,this.sheetFormulaInfotable=new Map}return r}(),ue=function(){function r(r,t,e){return this.row=r,this.col=t,this.value=e,this.getRowIndex=function(){return r},this.setRowIndex=function(t){r=t},this.getColIndex=function(){return t},this.setColIndex=function(r){t=r},this.getFormulaValue=function(){return e},this}return r}();return r.ArrayFormulas=Ct,r.BasicFormulas=re,r.CalcSheetFamilyItem=ae,r.Calculate=ie,r.CalculateCommon=$,r.ComplexNumbersFormulas=it,r.DatabaseFormulas=zt,r.DateTimeExtraFormulas=ut,r.DateTimeFormulas=st,r.DateTimeIntlFormulas=jt,r.EngineeringBaseFormulas=Nr,r.EngineeringBesselFormulas=Ar,r.EngineeringConvertFormulas=Cr,r.EngineeringMiscFormulas=Sr,r.FinancialAmortizationEcmaFormulas=Gt,r.FinancialAnnuityFormulas=Fr,r.FinancialBondHelpers=Bt,r.FinancialCashflowFormulas=Mr,r.FinancialCouponsFormulas=Yt,r.FinancialDepreciationFormulas=Vr,r.FinancialRatesFormulas=Ir,r.FinancialSecuritiesFormulas=Ur,r.FormulaError=oe,r.FormulaInfo=se,r.FormulaModuleBase=Q,r.InformationAdvancedFormulas=Ut,r.InformationEcmaFormulas=_t,r.InformationExtraFormulas=Mt,r.InformationFormulas=It,r.LogicalExtraFormulas=gt,r.LogicalFormulas=ht,r.LookupArrayFormulas=St,r.LookupFormulas=mt,r.LookupRefExtraFormulas=Nt,r.LookupRefFormulas=dt,r.MathAggregateFormulas=rr,r.MathCeilingEcmaFormulas=kt,r.MathCombinatoricsFormulas=hr,r.MathMiscFormulas=ir,r.MathNumberFormulas=gr,r.MathRoundingFormulas=er,r.MathTrigFormulas=sr,r.MathTrigHyperbolicFormulas=ur,r.MatrixFormulaBase=mr,r.MatrixFormulas=dr,r.Parser=te,r.RegressionEcmaFormulas=Jt,r.StatisticalAdvancedFormulas=kr,r.StatisticalCorrelationFormulas=Hr,r.StatisticalDispersionFormulas=_r,r.StatisticalDistributionExtendedFormulas=et,r.StatisticalDistributionFormulas=$r,r.StatisticalEcmaFormulas=Kt,r.StatisticalExtendedFormulas=rt,r.StatisticalFormulas=jr,r.StatisticalIfsFormulas=Qr,r.StatisticalMomentsFormulas=Xr,r.StatisticalPercentileFormulas=Zr,r.StatisticalSampleBase=qr,r.TextAdvancedFormulas=Vt,r.TextEcmaFormulas=qt,r.TextExtraFormulas=Ft,r.TextFormulas=At,r.ValueChangedArgs=ue,r.besselI=V,r.besselJ=R,r.besselK=I,r.besselY=D,r.betaDist=k,r.betaInv=P,r.binomialCoeff=E,r.calculateDefaultLocale=z,r.chiSquareCDF=b,r.chiSquareInv=A,r.erf=g,r.erfc=f,r.fCDF=O,r.fInv=x,r.factorial=N,r.formatComplex=v,r.gamma=y,r.getAlphalabel=K,r.getSkeletonVal=n,r.isExternalFileLink=i,r.isUndefined=e,r.logGamma=S,r.logNormCDF=U,r.logNormInv=w,r.lowerRegularizedGamma=C,r.normCDF=m,r.normInv=c,r.parseComplexText=d,r.tCDF=j,r.tInv=L,r}({},ej.base),this.ejs=ej;
11
11
  //# sourceMappingURL=ej2-calculate.min.js.map