Build 586984stable
Module 115943
26,010 characters · in 56594.6edaaeaaca198aca.jsDependencies
Source Raw
function(e){var t=function(){var e={nextZero:function(e,t){for(;0!=e[t];)t++;return t},readUshort:function(e,t){return e[t]<<8|e[t+1]},writeUshort:function(e,t,n){e[t]=n>>8&255,e[t+1]=255&n},readUint:function(e,t){return 0x1000000*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3])},writeUint:function(e,t,n){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n},readASCII:function(e,t,n){for(var r="",i=0;i<n;i++)r+=String.fromCharCode(e[t+i]);return r},writeASCII:function(e,t,n){for(var r=0;r<n.length;r++)e[t+r]=n.charCodeAt(r)},readBytes:function(e,t,n){for(var r=[],i=0;i<n;i++)r.push(e[t+i]);return r},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(t,n,r){for(var i,a="",o=0;o<r;o++)a+="%"+e.pad(t[n+o].toString(16));try{i=decodeURIComponent(a)}catch(i){return e.readASCII(t,n,r)}return i}};function t(t,n,r,i){var o=n*r,s=Math.ceil(n*a(i)/8),l=new Uint8Array(4*o),u=new Uint32Array(l.buffer),c=i.ctype,d=i.depth,f=e.readUshort;if(Date.now(),6==c){var p=o<<2;if(8==d)for(var h=0;h<p;h+=4)l[h]=t[h],l[h+1]=t[h+1],l[h+2]=t[h+2],l[h+3]=t[h+3];if(16==d)for(var h=0;h<p;h++)l[h]=t[h<<1]}else if(2==c){var m=i.tabs.tRNS;if(null==m){if(8==d)for(var h=0;h<o;h++){var g=3*h;u[h]=-0x1000000|t[g+2]<<16|t[g+1]<<8|t[g]}if(16==d)for(var h=0;h<o;h++){var g=6*h;u[h]=-0x1000000|t[g+4]<<16|t[g+2]<<8|t[g]}}else{var v=m[0],y=m[1],b=m[2];if(8==d)for(var h=0;h<o;h++){var _=h<<2,g=3*h;u[h]=-0x1000000|t[g+2]<<16|t[g+1]<<8|t[g],t[g]==v&&t[g+1]==y&&t[g+2]==b&&(l[_+3]=0)}if(16==d)for(var h=0;h<o;h++){var _=h<<2,g=6*h;u[h]=-0x1000000|t[g+4]<<16|t[g+2]<<8|t[g],f(t,g)==v&&f(t,g+2)==y&&f(t,g+4)==b&&(l[_+3]=0)}}}else if(3==c){var w=i.tabs.PLTE,x=i.tabs.tRNS,E=x?x.length:0;if(1==d)for(var S=0;S<r;S++)for(var k=S*s,T=S*n,h=0;h<n;h++){var _=T+h<<2,C=t[k+(h>>3)]>>7-(7&h)&1,P=3*C;l[_]=w[P],l[_+1]=w[P+1],l[_+2]=w[P+2],l[_+3]=C<E?x[C]:255}if(2==d)for(var S=0;S<r;S++)for(var k=S*s,T=S*n,h=0;h<n;h++){var _=T+h<<2,C=t[k+(h>>2)]>>6-((3&h)<<1)&3,P=3*C;l[_]=w[P],l[_+1]=w[P+1],l[_+2]=w[P+2],l[_+3]=C<E?x[C]:255}if(4==d)for(var S=0;S<r;S++)for(var k=S*s,T=S*n,h=0;h<n;h++){var _=T+h<<2,C=t[k+(h>>1)]>>4-((1&h)<<2)&15,P=3*C;l[_]=w[P],l[_+1]=w[P+1],l[_+2]=w[P+2],l[_+3]=C<E?x[C]:255}if(8==d)for(var h=0;h<o;h++){var _=h<<2,C=t[h],P=3*C;l[_]=w[P],l[_+1]=w[P+1],l[_+2]=w[P+2],l[_+3]=C<E?x[C]:255}}else if(4==c){if(8==d)for(var h=0;h<o;h++){var _=h<<2,A=h<<1,M=t[A];l[_]=M,l[_+1]=M,l[_+2]=M,l[_+3]=t[A+1]}if(16==d)for(var h=0;h<o;h++){var _=h<<2,A=h<<2,M=t[A];l[_]=M,l[_+1]=M,l[_+2]=M,l[_+3]=t[A+2]}}else if(0==c)for(var v=i.tabs.tRNS?i.tabs.tRNS:-1,S=0;S<r;S++){var R=S*s,I=S*n;if(1==d)for(var L=0;L<n;L++){var M=255*(t[R+(L>>>3)]>>>7-(7&L)&1),O=255*(M!=255*v);u[I+L]=O<<24|M<<16|M<<8|M}else if(2==d)for(var L=0;L<n;L++){var M=85*(t[R+(L>>>2)]>>>6-((3&L)<<1)&3),O=255*(M!=85*v);u[I+L]=O<<24|M<<16|M<<8|M}else if(4==d)for(var L=0;L<n;L++){var M=17*(t[R+(L>>>1)]>>>4-((1&L)<<2)&15),O=255*(M!=17*v);u[I+L]=O<<24|M<<16|M<<8|M}else if(8==d)for(var L=0;L<n;L++){var M=t[R+L],O=255*(M!=v);u[I+L]=O<<24|M<<16|M<<8|M}else if(16==d)for(var L=0;L<n;L++){var M=t[R+(L<<1)],O=255*(f(t,R+(L<<1))!=v);u[I+L]=O<<24|M<<16|M<<8|M}}return l}function n(e,t,n,s){Date.now();var l=new Uint8Array((Math.ceil(n*a(e)/8)+1+e.interlace)*s);return t=e.tabs.CgBI?i(t,l):r(t,l),Date.now(),0==e.interlace?t=o(t,e,0,n,s):1==e.interlace&&(t=function(e,t){for(var n=t.width,r=t.height,i=a(t),s=i>>3,l=Math.ceil(n*i/8),u=new Uint8Array(r*l),c=0,d=[0,0,4,0,2,0,1],f=[0,4,0,2,0,1,0],p=[8,8,8,4,4,2,2],h=[8,8,4,4,2,2,1],m=0;m<7;){for(var g=p[m],v=h[m],y=0,b=0,_=d[m];_<r;)_+=g,b++;for(var w=f[m];w<n;)w+=v,y++;var x=Math.ceil(y*i/8);o(e,t,c,y,b);for(var E=0,S=d[m];S<r;){for(var k=f[m],T=c+E*x<<3;k<n;){if(1==i){var C=e[T>>3];C=C>>7-(7&T)&1,u[S*l+(k>>3)]|=C<<7-(7&k)}if(2==i){var C=e[T>>3];C=C>>6-(7&T)&3,u[S*l+(k>>2)]|=C<<6-((3&k)<<1)}if(4==i){var C=e[T>>3];C=C>>4-(7&T)&15,u[S*l+(k>>1)]|=C<<4-((1&k)<<2)}if(i>=8)for(var P=S*l+k*s,A=0;A<s;A++)u[P+A]=e[(T>>3)+A];T+=i,k+=v}E++,S+=g}y*b!=0&&(c+=b*(1+x)),m+=1}return u}(t,e)),t}function r(e,t){return i(new Uint8Array(e.buffer,2,e.length-6),t)}var i=function(){var e,t,n=(e=Uint16Array,t=Uint32Array,{m:new e(16),v:new e(16),d:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o:[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,999,999,999],z:[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],B:new e(32),p:[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,65535,65535],w:[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],h:new t(32),g:new e(512),s:[],A:new e(32),t:[],k:new e(32768),c:[],a:[],n:new e(32768),e:[],C:new e(512),b:[],i:new e(32768),r:new t(286),f:new t(30),l:new t(19),u:new t(15e3),q:new e(65536),j:new e(32768)});function r(e,t){for(var r,i,a,o,s,l=e.length,u=n.v,o=0;o<=t;o++)u[o]=0;for(o=1;o<l;o+=2)u[e[o]]++;var c=n.m;for(i=1,r=0,u[0]=0;i<=t;i++)r=r+u[i-1]<<1,c[i]=r;for(a=0;a<l;a+=2)0!=(s=e[a+1])&&(e[a]=c[s],c[s]++)}function i(e,t,r){for(var i=e.length,a=n.i,o=0;o<i;o+=2)if(0!=e[o+1])for(var s=o>>1,l=e[o+1],u=s<<4|l,c=t-l,d=e[o]<<c,f=d+(1<<c);d!=f;)r[a[d]>>>15-t]=u,d++}function a(e,t){for(var r=n.i,i=15-t,a=0;a<e.length;a+=2){var o=e[a]<<t-e[a+1];e[a]=r[o]>>>i}}for(var o=0;o<32768;o++){var s=o;s=(0xff00ff00&(s=(0xf0f0f0f0&(s=(0xcccccccc&(s=(0xaaaaaaaa&s)>>>1|(0x55555555&s)<<1))>>>2|(0x33333333&s)<<2))>>>4|(0xf0f0f0f&s)<<4))>>>8|(0xff00ff&s)<<8,n.i[o]=(s>>>16|s<<16)>>>17}function l(e,t,n){for(;0!=t--;)e.push(0,n)}for(var o=0;o<32;o++)n.B[o]=n.o[o]<<3|n.z[o],n.h[o]=n.p[o]<<4|n.w[o];function u(e,t,n){return(e[t>>>3]|e[(t>>>3)+1]<<8)>>>(7&t)&(1<<n)-1}function c(e,t,n){return(e[t>>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16)>>>(7&t)&(1<<n)-1}function d(e,t){return(e[t>>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16)>>>(7&t)}function f(e,t){var n=e.length;if(t<=n)return e;var r=new Uint8Array(Math.max(n<<1,t));return r.set(e,0),r}function p(e,t,n,r){for(var i=0,a=0,o=r.length>>>1;a<n;){var s=e[a+t];r[a<<1]=0,r[(a<<1)+1]=s,s>i&&(i=s),a++}for(;a<o;)r[a<<1]=0,r[(a<<1)+1]=0,a++;return i}return l(n.s,144,8),l(n.s,112,9),l(n.s,24,7),l(n.s,8,8),r(n.s,9),i(n.s,9,n.g),a(n.s,9),l(n.t,32,5),r(n.t,5),i(n.t,5,n.A),a(n.t,5),l(n.b,19,0),l(n.c,286,0),l(n.e,30,0),l(n.a,320,0),function(e,t){var a,o,s=Uint8Array,l=0,h=0,m=0,g=0,v=0,y=0,b=0,_=0,w=0;if(3==e[0]&&0==e[1])return t||new s(0);var x=null==t;for(x&&(t=new s(e.length>>>2<<3));0==l;){if(l=c(e,w,1),h=c(e,w+1,2),w+=3,0==h){(7&w)!=0&&(w+=8-(7&w));var E=(w>>>3)+4,S=e[E-4]|e[E-3]<<8;x&&(t=f(t,_+S)),t.set(new s(e.buffer,e.byteOffset+E,S),_),w=E+S<<3,_+=S;continue}if(x&&(t=f(t,_+131072)),1==h&&(a=n.g,o=n.A,y=511,b=31),2==h){m=u(e,w,5)+257,g=u(e,w+5,5)+1,v=u(e,w+10,4)+4,w+=14;for(var k=1,T=0;T<38;T+=2)n.b[T]=0,n.b[T+1]=0;for(var T=0;T<v;T++){var C=u(e,w+3*T,3);n.b[(n.d[T]<<1)+1]=C,C>k&&(k=C)}w+=3*v,r(n.b,k),i(n.b,k,n.C),a=n.k,o=n.n,w=function(e,t,n,r,i,a){for(var o=0;o<n;){var s=e[d(r,i)&t];i+=15&s;var l=s>>>4;if(l<=15)a[o]=l,o++;else{var c=0,f=0;16==l?(f=3+u(r,i,2),i+=2,c=a[o-1]):17==l?(f=3+u(r,i,3),i+=3):18==l&&(f=11+u(r,i,7),i+=7);for(var p=o+f;o<p;)a[o]=c,o++}}return i}(n.C,(1<<k)-1,m+g,e,w,n.a);var P=p(n.a,0,m,n.c);y=(1<<P)-1;var A=p(n.a,m,g,n.e);b=(1<<A)-1,r(n.c,P),i(n.c,P,a),r(n.e,A),i(n.e,A,o)}for(;;){var M=a[d(e,w)&y];w+=15&M;var R=M>>>4;if(R>>>8==0)t[_++]=R;else if(256==R)break;else{var I=_+R-254;if(R>264){var L=n.B[R-257];I=_+(L>>>3)+u(e,w,7&L),w+=7&L}var O=o[d(e,w)&b];w+=15&O;var D=O>>>4,F=n.h[D],N=(F>>>4)+c(e,w,15&F);for(w+=15&F,x&&(t=f(t,_+131072));_<I;)t[_]=t[_++-N],t[_]=t[_++-N],t[_]=t[_++-N],t[_]=t[_++-N];_=I}}}return t.length==_?t:t.slice(0,_)}}();function a(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth}function o(e,t,n,r,i){var o=a(t),l=Math.ceil(r*o/8);o=Math.ceil(o/8);var u,c,d=e[n],f=0;if(d>1&&(e[n]=[0,0,1][d-2]),3==d)for(f=o;f<l;f++)e[f+1]=e[f+1]+(e[f+1-o]>>>1)&255;for(var p=0;p<i;p++)if(d=e[(c=(u=n+p*l)+p+1)-1],f=0,0==d)for(;f<l;f++)e[u+f]=e[c+f];else if(1==d){for(;f<o;f++)e[u+f]=e[c+f];for(;f<l;f++)e[u+f]=e[c+f]+e[u+f-o]}else if(2==d)for(;f<l;f++)e[u+f]=e[c+f]+e[u+f-l];else if(3==d){for(;f<o;f++)e[u+f]=e[c+f]+(e[u+f-l]>>>1);for(;f<l;f++)e[u+f]=e[c+f]+(e[u+f-l]+e[u+f-o]>>>1)}else{for(;f<o;f++)e[u+f]=e[c+f]+s(0,e[u+f-l],0);for(;f<l;f++)e[u+f]=e[c+f]+s(e[u+f-o],e[u+f-l],e[u+f-o-l])}return e}function s(e,t,n){var r=e+t-n,i=r-e,a=r-t,o=r-n;return i*i<=a*a&&i*i<=o*o?e:a*a<=o*o?t:n}function l(e,t,n,r,i,a,o,s,l){for(var u=Math.min(t,i),c=Math.min(n,a),d=0,f=0,p=0;p<c;p++)for(var h=0;h<u;h++)if(o>=0&&s>=0?(d=p*t+h<<2,f=(s+p)*i+o+h<<2):(d=(-s+p)*t-o+h<<2,f=p*i+h<<2),0==l)r[f]=e[d],r[f+1]=e[d+1],r[f+2]=e[d+2],r[f+3]=e[d+3];else if(1==l){var m=e[d+3]*(1/255),g=e[d]*m,v=e[d+1]*m,y=e[d+2]*m,b=r[f+3]*(1/255),_=r[f]*b,w=r[f+1]*b,x=r[f+2]*b,E=1-m,S=m+b*E,k=0==S?0:1/S;r[f+3]=255*S,r[f+0]=(g+_*E)*k,r[f+1]=(v+w*E)*k,r[f+2]=(y+x*E)*k}else if(2==l){var m=e[d+3],g=e[d],v=e[d+1],y=e[d+2],b=r[f+3],_=r[f],w=r[f+1],x=r[f+2];m==b&&g==_&&v==w&&y==x?(r[f]=0,r[f+1]=0,r[f+2]=0,r[f+3]=0):(r[f]=g,r[f+1]=v,r[f+2]=y,r[f+3]=m)}else if(3==l){var m=e[d+3],g=e[d],v=e[d+1],y=e[d+2],b=r[f+3],_=r[f],w=r[f+1],x=r[f+2];if(m==b&&g==_&&v==w&&y==x)continue;if(m<220&&b>20)return!1}return!0}return{decode:function(t){for(var a,o=new Uint8Array(t),s=8,l=e.readUshort,u=e.readUint,c={tabs:{},frames:[]},d=new Uint8Array(o.length),f=0,p=0,h=[137,80,78,71,13,10,26,10],m=0;m<8;m++)if(o[m]!=h[m])throw"The input is not a PNG file!";for(;s<o.length;){var g=e.readUint(o,s);s+=4;var v=e.readASCII(o,s,4);if(s+=4,"IHDR"==v){k=o,T=s,(C=c).width=e.readUint(k,T),T+=4,C.height=e.readUint(k,T),C.depth=k[T+=4],C.ctype=k[++T],C.compress=k[++T],C.filter=k[++T],C.interlace=k[++T],T++}else if("iCCP"==v){for(var y=s;0!=o[y];)y++;e.readASCII(o,s,y-s),o[y+1];var b=o.slice(y+2,s+g),_=null;try{_=r(b)}catch(e){_=i(b)}c.tabs[v]=_}else if("CgBI"==v)c.tabs[v]=o.slice(s,s+4);else if("IDAT"==v){for(var m=0;m<g;m++)d[f+m]=o[s+m];f+=g}else if("acTL"==v)c.tabs[v]={num_frames:u(o,s),num_plays:u(o,s+4)},a=new Uint8Array(o.length);else if("fcTL"==v){if(0!=p){var w=c.frames[c.frames.length-1];w.data=n(c,a.slice(0,p),w.rect.width,w.rect.height),p=0}var x={x:u(o,s+12),y:u(o,s+16),width:u(o,s+4),height:u(o,s+8)},E=l(o,s+22),S={rect:x,delay:1e3*(E=l(o,s+20)/(0==E?100:E)),dispose:o[s+24],blend:o[s+25]};c.frames.push(S)}else if("fdAT"==v){for(var m=0;m<g-4;m++)a[p+m]=o[s+m+4];p+=g-4}else if("pHYs"==v)c.tabs[v]=[e.readUint(o,s),e.readUint(o,s+4),o[s+8]];else if("cHRM"==v){c.tabs[v]=[];for(var m=0;m<8;m++)c.tabs[v].push(e.readUint(o,s+4*m))}else if("tEXt"==v||"zTXt"==v){null==c.tabs[v]&&(c.tabs[v]={});var k,T,C,P,A=e.nextZero(o,s),M=e.readASCII(o,s,A-s),R=s+g-A-1;if("tEXt"==v)P=e.readASCII(o,A+1,R);else{var I=r(o.slice(A+2,A+2+R));P=e.readUTF8(I,0,I.length)}c.tabs[v][M]=P}else if("iTXt"==v){null==c.tabs[v]&&(c.tabs[v]={});var A=0,y=s;A=e.nextZero(o,y);var M=e.readASCII(o,y,A-y),L=o[y=A+1];o[y+1],y+=2,A=e.nextZero(o,y),e.readASCII(o,y,A-y),y=A+1,A=e.nextZero(o,y),e.readUTF8(o,y,A-y);var P,R=g-((y=A+1)-s);if(0==L)P=e.readUTF8(o,y,R);else{var I=r(o.slice(y,y+R));P=e.readUTF8(I,0,I.length)}c.tabs[v][M]=P}else if("PLTE"==v)c.tabs[v]=e.readBytes(o,s,g);else if("hIST"==v){var O=c.tabs.PLTE.length/3;c.tabs[v]=[];for(var m=0;m<O;m++)c.tabs[v].push(l(o,s+2*m))}else if("tRNS"==v)3==c.ctype?c.tabs[v]=e.readBytes(o,s,g):0==c.ctype?c.tabs[v]=l(o,s):2==c.ctype&&(c.tabs[v]=[l(o,s),l(o,s+2),l(o,s+4)]);else if("gAMA"==v)c.tabs[v]=e.readUint(o,s)/1e5;else if("sRGB"==v)c.tabs[v]=o[s];else if("bKGD"==v)0==c.ctype||4==c.ctype?c.tabs[v]=[l(o,s)]:2==c.ctype||6==c.ctype?c.tabs[v]=[l(o,s),l(o,s+2),l(o,s+4)]:3==c.ctype&&(c.tabs[v]=o[s]);else if("IEND"==v)break;s+=g,e.readUint(o,s),s+=4}if(0!=p){var w=c.frames[c.frames.length-1];w.data=n(c,a.slice(0,p),w.rect.width,w.rect.height)}return c.data=n(c,d,c.width,c.height),delete c.compress,delete c.interlace,delete c.filter,c},toRGBA8:function(e){var n=e.width,r=e.height;if(null==e.tabs.acTL)return[t(e.data,n,r,e).buffer];var i=[];null==e.frames[0].data&&(e.frames[0].data=e.data);for(var a=n*r*4,o=new Uint8Array(a),s=new Uint8Array(a),u=new Uint8Array(a),c=0;c<e.frames.length;c++){var d=e.frames[c],f=d.rect.x,p=d.rect.y,h=d.rect.width,m=d.rect.height,g=t(d.data,h,m,e);if(0!=c)for(var v=0;v<a;v++)u[v]=o[v];if(0==d.blend?l(g,h,m,o,n,r,f,p,0):1==d.blend&&l(g,h,m,o,n,r,f,p,1),i.push(o.buffer.slice(0)),0==d.dispose);else if(1==d.dispose)l(s,h,m,o,n,r,f,p,0);else if(2==d.dispose)for(var v=0;v<a;v++)o[v]=u[v]}return i},_paeth:s,_copyTile:l,_bin:e}}();!function(){var e=t._copyTile,n=t._bin,r=t._paeth,i={table:function(){for(var e=new Uint32Array(256),t=0;t<256;t++){for(var n=t,r=0;r<8;r++)1&n?n=0xedb88320^n>>>1:n>>>=1;e[t]=n}return e}(),update:function(e,t,n,r){for(var a=0;a<r;a++)e=i.table[(e^t[n+a])&255]^e>>>8;return e},crc:function(e,t,n){return 0xffffffff^i.update(0xffffffff,e,t,n)}};function a(e,t,n,r){t[n]+=e[0]*r>>4,t[n+1]+=e[1]*r>>4,t[n+2]+=e[2]*r>>4,t[n+3]+=e[3]*r>>4}function o(e){return Math.max(0,Math.min(255,e))}function s(e,t){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return n*n+r*r+i*i+a*a}function l(e,t,n,r,i,l,u){null==u&&(u=1);for(var c=r.length,d=[],f=[],p=0;p<c;p++){var h=r[p];d.push([h>>>0&255,h>>>8&255,h>>>16&255,h>>>24&255])}for(var p=0;p<c;p++){for(var m=0xffffffff,g=0,v=0;v<c;v++){var y=s(d[p],d[v]);v!=p&&y<m&&(m=y,g=v)}var b=Math.sqrt(m)/2;f[p]=~~(b*b)}for(var _=new Uint32Array(i.buffer),w=new Int16Array(t*n*4),x=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5],p=0;p<x.length;p++)x[p]=255*(-.5+(x[p]+.5)/16);for(var E=0;E<n;E++)for(var S=0;S<t;S++){var k,p=(E*t+S)*4;if(2!=u)k=[o(e[p]+w[p]),o(e[p+1]+w[p+1]),o(e[p+2]+w[p+2]),o(e[p+3]+w[p+3])];else{var y=x[(3&E)*4+(3&S)];k=[o(e[p]+y),o(e[p+1]+y),o(e[p+2]+y),o(e[p+3]+y)]}for(var g=0,T=0xffffff,v=0;v<c;v++){var C=s(k,d[v]);C<T&&(T=C,g=v)}var P=d[g],A=[k[0]-P[0],k[1]-P[1],k[2]-P[2],k[3]-P[3]];1==u&&(S!=t-1&&a(A,w,p+4,7),E!=n-1&&(0!=S&&a(A,w,p+4*t-4,3),a(A,w,p+4*t,5),S!=t-1&&a(A,w,p+4*t+4,1))),l[p>>2]=g,_[p>>2]=r[g]}}function u(e,t,r,a,o){null==o&&(o={});var s,l=i.crc,u=n.writeUint,c=n.writeUshort,d=n.writeASCII,f=8,p=e.frames.length>1,h=!1,m=33+20*!!p;if(null!=o.sRGB&&(m+=13),null!=o.pHYs&&(m+=21),null!=o.iCCP&&(m+=21+(s=pako.deflate(o.iCCP)).length+4),3==e.ctype){for(var g=e.plte.length,v=0;v<g;v++)e.plte[v]>>>24!=255&&(h=!0);m+=8+3*g+4+(h?8+ +g+4:0)}for(var y=0;y<e.frames.length;y++){var b=e.frames[y];p&&(m+=38),m+=b.cimg.length+12,0!=y&&(m+=4)}for(var _=new Uint8Array(m+=12),w=[137,80,78,71,13,10,26,10],v=0;v<8;v++)_[v]=w[v];if(u(_,f,13),d(_,f+=4,"IHDR"),u(_,f+=4,t),u(_,f+=4,r),_[f+=4]=e.depth,_[++f]=e.ctype,_[++f]=0,_[++f]=0,_[++f]=0,u(_,++f,l(_,f-17,17)),f+=4,null!=o.sRGB&&(u(_,f,1),d(_,f+=4,"sRGB"),_[f+=4]=o.sRGB,u(_,++f,l(_,f-5,5)),f+=4),null!=o.iCCP){var x=13+s.length;u(_,f,x),d(_,f+=4,"iCCP"),d(_,f+=4,"ICC profile"),f+=11,f+=2,_.set(s,f),u(_,f+=s.length,l(_,f-(x+4),x+4)),f+=4}if(null!=o.pHYs&&(u(_,f,9),d(_,f+=4,"pHYs"),u(_,f+=4,o.pHYs[0]),u(_,f+=4,o.pHYs[1]),_[f+=4]=o.pHYs[2],u(_,++f,l(_,f-13,13)),f+=4),p&&(u(_,f,8),d(_,f+=4,"acTL"),u(_,f+=4,e.frames.length),u(_,f+=4,null!=o.loop?o.loop:0),u(_,f+=4,l(_,f-12,12)),f+=4),3==e.ctype){var g=e.plte.length;u(_,f,3*g),d(_,f+=4,"PLTE"),f+=4;for(var v=0;v<g;v++){var E=3*v,S=e.plte[v],k=255&S,T=S>>>8&255,C=S>>>16&255;_[f+E+0]=k,_[f+E+1]=T,_[f+E+2]=C}if(u(_,f+=3*g,l(_,f-3*g-4,3*g+4)),f+=4,h){u(_,f,g),d(_,f+=4,"tRNS"),f+=4;for(var v=0;v<g;v++)_[f+v]=e.plte[v]>>>24&255;u(_,f+=g,l(_,f-g-4,g+4)),f+=4}}for(var P=0,y=0;y<e.frames.length;y++){var b=e.frames[y];p&&(u(_,f,26),d(_,f+=4,"fcTL"),u(_,f+=4,P++),u(_,f+=4,b.rect.width),u(_,f+=4,b.rect.height),u(_,f+=4,b.rect.x),u(_,f+=4,b.rect.y),c(_,f+=4,a[y]),c(_,f+=2,1e3),_[f+=2]=b.dispose,_[++f]=b.blend,u(_,++f,l(_,f-30,30)),f+=4);var A=b.cimg,g=A.length;u(_,f,g+4*(0!=y));var M=f+=4;d(_,f,0==y?"IDAT":"fdAT"),f+=4,0!=y&&(u(_,f,P++),f+=4),_.set(A,f),u(_,f+=g,l(_,M,f-M)),f+=4}return u(_,f,0),d(_,f+=4,"IEND"),u(_,f+=4,l(_,f-4,4)),f+=4,_.buffer}function c(e,t,n){for(var i=0;i<e.frames.length;i++){var a=e.frames[i],o=(a.rect.width,a.rect.height),s=new Uint8Array(o*a.bpl+o);a.cimg=function(e,t,n,i,a,o,s){var l=[],u=[0,1,2,3,4];-1!=o?u=[o]:(t*i>5e5||1==n)&&(u=[0]),s&&(p={level:0});var c=a.length>1e7&&null!=window.UZIP?window.UZIP:pako;Date.now();for(var d=0;d<u.length;d++){for(var f=0;f<t;f++)!function(e,t,n,i,a,o){var s=n*i,l=s+n;if(e[l]=o,l++,0==o)if(i<500)for(var u=0;u<i;u++)e[l+u]=t[s+u];else e.set(new Uint8Array(t.buffer,s,i),l);else if(1==o){for(var u=0;u<a;u++)e[l+u]=t[s+u];for(var u=a;u<i;u++)e[l+u]=t[s+u]-t[s+u-a]+256&255}else if(0==n){for(var u=0;u<a;u++)e[l+u]=t[s+u];if(2==o)for(var u=a;u<i;u++)e[l+u]=t[s+u];if(3==o)for(var u=a;u<i;u++)e[l+u]=t[s+u]-(t[s+u-a]>>1)+256&255;if(4==o)for(var u=a;u<i;u++)e[l+u]=t[s+u]-r(t[s+u-a],0,0)+256&255}else{if(2==o)for(var u=0;u<i;u++)e[l+u]=t[s+u]+256-t[s+u-i]&255;if(3==o){for(var u=0;u<a;u++)e[l+u]=t[s+u]+256-(t[s+u-i]>>1)&255;for(var u=a;u<i;u++)e[l+u]=t[s+u]+256-(t[s+u-i]+t[s+u-a]>>1)&255}if(4==o){for(var u=0;u<a;u++)e[l+u]=t[s+u]+256-r(0,t[s+u-i],0)&255;for(var u=a;u<i;u++)e[l+u]=t[s+u]+256-r(t[s+u-a],t[s+u-i],t[s+u-a-i])&255}}}(a,e,f,i,n,u[d]);l.push(c.deflate(a,p))}for(var p,h,m=1e9,d=0;d<l.length;d++)l[d].length<m&&(h=d,m=l[d].length);return l[h]}(a.img,o,a.bpp,a.bpl,s,t,n)}}function d(t,n,r,i,a){for(var o=a[0],s=a[1],u=a[2],c=a[3],d=a[4],m=a[5],g=6,v=8,y=255,b=0;b<t.length;b++)for(var _=new Uint8Array(t[b]),w=_.length,x=0;x<w;x+=4)y&=_[x+3];var E=255!=y,S=function(t,n,r,i,a,o){for(var s=[],l=0;l<t.length;l++){var u,c=new Uint8Array(t[l]),d=new Uint32Array(c.buffer),h=0,m=0,g=n,v=r,y=+!!i;if(0!=l){for(var b=o||i||1==l||0!=s[l-2].dispose?1:2,_=0,w=1e9,x=0;x<b;x++){for(var E=new Uint8Array(t[l-1-x]),S=new Uint32Array(t[l-1-x]),k=n,T=r,C=-1,P=-1,A=0;A<r;A++)for(var M=0;M<n;M++){var R=A*n+M;d[R]!=S[R]&&(M<k&&(k=M),M>C&&(C=M),A<T&&(T=A),A>P&&(P=A))}-1==C&&(k=T=C=P=0),a&&((1&k)==1&&k--,(1&T)==1&&T--);var I=(C-k+1)*(P-T+1);I<w&&(w=I,_=x,h=k,m=T,g=C-k+1,v=P-T+1)}var E=new Uint8Array(t[l-1-_]);1==_&&(s[l-1].dispose=2),e(E,n,r,u=new Uint8Array(g*v*4),g,v,-h,-m,0),1==(y=+!!e(c,n,r,u,g,v,-h,-m,3))?p(c,n,r,u,{x:h,y:m,width:g,height:v}):e(c,n,r,u,g,v,-h,-m,0)}else u=c.slice(0);s.push({rect:{x:h,y:m,width:g,height:v},img:u,blend:y,dispose:0})}if(i)for(var l=0;l<s.length;l++){var L=s[l];if(1!=L.blend){var O=L.rect,D=s[l-1].rect,F=Math.min(O.x,D.x),N=Math.min(O.y,D.y),V={x:F,y:N,width:Math.max(O.x+O.width,D.x+D.width)-F,height:Math.max(O.y+O.height,D.y+D.height)-N};s[l-1].dispose=1,l-1!=0&&f(t,n,r,s,l-1,V,a),f(t,n,r,s,l,V,a)}}if(1!=t.length)for(var R=0;R<s.length;R++){var L=s[R];L.rect.width,L.rect.height}return s}(t,n,r,o,s,u),k={},T=[],C=[];if(0!=i){for(var P=[],x=0;x<S.length;x++)P.push(S[x].img.buffer);for(var A=h(function(e){for(var t=0,n=0;n<e.length;n++)t+=e[n].byteLength;for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){for(var a=new Uint8Array(e[n]),o=a.length,s=0;s<o;s+=4){var l=a[s],u=a[s+1],c=a[s+2],d=a[s+3];0==d&&(l=u=c=0),r[i+s]=l,r[i+s+1]=u,r[i+s+2]=c,r[i+s+3]=d}i+=o}return r.buffer}(P),i),x=0;x<A.plte.length;x++)T.push(A.plte[x].est.rgba);for(var M=0,x=0;x<S.length;x++){var R=S[x],I=R.img.length,L=new Uint8Array(A.inds.buffer,M>>2,I>>2);C.push(L);var O=new Uint8Array(A.abuf,M,I);m&&l(R.img,R.rect.width,R.rect.height,T,O,L),R.img.set(O),M+=I}}else for(var b=0;b<S.length;b++){var R=S[b],D=new Uint32Array(R.img.buffer),F=R.rect.width,w=D.length,L=new Uint8Array(w);C.push(L);for(var x=0;x<w;x++){var N=D[x];if(0!=x&&N==D[x-1])L[x]=L[x-1];else if(x>F&&N==D[x-F])L[x]=L[x-F];else{var V=k[N];if(null==V&&(k[N]=V=T.length,T.push(N),T.length>=300))break;L[x]=V}}}var j=T.length;j<=256&&!1==d&&(v=Math.max(v=j<=2?1:j<=4?2:j<=16?4:8,c));for(var b=0;b<S.length;b++){var R=S[b],F=(R.rect.x,R.rect.y,R.rect.width),B=R.rect.height,U=R.img;new Uint32Array(U.buffer);var K=4*F,$=4;if(j<=256&&!1==d){for(var z=new Uint8Array((K=Math.ceil(v*F/8))*B),W=C[b],G=0;G<B;G++){var x=G*K,H=G*F;if(8==v)for(var q=0;q<F;q++)z[x+q]=W[H+q];else if(4==v)for(var q=0;q<F;q++)z[x+(q>>1)]|=W[H+q]<<4-(1&q)*4;else if(2==v)for(var q=0;q<F;q++)z[x+(q>>2)]|=W[H+q]<<6-(3&q)*2;else if(1==v)for(var q=0;q<F;q++)z[x+(q>>3)]|=W[H+q]<<7-(7&q)*1}U=z,g=3,$=1}else if(!1==E&&1==S.length){for(var z=new Uint8Array(F*B*3),Y=F*B,x=0;x<Y;x++){var X=3*x,J=4*x;z[X]=U[J],z[X+1]=U[J+1],z[X+2]=U[J+2]}U=z,g=2,$=3,K=3*F}R.img=U,R.bpl=K,R.bpp=$}return{ctype:g,depth:v,plte:T,frames:S}}function f(t,n,r,i,a,o,s){for(var l=Uint8Array,u=Uint32Array,c=new l(t[a-1]),d=new u(t[a-1]),f=a+1<t.length?new l(t[a+1]):null,h=new l(t[a]),m=new u(h.buffer),g=n,v=r,y=-1,b=-1,_=0;_<o.height;_++)for(var w=0;w<o.width;w++){var x=o.x+w,E=o.y+_,S=E*n+x,k=m[S];0==k||0==i[a-1].dispose&&d[S]==k&&(null==f||0!=f[4*S+3])||(x<g&&(g=x),x>y&&(y=x),E<v&&(v=E),E>b&&(b=E))}-1==y&&(g=v=y=b=0),s&&((1&g)==1&&g--,(1&v)==1&&v--),o={x:g,y:v,width:y-g+1,height:b-v+1};var T=i[a];T.rect=o,T.blend=1,T.img=new Uint8Array(o.width*o.height*4),0==i[a-1].dispose?(e(c,n,r,T.img,o.width,o.height,-o.x,-o.y,0),p(h,n,r,T.img,o)):e(h,n,r,T.img,o.width,o.height,-o.x,-o.y,0)}function p(t,n,r,i,a){e(t,n,r,i,a.width,a.height,-a.x,-a.y,2)}function h(e,t,n){Date.now();for(var r=new Uint8Array(e),i=r.slice(0),a=new Uint32Array(i.buffer),o=v(i,t),s=o[0],l=o[1],u=l.length,c=new Uint32Array(u),d=new Uint8Array(c.buffer),f=0;f<u;f++)c[f]=l[f].est.rgba;var p,h=r.length,_=new Uint8Array(h>>2);if(u<=60)g(r,_,d),m(_,a,c);else if(r.length<32e6)for(var f=0;f<h;f+=4){var w=r[f]*(1/255),x=r[f+1]*(1/255),E=r[f+2]*(1/255),S=r[f+3]*(1/255);p=y(s,w,x,E,S),_[f>>2]=p.ind,a[f>>2]=p.est.rgba}else for(var f=0;f<h;f+=4){var w=r[f]*(1/255),x=r[f+1]*(1/255),E=r[f+2]*(1/255),S=r[f+3]*(1/255);for(p=s;p.left;)p=0>=b(p.est,w,x,E,S)?p.left:p.right;_[f>>2]=p.ind,a[f>>2]=p.est.rgba}if(n||r.length*u<10*4e6){for(var k=1e9,f=0;f<10;f++){var T,C,P,A=(function(e,t,n){for(var r=n.length>>>2,i=new Uint32Array(4*r),a=new Uint32Array(r),o=0;o<e.length;o+=4){var s=t[o>>>2],l=4*s;a[s]++,i[l]+=e[o],i[l+1]+=e[o+1],i[l+2]+=e[o+2],i[l+3]+=e[o+3]}for(var o=0;o<n.length;o++)n[o]=Math.round(i[o]/a[o>>>2])}(T=r,C=_,P=d),g(T,C,P));if(A/k>.997)break;k=A}for(var f=0;f<u;f++)l[f].est.rgba=c[f];m(_,a,c)}return{abuf:i.buffer,inds:_,plte:l}}function m(e,t,n){for(var r=0;r<e.length;r++)t[r]=n[e[r]]}function g(e,t,n){for(var r=0,i=n.length>>>2,a=[],o=0;o<i;o++){for(var s=4*o,l=n[s],u=n[s+1],c=n[s+2],d=n[s+3],f=0,p=1e9,h=0;h<i;h++)if(o!=h){var m=4*h,g=l-n[m],v=u-n[m+1],y=c-n[m+2],b=d-n[m+3],_=g*g+v*v+y*y+b*b;_<p&&(p=_,f=h)}a[o]=.5*Math.sqrt(p),a[o]=a[o]*a[o]}for(var o=0;o<e.length;o+=4){var l=e[o],u=e[o+1],c=e[o+2],d=e[o+3],f=t[o>>>2],s=4*f,g=l-n[s],v=u-n[s+1],y=c-n[s+2],b=d-n[s+3],p=g*g+v*v+y*y+b*b;if(p>a[f])for(var h=0;h<i;h++){g=l-n[s=4*h],v=u-n[s+1];var _=g*g+v*v+(y=c-n[s+2])*y+(b=d-n[s+3])*b;if(_<p&&(p=_,f=h,p<a[h]))break}t[o>>>2]=f,r+=p}return r/(e.length>>>2)}function v(e,t,n){null==n&&(n=1e-4);var r=new Uint32Array(e.buffer),i={i0:0,i1:e.length,bst:null,est:null,tdst:0,left:null,right:null};i.bst=w(e,i.i0,i.i1),i.est=x(i.bst);for(var a=[i];a.length<t;){for(var o=0,s=0,l=0;l<a.length;l++)a[l].est.L>o&&(o=a[l].est.L,s=l);if(o<n)break;var u=a[s],c=function(e,t,n,r,i,a){for(r-=4;n<r;){for(;_(e,n,i)<=a;)n+=4;for(;_(e,r,i)>a;)r-=4;if(n>=r)break;var o=t[n>>2];t[n>>2]=t[r>>2],t[r>>2]=o,n+=4,r-=4}for(;_(e,n,i)>a;)n-=4;return n+4}(e,r,u.i0,u.i1,u.est.e,u.est.eMq255);if(u.i0>=c||u.i1<=c){u.est.L=0;continue}var d={i0:u.i0,i1:c,bst:null,est:null,tdst:0,left:null,right:null};d.bst=w(e,d.i0,d.i1),d.est=x(d.bst);var f={i0:c,i1:u.i1,bst:null,est:null,tdst:0,left:null,right:null};f.bst={R:[],m:[],N:u.bst.N-d.bst.N};for(var l=0;l<16;l++)f.bst.R[l]=u.bst.R[l]-d.bst.R[l];for(var l=0;l<4;l++)f.bst.m[l]=u.bst.m[l]-d.bst.m[l];f.est=x(f.bst),u.left=d,u.right=f,a[s]=d,a.push(f)}a.sort(function(e,t){return t.bst.N-e.bst.N});for(var l=0;l<a.length;l++)a[l].ind=l;return[i,a]}function y(e,t,n,r,i){if(null==e.left){var a,o,s,l,u,c,d,f,p;return a=e.est.q,o=t,s=n,l=r,u=i,c=o-a[0],d=s-a[1],e.tdst=c*c+d*d+(f=l-a[2])*f+(p=u-a[3])*p,e}var h=b(e.est,t,n,r,i),m=e.left,g=e.right;h>0&&(m=e.right,g=e.left);var v=y(m,t,n,r,i);if(v.tdst<=h*h)return v;var _=y(g,t,n,r,i);return _.tdst<v.tdst?_:v}function b(e,t,n,r,i){var a=e.e;return a[0]*t+a[1]*n+a[2]*r+a[3]*i-e.eMq}function _(e,t,n){return e[t]*n[0]+e[t+1]*n[1]+e[t+2]*n[2]+e[t+3]*n[3]}function w(e,t,n){for(var r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],a=t;a<n;a+=4){var o=e[a]*(1/255),s=e[a+1]*(1/255),l=e[a+2]*(1/255),u=e[a+3]*(1/255);i[0]+=o,i[1]+=s,i[2]+=l,i[3]+=u,r[0]+=o*o,r[1]+=o*s,r[2]+=o*l,r[3]+=o*u,r[5]+=s*s,r[6]+=s*l,r[7]+=s*u,r[10]+=l*l,r[11]+=l*u,r[15]+=u*u}return r[4]=r[1],r[8]=r[2],r[9]=r[6],r[12]=r[3],r[13]=r[7],r[14]=r[11],{R:r,m:i,N:n-t>>2}}function x(e){var t=e.R,n=e.m,r=e.N,i=n[0],a=n[1],o=n[2],s=n[3],l=0==r?0:1/r,u=[t[0]-i*i*l,t[1]-i*a*l,t[2]-i*o*l,t[3]-i*s*l,t[4]-a*i*l,t[5]-a*a*l,t[6]-a*o*l,t[7]-a*s*l,t[8]-o*i*l,t[9]-o*a*l,t[10]-o*o*l,t[11]-o*s*l,t[12]-s*i*l,t[13]-s*a*l,t[14]-s*o*l,t[15]-s*s*l],c=[Math.random(),Math.random(),Math.random(),Math.random()],d=0,f=0;if(0!=r)for(var p=0;p<16&&(c=E.multVec(u,c),f=Math.sqrt(E.dot(c,c)),c=E.sml(1/f,c),!(0!=p&&1e-9>Math.abs(f-d)));p++)d=f;var h=[i*l,a*l,o*l,s*l],m=E.dot(E.sml(255,h),c);return{Cov:u,q:h,e:c,L:d,eMq255:m,eMq:E.dot(c,h),rgba:(Math.round(255*h[3])<<24|Math.round(255*h[2])<<16|Math.round(255*h[1])<<8|(0|Math.round(255*h[0])))>>>0}}var E={multVec:function(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7]*t[3],e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11]*t[3],e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]*t[3]]},dot:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},sml:function(e,t){return[e*t[0],e*t[1],e*t[2],e*t[3]]}};t.encode=function(e,t,n,r,i,a,o){null==r&&(r=0),null==o&&(o=!1);var s=d(e,t,n,r,[!1,!1,!1,0,o,!1]);return c(s,-1),u(s,t,n,i,a)},t.encodeLL=function(e,t,n,r,i,a,o,s){var l={ctype:0+2*(1!=r)+4*(0!=i),depth:a,frames:[]};Date.now();for(var d=(r+i)*a,f=d*t,p=0;p<e.length;p++)l.frames.push({rect:{x:0,y:0,width:t,height:n},img:new Uint8Array(e[p]),blend:0,dispose:1,bpp:Math.ceil(d/8),bpl:Math.ceil(f/8)});return c(l,0,!0),u(l,t,n,o,s)},t.encode.compress=d,t.encode.dither=l,t.quantize=h,t.quantize.findNearest=g,t.quantize.getKDtree=v,t.quantize.getNearest=y}(),e.exports=t}