diff --git a/core/client.js b/core/client.js index ec80f34c..ad6b1fbe 100644 --- a/core/client.js +++ b/core/client.js @@ -1029,6 +1029,97 @@ function removeFile() { } } +async function appExport() { + let JsZip = (await import('/static/jszip.min.js')).default; + let owner = window.location.pathname.split('/')[1].replace('~', ''); + let name = window.location.pathname.split('/')[2]; + let zip = new JsZip(); + zip.file(`${name}.json`, JSON.stringify({ + type: "tildefriends-app", + emoji: gApp.emoji || '📦', + })); + for (let file of Object.keys(gFiles)) { + zip.file(`${name}/${file}`, gFiles[file].buffer ?? gFiles[file].doc.doc.toString()); + } + let content = await zip.generateAsync({ + type: 'blob', + compression: 'DEFLATE', + }); + let a = document.createElement('a'); + a.href = URL.createObjectURL(content); + a.download = `${owner}_${name}.zip`; + a.click(); +} + +async function save_file_to_blob_id(name, file) { + console.log(`Saving ${name}.`); + let response = await fetch('/save', { + method: 'POST', + headers: { + 'Content-Type': 'application/binary', + }, + body: file, + }); + if (!response.ok) { + throw new Error('Saving "' + name + '": ' + response.status + ' ' + response.statusText); + } + let blob_id = await response.text(); + if (blob_id.charAt(0) == '/') { + blob_id = blob_id.substr(1); + } + return blob_id; +} + +async function appImport() { + let JsZip = (await import('/static/jszip.min.js')).default; + let input = document.createElement('input'); + input.type = 'file'; + input.click(); + input.onchange = async function() { + try { + for (let file of input.files) { + if (file.type != 'application/zip') { + console.log('This does not look like a .zip.'); + continue; + } + let buffer = await file.arrayBuffer(); + let zip = new JsZip(); + await zip.loadAsync(buffer); + let app_object; + let app_name; + for (let [name, object] of Object.entries(zip.files)) { + if (name.endsWith('.json') && name.indexOf('/') == -1) { + try { + let parsed = JSON.parse(await object.async('text')); + if (parsed.type == 'tildefriends-app') { + app_object = parsed; + app_name = name.substring(0, name.length - '.json'.length); + break; + } + } catch (e) { + console.log(e); + } + } + } + if (app_object) { + app_object.files = {}; + for (let [name, object] of Object.entries(zip.files)) { + if (!name.startsWith(app_name + '/') || name.endsWith('/')) { + continue; + } + app_object.files[name.substring(app_name.length + '/'.length)] = await save_file_to_blob_id(name, await object.async('arrayBuffer')); + } + let path = '/' + await save_file_to_blob_id(`${app_name}.json`, JSON.stringify(app_object)) + '/'; + console.log('Redirecting to:', path); + window.location.pathname = path; + } + } + } catch (e) { + alert(e.toString()); + } + } +} + window.addEventListener("load", function() { window.addEventListener("hashchange", hashChange); window.addEventListener("focus", focus); @@ -1040,6 +1131,8 @@ window.addEventListener("load", function() { document.getElementById('save').addEventListener('click', () => save()); document.getElementById('icon').addEventListener('click', () => changeIcon()); document.getElementById('delete').addEventListener('click', () => deleteApp()); + document.getElementById('export').addEventListener('click', () => appExport()); + document.getElementById('import').addEventListener('click', () => appImport()); document.getElementById('trace_button').addEventListener('click', function(event) { event.preventDefault(); trace(); diff --git a/core/core.js b/core/core.js index 88d95eb6..a71ff6e0 100644 --- a/core/core.js +++ b/core/core.js @@ -35,6 +35,7 @@ let k_static_files = [ {uri: '/', path: 'index.html', type: 'text/html; charset=UTF-8'}, {uri: '/client.js', type: 'text/javascript; charset=UTF-8'}, {uri: '/favicon.png', type: 'image/png'}, + {uri: '/jszip.min.js', type: 'text/javascript; charset=UTF-8'}, {uri: '/robots.txt', type: 'text/plain; charset=UTF-8'}, {uri: '/style.css', type: 'text/css; charset=UTF-8'}, {uri: '/tfrpc.js', type: 'text/javascript; charset=UTF-8', headers: {'Access-Control-Allow-Origin': 'null'}}, diff --git a/core/index.html b/core/index.html index 2560fd7f..231e9d74 100644 --- a/core/index.html +++ b/core/index.html @@ -22,6 +22,8 @@ + + diff --git a/core/jszip.min.js b/core/jszip.min.js new file mode 100644 index 00000000..b8fbd69c --- /dev/null +++ b/core/jszip.min.js @@ -0,0 +1 @@ +var t={Promise:Promise},e={base64:!0,array:!0,string:!0,nodebuffer:!1,nodestream:!1,get arraybuffer(){return"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array},get uint8array(){return"undefined"!=typeof Uint8Array},get blob(){return r()}},r=function(){var t;if("undefined"==typeof ArrayBuffer)t=!1;else{var e=new ArrayBuffer(0);try{t=0===new Blob([e],{type:"application/zip"}).size}catch(e){t=!1}}return r=function(){return t},t},i=e,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function a(t){return t}function s(t,e){for(var r=0;r1;)try{return o(t,r,e)}catch(t){e=Math.floor(e/2)}return function(t){for(var e="",r=0;r>4,r=(15&s)<<4|(o=n.indexOf(t.charAt(l++)))>>2,a=(3&o)<<6|(h=n.indexOf(t.charAt(l++))),u[d++]=e,64!==o&&(u[d++]=r),64!==h&&(u[d++]=a);return u}(r):a&&!0!==o&&(r=s(l=r,i.uint8array?new Uint8Array(l.length):new Array(l.length)))),r):t.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))},w=function(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null};w.prototype.push=function(t){this.emit("data",t)},w.prototype.end=function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},w.prototype.error=function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},w.prototype.on=function(t,e){return this._listeners[t].push(e),this},w.prototype.cleanUp=function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},w.prototype.emit=function(t,e){if(this._listeners[t])for(var r=0;r "+t:t};var b=function(t){for(var e=new Array(256),r=0;r<256;r++)e[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;return e[254]=e[254]=1,b=function(t){return e[t]},e[t]},k=function(t){return function(t){var e,r,n,a,s,o=t.length,h=0;for(a=0;a>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e}(t)},x=function(t){return function(t){var e,r,i,n,a=t.length,s=new Array(2*a);for(r=0,e=0;e4)s[r++]=65533,e+=n-1;else{for(i&=2===n?31:3===n?15:7;n>1&&e1?s[r++]=65533:i<65536?s[r++]=i:(i-=65536,s[r++]=55296|i>>10&1023,s[r++]=56320|1023&i)}return s.length!==r&&(s.subarray?s=s.subarray(0,r):s.length=r),d(s)}(t=f(i.uint8array?"uint8array":"array",t))},z=function(t){function e(){t.call(this,"utf-8 decode"),this.leftOver=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.processChunk=function(t){var e=f(i.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var r=e;(e=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),e.set(r,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var n=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+b(t[r])>e?r:e}(e),a=e;n!==e.length&&(i.uint8array?(a=e.subarray(0,n),this.leftOver=e.subarray(n,e.length)):(a=e.slice(0,n),this.leftOver=e.slice(n,e.length))),this.push({data:x(a),meta:t.meta})},e.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:x(this.leftOver),meta:{}}),this.leftOver=null)},e}(w),S=function(t){function e(){t.call(this,"utf-8 encode")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.processChunk=function(t){this.push({data:k(t.data),meta:t.meta})},e}(w),C=function(t){function e(e){t.call(this,"ConvertWorker to "+e),this.destType=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.processChunk=function(t){this.push({data:f(this.destType,t.data),meta:t.meta})},e}(w);function A(t,e,r){switch(t){case"blob":return function(t,e){return m("blob"),new Blob([t],{type:e})}(f("arraybuffer",e),r);case"base64":return function(t){for(var e,r,i,a,s,o,h,l=[],d=0,u=t.length,c=u,f="string"!=typeof t;d>2,s=(3&e)<<4|r>>4,o=c>1?(15&r)<<2|i>>6:64,h=c>2?63&i:64,l.push(n.charAt(a)+n.charAt(s)+n.charAt(o)+n.charAt(h));return l.join("")}(e);default:return f(t,e)}}function I(e,r){return new t.Promise((function(t,i){var n=[],a=e._internalType,s=e._outputType,o=e._mimeType;e.on("data",(function(t,e){n.push(t),r&&r(e)})).on("error",(function(t){n=[],i(t)})).on("end",(function(){try{var e=A(s,function(t,e){var r,i=0,n=null,a=0;for(r=0;r=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e}(w),B=function(t){function e(e){t.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.processChunk=function(e){if(e){var r=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=r+e.data.length}t.prototype.processChunk.call(this,e)},e}(w),D=function(){for(var t=[],e=0;e<256;e++){for(var r=e,i=0;i<8;i++)r=1&r?3988292384^r>>>1:r>>>1;t[e]=r}return D=function(){return t},t};function U(t,e){return void 0!==t&&t.length?"string"!==p(t)?function(t,e,r,i){var n=D(),a=i+r;t^=-1;for(var s=i;s>>8^n[255&(t^e[s])];return-1^t}(0|e,t,t.length,0):function(t,e,r,i){var n=D(),a=i+r;t^=-1;for(var s=i;s>>8^n[255&(t^e.charCodeAt(s))];return-1^t}(0|e,t,t.length,0):0}var j=function(t){function e(){t.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.processChunk=function(t){this.streamInfo.crc32=U(t.data,this.streamInfo.crc32||0),this.push(t)},e}(w),R=function(t,e,r,i,n){this.compressedSize=t,this.uncompressedSize=e,this.crc32=r,this.compression=i,this.compressedContent=n};R.prototype.getContentWorker=function(){var e=new F(t.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new B("data_length")),r=this;return e.on("end",(function(){if(this.streamInfo.data_length!==r.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},R.prototype.getCompressedWorker=function(){return new F(t.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)},R.createWorkerFrom=function(t,e,r){return t.pipe(new j).pipe(new B("uncompressedSize")).pipe(e.compressWorker(r)).pipe(new B("compressedSize")).withStreamInfo("compression",e)};var N=R,T=function(t,e,r){this.name=t,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=e,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}};T.prototype.internalStream=function(t){var e=null,r="string";try{if(!t)throw new Error("No output type specified.");var i="string"===(r=t.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),e=this._decompressWorker();var n=!this._dataBinary;n&&!i&&(e=e.pipe(new S)),!n&&i&&(e=e.pipe(new z))}catch(t){(e=new w("error")).error(t)}return new P(e,r,"")},T.prototype.async=function(t,e){return this.internalStream(t).accumulate(e)},T.prototype._compressWorker=function(t,e){if(this._data instanceof N&&this._data.compression.magic===t.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new S)),N.createWorkerFrom(r,t,e)},T.prototype._decompressWorker=function(){return this._data instanceof N?this._data.getContentWorker():this._data instanceof w?this._data:new F(this._data)};function W(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function L(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)W(r,i)&&(t[i]=r[i])}}return t}function Z(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)}var K={arraySet:function(t,e,r,i,n){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+i),n);else for(var a=0;a=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;return e[254]=e[254]=1,$=function(t){return e[t]},e[t]};function tt(t){var e,r,i,n,a,s=t.length,o=0;for(n=0;n>>6,e[a++]=128|63&r):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|63&r):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|63&r);return e}function et(t,e){if(e<65534&&(t.subarray&&V()||!t.subarray&&Q()))return String.fromCharCode.apply(null,Z(t,e));for(var r="",i=0;i4)o[i++]=65533,r+=a-1;else{for(n&=2===a?31:3===a?15:7;a>1&&r1?o[i++]=65533:n<65536?o[i++]=n:(n-=65536,o[i++]=55296|n>>10&1023,o[i++]=56320|1023&n)}return et(o,i)}function it(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+$(t[r])>e?r:e}function nt(t,e,r,i){for(var n=65535&t|0,a=t>>>16&65535|0,s=0;0!==r;){r-=s=r>2e3?2e3:r;do{a=a+(n=n+e[i++]|0)|0}while(--s);n%=65521,a%=65521}return n|a<<16|0}var at=function(){var t=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();return at=function(){return t},t};function st(t,e,r,i){var n=at(),a=i+r;t^=-1;for(var s=i;s>>8^n[255&(t^e[s])];return-1^t}function ot(t,e){var r,i,n,a,s,o,h,l,d,u,c,f,p,m,_,g,y,v,w,b,k,x,z,S,C;r=t.state,i=t.next_in,S=t.input,n=i+(t.avail_in-5),a=t.next_out,C=t.output,s=a-(e-t.avail_out),o=a+(t.avail_out-257),h=r.dmax,l=r.wsize,d=r.whave,u=r.wnext,c=r.window,f=r.hold,p=r.bits,m=r.lencode,_=r.distcode,g=(1<>>=w=v>>>24,p-=w,0===(w=v>>>16&255))C[a++]=65535&v;else{if(!(16&w)){if(0==(64&w)){v=m[(65535&v)+(f&(1<>>=w,p-=w),p<15&&(f+=S[i++]<>>=w=v>>>24,p-=w,!(16&(w=v>>>16&255))){if(0==(64&w)){v=_[(65535&v)+(f&(1<h){t.msg="invalid distance too far back",r.mode=30;break t}if(f>>>=w,p-=w,k>(w=a-s)){if((w=k-w)>d&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(x=0,z=c,0===u){if(x+=l-w,w2;)C[a++]=z[x++],C[a++]=z[x++],C[a++]=z[x++],b-=3;b&&(C[a++]=z[x++],b>1&&(C[a++]=z[x++]))}else{x=a-k;do{C[a++]=C[x++],C[a++]=C[x++],C[a++]=C[x++],b-=3}while(b>2);b&&(C[a++]=C[x++],b>1&&(C[a++]=C[x++]))}break}}break}}while(i>3,f&=(1<<(p-=b<<3))-1,t.next_in=i,t.next_out=a,t.avail_in=i=1&&0===P[b];b--);if(k>b&&(k=b),0===b)return n[a++]=20971520,n[a++]=20971520,o.bits=1,0;for(w=1;w0&&(0===t||1!==b))return-1;for(E[1]=0,y=1;y<15;y++)E[y+1]=E[y]+P[y];for(v=0;v852||2===t&&C>592)return 1;for(;;){p=y-z,s[v]f?(m=F[B+s[v]],_=I[O+s[v]]):(m=96,_=0),h=1<>z)+(l-=h)]=p<<24|m<<16|_|0}while(0!==l);for(h=1<>=1;if(0!==h?(A&=h-1,A+=h):A=0,v++,0==--P[y]){if(y===b)break;y=e[r+s[v]]}if(y>k&&(A&u)!==d){for(0===z&&(z=k),c+=w,S=1<<(x=y-z);x+z852||2===t&&C>592)return 1;n[d=A&u]=k<<24|x<<16|c-a|0}}return 0!==A&&(n[c+A]=y-z<<24|64<<16|0),o.bits=k,0}function ft(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function pt(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=q(320),this.work=q(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function mt(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=G(852),e.distcode=e.distdyn=G(592),e.sane=1,e.back=-1,0):-2}(t)):-2}function _t(t,e){var r,i;return t?(i=new pt,t.state=i,i.window=null,0!==(r=function(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?-2:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,mt(t))):-2}(t,e))&&(t.state=null),r):-2}var gt,yt,vt=!0;function wt(t){if(vt){var e;for(gt=G(512),yt=G(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ct(1,t.lens,0,288,gt,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ct(2,t.lens,0,32,yt,0,t.work,{bits:5}),vt=!1}t.lencode=gt,t.lenbits=9,t.distcode=yt,t.distbits=5}function bt(t,e,r,i){var n,a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(J(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((n=a.wsize-a.wnext)>i&&(n=i),J(a.window,e,r-i,n,a.wnext),(i-=n)?(J(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=st(r.check,A,2,0),l=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=30;break}if(8!=(15&l)){t.msg="unknown compression method",r.mode=30;break}if(d-=4,k=8+(15&(l>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){t.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(A[0]=255&l,A[1]=l>>>8&255,r.check=st(r.check,A,2,0)),l=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=i[a++]<>>8&255,A[2]=l>>>16&255,A[3]=l>>>24&255,r.check=st(r.check,A,4,0)),l=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=i[a++]<>8),512&r.flags&&(A[0]=255&l,A[1]=l>>>8&255,r.check=st(r.check,A,2,0)),l=0,d=0,r.mode=5;case 5:if(1024&r.flags){for(;d<16;){if(0===o)break t;o--,l+=i[a++]<>>8&255,r.check=st(r.check,A,2,0)),l=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((f=r.length)>o&&(f=o),f&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),J(r.head.extra,i,a,f,k)),512&r.flags&&(r.check=st(r.check,i,f,a)),o-=f,a+=f,r.length-=f),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break t;f=0;do{k=i[a+f++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&f>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=12;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=i[a++]<>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=i[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(wt(r),r.mode=20,6===e){l>>>=2,d-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=30}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=i[a++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&l,l=0,d=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(f=r.length){if(f>o&&(f=o),f>h&&(f=h),0===f)break t;J(n,i,a,f,s),o-=f,a+=f,h-=f,s+=f,r.length-=f;break}r.mode=12;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=i[a++]<>>=5,d-=5,r.ndist=1+(31&l),l>>>=5,d-=5,r.ncode=4+(15&l),l>>>=4,d-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,d-=3}for(;r.have<19;)r.lens[I[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,z={bits:r.lenbits},x=ct(0,r.lens,0,19,r.lencode,0,r.work,z),r.lenbits=z.bits,x){t.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,y=65535&C,!((_=C>>>24)<=d);){if(0===o)break t;o--,l+=i[a++]<>>=_,d-=_,r.lens[r.have++]=y;else{if(16===y){for(S=_+2;d>>=_,d-=_,0===r.have){t.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],f=3+(3&l),l>>>=2,d-=2}else if(17===y){for(S=_+3;d>>=_)),l>>>=3,d-=3}else{for(S=_+7;d>>=_)),l>>>=7,d-=7}if(r.have+f>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=30;break}for(;f--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,z={bits:r.lenbits},x=ct(1,r.lens,0,r.nlen,r.lencode,0,r.work,z),r.lenbits=z.bits,x){t.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,z={bits:r.distbits},x=ct(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,z),r.distbits=z.bits,x){t.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(o>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,r.hold=l,r.bits=d,ot(t,c),s=t.next_out,n=t.output,h=t.avail_out,a=t.next_in,i=t.input,o=t.avail_in,l=r.hold,d=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[l&(1<>>16&255,y=65535&C,!((_=C>>>24)<=d);){if(0===o)break t;o--,l+=i[a++]<>v)])>>>16&255,y=65535&C,!(v+(_=C>>>24)<=d);){if(0===o)break t;o--,l+=i[a++]<>>=v,d-=v,r.back+=v}if(l>>>=_,d-=_,r.back+=_,r.length=y,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){t.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(S=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[l&(1<>>16&255,y=65535&C,!((_=C>>>24)<=d);){if(0===o)break t;o--,l+=i[a++]<>v)])>>>16&255,y=65535&C,!(v+(_=C>>>24)<=d);){if(0===o)break t;o--,l+=i[a++]<>>=v,d-=v,r.back+=v}if(l>>>=_,d-=_,r.back+=_,64&g){t.msg="invalid distance code",r.mode=30;break}r.offset=y,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(S=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break t;if(f=c-h,r.offset>f){if((f=r.offset-f)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=30;break}f>r.wnext?(f-=r.wnext,p=r.wsize-f):p=r.wnext-f,f>r.length&&(f=r.length),m=r.window}else m=n,p=s-r.offset,f=r.length;f>h&&(f=h),h-=f,r.length-=f;do{n[s++]=m[p++]}while(--f);0===r.length&&(r.mode=21);break;case 26:if(0===h)break t;n[s++]=r.length,h--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===o)break t;o--,l|=i[a++]<=0&&r.windowBits<16&&(r.windowBits=-r.windowBits,0===r.windowBits&&(r.windowBits=-15)),!(r.windowBits>=0&&r.windowBits<16)||e&&e.windowBits||(r.windowBits+=32),r.windowBits>15&&r.windowBits<48&&0==(15&r.windowBits)&&(r.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new St,this.strm.avail_out=0;var i,n,a,s=_t(this.strm,r.windowBits);if(0!==s)throw new Error(zt[s]);if(this.header=new Ct,i=this.strm,n=this.header,i&&i.state&&(0==(2&(a=i.state).wrap)||(a.head=n,n.done=!1)),r.dictionary&&("string"==typeof r.dictionary?r.dictionary=tt(r.dictionary):"[object ArrayBuffer]"===At.call(r.dictionary)&&(r.dictionary=new Uint8Array(r.dictionary)),r.raw&&0!==(s=xt(this.strm,r.dictionary))))throw new Error(zt[s])};function Ot(t){for(var e=t.length;--e>=0;)t[e]=0}It.prototype.push=function(t,e){var r,i,n,a,s,o,h=this.strm,l=this.options.chunkSize,d=this.options.dictionary,u=!1;if(this.ended)return!1;i=e===~~e?e:!0===e?4:0,"string"==typeof t?h.input=function(t){for(var e=new Uint8Array(t.length),r=0,i=e.length;r0||0===h.avail_out)&&1!==r);return 1===r&&(i=4),4===i?(r=function(t){if(!t||!t.state)return-2;var e=t.state;return e.window&&(e.window=null),t.state=null,0}(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==i||(this.onEnd(0),h.avail_out=0,!0)},It.prototype.onData=function(t){this.chunks.push(t)},It.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=X(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Pt,Et,Ft,Bt,Dt,Ut,jt,Rt,Nt,Tt=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Wt=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Lt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Zt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Kt(t,e,r,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}function Mt(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function Ht(t){return t<256?Ft[t]:Ft[256+(t>>>7)]}function Jt(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function Xt(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<>>=1,r<<=1}while(--e>0);return r>>>1}function Gt(t,e,r){var i,n,a=new Array(16),s=0;for(i=1;i<=15;i++)a[i]=s=s+r[i-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=qt(a[o]++,o))}}function Qt(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function Vt(t){t.bi_valid>8?Jt(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function $t(t,e,r,i){var n=2*e,a=2*r;return t[n]>1;r>=1;r--)te(t,a,r);n=h;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],te(t,a,1),i=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=i,a[2*n]=a[2*r]+a[2*i],t.depth[n]=(t.depth[r]>=t.depth[i]?t.depth[r]:t.depth[i])+1,a[2*r+1]=a[2*i+1]=n,t.heap[1]=n++,te(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,i,n,a,s,o,h=e.dyn_tree,l=e.max_code,d=e.stat_desc.static_tree,u=e.stat_desc.has_stree,c=e.stat_desc.extra_bits,f=e.stat_desc.extra_base,p=e.stat_desc.max_length,m=0;for(a=0;a<=15;a++)t.bl_count[a]=0;for(h[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(a=h[2*h[2*(i=t.heap[r])+1]+1]+1)>p&&(a=p,m++),h[2*i+1]=a,i>l||(t.bl_count[a]++,s=0,i>=f&&(s=c[i-f]),o=h[2*i],t.opt_len+=o*(a+s),u&&(t.static_len+=o*(d[2*i+1]+s)));if(0!==m){do{for(a=p-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[p]--,m-=2}while(m>0);for(a=p;0!==a;a--)for(i=t.bl_count[a];0!==i;)(n=t.heap[--r])>l||(h[2*n+1]!==a&&(t.opt_len+=(a-h[2*n+1])*h[2*n],h[2*n+1]=a),i--)}}(t,e),Gt(a,l,t.bl_count)}function ie(t,e,r){var i,n,a=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(r+1)+1]=65535,i=0;i<=r;i++)n=s,s=e[2*(i+1)+1],++o>=7;i<30;i++)for(Ut[i]=n<<7,t=0;t<1<=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}function le(t,e,r,i){var n,a,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),re(t,t.l_desc),re(t,t.d_desc),s=function(t){var e;for(ie(t,t.dyn_ltree,t.l_desc.max_code),ie(t,t.dyn_dtree,t.d_desc.max_code),re(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Zt[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),n=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=n&&(n=a)):n=a=r+5,r+4<=n&&-1!==e?oe(t,e,r,i):4===t.strategy||a===n?(Xt(t,2+(i?1:0),3),ee(t,Pt,Et)):(Xt(t,4+(i?1:0),3),function(t,e,r,i){var n;for(Xt(t,e-257,5),Xt(t,r-1,5),Xt(t,i-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(Bt[r]+256+1)]++,t.dyn_dtree[2*Ht(e)]++),t.last_lit===t.lit_bufsize-1}function ue(t,e){return t.msg=zt[e],e}function ce(t){return(t<<1)-(t>4?9:0)}function fe(t){for(var e=t.length;--e>=0;)t[e]=0}function pe(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(J(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function me(t,e){le(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,pe(t.strm)}function _e(t,e){t.pending_buf[t.pending++]=e}function ge(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function ye(t,e){var r,i,n=t.max_chain_length,a=t.strstart,s=t.prev_length,o=t.nice_match,h=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,l=t.window,d=t.w_mask,u=t.prev,c=t.strstart+258,f=l[a+s-1],p=l[a+s];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(l[(r=e)+s]===p&&l[r+s-1]===f&&l[r]===l[a]&&l[++r]===l[a+1]){a+=2,r++;do{}while(l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&as){if(t.match_start=e,s=i,i>=o)break;f=l[a+s-1],p=l[a+s]}}}while((e=u[e&d])>h&&0!=--n);return s<=t.lookahead?s:t.lookahead}function ve(t){var e,r,i,n,a,s,o,h,l,d,u=t.w_size;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=u+(u-262)){J(t.window,t.window,u,u,0),t.match_start-=u,t.strstart-=u,t.block_start-=u,e=r=t.hash_size;do{i=t.head[--e],t.head[e]=i>=u?i-u:0}while(--r);e=r=u;do{i=t.prev[--e],t.prev[e]=i>=u?i-u:0}while(--r);n+=u}if(0===t.strm.avail_in)break;if(s=t.strm,o=t.window,h=t.strstart+t.lookahead,l=n,d=void 0,(d=s.avail_in)>l&&(d=l),r=0===d?0:(s.avail_in-=d,J(o,s.input,s.next_in,d,h),1===s.state.wrap?s.adler=nt(s.adler,o,d,h):2===s.state.wrap&&(s.adler=st(s.adler,o,d,h)),s.next_in+=d,s.total_in+=d,d),t.lookahead+=r,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(ve(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+r;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,me(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(me(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(me(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(me(t,!1),t.strm.avail_out),1)}function be(t,e){for(var r,i;;){if(t.lookahead<262){if(ve(t),t.lookahead<262&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<=3)if(i=de(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=de(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=(t.ins_h<5||e<0)return t?ue(t,-2):-2;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||666===i.status&&4!==e)return ue(t,0===t.avail_out?-5:-2);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,_e(i,31),_e(i,139),_e(i,8),i.gzhead?(_e(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),_e(i,255&i.gzhead.time),_e(i,i.gzhead.time>>8&255),_e(i,i.gzhead.time>>16&255),_e(i,i.gzhead.time>>24&255),_e(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),_e(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(_e(i,255&i.gzhead.extra.length),_e(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=st(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(_e(i,0),_e(i,0),_e(i,0),_e(i,0),_e(i,0),_e(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),_e(i,3),i.status=113);else{var s=8+(i.w_bits-8<<4)<<8;s|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(s|=32),s+=31-s%31,i.status=113,ge(i,s),0!==i.strstart&&(ge(i,t.adler>>>16),ge(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=st(t.adler,i.pending_buf,i.pending-n,n)),pe(t),n=i.pending,i.pending!==i.pending_buf_size));)_e(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=st(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=st(t.adler,i.pending_buf,i.pending-n,n)),pe(t),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}a=i.gzindexn&&(t.adler=st(t.adler,i.pending_buf,i.pending-n,n)),0===a&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=st(t.adler,i.pending_buf,i.pending-n,n)),pe(t),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}a=i.gzindexn&&(t.adler=st(t.adler,i.pending_buf,i.pending-n,n)),0===a&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&pe(t),i.pending+2<=i.pending_buf_size&&(_e(i,255&t.adler),_e(i,t.adler>>8&255),t.adler=0,i.status=113)):i.status=113),0!==i.pending){if(pe(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&ce(e)<=ce(r)&&4!==e)return ue(t,-5);if(666===i.status&&0!==t.avail_in)return ue(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&666!==i.status){var o=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(ve(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=de(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(me(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(me(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(me(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,i,n,a,s=t.window;;){if(t.lookahead<=258){if(ve(t),t.lookahead<=258&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=s[n=t.strstart-1])===s[++n]&&i===s[++n]&&i===s[++n]){a=t.strstart+258;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&nt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=de(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=de(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(me(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(me(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(me(t,!1),0===t.strm.avail_out)?1:2}(i,e):ze()[i.level].func(i,e);if(3!==o&&4!==o||(i.status=666),1===o||3===o)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===o&&(1===e?he(i):5!==e&&(oe(i,0,0,!1),3===e&&(fe(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),pe(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(_e(i,255&t.adler),_e(i,t.adler>>8&255),_e(i,t.adler>>16&255),_e(i,t.adler>>24&255),_e(i,255&t.total_in),_e(i,t.total_in>>8&255),_e(i,t.total_in>>16&255),_e(i,t.total_in>>24&255)):(ge(i,t.adler>>>16),ge(i,65535&t.adler)),pe(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)}var Ie=Object.prototype.toString,Oe=function(t){this.options=L({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new St,this.strm.avail_out=0;var r,i,n=function(t,e,r,i,n,a){if(!t)return-2;var s=1;if(-1===e&&(e=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),n<1||n>9||8!==r||i<8||i>15||e<0||e>9||a<0||a>4)return ue(t,-2);8===i&&(i=9);var o=new Se;return t.state=o,o.strm=t,o.wrap=s,o.gzhead=null,o.w_bits=i,o.w_size=1<=r.w_size&&(0===a&&(fe(r.head),r.strstart=0,r.block_start=0,r.insert=0),l=Y(r.w_size),J(l,e,d-r.w_size,r.w_size,0),e=l,d=r.w_size),s=t.avail_in,o=t.next_in,h=t.input,t.avail_in=d,t.next_in=0,t.input=e,ve(r);r.lookahead>=3;){i=r.strstart,n=r.lookahead-2;do{r.ins_h=(r.ins_h<0||0===a.avail_out)&&1!==r);return 4===i?(r=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?ue(t,-2):(t.state=null,113===e?ue(t,-3):0):-2}(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==i||(this.onEnd(0),a.avail_out=0,!0)},Oe.prototype.onData=function(t){this.chunks.push(t)},Oe.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=X(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Pe=function(){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array?"uint8array":"array";Pe=function(){return t}},Ee=function(t){function e(e,r){t.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=r,this.meta={}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(f(Pe(),t.data),!1)},e.prototype.flush=function(){t.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},e.prototype.cleanUp=function(){t.prototype.cleanUp.call(this),this._pako=null},e.prototype._createPako=function(){var t=this,e={raw:!0,level:this._pakoOptions.level||-1};this._pako="Deflate"===this._pakoAction?new Oe(e):new It(e),this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},e}(w),Fe={STORE:{magic:"\0\0",compressWorker:function(){return new w("STORE compression")},uncompressWorker:function(){return new w("STORE decompression")}},DEFLATE:{magic:"\b\0",compressWorker:function(t){return new Ee("Deflate",t)},uncompressWorker:function(){return new Ee("Inflate",{})}}},Be=function(t,e){var r,i="";for(r=0;r>>=8;return i},De=function(t,e,r,i,n,a){var s,o,h=t.file,l=t.compression,d=a!==k,u=f("string",a(h.name)),c=f("string",k(h.name)),p=h.comment,m=f("string",a(p)),_=f("string",k(p)),g=c.length!==h.name.length,y=_.length!==p.length,v="",w="",b="",x=h.dir,z=h.date,S={crc32:0,compressedSize:0,uncompressedSize:0};e&&!r||(S.crc32=t.crc32,S.compressedSize=t.compressedSize,S.uncompressedSize=t.uncompressedSize);var C=0;e&&(C|=8),d||!g&&!y||(C|=2048);var A=0,I=0;x&&(A|=16),"UNIX"===n?(I=798,A|=function(t,e){var r=t;return t||(r=e?16893:33204),(65535&r)<<16}(h.unixPermissions,x)):(I=20,A|=function(t,e){return 63&(t||0)}(h.dosPermissions)),s=z.getUTCHours(),s<<=6,s|=z.getUTCMinutes(),s<<=5,s|=z.getUTCSeconds()/2,o=z.getUTCFullYear()-1980,o<<=4,o|=z.getUTCMonth()+1,o<<=5,o|=z.getUTCDate(),g&&(w=Be(1,1)+Be(U(u),4)+c,v+="up"+Be(w.length,2)+w),y&&(b=Be(1,1)+Be(U(m),4)+_,v+="uc"+Be(b.length,2)+b);var O="";return O+="\n\0",O+=Be(C,2),O+=l.magic,O+=Be(s,2),O+=Be(o,2),O+=Be(S.crc32,4),O+=Be(S.compressedSize,4),O+=Be(S.uncompressedSize,4),O+=Be(u.length,2),{fileRecord:"PK"+(O+=Be(v.length,2))+u+v,dirRecord:"PK"+Be(I,2)+O+Be(m.length,2)+"\0\0\0\0"+Be(A,4)+Be(i,4)+u+v+m}},Ue=function(t){return"PK\b"+Be(t.crc32,4)+Be(t.compressedSize,4)+Be(t.uncompressedSize,4)},je=function(t){function e(e,r,i,n){t.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=r,this.zipPlatform=i,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(e){var r=e.meta.percent||0,i=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,t.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:i?(r+100*(i-n-1))/i:100}}))},e.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var r=De(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},e.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,r=De(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),e)this.push({data:Ue(t),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},e.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)r=(r<<8)+this.byteAt(e);return this.index+=t,r},Ne.prototype.readString=function(t){return f("string",this.readData(t))},Ne.prototype.readData=function(t){},Ne.prototype.lastIndexOfSignature=function(t){},Ne.prototype.readAndCheckSignature=function(t){},Ne.prototype.readDate=function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))};var Te=Ne,We=function(t){function e(e){t.call(this,e);for(var r=0;r=0;--a)if(this.data[a]===e&&this.data[a+1]===r&&this.data[a+2]===i&&this.data[a+3]===n)return a-this.zero;return-1},e.prototype.readAndCheckSignature=function(t){var e=t.charCodeAt(0),r=t.charCodeAt(1),i=t.charCodeAt(2),n=t.charCodeAt(3),a=this.readData(4);return e===a[0]&&r===a[1]&&i===a[2]&&n===a[3]},e.prototype.readData=function(t){if(this.checkOffset(t),0===t)return[];var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e}(Te),Le=function(t){function e(e){t.call(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},e.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},e.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},e.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e}(Te),Ze=function(t){function e(e){t.call(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e}(We);function Ke(t){var e=p(t);return m(e),"string"!==e||i.uint8array?i.uint8array?new Ze(f("uint8array",t)):new We(f("array",t)):new Le(t)}var Me=function(t,e){this.options=t,this.loadOptions=e};Me.prototype.isEncrypted=function(){return 1==(1&this.bitFlag)},Me.prototype.useUTF8=function(){return 2048==(2048&this.bitFlag)},Me.prototype.readLocalPart=function(t){var e,r;if(t.skip(22),this.fileNameLength=t.readInt(2),r=t.readInt(2),this.fileName=t.readData(this.fileNameLength),t.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(e=function(t){for(var e in Fe)if(Fe.hasOwnProperty(e)&&Fe[e].magic===t)return Fe[e];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+_(this.compressionMethod)+" unknown (inner file : "+f("string",this.fileName)+")");this.decompressed=new N(this.compressedSize,this.uncompressedSize,this.crc32,e,t.readData(this.compressedSize))},Me.prototype.readCentralPart=function(t){this.versionMadeBy=t.readInt(2),t.skip(2),this.bitFlag=t.readInt(2),this.compressionMethod=t.readString(2),this.date=t.readDate(),this.crc32=t.readInt(4),this.compressedSize=t.readInt(4),this.uncompressedSize=t.readInt(4);var e=t.readInt(2);if(this.extraFieldsLength=t.readInt(2),this.fileCommentLength=t.readInt(2),this.diskNumberStart=t.readInt(2),this.internalFileAttributes=t.readInt(2),this.externalFileAttributes=t.readInt(4),this.localHeaderOffset=t.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");t.skip(e),this.readExtraFields(t),this.parseZIP64ExtraField(t),this.fileComment=t.readData(this.fileCommentLength)},Me.prototype.processAttributes=function(){this.unixPermissions=null,this.dosPermissions=null;var t=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0===t&&(this.dosPermissions=63&this.externalFileAttributes),3===t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},Me.prototype.parseZIP64ExtraField=function(t){if(this.extraFields[1]){var e=Ke(this.extraFields[1].value);-1===this.uncompressedSize&&(this.uncompressedSize=e.readInt(8)),-1===this.compressedSize&&(this.compressedSize=e.readInt(8)),-1===this.localHeaderOffset&&(this.localHeaderOffset=e.readInt(8)),-1===this.diskNumberStart&&(this.diskNumberStart=e.readInt(4))}},Me.prototype.readExtraFields=function(t){var e,r,i,n=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index1)throw new Error("Multi-volumes zip are not supported")},Je.prototype.readLocalFiles=function(){var t,e;for(t=0;t0)this.isSignature(e,"PK")||(this.reader.zero=i);else if(i<0)throw new Error("Corrupted zip: missing "+Math.abs(i)+" bytes.")},Je.prototype.prepareReader=function(t){this.reader=Ke(t)},Je.prototype.load=function(t){this.prepareReader(t),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()};var qe=function(t,e,r){var i,n=p(e),a=y(r||{},E);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(t=Qe(t)),a.createFolders&&(i=Ge(t))&&Ve.call(this,i,!0);var s="string"===n&&!1===a.binary&&!1===a.base64;r&&void 0!==r.binary||(a.binary=!s),(e instanceof N&&0===e.uncompressedSize||a.dir||!e||0===e.length)&&(a.base64=!1,a.binary=!0,e="",a.compression="STORE",n="string");var o=null;o=e instanceof N||e instanceof w?e:v(t,e,a.binary,a.optimizedBinaryString,a.base64);var h=new T(t,o,a);this.files[t]=h},Ge=function(t){"/"===t.slice(-1)&&(t=t.substring(0,t.length-1));var e=t.lastIndexOf("/");return e>0?t.substring(0,e):""},Qe=function(t){return"/"!==t.slice(-1)&&(t+="/"),t},Ve=function(t,e){return e=void 0===e||e,t=Qe(t),this.files[t]||qe.call(this,t,null,{dir:!0,createFolders:e}),this.files[t]};function $e(t){return"[object RegExp]"===Object.prototype.toString.call(t)}var tr=function t(){if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new t;for(var r in this)"function"!=typeof this[r]&&(e[r]=this[r]);return e}},er={support:{configurable:!0},defaults:{configurable:!0},version:{configurable:!0},external:{configurable:!0}};tr.prototype.load=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},tr.prototype.forEach=function(t){var e,r,i;for(e in this.files)i=this.files[e],(r=e.slice(this.root.length,e.length))&&e.slice(0,this.root.length)===this.root&&t(r,i)},tr.prototype.filter=function(t){var e=[];return this.forEach((function(r,i){t(r,i)&&e.push(i)})),e},tr.prototype.file=function(t,e,r){if(1===arguments.length){if($e(t)){var i=t;return this.filter((function(t,e){return!e.dir&&i.test(t)}))}var n=this.files[this.root+t];return n&&!n.dir?n:null}return t=this.root+t,qe.call(this,t,e,r),this},tr.prototype.folder=function(t){if(!t)return this;if($e(t))return this.filter((function(e,r){return r.dir&&t.test(e)}));var e=this.root+t,r=Ve.call(this,e),i=this.clone();return i.root=r.name,i},tr.prototype.remove=function(t){t=this.root+t;var e=this.files[t];if(e||("/"!==t.slice(-1)&&(t+="/"),e=this.files[t]),e&&!e.dir)delete this.files[t];else for(var r=this.filter((function(e,r){return r.name.slice(0,t.length)===t})),i=0;i