/*! * * SpreadJS Library 13.1.0 * * Copyright(c) GrapeCity, Inc. All rights reserved. * * Licensed under the SpreadJS Commercial License. * us.sales@grapecity.com * http://www.grapecity.com/en/licensing/grapecity/ * * */ var GC="object"==typeof GC?GC:{};GC.Spread=GC.Spread||{},GC.Spread.Sheets=GC.Spread.Sheets||{},GC.Spread.Sheets.CalcEngine=function(a){var b={};function c(d){if(b[d])return b[d].exports;var e=b[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,c),e.l=!0,e.exports}return c.m=a,c.c=b,c.d=function(a,b,d){c.o(a,b)||Object.defineProperty(a,b,{enumerable:!0,get:d})},c.r=function(a){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},c.t=function(a,b){var d,e;if(1&b&&(a=c(a)),8&b)return a;if(4&b&&"object"==typeof a&&a&&a.__esModule)return a;if(d=Object.create(null),c.r(d),Object.defineProperty(d,"default",{enumerable:!0,value:a}),2&b&&"string"!=typeof a)for(e in a)c.d(d,e,function(b){return a[b]}.bind(null,e));return d},c.n=function(a){var b=a&&a.__esModule?function b(){return a.default}:function b(){return a};return c.d(b,"a",b),b},c.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},c.p="/assets/",c(c.s="./dist/plugins/sheetsCalc/sheetsCalc.entry.js")}({"./dist/plugins/sheetsCalc/calc-spreadjs.js":function(a,b,c){"use strict";var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O=this&&this.__extends||function(){var a=function(b,c){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])})(b,c)};return function(b,c){a(b,c);function d(){this.constructor=b}b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}();Object.defineProperty(b,"__esModule",{value:!0}),d=c("Core"),e=c("Core"),f=c("Common"),g=c("./dist/plugins/sheetsCalc/parser-sheets.js"),h=c("CalcEngine"),i=c("./dist/plugins/sheetsCalc/calc.ns.js"),j=f.Common.j,k=f.Common.u,l=j.Ia,m=j.za,n=null,o=void 0,p=["v","n","s","b","d","sn"],q=h.Errors.Value,r=h.Errors.Calc,s=f.Formatter&&f.Formatter.GeneralFormatter,t=h.Convert.vf,u=h.Convert.Fh,v=h.Convert.Ca,w=h.Errors.Reference,x=h.Errors.NotAvailable,y=h.Errors.Name,z=f.Common.A,A=f.Common.B,B=j.Fa,C=function(a){return h.Convert.Na(a,!0)},D=d.Range.prototype.contains,E=k.Nb,F="number",G=h.CalcSource.prototype,G.referenceToArray=function(a,b,c,d,e,f,g,i){var j,k,l,m,p,r,s,t,u,v,w,x,y=this,z=1,A=1,B=[],C=a.getRangeCount();if(0===C)return B.isError=!0,B;for(s=y.getRowCount(),t=y.getColumnCount(),c=c===o||c,u=0;u=s||m>=t)return B=[n],B.rowCount=1,B.colCount=1,B.rangeCount=1,B;for(l+z>s&&(z=s-l),m+A>t&&(A=t-m),v=void 0,w=0;w0)for(d=0;d0&&(b=this.kj,b.Wq(d.Events.RangeChanged,{sheet:b,sheetName:b.name(),row:0,col:0,rowCount:b.getRowCount(),colCount:b.getColumnCount(),changedCells:a,action:6},b.vxb)),this.Iu=n,c=this.Bf.ug(!1),c&&c.clearListenersCache()},b.prototype.clearValueCache=function(){this.zLb()},b.prototype.zLb=function(){var a=this.getRowCount(),b=this.getColumnCount();this.Hu={rowCount:a,colCount:b,arrayInfo:[]},this.Iu=[]},b.prototype.getValue=function(a,b){var c,e,f,g,i,j,k,l,m,r,s,t,u=[];for(c=2;c=l?n:i>=m?n:(r=j[g],r||(r=j[g]={}),s=r[i],s||(s=r[i]={v:f.getValue(g,i)}),t=s[k],t===o&&(t=h.Convert.wf(s.v,b,!h.ExcelCompatibleCalcMode),s[k]=t),t=d.Ul.w0a(t))):g>=e.getRowCount()?n:i>=e.getColumnCount()?n:e.kj.getValue(g,i))},b.prototype.getIdentity=function(a,b){var c=this,d=b.row,e=b.rowCount||1,f=b.column,g=b.columnCount||1;return d===-1&&(d=0,e=c.getRowCount()),f===-1&&(f=0,g=c.getColumnCount()),c.getName()+"."+d+"."+e+"."+f+"."+g},b.prototype.getReference=function(a){var b,c,d,e,f,g,i=this,j=a.row,k=a.col;if(j===-1&&(a.row=0,a.rowCount=i.getRowCount()),k===-1&&(a.col=0,a.colCount=i.getColumnCount()),b=!1,a.spillRef)if(c=i.ALb().getAnchorCell(j,k))a.rowCount=c.rowCount,a.colCount=c.colCount,b=!c.isValid;else{if(d=i.getCalcSourceModel(),e=d.Qf(j,k))return e.row===j&&e.col===k?(a.rowCount=e.rowCount,a.colCount=e.colCount,new h.CalcReference(i,[a])):void 0;if(f=d.Kf(j,k),!f||33!==f.type)return;b=!0,a.rowCount=1,a.colCount=1}return g=new h.CalcReference(i,[a]),b&&(g.isSpillError=!0),g},b.prototype.getSources=function(a){var c,d,e,f,g;if(this.kj&&this.kj.parent&&this.kj.parent.sheets&&a instanceof b){for(c=this.kj.parent.sheets,d=!1,e=void 0,f=[],g=0;g=y||t>=z)return L=c?[n]:[[n]],L.rowCount=1,L.colCount=1,L.rangeCount=1,I.BLb(L);for(r+J>y&&(J=y-r),t+K>z&&(K=z-t),B=void 0,C=void 0,D=M.Ju,E=0;E=4&&(q=0!==(1&d),r=0!==(4&d),s=0!==(2&d),t=0!==(8&d),l-=q?b:0,o-=r?b:0,m-=s?c:0,p-=t?c:0),e&&(j=V(a,e,b),k=W(a,e,b),j&&k)?f=g.StructureReferenceResolver.create(e,j,k,a.col-e.dataRange().col,a.col+a.colCount-e.dataRange().col-1):(1===a.rowCount&&1===a.colCount?f=h.rf(n,n,l,m,q,s):(a.row<0&&(l=o=i.BAND_INDEX_CONST),a.col<0&&(m=p=i.BAND_INDEX_CONST),f=h.uf(n,n,l,m,o,p,q,s,r,t,b,c)),f)}b.rangeToExpression=U;function V(a,b,c){if(1===a.rowCount){if(b.hasHeadersRow()&&a.row===b.startRow())return 2;if(b.hasTotalsRow()&&a.row===b.endRow())return 8;if(c===a.row)return 1}else{if(b.hasHeadersRow()&&a.row===b.startRow()){if(a.rowCount===b.dataRange().rowCount+1)return 6;if(b.hasTotalsRow()&&a.rowCount===b.dataRange().rowCount+1+1)return 14}if(a.row===b.dataRange().row){if(a.rowCount===b.dataRange().rowCount)return 3;if(b.hasTotalsRow()&&a.rowCount===b.dataRange().rowCount+1)return 12}}return o}function W(a,b,c){return a.col===b.startColumn()&&a.colCount===b.dataRange().colCount?1:1===a.colCount?2:a.col>=b.startColumn()&&a.col+a.colCount-1<=b.endColumn()?4:o}function X(a,b,c,d,e){var f=U(a,b,c,d),g=new K(n,(!!e),h.pf(b,c)),i=new h.Parser,j=i.unparse(g,f);return g.no(),j}b.rangeToFormula=X;function Y(a,b,c,d,e,f,g){var i=U(b,c,d,e,g),j=new K(a,(!!f),h.pf(c,d)),k=new h.Parser;return k.unparse(j,i)}b.rangeToFormulaWithStructReference=Y;function Z(a,b,c,e){var f,g,h,i,j,k,l,m,n;if(!b)return null;if(c=c?c:0,e=e?e:0,f=a.Cf(),g=f.parse(a.yj(),b,c,e,!0,!0))if(h=g.source,h&&13===g.type);else if(1===g.type&&g.endSource){for(i=g.source,j=g.endSource,k=i.getSources(j),l=!1,m=0;m0?", "+i:i;return j}b.CLb=aa,b.RangeReferenceRelative={allAbsolute:0,startRowRelative:1,startColRelative:2,endRowRelative:4,endColRelative:8,rowRelative:5,colRelative:10,allRelative:15};function ba(a,b,c,d,e,g,h){var i,j,k,l,m=d.getValue(b,c),n=!1,o=100,p=.001,q=.01,r=(C(m)?+m:0)-h,s=d.getValue(e,g),u=(C(s)?+s:0)-h;if(C(s)&&Math.abs(u)=e||d>=f?n:{row:c,column:d,rowCount:e-c,columnCount:f-d,intersectWith:u}}r=function(){function a(a,b,c,d,e,f,g,h){var i=this;i.Rj=a,i.Vj=b,i.Wj=c,i.Qj=d,i.Tj=e,i.Uj=f,i.Xj=g,i.Yj=h}return a.prototype.Nj=function(){return this.Tj-this.Vj},a.prototype.Oj=function(){return this.Uj-this.Wj},a.prototype.Sj=function(a,b,c,d,e){var f=this;return f.Rj===a&&(f.Vj===-1||f.Vj<=b&&b+d<=f.Vj+f.Xj)&&(f.Wj===-1||f.Wj<=c&&c+e<=f.Wj+f.Yj)},a.prototype.Pj=function(a,b,c,d,e){var f=this;return f.Qj===a&&(f.Tj===-1||f.Tj<=b&&b+d<=f.Tj+f.Xj)&&(f.Uj===-1||f.Uj<=c&&c+e<=f.Uj+f.Yj)},a.prototype.intersectWith=function(a,b,c,d,e){var f,g,h=this;return h.Qj!==a?n:(f=h.Zj(a,b,c,d,e),g=h.Zj(a,h.Vj,h.Wj,d,e),g.intersectWith(f))},a.prototype.Zj=function(a,b,c,d,e){var f=b===-1?0:b,g=b===-1||d===-1?a.rowCount:d,h=c===-1?0:c,i=c===-1||e===-1?a.colCount:e;return{row:f,column:h,rowCount:g,columnCount:i,intersectWith:u}},a}(),b.MoveSwapInfo=r;function v(a,b,c,d){return(!d||a=q)||e.columnRelative&&(e.column+h<0||e.column+h>=r))return d.Hh(p,e.source);w=e.offset(0,0,!1)}else if(1===s){if(q=k((e.source||c).getRowCount(),f.MAX_ROW_COUNT),r=k((e.source||c).getColumnCount(),f.MAX_COLUMN_COUNT),t=e,t.rowRelative&&!e.isFullColumn&&(t.row+g<0||t.row+g>q)||t.columnRelative&&!e.isFullRow&&(t.column+h<0||t.column+h>r)||t.endRowRelative&&!e.isFullColumn&&(t.endRow+g<0||t.endRow+g>q)||t.endColumnRelative&&!e.isFullRow&&(t.endColumn+h<0||t.endColumn+h>r))return d.Hh(p,e.source,e.endSource);w=e.offset(0,0,!1,g,h)}else if(9===e.type)w=d.Kh(e.operatorType,y.call(x,b,c,e.value,g,h,i,j,l,m,n,o),e.value2&&y.call(x,b,c,e.value2,g,h,i,j,l,m,n,o));else if(7===s){if(u=[],e.arguments&&e.arguments.length>0)for(v=0;v0&&(D-=F),G=s-v,G0&&(E-=H),I=t-w,I3&&G.hasOwnProperty(B))for(;G[B];)D=G[B],E=D.ah,l=b.call(F,E,0,0,D.expression,a,c,d,e,f),E.setExpression(D.id,D.name,l),F.Fj(D,C)}},a.prototype.ph=function(a){var b=this,c=a.getCalcSourceModel(),d=a.getRowCount(),e=a.getColumnCount();ba(c,0,0,d,e),b.Hj(a,N),E(a,N,0,0,0,0,0,0,!0,!1),H(a,N,0,0,!0,!1)},a.prototype.Ej=function(a,b,c,d,e,f,g,h,i,j,k){var l,n,o,p,q,s,t,u,v,z,A,B,C,D,E,F,G,H,I,K,L,M,N=this,O=Z,P=new r(b,c,d,e,f,g,h,i),Q={};if(a&&$(a,P,j),J(b,P,j),t=N.imb,v={},t){for(;t[0];)if(n=t[0],l=n.ah,o=n.row,p=n.column,s=l.dUa(),y(Q,o,p))N.Fj(n,0);else{if(q=l.Kf(o,p),u=l.getSource(),q)if(z=m,k&&k[o+", "+p]&&(u=b,z={crossSheetMoved:!0}),q=O.call(N,u,o,p,q,P,j,z),A=l.Qf(o,p),B=void 0,A&&!A.isDynamicArray)if(B=w(A),o===A.row&&p===A.col)for(v[B]=!0,C=o;C3&&t.hasOwnProperty(H))for(;t[H];)K=t[H],L=K.ah,M=L.getSource(),q=O.call(N,M,0,0,K.expression,P,j),L.setExpression(K.id,K.name,q),N.Fj(K,I)}},a.prototype.Dj=function(a,b,c,d,e){var f,g,h,i,j,k=this,l=b+d,m=c+e;for(h=b;h=0||!e?(l=d+(e?c:0),m=f+(g?c:0),h===a&&(!k&&i+j<=c||k&&i<=c)&&(l-=e?j:0,m-=g?j:0),h===b&&(!k&&i<=l||k&&(e&&c+d>=i||!e&&d>=i)?(l+=j,m+=j):(!k&&i<=m||k&&(g&&c+f>=i||!g&&f>=i))&&(m+=j)),l-=e?c:0,m-=g?c:0,k&&i+j<=c&&(l+=e?j:0,m+=g?j:0),{index:l,endIndex:m}):{index:d,endIndex:f}}function A(a,b,c,e,f,g,h,i,j,k,l,m){if(b&&!m){var n=j?f.row:f.column,p=j?f.rowRelative:f.columnRelative,q=void 0;if(j&&c>=0||!j&&e>=0||!p){if(k)q=z(a,b,j?c:e,n,p,-1,!1,g,h,i,l).index;else if(q=K(a,b,j?c:e,n,p,g,h,i,l),o(q))return d.Hh(q);q!==n&&(f=f.offset(j?q-n:0,j?0:q-n,!0))}}return f}function B(a,b,c,e,f,g,h,i,j,k,l,m){var n,p,q,r,s,t,u,v;if(b&&!m){if(n=f.tf(),3===n||j&&2===n||!j&&1===n)return f;if(p=j?f.rowRelative:f.columnRelative,q=j?f.endRowRelative:f.endColumnRelative,r=j?f.row:f.column,s=j?f.endRow:f.endColumn,t=void 0,j&&c>=0||!j&&e>=0||!p||!q){if(k)t=z(a,b,j?c:e,r,p,s,q,g,h,i,l);else if(t=L(a,b,j?c:e,r,p,s,q,g,h,i,l),o(t))return d.Hh(t);u=t.index,v=t.endIndex,u===r&&v===s||(f=f.offset2(j?u-r:0,j?0:u-r,j?v-s:0,j?0:v-s,c,e))}}return f}function C(a,b,c,d,e,f,g,h,i){if(b){var j=e;if(j&&b===j.source)return j.offsetWhenInsertRemoveColumn(g,h,i)}return e}function D(a,b,c,e,f,g,h,i,j,k,l,o){var p,q,r,s,t,u,v,w,x=D,y=e;if(e){if(1===e.type&&e.sf()||33===e.type)y=A(a,e.source||a,b,c,e,f,g,h,i,j,l,o);else if(1===e.type)y=B(a,e.source||a,b,c,e,f,g,h,i,j,l,o);else if(10===e.type)p=x(a,b,c,e.value,f,g,h,i,j,m,l,o),p!==e.value&&(y=d.Lh(p));else if(9===e.type)q=x(a,b,c,e.value,f,g,h,i,j,m,l,o),r=e.value2&&x(a,b,c,e.value2,f,g,h,i,j,m,l,o),q===e.value&&r===e.value2||(y=d.Kh(e.operatorType,q,r));else if(7===e.type){for(s=n,t=void 0,u=void 0,v=e,w=v.arguments.length,u=0;ui?i:n),u!==-1&&(l=!1,o=o>j?j:o),l||m);q++);if(!(c&&m||!c&&l)&&(h=a[k].sheet,v=h.yj(),f=e.condition(),w=f.getExpressions(),w&&w.length>0)){ for(x=0;x0){for(o=0;o=0||!e){if(j=d+(e?c:0),f===a&&g<=c&&(j+=e?h:0),f===b)if(k=c+d,l=c+h+d,!i&&g+h<=j||i&&k>=g+h)j-=h;else if(!i&&g<=j||i&&k>=g&&g<=l&&l<=g+h)return p;return j-=e?c:0,i&&g<=c&&(j-=h),j}return d}function L(a,b,c,d,e,f,g,h,i,j,k){var l,m,n,o,q;if(c>=0||!e){if(l=d+(e?c:0),m=f+(g?c:0),n=i+j-1,h===a&&i<=c&&(l+=e?j:0,m+=g?j:0),h===b)if(o=c+d,q=c+f,!k&&n=m||k&&i<=o&&n>=q)return p;!k&&i>m||k&&i>q||(!k&&n<=m||k&&n<=q?(l=!k&&i>=l||k&&i>=o?l:i,m-=j):m=i-1)}return l-=e?c:0,m-=g?c:0,k&&i<=c&&(l-=j,m-=j),{index:l,endIndex:m}}return{index:d,endIndex:f}}function M(a,b,c){var e,f,g,h,i,k,l,o,p,q,r,s,t=M,u=b;if(b)if(b.source)h=b.source,(a!==c&&h===c||a===c&&h!==c)&&(u=d.Ih);else if(10===b.type)e=t(a,b.value,c),e!==b.value&&(u=d.Lh(e));else if(9===b.type)i=t(a,b.value,c),k=b.value2&&t(a,b.value2,c),i===b.value&&k===b.value2||(u=d.Kh(b.operatorType,i,k));else if(7===b.type){for(l=n,o=b.arguments.length,g=0;g=0||!q)&&(c>=0||!r)){if(h=e.row+(q?b:0),i=e.column+(r?c:0),g&&g.isNameID||a===f.Rj&&(a===f.Qj?k=f.Pj(f.Qj,b,c,1,1):(l=b,m=c,g&&g.crossSheetMoved&&(l-=s,m-=t),k=f.Sj(f.Rj,l,m,1,1))),p===f.Qj&&f.Pj(p,h,i,1,1)&&!f.Sj(p,h,i,1,1)&&(!q&&!r||!k))return d.Ih;if(j=(o&&p===f.Rj||!o&&a===f.Rj)&&(!k&&f.Sj(f.Rj,h,i,1,1)||k&&f.Pj(f.Qj,q?h:h+s,r?i:i+t,1,1)),k&&(h-=q?s:0,i-=r?t:0),j&&(h+=s,i+=t),h-=q?b:0,i-=r?c:0,p=e.source,f.Rj!==f.Qj&&(j&&k?o&&(p=f.Qj):j?p=f.Qj:k&&!o&&(p=f.Rj)),h!==e.row||i!==e.column||p!==e.source)return P(p,n,h,i,q,r,u,v)}else if((b>=0||!q)&&c===-1){if(h=e.row+(q?b:0),f.Pj(a,b,c,1,1)&&(h-=q?s:0),f.Sj(p,h,-1,1,-1))h+=s;else if(f.Pj(p,h,-1,1,-1))return d.Ih;if(h-=q?b:0,h!==e.row)return P(e.source,n,h,e.column,q,e.columnRelative,u,v)}else if(b===-1&&c>=0&&!r){if(i=e.column+(r?c:0),f.Pj(a,b,c,1,1)&&(i-=r?t:0),f.Sj(p,h,i,1,1))i+=t;else if(f.Pj(p,h,i,1,1))return d.Ih;if(i-=r?c:0,h!==e.row||i!==e.column)return P(e.source,e.endSource,e.row,i,e.rowRelative,r,u,v)}return e}function R(a,b){if(b=a.getIntersect(b,0,0),!b)return n;var c=a.row,d=a.col,e=a.rowCount,f=a.colCount;return a.rowCount===b.rowCount&&a.colCount===b.colCount||(a.rowCount===b.rowCount?(a.col===b.col&&(d=a.col+b.colCount),f=a.colCount-b.colCount):a.colCount===b.colCount&&(a.row===b.row&&(c=a.row+b.rowCount),e=a.rowCount-b.rowCount)),h.kf(c,d,e,f)}function S(a,b,c,d,e){var f,g;return!(!b||!a)&&(f=b.getIntersect(a,0,0),!(f||!(g=b.getIntersect(c,0,0)))||(!(!f||f.rowCount!==b.rowCount||0===e)||!(!f||f.colCount!==b.colCount||0===d)))}function T(a,b,c){var d=a.getRange(b,c);return h.kf(d.row,d.col,d.rowCount,d.colCount)}function U(a,b,c){var d,e=R(a,b);return d=e?e.union(c):c,{startRow:d.row,endRow:d.row+d.rowCount-1,startColumn:d.col,endColumn:d.col+d.colCount-1}}function V(a,b,c,d,e){var f,g=R(a,b),h=a.getIntersect(b,0,0);return h?(h.row+=d,h.col+=e,f=g?g.union(h):c,{startRow:f.row,endRow:f.row+f.rowCount-1,startColumn:f.col,endColumn:f.col+f.colCount-1}):n}function W(a,b){var c=a.row,d=a.col,e=a.rowCount,f=a.colCount,g=b.row,h=b.col,i=b.rowCount,j=b.colCount;return 1===e&&1!==f?h=q&&m<=r,k=n>=q&&n<=r,j&&k)m+=b,n+=b;else if(j&&!k)if(b<=0)m+=b;else if(q+b>n);else{if(!(r+b=0)n+=b;else if(r+bm))return V(l,w,x,b,c);if(r===n)return U(l,w,x);n+=b}else y&&!y.equals(x)&&W(l,x)&&(g=R(l,y),m=g.row,n=g.row+g.rowCount-1,o=g.col,p=g.col+g.colCount-1);else if(j=o>=s&&o<=t,k=p>=s&&p<=t,j&&k)o+=c,p+=c;else if(j&&!k)if(c<0)o+=c;else if(s+c>p);else{if(!(t+c0)p+=c;else if(t+co))return V(l,w,x,b,c);if(t===p)return U(l,w,x);p+=c}else y&&!y.equals(x)&&W(l,x)&&(g=R(l,y),m=g.row,n=g.row+g.rowCount-1,o=g.col,p=g.col+g.colCount-1);return{startRow:m,endRow:n,startColumn:o,endColumn:p}}function Y(a,b,c,e,g,h){var i,j,k,l,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,P,Q,R=!!e.source,S=R?e.source:a,T=e.tf(),U=g.Nj(),V=g.Oj(),W=h&&h.isDataValidator,Y=O(g,a);if(0===T)if(i=e.rowRelative,j=e.columnRelative,k=e.endRowRelative,l=e.endColumnRelative,b>=0||!i||!k||c>=0||!j||!l){if(o=e.row+(i?b:0),p=e.endRow+(k?b:0),q=e.column+(j?c:0),r=e.endColumn+(l?c:0),s=p-o+1,t=r-q+1,!W&&Y)return C=g.Sj(g.Rj,o,q,s,t),C?e.offset(U,V,!0):g.Pj(S,o,q,s,t)?d.Ih:e;if(h&&h.isNameID||a===g.Rj&&(a===g.Qj?B=g.Pj(g.Qj,b,c,1,1):(D=b,E=c,h&&h.crossSheetMoved&&(D-=U,E-=V),B=g.Sj(g.Rj,D,E,1,1))),a===S&&a===g.Rj&&a===g.Qj&&(F=b,G=c,B&&(F-=U,G-=V),0===U||0===V)){if(H=X(g,U,V,e,F,G),!H)return d.Ih;if(0===V&&U&&H.endColumn>=r&&H.startColumn<=q||0===U&&V&&H.endRow>=p&&H.startRow<=o)return I=H.startRow,J=H.startColumn,K=H.endRow,L=H.endColumn,I===o&&K===p&&J===q&&L===r?e:(i&&(I-=b),k&&(K-=b),j&&(J-=c),l&&(L-=c),d.uf(e.source,n,I,J,K,L,i,j,k,l,b,c))}if(B&&(M=g.Tj-g.Vj,N=g.Uj-g.Wj,s+=(i?-M:0)+(k?M:0),t+=(j?-N:0)+(l?N:0)),S===g.Qj&&g.Pj(S,o,q,s,t)&&!t&&(!i&&!j&&!k&&!l||!B))return d.Ih;if(A=(R&&S===g.Rj||!R&&a===g.Rj)&&(!B&&g.Sj(g.Rj,o,q,s,t)||B&&g.Pj(g.Qj,i?o:o+U,j?q:q+V,s,t)),B&&(w=i?U:0,x=k?U:0,y=j?V:0,z=l?V:0,o-=w,p-=x,q-=y,r-=z),P=!1,A)u=U,v=V,o+=u,p+=u,q+=v,r+=v;else if(g.Pj(S,o,q,s,t)){if(Q=g.intersectWith(S,o,q,s,t),!Q||Q.rowCount!==s&&Q.colCount!==t)return d.Ih;o=Q.row+U,q=Q.col+V,p=o+Q.rowCount,r=q+Q.colCount,P=!0}if(o-=i?b:0,p-=k?b:0,q-=j?c:0,r-=l?c:0,g.Rj===g.Qj?S=R?e.source:m:(S=e.source,A&&B&&R?S=g.Qj:A&&B||(A?S=g.Qj:B&&!R&&(S=g.Rj))),o!==e.row||q!==e.column||p!==e.endRow||r!==e.endColumn||P||S!==e.source)return d.uf(S,n,o,q,p,r,i,j,k,l,b,c)}else if(!(b>=0)&&i&&k||c!==-1){if(b===-1&&(c>=0||!j||!l)){if(q=e.column+(j?c:0),r=e.endColumn+(l?c:0),q>r)return d.Ih;if(g.Pj(a,b,c,1,1)&&(y=j?V:0,z=l?V:0,q-=y,r-=z),t=r-q,g.Sj(S,-1,q,-1,t))v=V,q+=v,r+=v;else if(g.Pj(S,-1,q,-1,t))return d.Ih;if(q-=j?c:0,r-=l?c:0,q!==e.column||r!==e.endColumn)return d.uf(e.source,n,e.row,q,e.endRow,r,e.rowRelative,j,e.endRowRelative,l,b,c)}}else{if(o=e.row+(i?b:0),p=e.endRow+(k?b:0),o>p)return d.Ih;if(g.Pj(a,b,c,1,1)&&(w=i?U:0,x=k?U:0,o-=w,p-=x),s=p-o,g.Sj(S,o,-1,s,-1))u=U,o+=u,p+=u;else if(g.Pj(S,o,-1,s,-1))return d.Ih;if(o-=i?b:0,p-=k?b:0,o!==e.row||p!==e.endRow)return d.uf(e.source,n,o,e.column,p,e.endColumn,i,e.columnRelative,k,e.endColumnRelative,b,c)}else if(1===T){if(i=e.rowRelative,k=e.endRowRelative,b>=0||!i||!k){if(o=e.row+(i?b:0),p=e.endRow+(k?b:0),o>p)return d.Ih;if(g.Pj(a,b,c,1,1)&&(w=i?U:0,x=k?U:0,o-=w,p-=x),s=p-o,g.Sj(S,o,-1,s,-1))u=U,o+=u,p+=u;else if(g.Pj(S,o,-1,s,-1))return d.Ih;if(o-=i?b:0,p-=k?b:0,o!==e.row||p!==e.endRow)return d.uf(e.source,e.endSource,o,f.BAND_INDEX_CONST,p,f.BAND_INDEX_CONST,i,!1,k,!1,b,c)}}else if(2===T){if(j=e.columnRelative,l=e.endColumnRelative,q=e.column+(j?c:0),r=e.endColumn+(l?c:0),q0){for(n=0;n=0||!i)&&(c>=0||!j)){if(f=d.row+(i?b:0),g=d.column+(j?c:0),e.Pj(a,b,c,1,1)?(f-=i?k:0,g-=j?l:0):e.Sj(a,f,g,1,1)&&(f+=i?k:0,g+=j?l:0),e.Sj(h,f,g,1,1)?(f+=k,g+=l):e.Pj(h,f,g,1,1)&&(f-=k,g-=l),f-=i?b:0,g-=j?c:0,f!==d.row||g!==d.column)return P(d.source,n,f,g,i,j,m,o)}else if((b>=0||!i)&&c===-1){if(f=d.row+(i?b:0),e.Pj(a,b,-1,1,-1)?f-=i?k:0:e.Sj(a,f,-1,1,-1)&&(f+=i?k:0),e.Sj(h,f,-1,1,-1)?f+=k:e.Pj(h,f,-1,1,-1)&&(f-=k),f-=i?b:0,f!==d.row||g!==d.column)return P(d.source,n,f,d.column,i,d.columnRelative,m,o)}else if(b===-1&&c>=0&&!j&&(g=d.column+0,e.Pj(a,-1,c,-1,1)?g-=0:e.Sj(a,-1,g,-1,1)&&(g+=0),e.Sj(h,-1,g,-1,1)?g+=l:e.Pj(h,-1,g,-1,1)&&(g-=l),g-=0,f!==d.row||g!==d.column))return P(d.source,n,d.row,g,d.rowRelative,j,m,o);return d}function aa(a,b,c,e,g){var h,i,j,k,l,m,o,p,q,r,s,t,u,v,w,x,y=e.source||a,z=e.tf(),A=g.Nj(),B=g.Oj();if(0===z){if(o=e.rowRelative,p=e.columnRelative,q=e.endRowRelative,r=e.endColumnRelative,!(b>=0)&&o&&q||!(c>=0)&&p&&r)if(!(b>=0)&&o&&q||c!==-1){if(b===-1&&(c>=0||!p||!r)){if(j=e.column+(p?c:0),k=e.endColumn+(r?c:0),j=0||!o||!q){if(h=e.row+(o?b:0),i=e.endRow+(q?b:0),hk)return d.Ih;if(g.Pj(a,-1,c,-1,1)?(v=p?B:0,x=r?B:0,j-=v,k-=x):g.Sj(a,-1,c,-1,1)&&(v=p?B:0,x=r?B:0,j+=v,k+=x),m=k-j,g.Sj(y,-1,j,-1,m)?(t=B,j+=t,k+=t):g.Pj(y,-1,j,-1,m)&&(t=B,j-=t,k-=t),j-=p?c:0,k-=r?c:0,j!==e.column||k!==e.endColumn)return d.uf(e.source,n,f.BAND_INDEX_CONST,j,f.BAND_INDEX_CONST,k,!1,p,!1,r,b,c)}return e}function ba(a,b,c,d,e,f){a._g(b,c,d,e,!0,!1,f)}function ca(a,b,c){var e,f,g,h,i,j,k,l=ca,o=b;if(8===b.type){if(b.value===c&&(!b.source||b.source===a.getSource()))return d.Hh(p,b.source)}else if(10===b.type)e=l(a,b.value,c),e!==b.value&&(o=d.Lh(e));else if(9===b.type)h=l(a,b.value,c),i=b.value2&&l(a,b.value2,c),h===b.value&&i===b.value2||(o=d.Kh(b.operatorType,h,i));else if(7===b.type){for(j=n,k=b.arguments.length,g=0;gb?a%c:a}function C(a){return new f.ErrorSource(a)}function D(a,b,c,d,e,f,g){return 3===g||c>=0&&d>=0||1===g&&c>=0||2===g&&d>=0}function E(a,b,c,d){var e,g,i=h.BAND_INDEX_CONST,j={cj:i,dj:i,ej:!0,fj:!0,gj:!1,li:0,Vka:!0},k=b?I(a,c,d,0):H(a,0);return k.hj?(j.cj=k.ij,j.ej=k.jj):(j.dj=k.ij,j.fj=k.jj),j.li=k.li,j.gj=k.gj,!k.gj||k.li>=a.length?j:!b&&k.hj||b&&!k.hj?{gj:!1}:(e=a[j.li],!b&&(f.isNumber(e)||"$"===e)||b&&("C"===e||"c"===e)?(g=b?I(a,c,d,j.li):H(a,j.li),j.li=g.li,!g.gj||!b&&!g.hj||b&&g.hj?(j.gj=!1,j):(g.ELb&&(j.ELb=!0),j.li=q)return p;if("$"===a[c]&&(p.jj=!1,c++),c>=q)return p;if(d=c,e=0,g=a[d],h=!1,f.isNumber(g)&&"0"!==g){for(p.hj=!0;d7)return p;for(i=d-1,j=0;i>=c;i--,j++)e+=(a[i].charCodeAt(0)-48)*r[j];if(e<=b.maxRowCount)return p.ij=e-1,p.li=h?q:d,p.ELb=h,p.gj=!0,p}else if(f.ei(g)){for(p.hj=!1;d3)return p;if(G(d,a,q))return p;for(e=0,l=d-1,m=l;m>=c;m--){if(o=a[m].charCodeAt(0),!(o>=65&&o<=90||o>=97&&o<=122))return p;e+=((32|o)-96)*n[l-m]}if(e<=b.maxColumnCount)return p.ij=e-1,p.li=d,p.gj=!0,p}return p}function I(a,c,d,e){var g,i,j,k,l,m=h.BAND_INDEX_CONST,n={li:e,ij:m,hj:!0,jj:!1,gj:!1},o=a.length;if(e>=o)return n;if(g=e,i=a[g],"R"===i||"r"===i)n.hj=!0,j=c;else{if("C"!==i&&"c"!==i)return n;n.hj=!1,j=d}if(e++,g++,e>=o)return n.li=e,n.ij=j,n.jj=!0,n.gj=!0,n;if(i=a[g],"["===i&&(e++,g++,n.jj=!0),e>=o)return n;if(k=!1,i=a[g],n.jj&&"-"===i&&(e++,g++,k=!0),e>=o)return n;if(i=a[g],!f.isNumber(i))return n.jj?n:(n.li=e,n.ij=j,n.jj=!0,n.gj=!0,n);for(;g=o||"]"!==a[g])return n;g++}return l<(n.hj?b.maxRowCount:b.maxColumnCount)?(n.jj?(l=k?-l:l,n.ij=l+j):n.ij=l-1,n.li=g,n.gj=!0,n):void 0}s=[{prefix:"ANCHORARRAY(",surfix:")"},{prefix:"",surfix:"#"}];function J(a,b,c,d){var e,g,h,i,j,k,l=a.row||0,m=a.column||0,n=a.Eh;if(c.source===f.BangSource)d.push("!");else if(c.source&&(e=M(a,d,c.source,c.endSource),!e))return void d.push("#","R","E","F","!");if(g=c.type,h=33===g,8===g||5===g)d.push(""+c.value);else if(c.value&&c._error)d.push(""+c.value);else if(h||c.sf()){if(i=void 0,j=void 0,k=void 0,h&&(i=s[n?0:1],j=i.prefix,k=i.surfix,d.push(j),c.isReferenceError))return d.push("#REF!"),void d.push(k);K(a.useR1C1,l,m,c.row,c.column,c.rowRelative,c.columnRelative,d),h&&d.push(k)}else L(a.source,a.useR1C1,l,m,c.row,c.column,c.endRow,c.endColumn,c.rowRelative,c.columnRelative,c.endRowRelative,c.endColumnRelative,d,c.tf())}function K(a,c,d,e,g,h,i,j,k){var l,m;if(k=k||0,l=b.maxRowCount-1,(0===k||1===k)&&e>-l&&e<=2*l&&(e+=h?c:0,e=B(e,l)),m=b.maxColumnCount-1,(0===k||2===k)&&g>-m&&g<=2*m&&(g+=i?d:0,g=B(g,m)),!D(c,d,e,g,h,i,k))return void j.push(""+f.Errors.Reference);if(a){if(2!==k&&(j.push("R"),e>=0&&(c!==e||!h)&&(h?j.push("["+(e-c)+"]"):(e++,j.push(e+""))),g<0))return;1!==k&&(j.push("C"),d===g&&i||(i?j.push("["+(g-d)+"]"):(g++,j.push(g+""))))}else{if(g>=0&&(i||j.push("$"),j.push.apply(j,A(g))),e<0)return;e++,h||j.push("$"),j.push(e+"")}}function L(a,c,d,e,f,g,i,j,k,l,m,n,o,p){p=p||0,3===p&&(f=0,i=a?a.getRowCount():b.maxRowCount-1,p=1),K(c,d,e,f,g,k,l,o,p);var q=h.BAND_INDEX_CONST;(!c||f!==i||g!==j||i!==q&&j!==q)&&(i===q&&j===q||(o.push(":"),K(c,d,e,i,j,m,n,o,p)))}function M(a,b,c,d){if(a.getExternalSourceToken){if(c!==f.BangSource){var e=N(a,a.getExternalSourceToken(c).split(""),d&&a.getExternalSourceToken(d).split(""));if(!(e.length>0))return!1;b.push.apply(b,e)}return b.push("!"),!0}return!1}function N(a,b,c){if(!b||0===b.length||O(a,b)||O(a,c))return[];var d=b,e;if(R(b,!1)||c&&R(c,!1)){for(d=["'"],e=0;ec}function P(a,b){var c,d,e;if(!a||0===a.length)return!0;if(!b){if(f.isNumber(a[0]))return!1;if(c=S(a),c.gj&&c.li<=a.length)return!1}for(e=0;e=a.length-1||"'"!==a[d+1]))return!1}else if("'"===c||"["===c||"]"===c||"?"===c||"%"===c||f.operaterTypesMap[c])return!1;return!0}function R(a,b){var c,d,e;return!!f.isDigit(+a[0])||(c=[],d=a,"["===a[0]&&(e=a.lastIndexOf("]"),e>0&&(c=a.slice(1,e),d=a.slice(e+1))),!Q(c)||!P(d,b))}function S(a){var b=E(a,!1,0,0);return b.gj||(b=E(a,!0,0,0)),b}function T(a){var b=new f.Expression(8);return b.value=a,b}function U(a){var b=a;return a&&a.length>=3&&"["===a[0]&&"0"===a[1]&&"]"===a[2]&&(b=3===a.length?"":a.substring(3)),b}t=function(a){z(b,a);function b(b){var c=a.call(this,8e3)||this;return c.kj=b,c}return b.prototype.resolveToken=function(a,b,c,d){var e,g,i,j,k,l,m,n,o,q,r,s,t,u,v,w,x,y=a.useR1C1,z=a.row||0,A=a.column||0,B=c.length,D=c[d],F=D.ni,G=D.Nc,H=D.hi;if(0!==G&&6!==H)return!1;if(0===G&&0===H&&d0?(m=F.indexOf(":"),k=F.substring(1,m-1),l=F.substring(m+1,F.length-2)):(k=F,"'"===k.charAt(0)&&(k=k.substring(1,k.length-1)),0===H&&(l=c[d+2].ni,"'"===l.charAt(0)&&(l=l.substring(1,l.length-1))))),d++,j=!!k,k=U(k),k&&(g=F?a.getExternalSource("",k):f.BangSource,g=g||C(k),l=U(l),l&&(i=a.getExternalSource("",l),i=i||C(l),d+=2)),D=c[d],!D)return T(F);F=D.ni}if(n=d===B-1?p:c[d+1],V(c,D,d,y,!0)){if(o=E(D.Qb,y,z,A),!o.gj&&!j)return!1;if(D.hi=7,o.gj&&o.Vka){if(q=o.cj,r=o.dj,s=o.ej,t=o.fj,u=o.ELb,da.endRow()&&c+e>a.endColumn()}w=function(a){z(b,a);function b(){return a.call(this,13)||this}return b.prototype.tableName=function(){return this.lj.tableName()},Object.defineProperty(b.prototype,"baseTable",{get:function(){return this.lj},set:function(a){this.lj=a,this.source=a.source()},enumerable:!0,configurable:!0}),b.prototype.JUa=function(){this.vzb=this.lj.startColumn()},b.prototype.columnReferenceStart=function(){return this.oj+this.lj.startColumn()},b.prototype.columnReferenceEnd=function(){return this.pj+this.lj.startColumn()},b.prototype.referencePortions=function(){return this.qj},b.prototype.referenceColumnSpecifier=function(){return this.rj},b.prototype.getRange=function(a,b,c){var d,e,g,h,i,j,k,l,m,n,o,q=this,r=q.lj;switch(q.JUa(),k=r.startRow(),l=r.endRow(),m=r.hasTotalsRow(),n=r.hasHeadersRow(),q.qj){case 3:case 16:d=n?k+1:k,g=m?l-1:l;break;case 2:if(n)d=k,g=k;else{if(!c)return p;d=k-1,g=k-1}break;case 8:if(m)d=l,g=l;else{if(!c)return p;d=l+1,g=l+1}break;case 1:d=a,g=a;break;case 6:d=k+(c&&!n?-1:0),g=m?l-1:l;break;case 12:d=n?k+1:k,g=l+(c&&!m?1:0);break;case 14:default:d=k+(c&&!n?-1:0),g=l+(c&&!m?1:0)}return e=q.columnReferenceStart(),h=q.columnReferenceEnd(),o=r.endColumn(),1===q.rj&&(h=o),e>o||h>o?(q._error=!0,p):gl?p:(i=g-d+1,j=h-e+1,f.qf(d,e,i,j))},b.prototype.offsetWhenInsertRemoveColumn=function(a,c,d){var e,g,h=this,i=h.vzb;return ah.pj+i?h:(c=d?c:-c,e=a-i,g=new b,g.baseTable=h.lj,g.pj=h.pj+c,g.oj=h.oj,a<=i+h.oj&&(g.oj+=c,g.oj=c.startRow()&&b>=c.startColumn()&&a<=c.endRow()&&b<=c.endColumn()},b.prototype.tzb=function(a,b,c){this.lj.wzb(a,b,c)},b}(f.Expression),b.xzb=w,x=function(a){z(b,a);function b(b){var c=a.call(this,7900)||this;return c.kj=b,c}return b.prototype.resolveToken=function(a,c,d,e){var f,g,h,i=d[e];if(0===i.Nc&&(0===i.hi||7===i.hi))if(f=i.ni,"]"===f.charAt(f.length-1))try{return g=new w,X(a,f.split(""),g),g}catch(a){}else if(h=a.getTableByName&&a.getTableByName(f))return b.create(h);return p},b.prototype.unparse=function(a,b,c,d){var e,g,h,i,j,k,l,m,n;return 13===c.type&&(e=c,a.YSa?(g=e.getRange(a.row,a.column,!0),h=f.uf(e.source,p,g.row,g.col,g.row+g.rowCount-1,g.col+g.colCount-1,!1,!1,!1,!1),J(a,b,h,d),!0):16===e.qj&&1===e.rj?(d.push(e.lj.tableName()),void(a.Eh&&d.push("[]"))):(j=d.length,k=a.source===e.lj.source()&&e.Kma(a.row,a.column),k&&!a.Eh||d.push(e.lj.tableName()),d.push("["),16!==e.qj&&(l=ja(e.qj,1!==e.rj,a.Eh),d.push(l)),1!==e.rj&&(1===e.qj&&!a.Eh||16===e.qj||d.push(", "),m=e.lj.getColumnName(e.oj),m?m=ca(m.split("")).join(""):i=!0,i||(4===e.rj?(n=e.lj.getColumnName(e.pj),n?(n=ca(n.split("")).join(""),d.push("[",m,"]:[",n,"]")):i=!0):1===e.qj&&!a.Eh&&!da(m)||16===e.qj?d.push(m):d.push("[",m,"]"))),i?(d.length=j,d.push("#REF!")):d.push("]"),!0))},b.create=function(a,b,c,d,e){void 0===b&&(b=u.NotSpecific),void 0===c&&(c=v.NotSpecific),void 0===d&&(d=0),void 0===e&&(e=a.endColumn()-a.startColumn());var f=new w;return f.baseTable=a,f.qj=b,f.oj=d,f.pj=e,f.rj=c,f},b}(f.TokenResolver),b.StructureReferenceResolver=x;function X(a,b,c){var d,e,f,g,h,i,j,k,l,m=c,n=0,o=b[n],p=ha(a,b,n,o),q=p.sj;for(q||ia(),m.baseTable=q,n=p.tj,n++,o=b[n],d=n;" "===o;)n++,o=b[n];for("@"!==o&&"["!==o&&(n=d,o=b[n]),e=1,f=!1,g=!1,h=b.length;0!==e&&n1||f)&&ia(),f=!0,m.qj=1,n++,o=b[n];" "===o;)n++,o=b[n];","===o&&ia()}else{for(k=n;"]"!==o&&"["!==o;)if("'"===o&&n++,","===o){for(n++,o=b[n],l=n;" "===o;)n++,o=b[n];if("["===o){n=l,o=",";break}}else n++,o=b[n];if(n>k&&((g||"["===o&&e>1)&&ia(),i=Z(m,b,n,o,e,k),n=i.tj,o=i.uj,e=i.wj,g=!0),"]"===o){if(e--,0===e)break;n>=b.length&&ia(),n++,o=b[n]}","===o&&(n++,o=b[n])}f||(m.qj=a.FLb?1:16),g||(m.oj=0,m.pj=m.lj.endColumn()-m.lj.startColumn(),m.rj=1)}function Y(a,b,c){return a.slice(b,c).join("")}function Z(a,b,c,d,e,f){var g,h,i,j,k,l,m=a,n=[],p="",q=!1,r=!1;if(e>1)q=!0,e--,n=b.slice(f,c),c++,d=b[c],":"===d&&(c++,d=b[c],r="["===d,h=ea(b,c,d,e),p=h.xj,c=h.tj,d=h.uj,e=h.wj);else if("["===d){for(r=!0,g=c-1,d=b[g];" "===d;)g--,d=b[g];":"!==d&&ia(),n=b.slice(f,g),n=$(n),d=b[c],h=ea(b,c,d,e),p=h.xj,c=h.tj,d=h.uj,e=h.wj}else m.qj!==o&&16!==m.qj||(q=!0),i=b.slice(f,c),g=i.indexOf(":"),g>0?(n=i.slice(0,g),p=i.slice(g+1),"["!==p[0]&&ia()):n=i;if(j=aa(m,n,q),p?(k=aa(m,p,r),m.rj=4):(k=j,m.rj=2),j>k&&(l=j,j=k,k=l),m.oj=j,m.pj=k,c++,c=0&&" "===a[b];)b--;for(;b>=0&&" "!==a[b];)b--;return b>=0?a.slice(b+1,a.length-b-1):a}function _(a){for(var b=0,c=a.length,d=0;bd&&" "===a[b];)b++;return b>=d?a.slice(d,b+1):a}function aa(a,b,c){var d,e,f,g;if(b&&ba(b,c)){for(d=[],e=0,f=b.length;e1);)"'"===c&&b++,b++,c=a[b];return b<=e&&ia(),f=a.slice(e,b),d>1&&d--,g||(f=_(f)),{xj:f,tj:b,uj:c,wj:d}}y={"#all":14,"#data":3,"#headers":2,"#totals":8,"#this row":1};function fa(a){var b,c=f.getMapping()&&f.getMapping().tableFunctionsMapping;if(!i.isNullOrUndefined(c))for(b in c)if(c[b].toLowerCase()===a)return b.toLowerCase();return a}function ga(a,b,c,d){for(var e,f,g,h,i=14,j=b;"]"!==c;)"'"===c&&b++,b++,c=a[b];for(e=Y(a,j,b).toLowerCase().trim(),e=fa(e),f=!1,g=0;g=a.length)d--;else{for(c=a[b];" "===c;)b++,c=a[b];if(","===c){for(d<=1&&ia(),b++,c=a[b];" "===c;)b++,c=a[b];for("["===c&&(d++,b++,c=a[b]);" "===c;)b++,c=a[b]}d>1&&d--}return{vj:i,tj:b,uj:c,wj:d}}function ha(a,b,c,d){for(var e,f,g=0,h=b.length;"["!==d&&c0?(f=Y(b,0,g),e=a.getTableByName(f)):e=a.getTableByIndex(a.row,a.column),{sj:e,tj:c,uj:d}}function ia(){throw l().Exp_FormulaInvalid}function ja(a,b,c){var d=f.getMapping()&&f.getMapping().tableFunctionsMapping,e=f.sR().B2,g=d?d["#All"]:e.All.name,h=d?d["#This row"]:e.thisRow.name,i=d?d["#Headers"]:e.Headers.name,j=d?d["#Data"]:e.Data.name,k=d?d["#Totals"]:e.Totals.name;switch(a){case 1:return c?"["+h+"]":"@";case 2:return b?"["+i+"]":i;case 3:return b?"["+j+"]":j;case 8:return b?"["+k+"]":k;case 6:return"["+i+"], ["+j+"]";case 12:return"["+j+"], ["+k+"]";case 14:case 16:}return b?"["+g+"]":g}function ka(a,b){var c,d,e,g,h,i,j,k,l,m,n=0;for(a.unshift(new f.FormulaToken("=",1,0,0,0)),g=[],h=0,e=a.length-1;e>0;e--)a[e].mi===a[e-1].mi&&a[e].ni===a[e-1].ni||(g[h]=a[e],h++);for(g[h]=a[e],g.reverse(),i=[],j=0,k=0;k0&&(c=new f.FormulaToken(b.slice(g[k].mi+d,g[k+1].mi),7,g[k].mi+d),++j,i[j]=c);for(i[j]=g[k],d=la(i[j]),i.length>0&&b.length>i[j].mi+d&&(c=new f.FormulaToken(b.slice(i[j].mi+d,b.length),7,i[j].mi+d),i[j+1]=c),l=0;l=2&&a.type<=6);else if(1===a.type)h=a.getRange(e,g),!d.source||a.source&&a.source!==d.source||b.push(h),ma(c,a.source||d.source,h);else if(13===a.type)h=a.getRange(e,g),a.source===d.source&&h&&b.push(h),ma(c,a.source||d.source,h);else if(8===a.type)j=p, a.source?a.source.Cf()&&(j=new f.EvaluateContext(a.source,f.pf(e,g))):j=d,na(j.getName(a.value),b,c,j,e,g);else if(9===a.type)na(a.value,b,c,d,e,g),a.value2&&na(a.value2,b,c,d,e,g);else if(7===a.type)for(k=0;k0){for(r=0;r0?k.push({text:w,type:0,subType:7,canDrag:q,ranges:x,value:w,sheetRanges:y}):k.push({text:w,type:l.Nc,subType:l.hi,canDrag:q,ranges:x,value:w,sheetRanges:y})}}else k.push({text:l.ni,type:l.Nc,subType:l.hi,canDrag:!1,ranges:l.ranges,value:l.ni})}catch(a){k.push({text:l.ni,type:l.Nc,subType:l.hi,canDrag:!1,ranges:l.ranges,value:l.ni})}return k}function qa(a,b,c,d,e){var f,g,h,i,j,k,l=c[d];return l&&"function"!=typeof l&&0===l.Nc?(f=[],g=a.resolveToken(b,c,f,d)-1,h=f[0],i=h.type,1===i||13===i||33===i||8===i||5===i&&h.source?(j=c[g],k={mi:l.mi,li:j.li,Lf:h},e.push(k),g):d):d}},"./dist/plugins/sheetsCalc/sheetsCalc.entry.js":function(a,b,c){"use strict";function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,"__esModule",{value:!0}),d(c("./dist/plugins/sheetsCalc/calc.ns.js")),d(c("./dist/plugins/sheetsCalc/parser-sheets.js")),d(c("./dist/plugins/sheetsCalc/calc-spreadjs.js")),d(c("./dist/plugins/sheetsCalc/formulaOperatorAdjustor.js")),d(c("./dist/plugins/sheetsCalc/worksheet-formula.js")),c("./dist/plugins/sheetsCalc/workbook-formula.js")},"./dist/plugins/sheetsCalc/workbook-formula.js":function(a,b,c){"use strict";var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;Object.defineProperty(b,"__esModule",{value:!0}),d=c("Core"),e=c("Core"),f=c("Common"),g=c("CalcEngine"),h=c("./dist/plugins/sheetsCalc/calc-spreadjs.js"),i=c("./dist/plugins/sheetsCalc/calc-spreadjs.js"),j=h.SpreadSource,k=f.Common.u.Nb,l=new f.Common.ResourceManager(d.SR),m=l.getResource.bind(l),n=void 0,o=null,p=f.Common.j,q=p.Fa,r=d.Workbook.prototype,r.qv=function(a){var b=this,c=b.Wu;b.Wu=new g.CalcService,a&&c&&b.Wu.cloneFrom(c),b.yv=new j(b),b.zv=b.Wu.getGlobalSourceModel(b.yv)},r.addCustomFunction=function(a){this.Xu(a)},r.Xu=function(a){if(!(a&&a instanceof g.Functions.Function))throw Error(m().Exp_InvalidCustomFunction);this.Su[k(a.name)]=a},r.getCustomFunction=function(a){return a?this.Su[k(a)]:n},r.removeCustomFunction=function(a){a&&(delete this.Su[k(a)],this.iK())},r.clearCustomFunctions=function(){this.Su={}},r.addCustomName=function(a,b,c,d,e){this.Yu(this.Tu,a,b,c,d,!1,e)},r.H$a=function(a){return!this.Tu[k(a)]},r.isValidCustomName=function(a){return a&&d.Ul.G$a(a)&&this.H$a(a)},r.Yu=function(a,b,c,d,e,f,g){var h,j,l,n,p=this;if(!b||!c||!f&&!p.isValidCustomName(b))throw Error(m().Exp_InvalidCustomName);if(p.Wu){if(h=this.getActiveSheet(),j=h?h.yj():o,l=void 0,f)try{l=p.Wu.parse(j,c,d,e,!1,!1,!0)}catch(a){}else l=p.Wu.parse(j,c,d,e);a[k(b)]=new i.NameInfo(b,l,d,e,g),f||(n={},n[b]=b,this.Zu(n,!0))}},r.getCustomName=function(a){return a?this.Tu[k(a)]:n},r.cJb=function(a){return a?this.SHb[k(a)]:n},r.getCustomNames=function(){var a=[];return d.GC$.each(this.Tu,function(b,c){a.push(c)}),a},r.GLb=function(){var a=[];return d.GC$.each(this.SHb,function(b,c){a.push(c)}),a},r.removeCustomName=function(a){if(a){delete this.Tu[k(a)];var b={};b[a]=a,this.Zu(b,!1)}},r.THb=function(a){if(a){delete this.SHb[k(a)];var b={};b[a]=a,this.Zu(b,!1)}},r.clearCustomNames=function(){var a=this.Tu;this.Tu={},this.Zu(a,!1)},r.HLb=function(){var a=this.SHb;this.SHb={},this.Zu(a,!1)},r.Zu=function(a,b){var c,d;if(a){c=this.zv;for(d in a)c&&c.updateNameCalc(d,b);this.iK()}},r.iK=function(){if(this.Wu&&!this.Wu.IsSuspended()){var a=this.getActiveSheet();a&&(a.suspendPaint(),this.Wu.recalculateAll(),a.resumePaint())}},r.getCalcService=function(){return this.Wu},r.Cf=function(){return this.Wu},r.suspendCalcService=function(a){this.Wu&&this.Wu.suspend(a)},r.resumeCalcService=function(a){this.Wu&&this.Wu.resume(a)},d.Workbook.$n("calc",{priority:1e3,init:function(){this.Su={},this.Tu={},this.SHb={}},toJson:function(a){var b,c,e,f,g,h,i,j=this,k=j.Su;d.GC$.isEmptyObject(k)||(a.customFunctions=k),b=[],c=[],e=j.getCustomNames(),f=j.GLb(),g=j.Wu,h=this.getActiveSheet(),i=h?h.yj():o,e&&g&&(d.GC$.each(e,function(a,c){var d,e,f=c.getName(),h=c.getRow(),j=c.getColumn(),k=c.getExpression(),l=c.getComment();k&&(d=g.unparse(i,k,h,j,!1,!0),e={name:f,formula:d,row:h,col:j},l&&(e.comment=l),b.push(e))}),d.GC$.each(f,function(a,b){var d,e,f=b.getName(),h=b.getRow(),j=b.getColumn(),k=b.getExpression(),l=b.getComment();k&&(d=g.unparse(i,k,h,j,!1,!0),e={name:f,formula:d,row:h,col:j},l&&(e.comment=l),c.push(e))}),b.length>0&&(a.names=b),c.length>0&&(a.formatStringNames=c))},fromJson:function(a,b,c){var d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x=this,y=x.Wu;if(y&&y.suspend(),x.clearCustomNames(),d=a.names)for(f=0;f0}function A(a){var b,c,d,e=[],f=[];for(b=0;b=u.getRowCount()||b<0||b>=u.getColumnCount())return void u.Os(0,o().Exp_IndexOutOfRange);i=a>=0?a:0,l=b>=0?b:0,d=d||(c&&u.Wu?u.Wu.parse(u.ft,c,i,l,!1,e,e):j),h&&(d.ensureSingle=!0),m=u.tables,3===f&&a>=0&&b>=0&&m&&!(n=m.Hma(a,b,1,1,c,d))||(q=u.Bj(),r=u.conditionalFormats,q&&(s=q.getFormula(a,b),t=u.ITa,q.setFormula(a,b,c,d,e,k,t.dUa()),r&&r.Nm(),g||u.Bq("formula",a,b,f,s,c)),u.t4&&u.t4(a,b,1,1,f),u.$p())}},r.setArrayFormula=function(a,b,c,d,e){this.bv(a,b,c,d,e,!1)},r.bv=function(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,p;if(void 0===g&&(g=3),h=this,1!==g&&2!==g){if(a<0||a+c>h.getRowCount()||b<0||b+d>h.getColumnCount())return void h.Os(0,o().Exp_IndexOutOfRange);if(h.ITa.MTa(a,b,c,d))return void h.Os(0,o().Exp_ArrayFromulaSpan);if(i=h.tables,!(3===g&&a>=0&&b>=0&&i)||(j=i.Hma(a,b,c,d,e))){if(k=h.Bj(),l=h.conditionalFormats,k&&(h.suspendEvent(),k.setArrayFormula(a,b,c,d,e,f,h.ITa.dUa()),h.resumeEvent(),l&&l.Nm(),h.jm<1)){for(m=[],n=a;n0){for(l=0;l=c?d:0;else if(!f&&e)u+=u>=c?d:0;else if(f){if(t>=c+d)t-=d;else if(t>=c)return N}else if(u>=c+d)u-=d;else if(u>=c)return N;if(t!==v||u!==w)return g.rf(M,j,t,u,h.rowRelative,h.columnRelative)}}else if(1===h.type){if(i=h.source||a&&a.yj(),x=h.row,y=h.column,z=h.endRow,A=h.endColumn,B=h.rowRelative,D=h.columnRelative,E=h.endRowRelative,F=h.endColumnRelative,G=x,H=y,I=z,J=A,i&&i===M){if(f&&e)x+=!B&&x>=c?d:0,z+=!E&&z>=c?d:0;else if(!f&&e)y+=!D&&y>=c?d:0,A+=!F&&A>=c?d:0;else if(f&&!e){if(!B&&x>=c&&!E&&z=c+d)x-=d;else if(xc&&(x=c)}if(!E)if(z>=c+d)z-=d;else{if(B)return N;z=c&&!F&&A=c+d)y-=d;else if(yc&&(y=c)}if(!F)if(A>=c+d)A-=d;else{if(D)return N;A0&&(a.names=c)),g=b&&b.ignoreFormula,h=i.et,h&&!g&&h.toJSON(a)},fromJson:function(a,b,c,d){var e=this;e.clearCustomFunctions(),e.clearCustomNames(),d&&(e.nameFunctionsFromJSON(a,b,c),e.formulaFromJSON(a,b,c))},setName:function(a){var b,c,d;E(this),b=this.Bj(),c=w(b),d=c.lh.asyncManager,d.changeSourceName(a.oldName,a.newName)},beforeSetName:function(){this.uja&&(this.parent||this).tja()}})},"./node_modules/process/browser.js":function(a,b){var c,d,e,f,g,h,i=a.exports={};function j(){throw Error("setTimeout has not been defined")}function k(){throw Error("clearTimeout has not been defined")}!function(){try{c="function"==typeof setTimeout?setTimeout:j}catch(a){c=j}try{d="function"==typeof clearTimeout?clearTimeout:k}catch(a){d=k}}();function l(a){if(c===setTimeout)return setTimeout(a,0);if((c===j||!c)&&setTimeout)return c=setTimeout,setTimeout(a,0);try{return c(a,0)}catch(b){try{return c.call(null,a,0)}catch(b){return c.call(this,a,0)}}}function m(a){if(d===clearTimeout)return clearTimeout(a);if((d===k||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(a);try{return d(a)}catch(b){try{return d.call(null,a)}catch(b){return d.call(this,a)}}}e=[],f=!1,h=-1;function n(){f&&g&&(f=!1,g.length?e=g.concat(e):h=-1,e.length&&o())}function o(){var a,b;if(!f){for(a=l(n),f=!0,b=e.length;b;){for(g=e,e=[];++h1)for(b=1;b=e)return a;switch(a){case"%s":return d[c++]+"";case"%d":return+d[c++];case"%j":try{return JSON.stringify(d[c++])}catch(a){return"[Circular]"}default:return a}}),g=d[c];c=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),u(c)?d.showHidden=c:c&&b.Ia(d,c),A(d.showHidden)&&(d.showHidden=!1),A(d.depth)&&(d.depth=2),A(d.colors)&&(d.colors=!1),A(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=k),n(d,a,d.depth)}b.inspect=j,j.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},j.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function k(a,b){var c=j.styles[b];return c?"\x1b["+j.colors[c][0]+"m"+a+"\x1b["+j.colors[c][1]+"m":a}function l(a,b){return a}function m(a){var b={};return a.forEach(function(a,c){b[a]=!0}),b}function n(a,c,d){var e,f,g,h,i,j,k,l,u,v;if(a.customInspect&&c&&F(c.inspect)&&c.inspect!==b.inspect&&(!c.constructor||c.constructor.prototype!==c))return e=c.inspect(d,a),y(e)||(e=n(a,e,d)),e;if(f=o(a,c))return f;if(g=Object.keys(c),h=m(g),a.showHidden&&(g=Object.getOwnPropertyNames(c)),E(c)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return p(c);if(0===g.length){if(F(c))return i=c.name?": "+c.name:"",a.stylize("[Function"+i+"]","special");if(B(c))return a.stylize(RegExp.prototype.toString.call(c),"regexp");if(D(c))return a.stylize(Date.prototype.toString.call(c),"date");if(E(c))return p(c)}return j="",k=!1,l=["{","}"],t(c)&&(k=!0,l=["[","]"]),F(c)&&(u=c.name?": "+c.name:"",j=" [Function"+u+"]"),B(c)&&(j=" "+RegExp.prototype.toString.call(c)),D(c)&&(j=" "+Date.prototype.toUTCString.call(c)),E(c)&&(j=" "+p(c)),0!==g.length||k&&0!=c.length?d<0?B(c)?a.stylize(RegExp.prototype.toString.call(c),"regexp"):a.stylize("[Object]","special"):(a.seen.push(c),v=k?q(a,c,d,h,g):g.map(function(b){return r(a,c,d,h,b,k)}),a.seen.pop(),s(v,j,l)):l[0]+j+l[1]}function o(a,b){if(A(b))return a.stylize("undefined","undefined");if(y(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return x(b)?a.stylize(""+b,"number"):u(b)?a.stylize(""+b,"boolean"):v(b)?a.stylize("null","null"):void 0}function p(a){return"["+Error.prototype.toString.call(a)+"]"}function q(a,b,c,d,e){var f,g,h=[];for(f=0,g=b.length;f-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),A(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function s(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function t(a){return Array.isArray(a)}b.isArray=t;function u(a){return"boolean"==typeof a}b.isBoolean=u;function v(a){return null===a}b.isNull=v;function w(a){return null==a}b.isNullOrUndefined=w;function x(a){return"number"==typeof a}b.isNumber=x;function y(a){return"string"==typeof a}b.isString=y;function z(a){return"symbol"==typeof a}b.isSymbol=z;function A(a){return void 0===a}b.isUndefined=A;function B(a){return C(a)&&"[object RegExp]"===H(a)}b.isRegExp=B;function C(a){return"object"==typeof a&&null!==a}b.isObject=C;function D(a){return C(a)&&"[object Date]"===H(a)}b.isDate=D;function E(a){return C(a)&&("[object Error]"===H(a)||a instanceof Error)}b.isError=E;function F(a){return"function"==typeof a}b.isFunction=F;function G(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||void 0===a}b.isPrimitive=G,b.isBuffer=c("./node_modules/util/support/isBufferBrowser.js");function H(a){return Object.prototype.toString.call(a)}function I(a){return a<10?"0"+a.toString(10):a.toString(10)}f=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function J(){var a=new Date,b=[I(a.getHours()),I(a.getMinutes()),I(a.getSeconds())].join(":");return[a.getDate(),f[a.getMonth()],b].join(" ")}b.log=function(){console.log("%s - %s",J(),b.format.apply(b,arguments))},b.inherits=c("./node_modules/util/node_modules/inherits/inherits_browser.js"),b.Ia=function(a,b){var c,d;if(!b||!C(b))return a;for(c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a};function K(a,b){return Object.prototype.hasOwnProperty.call(a,b)}g="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0,b.promisify=function a(b){if("function"!=typeof b)throw new TypeError('The "original" argument must be of type Function'); if(g&&b[g]){var c=b[g];if("function"!=typeof c)throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(c,g,{value:c,enumerable:!1,writable:!1,configurable:!0}),c}function c(){var a,c,d,e=new Promise(function(b,d){a=b,c=d}),f=[];for(d=0;d