varJSZip=function(data,options){this.files={};this.root="";if(data){this.load(data,options)}};JSZip.signature={LOCAL_FILE_HEADER:"PK",CENTRAL_FILE_HEADER:"PK",CENTRAL_DIRECTORY_END:"PK",ZIP64_CENTRAL_DIRECTORY_LOCATOR:"PK",ZIP64_CENTRAL_DIRECTORY_END:"PK",DATA_DESCRIPTOR:"PK\b"};JSZip.defaults={base64:false,binary:false,dir:false,date:null,compression:null};JSZip.support={arraybuffer:function(){returntypeofArrayBuffer!=="undefined"&&typeofUint8Array!=="undefined"}(),nodebuffer:function(){returntypeofBuffer!=="undefined"}(),uint8array:function(){returntypeofUint8Array!=="undefined"}(),blob:function(){if(typeofArrayBuffer==="undefined"){returnfalse}varbuffer=newArrayBuffer(0);try{returnnewBlob([buffer],{type:"application/zip"}).size===0}catch(e){}try{varBlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;varbuilder=newBlobBuilder;builder.append(buffer);returnbuilder.getBlob("application/zip").size===0}catch(e){}returnfalse}()};JSZip.prototype=function(){vartextEncoder,textDecoder;if(JSZip.support.uint8array&&typeofTextEncoder==="function"&&typeofTextDecoder==="function"){textEncoder=newTextEncoder("utf-8");textDecoder=newTextDecoder("utf-8")}vargetRawData=function(file){if(file._datainstanceofJSZip.CompressedObject){file._data=file._data.getContent();file.options.binary=true;file.options.base64=false;if(JSZip.utils.getTypeOf(file._data)==="uint8array"){varcopy=file._data;file._data=newUint8Array(copy.length);if(copy.length!==0){file._data.set(copy,0)}}}returnfile._data};vargetBinaryData=function(file){varresult=getRawData(file),type=JSZip.utils.getTypeOf(result);if(type==="string"){if(!file.options.binary){if(textEncoder){returntextEncoder.encode(result)}if(JSZip.support.nodebuffer){returnnewBuffer(result,"utf-8")}}returnfile.asBinary()}returnresult};vardataToString=function(asUTF8){varresult=getRawData(this);if(result===null||typeofresult==="undefined"){return""}if(this.options.base64){result=JSZip.base64.decode(result)}if(asUTF8&&this.options.binary){result=JSZip.prototype.utf8decode(result)}else{result=JSZip.utils.transformTo("string",result)}if(!asUTF8&&!this.options.binary){result=JSZip.prototype.utf8encode(result)}returnresult};varZipObject=function(name,data,options){this.name=name;this._data=data;this.options=options};ZipObject.prototype={asText:function(){returndataToString.call(this,true)},asBinary:function(){returndataToString.call(this,false)},asNodeBuffer:function(){varresult=getBinaryData(this);returnJSZip.utils.transformTo("nodebuffer",result)},asUint8Array:function(){varresult=getBinaryData(this);returnJSZip.utils.transformTo("uint8array",result)},asArrayBuffer:function(){returnthis.asUint8Array().buffer}};vardecToHex=function(dec,bytes){varhex="",i;for(i=0;i<bytes;i++){hex+=String.fromCharCode(dec&255);dec=dec>>>8}returnhex};varextend=function(){varresult={},i,attr;for(i=0;i<arguments.length;i++){for(attrinarguments[i]){if(arguments[i].hasOwnProperty(attr)&&typeofresult[attr]==="undefined"){result[attr]=arguments[i][attr]}}}returnresult};varprepareFileAttrs=function(o){o=o||{};if(o.base64===true&&o.binary==null){o.binary=true}o=extend(o,JSZip.defaults);o.date=o.date||newDate;if(o.compression!==null)o.compression=o.compression.toUpperCase();returno};varfileAdd=function(name,data,o){varparent=parentFolder(name),dataType=JSZip.utils.getTypeOf(data);if(parent){folderAdd.call(this,parent)}o=prepareFileAttrs(o);if(o.dir||data===null||typeofdata==="undefined"){o.base64=false;o.binary=false;data=null}elseif(dataType==="string"){if(o.binary&&!o.base64){if(o.optimizedBinaryString!==true){data=JSZip.utils.string2binary(data)}}}else{o.base64=false;o.binary=true;if(!dataType&&!(datainstanceofJSZip.CompressedObject)){thrownewError("The data of '"+name+"' is in an unsupported format !")}if(dataType==="arraybuffer"){data=JSZip.utils.transformTo("uint8array",data)}}varobject=newZipObject(name,data,o);this.files[name]=object;returnobject};varparentFolder=function(path){if(path.slice(-1)=="/"
out.i=data.read_shift(4);varcell={};cell.r=data.read_shift(4);cell.c=data.read_shift(4);out.r=encode_cell(cell);varflags=data.read_shift(1);if(flags&2)out.l="1";if(flags&8)out.a="1";returnout}functionparse_cc_bin(data,opts){varout=[];varpass=false;recordhopper(data,functionhopper_cc(val,R,RT){switch(R.n){case"BrtCalcChainItem$":out.push(val);break;case"BrtBeginCalcChain$":break;case"BrtEndCalcChain$":break;default:if(!pass||opts.WTF)thrownewError("Unexpected record "+RT+" "+R.n)}});returnout}functionwrite_cc_bin(data,opts){}functionparse_comments(zip,dirComments,sheets,sheetRels,opts){for(vari=0;i!=dirComments.length;++i){varcanonicalpath=dirComments[i];varcomments=parse_cmnt(getzipdata(zip,canonicalpath.replace(/^\//,""),true),canonicalpath,opts);if(!comments||!comments.length)continue;varsheetNames=keys(sheets);for(varj=0;j!=sheetNames.length;++j){varsheetName=sheetNames[j];varrels=sheetRels[sheetName];if(rels){varrel=rels[canonicalpath];if(rel)insertCommentsIntoSheet(sheetName,sheets[sheetName],comments)}}}}functioninsertCommentsIntoSheet(sheetName,sheet,comments){comments.forEach(function(comment){varcell=sheet[comment.ref];if(!cell){cell={};sheet[comment.ref]=cell;varrange=safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");varthisCell=decode_cell(comment.ref);if(range.s.r>thisCell.r)range.s.r=thisCell.r;if(range.e.r<thisCell.r)range.e.r=thisCell.r;if(range.s.c>thisCell.c)range.s.c=thisCell.c;if(range.e.c<thisCell.c)range.e.c=thisCell.c;varencoded=encode_range(range);if(encoded!==sheet["!ref"])sheet["!ref"]=encoded}if(!cell.c)cell.c=[];varo={a:comment.author,t:comment.t,r:comment.r};if(comment.h)o.h=comment.h;cell.c.push(o)})}functionparse_comments_xml(data,opts){if(data.match(/<(?:\w+:)?comments *\/>/))return[];varauthors=[];varcommentList=[];data.match(/<(?:\w+:)?authors>([^\u2603]*)<\/(?:\w+:)?authors>/)[1].split(/<\/\w*:?author>/).forEach(function(x){if(x===""||x.trim()==="")return;authors.push(x.match(/<(?:\w+:)?author[^>]*>(.*)/)[1])});(data.match(/<(?:\w+:)?commentList>([^\u2603]*)<\/(?:\w+:)?commentList>/)||["",""])[1].split(/<\/\w*:?comment>/).forEach(function(x,index){if(x===""||x.trim()==="")return;vary=parsexmltag(x.match(/<(?:\w+:)?comment[^>]*>/)[0]);varcomment={author:y.authorId&&authors[y.authorId]?authors[y.authorId]:undefined,ref:y.ref,guid:y.guid};varcell=decode_cell(y.ref);if(opts.sheetRows&&opts.sheetRows<=cell.r)return;vartextMatch=x.match(/<text>([^\u2603]*)<\/text>/);if(!textMatch||!textMatch[1])return;varrt=parse_si(textMatch[1]);comment.r=rt.r;comment.t=rt.t;if(opts.cellHTML)comment.h=rt.h;commentList.push(comment)});returncommentList}functionwrite_comments_xml(data,opts){}functionparse_BrtBeginComment(data,length){varout={};out.iauthor=data.read_shift(4);varrfx=parse_UncheckedRfX(data,16);out.rfx=rfx.s;out.ref=encode_cell(rfx.s);data.l+=16;returnout}varparse_BrtCommentAuthor=parse_XLWideString;varparse_BrtCommentText=parse_RichStr;functionparse_comments_bin(data,opts){varout=[];varauthors=[];varc={};varpass=false;recordhopper(data,functionhopper_cmnt(val,R,RT){switch(R.n){case"BrtCommentAuthor":authors.push(val);break;case"BrtBeginComment":c=val;break;case"BrtCommentText":c.t=val.t;c.h=val.h;c.r=val.r;break;case"BrtEndComment":c.author=authors[c.iauthor];deletec.iauthor;if(opts.sheetRows&&opts.sheetRows<=c.rfx.r)break;deletec.rfx;out.push(c);break;case"BrtBeginComments":break;case"BrtEndComments":break;case"BrtBeginCommentAuthors":break;case"BrtEndCommentAuthors":break;case"BrtBeginCommentList":break;case"BrtEndCommentList":break;default:if(!pass||opts.WTF)thrownewError("Unexpected record "+RT+" "+R.n)}});returnout}functionwrite_comments_bin(data,opts){}functionparse_CellParsedFormula(data,length){varcce=data.read_shift(4);returnparsenoop(data,length-4)}varstrs={};var_ssfopts={};RELS.WS="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";functionget_sst_id(sst,str){for(vari=0,len=sst.length;i<len;++i)if(sst[i].t===str){sst.Count++;returni}sst[len]={t:str};sst.Count++;sst.Unique++;returnlen}function
varevert_RE=evert_key(RecordEnum,"n");functionfix_opts_func(defaults){returnfunctionfix_opts(opts){for(vari=0;i!=defaults.length;++i){vard=defaults[i];if(opts[d[0]]===undefined)opts[d[0]]=d[1];if(d[2]==="n")opts[d[0]]=Number(opts[d[0]])}}}varfix_read_opts=fix_opts_func([["cellNF",false],["cellHTML",true],["cellFormula",true],["cellStyles",false],["sheetStubs",false],["sheetRows",0,"n"],["bookDeps",false],["bookSheets",false],["bookProps",false],["bookFiles",false],["bookVBA",false],["WTF",false]]);varfix_write_opts=fix_opts_func([["bookSST",false],["bookType","xlsx"],["WTF",false]]);functionsafe_parse_wbrels(wbrels,sheets){if(!wbrels)return0;try{wbrels=sheets.map(functionpwbr(w){return[w.name,wbrels["!id"][w.id].Target]})}catch(e){returnnull}return!wbrels||wbrels.length===0?null:wbrels}functionsafe_parse_ws(zip,path,relsPath,sheet,sheetRels,sheets,opts){try{sheetRels[sheet]=parse_rels(getzipdata(zip,relsPath,true),path);sheets[sheet]=parse_ws(getzipdata(zip,path),path,opts,sheetRels[sheet])}catch(e){if(opts.WTF)throwe}}varnodirs=functionnodirs(x){returnx.substr(-1)!="/"};functionparse_zip(zip,opts){make_ssf(SSF);opts=opts||{};fix_read_opts(opts);reset_cp();varentries=keys(zip.files).filter(nodirs).sort();vardir=parse_ct(getzipdata(zip,"[Content_Types].xml"),opts);varxlsb=false;varsheets,binname;if(dir.workbooks.length===0){binname="xl/workbook.xml";if(getzipdata(zip,binname,true))dir.workbooks.push(binname)}if(dir.workbooks.length===0){binname="xl/workbook.bin";if(!getzipfile(zip,binname,true))thrownewError("Could not find workbook");dir.workbooks.push(binname);xlsb=true}if(dir.workbooks[0].substr(-3)=="bin")xlsb=true;if(xlsb)set_cp(1200);if(!opts.bookSheets&&!opts.bookProps){strs=[];if(dir.sst)strs=parse_sst(getzipdata(zip,dir.sst.replace(/^\//,"")),dir.sst,opts);styles={};if(dir.style)styles=parse_sty(getzipdata(zip,dir.style.replace(/^\//,"")),dir.style,opts);themes={};if(opts.cellStyles&&dir.themes.length)themes=parse_theme(getzipdata(zip,dir.themes[0].replace(/^\//,""),true),dir.themes[0],opts)}varwb=parse_wb(getzipdata(zip,dir.workbooks[0].replace(/^\//,"")),dir.workbooks[0],opts);varprops={},propdata="";if(dir.coreprops.length!==0){propdata=getzipdata(zip,dir.coreprops[0].replace(/^\//,""),true);if(propdata)props=parse_core_props(propdata);if(dir.extprops.length!==0){propdata=getzipdata(zip,dir.extprops[0].replace(/^\//,""),true);if(propdata)parse_ext_props(propdata,props)}}varcustprops={};if(!opts.bookSheets||opts.bookProps){if(dir.custprops.length!==0){propdata=getzipdata(zip,dir.custprops[0].replace(/^\//,""),true);if(propdata)custprops=parse_cust_props(propdata,opts)}}varout={};if(opts.bookSheets||opts.bookProps){if(props.Worksheets&&props.SheetNames.length>0)sheets=props.SheetNames;elseif(wb.Sheets)sheets=wb.Sheets.map(functionpluck(x){returnx.name});if(opts.bookProps){out.Props=props;out.Custprops=custprops}if(typeofsheets!=="undefined")out.SheetNames=sheets;if(opts.bookSheets?out.SheetNames:opts.bookProps)returnout}sheets={};vardeps={};if(opts.bookDeps&&dir.calcchain)deps=parse_cc(getzipdata(zip,dir.calcchain.replace(/^\//,"")),dir.calcchain,opts);vari=0;varsheetRels={};varpath,relsPath;if(!props.Worksheets){varwbsheets=wb.Sheets;props.Worksheets=wbsheets.length;props.SheetNames=[];for(varj=0;j!=wbsheets.length;++j){props.SheetNames[j]=wbsheets[j].name}}varwbext=xlsb?"bin":"xml";varwbrelsfile="xl/_rels/workbook."+wbext+".rels";varwbrels=parse_rels(getzipdata(zip,wbrelsfile,true),wbrelsfile);if(wbrels)wbrels=safe_parse_wbrels(wbrels,wb.Sheets);varnmode=getzipdata(zip,"xl/worksheets/sheet.xml",true)?1:0;for(i=0;i!=props.Worksheets;++i){if(wbrels)path="xl/"+wbrels[i][1].replace(/[\/]?xl\//,"");else{path="xl/worksheets/sheet"+(i+1-nmode)+"."+wbext;path=path.replace(/sheet0\./,"sheet.")}relsPath=path.replace(/^(.*)(\/)([^\/]*)$/,"$1/_rels/$3.rels");safe_parse_ws(zip,path,relsPath,props.SheetNames[i],sheetRels,sheets,opts)}if(dir.comments)parse_comments(zip,dir.comments,sheets,sheetRels,opts);out={Directory:dir,Workbook:wb,Props:props,Custprops:custprops,Deps:deps,Sheet