2 lines
8.8 KiB
JavaScript
2 lines
8.8 KiB
JavaScript
var B=Uint8Array,Q=Uint16Array,kr=Int32Array,or=new B([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,0,0,0]),ur=new B([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,0,0]),gr=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Sr=function(r,a){for(var n=new Q(31),e=0;e<31;++e)n[e]=a+=1<<r[e-1];for(var v=new kr(n[30]),e=1;e<30;++e)for(var f=n[e];f<n[e+1];++f)v[f]=f-n[e]<<5|e;return{b:n,r:v}},Tr=Sr(or,2),Cr=Tr.b,Mr=Tr.r;Cr[28]=258,Mr[258]=28;var Er=Sr(ur,0),Dr=Er.b,yr=Er.r,xr=new Q(32768);for(var g=0;g<32768;++g){var L=(g&43690)>>1|(g&21845)<<1;L=(L&52428)>>2|(L&13107)<<2,L=(L&61680)>>4|(L&3855)<<4,xr[g]=((L&65280)>>8|(L&255)<<8)>>1}var Z=function(r,a,n){for(var e=r.length,v=0,f=new Q(a);v<e;++v)r[v]&&++f[r[v]-1];var o=new Q(a);for(v=1;v<a;++v)o[v]=o[v-1]+f[v-1]<<1;var w;if(n){w=new Q(1<<a);var t=15-a;for(v=0;v<e;++v)if(r[v])for(var F=v<<4|r[v],i=a-r[v],l=o[r[v]-1]++<<i,c=l|(1<<i)-1;l<=c;++l)w[xr[l]>>t]=F}else for(w=new Q(e),v=0;v<e;++v)r[v]&&(w[v]=xr[o[r[v]-1]++]>>15-r[v]);return w},m=new B(288);for(var g=0;g<144;++g)m[g]=8;for(var g=144;g<256;++g)m[g]=9;for(var g=256;g<280;++g)m[g]=7;for(var g=280;g<288;++g)m[g]=8;var fr=new B(32);for(var g=0;g<32;++g)fr[g]=5;var Gr=Z(m,9,0),Hr=Z(m,9,1),Jr=Z(fr,5,0),Kr=Z(fr,5,1),hr=function(r){for(var a=r[0],n=1;n<r.length;++n)r[n]>a&&(a=r[n]);return a},W=function(r,a,n){var e=a/8|0;return(r[e]|r[e+1]<<8)>>(a&7)&n},wr=function(r,a){var n=a/8|0;return(r[n]|r[n+1]<<8|r[n+2]<<16)>>(a&7)},Fr=function(r){return(r+7)/8|0},Ur=function(r,a,n){return(a==null||a<0)&&(a=0),(n==null||n>r.length)&&(n=r.length),new B(r.subarray(a,n))},Nr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],X=function(r,a,n){var e=new Error(a||Nr[r]);if(e.code=r,Error.captureStackTrace&&Error.captureStackTrace(e,X),!n)throw e;return e},Pr=function(r,a,n,e){var v=r.length,f=e?e.length:0;if(!v||a.f&&!a.l)return n||new B(0);var o=!n,w=o||a.i!=2,t=a.i;o&&(n=new B(v*3));var F=function(ar){var nr=n.length;if(ar>nr){var d=new B(Math.max(nr*2,ar));d.set(n),n=d}},i=a.f||0,l=a.p||0,c=a.b||0,M=a.l,E=a.d,x=a.m,D=a.n,V=v*8;do{if(!M){i=W(r,l,1);var J=W(r,l+1,3);if(l+=3,J)if(J==1)M=Hr,E=Kr,x=9,D=5;else if(J==2){var O=W(r,l,31)+257,A=W(r,l+10,15)+4,h=O+W(r,l+5,31)+1;l+=14;for(var u=new B(h),S=new B(19),y=0;y<A;++y)S[gr[y]]=W(r,l+y*3,7);l+=A*3;for(var q=hr(S),j=(1<<q)-1,K=Z(S,q,1),y=0;y<h;){var G=K[W(r,l,j)];l+=G&15;var z=G>>4;if(z<16)u[y++]=z;else{var T=0,b=0;for(z==16?(b=3+W(r,l,3),l+=2,T=u[y-1]):z==17?(b=3+W(r,l,7),l+=3):z==18&&(b=11+W(r,l,127),l+=7);b--;)u[y++]=T}}var H=u.subarray(0,O),C=u.subarray(O);x=hr(H),D=hr(C),M=Z(H,x,1),E=Z(C,D,1)}else X(1);else{var z=Fr(l)+4,I=r[z-4]|r[z-3]<<8,U=z+I;if(U>v){t&&X(0);break}w&&F(c+I),n.set(r.subarray(z,U),c),a.b=c+=I,a.p=l=U*8,a.f=i;continue}if(l>V){t&&X(0);break}}w&&F(c+131072);for(var rr=(1<<x)-1,R=(1<<D)-1,$=l;;$=l){var T=M[wr(r,l)&rr],N=T>>4;if(l+=T&15,l>V){t&&X(0);break}if(T||X(2),N<256)n[c++]=N;else if(N==256){$=l,M=null;break}else{var P=N-254;if(N>264){var y=N-257,k=or[y];P=W(r,l,(1<<k)-1)+Cr[y],l+=k}var Y=E[wr(r,l)&R],s=Y>>4;Y||X(3),l+=Y&15;var C=Dr[s];if(s>3){var k=ur[s];C+=wr(r,l)&(1<<k)-1,l+=k}if(l>V){t&&X(0);break}w&&F(c+131072);var p=c+P;if(c<C){var ir=f-C,lr=Math.min(C,p);for(ir+c<0&&X(3);c<lr;++c)n[c]=e[ir+c]}for(;c<p;++c)n[c]=n[c-C]}}a.l=M,a.p=$,a.b=c,a.f=i,M&&(i=1,a.m=x,a.d=E,a.n=D)}while(!i);return c!=n.length&&o?Ur(n,0,c):n.subarray(0,c)},_=function(r,a,n){n<<=a&7;var e=a/8|0;r[e]|=n,r[e+1]|=n>>8},er=function(r,a,n){n<<=a&7;var e=a/8|0;r[e]|=n,r[e+1]|=n>>8,r[e+2]|=n>>16},tr=function(r,a){for(var n=[],e=0;e<r.length;++e)r[e]&&n.push({s:e,f:r[e]});var v=n.length,f=n.slice();if(!v)return{t:Br,l:0};if(v==1){var o=new B(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(U,O){return U.f-O.f}),n.push({s:-1,f:25001});var w=n[0],t=n[1],F=0,i=1,l=2;for(n[0]={s:-1,f:w.f+t.f,l:w,r:t};i!=v-1;)w=n[n[F].f<n[l].f?F++:l++],t=n[F!=i&&n[F].f<n[l].f?F++:l++],n[i++]={s:-1,f:w.f+t.f,l:w,r:t};for(var c=f[0].s,e=1;e<v;++e)f[e].s>c&&(c=f[e].s);var M=new Q(c+1),E=br(n[i-1],M,0);if(E>a){var e=0,x=0,D=E-a,V=1<<D;for(f.sort(function(O,A){return M[A.s]-M[O.s]||O.f-A.f});e<v;++e){var J=f[e].s;if(M[J]>a)x+=V-(1<<E-M[J]),M[J]=a;else break}for(x>>=D;x>0;){var z=f[e].s;M[z]<a?x-=1<<a-M[z]++-1:++e}for(;e>=0&&x;--e){var I=f[e].s;M[I]==a&&(--M[I],++x)}E=a}return{t:new B(M),l:E}},br=function(r,a,n){return r.s==-1?Math.max(br(r.l,a,n+1),br(r.r,a,n+1)):a[r.s]=n},zr=function(r){for(var a=r.length;a&&!r[--a];);for(var n=new Q(++a),e=0,v=r[0],f=1,o=function(t){n[e++]=t},w=1;w<=a;++w)if(r[w]==v&&w!=a)++f;else{if(!v&&f>2){for(;f>138;f-=138)o(32754);f>2&&(o(f>10?f-11<<5|28690:f-3<<5|12305),f=0)}else if(f>3){for(o(v),--f;f>6;f-=6)o(8304);f>2&&(o(f-3<<5|8208),f=0)}for(;f--;)o(v);f=1,v=r[w]}return{c:n.subarray(0,e),n:a}},vr=function(r,a){for(var n=0,e=0;e<a.length;++e)n+=r[e]*a[e];return n},qr=function(r,a,n){var e=n.length,v=Fr(a+2);r[v]=e&255,r[v+1]=e>>8,r[v+2]=r[v]^255,r[v+3]=r[v+1]^255;for(var f=0;f<e;++f)r[v+f+4]=n[f];return(v+4+e)*8},Ar=function(r,a,n,e,v,f,o,w,t,F,i){_(a,i++,n),++v[256];for(var l=tr(v,15),c=l.t,M=l.l,E=tr(f,15),x=E.t,D=E.l,V=zr(c),J=V.c,z=V.n,I=zr(x),U=I.c,O=I.n,A=new Q(19),h=0;h<J.length;++h)++A[J[h]&31];for(var h=0;h<U.length;++h)++A[U[h]&31];for(var u=tr(A,7),S=u.t,y=u.l,q=19;q>4&&!S[gr[q-1]];--q);var j=F+5<<3,K=vr(v,m)+vr(f,fr)+o,G=vr(v,c)+vr(f,x)+o+14+3*q+vr(A,S)+2*A[16]+3*A[17]+7*A[18];if(t>=0&&j<=K&&j<=G)return qr(a,i,r.subarray(t,t+F));var T,b,H,C;if(_(a,i,1+(G<K)),i+=2,G<K){T=Z(c,M,0),b=c,H=Z(x,D,0),C=x;var rr=Z(S,y,0);_(a,i,z-257),_(a,i+5,O-1),_(a,i+10,q-4),i+=14;for(var h=0;h<q;++h)_(a,i+3*h,S[gr[h]]);i+=3*q;for(var R=[J,U],$=0;$<2;++$)for(var N=R[$],h=0;h<N.length;++h){var P=N[h]&31;_(a,i,rr[P]),i+=S[P],P>15&&(_(a,i,N[h]>>5&127),i+=N[h]>>12)}}else T=Gr,b=m,H=Jr,C=fr;for(var h=0;h<w;++h){var k=e[h];if(k>255){var P=k>>18&31;er(a,i,T[P+257]),i+=b[P+257],P>7&&(_(a,i,k>>23&31),i+=or[P]);var Y=k&31;er(a,i,H[Y]),i+=C[Y],Y>3&&(er(a,i,k>>5&8191),i+=ur[Y])}else er(a,i,T[k]),i+=b[k]}return er(a,i,T[256]),i+b[256]},Qr=new kr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Br=new B(0),Rr=function(r,a,n,e,v,f){var o=f.z||r.length,w=new B(e+o+5*(1+Math.ceil(o/7e3))+v),t=w.subarray(e,w.length-v),F=f.l,i=(f.r||0)&7;if(a){i&&(t[0]=f.r>>3);for(var l=Qr[a-1],c=l>>13,M=l&8191,E=(1<<n)-1,x=f.p||new Q(32768),D=f.h||new Q(E+1),V=Math.ceil(n/3),J=2*V,z=function(cr){return(r[cr]^r[cr+1]<<V^r[cr+2]<<J)&E},I=new kr(25e3),U=new Q(288),O=new Q(32),A=0,h=0,u=f.i||0,S=0,y=f.w||0,q=0;u+2<o;++u){var j=z(u),K=u&32767,G=D[j];if(x[K]=G,D[j]=K,y<=u){var T=o-u;if((A>7e3||S>24576)&&(T>423||!F)){i=Ar(r,t,0,I,U,O,h,S,q,u-q,i),S=A=h=0,q=u;for(var b=0;b<286;++b)U[b]=0;for(var b=0;b<30;++b)O[b]=0}var H=2,C=0,rr=M,R=K-G&32767;if(T>2&&j==z(u-R))for(var $=Math.min(c,T)-1,N=Math.min(32767,u),P=Math.min(258,T);R<=N&&--rr&&K!=G;){if(r[u+H]==r[u+H-R]){for(var k=0;k<P&&r[u+k]==r[u+k-R];++k);if(k>H){if(H=k,C=R,k>$)break;for(var Y=Math.min(R,k-2),s=0,b=0;b<Y;++b){var p=u-R+b&32767,ir=x[p],lr=p-ir&32767;lr>s&&(s=lr,G=p)}}}K=G,G=x[K],R+=K-G&32767}if(C){I[S++]=268435456|Mr[H]<<18|yr[C];var ar=Mr[H]&31,nr=yr[C]&31;h+=or[ar]+ur[nr],++U[257+ar],++O[nr],y=u+H,++A}else I[S++]=r[u],++U[r[u]]}}for(u=Math.max(u,y);u<o;++u)I[S++]=r[u],++U[r[u]];i=Ar(r,t,F,I,U,O,h,S,q,u-q,i),F||(f.r=i&7|t[i/8|0]<<3,i-=7,f.h=D,f.p=x,f.i=u,f.w=y)}else{for(var u=f.w||0;u<o+F;u+=65535){var d=u+65535;d>=o&&(t[i/8|0]=F,d=o),i=qr(t,i+1,r.subarray(u,d))}f.i=o}return Ur(w,0,e+Fr(i)+v)},Ir=function(){var r=1,a=0;return{p:function(n){for(var e=r,v=a,f=n.length|0,o=0;o!=f;){for(var w=Math.min(o+2655,f);o<w;++o)v+=e+=n[o];e=(e&65535)+15*(e>>16),v=(v&65535)+15*(v>>16)}r=e,a=v},d:function(){return r%=65521,a%=65521,(r&255)<<24|(r&65280)<<8|(a&255)<<8|a>>8}}},Vr=function(r,a,n,e,v){if(!v&&(v={l:1},a.dictionary)){var f=a.dictionary.subarray(-32768),o=new B(f.length+r.length);o.set(f),o.set(r,f.length),r=o,v.w=f.length}return Rr(r,a.level==null?6:a.level,a.mem==null?v.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+a.mem,n,e,v)},Or=function(r,a,n){for(;n;++a)r[a]=n,n>>>=8},Wr=function(r,a){var n=a.level,e=n==0?0:n<6?1:n==9?3:2;if(r[0]=120,r[1]=e<<6|(a.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,a.dictionary){var v=Ir();v.p(a.dictionary),Or(r,2,v.d())}},Xr=function(r,a){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&X(6,"invalid zlib data"),(r[1]>>5&1)==+!a&&X(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function $r(r,a){a||(a={});var n=Ir();n.p(r);var e=Vr(r,a,a.dictionary?6:2,4);return Wr(e,a),Or(e,e.length-4,n.d()),e}function _r(r,a){return Pr(r.subarray(Xr(r,a&&a.dictionary),-4),{i:2},a&&a.out,a&&a.dictionary)}var Yr=typeof TextDecoder<"u"&&new TextDecoder,Zr=0;try{Yr.decode(Br,{stream:!0}),Zr=1}catch{}export{_r as u,$r as z};
|