-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
xlsx-calc.js
2 lines (2 loc) · 25.6 KB
/
xlsx-calc.js
1
2
!function(r,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t=e();for(var n in t)("object"==typeof exports?exports:r)[n]=t[n]}}(this,(()=>{return r={490:(r,e,t)=>{"use strict";const n=t(77),o=t(530),a=t(82);r.exports=class{constructor(r,e){this.workbook=r,this.expressions=[],this.exec_formula=e,this.variables={},this.formulas=a(r,e);for(let r=this.formulas.length-1;r>=0;r--){let t=e.build_expression(this.formulas[r]);this.expressions.push(t)}this.calcNames()}setVar(r,e){let t=this.variables[r];t?t.setValue(e):this.expressions.forEach((t=>{this.setVarOfExpression(t,r,e)}))}getVars(){let r={};for(let e in this.variables)r[e]=this.variables[e].calc();return r}calcNames(){this.workbook&&this.workbook.Workbook&&this.workbook.Workbook.Names&&this.workbook.Workbook.Names.forEach((r=>{let e=this.getRef(r.Ref);this.variables[r.Name]=e,this.expressions.forEach((e=>{this.setVarOfExpression(e,r.Name)}))}))}getRef(r){if(!this.formulas.length)throw new Error("No formula found.");let e={formula_ref:this.formulas[0].formula_ref,wb:this.workbook,exec_formula:this.exec_formula};return o(r,e)}setVarOfExpression(r,e,t){for(let o=0;o<r.args.length;o++){let a=r.args[o];a===e?r.args[o]=this.variables[e]||(this.variables[e]=new n(t)):"object"!=typeof a||"Expression"!==a.name&&"UserFn"!==a.name||this.setVarOfExpression(a,e,t)}}execute(){this.expressions.forEach((r=>{r.update_cell_value()}))}}},755:(r,e,t)=>{"use strict";const n=t(77),o=(t(529),t(530)),a=864e5,i=t(161),l=t(217),s=t(948),{getErrorValueByMessage:f}=t(325);var u=0;r.exports=function(r){var e,t=this;function c(r,e){const t=e||{};r.t="e";const n=f(t.message);return void 0!==n&&(r.w=t.message,r.v=n,!0)}function h(r,e){if(e instanceof Error)c(r,e);else{const t=p(e);r.v=e,t&&(r.t=t)}}function p(r){return"string"==typeof r?"s":"number"==typeof r?"n":r instanceof Error?"e":void 0}function g(r){return null==r||""===r}function w(r){if("function"!=typeof r.calc)throw new Error("Undefined "+r)}function v(r,e,t){for(var o=0;o<e.length;o++)if(e[o]===r)try{if(0===o&&"+"===r){w(e[o+1]);let r=e[o+1].calc();e.splice(o,2,new n(r))}else{w(e[o-1]),w(e[o+1]);let r=e[o-1].calc(),a=e[o+1].calc();if(r instanceof Error)throw r;if(a instanceof Error)throw a;let i=t(r,a);e.splice(o-1,3,new n(i)),o--}}catch(r){throw r}}function m(r){return Array.isArray(r)?r.map(m):-r}t.id=++u,t.args=[],t.name="Expression",t.update_cell_value=function(){try{if(r.cell.v=t.calc(),r.cell.t=p(r.cell.v),e=r.cell.v,Array.isArray(e)&&(0===e.length||Array.isArray(e[0]))){const e=r.cell.v;r.cell.v=void 0;let t=r.name.match(/([A-Z]+)([0-9]+)/),n=i(t[1]),o=+t[2];for(let t=0;t<e.length;t++){const a=o+t;for(let o=0;o<e[t].length;o++){const i=e[t][o],s=l(o+n)+a;let f=r.sheet[s];f||(f={},r.sheet[s]=f),h(f,i)}}}}catch(e){if(!c(r.cell,e))throw e}finally{r.status="done"}var e},t.formula=r,t.calc=function(){let r=t.args.concat();if(function(r,e){for(var t=0;t<r.length-2;t++)if("^"===r[t]&&"-"===r[t+1])try{w(r[t-1]),w(r[t+2]);let o=r[t-1].calc(),a=r[t+2].calc();Array.isArray(o)&&(o=o[getCurrentCellIndex()-1][0]),Array.isArray(a)&&(a=a[getCurrentCellIndex()-1][0]);let i=e(o,a);r.splice(t-1,4,new n(i)),t--}catch(r){throw r}}(r,(function(r,e){return Math.pow(+r,0-e)})),v("^",r,s((function(r,e){return Math.pow(+r,+e)}))),function(r){for(var e=r.length;e--;)if("-"===r[e]){w(r[e+1]);var t=r[e+1].calc();if(e>0&&"string"!=typeof r[e-1]){if(r.splice(e,1,"+"),t instanceof Date){t=Date.parse(t),w(r[e-1]);var o=r[e-1].calc();o instanceof Date&&(o=Date.parse(o)/a,t/=a,r.splice(e-1,1,new n(o)))}r.splice(e+1,1,new n(m(t)))}else{if("string"==typeof t)throw new Error("#VALUE!");r.splice(e,2,new n(m(t)))}}}(r),v("/",r,s((function(r,e){if(0==e)throw Error("#DIV/0!");return+r/+e}))),v("*",r,s((function(r,e){return+r*+e}))),v("+",r,s((function(r,e){return r instanceof Date&&"number"==typeof e&&(e*=a),+r+ +e}))),v("&",r,s((function(r,e){var t="";return null!==r&&(t+=r),null!==e&&(t+=e),t}))),v("<",r,s((function(r,e){return r<e}))),v(">",r,s((function(r,e){return r>e}))),v(">=",r,s((function(r,e){return r>=e}))),v("<=",r,s((function(r,e){return r<=e}))),v("<>",r,s((function(r,e){return r instanceof Date&&e instanceof Date?r.getTime()!==e.getTime():!(g(r)&&g(e)||r===e)}))),v("=",r,s((function(r,e){return r instanceof Date&&e instanceof Date?r.getTime()===e.getTime():!(!g(r)||!g(e))||null==r&&0===e||0===r&&null==e||"string"==typeof r&&"string"==typeof e&&r.toLowerCase()===e.toLowerCase()||r===e}))),1==r.length)return"function"!=typeof r[0].calc?r[0]:r[0].calc()},t.push=function(n){if(n){var a=o(n,r);"="===a&&(">"==e||"<"==e)||"<"==e&&">"===a?t.args[t.args.length-1]+=a:t.args.push(a),e=a}}}},839:r=>{"use strict";r.exports=function(r){this.calc=function(){return r()}}},529:(r,e,t)=>{"use strict";const n=t(161),o=t(217),a=t(199);r.exports=function(r,e){this.parse=function(){var t,o,i;if(-1!=r.indexOf("!")){var l=r.split("!");o=a(l[0]),t=l[1]}else o=e.sheet_name,t=r;i=e.wb.Sheets[o];var s,f=t.split(":"),u=parseInt(f[0].replace(/^[A-Z]+/,""),10)||0,c=f[1].replace(/^[A-Z]+/,"");return""===c&&i["!ref"]&&(c=(i["!ref"].includes(":")?i["!ref"].split(":")[1]:i["!ref"]).replace(/^[A-Z]+/,"")),s=parseInt(""==c?"500000":c,10),{sheet_name:o,sheet:i,min_row:u,min_col:n(f[0]),max_row:s,max_col:n(f[1])}},this.calc=function(){for(var r=this.parse(),t=r.sheet_name,n=r.sheet,a=r.min_row,i=r.min_col,l=r.max_row,s=r.max_col,f=[],u=a;u<=l;u++){var c=[];f.push(c);for(var h=i;h<=s;h++){var p=o(h)+u,g=t+"!"+p,w=e.formula_ref[g];if(w){if("new"===w.status)e.exec_formula(w);else if("working"===w.status){if(w.cell.f.includes(e.name))throw new Error("Circular ref");e.exec_formula(w)}"e"===n[p].t?c.push(n[p]):c.push(n[p].v)}else n[p]?"e"===n[p].t?c.push(n[p]):c.push(n[p].v):c.push(null)}}return f}}},77:r=>{"use strict";r.exports=function(r){this.setValue=function(e){r=e},this.calc=function(){return r}}},596:(r,e,t)=>{"use strict";const n=t(199);r.exports=function(r,e){var t=this;this.name="RefValue",this.str_expression=r,this.formula=e,t.parseRef=function(){var t,o,a;if(-1!=r.indexOf("!")){var i=r.split("!");o=n(i[0]),t=e.wb.Sheets[o],a=i[1]}else t=e.sheet,o=e.sheet_name,a=r;if(!t)throw Error("Sheet "+o+" not found.");return{sheet:t,sheet_name:o,cell_name:a,cell_full_name:o+"!"+a}},this.calc=function(){var r=t.parseRef(),n=r.sheet,o=r.cell_name,a=r.cell_full_name,i=n[o];if(!i)return null;var l=e.formula_ref[a];if(!l){if("e"===i.t)throw console.log("ref is an error with no formula",o),new Error(i.w);return i.v}if("new"===l.status){if(e.exec_formula(l),"e"===i.t)throw console.log("ref is an error with new formula",a,i.w),new Error(i.w);return i.v}if("working"===l.status){if(i.f.includes(e.name))throw new Error("Circular ref");return e.exec_formula(l),this.calc()}if("done"===l.status){if("e"===i.t)throw console.log("ref is an error after formula eval",a,i.w),new Error(i.w);return i.v}}}},120:(r,e,t)=>{"use strict";const{getErrorValueByMessage:n}=t(325);r.exports=function(r){var e=this;e.name="UserFn",e.args=[],e.calc=function(){var t;try{if((t=r.apply(e,e.args.map((r=>r.calc()))))instanceof Error)throw t}catch(e){const o=n(e.message);if("is_blank"===r.name&&void 0!==o)t=0;else{if("iserror"!==r.name||void 0===o)throw e;t=!0}}return t},e.push=function(r){e.args.push(r)}}},930:r=>{"use strict";r.exports=function(r,e){var t=this;t.name="UserRawFn",t.args=[],t.calc=function(){try{return r.apply(t,t.args)}catch(r){throw r}},t.push=function(r){t.args.push(r)}}},161:r=>{"use strict";r.exports=function(r){for(var e=0,t=r.replace(/[0-9]+$/,""),n=t.length;n--;)e+=Math.pow(26,t.length-n-1)*(t.charCodeAt(n)-64);return e-1}},948:(r,e,t)=>{const n=t(325);r.exports=function(r){return function(){for(var e=!1,t=[],o=[],a=[],i=0,l=arguments.length;i<l;i++){var s=arguments[i],f=Array.isArray(s);f&&(e=!0);var u=f?s.map((r=>Array.isArray(r)?r:[r])):[[s]];t[i]=u,o[i]=u.length,a[i]=u[0].length}for(var c=Math.max.apply(null,o),h=Math.max.apply(null,a),p=[],g=0;g<c;g++){p[g]=[];for(var w=0;w<h;w++){var v=!1,m=[];for(i=0,l=t.length;i<l;i++){var A=t[i],E=1===o[i]?0:g,y=1===a[i]?0:w;if(!(E in A)){v=!0;break}if(!(y in(A=A[E]))){v=!0;break}A=A[y],m[i]=A}p[g][w]=v?n.na:r.apply(null,m)}}return e?p:p[0][0]}}},325:r=>{const e=new Error("#NULL!"),t=new Error("#DIV/0!"),n=new Error("#VALUE!"),o=new Error("#REF!"),a=new Error("#NAME?"),i=new Error("#NUM!"),l=new Error("#N/A"),s=new Error("#ERROR!"),f=new Error("#GETTING_DATA"),u=new Error("#CALC!"),c={"#NULL!":0,"#DIV/0!":7,"#VALUE!":15,"#REF!":23,"#NAME?":29,"#NUM!":36,"#N/A":42,"#GETTING_DATA":43,"#CALC!":0};r.exports={nil:e,div0:t,value:n,ref:o,name:a,num:i,na:l,error:s,data:f,calc:u,getErrorValueByMessage:function(r){return c[r]}}},534:(r,e,t)=>{"use strict";const n=t(940);let o={},a={};function i(r,e){for(var t in r)a[t]=r[t]}function l(r,e){var t=(e=e||{}).prefix||"";for(var n in r){var a=r[n];"function"==typeof a?!e.override&&o[t+n]||(o[t+n]=a):"object"==typeof a&&l(a,s(e,{prefix:n+"."}))}}function s(r,e){var t=JSON.parse(JSON.stringify(r));for(var n in e)t[n]=e[n];return t}function f(r){return n(r,{xlsx_Fx:o,xlsx_raw_Fx:a})}function u(r){f(r).update_cell_value()}l(t(649)),i(t(982)),u.set_fx=function(r,e){o[r]=e},u.exec_fx=function(r,e){return o[r].apply(this,e)},u.localizeFunctions=function(r){for(let e in r){let t=r[e];o[t]&&(o[e]=o[t]),a[t]&&(a[e]=a[t])}},u.import_functions=l,u.import_raw_functions=i,u.build_expression=f,u.xlsx_Fx=o,r.exports=u},940:(r,e,t)=>{const n=t(755),o=t(77),a=t(120),i=t(930),l={"*":"multiply","+":"plus","-":"minus","/":"divide","^":"power","&":"concat","<":"lt",">":"gt","=":"eq"};r.exports=function(r,e){r.status="working";var t,s=e.xlsx_Fx||{},f=e.xlsx_raw_Fx||{},u=r.cell.f;"="==u[0]&&(u=u.substr(1));var c=t=new n(r),h="",p=!1,g=[{exp:c}];function w(r){'"'===r?(c.push(new o(h)),p=!0,h="",A=m):h+=r}function v(r){"'"===r&&(A=m),h+=r}function m(e){var t,o;'"'===e?(A=w,h=""):"'"===e?(A=v,h="'"):"("===e?function(){var e,t=h.trim(),o=s[t],l=f[t];if(l)o=new i(l,r);else if(o)o=new a(o,r);else if(t)throw new Error('"'+r.sheet_name+'"!'+r.name+": Function "+h+" not found");e=new n(r),g.push({exp:e,special:o}),c=e,h=""}():")"===e?(o=g.pop(),(c=o.exp).push(h),t=c,h="",c=g[g.length-1].exp,o.special?(o.special.push(t),c.push(o.special)):c.push(t)):l[e]?function(r){p||c.push(h),p=!1,c.push(r),h=""}(e):","===e&&g[g.length-1].special?(p=!1,g[g.length-1].exp.push(h),g[g.length-1].special.push(g[g.length-1].exp),g[g.length-1].exp=c=new n(r),h=""):" "!==e&&(h+=e)}for(var A=m,E=0;E<u.length;E++)A(u[E]);return t.push(h),t}},82:r=>{"use strict";r.exports=function(r,e){let t={},n=[];for(let o in r.Sheets){let a=r.Sheets[o];for(let i in a)if(a[i]&&a[i].f){let l=t[o+"!"+i]={formula_ref:t,wb:r,sheet:a,sheet_name:o,cell:a[i],name:i,status:"new",exec_formula:e};n.push(l)}}return n}},982:(r,e,t)=>{"use strict";const n=t(217),o=t(161),a=t(948),i=t(77),l=t(529),s=t(596);r.exports={OFFSET:function(r,e,t,a,f){if(a=(a||new i(1)).calc(),f=(f||new i(1)).calc(),1===r.args.length&&"RefValue"===r.args[0].name){var u=r.args[0],c=u.parseRef(),h=o(c.cell_name)+t.calc(),p=n(h),g=+c.cell_name.replace(/^[A-Z]+/g,"")+e.calc(),w=c.sheet_name+"!"+p+g;if(1===a&&1===f)return new s(w,u.formula).calc();var v=n(h+f-1);return new l(w+":"+(v+(g+a-1)),u.formula).calc()}},ROW:function(r){if(0===r.args.length)return+r.formula.name.replace(/^[A-Z]+/g,"");if(1===r.args.length&&"RefValue"===r.args[0].name)return+r.args[0].parseRef().cell_name.replace(/^[A-Z]+/g,"");if(1===r.args.length&&r.args[0]instanceof l){for(var e=r.args[0].parse(),t=e.min_row,n=e.max_row,o=[],a=t;a<=n;a++)o.push(a);return o}},COLUMN:function(r){if(0===r.args.length)return o(r.formula.name)+1;if(1===r.args.length&&"RefValue"===r.args[0].name){var e=r.args[0].parseRef();return o(e.cell_name)+1}if(1===r.args.length&&r.args[0]instanceof l){for(var t=r.args[0].parse(),n=t.min_col,a=t.max_col,i=[],s=n;s<=a;s++)i.push(s+1);return i}},IFERROR:function(r,e){try{var t=r.calc();return"number"!=typeof t||!isNaN(t)&&t!==1/0&&t!==-1/0?t:e.calc()}catch(r){return e.calc()}},IF:function(r,e,t){var n,o,i;try{n=r.calc()}catch(r){n=r}try{o=e.calc()}catch(r){o=r}try{i=void 0!==t&&t.calc()}catch(r){i=r}return a((function(r,e,t){return r instanceof Error?r:r?e:t}))(n,o,i)},AND:function(){for(var r=0;r<arguments.length;r++)if(!arguments[r].calc())return!1;return!0},OR:function(){for(var r=0;r<arguments.length;r++)if(arguments[r].calc())return!0;return!1},TRANSPOSE:function(r){let e=r.args[0].calc(),t=r.formula.name.match(/([A-Z]+)([0-9]+)/),a=r.formula.sheet,i=o(t[1]),l=+t[2];for(let r=0;r<e.length;r++){let t=e[r];for(let e=0;e<t.length;e++){let o=i+r,s=l+e,f=t[e];a[n(o)+s].v=f}}return e[0][0]}}},649:(r,e,t)=>{"use strict";const n=t(413),o=t(325);let a={FLOOR:Math.floor,"_xlfn.FLOOR.MATH":Math.floor,"FLOOR.MATH":Math.floor,ABS:Math.abs,SQRT:Math.sqrt,VLOOKUP:function(r,e,t,n=!0){for(var o=null,a=0;a<e.length;a++)if(e[a][0]<r)o=e[a][t-1];else if(e[a][0]==r)return e[a][t-1];if(n&&o)return o;throw Error("#N/A")},MAX:function(){for(var r=null,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;){var a=n[o];if(Array.isArray(a))for(var i=a.length;i--;)(null==r||null!=a[i]&&r<a[i])&&(r=a[i]);else(null==r||null!=a&&r<a)&&(r=a)}else!isNaN(t)&&(null==r||null!=t&&r<t)&&(r=t)}return r},SUM:g,MIN:function(){for(var r=null,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;){var a=n[o];if(Array.isArray(a))for(var i=a.length;i--;)(null==r||null!=a[i]&&r>a[i])&&(r=a[i]);else(null==r||null!=a&&r>a)&&(r=a)}else!isNaN(t)&&(null==r||null!=t&&r>t)&&(r=t)}return r},CONCATENATE:function(){for(var r="",e=0;e<arguments.length;e++){var t=arguments[e];null!=t&&(r+=t)}return r},PMT:function(r,e,t,n,o){if(o=o||0,n=n||0,0!=r){var a=Math.pow(1+r,e);return-r*(n+a*t)/((-1+a)*(1+r*o))}return 0!=e?-(n+t)/e:0},COUNTA:p,IRR:function(r,e){var t=-2,n=1,o=0;do{for(var a=(t+n)/2,i=0,l=0;l<r.length;l++)i+=r[l][0]/Math.pow(1+a,l);i>0?(t===n&&(n+=Math.abs(a)),t=a):n=a,o++}while(Math.abs(i)>1e-6&&o<1e5);return a},"NORM.INV":h,"_xlfn.NORM.INV":h,STDEV:function(){var r=f(arguments),e=function(r){return r.reduce((function(r,e){return r+e}))/r.length}(r),t=r.map((function(r){return(r-e)*(r-e)}));return Math.sqrt(t.reduce((function(r,e){return r+e}))/(r.length-1))},AVERAGE:c,EXP:function(r){return Math.pow(Math.E,r)},LN:Math.log,"_xlfn.VAR.P":u,"VAR.P":u,"_xlfn.COVARIANCE.P":s,"COVARIANCE.P":s,TRIM:function(r){return(""+r).trim()},LEN:function(r){return(""+r).length},ISBLANK:l,HLOOKUP:function(r,e,t,n){if(void 0===r||l(r))throw Error("#N/A");t=t||0;let o,a,i=e[0];if("string"==typeof r){for(a=r.toLowerCase(),o=0;o<i.length;o++)if(n&&i[o]===a||-1!==i[o].toLowerCase().indexOf(a))return t<e.length+1?e[t-1][o]:e[0][o]}else for(a=r,o=0;o<i.length;o++)if(n&&i[o]===a||i[o]===a)return t<e.length+1?e[t-1][o]:e[0][o];throw Error("#N/A")},INDEX:function(r,e,t){if(e<=r.length){var n=r[e-1];if(!Array.isArray(n))return r[e];if(!t)return n;if(t<=n.length)return n[t-1]}throw Error("#REF!")},MATCH:function(r,e,t){if(Array.isArray(e)&&1===e.length&&Array.isArray(e[0])&&(e=e[0]),!r&&!e)throw Error("#N/A");if(2===arguments.length&&(t=1),!(e instanceof Array))throw Error("#N/A");if(0===t)return"string"==typeof r?function(r,e){for(var t=0;t<r.length;t++)if(e=e.replace(/\?/g,"."),Array.isArray(r[t])){if(1===r[t].length&&"string"==typeof r[t][0]&&r[t][0].toLowerCase()===e.toLowerCase())return t+1}else if("string"==typeof r[t]&&r[t].toLowerCase()===e.toLowerCase())return t+1;throw Error("#N/A")}(e,r):function(r,e){for(var t=0;t<r.length;t++)if(Array.isArray(r[t])){if(1===r[t].length&&r[t][0]===e)return t+1}else if(r[t]===e)return t+1;throw Error("#N/A")}(e,r);if(1===t)return function(r,e){for(var t,n,o=0;o<r.length;o++){if(r[o]===e)return o+1;r[o]<e&&(n?r[o]>n&&(t=o+1,n=r[o]):(t=o+1,n=r[o]))}if(!t)throw Error("#N/A");return t}(e,r);if(-1===t)return function(r,e){for(var t,n,o=0;o<r.length;o++)if(Array.isArray(r[o])&&r[o].length>0){if(r[o][0]===e)return o+1;r[o][0]>e&&(n?r[o][0]<n&&(t=o+1,n=r[o][0]):(t=o+1,n=r[o][0]))}else{if(r[o]===e)return o+1;r[o]>e&&(n?r[o]<n&&(t=o+1,n=r[o]):(t=o+1,n=r[o]))}if(!t)throw Error("#N/A");return t}(e,r);throw Error("#N/A")},SUMPRODUCT:function(){var r=function(r){return void 0===r||""===r||null===r||isNaN(r)?0:parseFloat(r)};if(!arguments||0===arguments.length||!arguments[0])throw Error("#VALUE!");if(!function(r){for(var e=function(r=[]){return r.length},t=function(r=[]){return r[0]&&r[0].length},n=e(r[0]),o=t(r[0]),a=1;a<r.length;a++)if(e(r[a])!==n||t(r[a])!==o)return!1;return!0}(arguments))throw Error("#VALUE!");for(var e=0;e<arguments.length;e++){var t=arguments[e];if(Array.isArray(t))for(var n=0;n<t.length;n++){var o=t[n];if(Array.isArray(o))for(var a=0;a<o.length;a++){var i;if((i=o[a])&&"object"==typeof i&&"e"===i.t)throw Error(i.w)}else if((i=o)&&"object"==typeof i&&"e"===i.t)throw Error(i.w)}else if((i=t)&&"object"==typeof i&&"e"===i.t)throw Error(i.w)}var l,s=arguments.length+1,f=0;for(e=0;e<arguments[0].length;e++)if(arguments[0][e]instanceof Array)for(n=0;n<arguments[0][e].length;n++){for(l=1,a=1;a<s;a++)l*=r(arguments[a-1][e][n]);f+=l}else{for(l=1,a=1;a<s;a++)l*=r(arguments[a-1][e]);f+=l}return f},ISNUMBER:function(r){return!isNaN(r)},TODAY:function(){var r=new Date;return r.setHours(0,0,0,0),r},ISERROR:function(){return!1},TIME:function(r,e,t){return 1e3*(60*(60*r+e)+t)/864e5},DAY:function(r){if(!r.getDate)throw Error("#VALUE!");var e=r.getUTCDate();if(isNaN(e))throw Error("#VALUE!");return e},MONTH:function(r){if(!r.getMonth)throw Error("#VALUE!");var e=r.getUTCMonth();if(isNaN(e))throw Error("#VALUE!");return e+1},YEAR:function(r){if(!r.getFullYear)throw Error("#VALUE!");var e=r.getUTCFullYear();if(isNaN(e))throw Error("#VALUE!");return e},RIGHT:function(r,e){if(e=void 0===e?1:parseFloat(e),isNaN(e))throw Error("#VALUE!");return(r=null==r?"":""+r).substring(r.length-e)},LEFT:function(r,e){if(e=void 0===e?1:parseFloat(e),isNaN(e))throw Error("#VALUE!");return(r=null==r?"":""+r).substring(0,e)},IFS:function(){for(var r=0;r+1<arguments.length;r+=2)if(arguments[r])return arguments[r+1];throw Error("#N/A")},ROUND:function(r,e){if(0===arguments.length)throw new Error("Err:511");if(1===arguments.length)return Math.round(r);let t=Math.pow(10,e);return Math.round(t*r)/t},CORREL:function(r,e){if(r=f(r),e=f(e),r.length!==e.length)return"N/D";for(var t=1/(r.length-1),n=g.apply(this,r)/r.length,o=g.apply(this,e)/e.length,a=0,i=0,l=0,s=0;s<r.length;s++)a+=(r[s]-n)*(e[s]-o),i+=Math.pow(r[s],2),l+=Math.pow(e[s],2);return a/(t*(i=Math.sqrt(i/t))*(l=Math.sqrt(l/t)))},SUMIF:function(){let r=arguments[1],e=0;return[].slice.call(arguments)[0][0].forEach(((t,n)=>{null!==t&&(t=t.toString()).replace(/\'/g,"")===r&&(isNaN([].slice.call(arguments)[2][0][n])||(e+=[].slice.call(arguments)[2][0][n]))})),e},CHOOSE:function(r){return arguments[r]},SUBSTITUTE:function(r,e,t,n){if(n<=0)throw Error("#VALUE!");if(!r||!e||!t&&""!==t)return r;if(void 0===n)return r.replace(new RegExp(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),t);for(var o=0,a=0;r.indexOf(e,o)>0;)if(o=r.indexOf(e,o+1),++a===n)return r.substring(0,o)+t+r.substring(o+e.length)},CEILING:function(r,e){return Math.ceil(r/e)*e},FILTER:(i=function(r,e,t){if(!r||!e)return o.na;if(!(r instanceof Array))return o.na;if(!(e instanceof Array))return o.na;if(0===r.length)return o.na;if(0===e.length)return o.na;for(let e=0;e<r.length;e++){if(!(r[e]instanceof Array))return o.na;if(0===r[e].length)return o.na;if(r[e].length!==r[0].length)return o.na}for(let r=0;r<e.length;r++){if(!(e[r]instanceof Array))return o.na;if(0===e[r].length)return o.na;if(e[r].length!==e[0].length)return o.na}const a=r[0].length,i=r.length,l=e[0].length,s=e.length;if(a!==l&&i!==s)return o.na;if(i>1&&a>1&&(a===l&&1!==s||i===s&&1!==l))return o.na;if(i>1&&1===a&&(1!==l||1!==s&&s!==i))return o.na;const f=[];for(let t=0;t<i;t++){const o=[];for(let l=0;l<a;l++){const s=w(e,t,l)||w(e,0,l)||w(e,t,0),f=n.parseBool(s);if(!0===f)o.push(r[t][l]);else if(f instanceof Error)return n.addEmptyValuesToArray([[f]],a,i)}o.length>0&&f.push(o)}return 0===f.length?null!=t?n.addEmptyValuesToArray([[t]],a,i):n.addEmptyValuesToArray([[o.calc]],a,i):n.addEmptyValuesToArray(f,a,i)},function(){const r=i.apply(this,arguments);if(r instanceof Error)throw r;return r}),DATEDIF:function(r,e,t){if(r=new Date(r),e=new Date(e),!r||!e||"Invalid Date"==r||"Invalid Date"==e)throw Error("#VALUE!");switch(t=t.replace(/[^DMY]/gi,"")){case"M":return e.getMonth()-r.getMonth()+12*(e.getFullYear()-r.getFullYear());case"Y":return Math.abs(e.getUTCFullYear()-r.getUTCFullYear());default:var n=Math.abs(e-r);return Math.ceil(n/864e5)}},EOMONTH:function(r,e){if(!(r=new Date(r))||"Invalid Date"==r)throw Error("#VALUE!");e=e||0;var t=new Date(r.getUTCFullYear(),r.getUTCMonth()+e+1,0);return t.setUTCHours(0),t.setUTCMinutes(0),t.setUTCSeconds(0),t}};var i;function l(r){return!r}function s(r,e){if(r=f(r),e=f(e),r.length!=e.length)return"N/D";for(var t=1/r.length,n=g.apply(this,r)/r.length,o=g.apply(this,e)/e.length,a=0,i=0;i<r.length;i++)a+=(r[i]-n)*(e[i]-o);return a*t}function f(r){for(var e=[],t=0;t<r.length;t++){var n=r[t];if(Array.isArray(n)){for(var o=n,a=o.length;a--;)if("number"==typeof o[a])e.push(o[a]);else if(Array.isArray(o[a]))for(var i=o[a].length;i--;)"number"==typeof o[a][i]&&e.push(o[a][i])}else"number"==typeof n&&e.push(n)}return e}function u(){for(var r=c.apply(this,arguments),e=0,t=0,n=0;n<arguments.length;n++){var o=arguments[n];if(Array.isArray(o))for(var a=o,i=a.length;i--;)for(var l=a[i].length;l--;)null!==a[i][l]&&void 0!==a[i][l]&&(e+=Math.pow(a[i][l]-r,2),t++);else e+=Math.pow(o-r,2),t++}return e/t}function c(){var r=p.apply(this,arguments);if(0==r)throw Error("#DIV/0!");return g.apply(this,arguments)/r}function h(r,e,t){if(r<0||r>1)throw"The probality p must be bigger than 0 and smaller than 1";if(t<0)throw"The standard deviation sigma must be positive";return 0==r?-1/0:1==r?1/0:0==t?e:(n=r-.5,Math.abs(n)<=.425?a=n*(((((((2509.0809287301227*(o=.180625-n*n)+33430.57558358813)*o+67265.7709270087)*o+45921.95393154987)*o+13731.69376550946)*o+1971.5909503065513)*o+133.14166789178438)*o+3.3871328727963665)/(((((((5226.495278852854*o+28729.085735721943)*o+39307.89580009271)*o+21213.794301586597)*o+5394.196021424751)*o+687.1870074920579)*o+42.31333070160091)*o+1):(o=n>0?1-r:r,a=(o=Math.sqrt(-Math.log(o)))<=5?(((((((.0007745450142783414*(o+=-1.6)+.022723844989269184)*o+.2417807251774506)*o+1.2704582524523684)*o+3.6478483247632045)*o+5.769497221460691)*o+4.630337846156546)*o+1.4234371107496835)/(((((((1.0507500716444169e-9*o+.0005475938084995345)*o+.015198666563616457)*o+.14810397642748008)*o+.6897673349851)*o+1.6763848301838038)*o+2.053191626637759)*o+1):(((((((2.0103343992922881e-7*(o+=-5)+27115555687434876e-21)*o+.0012426609473880784)*o+.026532189526576124)*o+.29656057182850487)*o+1.7848265399172913)*o+5.463784911164114)*o+6.657904643501103)/(((((((20442631033899397e-31*o+1.421511758316446e-7)*o+18463183175100548e-21)*o+.0007868691311456133)*o+.014875361290850615)*o+.1369298809227358)*o+.599832206555888)*o+1),n<0&&(a=-a)),e+t*a);var n,o,a}function p(){for(var r=0,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;)for(var a=n[o].length;a--;)null!==n[o][a]&&void 0!==n[o][a]&&r++;else null!=t&&r++}return r}function g(){for(var r=0,e=arguments.length;e--;){var t=arguments[e];if(Array.isArray(t))for(var n=t,o=n.length;o--;)for(var a=n[o].length;a--;)isNaN(n[o][a])||(r+=+n[o][a]);else r+=+t}return r}function w(r,e,t){if(r[e])return!1===r[e][t]?"FALSE":r[e][t]}r.exports=a},199:r=>{"use strict";r.exports=function(r){var e=r.match(/^'(.*)'$/);return e?e[1]:r}},44:(r,e,t)=>{"use strict";const n=t(217),o=t(161),a=t(534),i=t(82),l=t(490);var s=function(r,e){for(var t=i(r,a),n=t.length-1;n>=0;n--)try{if("done"===t[n].status)continue;a(t[n])}catch(r){if(!e||!e.continue_after_error)throw r;e.log_error&&console.log("error executing formula","sheet",t[n].sheet_name,"cell",t[n].name,r)}};s.calculator=function(r){return new l(r,a)},s.set_fx=a.set_fx,s.exec_fx=a.exec_fx,s.col_str_2_int=o,s.int_2_col_str=n,s.import_functions=a.import_functions,s.import_raw_functions=a.import_raw_functions,s.xlsx_Fx=a.xlsx_Fx,s.localizeFunctions=a.localizeFunctions,s.XLSX_CALC=s,r.exports=s},217:r=>{"use strict";r.exports=function(r){for(var e,t=r+1,n="",o=10;t>0&&o--;)e=(t-1)%26,n=String.fromCharCode(e+65)+n,t=(t-e-1)/26;return n}},530:(r,e,t)=>{const n=t(77),o=t(596),a=t(839),i=t(529);let l,s;function f(r,e){if(!e.wb.Workbook||!e.wb.Workbook.Names)return null;if(s!==e.wb)return s=e.wb,l=null,f(r,e);if(l)return l[r];const t=Object.values(e.wb.Workbook.Names);return 0!==t.length?(l={},t.forEach((({Name:r,Ref:e})=>{r.includes(".")||(l[r]=e)})),f(r,e)):void 0}r.exports=function r(e,t){if(!isNaN(e))return new n(+e);if("TRUE"===e)return new n(1);if("FALSE"===e)return new n(0);if("string"!=typeof e)return e;if((e=e.trim().replace(/\$/g,"")).match(/^[A-Z]+[0-9]+:[A-Z]+[0-9]+$/))return new i(e,t);if(e.match(/^[^!]+![A-Z]+[0-9]+:[A-Z]+[0-9]+$/))return new i(e,t);if(e.match(/^[A-Z]+:[A-Z]+$/))return new i(e,t);if(e.match(/^[^!]+![A-Z]+:[A-Z]+$/))return new i(e,t);if(e.match(/^[A-Z]+[0-9]+$/))return new o(e,t);if(e.match(/^[^!]+![A-Z]+[0-9]+$/))return new o(e,t);if(e.match(/%$/)){var l=r(e.substr(0,e.length-1),t);return new a((()=>l.calc()/100))}return f(e,t)?r(f(e,t),t):e}},413:(r,e,t)=>{const n=t(325);r.exports={addEmptyValuesToArray:function(r,e,t){if(!r||!e||!t)return r;if(e<0||t<0)return r;if(!Array.isArray(r)||!r.length)return r;for(let e=0;e<r.length;e++)if(!(r[e]instanceof Array))return r;for(let t=0;t<r.length;t++)if(r[t].length<e)for(let n=r[t].length;n<e;n++)r[t].push("");if(r.length<t)for(let n=r.length;n<t;n++){r.push([]);for(let t=0;t<e;t++)r[n].push("")}return r},parseBool:function(r){if("boolean"==typeof r)return r;if(r instanceof Error)return r;if("number"==typeof r)return 0!==r;if("string"==typeof r){const e=r.toUpperCase();if("TRUE"===e)return!0;if("FALSE"===e)return!1}return r instanceof Date&&!isNaN(r)||n.value}}}},e={},function t(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={exports:{}};return r[n](a,a.exports,t),a.exports}(44);var r,e}));
//# sourceMappingURL=xlsx-calc.js.map