UNPKG

imgtotiny

Version:

一个通用前端图片压缩插件,并可对 PNG 图片进行有损压缩

2 lines (1 loc) 29.4 kB
import e from"uzip";import r from"pako";function t(e,r,t,n){return new(t||(t=Promise))((function(i,a){function f(e){try{l(n.next(e))}catch(e){a(e)}}function o(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(f,o)}l((n=n.apply(e,r||[])).next())}))}function n(e,r){var t,n,i,a,f={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(l){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(f=0)),f;)try{if(t=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return f.label++,{value:o[1],done:!1};case 5:f.label++,n=o[1],o=[0];continue;case 7:o=f.ops.pop(),f.trys.pop();continue;default:if(!(i=f.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){f=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){f.label=o[1];break}if(6===o[0]&&f.label<i[1]){f.label=i[1],i=o;break}if(i&&f.label<i[2]){f.label=i[2],f.ops.push(o);break}i[2]&&f.ops.pop(),f.trys.pop();continue}o=r.call(e,f)}catch(e){o=[6,e],n=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}var i,a,f,o={};function l(e){return new Promise((function(r){var t=new FileReader;t.readAsDataURL(e),t.onload=function(){t.result&&"string"==typeof t.result?r(t.result):r(null)},t.onerror=function(){r(null)}}))}function s(e){return new Promise((function(r){var t=new Image;t.onload=function(){return r(t)},t.onerror=function(){return r(null)},t.src=e}))}function u(e,r,t){return new Promise((function(n){return e.toBlob((function(e){return n(e)}),r,t)}))}function c(e,r){return t(this,void 0,void 0,(function(){var t,i,a,f,o,c,h;return n(this,(function(n){switch(n.label){case 0:return t="jpg"===r?"jpeg":r,e.type==="image/".concat(t)?[2,e]:[4,l(e)];case 1:if(null===(i=n.sent()))throw new Error("文件转base64失败,请重试");return[4,s(i)];case 2:if(null===(a=n.sent()))throw new Error("base64转Image失败,请重试");return f=document.createElement("canvas"),o=f.getContext("2d"),f.width=a.width,f.height=a.height,o.drawImage(a,0,0,a.width,a.height),[4,u(f,"image/".concat(t),1)];case 3:return(c=n.sent())?(h=e.name.split(".")[0]+"."+r,[2,new File([c],h,{type:"image/".concat(t)})]):[2,null]}}))}))}function h(e,r,i,a){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,u(e,r,i)];case 1:return(t=n.sent())?[2,new File([t],a,{type:r})]:[2,null]}}))}))}function d(e,r){return t(this,void 0,void 0,(function(){var t,i,a,f,u,d,v,g,p,w,b;return n(this,(function(n){switch(n.label){case 0:return function(e){if(e){if(e.type.includes("image/"))return!0;throw new Error("文件需要是图片类型")}throw new Error("文件不能为空")}(e)?(t=e,(i=r&&(null!==(y=r)&&"object"==typeof y)?r:{}).minSize&&i.minSize>0&&t.size<i.minSize&&!i.width&&!i.height?[2,t]:["image/jpeg","image/png","image/webp","image/svg+xml"].includes(t.type)||i.allKeepType?[3,2]:[4,c(t,"jpg")]):[2,e];case 1:null!==(a=n.sent())&&(t=a),n.label=2;case 2:return"image/svg+xml"!==t.type||i.allKeepType?[3,4]:[4,c(t,"png")];case 3:null!==(a=n.sent())&&(t=a),n.label=4;case 4:return[4,l(t)];case 5:if(null===(f=n.sent()))throw new Error("文件转base64失败,请重试");return[4,s(f)];case 6:if(null===(u=n.sent()))throw new Error("base64转Image失败,请重试");return d=document.createElement("canvas"),v=d.getContext("2d"),i.width&&i.height?(d.width=i.width,d.height=i.height):i.width&&!i.height?(d.width=i.width,g=u.width/u.height,d.height=Math.floor(i.width/g)):!i.width&&i.height?(d.height=i.height,g=u.width/u.height,d.width=Math.floor(i.height*g)):(d.width=u.width,d.height=u.height),v.drawImage(u,0,0,d.width,d.height),m=i.quality,w=0===m||1===m||m&&"number"==typeof m&&m>0&&m<1?i.quality:.6,"image/png"!==t.type?[3,7]:(p=function(e,r,t,n){var i=e.getImageData(0,0,r.width,r.height).data,a=0;t>0&&t<1&&(a=256*t);var f=o.encode([i.buffer],r.width,r.height,a);return f?new File([f],n,{type:"image/png"}):null}(v,u,w,t.name),[3,9]);case 7:return[4,h(d,t.type,w,t.name)];case 8:p=n.sent(),n.label=9;case 9:if(null===p)throw new Error("压缩图片失败");return i.returnBase64?[4,l(p)]:[3,11];case 10:if(null===(b=n.sent()))throw new Error("结果转base64失败,请重试");return[2,b];case 11:return[2,p]}var m,y}))}))}o.toRGBA8=function(e){var r=e.width,t=e.height;if(null==e.tabs.acTL)return[o.toRGBA8.decodeImage(e.data,r,t,e).buffer];var n=[];null==e.frames[0].data&&(e.frames[0].data=e.data);for(var i=r*t*4,a=new Uint8Array(i),f=new Uint8Array(i),l=new Uint8Array(i),s=0;s<e.frames.length;s++){var u=e.frames[s],c=u.rect.x,h=u.rect.y,d=u.rect.width,v=u.rect.height,g=o.toRGBA8.decodeImage(u.data,d,v,e);if(0!=s)for(var p=0;p<i;p++)l[p]=a[p];if(0==u.blend?o._copyTile(g,d,v,a,r,t,c,h,0):1==u.blend&&o._copyTile(g,d,v,a,r,t,c,h,1),n.push(a.buffer.slice(0)),0==u.dispose);else if(1==u.dispose)o._copyTile(f,d,v,a,r,t,c,h,0);else if(2==u.dispose)for(p=0;p<i;p++)a[p]=l[p]}return n},o.toRGBA8.decodeImage=function(e,r,t,n){var i=r*t,a=o.decode._getBPP(n),f=Math.ceil(r*a/8),l=new Uint8Array(4*i),s=new Uint32Array(l.buffer),u=n.ctype,c=n.depth,h=o._bin.readUshort;if(6==u){var d=i<<2;if(8==c)for(var v=0;v<d;v+=4)l[v]=e[v],l[v+1]=e[v+1],l[v+2]=e[v+2],l[v+3]=e[v+3];if(16==c)for(v=0;v<d;v++)l[v]=e[v<<1]}else if(2==u){var g=n.tabs.tRNS;if(null==g){if(8==c)for(v=0;v<i;v++){var p=3*v;s[v]=255<<24|e[p+2]<<16|e[p+1]<<8|e[p]}if(16==c)for(v=0;v<i;v++){p=6*v;s[v]=255<<24|e[p+4]<<16|e[p+2]<<8|e[p]}}else{var w=g[0],b=g[1],m=g[2];if(8==c)for(v=0;v<i;v++){var y=v<<2;p=3*v;s[v]=255<<24|e[p+2]<<16|e[p+1]<<8|e[p],e[p]==w&&e[p+1]==b&&e[p+2]==m&&(l[y+3]=0)}if(16==c)for(v=0;v<i;v++){y=v<<2,p=6*v;s[v]=255<<24|e[p+4]<<16|e[p+2]<<8|e[p],h(e,p)==w&&h(e,p+2)==b&&h(e,p+4)==m&&(l[y+3]=0)}}}else if(3==u){var A=n.tabs.PLTE,U=n.tabs.tRNS,_=U?U.length:0;if(1==c)for(var H=0;H<t;H++){var I=H*f,M=H*r;for(v=0;v<r;v++){y=M+v<<2;var x=3*(T=e[I+(v>>3)]>>7-((7&v)<<0)&1);l[y]=A[x],l[y+1]=A[x+1],l[y+2]=A[x+2],l[y+3]=T<_?U[T]:255}}if(2==c)for(H=0;H<t;H++)for(I=H*f,M=H*r,v=0;v<r;v++){y=M+v<<2,x=3*(T=e[I+(v>>2)]>>6-((3&v)<<1)&3);l[y]=A[x],l[y+1]=A[x+1],l[y+2]=A[x+2],l[y+3]=T<_?U[T]:255}if(4==c)for(H=0;H<t;H++)for(I=H*f,M=H*r,v=0;v<r;v++){y=M+v<<2,x=3*(T=e[I+(v>>1)]>>4-((1&v)<<2)&15);l[y]=A[x],l[y+1]=A[x+1],l[y+2]=A[x+2],l[y+3]=T<_?U[T]:255}if(8==c)for(v=0;v<i;v++){var T;y=v<<2,x=3*(T=e[v]);l[y]=A[x],l[y+1]=A[x+1],l[y+2]=A[x+2],l[y+3]=T<_?U[T]:255}}else if(4==u){if(8==c)for(v=0;v<i;v++){y=v<<2;var q=e[R=v<<1];l[y]=q,l[y+1]=q,l[y+2]=q,l[y+3]=e[R+1]}if(16==c)for(v=0;v<i;v++){var R;y=v<<2,q=e[R=v<<2];l[y]=q,l[y+1]=q,l[y+2]=q,l[y+3]=e[R+2]}}else if(0==u)for(w=n.tabs.tRNS?n.tabs.tRNS:-1,H=0;H<t;H++){var z=H*f,D=H*r;if(1==c)for(var N=0;N<r;N++){var S=(q=255*(e[z+(N>>>3)]>>>7-(7&N)&1))==255*w?0:255;s[D+N]=S<<24|q<<16|q<<8|q}else if(2==c)for(N=0;N<r;N++){S=(q=85*(e[z+(N>>>2)]>>>6-((3&N)<<1)&3))==85*w?0:255;s[D+N]=S<<24|q<<16|q<<8|q}else if(4==c)for(N=0;N<r;N++){S=(q=17*(e[z+(N>>>1)]>>>4-((1&N)<<2)&15))==17*w?0:255;s[D+N]=S<<24|q<<16|q<<8|q}else if(8==c)for(N=0;N<r;N++){S=(q=e[z+N])==w?0:255;s[D+N]=S<<24|q<<16|q<<8|q}else if(16==c)for(N=0;N<r;N++){q=e[z+(N<<1)],S=h(e,z+(N<<v))==w?0:255;s[D+N]=S<<24|q<<16|q<<8|q}}return l},o.decode=function(e){for(var r,t=new Uint8Array(e),n=8,i=o._bin,a=i.readUshort,f=i.readUint,l={tabs:{},frames:[]},s=new Uint8Array(t.length),u=0,c=0,h=[137,80,78,71,13,10,26,10],d=0;d<8;d++)if(t[d]!=h[d])throw"The input is not a PNG file!";for(;n<t.length;){var v=i.readUint(t,n);n+=4;var g=i.readASCII(t,n,4);if(n+=4,"IHDR"==g)o.decode._IHDR(t,n,l);else if("CgBI"==g)l.tabs[g]=t.slice(n,n+4);else if("IDAT"==g){for(d=0;d<v;d++)s[u+d]=t[n+d];u+=v}else if("acTL"==g)l.tabs[g]={num_frames:f(t,n),num_plays:f(t,n+4)},r=new Uint8Array(t.length);else if("fcTL"==g){var p;if(0!=c)(p=l.frames[l.frames.length-1]).data=o.decode._decompress(l,r.slice(0,c),p.rect.width,p.rect.height),c=0;var w={x:f(t,n+12),y:f(t,n+16),width:f(t,n+4),height:f(t,n+8)},b=a(t,n+22);b=a(t,n+20)/(0==b?100:b);var m={rect:w,delay:Math.round(1e3*b),dispose:t[n+24],blend:t[n+25]};l.frames.push(m)}else if("fdAT"==g){for(d=0;d<v-4;d++)r[c+d]=t[n+d+4];c+=v-4}else if("pHYs"==g)l.tabs[g]=[i.readUint(t,n),i.readUint(t,n+4),t[n+8]];else if("cHRM"==g){l.tabs[g]=[];for(d=0;d<8;d++)l.tabs[g].push(i.readUint(t,n+4*d))}else if("tEXt"==g||"zTXt"==g){null==l.tabs[g]&&(l.tabs[g]={});var y=i.nextZero(t,n),A=i.readASCII(t,n,y-n),U=n+v-y-1;if("tEXt"==g)M=i.readASCII(t,y+1,U);else{var _=o.decode._inflate(t.slice(y+2,y+2+U));M=i.readUTF8(_,0,_.length)}l.tabs[g][A]=M}else if("iTXt"==g){null==l.tabs[g]&&(l.tabs[g]={});y=0;var H=n;y=i.nextZero(t,H);A=i.readASCII(t,H,y-H);var I=t[H=y+1];t[H+1],H+=2,y=i.nextZero(t,H),i.readASCII(t,H,y-H),H=y+1,y=i.nextZero(t,H),i.readUTF8(t,H,y-H);var M;U=v-((H=y+1)-n);if(0==I)M=i.readUTF8(t,H,U);else{_=o.decode._inflate(t.slice(H,H+U));M=i.readUTF8(_,0,_.length)}l.tabs[g][A]=M}else if("PLTE"==g)l.tabs[g]=i.readBytes(t,n,v);else if("hIST"==g){var x=l.tabs.PLTE.length/3;l.tabs[g]=[];for(d=0;d<x;d++)l.tabs[g].push(a(t,n+2*d))}else if("tRNS"==g)3==l.ctype?l.tabs[g]=i.readBytes(t,n,v):0==l.ctype?l.tabs[g]=a(t,n):2==l.ctype&&(l.tabs[g]=[a(t,n),a(t,n+2),a(t,n+4)]);else if("gAMA"==g)l.tabs[g]=i.readUint(t,n)/1e5;else if("sRGB"==g)l.tabs[g]=t[n];else if("bKGD"==g)0==l.ctype||4==l.ctype?l.tabs[g]=[a(t,n)]:2==l.ctype||6==l.ctype?l.tabs[g]=[a(t,n),a(t,n+2),a(t,n+4)]:3==l.ctype&&(l.tabs[g]=t[n]);else if("IEND"==g)break;n+=v,i.readUint(t,n),n+=4}0!=c&&((p=l.frames[l.frames.length-1]).data=o.decode._decompress(l,r.slice(0,c),p.rect.width,p.rect.height),c=0);return l.data=o.decode._decompress(l,s,l.width,l.height),delete l.compress,delete l.interlace,delete l.filter,l},o.decode._decompress=function(e,r,t,n){var i=o.decode._getBPP(e),a=Math.ceil(t*i/8),f=new Uint8Array((a+1+e.interlace)*n);return r=e.tabs.CgBI?o.inflateRaw(r,f):o.decode._inflate(r,f),0==e.interlace?r=o.decode._filterZero(r,e,0,t,n):1==e.interlace&&(r=o.decode._readInterlace(r,e)),r},o.decode._inflate=function(e,r){return o.inflateRaw(new Uint8Array(e.buffer,2,e.length-6),r)},o.inflateRaw=((f={}).H={},f.H.N=function(e,r){var t,n,i=Uint8Array,a=0,o=0,l=0,s=0,u=0,c=0,h=0,d=0,v=0;if(3==e[0]&&0==e[1])return r||new i(0);var g=f.H,p=g.b,w=g.e,b=g.R,m=g.n,y=g.A,A=g.Z,U=g.m,_=null==r;for(_&&(r=new i(e.length>>>2<<3));0==a;)if(a=p(e,v,1),o=p(e,v+1,2),v+=3,0!=o){if(_&&(r=f.H.W(r,d+(1<<17))),1==o&&(t=U.J,n=U.h,c=511,h=31),2==o){l=w(e,v,5)+257,s=w(e,v+5,5)+1,u=w(e,v+10,4)+4,v+=14;for(var H=1,I=0;I<38;I+=2)U.Q[I]=0,U.Q[I+1]=0;for(I=0;I<u;I++){var M=w(e,v+3*I,3);U.Q[1+(U.X[I]<<1)]=M,M>H&&(H=M)}v+=3*u,m(U.Q,H),y(U.Q,H,U.u),t=U.w,n=U.d,v=b(U.u,(1<<H)-1,l+s,e,v,U.v);var x=g.V(U.v,0,l,U.C);c=(1<<x)-1;var T=g.V(U.v,l,s,U.D);h=(1<<T)-1,m(U.C,x),y(U.C,x,t),m(U.D,T),y(U.D,T,n)}for(;;){var q=t[A(e,v)&c];v+=15&q;var R=q>>>4;if(R>>>8==0)r[d++]=R;else{if(256==R)break;var z=d+R-254;if(R>264){var D=U.q[R-257];z=d+(D>>>3)+w(e,v,7&D),v+=7&D}var N=n[A(e,v)&h];v+=15&N;var S=N>>>4,P=U.c[S],B=(P>>>4)+p(e,v,15&P);for(v+=15&P;d<z;)r[d]=r[d++-B],r[d]=r[d++-B],r[d]=r[d++-B],r[d]=r[d++-B];d=z}}}else{0!=(7&v)&&(v+=8-(7&v));var C=4+(v>>>3),E=e[C-4]|e[C-3]<<8;_&&(r=f.H.W(r,d+E)),r.set(new i(e.buffer,e.byteOffset+C,E),d),v=C+E<<3,d+=E}return r.length==d?r:r.slice(0,d)},f.H.W=function(e,r){var t=e.length;if(r<=t)return e;var n=new Uint8Array(t<<1);return n.set(e,0),n},f.H.R=function(e,r,t,n,i,a){for(var o=f.H.e,l=f.H.Z,s=0;s<t;){var u=e[l(n,i)&r];i+=15&u;var c=u>>>4;if(c<=15)a[s]=c,s++;else{var h=0,d=0;16==c?(d=3+o(n,i,2),i+=2,h=a[s-1]):17==c?(d=3+o(n,i,3),i+=3):18==c&&(d=11+o(n,i,7),i+=7);for(var v=s+d;s<v;)a[s]=h,s++}}return i},f.H.V=function(e,r,t,n){for(var i=0,a=0,f=n.length>>>1;a<t;){var o=e[a+r];n[a<<1]=0,n[1+(a<<1)]=o,o>i&&(i=o),a++}for(;a<f;)n[a<<1]=0,n[1+(a<<1)]=0,a++;return i},f.H.n=function(e,r){for(var t,n,i,a,o=f.H.m,l=e.length,s=o.j,u=0;u<=r;u++)s[u]=0;for(u=1;u<l;u+=2)s[e[u]]++;var c=o.K;for(t=0,s[0]=0,n=1;n<=r;n++)t=t+s[n-1]<<1,c[n]=t;for(i=0;i<l;i+=2)0!=(a=e[i+1])&&(e[i]=c[a],c[a]++)},f.H.A=function(e,r,t){for(var n=e.length,i=f.H.m.r,a=0;a<n;a+=2)if(0!=e[a+1])for(var o=a>>1,l=e[a+1],s=o<<4|l,u=r-l,c=e[a]<<u,h=c+(1<<u);c!=h;)t[i[c]>>>15-r]=s,c++},f.H.l=function(e,r){for(var t=f.H.m.r,n=15-r,i=0;i<e.length;i+=2){var a=e[i]<<r-e[i+1];e[i]=t[a]>>>n}},f.H.M=function(e,r,t){t<<=7&r;var n=r>>>3;e[n]|=t,e[n+1]|=t>>>8},f.H.I=function(e,r,t){t<<=7&r;var n=r>>>3;e[n]|=t,e[n+1]|=t>>>8,e[n+2]|=t>>>16},f.H.e=function(e,r,t){return(e[r>>>3]|e[1+(r>>>3)]<<8)>>>(7&r)&(1<<t)-1},f.H.b=function(e,r,t){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)&(1<<t)-1},f.H.Z=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)},f.H.i=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16|e[3+(r>>>3)]<<24)>>>(7&r)},f.H.m=(i=Uint16Array,a=Uint32Array,{K:new i(16),j:new i(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],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,999,999,999],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,0,0,0],q:new i(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],z:[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],c:new a(32),J:new i(512),_:[],h:new i(32),$:[],w:new i(32768),C:[],v:[],d:new i(32768),D:[],u:new i(512),Q:[],r:new i(32768),s:new a(286),Y:new a(30),a:new a(19),t:new a(15e3),k:new i(65536),g:new i(32768)}),function(){for(var e=f.H.m,r=0;r<32768;r++){var t=r;t=(4278255360&(t=(4042322160&(t=(3435973836&(t=(2863311530&t)>>>1|(1431655765&t)<<1))>>>2|(858993459&t)<<2))>>>4|(252645135&t)<<4))>>>8|(16711935&t)<<8,e.r[r]=(t>>>16|t<<16)>>>17}function n(e,r,t){for(;0!=r--;)e.push(0,t)}for(r=0;r<32;r++)e.q[r]=e.S[r]<<3|e.T[r],e.c[r]=e.p[r]<<4|e.z[r];n(e._,144,8),n(e._,112,9),n(e._,24,7),n(e._,8,8),f.H.n(e._,9),f.H.A(e._,9,e.J),f.H.l(e._,9),n(e.$,32,5),f.H.n(e.$,5),f.H.A(e.$,5,e.h),f.H.l(e.$,5),n(e.Q,19,0),n(e.C,286,0),n(e.D,30,0),n(e.v,320,0)}(),f.H.N),o.decode._readInterlace=function(e,r){for(var t=r.width,n=r.height,i=o.decode._getBPP(r),a=i>>3,f=Math.ceil(t*i/8),l=new Uint8Array(n*f),s=0,u=[0,0,4,0,2,0,1],c=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],d=[8,8,4,4,2,2,1],v=0;v<7;){for(var g=h[v],p=d[v],w=0,b=0,m=u[v];m<n;)m+=g,b++;for(var y=c[v];y<t;)y+=p,w++;var A=Math.ceil(w*i/8);o.decode._filterZero(e,r,s,w,b);for(var U=0,_=u[v];_<n;){for(var H=c[v],I=s+U*A<<3;H<t;){var M;if(1==i)M=(M=e[I>>3])>>7-(7&I)&1,l[_*f+(H>>3)]|=M<<7-((7&H)<<0);if(2==i)M=(M=e[I>>3])>>6-(7&I)&3,l[_*f+(H>>2)]|=M<<6-((3&H)<<1);if(4==i)M=(M=e[I>>3])>>4-(7&I)&15,l[_*f+(H>>1)]|=M<<4-((1&H)<<2);if(i>=8)for(var x=_*f+H*a,T=0;T<a;T++)l[x+T]=e[(I>>3)+T];I+=i,H+=p}U++,_+=g}w*b!=0&&(s+=b*(1+A)),v+=1}return l},o.decode._getBPP=function(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth},o.decode._filterZero=function(e,r,t,n,i){var a=o.decode._getBPP(r),f=Math.ceil(n*a/8),l=o.decode._paeth;a=Math.ceil(a/8);var s=0,u=1,c=e[t],h=0;if(c>1&&(e[t]=[0,0,1][c-2]),3==c)for(h=a;h<f;h++)e[h+1]=e[h+1]+(e[h+1-a]>>>1)&255;for(var d=0;d<i;d++)if(h=0,0==(c=e[(u=(s=t+d*f)+d+1)-1]))for(;h<f;h++)e[s+h]=e[u+h];else if(1==c){for(;h<a;h++)e[s+h]=e[u+h];for(;h<f;h++)e[s+h]=e[u+h]+e[s+h-a]}else if(2==c)for(;h<f;h++)e[s+h]=e[u+h]+e[s+h-f];else if(3==c){for(;h<a;h++)e[s+h]=e[u+h]+(e[s+h-f]>>>1);for(;h<f;h++)e[s+h]=e[u+h]+(e[s+h-f]+e[s+h-a]>>>1)}else{for(;h<a;h++)e[s+h]=e[u+h]+l(0,e[s+h-f],0);for(;h<f;h++)e[s+h]=e[u+h]+l(e[s+h-a],e[s+h-f],e[s+h-a-f])}return e},o.decode._paeth=function(e,r,t){var n=e+r-t,i=n-e,a=n-r,f=n-t;return i*i<=a*a&&i*i<=f*f?e:a*a<=f*f?r:t},o.decode._IHDR=function(e,r,t){var n=o._bin;t.width=n.readUint(e,r),r+=4,t.height=n.readUint(e,r),r+=4,t.depth=e[r],r++,t.ctype=e[r],r++,t.compress=e[r],r++,t.filter=e[r],r++,t.interlace=e[r],r++},o._bin={nextZero:function(e,r){for(;0!=e[r];)r++;return r},readUshort:function(e,r){return e[r]<<8|e[r+1]},writeUshort:function(e,r,t){e[r]=t>>8&255,e[r+1]=255&t},readUint:function(e,r){return 16777216*e[r]+(e[r+1]<<16|e[r+2]<<8|e[r+3])},writeUint:function(e,r,t){e[r]=t>>24&255,e[r+1]=t>>16&255,e[r+2]=t>>8&255,e[r+3]=255&t},readASCII:function(e,r,t){for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[r+i]);return n},writeASCII:function(e,r,t){for(var n=0;n<t.length;n++)e[r+n]=t.charCodeAt(n)},readBytes:function(e,r,t){for(var n=[],i=0;i<t;i++)n.push(e[r+i]);return n},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,r,t){for(var n,i="",a=0;a<t;a++)i+="%"+o._bin.pad(e[r+a].toString(16));try{n=decodeURIComponent(i)}catch(n){return o._bin.readASCII(e,r,t)}return n}},o._copyTile=function(e,r,t,n,i,a,f,o,l){for(var s=Math.min(r,i),u=Math.min(t,a),c=0,h=0,d=0;d<u;d++)for(var v=0;v<s;v++)if(f>=0&&o>=0?(c=d*r+v<<2,h=(o+d)*i+f+v<<2):(c=(-o+d)*r-f+v<<2,h=d*i+v<<2),0==l)n[h]=e[c],n[h+1]=e[c+1],n[h+2]=e[c+2],n[h+3]=e[c+3];else if(1==l){var g=e[c+3]*(1/255),p=e[c]*g,w=e[c+1]*g,b=e[c+2]*g,m=n[h+3]*(1/255),y=n[h]*m,A=n[h+1]*m,U=n[h+2]*m,_=1-g,H=g+m*_,I=0==H?0:1/H;n[h+3]=255*H,n[h+0]=(p+y*_)*I,n[h+1]=(w+A*_)*I,n[h+2]=(b+U*_)*I}else if(2==l){g=e[c+3],p=e[c],w=e[c+1],b=e[c+2],m=n[h+3],y=n[h],A=n[h+1],U=n[h+2];g==m&&p==y&&w==A&&b==U?(n[h]=0,n[h+1]=0,n[h+2]=0,n[h+3]=0):(n[h]=p,n[h+1]=w,n[h+2]=b,n[h+3]=g)}else if(3==l){g=e[c+3],p=e[c],w=e[c+1],b=e[c+2],m=n[h+3],y=n[h],A=n[h+1],U=n[h+2];if(g==m&&p==y&&w==A&&b==U)continue;if(g<220&&m>20)return!1}return!0},o.encode=function(e,r,t,n,i,a,f){null==n&&(n=0),null==f&&(f=!1);var l=o.encode.compress(e,r,t,n,[!1,!1,!1,0,f]);return o.encode.compressPNG(l,-1),o.encode._main(l,r,t,i,a)},o.encodeLL=function(e,r,t,n,i,a,f,l){for(var s={ctype:0+(1==n?0:2)+(0==i?0:4),depth:a,frames:[]},u=(n+i)*a,c=u*r,h=0;h<e.length;h++)s.frames.push({rect:{x:0,y:0,width:r,height:t},img:new Uint8Array(e[h]),blend:0,dispose:1,bpp:Math.ceil(u/8),bpl:Math.ceil(c/8)});return o.encode.compressPNG(s,0,!0),o.encode._main(s,r,t,f,l)},o.encode._main=function(e,r,t,n,i){null==i&&(i={});var a=o.crc.crc,f=o._bin.writeUint,l=o._bin.writeUshort,s=o._bin.writeASCII,u=8,c=e.frames.length>1,h=!1,d=33+(c?20:0);if(null!=i.sRGB&&(d+=13),null!=i.pHYs&&(d+=21),3==e.ctype){for(var v=e.plte.length,g=0;g<v;g++)e.plte[g]>>>24!=255&&(h=!0);d+=8+3*v+4+(h?8+1*v+4:0)}for(var p=0;p<e.frames.length;p++){c&&(d+=38),d+=(I=e.frames[p]).cimg.length+12,0!=p&&(d+=4)}d+=12;var w=new Uint8Array(d),b=[137,80,78,71,13,10,26,10];for(g=0;g<8;g++)w[g]=b[g];if(f(w,u,13),s(w,u+=4,"IHDR"),f(w,u+=4,r),f(w,u+=4,t),w[u+=4]=e.depth,w[++u]=e.ctype,w[++u]=0,w[++u]=0,w[++u]=0,f(w,++u,a(w,u-17,17)),u+=4,null!=i.sRGB&&(f(w,u,1),s(w,u+=4,"sRGB"),w[u+=4]=i.sRGB,f(w,++u,a(w,u-5,5)),u+=4),null!=i.pHYs&&(f(w,u,9),s(w,u+=4,"pHYs"),f(w,u+=4,i.pHYs[0]),f(w,u+=4,i.pHYs[1]),w[u+=4]=i.pHYs[2],f(w,++u,a(w,u-13,13)),u+=4),c&&(f(w,u,8),s(w,u+=4,"acTL"),f(w,u+=4,e.frames.length),f(w,u+=4,null!=i.loop?i.loop:0),f(w,u+=4,a(w,u-12,12)),u+=4),3==e.ctype){f(w,u,3*(v=e.plte.length)),s(w,u+=4,"PLTE"),u+=4;for(g=0;g<v;g++){var m=3*g,y=e.plte[g],A=255&y,U=y>>>8&255,_=y>>>16&255;w[u+m+0]=A,w[u+m+1]=U,w[u+m+2]=_}if(f(w,u+=3*v,a(w,u-3*v-4,3*v+4)),u+=4,h){f(w,u,v),s(w,u+=4,"tRNS"),u+=4;for(g=0;g<v;g++)w[u+g]=e.plte[g]>>>24&255;f(w,u+=v,a(w,u-v-4,v+4)),u+=4}}var H=0;for(p=0;p<e.frames.length;p++){var I=e.frames[p];c&&(f(w,u,26),s(w,u+=4,"fcTL"),f(w,u+=4,H++),f(w,u+=4,I.rect.width),f(w,u+=4,I.rect.height),f(w,u+=4,I.rect.x),f(w,u+=4,I.rect.y),l(w,u+=4,n[p]),l(w,u+=2,1e3),w[u+=2]=I.dispose,w[++u]=I.blend,f(w,++u,a(w,u-30,30)),u+=4);var M=I.cimg;f(w,u,(v=M.length)+(0==p?0:4));var x=u+=4;s(w,u,0==p?"IDAT":"fdAT"),u+=4,0!=p&&(f(w,u,H++),u+=4),w.set(M,u),f(w,u+=v,a(w,x,u-x)),u+=4}return f(w,u,0),s(w,u+=4,"IEND"),f(w,u+=4,a(w,u-4,4)),u+=4,w.buffer},o.encode.compressPNG=function(e,r,t){for(var n=0;n<e.frames.length;n++){var i=e.frames[n];i.rect.width;var a=i.rect.height,f=new Uint8Array(a*i.bpl+a);i.cimg=o.encode._filterZero(i.img,a,i.bpp,i.bpl,f,r,t)}},o.encode.compress=function(e,r,t,n,i){for(var a=i[0],f=i[1],l=i[2],s=i[3],u=i[4],c=6,h=8,d=255,v=0;v<e.length;v++)for(var g=new Uint8Array(e[v]),p=g.length,w=0;w<p;w+=4)d&=g[w+3];var b=255!=d,m=o.encode.framize(e,r,t,a,f,l),y={},A=[],U=[];if(0!=n){var _=[];for(w=0;w<m.length;w++)_.push(m[w].img.buffer);var H=o.encode.concatRGBA(_),I=o.quantize(H,n);console.log(I);var M=0,x=new Uint8Array(I.abuf);for(w=0;w<m.length;w++){var T=(K=m[w].img).length;U.push(new Uint8Array(I.inds.buffer,M>>2,T>>2));for(v=0;v<T;v+=4)K[v]=x[M+v],K[v+1]=x[M+v+1],K[v+2]=x[M+v+2],K[v+3]=x[M+v+3];M+=T}for(w=0;w<I.plte.length;w++)A.push(I.plte[w].est.rgba)}else for(v=0;v<m.length;v++){var q=m[v],R=new Uint32Array(q.img.buffer),z=q.rect.width,D=(p=R.length,new Uint8Array(p));U.push(D);for(w=0;w<p;w++){var N=R[w];if(0!=w&&N==R[w-1])D[w]=D[w-1];else if(w>z&&N==R[w-z])D[w]=D[w-z];else{var S=y[N];if(null==S&&(y[N]=S=A.length,A.push(N),A.length>=300))break;D[w]=S}}}var P=A.length;P<=256&&0==u&&(h=P<=2?1:P<=4?2:P<=16?4:8,h=Math.max(h,s));for(v=0;v<m.length;v++){(q=m[v]).rect.x,q.rect.y;z=q.rect.width;var B=q.rect.height,C=q.img;new Uint32Array(C.buffer);var E=4*z,L=4;if(P<=256&&0==u){E=Math.ceil(h*z/8);for(var G=new Uint8Array(E*B),Z=U[v],F=0;F<B;F++){w=F*E;var k=F*z;if(8==h)for(var Y=0;Y<z;Y++)G[w+Y]=Z[k+Y];else if(4==h)for(Y=0;Y<z;Y++)G[w+(Y>>1)]|=Z[k+Y]<<4-4*(1&Y);else if(2==h)for(Y=0;Y<z;Y++)G[w+(Y>>2)]|=Z[k+Y]<<6-2*(3&Y);else if(1==h)for(Y=0;Y<z;Y++)G[w+(Y>>3)]|=Z[k+Y]<<7-1*(7&Y)}C=G,c=3,L=1}else if(0==b&&1==m.length){G=new Uint8Array(z*B*3);var j=z*B;for(w=0;w<j;w++){var K,Q=4*w;G[K=3*w]=C[Q],G[K+1]=C[Q+1],G[K+2]=C[Q+2]}C=G,c=2,L=3,E=3*z}q.img=C,q.bpl=E,q.bpp=L}return{ctype:c,depth:h,plte:A,frames:m}},o.encode.framize=function(e,r,t,n,i,a){for(var f=[],l=0;l<e.length;l++){var s,u=new Uint8Array(e[l]),c=new Uint32Array(u.buffer),h=0,d=0,v=r,g=t,p=n?1:0;if(0!=l){for(var w=a||n||1==l||0!=f[l-2].dispose?1:2,b=0,m=1e9,y=0;y<w;y++){for(var A=new Uint8Array(e[l-1-y]),U=new Uint32Array(e[l-1-y]),_=r,H=t,I=-1,M=-1,x=0;x<t;x++)for(var T=0;T<r;T++){c[P=x*r+T]!=U[P]&&(T<_&&(_=T),T>I&&(I=T),x<H&&(H=x),x>M&&(M=x))}-1==I&&(_=H=I=M=0),i&&(1==(1&_)&&_--,1==(1&H)&&H--);var q=(I-_+1)*(M-H+1);q<m&&(m=q,b=y,h=_,d=H,v=I-_+1,g=M-H+1)}A=new Uint8Array(e[l-1-b]);1==b&&(f[l-1].dispose=2),s=new Uint8Array(v*g*4),o._copyTile(A,r,t,s,v,g,-h,-d,0),1==(p=o._copyTile(u,r,t,s,v,g,-h,-d,3)?1:0)?o.encode._prepareDiff(u,r,t,s,{x:h,y:d,width:v,height:g}):o._copyTile(u,r,t,s,v,g,-h,-d,0)}else s=u.slice(0);f.push({rect:{x:h,y:d,width:v,height:g},img:s,blend:p,dispose:0})}if(n)for(l=0;l<f.length;l++){if(1!=(B=f[l]).blend){var R=B.rect,z=f[l-1].rect,D=Math.min(R.x,z.x),N=Math.min(R.y,z.y),S={x:D,y:N,width:Math.max(R.x+R.width,z.x+z.width)-D,height:Math.max(R.y+R.height,z.y+z.height)-N};f[l-1].dispose=1,l-1!=0&&o.encode._updateFrame(e,r,t,f,l-1,S,i),o.encode._updateFrame(e,r,t,f,l,S,i)}}if(1!=e.length)for(var P=0;P<f.length;P++){var B;(B=f[P]).rect.width*B.rect.height}return f},o.encode._updateFrame=function(e,r,t,n,i,a,f){for(var l=Uint8Array,s=Uint32Array,u=new l(e[i-1]),c=new s(e[i-1]),h=i+1<e.length?new l(e[i+1]):null,d=new l(e[i]),v=new s(d.buffer),g=r,p=t,w=-1,b=-1,m=0;m<a.height;m++)for(var y=0;y<a.width;y++){var A=a.x+y,U=a.y+m,_=U*r+A,H=v[_];0==H||0==n[i-1].dispose&&c[_]==H&&(null==h||0!=h[4*_+3])||(A<g&&(g=A),A>w&&(w=A),U<p&&(p=U),U>b&&(b=U))}-1==w&&(g=p=w=b=0),f&&(1==(1&g)&&g--,1==(1&p)&&p--),a={x:g,y:p,width:w-g+1,height:b-p+1};var I=n[i];I.rect=a,I.blend=1,I.img=new Uint8Array(a.width*a.height*4),0==n[i-1].dispose?(o._copyTile(u,r,t,I.img,a.width,a.height,-a.x,-a.y,0),o.encode._prepareDiff(d,r,t,I.img,a)):o._copyTile(d,r,t,I.img,a.width,a.height,-a.x,-a.y,0)},o.encode._prepareDiff=function(e,r,t,n,i){o._copyTile(e,r,t,n,i.width,i.height,-i.x,-i.y,2)},o.encode._filterZero=function(t,n,i,a,f,l,s){var u,c=[],h=[0,1,2,3,4];-1!=l?h=[l]:(n*a>5e5||1==i)&&(h=[0]),s&&(u={level:0});for(var d=f.length>1e7&&null!=e?e:r,v=0;v<h.length;v++){for(var g=0;g<n;g++)o.encode._filterLine(f,t,g,a,i,h[v]);c.push(d.deflate(f,u))}var p,w=1e9;for(v=0;v<c.length;v++)c[v].length<w&&(p=v,w=c[v].length);return c[p]},o.encode._filterLine=function(e,r,t,n,i,a){var f=t*n,l=f+t,s=o.decode._paeth;if(e[l]=a,l++,0==a)if(n<500)for(var u=0;u<n;u++)e[l+u]=r[f+u];else e.set(new Uint8Array(r.buffer,f,n),l);else if(1==a){for(u=0;u<i;u++)e[l+u]=r[f+u];for(u=i;u<n;u++)e[l+u]=r[f+u]-r[f+u-i]+256&255}else if(0==t){for(u=0;u<i;u++)e[l+u]=r[f+u];if(2==a)for(u=i;u<n;u++)e[l+u]=r[f+u];if(3==a)for(u=i;u<n;u++)e[l+u]=r[f+u]-(r[f+u-i]>>1)+256&255;if(4==a)for(u=i;u<n;u++)e[l+u]=r[f+u]-s(r[f+u-i],0,0)+256&255}else{if(2==a)for(u=0;u<n;u++)e[l+u]=r[f+u]+256-r[f+u-n]&255;if(3==a){for(u=0;u<i;u++)e[l+u]=r[f+u]+256-(r[f+u-n]>>1)&255;for(u=i;u<n;u++)e[l+u]=r[f+u]+256-(r[f+u-n]+r[f+u-i]>>1)&255}if(4==a){for(u=0;u<i;u++)e[l+u]=r[f+u]+256-s(0,r[f+u-n],0)&255;for(u=i;u<n;u++)e[l+u]=r[f+u]+256-s(r[f+u-i],r[f+u-n],r[f+u-i-n])&255}}},o.crc={table:function(){for(var e=new Uint32Array(256),r=0;r<256;r++){for(var t=r,n=0;n<8;n++)1&t?t=3988292384^t>>>1:t>>>=1;e[r]=t}return e}(),update:function(e,r,t,n){for(var i=0;i<n;i++)e=o.crc.table[255&(e^r[t+i])]^e>>>8;return e},crc:function(e,r,t){return 4294967295^o.crc.update(4294967295,e,r,t)}},o.quantize=function(e,r){var t,n=new Uint8Array(e),i=n.slice(0),a=new Uint32Array(i.buffer),f=o.quantize.getKDtree(i,r),l=f[0],s=f[1],u=o.quantize.planeDst,c=n,h=a,d=c.length,v=new Uint8Array(n.length>>2);if(n.length<2e7)for(var g=0;g<d;g+=4){var p=c[g]*(1/255),w=c[g+1]*(1/255),b=c[g+2]*(1/255),m=c[g+3]*(1/255);t=o.quantize.getNearest(l,p,w,b,m),v[g>>2]=t.ind,h[g>>2]=t.est.rgba}else for(g=0;g<d;g+=4){p=c[g]*(1/255),w=c[g+1]*(1/255),b=c[g+2]*(1/255),m=c[g+3]*(1/255);for(t=l;t.left;)t=u(t.est,p,w,b,m)<=0?t.left:t.right;v[g>>2]=t.ind,h[g>>2]=t.est.rgba}return{abuf:i.buffer,inds:v,plte:s}},o.quantize.getKDtree=function(e,r,t){null==t&&(t=1e-4);var n=new Uint32Array(e.buffer),i={i0:0,i1:e.length,bst:null,est:null,tdst:0,left:null,right:null};i.bst=o.quantize.stats(e,i.i0,i.i1),i.est=o.quantize.estats(i.bst);for(var a=[i];a.length<r;){for(var f=0,l=0,s=0;s<a.length;s++)a[s].est.L>f&&(f=a[s].est.L,l=s);if(f<t)break;var u=a[l],c=o.quantize.splitPixels(e,n,u.i0,u.i1,u.est.e,u.est.eMq255);if(u.i0>=c||u.i1<=c)u.est.L=0;else{var h={i0:u.i0,i1:c,bst:null,est:null,tdst:0,left:null,right:null};h.bst=o.quantize.stats(e,h.i0,h.i1),h.est=o.quantize.estats(h.bst);var d={i0:c,i1:u.i1,bst:null,est:null,tdst:0,left:null,right:null};d.bst={R:[],m:[],N:u.bst.N-h.bst.N};for(s=0;s<16;s++)d.bst.R[s]=u.bst.R[s]-h.bst.R[s];for(s=0;s<4;s++)d.bst.m[s]=u.bst.m[s]-h.bst.m[s];d.est=o.quantize.estats(d.bst),u.left=h,u.right=d,a[l]=h,a.push(d)}}a.sort((function(e,r){return r.bst.N-e.bst.N}));for(s=0;s<a.length;s++)a[s].ind=s;return[i,a]},o.quantize.getNearest=function(e,r,t,n,i){if(null==e.left)return e.tdst=o.quantize.dist(e.est.q,r,t,n,i),e;var a=o.quantize.planeDst(e.est,r,t,n,i),f=e.left,l=e.right;a>0&&(f=e.right,l=e.left);var s=o.quantize.getNearest(f,r,t,n,i);if(s.tdst<=a*a)return s;var u=o.quantize.getNearest(l,r,t,n,i);return u.tdst<s.tdst?u:s},o.quantize.planeDst=function(e,r,t,n,i){var a=e.e;return a[0]*r+a[1]*t+a[2]*n+a[3]*i-e.eMq},o.quantize.dist=function(e,r,t,n,i){var a=r-e[0],f=t-e[1],o=n-e[2],l=i-e[3];return a*a+f*f+o*o+l*l},o.quantize.splitPixels=function(e,r,t,n,i,a){var f=o.quantize.vecDot;for(n-=4;t<n;){for(;f(e,t,i)<=a;)t+=4;for(;f(e,n,i)>a;)n-=4;if(t>=n)break;var l=r[t>>2];r[t>>2]=r[n>>2],r[n>>2]=l,t+=4,n-=4}for(;f(e,t,i)>a;)t-=4;return t+4},o.quantize.vecDot=function(e,r,t){return e[r]*t[0]+e[r+1]*t[1]+e[r+2]*t[2]+e[r+3]*t[3]},o.quantize.stats=function(e,r,t){for(var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],a=t-r>>2,f=r;f<t;f+=4){var o=e[f]*(1/255),l=e[f+1]*(1/255),s=e[f+2]*(1/255),u=e[f+3]*(1/255);i[0]+=o,i[1]+=l,i[2]+=s,i[3]+=u,n[0]+=o*o,n[1]+=o*l,n[2]+=o*s,n[3]+=o*u,n[5]+=l*l,n[6]+=l*s,n[7]+=l*u,n[10]+=s*s,n[11]+=s*u,n[15]+=u*u}return n[4]=n[1],n[8]=n[2],n[9]=n[6],n[12]=n[3],n[13]=n[7],n[14]=n[11],{R:n,m:i,N:a}},o.quantize.estats=function(e){var r=e.R,t=e.m,n=e.N,i=t[0],a=t[1],f=t[2],l=t[3],s=0==n?0:1/n,u=[r[0]-i*i*s,r[1]-i*a*s,r[2]-i*f*s,r[3]-i*l*s,r[4]-a*i*s,r[5]-a*a*s,r[6]-a*f*s,r[7]-a*l*s,r[8]-f*i*s,r[9]-f*a*s,r[10]-f*f*s,r[11]-f*l*s,r[12]-l*i*s,r[13]-l*a*s,r[14]-l*f*s,r[15]-l*l*s],c=u,h=o.M4,d=[Math.random(),Math.random(),Math.random(),Math.random()],v=0,g=0;if(0!=n)for(var p=0;p<16&&(d=h.multVec(c,d),g=Math.sqrt(h.dot(d,d)),d=h.sml(1/g,d),!(0!=p&&Math.abs(g-v)<1e-9));p++)v=g;var w=[i*s,a*s,f*s,l*s];return{Cov:u,q:w,e:d,L:v,eMq255:h.dot(h.sml(255,w),d),eMq:h.dot(d,w),rgba:(Math.round(255*w[3])<<24|Math.round(255*w[2])<<16|Math.round(255*w[1])<<8|Math.round(255*w[0])<<0)>>>0}},o.M4={multVec:function(e,r){return[e[0]*r[0]+e[1]*r[1]+e[2]*r[2]+e[3]*r[3],e[4]*r[0]+e[5]*r[1]+e[6]*r[2]+e[7]*r[3],e[8]*r[0]+e[9]*r[1]+e[10]*r[2]+e[11]*r[3],e[12]*r[0]+e[13]*r[1]+e[14]*r[2]+e[15]*r[3]]},dot:function(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]+e[3]*r[3]},sml:function(e,r){return[e*r[0],e*r[1],e*r[2],e*r[3]]}},o.encode.concatRGBA=function(e){for(var r=0,t=0;t<e.length;t++)r+=e[t].byteLength;var n=new Uint8Array(r),i=0;for(t=0;t<e.length;t++){for(var a=new Uint8Array(e[t]),f=a.length,o=0;o<f;o+=4){var l=a[o],s=a[o+1],u=a[o+2],c=a[o+3];0==c&&(l=s=u=0),n[i+o]=l,n[i+o+1]=s,n[i+o+2]=u,n[i+o+3]=c}i+=f}return n.buffer};export{d as default,l as fileToBase64};