@mescius/activereportsjs
Version:
ActiveReportsJS
8 lines • 1.54 MB
JavaScript
/*!
* @mescius/activereports 5.2.1
* Description: ActiveReportsJS
* https://www.npmjs.com/package/@mescius/activereports
* Copyright ©️ MESCIUS inc. All rights reserved.
* Licensed under the Commercial license
*/
(function(wr,ci){typeof exports=="object"&&typeof module<"u"?ci(exports):typeof define=="function"&&define.amd?define(["exports"],ci):(wr=typeof globalThis<"u"?globalThis:wr||self,ci((wr.MESCIUS=wr.MESCIUS||{},wr.MESCIUS.ActiveReportsJS=wr.MESCIUS.ActiveReportsJS||{},wr.MESCIUS.ActiveReportsJS.XlsxExport={})))})(this,function(wr){"use strict";function ci(B,w){for(var o=0;o<w.length;o++){const b=w[o];if(typeof b!="string"&&!Array.isArray(b)){for(const v in b)if(v!=="default"&&!(v in B)){const i=Object.getOwnPropertyDescriptor(b,v);i&&Object.defineProperty(B,v,i.get?i:{enumerable:!0,get:()=>b[v]})}}}return Object.freeze(Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}))}function Qr(B){return B&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")?B.default:B}function Po(B){if(B.__esModule)return B;var w=B.default;if(typeof w=="function"){var o=function b(){return this instanceof b?Reflect.construct(w,arguments,this.constructor):w.apply(this,arguments)};o.prototype=w.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(B).forEach(function(b){var v=Object.getOwnPropertyDescriptor(B,b);Object.defineProperty(o,b,v.get?v:{enumerable:!0,get:function(){return B[b]}})}),o}var vn={exports:{}},Do;function Fc(){return Do||(Do=1,function(B){var w=function(o){var b=Object.prototype,v=b.hasOwnProperty,i=Object.defineProperty||function(S,E,C){S[E]=C.value},f,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",e=n.asyncIterator||"@@asyncIterator",t=n.toStringTag||"@@toStringTag";function h(S,E,C){return Object.defineProperty(S,E,{value:C,enumerable:!0,configurable:!0,writable:!0}),S[E]}try{h({},"")}catch{h=function(E,C,k){return E[C]=k}}function a(S,E,C,k){var P=E&&E.prototype instanceof A?E:A,$=Object.create(P.prototype),J=new d(k||[]);return i($,"_invoke",{value:T(S,C,J)}),$}o.wrap=a;function s(S,E,C){try{return{type:"normal",arg:S.call(E,C)}}catch(k){return{type:"throw",arg:k}}}var u="suspendedStart",p="suspendedYield",c="executing",y="completed",_={};function A(){}function R(){}function N(){}var L={};h(L,r,function(){return this});var z=Object.getPrototypeOf,F=z&&z(z(g([])));F&&F!==b&&v.call(F,r)&&(L=F);var j=N.prototype=A.prototype=Object.create(L);R.prototype=N,i(j,"constructor",{value:N,configurable:!0}),i(N,"constructor",{value:R,configurable:!0}),R.displayName=h(N,t,"GeneratorFunction");function V(S){["next","throw","return"].forEach(function(E){h(S,E,function(C){return this._invoke(E,C)})})}o.isGeneratorFunction=function(S){var E=typeof S=="function"&&S.constructor;return E?E===R||(E.displayName||E.name)==="GeneratorFunction":!1},o.mark=function(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,N):(S.__proto__=N,h(S,t,"GeneratorFunction")),S.prototype=Object.create(j),S},o.awrap=function(S){return{__await:S}};function q(S,E){function C($,J,D,U){var I=s(S[$],S,J);if(I.type==="throw")U(I.arg);else{var O=I.arg,H=O.value;return H&&typeof H=="object"&&v.call(H,"__await")?E.resolve(H.__await).then(function(W){C("next",W,D,U)},function(W){C("throw",W,D,U)}):E.resolve(H).then(function(W){O.value=W,D(O)},function(W){return C("throw",W,D,U)})}}var k;function P($,J){function D(){return new E(function(U,I){C($,J,U,I)})}return k=k?k.then(D,D):D()}i(this,"_invoke",{value:P})}V(q.prototype),h(q.prototype,e,function(){return this}),o.AsyncIterator=q,o.async=function(S,E,C,k,P){P===void 0&&(P=Promise);var $=new q(a(S,E,C,k),P);return o.isGeneratorFunction(E)?$:$.next().then(function(J){return J.done?J.value:$.next()})};function T(S,E,C){var k=u;return function($,J){if(k===c)throw new Error("Generator is already running");if(k===y){if($==="throw")throw J;return x()}for(C.method=$,C.arg=J;;){var D=C.delegate;if(D){var U=M(D,C);if(U){if(U===_)continue;return U}}if(C.method==="next")C.sent=C._sent=C.arg;else if(C.method==="throw"){if(k===u)throw k=y,C.arg;C.dispatchException(C.arg)}else C.method==="return"&&C.abrupt("return",C.arg);k=c;var I=s(S,E,C);if(I.type==="normal"){if(k=C.done?y:p,I.arg===_)continue;return{value:I.arg,done:C.done}}else I.type==="throw"&&(k=y,C.method="throw",C.arg=I.arg)}}}function M(S,E){var C=E.method,k=S.iterator[C];if(k===f)return E.delegate=null,C==="throw"&&S.iterator.return&&(E.method="return",E.arg=f,M(S,E),E.method==="throw")||C!=="return"&&(E.method="throw",E.arg=new TypeError("The iterator does not provide a '"+C+"' method")),_;var P=s(k,S.iterator,E.arg);if(P.type==="throw")return E.method="throw",E.arg=P.arg,E.delegate=null,_;var $=P.arg;if(!$)return E.method="throw",E.arg=new TypeError("iterator result is not an object"),E.delegate=null,_;if($.done)E[S.resultName]=$.value,E.next=S.nextLoc,E.method!=="return"&&(E.method="next",E.arg=f);else return $;return E.delegate=null,_}V(j),h(j,t,"Generator"),h(j,r,function(){return this}),h(j,"toString",function(){return"[object Generator]"});function l(S){var E={tryLoc:S[0]};1 in S&&(E.catchLoc=S[1]),2 in S&&(E.finallyLoc=S[2],E.afterLoc=S[3]),this.tryEntries.push(E)}function m(S){var E=S.completion||{};E.type="normal",delete E.arg,S.completion=E}function d(S){this.tryEntries=[{tryLoc:"root"}],S.forEach(l,this),this.reset(!0)}o.keys=function(S){var E=Object(S),C=[];for(var k in E)C.push(k);return C.reverse(),function P(){for(;C.length;){var $=C.pop();if($ in E)return P.value=$,P.done=!1,P}return P.done=!0,P}};function g(S){if(S){var E=S[r];if(E)return E.call(S);if(typeof S.next=="function")return S;if(!isNaN(S.length)){var C=-1,k=function P(){for(;++C<S.length;)if(v.call(S,C))return P.value=S[C],P.done=!1,P;return P.value=f,P.done=!0,P};return k.next=k}}return{next:x}}o.values=g;function x(){return{value:f,done:!0}}return d.prototype={constructor:d,reset:function(S){if(this.prev=0,this.next=0,this.sent=this._sent=f,this.done=!1,this.delegate=null,this.method="next",this.arg=f,this.tryEntries.forEach(m),!S)for(var E in this)E.charAt(0)==="t"&&v.call(this,E)&&!isNaN(+E.slice(1))&&(this[E]=f)},stop:function(){this.done=!0;var S=this.tryEntries[0],E=S.completion;if(E.type==="throw")throw E.arg;return this.rval},dispatchException:function(S){if(this.done)throw S;var E=this;function C(U,I){return $.type="throw",$.arg=S,E.next=U,I&&(E.method="next",E.arg=f),!!I}for(var k=this.tryEntries.length-1;k>=0;--k){var P=this.tryEntries[k],$=P.completion;if(P.tryLoc==="root")return C("end");if(P.tryLoc<=this.prev){var J=v.call(P,"catchLoc"),D=v.call(P,"finallyLoc");if(J&&D){if(this.prev<P.catchLoc)return C(P.catchLoc,!0);if(this.prev<P.finallyLoc)return C(P.finallyLoc)}else if(J){if(this.prev<P.catchLoc)return C(P.catchLoc,!0)}else if(D){if(this.prev<P.finallyLoc)return C(P.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(S,E){for(var C=this.tryEntries.length-1;C>=0;--C){var k=this.tryEntries[C];if(k.tryLoc<=this.prev&&v.call(k,"finallyLoc")&&this.prev<k.finallyLoc){var P=k;break}}P&&(S==="break"||S==="continue")&&P.tryLoc<=E&&E<=P.finallyLoc&&(P=null);var $=P?P.completion:{};return $.type=S,$.arg=E,P?(this.method="next",this.next=P.finallyLoc,_):this.complete($)},complete:function(S,E){if(S.type==="throw")throw S.arg;return S.type==="break"||S.type==="continue"?this.next=S.arg:S.type==="return"?(this.rval=this.arg=S.arg,this.method="return",this.next="end"):S.type==="normal"&&E&&(this.next=E),_},finish:function(S){for(var E=this.tryEntries.length-1;E>=0;--E){var C=this.tryEntries[E];if(C.finallyLoc===S)return this.complete(C.completion,C.afterLoc),m(C),_}},catch:function(S){for(var E=this.tryEntries.length-1;E>=0;--E){var C=this.tryEntries[E];if(C.tryLoc===S){var k=C.completion;if(k.type==="throw"){var P=k.arg;m(C)}return P}}throw new Error("illegal catch attempt")},delegateYield:function(S,E,C){return this.delegate={iterator:g(S),resultName:E,nextLoc:C},this.method==="next"&&(this.arg=f),_}},o}(B.exports);try{regeneratorRuntime=w}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=w:Function("r","regeneratorRuntime = r")(w)}}(vn)),vn.exports}var jc=Fc();const Uc=Qr(jc);function di(B){throw new Error('Could not dynamically require "'+B+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var yn={exports:{}};var Lo;function zc(){return Lo||(Lo=1,function(B,w){(function(o){B.exports=o()})(function(){return function o(b,v,i){function f(e,t){if(!v[e]){if(!b[e]){var h=typeof di=="function"&&di;if(!t&&h)return h(e,!0);if(n)return n(e,!0);var a=new Error("Cannot find module '"+e+"'");throw a.code="MODULE_NOT_FOUND",a}var s=v[e]={exports:{}};b[e][0].call(s.exports,function(u){return f(b[e][1][u]||u)},s,s.exports,o,b,v,i)}return v[e].exports}for(var n=typeof di=="function"&&di,r=0;r<i.length;r++)f(i[r]);return f}({1:[function(o,b,v){const i=o("fs"),f=o("fast-csv"),n=o("dayjs/plugin/customParseFormat"),r=o("dayjs/plugin/utc"),e=o("dayjs").extend(n).extend(r),t=o("../utils/stream-buf"),{fs:{exists:h}}=o("../utils/utils"),a={true:!0,false:!1,"#N/A":{error:"#N/A"},"#REF!":{error:"#REF!"},"#NAME?":{error:"#NAME?"},"#DIV/0!":{error:"#DIV/0!"},"#NULL!":{error:"#NULL!"},"#VALUE!":{error:"#VALUE!"},"#NUM!":{error:"#NUM!"}};b.exports=class{constructor(s){this.workbook=s,this.worksheet=null}async readFile(s,u){if(u=u||{},!await h(s))throw new Error("File not found: "+s);const p=i.createReadStream(s),c=await this.read(p,u);return p.close(),c}read(s,u){return u=u||{},new Promise((p,c)=>{const y=this.workbook.addWorksheet(u.sheetName),_=u.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],A=u.map||function(N){if(N==="")return null;const L=Number(N);if(!Number.isNaN(L)&&L!==1/0)return L;const z=_.reduce((j,V)=>{if(j)return j;const q=e(N,V,!0);return q.isValid()?q:null},null);if(z)return new Date(z.valueOf());const F=a[N];return F!==void 0?F:N},R=f.parse(u.parserOptions).on("data",N=>{y.addRow(N.map(A))}).on("end",()=>{R.emit("worksheet",y)});R.on("worksheet",p).on("error",c),s.pipe(R)})}createInputStream(){throw new Error("`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}write(s,u){return new Promise((p,c)=>{u=u||{};const y=this.workbook.getWorksheet(u.sheetName||u.sheetId),_=f.format(u.formatterOptions);s.on("finish",()=>{p()}),_.on("error",c),_.pipe(s);const{dateFormat:A,dateUTC:R}=u,N=u.map||(F=>{if(F){if(F.text||F.hyperlink)return F.hyperlink||F.text||"";if(F.formula||F.result)return F.result||"";if(F instanceof Date)return A?R?e.utc(F).format(A):e(F).format(A):R?e.utc(F).format():e(F).format();if(F.error)return F.error;if(typeof F=="object")return JSON.stringify(F)}return F}),L=u.includeEmptyRows===void 0||u.includeEmptyRows;let z=1;y&&y.eachRow((F,j)=>{if(L)for(;z++<j-1;)_.write([]);const{values:V}=F;V.shift(),_.write(V.map(N)),z=j}),_.end()})}writeFile(s,u){const p={encoding:(u=u||{}).encoding||"utf8"},c=i.createWriteStream(s,p);return this.write(c,u)}async writeBuffer(s){const u=new t;return await this.write(u,s),u.read()}}},{"../utils/stream-buf":24,"../utils/utils":27,dayjs:230,"dayjs/plugin/customParseFormat":231,"dayjs/plugin/utc":232,"fast-csv":263,fs:216}],2:[function(o,b,v){const i=o("../utils/col-cache");class f{constructor(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.worksheet=r,e)if(typeof e=="string"){const h=i.decodeAddress(e);this.nativeCol=h.col+t,this.nativeColOff=0,this.nativeRow=h.row+t,this.nativeRowOff=0}else e.nativeCol!==void 0?(this.nativeCol=e.nativeCol||0,this.nativeColOff=e.nativeColOff||0,this.nativeRow=e.nativeRow||0,this.nativeRowOff=e.nativeRowOff||0):e.col!==void 0?(this.col=e.col+t,this.row=e.row+t):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);else this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0}static asInstance(r){return r instanceof f||r==null?r:new f(r)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(r){this.nativeCol=Math.floor(r),this.nativeColOff=Math.floor((r-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(r){this.nativeRow=Math.floor(r),this.nativeRowOff=Math.floor((r-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(1e4*this.worksheet.getColumn(this.nativeCol+1).width):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(1e4*this.worksheet.getRow(this.nativeRow+1).height):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(r){this.nativeCol=r.nativeCol,this.nativeColOff=r.nativeColOff,this.nativeRow=r.nativeRow,this.nativeRowOff=r.nativeRowOff}}b.exports=f},{"../utils/col-cache":19}],3:[function(o,b,v){const i=o("../utils/col-cache"),f=o("../utils/under-dash"),n=o("./enums"),{slideFormula:r}=o("../utils/shared-formula"),e=o("./note");class t{constructor(s,u,p){if(!s||!u)throw new Error("A Cell needs a Row");this._row=s,this._column=u,i.validateAddress(p),this._address=p,this._value=h.create(t.Types.Null,this),this.style=this._mergeStyle(s.style,u.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(s){this.style.numFmt=s}get font(){return this.style.font}set font(s){this.style.font=s}get alignment(){return this.style.alignment}set alignment(s){this.style.alignment=s}get border(){return this.style.border}set border(s){this.style.border=s}get fill(){return this.style.fill}set fill(s){this.style.fill=s}get protection(){return this.style.protection}set protection(s){this.style.protection=s}_mergeStyle(s,u,p){const c=s&&s.numFmt||u&&u.numFmt;c&&(p.numFmt=c);const y=s&&s.font||u&&u.font;y&&(p.font=y);const _=s&&s.alignment||u&&u.alignment;_&&(p.alignment=_);const A=s&&s.border||u&&u.border;A&&(p.border=A);const R=s&&s.fill||u&&u.fill;R&&(p.fill=R);const N=s&&s.protection||u&&u.protection;return N&&(p.protection=N),p}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===t.Types.Merge}merge(s,u){this._value.release(),this._value=h.create(t.Types.Merge,this,s),u||(this.style=s.style)}unmerge(){this.type===t.Types.Merge&&(this._value.release(),this._value=h.create(t.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}isMergedTo(s){return this._value.type===t.Types.Merge&&this._value.isMergedTo(s)}get master(){return this.type===t.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===t.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(s){this.type!==t.Types.Merge?(this._value.release(),this._value=h.create(h.getType(s),this,s)):this._value.master.value=s}get note(){return this._comment&&this._comment.note}set note(s){this._comment=new e(s)}get text(){return this._value.toString()}get html(){return f.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(s){this.type===t.Types.String&&(this._value=h.create(t.Types.Hyperlink,this,{text:this._value.value,hyperlink:s}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){const{worksheet:s}=this._row;return{sheetName:s.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(s){this.names=[s]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(s){const{definedNames:u}=this.workbook;u.removeAllNames(this.fullAddress),s.forEach(p=>{u.addEx(this.fullAddress,p)})}addName(s){this.workbook.definedNames.addEx(this.fullAddress,s)}removeName(s){this.workbook.definedNames.removeEx(this.fullAddress,s)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(s){this._dataValidations.add(this.address,s)}get model(){const{model:s}=this._value;return s.style=this.style,this._comment&&(s.comment=this._comment.model),s}set model(s){if(this._value.release(),this._value=h.create(s.type,this),this._value.model=s,s.comment)switch(s.comment.type){case"note":this._comment=e.fromModel(s.comment)}s.style?this.style=s.style:this.style={}}}t.Types=n.ValueType;const h={getType:a=>a==null?t.Types.Null:a instanceof String||typeof a=="string"?t.Types.String:typeof a=="number"?t.Types.Number:typeof a=="boolean"?t.Types.Boolean:a instanceof Date?t.Types.Date:a.text&&a.hyperlink?t.Types.Hyperlink:a.formula||a.sharedFormula?t.Types.Formula:a.richText?t.Types.RichText:a.sharedString?t.Types.SharedString:a.error?t.Types.Error:t.Types.JSON,types:[{t:t.Types.Null,f:class{constructor(a){this.model={address:a.address,type:t.Types.Null}}get value(){return null}set value(a){}get type(){return t.Types.Null}get effectiveType(){return t.Types.Null}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return""}release(){}toString(){return""}}},{t:t.Types.Number,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.Number,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}get type(){return t.Types.Number}get effectiveType(){return t.Types.Number}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:t.Types.String,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.String,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}get type(){return t.Types.String}get effectiveType(){return t.Types.String}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return`"${this.model.value.replace(/"/g,'""')}"`}release(){}toString(){return this.model.value}}},{t:t.Types.Date,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.Date,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}get type(){return t.Types.Date}get effectiveType(){return t.Types.Date}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}}},{t:t.Types.Hyperlink,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.Hyperlink,text:s?s.text:void 0,hyperlink:s?s.hyperlink:void 0},s&&s.tooltip&&(this.model.tooltip=s.tooltip)}get value(){const a={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(a.tooltip=this.model.tooltip),a}set value(a){this.model={text:a.text,hyperlink:a.hyperlink},a.tooltip&&(this.model.tooltip=a.tooltip)}get text(){return this.model.text}set text(a){this.model.text=a}get hyperlink(){return this.model.hyperlink}set hyperlink(a){this.model.hyperlink=a}get type(){return t.Types.Hyperlink}get effectiveType(){return t.Types.Hyperlink}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.model.hyperlink}release(){}toString(){return this.model.text}}},{t:t.Types.Formula,f:class{constructor(a,s){this.cell=a,this.model={address:a.address,type:t.Types.Formula,shareType:s?s.shareType:void 0,ref:s?s.ref:void 0,formula:s?s.formula:void 0,sharedFormula:s?s.sharedFormula:void 0,result:s?s.result:void 0}}_copyModel(a){const s={},u=p=>{const c=a[p];c&&(s[p]=c)};return u("formula"),u("result"),u("ref"),u("shareType"),u("sharedFormula"),s}get value(){return this._copyModel(this.model)}set value(a){this.model=this._copyModel(a)}validate(a){switch(h.getType(a)){case t.Types.Null:case t.Types.String:case t.Types.Number:case t.Types.Date:break;case t.Types.Hyperlink:case t.Types.Formula:default:throw new Error("Cannot process that type of result value")}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,"").match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()}set formula(a){this.model.formula=a}get formulaType(){return this.model.formula?n.FormulaType.Master:this.model.sharedFormula?n.FormulaType.Shared:n.FormulaType.None}get result(){return this.model.result}set result(a){this.model.result=a}get type(){return t.Types.Formula}get effectiveType(){const a=this.model.result;return a==null?n.ValueType.Null:a instanceof String||typeof a=="string"?n.ValueType.String:typeof a=="number"?n.ValueType.Number:a instanceof Date?n.ValueType.Date:a.text&&a.hyperlink?n.ValueType.Hyperlink:a.formula?n.ValueType.Formula:n.ValueType.Null}get address(){return this.model.address}set address(a){this.model.address=a}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){const{worksheet:a}=this.cell,s=a.findCell(this.model.sharedFormula);this._translatedFormula=s&&r(s.formula,s.address,this.model.address)}return this._translatedFormula}toCsvString(){return""+(this.model.result||"")}release(){}toString(){return this.model.result?this.model.result.toString():""}}},{t:t.Types.Merge,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.Merge,master:s?s.address:void 0},this._master=s,s&&s.addMergeRef()}get value(){return this._master.value}set value(a){a instanceof t?(this._master&&this._master.releaseMergeRef(),a.addMergeRef(),this._master=a):this._master.value=a}isMergedTo(a){return a===this._master}get master(){return this._master}get type(){return t.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return""}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}}},{t:t.Types.JSON,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.String,value:JSON.stringify(s),rawValue:s}}get value(){return this.model.rawValue}set value(a){this.model.rawValue=a,this.model.value=JSON.stringify(a)}get type(){return t.Types.String}get effectiveType(){return t.Types.String}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}}},{t:t.Types.SharedString,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.SharedString,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}get type(){return t.Types.SharedString}get effectiveType(){return t.Types.SharedString}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:t.Types.RichText,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.String,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}toString(){return this.model.value.richText.map(a=>a.text).join("")}get type(){return t.Types.RichText}get effectiveType(){return t.Types.RichText}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}},{t:t.Types.Boolean,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.Boolean,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}get type(){return t.Types.Boolean}get effectiveType(){return t.Types.Boolean}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}}},{t:t.Types.Error,f:class{constructor(a,s){this.model={address:a.address,type:t.Types.Error,value:s}}get value(){return this.model.value}set value(a){this.model.value=a}get type(){return t.Types.Error}get effectiveType(){return t.Types.Error}get address(){return this.model.address}set address(a){this.model.address=a}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}}}].reduce((a,s)=>(a[s.t]=s.f,a),[]),create(a,s,u){const p=this.types[a];if(!p)throw new Error("Could not create Value of type "+a);return new p(s,u)}};b.exports=t},{"../utils/col-cache":19,"../utils/shared-formula":23,"../utils/under-dash":26,"./enums":7,"./note":9}],4:[function(o,b,v){const i=o("../utils/under-dash"),f=o("./enums"),n=o("../utils/col-cache");class r{constructor(t,h,a){this._worksheet=t,this._number=h,a!==!1&&(this.defn=a)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return n.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}}set defn(t){t?(this.key=t.key,this.width=t.width!==void 0?t.width:9,this.outlineLevel=t.outlineLevel,t.style?this.style=t.style:this.style={},this.header=t.header,this._hidden=!!t.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}get headers(){return this._header&&this._header instanceof Array?this._header:[this._header]}get header(){return this._header}set header(t){t!==void 0?(this._header=t,this.headers.forEach((h,a)=>{this._worksheet.getCell(a+1,this.number).value=h})):this._header=void 0}get key(){return this._key}set key(t){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=t,t&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(t){this._hidden=t}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(t){this._outlineLevel=t}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(t){return this.width===t.width&&this.hidden===t.hidden&&this.outlineLevel===t.outlineLevel&&i.isEqual(this.style,t.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel)return!1;const t=this.style;return!t||!(t.font||t.numFmt||t.alignment||t.border||t.fill||t.protection)}get headerCount(){return this.headers.length}eachCell(t,h){const a=this.number;h||(h=t,t=null),this._worksheet.eachRow(t,(s,u)=>{h(s.getCell(a),u)})}get values(){const t=[];return this.eachCell((h,a)=>{h&&h.type!==f.ValueType.Null&&(t[a]=h.value)}),t}set values(t){if(!t)return;const h=this.number;let a=0;t.hasOwnProperty("0")&&(a=1),t.forEach((s,u)=>{this._worksheet.getCell(u+a,h).value=s})}_applyStyle(t,h){return this.style[t]=h,this.eachCell(a=>{a[t]=h}),h}get numFmt(){return this.style.numFmt}set numFmt(t){this._applyStyle("numFmt",t)}get font(){return this.style.font}set font(t){this._applyStyle("font",t)}get alignment(){return this.style.alignment}set alignment(t){this._applyStyle("alignment",t)}get protection(){return this.style.protection}set protection(t){this._applyStyle("protection",t)}get border(){return this.style.border}set border(t){this._applyStyle("border",t)}get fill(){return this.style.fill}set fill(t){this._applyStyle("fill",t)}static toModel(t){const h=[];let a=null;return t&&t.forEach((s,u)=>{s.isDefault?a&&(a=null):a&&s.equivalentTo(a)?a.max=u+1:(a={min:u+1,max:u+1,width:s.width!==void 0?s.width:9,style:s.style,isCustomWidth:s.isCustomWidth,hidden:s.hidden,outlineLevel:s.outlineLevel,collapsed:s.collapsed},h.push(a))}),h.length?h:void 0}static fromModel(t,h){const a=[];let s=1,u=0;for(h=(h=h||[]).sort(function(p,c){return p.min-c.min});u<h.length;){const p=h[u++];for(;s<p.min;)a.push(new r(t,s++));for(;s<=p.max;)a.push(new r(t,s++,p))}return a.length?a:null}}b.exports=r},{"../utils/col-cache":19,"../utils/under-dash":26,"./enums":7}],5:[function(o,b,v){b.exports=class{constructor(i){this.model=i||{}}add(i,f){return this.model[i]=f}find(i){return this.model[i]}remove(i){this.model[i]=void 0}}},{}],6:[function(o,b,v){const i=o("../utils/under-dash"),f=o("../utils/col-cache"),n=o("../utils/cell-matrix"),r=o("./range"),e=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;b.exports=class{constructor(){this.matrixMap={}}getMatrix(t){return this.matrixMap[t]||(this.matrixMap[t]=new n)}add(t,h){const a=f.decodeEx(t);this.addEx(a,h)}addEx(t,h){const a=this.getMatrix(h);if(t.top)for(let s=t.left;s<=t.right;s++)for(let u=t.top;u<=t.bottom;u++){const p={sheetName:t.sheetName,address:f.n2l(s)+u,row:u,col:s};a.addCellEx(p)}else a.addCellEx(t)}remove(t,h){const a=f.decodeEx(t);this.removeEx(a,h)}removeEx(t,h){this.getMatrix(h).removeCellEx(t)}removeAllNames(t){i.each(this.matrixMap,h=>{h.removeCellEx(t)})}forEach(t){i.each(this.matrixMap,(h,a)=>{h.forEach(s=>{t(a,s)})})}getNames(t){return this.getNamesEx(f.decodeEx(t))}getNamesEx(t){return i.map(this.matrixMap,(h,a)=>h.findCellEx(t)&&a).filter(Boolean)}_explore(t,h){h.mark=!1;const{sheetName:a}=h,s=new r(h.row,h.col,h.row,h.col,a);let u,p;function c(_,A){const R=t.findCellAt(a,_,h.col);return!(!R||!R.mark)&&(s[A]=_,R.mark=!1,!0)}for(p=h.row-1;c(p,"top");p--);for(p=h.row+1;c(p,"bottom");p++);function y(_,A){const R=[];for(p=s.top;p<=s.bottom;p++){const N=t.findCellAt(a,p,_);if(!N||!N.mark)return!1;R.push(N)}s[A]=_;for(let N=0;N<R.length;N++)R[N].mark=!1;return!0}for(u=h.col-1;y(u,"left");u--);for(u=h.col+1;y(u,"right");u++);return s}getRanges(t,h){return(h=h||this.matrixMap[t])?(h.forEach(a=>{a.mark=!0}),{name:t,ranges:h.map(a=>a.mark&&this._explore(h,a)).filter(Boolean).map(a=>a.$shortRange)}):{name:t,ranges:[]}}normaliseMatrix(t,h){t.forEachInSheet(h,(a,s,u)=>{a&&(a.row===s&&a.col===u||(a.row=s,a.col=u,a.address=f.n2l(u)+s))})}spliceRows(t,h,a,s){i.each(this.matrixMap,u=>{u.spliceRows(t,h,a,s),this.normaliseMatrix(u,t)})}spliceColumns(t,h,a,s){i.each(this.matrixMap,u=>{u.spliceColumns(t,h,a,s),this.normaliseMatrix(u,t)})}get model(){return i.map(this.matrixMap,(t,h)=>this.getRanges(h,t)).filter(t=>t.ranges.length)}set model(t){const h=this.matrixMap={};t.forEach(a=>{const s=h[a.name]=new n;a.ranges.forEach(u=>{e.test(u.split("!").pop()||"")&&s.addCell(u)})})}}},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":26,"./range":10}],7:[function(o,b,v){b.exports={ValueType:{Null:0,Merge:1,Number:2,String:3,Date:4,Hyperlink:5,Formula:6,SharedString:7,RichText:8,Boolean:9,Error:10},FormulaType:{None:0,Master:1,Shared:2},RelationshipType:{None:0,OfficeDocument:1,Worksheet:2,CalcChain:3,SharedStrings:4,Styles:5,Theme:6,Hyperlink:7},DocumentType:{Xlsx:1},ReadingOrder:{LeftToRight:1,RightToLeft:2},ErrorValue:{NotApplicable:"#N/A",Ref:"#REF!",Name:"#NAME?",DivZero:"#DIV/0!",Null:"#NULL!",Value:"#VALUE!",Num:"#NUM!"}}},{}],8:[function(o,b,v){const i=o("../utils/col-cache"),f=o("./anchor");b.exports=class{constructor(n,r){this.worksheet=n,this.model=r}get model(){switch(this.type){case"background":return{type:this.type,imageId:this.imageId};case"image":return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw new Error("Invalid Image Type")}}set model(n){let{type:r,imageId:e,range:t,hyperlinks:h}=n;if(this.type=r,this.imageId=e,r==="image")if(typeof t=="string"){const a=i.decode(t);this.range={tl:new f(this.worksheet,{col:a.left,row:a.top},-1),br:new f(this.worksheet,{col:a.right,row:a.bottom},0),editAs:"oneCell"}}else this.range={tl:new f(this.worksheet,t.tl,0),br:t.br&&new f(this.worksheet,t.br,0),ext:t.ext,editAs:t.editAs,hyperlinks:h||t.hyperlinks}}}},{"../utils/col-cache":19,"./anchor":2}],9:[function(o,b,v){const i=o("../utils/under-dash");class f{constructor(r){this.note=r}get model(){let r=null;switch(typeof this.note){case"string":r={type:"note",note:{texts:[{text:this.note}]}};break;default:r={type:"note",note:this.note}}return i.deepMerge({},f.DEFAULT_CONFIGS,r)}set model(r){const{note:e}=r,{texts:t}=e;t.length===1&&Object.keys(t[0]).length===1?this.note=t[0].text:this.note=e}static fromModel(r){const e=new f;return e.model=r,e}}f.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},b.exports=f},{"../utils/under-dash":26}],10:[function(o,b,v){const i=o("../utils/col-cache");class f{constructor(){this.decode(arguments)}setTLBR(r,e,t,h,a){if(arguments.length<4){const s=i.decodeAddress(r),u=i.decodeAddress(e);this.model={top:Math.min(s.row,u.row),left:Math.min(s.col,u.col),bottom:Math.max(s.row,u.row),right:Math.max(s.col,u.col),sheetName:t},this.setTLBR(s.row,s.col,u.row,u.col,a)}else this.model={top:Math.min(r,t),left:Math.min(e,h),bottom:Math.max(r,t),right:Math.max(e,h),sheetName:a}}decode(r){switch(r.length){case 5:this.setTLBR(r[0],r[1],r[2],r[3],r[4]);break;case 4:this.setTLBR(r[0],r[1],r[2],r[3]);break;case 3:this.setTLBR(r[0],r[1],r[2]);break;case 2:this.setTLBR(r[0],r[1]);break;case 1:{const e=r[0];if(e instanceof f)this.model={top:e.model.top,left:e.model.left,bottom:e.model.bottom,right:e.model.right,sheetName:e.sheetName};else if(e instanceof Array)this.decode(e);else if(e.top&&e.left&&e.bottom&&e.right)this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName};else{const t=i.decodeEx(e);t.top?this.model={top:t.top,left:t.left,bottom:t.bottom,right:t.right,sheetName:t.sheetName}:this.model={top:t.row,left:t.col,bottom:t.row,right:t.col,sheetName:t.sheetName}}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Error("Invalid number of arguments to _getDimensions() - "+r.length)}}get top(){return this.model.top||1}set top(r){this.model.top=r}get left(){return this.model.left||1}set left(r){this.model.left=r}get bottom(){return this.model.bottom||1}set bottom(r){this.model.bottom=r}get right(){return this.model.right||1}set right(r){this.model.right=r}get sheetName(){return this.model.sheetName}set sheetName(r){this.model.sheetName=r}get _serialisedSheetName(){const{sheetName:r}=this.model;return r?/^[a-zA-Z0-9]*$/.test(r)?r+"!":`'${r}'!`:""}expand(r,e,t,h){(!this.model.top||r<this.top)&&(this.top=r),(!this.model.left||e<this.left)&&(this.left=e),(!this.model.bottom||t>this.bottom)&&(this.bottom=t),(!this.model.right||h>this.right)&&(this.right=h)}expandRow(r){if(r){const{dimensions:e,number:t}=r;e&&this.expand(t,e.min,t,e.max)}}expandToAddress(r){const e=i.decodeEx(r);this.expand(e.row,e.col,e.row,e.col)}get tl(){return i.n2l(this.left)+this.top}get $t$l(){return`$${i.n2l(this.left)}$${this.top}`}get br(){return i.n2l(this.right)+this.bottom}get $b$r(){return`$${i.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(r){return(!r.sheetName||!this.sheetName||r.sheetName===this.sheetName)&&!(r.bottom<this.top)&&!(r.top>this.bottom)&&!(r.right<this.left)&&!(r.left>this.right)}contains(r){const e=i.decodeEx(r);return this.containsEx(e)}containsEx(r){return(!r.sheetName||!this.sheetName||r.sheetName===this.sheetName)&&r.row>=this.top&&r.row<=this.bottom&&r.col>=this.left&&r.col<=this.right}forEachAddress(r){for(let e=this.left;e<=this.right;e++)for(let t=this.top;t<=this.bottom;t++)r(i.encodeAddress(t,e),t,e)}}b.exports=f},{"../utils/col-cache":19}],11:[function(o,b,v){const i=o("../utils/under-dash"),f=o("./enums"),n=o("../utils/col-cache"),r=o("./cell");b.exports=class{constructor(e,t){this._worksheet=e,this._number=t,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(e){return this._cells[e-1]}getCellEx(e){let t=this._cells[e.col-1];if(!t){const h=this._worksheet.getColumn(e.col);t=new r(this,h,e.address),this._cells[e.col-1]=t}return t}getCell(e){if(typeof e=="string"){const t=this._worksheet.getColumnKey(e);e=t?t.number:n.l2n(e)}return this._cells[e-1]||this.getCellEx({address:n.encodeAddress(this._number,e),row:this._number,col:e})}splice(e,t){const h=e+t;for(var a=arguments.length,s=new Array(a>2?a-2:0),u=2;u<a;u++)s[u-2]=arguments[u];const p=s.length-t,c=this._cells.length;let y,_,A;if(p<0)for(y=e+s.length;y<=c;y++)A=this._cells[y-1],_=this._cells[y-p-1],_?(A=this.getCell(y),A.value=_.value,A.style=_.style,A._comment=_._comment):A&&(A.value=null,A.style={},A._comment=void 0);else if(p>0)for(y=c;y>=h;y--)_=this._cells[y-1],_?(A=this.getCell(y+p),A.value=_.value,A.style=_.style,A._comment=_._comment):this._cells[y+p-1]=void 0;for(y=0;y<s.length;y++)A=this.getCell(e+y),A.value=s[y],A.style={},A._comment=void 0}eachCell(e,t){if(t||(t=e,e=null),e&&e.includeEmpty){const h=this._cells.length;for(let a=1;a<=h;a++)t(this.getCell(a),a)}else this._cells.forEach((h,a)=>{h&&h.type!==f.ValueType.Null&&t(h,a+1)})}addPageBreak(e,t){const h=this._worksheet,a=Math.max(0,e-1)||0,s=Math.max(0,t-1)||16838,u={id:this._number,max:s,man:1};a&&(u.min=a),h.rowBreaks.push(u)}get values(){const e=[];return this._cells.forEach(t=>{t&&t.type!==f.ValueType.Null&&(e[t.col]=t.value)}),e}set values(e){if(this._cells=[],e)if(e instanceof Array){let t=0;e.hasOwnProperty("0")&&(t=1),e.forEach((h,a)=>{h!==void 0&&(this.getCellEx({address:n.encodeAddress(this._number,a+t),row:this._number,col:a+t}).value=h)})}else this._worksheet.eachColumnKey((t,h)=>{e[h]!==void 0&&(this.getCellEx({address:n.encodeAddress(this._number,t.number),row:this._number,col:t.number}).value=e[h])})}get hasValues(){return i.some(this._cells,e=>e&&e.type!==f.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let e=0;return this.eachCell(()=>{e++}),e}get dimensions(){let e=0,t=0;return this._cells.forEach(h=>{h&&h.type!==f.ValueType.Null&&((!e||e>h.col)&&(e=h.col),t<h.col&&(t=h.col))}),e>0?{min:e,max:t}:null}_applyStyle(e,t){return this.style[e]=t,this._cells.forEach(h=>{h&&(h[e]=t)}),t}get numFmt(){return this.style.numFmt}set numFmt(e){this._applyStyle("numFmt",e)}get font(){return this.style.font}set font(e){this._applyStyle("font",e)}get alignment(){return this.style.alignment}set alignment(e){this._applyStyle("alignment",e)}get protection(){return this.style.protection}set protection(e){this._applyStyle("protection",e)}get border(){return this.style.border}set border(e){this._applyStyle("border",e)}get fill(){return this.style.fill}set fill(e){this._applyStyle("fill",e)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){const e=[];let t=0,h=0;return this._cells.forEach(a=>{if(a){const s=a.model;s&&((!t||t>a.col)&&(t=a.col),h<a.col&&(h=a.col),e.push(s))}}),this.height||e.length?{cells:e,number:this.number,min:t,max:h,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed}:null}set model(e){if(e.number!==this._number)throw new Error("Invalid row number in model");let t;this._cells=[],e.cells.forEach(h=>{switch(h.type){case r.Types.Merge:break;default:{let a;if(h.address)a=n.decodeAddress(h.address);else if(t){const{row:s}=t,u=t.col+1;a={row:s,col:u,address:n.encodeAddress(s,u),$col$row:`$${n.n2l(u)}$${s}`}}t=a,this.getCellEx(a).model=h;break}}}),e.height?this.height=e.height:delete this.height,this.hidden=e.hidden,this.outlineLevel=e.outlineLevel||0,this.style=e.style&&JSON.parse(JSON.stringify(e.style))||{}}}},{"../utils/col-cache":19,"../utils/under-dash":26,"./cell":3,"./enums":7}],12:[function(o,b,v){const i=o("../utils/col-cache");class f{constructor(r,e,t){this.table=r,this.column=e,this.index=t}_set(r,e){this.table.cacheState(),this.column[r]=e}get name(){return this.column.name}set name(r){this._set("name",r)}get filterButton(){return this.column.filterButton}set filterButton(r){this.column.filterButton=r}get style(){return this.column.style}set style(r){this.column.style=r}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(r){this._set("totalsRowLabel",r)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(r){this._set("totalsRowFunction",r)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(r){this._set("totalsRowResult",r)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(r){this._set("totalsRowFormula",r)}}b.exports=class{constructor(n,r){this.worksheet=n,r&&(this.table=r,this.validate(),this.store())}getFormula(n){switch(n.totalsRowFunction){case"none":return null;case"average":return`SUBTOTAL(101,${this.table.name}[${n.name}])`;case"countNums":return`SUBTOTAL(102,${this.table.name}[${n.name}])`;case"count":return`SUBTOTAL(103,${this.table.name}[${n.name}])`;case"max":return`SUBTOTAL(104,${this.table.name}[${n.name}])`;case"min":return`SUBTOTAL(105,${this.table.name}[${n.name}])`;case"stdDev":return`SUBTOTAL(106,${this.table.name}[${n.name}])`;case"var":return`SUBTOTAL(107,${this.table.name}[${n.name}])`;case"sum":return`SUBTOTAL(109,${this.table.name}[${n.name}])`;case"custom":return n.totalsRowFormula;default:throw new Error("Invalid Totals Row Function: "+n.totalsRowFunction)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){const{table:n}=this,r=(p,c,y)=>{p[c]===void 0&&(p[c]=y)};r(n,"headerRow",!0),r(n,"totalsRow",!1),r(n,"style",{}),r(n.style,"theme","TableStyleMedium2"),r(n.style,"showFirstColumn",!1),r(n.style,"showLastColumn",!1),r(n.style,"showRowStripes",!1),r(n.style,"showColumnStripes",!1);const e=(p,c)=>{if(!p)throw new Error(c)};e(n.ref,"Table must have ref"),e(n.columns,"Table must have column definitions"),e(n.rows,"Table must have row definitions"),n.tl=i.decodeAddress(n.ref);const{row:t,col:h}=n.tl;e(t>0,"Table must be on valid row"),e(h>0,"Table must be on valid col");const{width:a,filterHeight:s,tableHeight:u}=this;n.autoFilterRef=i.encode(t,h,t+s-1,h+a-1),n.tableRef=i.encode(t,h,t+u-1,h+a-1),n.columns.forEach((p,c)=>{e(p.name,`Column ${c} must have a name`),c===0?r(p,"totalsRowLabel","Total"):(r(p,"totalsRowFunction","none"),p.totalsRowFormula=this.getFormula(p))})}store(){const n=(s,u)=>{u&&Object.keys(u).forEach(p=>{s[p]=u[p]})},{worksheet:r,table:e}=this,{row:t,col:h}=e.tl;let a=0;if(e.headerRow){const s=r.getRow(t+a++);e.columns.forEach((u,p)=>{const{style:c,name:y}=u,_=s.getCell(h+p);_.value=y,n(_,c)})}if(e.rows.forEach(s=>{const u=r.getRow(t+a++);s.forEach((p,c)=>{const y=u.getCell(h+c);y.value=p,n(y,e.columns[c].style)})}),e.totalsRow){const s=r.getRow(t+a++);e.columns.forEach((u,p)=>{const c=s.getCell(h+p);if(p===0)c.value=u.totalsRowLabel;else{const y=this.getFormula(u);c.value=y?{formula:u.totalsRowFormula,result:u.totalsRowResult}:null}n(c,u.style)})}}load(n){const{table:r}=this,{row:e,col:t}=r.tl;let h=0;if(r.headerRow){const a=n.getRow(e+h++);r.columns.forEach((s,u)=>{a.getCell(t+u).value=s.name})}if(r.rows.forEach(a=>{const s=n.getRow(e+h++);a.forEach((u,p)=>{s.getCell(t+p).value=u})}),r.totalsRow){const a=n.getRow(e+h++);r.columns.forEach((s,u)=>{const p=a.getCell(t+u);u===0?p.value=s.totalsRowLabel:this.getFormula(s)&&(p.value={formula:s.totalsRowFormula,result:s.totalsRowResult})})}}get model(){return this.table}set model(n){this.table=n}cacheState(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}commit(){if(!this._cache)return;this.validate();const n=i.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let r=0;r<this._cache.tableHeight;r++){const e=this.worksheet.getRow(n.row+r);for(let t=0;t<this._cache.width;t++)e.getCell(n.col+t).value=null}else{for(let r=this.tableHeight;r<this._cache.tableHeight;r++){const e=this.worksheet.getRow(n.row+r);for(let t=0;t<this._cache.width;t++)e.getCell(n.col+t).value=null}for(let r=0;r<this.tableHeight;r++){const e=this.worksheet.getRow(n.row+r);for(let t=this.width;t<this._cache.width;t++)e.getCell(n.col+t).value=null}}this.store()}addRow(n,r){this.cacheState(),r===void 0?this.table.rows.push(n):this.table.rows.splice(r,0,n)}removeRows(n){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.rows.splice(n,r)}getColumn(n){const r=this.table.columns[n];return new f(this,r,n)}addColumn(n,r,e){this.cacheState(),e===void 0?(this.table.columns.push(n),this.table.rows.forEach((t,h)=>{t.push(r[h])})):(this.table.columns.splice(e,0,n),this.table.rows.forEach((t,h)=>{t.splice(e,0,r[h])}))}removeColumns(n){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.columns.splice(n,r),this.table.rows.forEach(e=>{e.splice(n,r)})}_assign(n,r,e){this.cacheState(),n[r]=e}get ref(){return this.table.ref}set ref(n){this._assign(this.table,"ref",n)}get name(){return this.table.name}set name(n){this.table.name=n}get displayName(){return this.table.displyName||this.table.name}set displayNamename(n){this.table.displayName=n}get headerRow(){return this.table.headerRow}set headerRow(n){this._assign(this.table,"headerRow",n)}get totalsRow(){return this.table.totalsRow}set totalsRow(n){this._assign(this.table,"totalsRow",n)}get theme(){return this.table.style.name}set theme(n){this.table.style.name=n}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(n){this.table.style.showFirstColumn=n}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(n){this.table.style.showLastColumn=n}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(n){this.table.style.showRowStripes=n}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(n){this.table.style.showColumnStripes=n}}},{"../utils/col-cache":19}],13:[function(o,b,v){const i=o("./worksheet"),f=o("./defined-names"),n=o("../xlsx/xlsx"),r=o("../csv/csv");b.exports=class{constructor(){this.category="",this.company="",this.created=new Date,this.description="",this.keywords="",this.manager="",this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject="",this.title="",this.views=[],this.media=[],this._definedNames=new f}get xlsx(){return this._xlsx||(this._xlsx=new n(this)),this._xlsx}get csv(){return this._csv||(this._csv=new r(this)),this._csv}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addWorksheet(e,t){const h=this.nextId;t&&(typeof t=="string"?(console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'),t={properties:{tabColor:{argb:t}}}):(t.argb||t.theme||t.indexed)&&(console.trace("tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }"),t={properties:{tabColor:t}}));const a=this._worksheets.reduce((p,c)=>(c&&c.orderNo)>p?c.orderNo:p,0),s=Object.assign({},t,{id:h,name:e,orderNo:a+1,workbook:this}),u=new i(s);return this._worksheets[h]=u,u}removeWorksheetEx(e){delete this._worksheets[e.id]}removeWorksheet(e){const t=this.getWorksheet(e);t&&t.destroy()}getWorksheet(e){return e===void 0?this._worksheets.find(Boolean):typeof e=="number"?this._worksheets[e]:typeof e=="string"?this._worksheets.find(t=>t&&t.name===e):void 0}get worksheets(){return this._worksheets.slice(1).sort((e,t)=>e.orderNo-t.orderNo).filter(Boolean)}eachSheet(e){this.worksheets.forEach(t=>{e(t,t.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(e){const t=this.media.length;return this.media.push(Object.assign({},e,{type:"image"})),t}getImage(e){return this.media[e]}get model(){return{creator:this.creator||"Unknown",lastModifiedBy:this.lastModifiedBy||"Unknown",lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(e=>e.model),sheets:this.worksheets.map(e=>e.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,calcProperties:this.calcProperties}}set model(e){this.creator=e.creator,this.lastModifiedBy=e.lastModified