UNPKG

api-console-assets

Version:

This repo only exists to publish api console components to npm

420 lines (397 loc) 58.9 kB
<!-- @license Copyright 2016 The Advanced REST client authors <arc@mulesoft.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <link rel="import" href="../polymer/polymer.html"> <link rel="import" href="../arc-polyfills/arc-polyfills.html"> <link rel="import" href="zipjs-imports.html"> <!-- `<web-unzip>` A web component that unzips files. The elment, after assigning an array of files (either file from file input or from drop event) will read zip structure automatically. After structure is read it will set the `fileStructure` property and will fire `web-unzip-file-structure` custom event. It the `auto-read` attribute is set (`autoRead` property) then it will automatically ready files content and will send `web-unzip-read` custom event. Otherwise `getAllData()` or `getFileContent()` function must be called to read all / entry data. ## Dependency files This component uses web workers. Files required by the workers are included into the element body and in most cases it doesn't depend on external files. However, IE10 doesnt work this way. Or at least zip.js worker script and it throws unhandled error in the web worker. For IE10 and Safari it will import `inflate.js` and `deflate.js` scripts from `zipjs` folder. Make sure that the build process copies this two libraries into `bower_components/web-unzip/zipjs` directory. ### Killing the web worker The zip.js library uses web worker to unzip files. Each time the `file` property change previously created web worker will be killed and removed from memory. You can call the `closeLastReader()` function to close the worker manually. Later read file content will be not possible. Additionally the element will kill the web worker when it's detached from the document (web compnents detachedCallback). ### Example ``` <web-unzip></web-unzip> ``` @group Logic Elements @element web-unzip @demo demo/index.html --> <dom-module id="web-unzip"> <template> <style> :host { display: none; } </style> <script id="worker" type="javascript/worker"> (function(p){function m(a){var c=self[a.codecClass],d=a.sn;if(h[d])throw Error("duplicated sn");h[d]={codec:new c(a.options),crcInput:"input"===a.crcType,crcOutput:"output"===a.crcType,crc:new f};postMessage({type:"newTask",sn:d})}function n(a){var c=a.sn,d=a.type,b=a.data,e=h[c];!e&&a.codecClass&&(m(a),e=h[c]);a="append"===d;var f=l.now();if(a)var g=e.codec.append(b,function(a){postMessage({type:"progress",sn:c,loaded:a})});else delete h[c],g=e.codec.flush();var k=l.now()-f,f=l.now();b&&e.crcInput&& e.crc.append(b);g&&e.crcOutput&&e.crc.append(g);b=l.now()-f;d={type:d,sn:c,codecTime:k,crcTime:b};b=[d];g&&(d.data=g,b[1]=[g.buffer]);a||!e.crcInput&&!e.crcOutput||(d.crc=e.crc.get());postMessage.apply(void 0,b)}function f(){this.crc=-1}function k(){}addEventListener("message",function(a){a=a.data;var c=a.type,d=a.sn,b=q[c];if(b)try{b(a)}catch(e){postMessage({type:c,sn:d,error:{message:e.message,stack:e.stack}})}});var q={importScripts:function(a){a.scripts&&0<a.scripts.length&&importScripts.apply(void 0, a.scripts);postMessage({type:"importScripts"})},newTask:m,append:n,flush:n},h={},l=self.performance||Date;f.prototype.append=function(a){for(var c=this.crc|0,d=this.table,b=0,e=a.length|0;b<e;b++)c=c>>>8^d[(c^a[b])&255];this.crc=c};f.prototype.get=function(){return~this.crc};f.prototype.table=function(){var a,c,d=[];for(a=0;256>a;a++){var b=a;for(c=0;8>c;c++)b=b&1?b>>>1^3988292384:b>>>1;d[a]=b}return d}();p.NOOP=k;k.prototype.append=function(a,c){return a};k.prototype.flush=function(){}})(this); (function(M){function N(){function h(a,h,q,p,H,D,b,c,e,k,l){var g,f,m,d;var w=0;var C=q;do n[a[h+w]]++,w++,C--;while(0!==C);if(n[0]==q)return b[0]=-1,c[0]=0;var v=c[0];for(f=1;15>=f&&0===n[f];f++);var E=f;v<f&&(v=f);for(C=15;0!==C&&0===n[C];C--);var G=C;v>C&&(v=C);c[0]=v;for(c=1<<f;f<C;f++,c<<=1)if(0>(c-=n[f]))return-3;if(0>(c-=n[C]))return-3;n[C]+=c;x[1]=f=0;w=1;for(m=2;0!==--C;)x[m]=f+=n[w],m++,w++;w=C=0;do 0!==(f=a[h+w])&&(l[x[f]++]=C),w++;while(++C<q);q=x[G];w=x[0]=C=0;h=-1;var t=-v;for(d=m=y[0]= 0;E<=G;E++)for(a=n[E];0!==a--;){for(;E>t+v;){h++;t+=v;d=G-t;d=d>v?v:d;if((g=1<<(f=E-t))>a+1&&(g-=a+1,m=E,f<d))for(;++f<d&&!((g<<=1)<=n[++m]);)g-=n[m];d=1<<f;if(1440<k[0]+d)return-3;y[h]=m=k[0];k[0]+=d;0!==h?(x[h]=C,z[0]=f,z[1]=v,f=C>>>t-v,z[2]=m-y[h-1]-f,e.set(z,3*(y[h-1]+f))):b[0]=m}z[1]=E-t;w>=q?z[0]=192:l[w]<p?(z[0]=256>l[w]?0:96,z[2]=l[w++]):(z[0]=D[l[w]-p]+16+64,z[2]=H[l[w++]-p]);g=1<<E-t;for(f=C>>>t;f<d;f+=g)e.set(z,3*(m+f));for(f=1<<E-1;0!==(C&f);f>>>=1)C^=f;C^=f;for(f=(1<<t)-1;(C&f)!=x[h];)h--, t-=v,f=(1<<t)-1}return 0!==c&&1!=G?-5:0}function p(h){var v;a||(a=[],q=[],n=new Int32Array(16),z=[],y=new Int32Array(15),x=new Int32Array(16));q.length<h&&(q=[]);for(v=0;v<h;v++)q[v]=0;for(v=0;16>v;v++)n[v]=0;for(v=0;3>v;v++)z[v]=0;y.set(n.subarray(0,15),0);x.set(n.subarray(0,16),0)}var a,q,n,z,y,x;this.inflate_trees_bits=function(n,v,z,x,y){p(19);a[0]=0;n=h(n,0,19,19,null,null,z,v,x,a,q);if(-3==n)y.msg="oversubscribed dynamic bit lengths tree";else if(-5==n||0===v[0])y.msg="incomplete dynamic bit lengths tree", n=-3;return n};this.inflate_trees_dynamic=function(n,v,z,x,y,D,b,c,e){p(288);a[0]=0;D=h(z,0,n,257,S,T,D,x,c,a,q);if(0!=D||0===x[0])return-3==D?e.msg="oversubscribed literal/length tree":-4!=D&&(e.msg="incomplete literal/length tree",D=-3),D;p(288);D=h(z,n,v,0,U,V,b,y,c,a,q);return 0!=D||0===y[0]&&257<n?(-3==D?e.msg="oversubscribed distance tree":-5==D?(e.msg="incomplete distance tree",D=-3):-4!=D&&(e.msg="empty distance tree with lengths",D=-3),D):0}}function W(){var h,p=0,a,q=0,n=0,z=0,y=0,x=0,E= 0,v=0,G,K=0,H,D=0;this.init=function(b,c,e,k,l,g){h=0;E=b;v=c;G=e;K=k;H=l;D=g;a=null};this.proc=function(b,c,e){var k;var l=c.next_in_index;var g=c.avail_in;var f=b.bitb;var m=b.bitk;var d=b.write;for(k=d<b.read?b.read-d-1:b.end-d;;)switch(h){case 0:if(258<=k&&10<=g){b.bitb=f;b.bitk=m;c.avail_in=g;c.total_in+=l-c.next_in_index;c.next_in_index=l;b.write=d;a:{var w,C=G,L=K,M=H,N=D,t=b,A=c;k=A.next_in_index;d=A.avail_in;var B=t.bitb;var r=t.bitk;g=t.write;l=g<t.read?t.read-g-1:t.end-g;m=I[E];f=I[v]; do{for(;20>r;)d--,B|=(A.read_byte(k++)&255)<<r,r+=8;var J=B&m;var F=C;var O=L;var u=3*(O+J);if(0===(w=F[u]))B>>=F[u+1],r-=F[u+1],t.window[g++]=F[u+2],l--;else{do{B>>=F[u+1];r-=F[u+1];if(0!==(w&16)){w&=15;e=F[u+2]+(B&I[w]);B>>=w;for(r-=w;15>r;)d--,B|=(A.read_byte(k++)&255)<<r,r+=8;J=B&f;F=M;O=N;u=3*(O+J);w=F[u];do if(B>>=F[u+1],r-=F[u+1],0!==(w&16)){for(w&=15;r<w;)d--,B|=(A.read_byte(k++)&255)<<r,r+=8;u=F[u+2]+(B&I[w]);B>>=w;r-=w;l-=e;if(g>=u)u=g-u,0<g-u&&2>g-u?(t.window[g++]=t.window[u++],t.window[g++]= t.window[u++]):(t.window.set(t.window.subarray(u,u+2),g),g+=2,u+=2),e-=2;else{u=g-u;do u+=t.end;while(0>u);w=t.end-u;if(e>w){e-=w;if(0<g-u&&w>g-u){do t.window[g++]=t.window[u++];while(0!==--w)}else t.window.set(t.window.subarray(u,u+w),g),g+=w;u=0}}if(0<g-u&&e>g-u){do t.window[g++]=t.window[u++];while(0!==--e)}else t.window.set(t.window.subarray(u,u+e),g),g+=e;break}else if(0===(w&64))J+=F[u+2],J+=B&I[w],u=3*(O+J),w=F[u];else{A.msg="invalid distance code";e=A.avail_in-d;e=r>>3<e?r>>3:e;d+=e;k-=e; r-=e<<3;t.bitb=B;t.bitk=r;A.avail_in=d;A.total_in+=k-A.next_in_index;A.next_in_index=k;t.write=g;e=-3;break a}while(1);break}if(0===(w&64)){if(J+=F[u+2],J+=B&I[w],u=3*(O+J),0===(w=F[u])){B>>=F[u+1];r-=F[u+1];t.window[g++]=F[u+2];l--;break}}else{0!==(w&32)?(e=A.avail_in-d,e=r>>3<e?r>>3:e,d+=e,k-=e,r-=e<<3,t.bitb=B,t.bitk=r,A.avail_in=d,A.total_in+=k-A.next_in_index,A.next_in_index=k,t.write=g,e=1):(A.msg="invalid literal/length code",e=A.avail_in-d,e=r>>3<e?r>>3:e,d+=e,k-=e,r-=e<<3,t.bitb=B,t.bitk= r,A.avail_in=d,A.total_in+=k-A.next_in_index,A.next_in_index=k,t.write=g,e=-3);break a}}while(1)}}while(258<=l&&10<=d);e=A.avail_in-d;e=r>>3<e?r>>3:e;k-=e;t.bitb=B;t.bitk=r-(e<<3);A.avail_in=d+e;A.total_in+=k-A.next_in_index;A.next_in_index=k;t.write=g;e=0}l=c.next_in_index;g=c.avail_in;f=b.bitb;m=b.bitk;d=b.write;k=d<b.read?b.read-d-1:b.end-d;if(0!=e){h=1==e?7:9;break}}n=E;a=G;q=K;h=1;case 1:for(r=n;m<r;){if(0!==g)e=0;else return b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index= l,b.write=d,b.inflate_flush(c,e);g--;f|=(c.read_byte(l++)&255)<<m;m+=8}r=3*(q+(f&I[r]));f>>>=a[r+1];m-=a[r+1];B=a[r];if(0===B){z=a[r+2];h=6;break}if(0!==(B&16)){y=B&15;p=a[r+2];h=2;break}if(0===(B&64)){n=B;q=r/3+a[r+2];break}if(0!==(B&32)){h=7;break}h=9;c.msg="invalid literal/length code";e=-3;b.bitb=f;b.bitk=m;c.avail_in=g;c.total_in+=l-c.next_in_index;c.next_in_index=l;b.write=d;return b.inflate_flush(c,e);case 2:for(r=y;m<r;){if(0!==g)e=0;else return b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+= l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);g--;f|=(c.read_byte(l++)&255)<<m;m+=8}p+=f&I[r];f>>=r;m-=r;n=v;a=H;q=D;h=3;case 3:for(r=n;m<r;){if(0!==g)e=0;else return b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);g--;f|=(c.read_byte(l++)&255)<<m;m+=8}r=3*(q+(f&I[r]));f>>=a[r+1];m-=a[r+1];B=a[r];if(0!==(B&16)){y=B&15;x=a[r+2];h=4;break}if(0===(B&64)){n=B;q=r/3+a[r+2];break}h=9;c.msg="invalid distance code";e=-3;b.bitb= f;b.bitk=m;c.avail_in=g;c.total_in+=l-c.next_in_index;c.next_in_index=l;b.write=d;return b.inflate_flush(c,e);case 4:for(r=y;m<r;){if(0!==g)e=0;else return b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);g--;f|=(c.read_byte(l++)&255)<<m;m+=8}x+=f&I[r];f>>=r;m-=r;h=5;case 5:for(r=d-x;0>r;)r+=b.end;for(;0!==p;){if(0===k&&(d==b.end&&0!==b.read&&(d=0,k=d<b.read?b.read-d-1:b.end-d),0===k&&(b.write=d,e=b.inflate_flush(c,e),d=b.write,k=d<b.read? b.read-d-1:b.end-d,d==b.end&&0!==b.read&&(d=0,k=d<b.read?b.read-d-1:b.end-d),0===k)))return b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);b.window[d++]=b.window[r++];k--;r==b.end&&(r=0);p--}h=0;break;case 6:if(0===k&&(d==b.end&&0!==b.read&&(d=0,k=d<b.read?b.read-d-1:b.end-d),0===k&&(b.write=d,e=b.inflate_flush(c,e),d=b.write,k=d<b.read?b.read-d-1:b.end-d,d==b.end&&0!==b.read&&(d=0,k=d<b.read?b.read-d-1:b.end-d),0===k)))return b.bitb= f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);e=0;b.window[d++]=z;k--;h=0;break;case 7:7<m&&(m-=8,g++,l--);b.write=d;e=b.inflate_flush(c,e);d=b.write;if(b.read!=b.write)return b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);h=8;case 8:return e=1,b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);case 9:return e=-3,b.bitb= f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e);default:return e=-2,b.bitb=f,b.bitk=m,c.avail_in=g,c.total_in+=l-c.next_in_index,c.next_in_index=l,b.write=d,b.inflate_flush(c,e)}};this.free=function(){}}function X(h,p){var a=this,q=0,n=0,z=0,y=0,x,E=[0],v=[0],G=new W,K=0,H=new Int32Array(4320),D=new N;a.bitk=0;a.bitb=0;a.window=new Uint8Array(p);a.end=p;a.read=0;a.write=0;a.reset=function(b,c){c&&(c[0]=0);6==q&&G.free(b);q=0;a.bitk=0;a.bitb=0; a.read=a.write=0};a.reset(h,null);a.inflate_flush=function(b,c){var e=b.next_out_index;var k=a.read;var l=(k<=a.write?a.write:a.end)-k;l>b.avail_out&&(l=b.avail_out);0!==l&&-5==c&&(c=0);b.avail_out-=l;b.total_out+=l;b.next_out.set(a.window.subarray(k,k+l),e);e+=l;k+=l;k==a.end&&(k=0,a.write==a.end&&(a.write=0),l=a.write-k,l>b.avail_out&&(l=b.avail_out),0!==l&&-5==c&&(c=0),b.avail_out-=l,b.total_out+=l,b.next_out.set(a.window.subarray(k,k+l),e),e+=l,k+=l);b.next_out_index=e;a.read=k;return c};a.proc= function(b,c){var e;var k=b.next_in_index;var l=b.avail_in;var g=a.bitb;var f=a.bitk;var m=a.write;for(e=m<a.read?a.read-m-1:a.end-m;;)switch(q){case 0:for(;3>f;){if(0!==l)c=0;else return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);l--;g|=(b.read_byte(k++)&255)<<f;f+=8}var d=g&7;K=d&1;switch(d>>>1){case 0:g>>>=3;f-=3;d=f&7;g>>>=d;f-=d;q=1;break;case 1:d=[];var h=[],p=[[]],L=[[]];N.inflate_trees_fixed(d,h,p,L);G.init(d[0],h[0],p[0], 0,L[0],0);g>>>=3;f-=3;q=6;break;case 2:g>>>=3;f-=3;q=3;break;case 3:return g>>>=3,f-=3,q=9,b.msg="invalid block type",c=-3,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c)}break;case 1:for(;32>f;){if(0!==l)c=0;else return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);l--;g|=(b.read_byte(k++)&255)<<f;f+=8}if((~g>>>16&65535)!=(g&65535))return q=9,b.msg="invalid stored block lengths", c=-3,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);n=g&65535;g=f=0;q=0!==n?2:0!==K?7:0;break;case 2:if(0===l||0===e&&(m==a.end&&0!==a.read&&(m=0,e=m<a.read?a.read-m-1:a.end-m),0===e&&(a.write=m,c=a.inflate_flush(b,c),m=a.write,e=m<a.read?a.read-m-1:a.end-m,m==a.end&&0!==a.read&&(m=0,e=m<a.read?a.read-m-1:a.end-m),0===e)))return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b, c);c=0;d=n;d>l&&(d=l);d>e&&(d=e);a.window.set(b.read_buf(k,d),m);k+=d;l-=d;m+=d;e-=d;if(0!==(n-=d))break;q=0!==K?7:0;break;case 3:for(;14>f;){if(0!==l)c=0;else return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);l--;g|=(b.read_byte(k++)&255)<<f;f+=8}z=d=g&16383;if(29<(d&31)||29<(d>>5&31))return q=9,b.msg="too many length or distance symbols",c=-3,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write= m,a.inflate_flush(b,c);d=258+(d&31)+(d>>5&31);if(!x||x.length<d)x=[];else for(e=0;e<d;e++)x[e]=0;g>>>=14;f-=14;y=0;q=4;case 4:for(;y<4+(z>>>10);){for(;3>f;){if(0!==l)c=0;else return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);l--;g|=(b.read_byte(k++)&255)<<f;f+=8}x[P[y++]]=g&7;g>>>=3;f-=3}for(;19>y;)x[P[y++]]=0;E[0]=7;d=D.inflate_trees_bits(x,E,v,H,b);if(0!=d)return c=d,-3==c&&(x=null,q=9),a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+= k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);y=0;q=5;case 5:for(;;){d=z;if(!(y<258+(d&31)+(d>>5&31)))break;for(d=E[0];f<d;){if(0!==l)c=0;else return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);l--;g|=(b.read_byte(k++)&255)<<f;f+=8}d=H[3*(v[0]+(g&I[d]))+1];p=H[3*(v[0]+(g&I[d]))+2];if(16>p)g>>>=d,f-=d,x[y++]=p;else{e=18==p?7:p-14;for(h=18==p?11:3;f<d+e;){if(0!==l)c=0;else return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+= k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);l--;g|=(b.read_byte(k++)&255)<<f;f+=8}g>>>=d;f-=d;h+=g&I[e];g>>>=e;f-=e;e=y;d=z;if(e+h>258+(d&31)+(d>>5&31)||16==p&&1>e)return x=null,q=9,b.msg="invalid bit length repeat",c=-3,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);p=16==p?x[e-1]:0;do x[e++]=p;while(0!==--h);y=e}}v[0]=-1;e=[];h=[];p=[];L=[];e[0]=9;h[0]=6;d=z;d=D.inflate_trees_dynamic(257+(d&31),1+(d>>5&31),x,e, h,p,L,H,b);if(0!=d)return-3==d&&(x=null,q=9),c=d,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);G.init(e[0],h[0],H,p[0],H,L[0]);q=6;case 6:a.bitb=g;a.bitk=f;b.avail_in=l;b.total_in+=k-b.next_in_index;b.next_in_index=k;a.write=m;if(1!=(c=G.proc(a,b,c)))return a.inflate_flush(b,c);c=0;G.free(b);k=b.next_in_index;l=b.avail_in;g=a.bitb;f=a.bitk;m=a.write;e=m<a.read?a.read-m-1:a.end-m;if(0===K){q=0;break}q=7;case 7:a.write=m;c=a.inflate_flush(b, c);m=a.write;if(a.read!=a.write)return a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);q=8;case 8:return c=1,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);case 9:return c=-3,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index=k,a.write=m,a.inflate_flush(b,c);default:return c=-2,a.bitb=g,a.bitk=f,b.avail_in=l,b.total_in+=k-b.next_in_index,b.next_in_index= k,a.write=m,a.inflate_flush(b,c)}};a.free=function(b){a.reset(b,null);H=a.window=null};a.set_dictionary=function(b,c,e){a.window.set(b.subarray(c,c+e),0);a.read=a.write=e};a.sync_point=function(){return 1==q?1:0}}function Y(){function h(a){if(!a||!a.istate)return-2;a.total_in=a.total_out=0;a.msg=null;a.istate.mode=7;a.istate.blocks.reset(a,null);return 0}var p=this;p.mode=0;p.method=0;p.was=[0];p.need=0;p.marker=0;p.wbits=0;p.inflateEnd=function(a){p.blocks&&p.blocks.free(a);p.blocks=null;return 0}; p.inflateInit=function(a,q){a.msg=null;p.blocks=null;if(8>q||15<q)return p.inflateEnd(a),-2;p.wbits=q;a.istate.blocks=new X(a,1<<q);h(a);return 0};p.inflate=function(a,h){var n;if(!a||!a.istate||!a.next_in)return-2;h=4==h?-5:0;for(n=-5;;)switch(a.istate.mode){case 0:if(0===a.avail_in)return n;n=h;a.avail_in--;a.total_in++;if(8!=((a.istate.method=a.read_byte(a.next_in_index++))&15)){a.istate.mode=13;a.msg="unknown compression method";a.istate.marker=5;break}if((a.istate.method>>4)+8>a.istate.wbits){a.istate.mode= 13;a.msg="invalid window size";a.istate.marker=5;break}a.istate.mode=1;case 1:if(0===a.avail_in)return n;n=h;a.avail_in--;a.total_in++;var q=a.read_byte(a.next_in_index++)&255;if(0!==((a.istate.method<<8)+q)%31){a.istate.mode=13;a.msg="incorrect header check";a.istate.marker=5;break}if(0===(q&32)){a.istate.mode=7;break}a.istate.mode=2;case 2:if(0===a.avail_in)return n;n=h;a.avail_in--;a.total_in++;a.istate.need=(a.read_byte(a.next_in_index++)&255)<<24&4278190080;a.istate.mode=3;case 3:if(0===a.avail_in)return n; n=h;a.avail_in--;a.total_in++;a.istate.need+=(a.read_byte(a.next_in_index++)&255)<<16&16711680;a.istate.mode=4;case 4:if(0===a.avail_in)return n;n=h;a.avail_in--;a.total_in++;a.istate.need+=(a.read_byte(a.next_in_index++)&255)<<8&65280;a.istate.mode=5;case 5:if(0===a.avail_in)return n;a.avail_in--;a.total_in++;a.istate.need+=a.read_byte(a.next_in_index++)&255;a.istate.mode=6;return 2;case 6:return a.istate.mode=13,a.msg="need dictionary",a.istate.marker=0,-2;case 7:n=a.istate.blocks.proc(a,n);if(-3== n){a.istate.mode=13;a.istate.marker=0;break}0==n&&(n=h);if(1!=n)return n;a.istate.blocks.reset(a,a.istate.was);a.istate.mode=12;case 12:return 1;case 13:return-3;default:return-2}};p.inflateSetDictionary=function(a,h,n){var q=0,p=n;if(!a||!a.istate||6!=a.istate.mode)return-2;p>=1<<a.istate.wbits&&(p=(1<<a.istate.wbits)-1,q=n-p);a.istate.blocks.set_dictionary(h,q,p);a.istate.mode=7;return 0};p.inflateSync=function(a){var q,n;if(!a||!a.istate)return-2;13!=a.istate.mode&&(a.istate.mode=13,a.istate.marker= 0);if(0===(q=a.avail_in))return-5;var p=a.next_in_index;for(n=a.istate.marker;0!==q&&4>n;)a.read_byte(p)==Z[n]?n++:n=0!==a.read_byte(p)?0:4-n,p++,q--;a.total_in+=p-a.next_in_index;a.next_in_index=p;a.avail_in=q;a.istate.marker=n;if(4!=n)return-3;q=a.total_in;p=a.total_out;h(a);a.total_in=q;a.total_out=p;a.istate.mode=7;return 0};p.inflateSyncPoint=function(a){return a&&a.istate&&a.istate.blocks?a.istate.blocks.sync_point():-2}}function Q(){}function R(){var h=new Q,p=new Uint8Array(512),a=!1;h.inflateInit(); h.next_out=p;this.append=function(q,n){var z=[],y=0,x=0,E=0;if(0!==q.length){h.next_in_index=0;h.next_in=q;h.avail_in=q.length;do{h.next_out_index=0;h.avail_out=512;0!==h.avail_in||a||(h.next_in_index=0,a=!0);var v=h.inflate(0);if(a&&-5==v){if(0!=h.avail_in)throw Error("inflating: bad input");}else if(0!=v&&1!=v)throw Error("inflating: "+h.msg);if((a||1==v)&&h.avail_in==q.length)throw Error("inflating: bad input");h.next_out_index&&(512==h.next_out_index?z.push(new Uint8Array(p)):z.push(new Uint8Array(p.subarray(0, h.next_out_index))));E+=h.next_out_index;n&&0<h.next_in_index&&h.next_in_index!=y&&(n(h.next_in_index),y=h.next_in_index)}while(0<h.avail_in||0===h.avail_out);var G=new Uint8Array(E);z.forEach(function(a){G.set(a,x);x+=a.length});return G}};this.flush=function(){h.inflateEnd()}}var I=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],aa=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24, 0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8, 122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210, 81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8, 43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8, 0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9, 245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85, 0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83, 7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],ba=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577], S=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],T=[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,112,112],U=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],V=[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];N.inflate_trees_fixed=function(h,p,a,q){h[0]=9;p[0]=5;a[0]=aa;q[0]=ba;return 0};var P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Z=[0,0,255,255]; Q.prototype={inflateInit:function(h){this.istate=new Y;h||(h=15);return this.istate.inflateInit(this,h)},inflate:function(h){return this.istate?this.istate.inflate(this,h):-2},inflateEnd:function(){if(!this.istate)return-2;var h=this.istate.inflateEnd(this);this.istate=null;return h},inflateSync:function(){return this.istate?this.istate.inflateSync(this):-2},inflateSetDictionary:function(h,p){return this.istate?this.istate.inflateSetDictionary(this,h,p):-2},read_byte:function(h){return this.next_in.subarray(h, h+1)[0]},read_buf:function(h,p){return this.next_in.subarray(h,h+p)}};M.zip?M.zip.Inflater=R:M.Inflater=R})(this); (function(W){function p(){var b=this;b.build_tree=function(a){var n=b.dyn_tree,d=b.stat_desc.static_tree,e=b.stat_desc.elems,g,z=-1;a.heap_len=0;a.heap_max=573;for(g=0;g<e;g++)0!==n[2*g]?(a.heap[++a.heap_len]=z=g,a.depth[g]=0):n[2*g+1]=0;for(;2>a.heap_len;){var r=a.heap[++a.heap_len]=2>z?++z:0;n[2*r]=1;a.depth[r]=0;a.opt_len--;d&&(a.static_len-=d[2*r+1])}b.max_code=z;for(g=Math.floor(a.heap_len/2);1<=g;g--)a.pqdownheap(n,g);r=e;do g=a.heap[1],a.heap[1]=a.heap[a.heap_len--],a.pqdownheap(n,1),d=a.heap[1], a.heap[--a.heap_max]=g,a.heap[--a.heap_max]=d,n[2*r]=n[2*g]+n[2*d],a.depth[r]=Math.max(a.depth[g],a.depth[d])+1,n[2*g+1]=n[2*d+1]=r,a.heap[1]=r++,a.pqdownheap(n,1);while(2<=a.heap_len);a.heap[--a.heap_max]=a.heap[1];g=b.dyn_tree;for(var z=b.stat_desc.static_tree,p=b.stat_desc.extra_bits,v=b.stat_desc.extra_base,A=b.stat_desc.max_length,u,F,O=0,e=0;15>=e;e++)a.bl_count[e]=0;g[2*a.heap[a.heap_max]+1]=0;for(r=a.heap_max+1;573>r;r++)d=a.heap[r],e=g[2*g[2*d+1]+1]+1,e>A&&(e=A,O++),g[2*d+1]=e,d>b.max_code|| (a.bl_count[e]++,u=0,d>=v&&(u=p[d-v]),F=g[2*d],a.opt_len+=F*(e+u),z&&(a.static_len+=F*(z[2*d+1]+u)));if(0!==O){do{for(e=A-1;0===a.bl_count[e];)e--;a.bl_count[e]--;a.bl_count[e+1]+=2;a.bl_count[A]--;O-=2}while(0<O);for(e=A;0!==e;e--)for(d=a.bl_count[e];0!==d;)z=a.heap[--r],z>b.max_code||(g[2*z+1]!=e&&(a.opt_len+=(e-g[2*z+1])*g[2*z],g[2*z+1]=e),d--)}g=b.max_code;r=a.bl_count;a=[];d=0;for(e=1;15>=e;e++)a[e]=d=d+r[e-1]<<1;for(r=0;r<=g;r++)if(z=n[2*r+1],0!==z){d=2*r;e=a[z]++;p=0;do p|=e&1,e>>>=1,p<<=1; while(0<--z);n[d]=p>>>1}}}function v(b,a,n,d,e){this.static_tree=b;this.extra_bits=a;this.extra_base=n;this.elems=d;this.max_length=e}function u(b,a,n,d,e){this.good_length=b;this.max_lazy=a;this.nice_length=n;this.max_chain=d;this.func=e}function ua(b,a,n,d){var e=b[2*a];b=b[2*n];return e<b||e==b&&d[a]<=d[n]}function wa(){function b(){var a;for(a=0;286>a;a++)P[2*a]=0;for(a=0;30>a;a++)Q[2*a]=0;for(a=0;19>a;a++)D[2*a]=0;P[512]=1;I=ia=l.opt_len=l.static_len=0}function a(a,h){var c,w=-1,e=a[1],b=0,f= 7,d=4;0===e&&(f=138,d=3);a[2*(h+1)+1]=65535;for(c=0;c<=h;c++){var g=e;e=a[2*(c+1)+1];++b<f&&g==e||(b<d?D[2*g]+=b:0!==g?(g!=w&&D[2*g]++,D[32]++):10>=b?D[34]++:D[36]++,b=0,w=g,0===e?(f=138,d=3):g==e?(f=6,d=3):(f=7,d=4))}}function n(a){l.pending_buf[l.pending++]=a}function d(a){n(a&255);n(a>>>8&255)}function e(a,h){E>16-h?(G|=a<<E&65535,d(G),G=a>>>16-E,E+=h-16):(G|=a<<E&65535,E+=h)}function g(a,h){var c=2*a;e(h[c]&65535,h[c+1]&65535)}function z(a,h){var c,w=-1,b=a[1],f=0,d=7,k=4;0===b&&(d=138,k=3);for(c= 0;c<=h;c++){var l=b;b=a[2*(c+1)+1];if(!(++f<d&&l==b)){if(f<k){do g(l,D);while(0!==--f)}else 0!==l?(l!=w&&(g(l,D),f--),g(16,D),e(f-3,2)):10>=f?(g(17,D),e(f-3,3)):(g(18,D),e(f-11,7));f=0;w=l;0===b?(d=138,k=3):l==b?(d=6,k=3):(d=7,k=4)}}}function r(){16==E?(d(G),E=G=0):8<=E&&(n(G&255),G>>>=8,E-=8)}function u(a,h){var c;l.pending_buf[X+2*I]=a>>>8&255;l.pending_buf[X+2*I+1]=a&255;l.pending_buf[ja+I]=h&255;I++;0===a?P[2*h]++:(ia++,a--,P[2*(p._length_code[h]+256+1)]++,Q[2*p.d_code(a)]++);if(0===(I&8191)&& 2<C){var w=8*I;var b=f-K;for(c=0;30>c;c++)w+=Q[2*c]*(5+p.extra_dbits[c]);if(ia<Math.floor(I/2)&&w>>>3<Math.floor(b/2))return!0}return I==S-1}function ra(a,h){var c=0;if(0!==I){do{var b=l.pending_buf[X+2*c]<<8&65280|l.pending_buf[X+2*c+1]&255;var w=l.pending_buf[ja+c]&255;c++;if(0===b)g(w,a);else{var f=p._length_code[w];g(f+256+1,a);var d=p.extra_lbits[f];0!==d&&(w-=p.base_length[f],e(w,d));b--;f=p.d_code(b);g(f,h);d=p.extra_dbits[f];0!==d&&(b-=p.base_dist[f],e(b,d))}}while(c<I)}g(256,a);Y=a[513]} function sa(){8<E?d(G):0<E&&n(G&255);E=G=0}function ta(a,h,c){sa();Y=8;c&&(d(h),d(~h));l.pending_buf.set(k.subarray(a,a+h),l.pending);l.pending+=h}function F(w){var h=0<=K?K:-1,c=f-K,d=0;if(0<C){Z.build_tree(l);aa.build_tree(l);a(P,Z.max_code);a(Q,aa.max_code);ka.build_tree(l);for(d=18;3<=d&&0===D[2*p.bl_order[d]+1];d--);l.opt_len+=3*(d+1)+14;var g=l.opt_len+3+7>>>3;var k=l.static_len+3+7>>>3;k<=g&&(g=k)}else g=k=c+5;if(c+4<=g&&-1!=h)e(0+(w?1:0),3),ta(h,c,!0);else if(k==g)e(2+(w?1:0),3),ra(v.static_ltree, v.static_dtree);else{e(4+(w?1:0),3);h=Z.max_code+1;c=aa.max_code+1;d+=1;e(h-257,5);e(c-1,5);e(d-4,4);for(g=0;g<d;g++)e(D[2*p.bl_order[g]+1],3);z(P,h-1);z(Q,c-1);ra(P,Q)}b();w&&sa();K=f;x.flush_pending()}function O(){var a;do{var h=ea-q-f;if(0===h&&0===f&&0===q)h=t;else if(-1==h)h--;else if(f>=t+t-262){k.set(k.subarray(t,t+t),0);ba-=t;f-=t;K-=t;var c=a=T;do{var b=y[--c]&65535;y[c]=b>=t?b-t:0}while(0!==--a);c=a=t;do b=L[--c]&65535,L[c]=b>=t?b-t:0;while(0!==--a);h+=t}if(0===x.avail_in)break;a=x.read_buf(k, f+q,h);q+=a;3<=q&&(m=k[f]&255,m=(m<<M^k[f+1]&255)&N)}while(262>q&&0!==x.avail_in)}function W(a){var h=65535;for(h>la-5&&(h=la-5);;){if(1>=q){O();if(0===q&&0==a)return 0;if(0===q)break}f+=q;q=0;var c=K+h;if(0===f||f>=c)if(q=f-c,f=c,F(!1),0===x.avail_out)return 0;if(f-K>=t-262&&(F(!1),0===x.avail_out))return 0}F(4==a);return 0===x.avail_out?4==a?2:0:4==a?3:1}function da(a){var h=ma,c=f,b=J,d=f>t-262?f-(t-262):0,e=na,g=R,w=f+258,l=k[c+b-1],n=k[c+b];J>=oa&&(h>>=2);e>q&&(e=q);do{var m=a;if(k[m+b]==n&& k[m+b-1]==l&&k[m]==k[c]&&k[++m]==k[c+1]){c+=2;for(m++;k[++c]==k[++m]&&k[++c]==k[++m]&&k[++c]==k[++m]&&k[++c]==k[++m]&&k[++c]==k[++m]&&k[++c]==k[++m]&&k[++c]==k[++m]&&k[++c]==k[++m]&&c<w;);m=258-(w-c);c=w-258;if(m>b){ba=a;b=m;if(m>=e)break;l=k[c+b-1];n=k[c+b]}}}while((a=L[a&g]&65535)>d&&0!==--h);return b<=q?b:q}function ha(a){for(var b=0,c,d;;){if(262>q){O();if(262>q&&0==a)return 0;if(0===q)break}3<=q&&(m=(m<<M^k[f+2]&255)&N,b=y[m]&65535,L[f&R]=y[m],y[m]=f);J=B;va=ba;B=2;0!==b&&J<fa&&(f-b&65535)<= t-262&&(2!=ca&&(B=da(b)),5>=B&&(1==ca||3==B&&4096<f-ba)&&(B=2));if(3<=J&&B<=J){d=f+q-3;c=u(f-1-va,J-3);q-=J-1;J-=2;do++f<=d&&(m=(m<<M^k[f+2]&255)&N,b=y[m]&65535,L[f&R]=y[m],y[m]=f);while(0!==--J);U=0;B=2;f++;if(c&&(F(!1),0===x.avail_out))return 0}else if(0!==U){if((c=u(0,k[f-1]&255))&&F(!1),f++,q--,0===x.avail_out)return 0}else U=1,f++,q--}0!==U&&(u(0,k[f-1]&255),U=0);F(4==a);return 0===x.avail_out?4==a?2:0:4==a?3:1}var l=this,x,H,la,V,t,pa,R,k,ea,L,y,m,T,qa,N,M,K,B,va,U,f,ba,q,J,ma,fa,C,ca,oa,na, Z=new p,aa=new p,ka=new p;l.depth=[];var ja,S,I,X,ia,Y,G,E;l.bl_count=[];l.heap=[];var P=[];var Q=[];var D=[];l.pqdownheap=function(a,b){for(var c=l.heap,d=c[b],h=b<<1;h<=l.heap_len;){h<l.heap_len&&ua(a,c[h+1],c[h],l.depth)&&h++;if(ua(a,d,c[h],l.depth))break;c[b]=c[h];b=h;h<<=1}c[b]=d};l.deflateInit=function(a,h,c,d,e,g){d||(d=8);e||(e=8);g||(g=0);a.msg=null;-1==h&&(h=6);if(1>e||9<e||8!=d||9>c||15<c||0>h||9<h||0>g||2<g)return-2;a.dstate=l;pa=c;t=1<<pa;R=t-1;qa=e+7;T=1<<qa;N=T-1;M=Math.floor((qa+3- 1)/3);k=new Uint8Array(2*t);L=[];y=[];S=1<<e+6;l.pending_buf=new Uint8Array(4*S);la=4*S;X=Math.floor(S/2);ja=3*S;C=h;ca=g;a.total_in=a.total_out=0;a.msg=null;l.pending=0;l.pending_out=0;H=113;V=0;Z.dyn_tree=P;Z.stat_desc=v.static_l_desc;aa.dyn_tree=Q;aa.stat_desc=v.static_d_desc;ka.dyn_tree=D;ka.stat_desc=v.static_bl_desc;E=G=0;Y=8;b();ea=2*t;for(a=y[T-1]=0;a<T-1;a++)y[a]=0;fa=A[C].max_lazy;oa=A[C].good_length;na=A[C].nice_length;ma=A[C].max_chain;q=K=f=0;B=J=2;return m=U=0};l.deflateEnd=function(){if(42!= H&&113!=H&&666!=H)return-2;k=L=y=l.pending_buf=null;l.dstate=null;return 113==H?-3:0};l.deflateParams=function(a,b,c){var d=0;-1==b&&(b=6);if(0>b||9<b||0>c||2<c)return-2;A[C].func!=A[b].func&&0!==a.total_in&&(d=a.deflate(1));C!=b&&(C=b,fa=A[C].max_lazy,oa=A[C].good_length,na=A[C].nice_length,ma=A[C].max_chain);ca=c;return d};l.deflateSetDictionary=function(a,b,c){a=c;var d=0;if(!b||42!=H)return-2;if(3>a)return 0;a>t-262&&(a=t-262,d=c-a);k.set(b.subarray(d,d+a),0);K=f=a;m=k[0]&255;m=(m<<M^k[1]&255)& N;for(b=0;b<=a-3;b++)m=(m<<M^k[b+2]&255)&N,L[b&R]=y[m],y[m]=b;return 0};l.deflate=function(a,b){if(4<b||0>b)return-2;if(!a.next_out||!a.next_in&&0!==a.avail_in||666==H&&4!=b)return a.msg=ga[4],-2;if(0===a.avail_out)return a.msg=ga[7],-5;x=a;var c=V;V=b;if(42==H){var d=8+(pa-8<<4)<<8;var h=(C-1&255)>>1;3<h&&(h=3);d|=h<<6;0!==f&&(d|=32);H=113;d+=31-d%31;n(d>>8&255);n(d&255)}if(0!==l.pending){if(x.flush_pending(),0===x.avail_out)return V=-1,0}else if(0===x.avail_in&&b<=c&&4!=b)return x.msg=ga[7],-5; if(666==H&&0!==x.avail_in)return a.msg=ga[7],-5;if(0!==x.avail_in||0!==q||0!=b&&666!=H){c=-1;switch(A[C].func){case 0:c=W(b);break;case 1:a:{for(c=0;;){if(262>q){O();if(262>q&&0==b){c=0;break a}if(0===q)break}3<=q&&(m=(m<<M^k[f+2]&255)&N,c=y[m]&65535,L[f&R]=y[m],y[m]=f);0!==c&&(f-c&65535)<=t-262&&2!=ca&&(B=da(c));if(3<=B)if(d=u(f-ba,B-3),q-=B,B<=fa&&3<=q){B--;do f++,m=(m<<M^k[f+2]&255)&N,c=y[m]&65535,L[f&R]=y[m],y[m]=f;while(0!==--B);f++}else f+=B,B=0,m=k[f]&255,m=(m<<M^k[f+1]&255)&N;else d=u(0,k[f]& 255),q--,f++;if(d&&(F(!1),0===x.avail_out)){c=0;break a}}F(4==b);c=0===x.avail_out?4==b?2:0:4==b?3:1}break;case 2:c=ha(b)}if(2==c||3==c)H=666;if(0==c||2==c)return 0===x.avail_out&&(V=-1),0;if(1==c){if(1==b)e(2,3),g(256,v.static_ltree),r(),9>1+Y+10-E&&(e(2,3),g(256,v.static_ltree),r()),Y=7;else if(e(0,3),ta(0,0,!0),3==b)for(c=0;c<T;c++)y[c]=0;x.flush_pending();if(0===x.avail_out)return V=-1,0}}return 4!=b?0:1}}function da(){this.total_out=this.avail_out=this.total_in=this.avail_in=this.next_out_index= this.next_in_index=0}function ha(b){var a=new da,n=new Uint8Array(512);b=b?b.level:-1;"undefined"==typeof b&&(b=-1);a.deflateInit(b);a.next_out=n;this.append=function(b,e){var d=[],p=0,r=0,u=0;if(b.length){a.next_in_index=0;a.next_in=b;a.avail_in=b.length;do{a.next_out_index=0;a.avail_out=512;var v=a.deflate(0);if(0!=v)throw Error("deflating: "+a.msg);a.next_out_index&&(512==a.next_out_index?d.push(new Uint8Array(n)):d.push(new Uint8Array(n.subarray(0,a.next_out_index))));u+=a.next_out_index;e&&0< a.next_in_index&&a.next_in_index!=p&&(e(a.next_in_index),p=a.next_in_index)}while(0<a.avail_in||0===a.avail_out);var A=new Uint8Array(u);d.forEach(function(a){A.set(a,r);r+=a.length});return A}};this.flush=function(){var b=[],e=0,g=0;do{a.next_out_index=0;a.avail_out=512;var p=a.deflate(4);if(1!=p&&0!=p)throw Error("deflating: "+a.msg);0<512-a.avail_out&&b.push(new Uint8Array(n.subarray(0,a.next_out_index)));g+=a.next_out_index}while(0<a.avail_in||0===a.avail_out);a.deflateEnd();var r=new Uint8Array(g); b.forEach(function(a){r.set(a,e);e+=a.length});return r}}var ea=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26, 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29, 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];p._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24, 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28];p.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0];p.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768, 1024,1536,2048,3072,4096,6144,8192,12288,16384,24576];p.d_code=function(b){return 256>b?ea[b]:ea[256+(b>>>7)]};p.extra_lbits=[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];p.extra_dbits=[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];p.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];p.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];v.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66, 8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57, 8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71, 9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99, 8,227,8];v.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5];v.static_l_desc=new v(v.static_ltree,p.extra_lbits,257,286,15);v.static_d_desc=new v(v.static_dtree,p.extra_dbits,0,30,15);v.static_bl_desc=new v(null,p.extra_blbits,0,19,7);var A=[new u(0,0,0,0,0),new u(4,4,8,4,1),new u(4,5,16,8,1),new u(4,6,32,32,1),new u(4,4,16,16,2),new u(8,16,32,32,2),new u(8,16,128,128,2),new u(8,32,128,256,2), new u(32,128,258,1024,2),new u(32,258,258,4096,2)],ga="need dictionary;stream end;;;stream error;data error;;buffer error;;".split(";");da.prototype={deflateInit:function(b,a){this.dstate=new wa;a||(a=15);return this.dstate.deflateInit(this,b,a)},deflate:function(b){return this.dstate?this.dstate.deflate(this,b):-2},deflateEnd:function(){if(!this.dstate)return-2;var b=this.dstate.deflateEnd();this.dstate=null;return b},deflateParams:function(b,a){return this.dstate?this.dstate.deflateParams(this, b,a):-2},deflateSetDictionary:function(b,a){return this.dstate?this.dstate.deflateSetDictionary(this,b,a):-2},read_buf:function(b,a,n){var d=this.avail_in;d>n&&(d=n);if(0===d)return 0;this.avail_in-=d;b.set(this.next_in.subarray(this.next_in_index,this.next_in_index+d),a);this.next_in_index+=d;this.total_in+=d;return d},flush_pending:function(){var b=this.dstate.pending;b>this.avail_out&&(b=this.avail_out);0!==b&&(this.next_out.set(this.dstate.pending_buf.subarray(this.dstate.pending_out,this.dstate.pending_out+ b),this.next_out_index),this.next_out_index+=b,this.dstate.pending_out+=b,this.total_out+=b,this.avail_out-=b,this.dstate.pending-=b,0===this.dstate.pending&&(this.dstate.pending_out=0))}};W.zip?W.zip.Deflater=ha:W.Deflater=ha})(this); </script> </template> <script> 'use strict'; Polymer({ is: 'web-unzip', /** * Fired when the list of files has been read from the zip file. * * @event web-unzip-file-structure * @property {Array} fileStructure Created structure. Depending on `flatStructure` property it * will be flat or complex structure. */ /** * Fired when all files were read. * The Entry elements in the structure will not contain `content` property with a File object. * They also will not contain `getData` function anymore. * * @event web-unzip-read * @property {Array} fileStructure Created structure. Depending on `flatStructure` property it * will be flat or complex structure. */ /** * Fired when error occurred anywhere in the element. * * @event error * @param {String} message An error message. */ properties: { /** * A file object returned by the `<file type="input">` or drop event. * Drop event always return FileList object which contains a list of files dropped so * this property expect iterable even if there will be only single file. */ file: Array, /** * The folder structure read from the zip file. * See overview for schema. */ fileStructure: { type: Array, notify: true, readOnly: true }, /** * Unizpped filesystem. */ result: { type: Object, readOnly: true, notify: true }, /** * If set, the `web-unzip-file-structure` and `web-unzip-read` events will fire an event * with flat structure of files instead of complex object. * * Note, this will not affect the `fileStructure` property which will always contain * complex file structure. */ flatStructure: Boolean, /** * If set it will read zip files content automatically after reading it's structure. * * This will update the `fileStrucure` property more than once. First when the structure has * been read and then again when files content is read. * * Both `web-unzip-file-structure` and `web-unzip-read` custom events will be fired. */ autoRead: Boolean }, /** * Checks if the browsers supports Web Workers from data:// scheme. * * @return {Boolean} True if web workers can be loaded. */ get _normalBrowser() { var ie10 = navigator.appVersion.indexOf('MSIE 10') !== -1; if (ie10) { return false; } return true; }, observers: ['_fileChnaged(file)'], ready: function() { this._loadMainThreadScripts(); }, attached: function() { this._loadMainThreadScripts(); }, detached: function() { this.closeLastReader(); }, // Resets element state reset: function() { this._setResult(undefined); this._setFileStructure(undefined); }, /** * Loads zip library scripts into the main thread * if current browser doesn't support web workers from the `data://` scheme. */ _loadMainThreadScripts: function() { if (this._normalBrowser) { return; } zip.useWebWorkers = false; if (!zip.Deflater) { var script = document.createElement('script'); script.src = this.resolveUrl('zipjs/deflate.js'); Polymer.dom(this.root).appendChild(script); console.info('Adding Deflate script to main thread.'); } if (!zip.Inflater) { var iScript = document.createElement('script'); iScript.src = this.resolveUrl('zipjs/inflate.js'); Polymer.dom(this.root).appendChild(iScript); console.info('Adding Inflate script to main thread.'); } }, /** * Creates a web worker from the element's content. * It sets `_workerUrl` property with the URL to the worker file. * * It does nothing if the browser doesn't suppoort this way of creating * web workers (Safari, IE10). */ _createWorker: function() { if (!this._normalBrowser || this._workerUrl) { return; } var blob = new Blob([this.$.worker.textContent], {type: 'text/javascript'}); this._workerUrl = window.URL.createObjectURL(blob); zip.workerScripts = { deflater: [this._workerUrl], inflater: [this._workerUrl] }; }, _fileChnaged: function(file) { if (!file || file.length !== 1) { this.reset(); return; } var source = file[0]; if (!source.type || source.type.indexOf('zip') === -1) { this.reset(); this._errorHandler('File not supported. File type is ' + source.type); return; } this.unzipFile(source); }, /** * Unzips the file. * * @param {Blob|File} file The file to unzip * @return {Promise} Promise resolved to list of files in the file. */ unzipFile: function(file) { var context = this; return this.closeLastReader() .then(function() { return this._unzipFileWorker(file); }.bind(this)) .then(function(entries) { context._entriesHandler(entries); return entries; }) .catch(function(message) { context._errorHandler(message); throw new Error(message); }); }, _unzipFileWorker: function(file) { this._createWorker(); var context = this; return new Promise(function(resolve, reject) { zip.createReader(new zip.BlobReader(file), function(zipReader) { context._zipReader = zipReader; zipReader.getEntries(function(entries) { resolve(entries); }); }, function(message) { reject(message); }); }); //READ: https://gildas-lormeau.github.io/zip.js/core-api.html //https://github.com/duanyao/zip.js/tree/integrate/WebContent }, /** * Manually closes the web worker created by previous zip file read. * * @return {Promise} A promise that resolves when the web worker was killed. */ closeLastReader: function() { if (!this._zipReader) { return Promise.resolve(); } return new Promise(function(resolve) { this._zipReader.close(function() { this._zipReader = undefined; if (this._workerUrl) { window.URL.revokeObjectURL(this._workerUrl); this._workerUrl = undefined; } resolve(); }.bind(this)); }.bind(this)); }, /** * Called when the zip reader reads all entries. * * @param {Array} entries List of entries. */ _entriesHandler: function(entries) { if (entries.length === 0) { this.fire('web-unzip-file-structure', { fileStructure: [] }); return; } this._setEntriesNames(entries); if (this.flatStructure) { this._setFileStructure(entries); this.__flatStructure = entries; } else { var structure = this._processFileStructure(entries); this._setFileStructure(structure); this.__flatStructure = entries; } this.fire('web-unzip-file-structure', { fileStructure: this.fileStructure }); if (this.autoRead) { this.getAllData(); } }, _errorHandler: function(message) { console.warn('web-unzip error', message); this.fire('error', { message: message }); }, /** * Sets a name property to each Entry object. */ _setEntriesNames: function(entries) { var len = entries.length; for (var i = 0; i < len; i++) { entries[i].name = this._computeName(entries[i]); } }, /** * Creates a structure of filesystem of list of all entries in the zip file. * * @param {Array} entries Result of zip.js read. * @return Array Transformed structure. */ _processFileStructure: function(entries) { var result = []; var _dirs = {}; var len = entries.length; for (var i = 0; i < len; i++) { var