u;)S=i[x++],v
u&&(U=e[I--],U[0]-=S*(U[0]-H)/ce,U[1]-=S*(U[1]-h)/ce,U[2]-=S*(U[2]-d)/ce)}function c(f,w,H){var h=2147483647,d=h,u=-1,p=u,v,I,x,U,S;for(v=0;v =0&&(d=e[x],u=w-d[1],u>=p?x=-1:(x--,u<0&&(u=-u),h=d[0]-f,h<0&&(h=-h),u+=h,u >vr;for(v<=1&&(v=0),f=0;f u;)S=i[x++],v u&&(U=e[I--],U[0]-=S*(U[0]-H)/ce,U[1]-=S*(U[1]-h)/ce,U[2]-=S*(U[2]-d)/ce)}function c(f,w,H){var h=2147483647,d=h,u=-1,p=u,v,I,x,U,S;for(v=0;v =0&&(d=e[x],u=w-d[1],u>=p?x=-1:(x--,u<0&&(u=-u),h=d[0]-f,h<0&&(h=-h),u+=h,u >vr;for(v<=1&&(v=0),f=0;f u;)S=i[x++],v u&&(U=e[I--],U[0]-=S*(U[0]-H)/ce,U[1]-=S*(U[1]-h)/ce,U[2]-=S*(U[2]-d)/ce)}function c(f,w,H){var h=2147483647,d=h,u=-1,p=u,v,I,x,U,S;for(v=0;v =0&&(d=e[x],u=w-d[1],u>=p?x=-1:(x--,u<0&&(u=-u),h=d[0]-f,h<0&&(h=-h),u+=h,u >vr;for(v<=1&&(v=0),f=0;f u;)S=i[x++],v u&&(U=e[I--],U[0]-=S*(U[0]-H)/ce,U[1]-=S*(U[1]-h)/ce,U[2]-=S*(U[2]-d)/ce)}function c(f,w,H){var h=2147483647,d=h,u=-1,p=u,v,I,x,U,S;for(v=0;v =0&&(d=e[x],u=w-d[1],u>=p?x=-1:(x--,u<0&&(u=-u),h=d[0]-f,h<0&&(h=-h),u+=h,u >vr;for(v<=1&&(v=0),f=0;f>16,(r&65280)>>8,r&255,A)};X.prototype.findClosestRGB=function(r,A,e,t){if(this.colorTab===null)return-1;if(this.neuQuant&&!t)return this.neuQuant.lookupRGB(r,A,e);for(var n=0,s=256*256*256,i=this.colorTab.length,a=0,B=0;a=0&&(A=this.dispose&7),A<<=2,this.out.writeByte(0|A|0|r),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)};X.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)};X.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)};X.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)};X.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var r=3*256-this.colorTab.length,A=0;A>>8^t[(e^A[n])&255];return this.crc=e,this}}Ot.prototype.table=(()=>{var r,A,e,t=[];for(r=0;r<256;r++){for(e=r,A=0;A<8;A++)e=e&1?e>>>1^3988292384:e>>>1;t[r]=e}return t})();function qt(r){let A=new Uint8Array(r),e=new DataView(A.buffer),t={array:A,view:e,size:r,set8(n,s){return e.setUint8(n,s),t},set16(n,s){return e.setUint16(n,s,!0),t},set32(n,s){return e.setUint32(n,s,!0),t},bytes(n,s){return A.set(s,n),t}};return t}class Rt{constructor(A){let e=new Date;Object.assign(this,{directory:A,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(A)}async add(A,e){let t=!e,n=Rt.encoder.encode("".concat(this.directory,"/").concat(t?"":A)),s=new Uint8Array(t?0:await e.arrayBuffer()),i=30+n.length,a=i+s.length,B=16,{offset:o}=this,l=qt(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Ot.for(s)).set32(14,s.length).set32(18,s.length).set16(22,n.length);o+=i;let c=qt(i+s.length+B).set32(0,67324752).bytes(4,l.array).bytes(30,n).bytes(i,s);o+=s.length,c.set32(a,134695760).bytes(a+4,l.array.slice(10,22)),o+=B,this.files.push({offset:o,folder:t,name:n,header:l,payload:c}),this.offset=o}toBuffer(){let A=this.files.reduce((c,{name:g})=>46+g.length+c,0),e=qt(A+22),t=0;for(var{offset:n,name:s,header:i,folder:a}of this.files)e.set32(t,33639248).set16(t+4,20).bytes(t+6,i.array).set8(t+38,a?16:0).set32(t+42,n).bytes(t+46,s),t+=46+s.length;e.set32(t,101010256).set16(t+8,this.files.length).set16(t+10,this.files.length).set32(t+12,A).set32(t+16,this.offset);let B=new Uint8Array(this.offset+e.size),o=0;for(var{payload:l}of this.files)B.set(l.array,o),o+=l.size;return B.set(e.array,o),B}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}}Rt.encoder=new TextEncoder;const Wr=(r,A,e,t)=>{if(t){let{width:n,height:s}=r,i=Object.assign(document.createElement("canvas"),{width:n,height:s}),a=i.getContext("2d");a.fillStyle=t,a.fillRect(0,0,n,s),a.drawImage(r,0,0),r=i}return new Promise((n,s)=>r.toBlob(n,A,e))},Pi=(...r)=>Wr(...r).then(A=>A.arrayBuffer()),ki=async(r,A,e,t,n)=>{ds(n,await Wr(r,A,e,t))},_i=async(r,A,e,t,n,s,i)=>{let a=l=>s.replace("{}",String(l+1).padStart(i,"0")),B=Fs(n,".zip")||"archive",o=new Rt(B);await Promise.all(r.map(async(l,c)=>{let g=a(c);await o.add(g,await Wr(l,A,e,t))})),ds("".concat(B,".zip"),o.blob)},ds=(r,A)=>{const e=window.URL.createObjectURL(A),t=document.createElement("a");t.style.display="none",t.href=e,t.setAttribute("download",r),typeof t.download>"u"&&t.setAttribute("target","_blank"),document.body.appendChild(t),t.click(),document.body.removeChild(t),setTimeout(()=>window.URL.revokeObjectURL(e),100)},Xi=(r,A,e)=>r.map(t=>{if(A==1&&!e)return t.canvas;let n=document.createElement("canvas"),s=n.getContext("2d"),i=t.canvas?t.canvas:t;return n.width=i.width*A,n.height=i.height*A,e&&(s.fillStyle=e,s.fillRect(0,0,n.width,n.height)),s.scale(A,A),s.drawImage(i,0,0),n}),Ji={asBuffer:Pi,asDownload:ki,asZipDownload:_i,atScale:Xi,options:Vi},{asBuffer:$t,asDownload:Yi,asZipDownload:Wi,atScale:Ar,options:er}=Ji,cn=Symbol.for("toDataURL"),Zi=r=>new Promise((A,e)=>Object.assign(new ps,{crossOrigin:"Anonymous",onload:A,onerror:e,src:r}));let zi=class{constructor(A,e){let t=document.createElement("canvas"),n=[];Object.defineProperty(t,"async",{value:!0,writable:!1,enumerable:!0});for(var[s,i]of Object.entries({png:()=>$t(t,"image/png"),jpg:()=>$t(t,"image/jpeg"),pages:()=>n.concat(t).map(a=>a.getContext("2d"))}))Object.defineProperty(t,s,{get:i});return Object.assign(t,{width:A,height:e,newPage(...a){var{width:o,height:l}=t,B=Object.assign(document.createElement("canvas"),{width:o,height:l});B.getContext("2d").drawImage(t,0,0),n.push(B);var[o,l]=a.length?a:[o,l];return Object.assign(t,{width:o,height:l}).getContext("2d")},saveAs(a,B){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{filename:a,...B}),{pattern:l,padding:c,mime:g,quality:C,matte:Q,density:F,archive:L}=o,f=Ar(o.pages,F);return c==null?Yi(f[0],g,C,Q,a):Wi(f,g,C,Q,L,l,c)},toBuffer(a="png",B={}){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{extension:a,...B}),{mime:l,quality:c,matte:g,pages:C,density:Q}=o,F=Ar(C,Q,g)[0];return $t(F,l,c,g)},[cn]:t.toDataURL.bind(t),toDataURL(a="png",B={}){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{extension:a,...B}),{mime:l,quality:c,matte:g,pages:C,density:Q}=o,F=Ar(C,Q,g)[0],L=F[F===t?cn:"toDataURL"](l,c);return Promise.resolve(L)}})}};const{CanvasRenderingContext2D:ji,CanvasGradient:qi,CanvasPattern:$i,Image:ps,ImageData:Aa,Path2D:ea,DOMMatrix:ta,DOMRect:ra,DOMPoint:na}=window,sa={Canvas:zi,loadImage:Zi,CanvasRenderingContext2D:ji,CanvasGradient:qi,CanvasPattern:$i,Image:ps,ImageData:Aa,Path2D:ea,DOMMatrix:ta,DOMRect:ra,DOMPoint:na},Ke=(r,A,e={},t=e)=>{if(Array.isArray(A))A.forEach(n=>Ke(r,n,e,t));else if(typeof A=="function")A(r,e,t,Ke);else{const n=Object.keys(A)[0];Array.isArray(A[n])?(t[n]={},Ke(r,A[n],e,t[n])):t[n]=A[n](r,e,t,Ke)}return e},le=(r,A)=>(e,t,n,s)=>{A(e,t,n)&&s(e,r,t,n)},ia=(r,A)=>(e,t,n,s)=>{const i=[];let a=e.pos;for(;A(e,t,n);){const B={};if(s(e,r,t,B),e.pos===a)break;a=e.pos,i.push(B)}return i},aa=r=>({data:r,pos:0}),HA=()=>r=>r.data[r.pos++],Es=(r=0)=>A=>A.data[A.pos+r],DA=r=>A=>A.data.subarray(A.pos,A.pos+=r),Gt=r=>A=>A.data.subarray(A.pos,A.pos+r),Er=r=>A=>Array.from(DA(r)(A)).map(e=>String.fromCharCode(e)).join(""),se=r=>A=>{const e=DA(2)(A);return r?(e[1]<<8)+e[0]:(e[0]<<8)+e[1]},vs=(r,A)=>(e,t,n)=>{const s=typeof A=="function"?A(e,t,n):A,i=DA(r),a=new Array(s);for(var B=0;B{for(var t=0,n=0;n{const A=new Uint8Array(r);return Ke(aa(A),fa)},Ca=r=>{const A=r.pixels.length,e=new Uint8ClampedArray(A*4);for(var t=0;t{if(!r.image){console.warn("gif frame does not have associated image.");return}const{image:t}=r,n=t.descriptor.width*t.descriptor.height;var s=Qa(t.data.minCodeSize,t.data.blocks,n);t.descriptor.lct.interlaced&&(s=wa(s,t.descriptor.width));const i={pixels:s,dims:{top:r.image.descriptor.top,left:r.image.descriptor.left,width:r.image.descriptor.width,height:r.image.descriptor.height}};return t.descriptor.lct&&t.descriptor.lct.exists?i.colorTable=t.lct:i.colorTable=A,r.gce&&(i.delay=(r.gce.delay||10)*10,i.disposalType=r.gce.extras.disposal,r.gce.extras.transparentColorGiven&&(i.transparentIndex=r.gce.transparentColorIndex)),e&&(i.patch=Ca(i)),i},Fa=(r,A)=>r.frames.filter(e=>e.image).map(e=>Ua(e,r.gct,A));function da(r,A,e){const t=Hs(A),n=r-1;let s=0;switch(e){case wA.L:s=xA[n][0];break;case wA.M:s=xA[n][1];break;case wA.Q:s=xA[n][2];break;case wA.H:s=xA[n][3];break}return t<=s}function pa(r,A){for(var e=1,t=Hs(r),n=0,s=xA.length;nxA.length)throw new Error("Too long data");return e}function Hs(r){var A=encodeURI(r).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return A.length+(A.length!=Number(r)?3:0)}class Ea{constructor(A){this.mode=UA.MODE_8BIT_BYTE,this.parsedData=[],this.data=A;const e=[];for(let t=0,n=this.data.length;t>16,(r&65280)>>8,r&255,A)};X.prototype.findClosestRGB=function(r,A,e,t){if(this.colorTab===null)return-1;if(this.neuQuant&&!t)return this.neuQuant.lookupRGB(r,A,e);for(var n=0,s=256*256*256,i=this.colorTab.length,a=0,B=0;a=0&&(A=this.dispose&7),A<<=2,this.out.writeByte(0|A|0|r),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)};X.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)};X.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)};X.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)};X.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var r=3*256-this.colorTab.length,A=0;A>>8^t[(e^A[n])&255];return this.crc=e,this}}Ot.prototype.table=(()=>{var r,A,e,t=[];for(r=0;r<256;r++){for(e=r,A=0;A<8;A++)e=e&1?e>>>1^3988292384:e>>>1;t[r]=e}return t})();function qt(r){let A=new Uint8Array(r),e=new DataView(A.buffer),t={array:A,view:e,size:r,set8(n,s){return e.setUint8(n,s),t},set16(n,s){return e.setUint16(n,s,!0),t},set32(n,s){return e.setUint32(n,s,!0),t},bytes(n,s){return A.set(s,n),t}};return t}class Rt{constructor(A){let e=new Date;Object.assign(this,{directory:A,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(A)}async add(A,e){let t=!e,n=Rt.encoder.encode("".concat(this.directory,"/").concat(t?"":A)),s=new Uint8Array(t?0:await e.arrayBuffer()),i=30+n.length,a=i+s.length,B=16,{offset:o}=this,l=qt(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Ot.for(s)).set32(14,s.length).set32(18,s.length).set16(22,n.length);o+=i;let c=qt(i+s.length+B).set32(0,67324752).bytes(4,l.array).bytes(30,n).bytes(i,s);o+=s.length,c.set32(a,134695760).bytes(a+4,l.array.slice(10,22)),o+=B,this.files.push({offset:o,folder:t,name:n,header:l,payload:c}),this.offset=o}toBuffer(){let A=this.files.reduce((c,{name:g})=>46+g.length+c,0),e=qt(A+22),t=0;for(var{offset:n,name:s,header:i,folder:a}of this.files)e.set32(t,33639248).set16(t+4,20).bytes(t+6,i.array).set8(t+38,a?16:0).set32(t+42,n).bytes(t+46,s),t+=46+s.length;e.set32(t,101010256).set16(t+8,this.files.length).set16(t+10,this.files.length).set32(t+12,A).set32(t+16,this.offset);let B=new Uint8Array(this.offset+e.size),o=0;for(var{payload:l}of this.files)B.set(l.array,o),o+=l.size;return B.set(e.array,o),B}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}}Rt.encoder=new TextEncoder;const Wr=(r,A,e,t)=>{if(t){let{width:n,height:s}=r,i=Object.assign(document.createElement("canvas"),{width:n,height:s}),a=i.getContext("2d");a.fillStyle=t,a.fillRect(0,0,n,s),a.drawImage(r,0,0),r=i}return new Promise((n,s)=>r.toBlob(n,A,e))},Pi=(...r)=>Wr(...r).then(A=>A.arrayBuffer()),ki=async(r,A,e,t,n)=>{ds(n,await Wr(r,A,e,t))},_i=async(r,A,e,t,n,s,i)=>{let a=l=>s.replace("{}",String(l+1).padStart(i,"0")),B=Fs(n,".zip")||"archive",o=new Rt(B);await Promise.all(r.map(async(l,c)=>{let g=a(c);await o.add(g,await Wr(l,A,e,t))})),ds("".concat(B,".zip"),o.blob)},ds=(r,A)=>{const e=window.URL.createObjectURL(A),t=document.createElement("a");t.style.display="none",t.href=e,t.setAttribute("download",r),typeof t.download>"u"&&t.setAttribute("target","_blank"),document.body.appendChild(t),t.click(),document.body.removeChild(t),setTimeout(()=>window.URL.revokeObjectURL(e),100)},Xi=(r,A,e)=>r.map(t=>{if(A==1&&!e)return t.canvas;let n=document.createElement("canvas"),s=n.getContext("2d"),i=t.canvas?t.canvas:t;return n.width=i.width*A,n.height=i.height*A,e&&(s.fillStyle=e,s.fillRect(0,0,n.width,n.height)),s.scale(A,A),s.drawImage(i,0,0),n}),Ji={asBuffer:Pi,asDownload:ki,asZipDownload:_i,atScale:Xi,options:Vi},{asBuffer:$t,asDownload:Yi,asZipDownload:Wi,atScale:Ar,options:er}=Ji,cn=Symbol.for("toDataURL"),Zi=r=>new Promise((A,e)=>Object.assign(new ps,{crossOrigin:"Anonymous",onload:A,onerror:e,src:r}));let zi=class{constructor(A,e){let t=document.createElement("canvas"),n=[];Object.defineProperty(t,"async",{value:!0,writable:!1,enumerable:!0});for(var[s,i]of Object.entries({png:()=>$t(t,"image/png"),jpg:()=>$t(t,"image/jpeg"),pages:()=>n.concat(t).map(a=>a.getContext("2d"))}))Object.defineProperty(t,s,{get:i});return Object.assign(t,{width:A,height:e,newPage(...a){var{width:o,height:l}=t,B=Object.assign(document.createElement("canvas"),{width:o,height:l});B.getContext("2d").drawImage(t,0,0),n.push(B);var[o,l]=a.length?a:[o,l];return Object.assign(t,{width:o,height:l}).getContext("2d")},saveAs(a,B){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{filename:a,...B}),{pattern:l,padding:c,mime:g,quality:C,matte:Q,density:F,archive:L}=o,f=Ar(o.pages,F);return c==null?Yi(f[0],g,C,Q,a):Wi(f,g,C,Q,L,l,c)},toBuffer(a="png",B={}){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{extension:a,...B}),{mime:l,quality:c,matte:g,pages:C,density:Q}=o,F=Ar(C,Q,g)[0];return $t(F,l,c,g)},[cn]:t.toDataURL.bind(t),toDataURL(a="png",B={}){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{extension:a,...B}),{mime:l,quality:c,matte:g,pages:C,density:Q}=o,F=Ar(C,Q,g)[0],L=F[F===t?cn:"toDataURL"](l,c);return Promise.resolve(L)}})}};const{CanvasRenderingContext2D:ji,CanvasGradient:qi,CanvasPattern:$i,Image:ps,ImageData:Aa,Path2D:ea,DOMMatrix:ta,DOMRect:ra,DOMPoint:na}=window,sa={Canvas:zi,loadImage:Zi,CanvasRenderingContext2D:ji,CanvasGradient:qi,CanvasPattern:$i,Image:ps,ImageData:Aa,Path2D:ea,DOMMatrix:ta,DOMRect:ra,DOMPoint:na},Ke=(r,A,e={},t=e)=>{if(Array.isArray(A))A.forEach(n=>Ke(r,n,e,t));else if(typeof A=="function")A(r,e,t,Ke);else{const n=Object.keys(A)[0];Array.isArray(A[n])?(t[n]={},Ke(r,A[n],e,t[n])):t[n]=A[n](r,e,t,Ke)}return e},le=(r,A)=>(e,t,n,s)=>{A(e,t,n)&&s(e,r,t,n)},ia=(r,A)=>(e,t,n,s)=>{const i=[];let a=e.pos;for(;A(e,t,n);){const B={};if(s(e,r,t,B),e.pos===a)break;a=e.pos,i.push(B)}return i},aa=r=>({data:r,pos:0}),HA=()=>r=>r.data[r.pos++],Es=(r=0)=>A=>A.data[A.pos+r],DA=r=>A=>A.data.subarray(A.pos,A.pos+=r),Gt=r=>A=>A.data.subarray(A.pos,A.pos+r),Er=r=>A=>Array.from(DA(r)(A)).map(e=>String.fromCharCode(e)).join(""),se=r=>A=>{const e=DA(2)(A);return r?(e[1]<<8)+e[0]:(e[0]<<8)+e[1]},vs=(r,A)=>(e,t,n)=>{const s=typeof A=="function"?A(e,t,n):A,i=DA(r),a=new Array(s);for(var B=0;B{for(var t=0,n=0;n{const A=new Uint8Array(r);return Ke(aa(A),fa)},Ca=r=>{const A=r.pixels.length,e=new Uint8ClampedArray(A*4);for(var t=0;t{if(!r.image){console.warn("gif frame does not have associated image.");return}const{image:t}=r,n=t.descriptor.width*t.descriptor.height;var s=Qa(t.data.minCodeSize,t.data.blocks,n);t.descriptor.lct.interlaced&&(s=wa(s,t.descriptor.width));const i={pixels:s,dims:{top:r.image.descriptor.top,left:r.image.descriptor.left,width:r.image.descriptor.width,height:r.image.descriptor.height}};return t.descriptor.lct&&t.descriptor.lct.exists?i.colorTable=t.lct:i.colorTable=A,r.gce&&(i.delay=(r.gce.delay||10)*10,i.disposalType=r.gce.extras.disposal,r.gce.extras.transparentColorGiven&&(i.transparentIndex=r.gce.transparentColorIndex)),e&&(i.patch=Ca(i)),i},Fa=(r,A)=>r.frames.filter(e=>e.image).map(e=>Ua(e,r.gct,A));function da(r,A,e){const t=Hs(A),n=r-1;let s=0;switch(e){case wA.L:s=xA[n][0];break;case wA.M:s=xA[n][1];break;case wA.Q:s=xA[n][2];break;case wA.H:s=xA[n][3];break}return t<=s}function pa(r,A){for(var e=1,t=Hs(r),n=0,s=xA.length;nxA.length)throw new Error("Too long data");return e}function Hs(r){var A=encodeURI(r).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return A.length+(A.length!=Number(r)?3:0)}class Ea{constructor(A){this.mode=UA.MODE_8BIT_BYTE,this.parsedData=[],this.data=A;const e=[];for(let t=0,n=this.data.length;t>16,(r&65280)>>8,r&255,A)};X.prototype.findClosestRGB=function(r,A,e,t){if(this.colorTab===null)return-1;if(this.neuQuant&&!t)return this.neuQuant.lookupRGB(r,A,e);for(var n=0,s=256*256*256,i=this.colorTab.length,a=0,B=0;a=0&&(A=this.dispose&7),A<<=2,this.out.writeByte(0|A|0|r),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)};X.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)};X.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)};X.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)};X.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var r=3*256-this.colorTab.length,A=0;A>>8^t[(e^A[n])&255];return this.crc=e,this}}Ot.prototype.table=(()=>{var r,A,e,t=[];for(r=0;r<256;r++){for(e=r,A=0;A<8;A++)e=e&1?e>>>1^3988292384:e>>>1;t[r]=e}return t})();function qt(r){let A=new Uint8Array(r),e=new DataView(A.buffer),t={array:A,view:e,size:r,set8(n,s){return e.setUint8(n,s),t},set16(n,s){return e.setUint16(n,s,!0),t},set32(n,s){return e.setUint32(n,s,!0),t},bytes(n,s){return A.set(s,n),t}};return t}class Rt{constructor(A){let e=new Date;Object.assign(this,{directory:A,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(A)}async add(A,e){let t=!e,n=Rt.encoder.encode("".concat(this.directory,"/").concat(t?"":A)),s=new Uint8Array(t?0:await e.arrayBuffer()),i=30+n.length,a=i+s.length,B=16,{offset:o}=this,l=qt(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Ot.for(s)).set32(14,s.length).set32(18,s.length).set16(22,n.length);o+=i;let c=qt(i+s.length+B).set32(0,67324752).bytes(4,l.array).bytes(30,n).bytes(i,s);o+=s.length,c.set32(a,134695760).bytes(a+4,l.array.slice(10,22)),o+=B,this.files.push({offset:o,folder:t,name:n,header:l,payload:c}),this.offset=o}toBuffer(){let A=this.files.reduce((c,{name:g})=>46+g.length+c,0),e=qt(A+22),t=0;for(var{offset:n,name:s,header:i,folder:a}of this.files)e.set32(t,33639248).set16(t+4,20).bytes(t+6,i.array).set8(t+38,a?16:0).set32(t+42,n).bytes(t+46,s),t+=46+s.length;e.set32(t,101010256).set16(t+8,this.files.length).set16(t+10,this.files.length).set32(t+12,A).set32(t+16,this.offset);let B=new Uint8Array(this.offset+e.size),o=0;for(var{payload:l}of this.files)B.set(l.array,o),o+=l.size;return B.set(e.array,o),B}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}}Rt.encoder=new TextEncoder;const Wr=(r,A,e,t)=>{if(t){let{width:n,height:s}=r,i=Object.assign(document.createElement("canvas"),{width:n,height:s}),a=i.getContext("2d");a.fillStyle=t,a.fillRect(0,0,n,s),a.drawImage(r,0,0),r=i}return new Promise((n,s)=>r.toBlob(n,A,e))},Pi=(...r)=>Wr(...r).then(A=>A.arrayBuffer()),ki=async(r,A,e,t,n)=>{ds(n,await Wr(r,A,e,t))},_i=async(r,A,e,t,n,s,i)=>{let a=l=>s.replace("{}",String(l+1).padStart(i,"0")),B=Fs(n,".zip")||"archive",o=new Rt(B);await Promise.all(r.map(async(l,c)=>{let g=a(c);await o.add(g,await Wr(l,A,e,t))})),ds("".concat(B,".zip"),o.blob)},ds=(r,A)=>{const e=window.URL.createObjectURL(A),t=document.createElement("a");t.style.display="none",t.href=e,t.setAttribute("download",r),typeof t.download>"u"&&t.setAttribute("target","_blank"),document.body.appendChild(t),t.click(),document.body.removeChild(t),setTimeout(()=>window.URL.revokeObjectURL(e),100)},Xi=(r,A,e)=>r.map(t=>{if(A==1&&!e)return t.canvas;let n=document.createElement("canvas"),s=n.getContext("2d"),i=t.canvas?t.canvas:t;return n.width=i.width*A,n.height=i.height*A,e&&(s.fillStyle=e,s.fillRect(0,0,n.width,n.height)),s.scale(A,A),s.drawImage(i,0,0),n}),Ji={asBuffer:Pi,asDownload:ki,asZipDownload:_i,atScale:Xi,options:Vi},{asBuffer:$t,asDownload:Yi,asZipDownload:Wi,atScale:Ar,options:er}=Ji,cn=Symbol.for("toDataURL"),Zi=r=>new Promise((A,e)=>Object.assign(new ps,{crossOrigin:"Anonymous",onload:A,onerror:e,src:r}));let zi=class{constructor(A,e){let t=document.createElement("canvas"),n=[];Object.defineProperty(t,"async",{value:!0,writable:!1,enumerable:!0});for(var[s,i]of Object.entries({png:()=>$t(t,"image/png"),jpg:()=>$t(t,"image/jpeg"),pages:()=>n.concat(t).map(a=>a.getContext("2d"))}))Object.defineProperty(t,s,{get:i});return Object.assign(t,{width:A,height:e,newPage(...a){var{width:o,height:l}=t,B=Object.assign(document.createElement("canvas"),{width:o,height:l});B.getContext("2d").drawImage(t,0,0),n.push(B);var[o,l]=a.length?a:[o,l];return Object.assign(t,{width:o,height:l}).getContext("2d")},saveAs(a,B){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{filename:a,...B}),{pattern:l,padding:c,mime:g,quality:C,matte:Q,density:F,archive:L}=o,f=Ar(o.pages,F);return c==null?Yi(f[0],g,C,Q,a):Wi(f,g,C,Q,L,l,c)},toBuffer(a="png",B={}){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{extension:a,...B}),{mime:l,quality:c,matte:g,pages:C,density:Q}=o,F=Ar(C,Q,g)[0];return $t(F,l,c,g)},[cn]:t.toDataURL.bind(t),toDataURL(a="png",B={}){B=typeof B=="number"?{quality:B}:B;let o=er(this.pages,{extension:a,...B}),{mime:l,quality:c,matte:g,pages:C,density:Q}=o,F=Ar(C,Q,g)[0],L=F[F===t?cn:"toDataURL"](l,c);return Promise.resolve(L)}})}};const{CanvasRenderingContext2D:ji,CanvasGradient:qi,CanvasPattern:$i,Image:ps,ImageData:Aa,Path2D:ea,DOMMatrix:ta,DOMRect:ra,DOMPoint:na}=window,sa={Canvas:zi,loadImage:Zi,CanvasRenderingContext2D:ji,CanvasGradient:qi,CanvasPattern:$i,Image:ps,ImageData:Aa,Path2D:ea,DOMMatrix:ta,DOMRect:ra,DOMPoint:na},Ke=(r,A,e={},t=e)=>{if(Array.isArray(A))A.forEach(n=>Ke(r,n,e,t));else if(typeof A=="function")A(r,e,t,Ke);else{const n=Object.keys(A)[0];Array.isArray(A[n])?(t[n]={},Ke(r,A[n],e,t[n])):t[n]=A[n](r,e,t,Ke)}return e},le=(r,A)=>(e,t,n,s)=>{A(e,t,n)&&s(e,r,t,n)},ia=(r,A)=>(e,t,n,s)=>{const i=[];let a=e.pos;for(;A(e,t,n);){const B={};if(s(e,r,t,B),e.pos===a)break;a=e.pos,i.push(B)}return i},aa=r=>({data:r,pos:0}),HA=()=>r=>r.data[r.pos++],Es=(r=0)=>A=>A.data[A.pos+r],DA=r=>A=>A.data.subarray(A.pos,A.pos+=r),Gt=r=>A=>A.data.subarray(A.pos,A.pos+r),Er=r=>A=>Array.from(DA(r)(A)).map(e=>String.fromCharCode(e)).join(""),se=r=>A=>{const e=DA(2)(A);return r?(e[1]<<8)+e[0]:(e[0]<<8)+e[1]},vs=(r,A)=>(e,t,n)=>{const s=typeof A=="function"?A(e,t,n):A,i=DA(r),a=new Array(s);for(var B=0;B{for(var t=0,n=0;n{const A=new Uint8Array(r);return Ke(aa(A),fa)},Ca=r=>{const A=r.pixels.length,e=new Uint8ClampedArray(A*4);for(var t=0;t{if(!r.image){console.warn("gif frame does not have associated image.");return}const{image:t}=r,n=t.descriptor.width*t.descriptor.height;var s=Qa(t.data.minCodeSize,t.data.blocks,n);t.descriptor.lct.interlaced&&(s=wa(s,t.descriptor.width));const i={pixels:s,dims:{top:r.image.descriptor.top,left:r.image.descriptor.left,width:r.image.descriptor.width,height:r.image.descriptor.height}};return t.descriptor.lct&&t.descriptor.lct.exists?i.colorTable=t.lct:i.colorTable=A,r.gce&&(i.delay=(r.gce.delay||10)*10,i.disposalType=r.gce.extras.disposal,r.gce.extras.transparentColorGiven&&(i.transparentIndex=r.gce.transparentColorIndex)),e&&(i.patch=Ca(i)),i},Fa=(r,A)=>r.frames.filter(e=>e.image).map(e=>Ua(e,r.gct,A));function da(r,A,e){const t=Hs(A),n=r-1;let s=0;switch(e){case wA.L:s=xA[n][0];break;case wA.M:s=xA[n][1];break;case wA.Q:s=xA[n][2];break;case wA.H:s=xA[n][3];break}return t<=s}function pa(r,A){for(var e=1,t=Hs(r),n=0,s=xA.length;nxA.length)throw new Error("Too long data");return e}function Hs(r){var A=encodeURI(r).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return A.length+(A.length!=Number(r)?3:0)}class Ea{constructor(A){this.mode=UA.MODE_8BIT_BYTE,this.parsedData=[],this.data=A;const e=[];for(let t=0,n=this.data.length;t>16,(r&65280)>>8,r&255,A)};X.prototype.findClosestRGB=function(r,A,e,t){if(this.colorTab===null)return-1;if(this.neuQuant&&!t)return this.neuQuant.lookupRGB(r,A,e);for(var n=0,s=256*256*256,i=this.colorTab.length,a=0,B=0;a=0&&(A=this.dispose&7),A<<=2,this.out.writeByte(0|A|0|r),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)};X.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)};X.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)};X.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)};X.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var r=3*256-this.colorTab.length,A=0;A=55296&&n<=56319&&e>Be)],e=(e< >qr),e=this.index[e],e+=A>>Be&$a,e=this.index[e],e=(e< "u"?[]:new Uint8Array(256);for(var rt=0;rt