var e;!function(e){e[e.Silent=0]="Silent",e[e.Debug=1]="Debug",e[e.Verbose=2]="Verbose"}(e||(e={}));let t=e.Silent;function n(...e){t>=1&&console.log(...e)}function i(...e){t>=2&&console.log(...e)}function a(e){t=e}function r(e){return new Promise(((t,n)=>{let i=new FileReader;i.onload=()=>{t(i.result)},i.onerror=()=>{n(i.error)},i.readAsArrayBuffer(e)}))}async function s(e,t,n,i,a){let r=(new Date).getTime(),s=!1;e(t,n,0);let o=(async()=>{let a,o=r+i;do{a=(new Date).getTime(),e(t,n,(a-r)/i),await new Promise(((e,t)=>{window.requestAnimationFrame(e)}))}while(!s&&ae.blocks)).reduce(((e,t)=>e+t),0)}function p(e){return 28+12*e.length+function(e){return e.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t),0)}(e)}function m(e,t){let n=new ArrayBuffer(p(t)),i=new DataView(n),a=new Uint8Array(n);i.setUint32(0,3978755898,!0),i.setUint16(4,1,!0),i.setUint16(6,0,!0),i.setUint16(8,28,!0),i.setUint16(10,12,!0),i.setUint32(12,e.blockSize,!0),i.setUint32(16,e.blocks,!0),i.setUint32(20,t.length,!0),i.setUint32(24,0,!0);let r=28;for(let e of t){i.setUint16(r,e.type,!0),i.setUint16(r+2,0,!0),i.setUint32(r+4,e.blocks,!0),i.setUint32(r+8,12+e.data.byteLength,!0),r+=12;let t=new Uint8Array(e.data);a.set(t,r),r+=e.data.byteLength}return n}!function(e){e[e.Raw=51905]="Raw",e[e.Fill=51906]="Fill",e[e.Skip=51907]="Skip",e[e.Crc32=51908]="Crc32"}(d||(d={}));function _(e){return e.map((([e,t])=>new Array(e).fill(t,0,e))).flat()}const h=[0,1,2,3].concat(..._([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function x(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.build_tree=function(n){const i=e.dyn_tree,a=e.stat_desc.static_tree,r=e.stat_desc.elems;let s,o,l,d=-1;for(n.heap_len=0,n.heap_max=573,s=0;s=1;s--)n.pqdownheap(i,s);l=r;do{s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),o=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=o,i[2*l]=i[2*s]+i[2*o],n.depth[l]=Math.max(n.depth[s],n.depth[o])+1,i[2*s+1]=i[2*o+1]=l,n.heap[1]=l++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(t){const n=e.dyn_tree,i=e.stat_desc.static_tree,a=e.stat_desc.extra_bits,r=e.stat_desc.extra_base,s=e.stat_desc.max_length;let o,l,d,c,f,u,p=0;for(c=0;c<=15;c++)t.bl_count[c]=0;for(n[2*t.heap[t.heap_max]+1]=0,o=t.heap_max+1;o<573;o++)l=t.heap[o],c=n[2*n[2*l+1]+1]+1,c>s&&(c=s,p++),n[2*l+1]=c,l>e.max_code||(t.bl_count[c]++,f=0,l>=r&&(f=a[l-r]),u=n[2*l],t.opt_len+=u*(c+f),i&&(t.static_len+=u*(i[2*l+1]+f)));if(0!==p){do{for(c=s-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[s]--,p-=2}while(p>0);for(c=s;0!==c;c--)for(l=t.bl_count[c];0!==l;)d=t.heap[--o],d>e.max_code||(n[2*d+1]!=c&&(t.opt_len+=(c-n[2*d+1])*n[2*d],n[2*d+1]=c),l--)}}(n),function(e,n,i){const a=[];let r,s,o,l=0;for(r=1;r<=15;r++)a[r]=l=l+i[r-1]<<1;for(s=0;s<=n;s++)o=e[2*s+1],0!==o&&(e[2*s]=t(a[o]++,o))}(i,e.max_code,n.bl_count)}}function w(e,t,n,i,a){const r=this;r.static_tree=e,r.extra_bits=t,r.extra_base=n,r.elems=i,r.max_length=a}x._length_code=[0,1,2,3,4,5,6,7].concat(..._([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),x.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],x.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],x.d_code=function(e){return e<256?h[e]:h[256+(e>>>7)]},x.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],x.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],x.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],x.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],w.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],w.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],w.static_l_desc=new w(w.static_ltree,x.extra_lbits,257,286,15),w.static_d_desc=new w(w.static_dtree,x.extra_dbits,0,30,15),w.static_bl_desc=new w(null,x.extra_blbits,0,19,7);function b(e,t,n,i,a){const r=this;r.good_length=e,r.max_lazy=t,r.nice_length=n,r.max_chain=i,r.func=a}const v=[new b(0,0,0,0,0),new b(4,4,8,4,1),new b(4,5,16,8,1),new b(4,6,32,32,1),new b(4,4,16,16,2),new b(8,16,32,32,2),new b(8,16,128,128,2),new b(8,32,128,256,2),new b(32,128,258,1024,2),new b(32,258,258,4096,2)],g=["need dictionary","stream end","","","stream error","data error","","buffer error","",""];function y(e,t,n,i){const a=e[2*t],r=e[2*n];return a>>8&255)}function ee(e,t){let n;const i=t;N>16-i?(n=e,Z|=n<>>16-N,N+=i-16):(Z|=e<=8&&(Q(255&Z),Z>>>=8,N-=8)}function ae(t,n){let i,a,r;if(e.pending_buf[H+2*P]=t>>>8&255,e.pending_buf[H+2*P+1]=255&t,e.pending_buf[O+P]=255&n,P++,0===t?L[2*n]++:(K++,t--,L[2*(x._length_code[n]+256+1)]++,D[2*x.d_code(t)]++),0==(8191&P)&&F>2){for(i=8*P,a=A-b,r=0;r<30;r++)i+=D[2*r]*(5+x.extra_dbits[r]);if(i>>>=3,K8?X(Z):N>0&&Q(255&Z),Z=0,N=0}function oe(t,n,i){ee(0+(i?1:0),3),function(t,n,i){se(),G=8,i&&(X(n),X(~n)),e.pending_buf.set(l.subarray(t,t+n),e.pending),e.pending+=n}(t,n,!0)}function le(t,n,i){let a,r,s=0;F>0?(R.build_tree(e),V.build_tree(e),s=function(){let t;for(J(L,R.max_code),J(D,V.max_code),W.build_tree(e),t=18;t>=3&&0===M[2*x.bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(),a=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=a&&(a=r)):a=r=n+5,n+4<=a&&-1!=t?oe(t,n,i):r==a?(ee(2+(i?1:0),3),re(w.static_ltree,w.static_dtree)):(ee(4+(i?1:0),3),function(e,t,n){let i;for(ee(e-257,5),ee(t-1,5),ee(n-4,4),i=0;i=0?b:-1,A-b,e),b=A,t.flush_pending()}function ce(){let e,n,i,a;do{if(a=d-j-A,0===a&&0===A&&0===j)a=r;else if(-1==a)a--;else if(A>=r+r-262){l.set(l.subarray(r,r+r),0),S-=r,A-=r,b-=r,e=p,i=e;do{n=65535&f[--i],f[i]=n>=r?n-r:0}while(0!=--e);e=r,i=e;do{n=65535&c[--i],c[i]=n>=r?n-r:0}while(0!=--e);a+=r}if(0===t.avail_in)return;e=t.read_buf(l,A+j,a),j+=e,j>=3&&(u=255&l[A],u=(u<r-262?A-(r-262):0;let f=q;const u=o,p=A+258;let m=l[a+s-1],_=l[a+s];E>=B&&(i>>=2),f>j&&(f=j);do{if(t=e,l[t+s]==_&&l[t+s-1]==m&&l[t]==l[a]&&l[++t]==l[a+1]){a+=2,t++;do{}while(l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&as){if(S=e,s=n,n>=f)break;m=l[a+s-1],_=l[a+s]}}}while((e=65535&c[e&u])>d&&0!=--i);return s<=j?s:j}function ue(t){return t.total_in=t.total_out=0,t.msg=null,e.pending=0,e.pending_out=0,n=113,a=0,R.dyn_tree=L,R.stat_desc=w.static_l_desc,V.dyn_tree=D,V.stat_desc=w.static_d_desc,W.dyn_tree=M,W.stat_desc=w.static_bl_desc,Z=0,N=0,G=8,Y(),function(){d=2*r,f[p-1]=0;for(let e=0;e9||8!=d||a<9||a>15||n<0||n>9||x<0||x>2?-2:(t.dstate=e,s=a,r=1<9||n<0||n>2?-2:(v[F].func!=v[t].func&&0!==e.total_in&&(i=e.deflate(1)),F!=t&&(F=t,I=v[F].max_lazy,B=v[F].good_length,q=v[F].nice_length,C=v[F].max_chain),$=n,i)},e.deflateSetDictionary=function(e,t,i){let a,s=i,d=0;if(!t||42!=n)return-2;if(s<3)return 0;for(s>r-262&&(s=r-262,d=i-s),l.set(t.subarray(d,d+s),0),A=s,b=s,u=255&l[0],u=(u<4||m<0)return-2;if(!d.next_out||!d.next_in&&0!==d.avail_in||666==n&&4!=m)return d.msg=g[4],-2;if(0===d.avail_out)return d.msg=g[7],-5;var L;if(t=d,B=a,a=m,42==n&&(y=8+(s-8<<4)<<8,C=(F-1&255)>>1,C>3&&(C=3),y|=C<<6,0!==A&&(y|=32),y+=31-y%31,n=113,Q((L=y)>>8&255),Q(255&L)),0!==e.pending){if(t.flush_pending(),0===t.avail_out)return a=-1,0}else if(0===t.avail_in&&m<=B&&4!=m)return t.msg=g[7],-5;if(666==n&&0!==t.avail_in)return d.msg=g[7],-5;if(0!==t.avail_in||0!==j||0!=m&&666!=n){switch(q=-1,v[F].func){case 0:q=function(e){let n,a=65535;for(a>i-5&&(a=i-5);;){if(j<=1){if(ce(),0===j&&0==e)return 0;if(0===j)break}if(A+=j,j=0,n=b+a,(0===A||A>=n)&&(j=A-n,A=n,de(!1),0===t.avail_out))return 0;if(A-b>=r-262&&(de(!1),0===t.avail_out))return 0}return de(4==e),0===t.avail_out?4==e?2:0:4==e?3:1}(m);break;case 1:q=function(e){let n,i=0;for(;;){if(j<262){if(ce(),j<262&&0==e)return 0;if(0===j)break}if(j>=3&&(u=(u<=3)if(n=ae(A-S,k-3),j-=k,k<=I&&j>=3){k--;do{A++,u=(u<=3&&(u=(u<4096)&&(k=2)),E>=3&&k<=E){i=A+j-3,n=ae(A-1-z,E-3),j-=E-1,E-=2;do{++A<=i&&(u=(u<n&&(a=n),0===a?0:(i.avail_in-=a,e.set(i.next_in.subarray(i.next_in_index,i.next_in_index+a),t),i.next_in_index+=a,i.total_in+=a,a)},flush_pending:function(){const e=this;let t=e.dstate.pending;t>e.avail_out&&(t=e.avail_out),0!==t&&(e.next_out.set(e.dstate.pending_buf.subarray(e.dstate.pending_out,e.dstate.pending_out+t),e.next_out_index),e.next_out_index+=t,e.dstate.pending_out+=t,e.total_out+=t,e.avail_out-=t,e.dstate.pending-=t,0===e.dstate.pending&&(e.dstate.pending_out=0))}};const U=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],A=[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],S=[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],j=[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],E=[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],C=[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],I=[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];function F(){let e,t,n,i,a,r;function s(e,t,s,o,l,d,c,f,u,p,m){let _,h,x,w,b,v,g,y,k,z,U,A,S,j,E;z=0,b=s;do{n[e[t+z]]++,z++,b--}while(0!==b);if(n[0]==s)return c[0]=-1,f[0]=0,0;for(y=f[0],v=1;v<=15&&0===n[v];v++);for(g=v,yb&&(y=b),f[0]=y,j=1<A+y;){if(w++,A+=y,E=x-A,E=E>y?y:E,(h=1<<(v=g-A))>_+1&&(h-=_+1,S=g,v1440)return-3;a[w]=U=p[0],p[0]+=E,0!==w?(r[w]=b,i[0]=v,i[1]=y,v=b>>>A-y,i[2]=U-a[w-1]-v,u.set(i,3*(a[w-1]+v))):c[0]=U}for(i[1]=g-A,z>=s?i[0]=192:m[z]>>A;v>>=1)b^=v;for(b^=v,k=(1<257?(-3==p?u.msg="oversubscribed distance tree":-5==p?(u.msg="incomplete distance tree",p=-3):-4!=p&&(u.msg="empty distance tree with lengths",p=-3),p):0)}}F.inflate_trees_fixed=function(e,t,n,i){return e[0]=9,t[0]=5,n[0]=A,i[0]=S,0};function $(){const e=this;let t,n,i,a,r=0,s=0,o=0,l=0,d=0,c=0,f=0,u=0,p=0,m=0;function _(e,t,n,i,a,r,s,o){let l,d,c,f,u,p,m,_,h,x,w,b,v,g,y,k;m=o.next_in_index,_=o.avail_in,u=s.bitb,p=s.bitk,h=s.write,x=h>=d[k+1],p-=d[k+1],0!=(16&f)){for(f&=15,v=d[k+2]+(u&U[f]),u>>=f,p-=f;p<15;)_--,u|=(255&o.read_byte(m++))<>=d[k+1],p-=d[k+1],0!=(16&f)){for(f&=15;p>=f,p-=f,x-=v,h>=g)y=h-g,h-y>0&&2>h-y?(s.window[h++]=s.window[y++],s.window[h++]=s.window[y++],v-=2):(s.window.set(s.window.subarray(y,y+2),h),h+=2,y+=2,v-=2);else{y=h-g;do{y+=s.end}while(y<0);if(f=s.end-y,v>f){if(v-=f,h-y>0&&f>h-y)do{s.window[h++]=s.window[y++]}while(0!=--f);else s.window.set(s.window.subarray(y,y+f),h),h+=f,y+=f,f=0;y=0}}if(h-y>0&&v>h-y)do{s.window[h++]=s.window[y++]}while(0!=--v);else s.window.set(s.window.subarray(y,y+v),h),h+=v,y+=v,v=0;break}if(0!=(64&f))return o.msg="invalid distance code",v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,-3;l+=d[k+2],l+=u&U[f],k=3*(c+l),f=d[k]}break}if(0!=(64&f))return 0!=(32&f)?(v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,1):(o.msg="invalid literal/length code",v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,-3);if(l+=d[k+2],l+=u&U[f],k=3*(c+l),0===(f=d[k])){u>>=d[k+1],p-=d[k+1],s.window[h++]=d[k+2],x--;break}}else u>>=d[k+1],p-=d[k+1],s.window[h++]=d[k+2],x--}while(x>=258&&_>=10);return v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,0}e.init=function(e,r,s,o,l,d){t=0,f=e,u=r,i=s,p=o,a=l,m=d,n=null},e.proc=function(e,h,x){let w,b,v,g,y,k,z,A=0,S=0,j=0;for(j=h.next_in_index,g=h.avail_in,A=e.bitb,S=e.bitk,y=e.write,k=y=258&&g>=10&&(e.bitb=A,e.bitk=S,h.avail_in=g,h.total_in+=j-h.next_in_index,h.next_in_index=j,e.write=y,x=_(f,u,i,p,a,m,e,h),j=h.next_in_index,g=h.avail_in,A=e.bitb,S=e.bitk,y=e.write,k=y>>=n[b+1],S-=n[b+1],v=n[b],0===v){l=n[b+2],t=6;break}if(0!=(16&v)){d=15&v,r=n[b+2],t=2;break}if(0==(64&v)){o=v,s=b/3+n[b+2];break}if(0!=(32&v)){t=7;break}return t=9,h.msg="invalid literal/length code",x=-3,e.bitb=A,e.bitk=S,h.avail_in=g,h.total_in+=j-h.next_in_index,h.next_in_index=j,e.write=y,e.inflate_flush(h,x);case 2:for(w=d;S>=w,S-=w,o=u,n=a,s=m,t=3;case 3:for(w=o;S>=n[b+1],S-=n[b+1],v=n[b],0!=(16&v)){d=15&v,c=n[b+2],t=4;break}if(0==(64&v)){o=v,s=b/3+n[b+2];break}return t=9,h.msg="invalid distance code",x=-3,e.bitb=A,e.bitk=S,h.avail_in=g,h.total_in+=j-h.next_in_index,h.next_in_index=j,e.write=y,e.inflate_flush(h,x);case 4:for(w=d;S>=w,S-=w,t=5;case 5:for(z=y-c;z<0;)z+=e.end;for(;0!==r;){if(0===k&&(y==e.end&&0!==e.read&&(y=0,k=y7&&(S-=8,g++,j--),e.write=y,x=e.inflate_flush(h,x),y=e.write,k=ye.avail_out&&(i=e.avail_out),0!==i&&-5==t&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.window.subarray(r,r+i),a),a+=i,r+=i,r==n.end&&(r=0,n.write==n.end&&(n.write=0),i=n.write-r,i>e.avail_out&&(i=e.avail_out),0!==i&&-5==t&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.window.subarray(r,r+i),a),a+=i,r+=i),e.next_out_index=a,n.read=r,t},n.proc=function(e,t){let m,_,h,x,w,b,v,g;for(x=e.next_in_index,w=e.avail_in,_=n.bitb,h=n.bitk,b=n.write,v=b>>1){case 0:_>>>=3,h-=3,m=7&h,_>>>=m,h-=m,a=1;break;case 1:y=[],k=[],z=[[]],A=[[]],F.inflate_trees_fixed(y,k,z,A),c.init(y[0],k[0],z[0],0,A[0],0),_>>>=3,h-=3,a=6;break;case 2:_>>>=3,h-=3,a=3;break;case 3:return _>>>=3,h-=3,a=9,e.msg="invalid block type",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t)}break;case 1:for(;h<32;){if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);t=0,w--,_|=(255&e.read_byte(x++))<>>16&65535)!=(65535&_))return a=9,e.msg="invalid stored block lengths",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);r=65535&_,_=h=0,a=0!==r?2:0!==f?7:0;break;case 2:if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);if(0===v&&(b==n.end&&0!==n.read&&(b=0,v=bw&&(m=w),m>v&&(m=v),n.window.set(e.read_buf(x,m),b),x+=m,w-=m,b+=m,v-=m,0!=(r-=m))break;a=0!==f?7:0;break;case 3:for(;h<14;){if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);t=0,w--,_|=(255&e.read_byte(x++))<29||(m>>5&31)>29)return a=9,e.msg="too many length or distance symbols",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);if(m=258+(31&m)+(m>>5&31),!i||i.length>>=14,h-=14,o=0,a=4;case 4:for(;o<4+(s>>>10);){for(;h<3;){if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);t=0,w--,_|=(255&e.read_byte(x++))<>>=3,h-=3}for(;o<19;)i[B[o++]]=0;if(l[0]=7,m=p.inflate_trees_bits(i,l,d,u,e),0!=m)return-3==(t=m)&&(i=null,a=9),n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);o=0,a=5;case 5:for(;m=s,!(o>=258+(31&m)+(m>>5&31));){let r,c;for(m=l[0];h>>=m,h-=m,i[o++]=c;else{for(g=18==c?7:c-14,r=18==c?11:3;h>>=m,h-=m,r+=_&U[g],_>>>=g,h-=g,g=o,m=s,g+r>258+(31&m)+(m>>5&31)||16==c&&g<1)return i=null,a=9,e.msg="invalid bit length repeat",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);c=16==c?i[g-1]:0;do{i[g++]=c}while(0!=--r);o=g}}if(d[0]=-1,S=[],j=[],E=[],C=[],S[0]=9,j[0]=6,m=s,m=p.inflate_trees_dynamic(257+(31&m),1+(m>>5&31),i,S,j,E,C,u,e),0!=m)return-3==m&&(i=null,a=9),t=m,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);c.init(S[0],j[0],u,E[0],u,C[0]),a=6;case 6:if(n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,1!=(t=c.proc(n,e,t)))return n.inflate_flush(e,t);if(t=0,c.free(e),x=e.next_in_index,w=e.avail_in,_=n.bitb,h=n.bitk,b=n.write,v=b15?(e.inflateEnd(n),-2):(e.wbits=i,n.istate.blocks=new q(n,1<>4)>a.wbits){a.mode=13,e.msg="invalid window size",a.marker=5;break}a.mode=1;case 1:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,i=255&e.read_byte(e.next_in_index++),((a.method<<8)+i)%31!=0){a.mode=13,e.msg="incorrect header check",a.marker=5;break}if(0==(32&i)){a.mode=7;break}a.mode=2;case 2:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,a.need=(255&e.read_byte(e.next_in_index++))<<24&4278190080,a.mode=3;case 3:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,a.need+=(255&e.read_byte(e.next_in_index++))<<16&16711680,a.mode=4;case 4:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,a.need+=(255&e.read_byte(e.next_in_index++))<<8&65280,a.mode=5;case 5:return 0===e.avail_in?n:(n=t,e.avail_in--,e.total_in++,a.need+=255&e.read_byte(e.next_in_index++),a.mode=6,2);case 6:return a.mode=13,e.msg="need dictionary",a.marker=0,-2;case 7:if(n=a.blocks.proc(e,n),-3==n){a.mode=13,a.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,a.blocks.reset(e,a.was),a.mode=12;case 12:return 1;case 13:return-3;default:return-2}},e.inflateSetDictionary=function(e,t,n){let i=0,a=n;if(!e||!e.istate||6!=e.istate.mode)return-2;const r=e.istate;return a>=1<{const e={};for(let t in O)if(O.hasOwnProperty(t))for(let n in O[t])if(O[t].hasOwnProperty(n)){const i=O[t][n];if("string"==typeof i)e[i]=t+"/"+n;else for(let a=0;a{e.onload=e=>t(e.target.result),e.onerror=n,e.readAsText(this.blob,this.encoding)}))}}class G extends P{constructor(e){super(),this.blob=e,this.size=e.size}async readUint8Array(e,t){const n=new FileReader;return new Promise(((i,a)=>{n.onload=e=>i(new Uint8Array(e.target.result)),n.onerror=a,n.readAsArrayBuffer(this.blob.slice(e,e+t))}))}}class Z extends H{constructor(e){super(),this.offset=0,this.contentType=e,this.blob=new Blob([],{type:e})}async writeUint8Array(e){super.writeUint8Array(e),this.blob=new Blob([this.blob,e.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}}const N="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");const Y=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)1&t?t=t>>>1^3988292384:t>>>=1;Y[e]=t}class J{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,i=0|e.length;n>>8^Y[255&(t^e[n])];this.crc=t}get(){return~this.crc}}const Q={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],i=Q.getPartial(n);return 32===i?e.concat(t):Q._shiftRight(t,i,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+Q.getPartial(n)},clamp(e,t){if(32*e.length0&&t&&(e[n-1]=Q.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>Math.round(e/1099511627776)||32,_shiftRight(e,t,n,i){for(void 0===i&&(i=[]);t>=32;t-=32)i.push(n),n=0;if(0===t)return i.concat(e);for(let a=0;a>>t),n=e[a]<<32-t;const a=e.length?e[e.length-1]:0,r=Q.getPartial(a);return i.push(Q.partial(t+r&31,t+r>32?n:i.pop(),1)),i}},X={bytes:{fromBits(e){const t=Q.bitLength(e)/8,n=new Uint8Array(t);let i;for(let a=0;a>>24,i<<=8;return n},toBits(e){const t=[];let n,i=0;for(n=0;n9007199254740991)throw new Error("Cannot hash more than 2^53 - 1 bits");const r=new Uint32Array(n);let s=0;for(let e=t.blockSize+i-(t.blockSize+i&t.blockSize-1);e<=a;e+=t.blockSize)t._block(r.subarray(16*s,16*(s+1))),s+=1;return n.splice(0,16*s),t},finalize:function(){const e=this;let t=e._buffer;const n=e._h;t=Q.concat(t,[Q.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(Math.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(e,t,n,i){return e<=19?t&n|~t&i:e<=39?t^n^i:e<=59?t&n|t&i|n&i:e<=79?t^n^i:void 0},_S:function(e,t){return t<>>32-e},_block:function(e){const t=this,n=t._h,i=Array(80);for(let t=0;t<16;t++)i[t]=e[t];let a=n[0],r=n[1],s=n[2],o=n[3],l=n[4];for(let e=0;e<=79;e++){e>=16&&(i[e]=t._S(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const n=t._S(5,a)+t._f(e,r,s,o)+l+i[e]+t._key[Math.floor(e/20)]|0;l=o,o=s,s=t._S(30,r),r=a,a=n}n[0]=n[0]+a|0,n[1]=n[1]+r|0,n[2]=n[2]+s|0,n[3]=n[3]+o|0,n[4]=n[4]+l|0}};const te={aes:class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],i=t._tables[1],a=e.length;let r,s,o,l=1;if(4!==a&&6!==a&&8!==a)throw new Error("invalid aes key size");for(t._key=[s=e.slice(0),o=[]],r=a;r<4*a+28;r++){let e=s[r-1];(r%a==0||8===a&&r%a==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],r%a==0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),s[r]=s[r-a]^e}for(let e=0;r;e++,r--){const t=s[3&e?r:r-4];o[e]=r<=4||e<4?t:i[0][n[t>>>24]]^i[1][n[t>>16&255]]^i[2][n[t>>8&255]]^i[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],i=t[4],a=[],r=[];let s,o,l,d;for(let e=0;e<256;e++)r[(a[e]=e<<1^283*(e>>7))^e]=e;for(let c=s=0;!n[c];c^=o||1,s=r[s]||1){let r=s^s<<1^s<<2^s<<3^s<<4;r=r>>8^255&r^99,n[c]=r,i[r]=c,d=a[l=a[o=a[c]]];let f=16843009*d^65537*l^257*o^16843008*c,u=257*a[r]^16843008*r;for(let n=0;n<4;n++)e[n][c]=u=u<<24^u>>>8,t[n][r]=f=f<<24^f>>>8}for(let n=0;n<5;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new Error("invalid aes block size");const n=this._key[t],i=n.length/4-2,a=[0,0,0,0],r=this._tables[t],s=r[0],o=r[1],l=r[2],d=r[3],c=r[4];let f,u,p,m=e[0]^n[0],_=e[t?3:1]^n[1],h=e[2]^n[2],x=e[t?1:3]^n[3],w=4;for(let e=0;e>>24]^o[_>>16&255]^l[h>>8&255]^d[255&x]^n[w],u=s[_>>>24]^o[h>>16&255]^l[x>>8&255]^d[255&m]^n[w+1],p=s[h>>>24]^o[x>>16&255]^l[m>>8&255]^d[255&_]^n[w+2],x=s[x>>>24]^o[m>>16&255]^l[_>>8&255]^d[255&h]^n[w+3],w+=4,m=f,_=u,h=p;for(let e=0;e<4;e++)a[t?3&-e:e]=c[m>>>24]<<24^c[_>>16&255]<<16^c[h>>8&255]<<8^c[255&x]^n[w++],f=m,m=_,_=h,h=x,x=f;return a}}},ne={ctrGladman:class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,i=255&e;255===t?(t=0,255===n?(n=0,255===i?i=0:++i):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=i}else e+=1<<24;return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let i;if(!(i=t.length))return[];const a=Q.bitLength(t);for(let a=0;aa&&(e=n.hash(e));for(let t=0;te.length){const n=e;(e=new Uint8Array(t)).set(n,0)}return e}(n,s-s%16)),o=0;o<=s-16;o+=16){const a=ue.toBits(ge(t,o,o+16));r&&e.hmac.update(a);const s=e.aesCtrGladman.update(a);r||e.hmac.update(s),n.set(ue.fromBits(s),o+i)}return e.pendingInput=ge(t,o),n}async function be(e,t,n){const i=(new TextEncoder).encode(t),a=await fe.importKey("raw",i,re,!1,oe),r=await fe.deriveBits(Object.assign({salt:n},se),a,8*(2*de[e.strength]+2)),s=new Uint8Array(r);e.keys={key:ue.toBits(ge(s,0,de[e.strength])),authentication:ue.toBits(ge(s,de[e.strength],2*de[e.strength])),passwordVerification:ge(s,2*de[e.strength])}}function ve(e,t){let n=e;return e.length+t.length&&(n=new Uint8Array(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ge(e,t,n){return e.subarray(t,n)}class ye{constructor(e,t){Object.assign(this,{password:e,passwordVerification:t}),Ae(this,e)}async append(e){const t=this;if(t.password){const n=ze(t,e.subarray(0,12));if(t.password=null,n[11]!=t.passwordVerification)throw new Error("Invalid pasword");e=e.subarray(12)}return ze(t,e)}async flush(){return{valid:!0,data:new Uint8Array(0)}}}class ke{constructor(e,t){Object.assign(this,{password:e,passwordVerification:t}),Ae(this,e)}async append(e){const t=this;let n,i;if(t.password){t.password=null;const a=crypto.getRandomValues(new Uint8Array(12));a[11]=t.passwordVerification,n=new Uint8Array(e.length+a.length),n.set(Ue(t,a),0),i=12}else n=new Uint8Array(e.length),i=0;return n.set(Ue(t,e),i),n}async flush(){return{data:new Uint8Array(0)}}}function ze(e,t){const n=new Uint8Array(t.length);for(let i=0;i>>24]),e.keys[2]=~e.crcKey2.get()}function je(e){const t=2|e.keys[2];return Ee(Math.imul(t,1^t)>>>8)}function Ee(e){return 255&e}function Ce(e){return 4294967295&e}class Ie{constructor(e,{signature:t,password:n,signed:i,compressed:a,zipCrypto:r,passwordVerification:s,encryptionStrength:o},{chunkSize:l}){const d=Boolean(n);Object.assign(this,{signature:t,encrypted:d,signed:i,compressed:a,inflate:a&&new e({chunkSize:l}),crc32:i&&new J,zipCrypto:r,decrypt:d&&r?new ye(n,s):new he(n,i,o)})}async append(e){const t=this;return t.encrypted&&e.length&&(e=await t.decrypt.append(e)),t.compressed&&e.length&&(e=await t.inflate.append(e)),(!t.encrypted||t.zipCrypto)&&t.signed&&e.length&&t.crc32.append(e),e}async flush(){const e=this;let t,n=new Uint8Array(0);if(e.encrypted){const t=await e.decrypt.flush();if(!t.valid)throw new Error("Invalid signature");n=t.data}if((!e.encrypted||e.zipCrypto)&&e.signed){const n=new DataView(new Uint8Array(4).buffer);if(t=e.crc32.get(),n.setUint32(0,t),e.cipher!=n.getUint32(0,!1))throw new Error("Invalid signature")}return e.compressed&&(n=await e.inflate.append(n)||new Uint8Array(0),await e.inflate.flush()),{data:n,signature:t}}}class Fe{constructor(e,{encrypted:t,signed:n,compressed:i,level:a,zipCrypto:r,password:s,passwordVerification:o,encryptionStrength:l},{chunkSize:d}){Object.assign(this,{encrypted:t,signed:n,compressed:i,deflate:i&&new e({level:a||5,chunkSize:d}),crc32:n&&new J,zipCrypto:r,encrypt:t&&r?new ke(s,o):new xe(s,l)})}async append(e){const t=this;let n=e;return t.compressed&&e.length&&(n=await t.deflate.append(e)),t.encrypted&&n.length&&(n=await t.encrypt.append(n)),(!t.encrypted||t.zipCrypto)&&t.signed&&e.length&&t.crc32.append(e),n}async flush(){const e=this;let t,n=new Uint8Array(0);if(e.compressed&&(n=await e.deflate.flush()||new Uint8Array(0)),e.encrypted){n=await e.encrypt.append(n);const i=await e.encrypt.flush();t=i.signature;const a=new Uint8Array(n.length+i.data.length);a.set(n,0),a.set(i.data,n.length),n=a}return e.encrypted&&!e.zipCrypto||!e.signed||(t=e.crc32.get()),{data:n,signature:t}}}var $e=(e,t,n,i,a,r,s)=>(Object.assign(e,{busy:!0,codecConstructor:t,options:Object.assign({},n),scripts:s,webWorker:r,onTaskFinished(){e.busy=!1;a(e)&&e.worker&&e.worker.terminate()}}),r?function(e,t){let n;e.interface||(e.worker=new Worker(new URL(e.scripts[0],import.meta.url)),e.worker.addEventListener("message",r,!1),e.interface={append:e=>i({type:"append",data:e}),flush:()=>i({type:"flush"})});return e.interface;async function i(i){if(!n){const n=e.options,i=e.scripts.slice(1);await a({scripts:i,type:"init",options:n,config:{chunkSize:t.chunkSize}})}return a(i)}function a(t){const i=e.worker,a=new Promise(((e,t)=>n={resolve:e,reject:t}));try{if(t.data)try{t.data=t.data.buffer,i.postMessage(t,[t.data])}catch(e){i.postMessage(t)}else i.postMessage(t)}catch(t){n.reject(t),n=null,e.onTaskFinished()}return a}function r(t){const i=t.data;if(n){const t=i.error,a=i.type;if(t){const i=new Error(t.message);i.stack=t.stack,n.reject(i),n=null,e.onTaskFinished()}else if("init"==a||"flush"==a||"append"==a){const t=i.data;"flush"==a?(n.resolve({data:new Uint8Array(t),signature:i.signature}),n=null,e.onTaskFinished()):n.resolve(t&&new Uint8Array(t))}}}}(e,i):function(e,t){const n=function(e,t,n){return t.codecType.startsWith("deflate")?new Fe(e,t,n):t.codecType.startsWith("inflate")?new Ie(e,t,n):void 0}(e.codecConstructor,e.options,t);return{async append(t){try{return await n.append(t)}catch(t){throw e.onTaskFinished(),t}},async flush(){try{return await n.flush()}finally{e.onTaskFinished()}}}}(e,i));let Be=[],qe=[];function Le(e){if(e&&e.aborted)throw new Error("Abort error")}async function De(e,t){return t.length&&await e.writeUint8Array(t),t.length}const Me=["filename","rawFilename","directory","encrypted","compressedSize","uncompressedSize","lastModDate","rawLastModDate","comment","rawComment","signature","extraField","rawExtraField","bitFlag","extraFieldZip64","extraFieldUnicodePath","extraFieldUnicodeComment","extraFieldAES","filenameUTF8","commentUTF8","offset","zip64","compressionMethod"];class Re{constructor(e){Me.forEach((t=>this[t]=e[t]))}}const Ve="File format is not recognized",We=["uncompressedSize","compressedSize","offset"];class Oe{constructor(e,t={}){Object.assign(this,{reader:e,options:t,config:V})}async getEntries(e={}){const t=this,n=t.reader;if(n.initialized||await n.init(),n.size<22)throw new Error(Ve);const i=await async function(e,t,n,i,a){const r=new Uint8Array(4);!function(e,t,n){e.setUint32(t,n,!0)}(et(r),0,t);const s=i+a;return await o(i)||await o(Math.min(s,n));async function o(t){const a=n-t,s=await tt(e,a,t);for(let e=s.length-i;e>=0;e--)if(s[e]==r[0]&&s[e+1]==r[1]&&s[e+2]==r[2]&&s[e+3]==r[3])return{offset:a+e,buffer:s.slice(e,e+i).buffer}}}(n,101010256,n.size,22,1048560);if(!i)throw new Error("End of central directory not found");const a=et(i);let r=Qe(a,12),s=Qe(a,16),o=Je(a,8),l=0;if(4294967295==s||65535==o){const e=et(await tt(n,i.offset-20,20));if(117853008!=Qe(e,0))throw new Error("End of Zip64 central directory not found");s=Xe(e,8);let t=await tt(n,s,56),a=et(t);const d=i.offset-20-56;if(101075792!=Qe(a,0)&&s!=d){const e=s;s=d,l=s-e,t=await tt(n,s,56),a=et(t)}if(101075792!=Qe(a,0))throw new Error("End of Zip64 central directory locator not found");o=Xe(a,24),r=Qe(e,4),s-=Xe(a,40)}if(s<0||s>=n.size)throw new Error(Ve);let d=0,c=await tt(n,s,n.size-s),f=et(c);const u=i.offset-r;if(33639248!=Qe(f,d)&&s!=u){const e=s;s=u,l=s-e,c=await tt(n,s,n.size-s),f=et(c)}if(s<0||s>=n.size)throw new Error(Ve);const p=[];for(let i=0;ii.getData(e,t),p.push(m),d=u}return p}async close(){}}class Te{constructor(e,t,n){Object.assign(this,{reader:e,config:t,options:n})}async getData(e,t={}){const n=this,{reader:i,offset:a,extraFieldAES:r,compressionMethod:s,config:o,bitFlag:l,signature:d,rawLastModDate:c,compressedSize:f}=n,u=n.localDirectory={};i.initialized||await i.init();const p=await tt(i,a,30),m=et(p);let _=Ge(n,t,"password");if(_=_&&_.length&&_,r&&99!=r.originalCompressionMethod)throw new Error("Compression method not supported");if(0!=s&&8!=s)throw new Error("Compression method not supported");if(67324752!=Qe(m,0))throw new Error("Local file header not found");Pe(u,m,4);const h=a+30+u.filenameLength,x=h+u.extraFieldLength;u.rawExtraField=p.subarray(h,x),He(n,u,m,4);const w=n.encrypted&&u.encrypted,b=w&&!r;if(w){if(!b&&void 0===r.strength)throw new Error("Encryption method not supported");if(!_)throw new Error("File contains encrypted entry")}const v=await function(e,t,n){const i=!(!t.compressed&&!t.signed&&!t.encrypted)&&(t.useWebWorkers||void 0===t.useWebWorkers&&n.useWebWorkers),a=i&&n.workerScripts?n.workerScripts[t.codecType]:[];if(Be.length!e.busy));return s?$e(s,e,t,n,r,i,a):new Promise((n=>qe.push({resolve:n,codecConstructor:e,options:t,webWorker:i,scripts:a})))}function r(e){const t=!qe.length;if(t)Be=Be.filter((t=>t!=e));else{const[{resolve:t,codecConstructor:i,options:a,webWorker:s,scripts:o}]=qe.splice(0,1);t($e(e,i,a,n,r,s,o))}return t}}(o.Inflate,{codecType:"inflate",password:_,zipCrypto:b,encryptionStrength:r&&r.strength,signed:Ge(n,t,"checkSignature"),passwordVerification:b&&(l.dataDescriptor?c>>>8&255:d>>>24&255),signature:d,compressed:0!=s,encrypted:w,useWebWorkers:Ge(n,t,"useWebWorkers")},o);e.initialized||await e.init();const g=Ge(n,t,"signal");return await async function(e,t,n,i,a,r,s){const o=Math.max(r.chunkSize,64);return async function r(l=0,d=0){const c=s.signal;if(l>1,dataDescriptor:8==(8&i),languageEncodingFlag:2048==(2048&i)},rawLastModDate:Qe(t,n+6),lastModDate:Ne(e.rawLastModDate),filenameLength:Je(t,n+22),extraFieldLength:Je(t,n+24)})}function He(e,t,n,i){const a=t.rawExtraField,r=t.extraField=new Map,s=et(new Uint8Array(a));let o=0;try{for(;o4294967295==t[e]));for(let t=0;t{if(4294967295==t[n]){if(!e||void 0===e[n])throw new Error("Zip64 extra field not found");t[n]=e[n]}}))}(d,t);const c=t.extraFieldUnicodePath=r.get(28789);c&&Ke(c,"filename","rawFilename",t,e);const f=t.extraFieldUnicodeComment=r.get(25461);f&&Ke(f,"comment","rawComment",t,e);const u=t.extraFieldAES=r.get(39169);u?function(e,t,n){if(e){const i=et(e.data);e.vendorVersion=Ye(i,0),e.vendorId=Ye(i,2);const a=Ye(i,4);e.strength=a,e.originalCompressionMethod=n,t.compressionMethod=e.compressionMethod=Je(i,5)}else t.compressionMethod=n}(u,t,l):t.compressionMethod=l}function Ke(e,t,n,i,a){const r=et(e.data);e.version=Ye(r,0),e.signature=Qe(r,1);const s=new J;s.append(a[n]);const o=et(new Uint8Array(4));o.setUint32(0,s.get(),!0),e[t]=(new TextDecoder).decode(e.data.subarray(5)),e.valid=!a.bitFlag.languageEncodingFlag&&e.signature==Qe(o,0),e.valid&&(i[t]=e[t],i[t+"UTF8"]=!0)}function Ge(e,t,n){return void 0===t[n]?e.options[n]:t[n]}function Ze(e,t){return t&&"cp437"!=t.trim().toLowerCase()?new TextDecoder(t).decode(e):(e=>{let t="";for(let n=0;n>16,n=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}function Ye(e,t){return e.getUint8(t)}function Je(e,t){return e.getUint16(t,!0)}function Qe(e,t){return e.getUint32(t,!0)}function Xe(e,t){return Number(e.getBigUint64(t,!0))}function et(e){return new DataView(e.buffer)}function tt(e,t,n){return e.readUint8Array(t,n)}(()=>{if("function"==typeof URL.createObjectURL){const e=(()=>{const e=[];for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)1&n?n=n>>>1^3988292384:n>>>=1;e[t]=n}class t{constructor(e){this.crc=e||-1}append(t){let n=0|this.crc;for(let i=0,a=0|t.length;i>>8^e[255&(n^t[i])];this.crc=n}get(){return~this.crc}}const n={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const i=e[e.length-1],a=n.getPartial(i);return 32===a?e.concat(t):n._shiftRight(t,a,0|i,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const i=e[t-1];return 32*(t-1)+n.getPartial(i)},clamp(e,t){if(32*e.length0&&t&&(e[i-1]=n.partial(t,e[i-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>Math.round(e/1099511627776)||32,_shiftRight(e,t,i,a){for(void 0===a&&(a=[]);t>=32;t-=32)a.push(i),i=0;if(0===t)return a.concat(e);for(let n=0;n>>t),i=e[n]<<32-t;const r=e.length?e[e.length-1]:0,s=n.getPartial(r);return a.push(n.partial(t+s&31,t+s>32?i:a.pop(),1)),a}},i={bytes:{fromBits(e){const t=n.bitLength(e)/8,i=new Uint8Array(t);let a;for(let n=0;n>>24,a<<=8;return i},toBits(e){const t=[];let i,a=0;for(i=0;i9007199254740991)throw new Error("Cannot hash more than 2^53 - 1 bits");const o=new Uint32Array(a);let l=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);e<=s;e+=t.blockSize)t._block(o.subarray(16*l,16*(l+1))),l+=1;return a.splice(0,16*l),t},finalize:function(){const e=this;let t=e._buffer;const i=e._h;t=n.concat(t,[n.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(Math.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),i},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(e,t,n,i){return e<=19?t&n|~t&i:e<=39?t^n^i:e<=59?t&n|t&i|n&i:e<=79?t^n^i:void 0},_S:function(e,t){return t<>>32-e},_block:function(e){const t=this,n=t._h,i=Array(80);for(let t=0;t<16;t++)i[t]=e[t];let a=n[0],r=n[1],s=n[2],o=n[3],l=n[4];for(let e=0;e<=79;e++){e>=16&&(i[e]=t._S(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const n=t._S(5,a)+t._f(e,r,s,o)+l+i[e]+t._key[Math.floor(e/20)]|0;l=o,o=s,s=t._S(30,r),r=a,a=n}n[0]=n[0]+a|0,n[1]=n[1]+r|0,n[2]=n[2]+s|0,n[3]=n[3]+o|0,n[4]=n[4]+l|0}};const r={name:"PBKDF2"},s=Object.assign({hash:{name:"HMAC"}},r),o=Object.assign({iterations:1e3,hash:{name:"SHA-1"}},r),l=["deriveBits"],d=[8,12,16],c=[16,24,32],f=[0,0,0,0],u=crypto.subtle,p=i.bytes,m=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],i=t._tables[1],a=e.length;let r,s,o,l=1;if(4!==a&&6!==a&&8!==a)throw new Error("invalid aes key size");for(t._key=[s=e.slice(0),o=[]],r=a;r<4*a+28;r++){let e=s[r-1];(r%a==0||8===a&&r%a==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],r%a==0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),s[r]=s[r-a]^e}for(let e=0;r;e++,r--){const t=s[3&e?r:r-4];o[e]=r<=4||e<4?t:i[0][n[t>>>24]]^i[1][n[t>>16&255]]^i[2][n[t>>8&255]]^i[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],i=t[4],a=[],r=[];let s,o,l,d;for(let e=0;e<256;e++)r[(a[e]=e<<1^283*(e>>7))^e]=e;for(let c=s=0;!n[c];c^=o||1,s=r[s]||1){let r=s^s<<1^s<<2^s<<3^s<<4;r=r>>8^255&r^99,n[c]=r,i[r]=c,d=a[l=a[o=a[c]]];let f=16843009*d^65537*l^257*o^16843008*c,u=257*a[r]^16843008*r;for(let n=0;n<4;n++)e[n][c]=u=u<<24^u>>>8,t[n][r]=f=f<<24^f>>>8}for(let n=0;n<5;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new Error("invalid aes block size");const n=this._key[t],i=n.length/4-2,a=[0,0,0,0],r=this._tables[t],s=r[0],o=r[1],l=r[2],d=r[3],c=r[4];let f,u,p,m=e[0]^n[0],_=e[t?3:1]^n[1],h=e[2]^n[2],x=e[t?1:3]^n[3],w=4;for(let e=0;e>>24]^o[_>>16&255]^l[h>>8&255]^d[255&x]^n[w],u=s[_>>>24]^o[h>>16&255]^l[x>>8&255]^d[255&m]^n[w+1],p=s[h>>>24]^o[x>>16&255]^l[m>>8&255]^d[255&_]^n[w+2],x=s[x>>>24]^o[m>>16&255]^l[_>>8&255]^d[255&h]^n[w+3],w+=4,m=f,_=u,h=p;for(let e=0;e<4;e++)a[t?3&-e:e]=c[m>>>24]<<24^c[_>>16&255]<<16^c[h>>8&255]<<8^c[255&x]^n[w++],f=m,m=_,_=h,h=x,x=f;return a}},_=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,i=255&e;255===t?(t=0,255===n?(n=0,255===i?i=0:++i):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=i}else e+=1<<24;return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,i){let a;if(!(a=t.length))return[];const r=n.bitLength(t);for(let n=0;nr&&(e=n.hash(e));for(let t=0;te.length){const n=e;(e=new Uint8Array(t)).set(n,0)}return e}(n,s-s%16)),o=0;o<=s-16;o+=16){const a=p.toBits(y(t,o,o+16));r&&e.hmac.update(a);const s=e.aesCtrGladman.update(a);r||e.hmac.update(s),n.set(p.fromBits(s),o+i)}return e.pendingInput=y(t,o),n}async function v(e,t,n){const i=(new TextEncoder).encode(t),a=await u.importKey("raw",i,s,!1,l),r=await u.deriveBits(Object.assign({salt:n},o),a,8*(2*c[e.strength]+2)),d=new Uint8Array(r);e.keys={key:p.toBits(y(d,0,c[e.strength])),authentication:p.toBits(y(d,c[e.strength],2*c[e.strength])),passwordVerification:y(d,2*c[e.strength])}}function g(e,t){let n=e;return e.length+t.length&&(n=new Uint8Array(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function y(e,t,n){return e.subarray(t,n)}class k{constructor(e,t){Object.assign(this,{password:e,passwordVerification:t}),S(this,e)}async append(e){const t=this;if(t.password){const n=U(t,e.subarray(0,12));if(t.password=null,n[11]!=t.passwordVerification)throw new Error("Invalid pasword");e=e.subarray(12)}return U(t,e)}async flush(){return{valid:!0,data:new Uint8Array(0)}}}class z{constructor(e,t){Object.assign(this,{password:e,passwordVerification:t}),S(this,e)}async append(e){const t=this;let n,i;if(t.password){t.password=null;const a=crypto.getRandomValues(new Uint8Array(12));a[11]=t.passwordVerification,n=new Uint8Array(e.length+a.length),n.set(A(t,a),0),i=12}else n=new Uint8Array(e.length),i=0;return n.set(A(t,e),i),n}async flush(){return{data:new Uint8Array(0)}}}function U(e,t){const n=new Uint8Array(t.length);for(let i=0;i>>24]),e.keys[2]=~e.crcKey2.get()}function E(e){const t=2|e.keys[2];return C(Math.imul(t,1^t)>>>8)}function C(e){return 255&e}function I(e){return 4294967295&e}class F{constructor(e,{signature:n,password:i,signed:a,compressed:r,zipCrypto:s,passwordVerification:o,encryptionStrength:l},{chunkSize:d}){const c=Boolean(i);Object.assign(this,{signature:n,encrypted:c,signed:a,compressed:r,inflate:r&&new e({chunkSize:d}),crc32:a&&new t,zipCrypto:s,decrypt:c&&s?new k(i,o):new x(i,a,l)})}async append(e){const t=this;return t.encrypted&&e.length&&(e=await t.decrypt.append(e)),t.compressed&&e.length&&(e=await t.inflate.append(e)),(!t.encrypted||t.zipCrypto)&&t.signed&&e.length&&t.crc32.append(e),e}async flush(){const e=this;let t,n=new Uint8Array(0);if(e.encrypted){const t=await e.decrypt.flush();if(!t.valid)throw new Error("Invalid signature");n=t.data}if((!e.encrypted||e.zipCrypto)&&e.signed){const n=new DataView(new Uint8Array(4).buffer);if(t=e.crc32.get(),n.setUint32(0,t),e.cipher!=n.getUint32(0,!1))throw new Error("Invalid signature")}return e.compressed&&(n=await e.inflate.append(n)||new Uint8Array(0),await e.inflate.flush()),{data:n,signature:t}}}class ${constructor(e,{encrypted:n,signed:i,compressed:a,level:r,zipCrypto:s,password:o,passwordVerification:l,encryptionStrength:d},{chunkSize:c}){Object.assign(this,{encrypted:n,signed:i,compressed:a,deflate:a&&new e({level:r||5,chunkSize:c}),crc32:i&&new t,zipCrypto:s,encrypt:n&&s?new z(o,l):new w(o,d)})}async append(e){const t=this;let n=e;return t.compressed&&e.length&&(n=await t.deflate.append(e)),t.encrypted&&n.length&&(n=await t.encrypt.append(n)),(!t.encrypted||t.zipCrypto)&&t.signed&&e.length&&t.crc32.append(e),n}async flush(){const e=this;let t,n=new Uint8Array(0);if(e.compressed&&(n=await e.deflate.flush()||new Uint8Array(0)),e.encrypted){n=await e.encrypt.append(n);const i=await e.encrypt.flush();t=i.signature;const a=new Uint8Array(n.length+i.data.length);a.set(n,0),a.set(i.data,n.length),n=a}return e.encrypted&&!e.zipCrypto||!e.signed||(t=e.crc32.get()),{data:n,signature:t}}}const B={init(e){e.scripts&&e.scripts.length&&importScripts.apply(void 0,e.scripts);const t=e.options;let n;self.initCodec&&self.initCodec(),t.codecType.startsWith("deflate")?n=self.Deflate:t.codecType.startsWith("inflate")&&(n=self.Inflate),q=function(e,t,n){return t.codecType.startsWith("deflate")?new $(e,t,n):t.codecType.startsWith("inflate")?new F(e,t,n):void 0}(n,t,e.config)},append:async e=>({data:await q.append(e.data)}),flush:()=>q.flush()};let q;function L(e){return e.map((([e,t])=>new Array(e).fill(t,0,e))).flat()}addEventListener("message",(async e=>{const t=e.data,n=t.type,i=B[n];if(i)try{t.data&&(t.data=new Uint8Array(t.data));const e=await i(t)||{};if(e.type=n,e.data)try{e.data=e.data.buffer,postMessage(e,[e.data])}catch(t){postMessage(e)}else postMessage(e)}catch(e){postMessage({type:n,error:{message:e.message,stack:e.stack}})}}));const D=[0,1,2,3].concat(...L([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function M(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.build_tree=function(n){const i=e.dyn_tree,a=e.stat_desc.static_tree,r=e.stat_desc.elems;let s,o,l,d=-1;for(n.heap_len=0,n.heap_max=573,s=0;s=1;s--)n.pqdownheap(i,s);l=r;do{s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),o=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=o,i[2*l]=i[2*s]+i[2*o],n.depth[l]=Math.max(n.depth[s],n.depth[o])+1,i[2*s+1]=i[2*o+1]=l,n.heap[1]=l++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(t){const n=e.dyn_tree,i=e.stat_desc.static_tree,a=e.stat_desc.extra_bits,r=e.stat_desc.extra_base,s=e.stat_desc.max_length;let o,l,d,c,f,u,p=0;for(c=0;c<=15;c++)t.bl_count[c]=0;for(n[2*t.heap[t.heap_max]+1]=0,o=t.heap_max+1;o<573;o++)l=t.heap[o],c=n[2*n[2*l+1]+1]+1,c>s&&(c=s,p++),n[2*l+1]=c,l>e.max_code||(t.bl_count[c]++,f=0,l>=r&&(f=a[l-r]),u=n[2*l],t.opt_len+=u*(c+f),i&&(t.static_len+=u*(i[2*l+1]+f)));if(0!==p){do{for(c=s-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[s]--,p-=2}while(p>0);for(c=s;0!==c;c--)for(l=t.bl_count[c];0!==l;)d=t.heap[--o],d>e.max_code||(n[2*d+1]!=c&&(t.opt_len+=(c-n[2*d+1])*n[2*d],n[2*d+1]=c),l--)}}(n),function(e,n,i){const a=[];let r,s,o,l=0;for(r=1;r<=15;r++)a[r]=l=l+i[r-1]<<1;for(s=0;s<=n;s++)o=e[2*s+1],0!==o&&(e[2*s]=t(a[o]++,o))}(i,e.max_code,n.bl_count)}}function R(e,t,n,i,a){const r=this;r.static_tree=e,r.extra_bits=t,r.extra_base=n,r.elems=i,r.max_length=a}function V(e,t,n,i,a){const r=this;r.good_length=e,r.max_lazy=t,r.nice_length=n,r.max_chain=i,r.func=a}M._length_code=[0,1,2,3,4,5,6,7].concat(...L([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),M.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],M.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],M.d_code=function(e){return e<256?D[e]:D[256+(e>>>7)]},M.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],M.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],M.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],M.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R.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],R.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],R.static_l_desc=new R(R.static_ltree,M.extra_lbits,257,286,15),R.static_d_desc=new R(R.static_dtree,M.extra_dbits,0,30,15),R.static_bl_desc=new R(null,M.extra_blbits,0,19,7);const W=[new V(0,0,0,0,0),new V(4,4,8,4,1),new V(4,5,16,8,1),new V(4,6,32,32,1),new V(4,4,16,16,2),new V(8,16,32,32,2),new V(8,16,128,128,2),new V(8,32,128,256,2),new V(32,128,258,1024,2),new V(32,258,258,4096,2)],O=["need dictionary","stream end","","","stream error","data error","","buffer error","",""];function T(e,t,n,i){const a=e[2*t],r=e[2*n];return a>>8&255)}function ee(e,t){let n;const i=t;N>16-i?(n=e,Z|=n<>>16-N,N+=i-16):(Z|=e<=8&&(Q(255&Z),Z>>>=8,N-=8)}function ae(t,n){let i,a,r;if(e.pending_buf[H+2*P]=t>>>8&255,e.pending_buf[H+2*P+1]=255&t,e.pending_buf[D+P]=255&n,P++,0===t?I[2*n]++:(K++,t--,I[2*(M._length_code[n]+256+1)]++,F[2*M.d_code(t)]++),0==(8191&P)&&S>2){for(i=8*P,a=g-x,r=0;r<30;r++)i+=F[2*r]*(5+M.extra_dbits[r]);if(i>>>=3,K8?X(Z):N>0&&Q(255&Z),Z=0,N=0}function oe(t,n,i){ee(0+(i?1:0),3),function(t,n,i){se(),G=8,X(n),X(~n),e.pending_buf.set(l.subarray(t,t+n),e.pending),e.pending+=n}(t,n)}function le(t,n,i){let a,r,s=0;S>0?(B.build_tree(e),q.build_tree(e),s=function(){let t;for(J(I,B.max_code),J(F,q.max_code),L.build_tree(e),t=18;t>=3&&0===$[2*M.bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(),a=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=a&&(a=r)):a=r=n+5,n+4<=a&&-1!=t?oe(t,n,i):r==a?(ee(2+(i?1:0),3),re(R.static_ltree,R.static_dtree)):(ee(4+(i?1:0),3),function(e,t,n){let i;for(ee(e-257,5),ee(t-1,5),ee(n-4,4),i=0;i=0?x:-1,g-x,e),x=g,t.flush_pending()}function ce(){let e,n,i,a;do{if(a=d-k-g,0===a&&0===g&&0===k)a=r;else if(-1==a)a--;else if(g>=r+r-262){l.set(l.subarray(r,r+r),0),y-=r,g-=r,x-=r,e=p,i=e;do{n=65535&f[--i],f[i]=n>=r?n-r:0}while(0!=--e);e=r,i=e;do{n=65535&c[--i],c[i]=n>=r?n-r:0}while(0!=--e);a+=r}if(0===t.avail_in)return;e=t.read_buf(l,g+k,a),k+=e,k>=3&&(u=255&l[g],u=(u<r-262?g-(r-262):0;let f=C;const u=o,p=g+258;let m=l[a+s-1],_=l[a+s];z>=E&&(i>>=2),f>k&&(f=k);do{if(t=e,l[t+s]==_&&l[t+s-1]==m&&l[t]==l[a]&&l[++t]==l[a+1]){a+=2,t++;do{}while(l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&l[++a]==l[++t]&&as){if(y=e,s=n,n>=f)break;m=l[a+s-1],_=l[a+s]}}}while((e=65535&c[e&u])>d&&0!=--i);return s<=k?s:k}function ue(t){return t.total_in=t.total_out=0,t.msg=null,e.pending=0,e.pending_out=0,n=113,a=0,B.dyn_tree=I,B.stat_desc=R.static_l_desc,q.dyn_tree=F,q.stat_desc=R.static_d_desc,L.dyn_tree=$,L.stat_desc=R.static_bl_desc,Z=0,N=0,G=8,Y(),function(){d=2*r,f[p-1]=0;for(let e=0;e9||8!=d||a<9||a>15||n<0||n>9||x<0||x>2?-2:(t.dstate=e,s=a,r=1<9||n<0||n>2?-2:(W[S].func!=W[t].func&&0!==e.total_in&&(i=e.deflate(1)),S!=t&&(S=t,A=W[S].max_lazy,E=W[S].good_length,C=W[S].nice_length,U=W[S].max_chain),j=n,i)},e.deflateSetDictionary=function(e,t,i){let a,s=i,d=0;if(!t||42!=n)return-2;if(s<3)return 0;for(s>r-262&&(s=r-262,d=i-s),l.set(t.subarray(d,d+s),0),g=s,x=s,u=255&l[0],u=(u<4||m<0)return-2;if(!d.next_out||!d.next_in&&0!==d.avail_in||666==n&&4!=m)return d.msg=O[4],-2;if(0===d.avail_out)return d.msg=O[7],-5;var $;if(t=d,I=a,a=m,42==n&&(E=8+(s-8<<4)<<8,C=(S-1&255)>>1,C>3&&(C=3),E|=C<<6,0!==g&&(E|=32),E+=31-E%31,n=113,Q(($=E)>>8&255),Q(255&$)),0!==e.pending){if(t.flush_pending(),0===t.avail_out)return a=-1,0}else if(0===t.avail_in&&m<=I&&4!=m)return t.msg=O[7],-5;if(666==n&&0!==t.avail_in)return d.msg=O[7],-5;if(0!==t.avail_in||0!==k||0!=m&&666!=n){switch(F=-1,W[S].func){case 0:F=function(e){let n,a=65535;for(a>i-5&&(a=i-5);;){if(k<=1){if(ce(),0===k&&0==e)return 0;if(0===k)break}if(g+=k,k=0,n=x+a,(0===g||g>=n)&&(k=g-n,g=n,de(!1),0===t.avail_out))return 0;if(g-x>=r-262&&(de(!1),0===t.avail_out))return 0}return de(4==e),0===t.avail_out?4==e?2:0:4==e?3:1}(m);break;case 1:F=function(e){let n,i=0;for(;;){if(k<262){if(ce(),k<262&&0==e)return 0;if(0===k)break}if(k>=3&&(u=(u<=3)if(n=ae(g-y,w-3),k-=w,w<=A&&k>=3){w--;do{g++,u=(u<=3&&(u=(u<4096)&&(w=2)),z>=3&&w<=z){i=g+k-3,n=ae(g-1-b,z-3),k-=z-1,z-=2;do{++g<=i&&(u=(u<0&&t.next_in_index!=o&&(a(t.next_in_index),o=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return c.length>1?(s=new Uint8Array(d),c.forEach((function(e){s.set(e,l),l+=e.length}))):s=c[0]||new Uint8Array(0),s}},this.flush=function(){let e,a,r=0,s=0;const o=[];do{if(t.next_out_index=0,t.avail_out=n,e=t.deflate(4),1!=e&&0!=e)throw new Error("deflating: "+t.msg);n-t.avail_out>0&&o.push(i.slice(0,t.next_out_index)),s+=t.next_out_index}while(t.avail_in>0||0===t.avail_out);return t.deflateEnd(),a=new Uint8Array(s),o.forEach((function(e){a.set(e,r),r+=e.length})),a}}H.prototype={deflateInit:function(e,t){const n=this;return n.dstate=new P,t||(t=15),n.dstate.deflateInit(n,e,t)},deflate:function(e){const t=this;return t.dstate?t.dstate.deflate(t,e):-2},deflateEnd:function(){const e=this;if(!e.dstate)return-2;const t=e.dstate.deflateEnd();return e.dstate=null,t},deflateParams:function(e,t){const n=this;return n.dstate?n.dstate.deflateParams(n,e,t):-2},deflateSetDictionary:function(e,t){const n=this;return n.dstate?n.dstate.deflateSetDictionary(n,e,t):-2},read_buf:function(e,t,n){const i=this;let a=i.avail_in;return a>n&&(a=n),0===a?0:(i.avail_in-=a,e.set(i.next_in.subarray(i.next_in_index,i.next_in_index+a),t),i.next_in_index+=a,i.total_in+=a,a)},flush_pending:function(){const e=this;let t=e.dstate.pending;t>e.avail_out&&(t=e.avail_out),0!==t&&(e.next_out.set(e.dstate.pending_buf.subarray(e.dstate.pending_out,e.dstate.pending_out+t),e.next_out_index),e.next_out_index+=t,e.dstate.pending_out+=t,e.total_out+=t,e.avail_out-=t,e.dstate.pending-=t,0===e.dstate.pending&&(e.dstate.pending_out=0))}};const G=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Z=[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],N=[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],Y=[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],J=[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],Q=[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],X=[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];function ee(){let e,t,n,i,a,r;function s(e,t,s,o,l,d,c,f,u,p,m){let _,h,x,w,b,v,g,y,k,z,U,A,S,j,E;z=0,b=s;do{n[e[t+z]]++,z++,b--}while(0!==b);if(n[0]==s)return c[0]=-1,f[0]=0,0;for(y=f[0],v=1;v<=15&&0===n[v];v++);for(g=v,yb&&(y=b),f[0]=y,j=1<A+y;){if(w++,A+=y,E=x-A,E=E>y?y:E,(h=1<<(v=g-A))>_+1&&(h-=_+1,S=g,v1440)return-3;a[w]=U=p[0],p[0]+=E,0!==w?(r[w]=b,i[0]=v,i[1]=y,v=b>>>A-y,i[2]=U-a[w-1]-v,u.set(i,3*(a[w-1]+v))):c[0]=U}for(i[1]=g-A,z>=s?i[0]=192:m[z]>>A;v>>=1)b^=v;for(b^=v,k=(1<257?(-3==p?u.msg="oversubscribed distance tree":-5==p?(u.msg="incomplete distance tree",p=-3):-4!=p&&(u.msg="empty distance tree with lengths",p=-3),p):0)}}function te(){const e=this;let t,n,i,a,r=0,s=0,o=0,l=0,d=0,c=0,f=0,u=0,p=0,m=0;function _(e,t,n,i,a,r,s,o){let l,d,c,f,u,p,m,_,h,x,w,b,v,g,y,k;m=o.next_in_index,_=o.avail_in,u=s.bitb,p=s.bitk,h=s.write,x=h>=d[k+1],p-=d[k+1],0!=(16&f)){for(f&=15,v=d[k+2]+(u&G[f]),u>>=f,p-=f;p<15;)_--,u|=(255&o.read_byte(m++))<>=d[k+1],p-=d[k+1],0!=(16&f)){for(f&=15;p>=f,p-=f,x-=v,h>=g)y=h-g,h-y>0&&2>h-y?(s.window[h++]=s.window[y++],s.window[h++]=s.window[y++],v-=2):(s.window.set(s.window.subarray(y,y+2),h),h+=2,y+=2,v-=2);else{y=h-g;do{y+=s.end}while(y<0);if(f=s.end-y,v>f){if(v-=f,h-y>0&&f>h-y)do{s.window[h++]=s.window[y++]}while(0!=--f);else s.window.set(s.window.subarray(y,y+f),h),h+=f,y+=f,f=0;y=0}}if(h-y>0&&v>h-y)do{s.window[h++]=s.window[y++]}while(0!=--v);else s.window.set(s.window.subarray(y,y+v),h),h+=v,y+=v,v=0;break}if(0!=(64&f))return o.msg="invalid distance code",v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,-3;l+=d[k+2],l+=u&G[f],k=3*(c+l),f=d[k]}break}if(0!=(64&f))return 0!=(32&f)?(v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,1):(o.msg="invalid literal/length code",v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,-3);if(l+=d[k+2],l+=u&G[f],k=3*(c+l),0===(f=d[k])){u>>=d[k+1],p-=d[k+1],s.window[h++]=d[k+2],x--;break}}else u>>=d[k+1],p-=d[k+1],s.window[h++]=d[k+2],x--}while(x>=258&&_>=10);return v=o.avail_in-_,v=p>>3>3:v,_+=v,m-=v,p-=v<<3,s.bitb=u,s.bitk=p,o.avail_in=_,o.total_in+=m-o.next_in_index,o.next_in_index=m,s.write=h,0}e.init=function(e,r,s,o,l,d){t=0,f=e,u=r,i=s,p=o,a=l,m=d,n=null},e.proc=function(e,h,x){let w,b,v,g,y,k,z,U=0,A=0,S=0;for(S=h.next_in_index,g=h.avail_in,U=e.bitb,A=e.bitk,y=e.write,k=y=258&&g>=10&&(e.bitb=U,e.bitk=A,h.avail_in=g,h.total_in+=S-h.next_in_index,h.next_in_index=S,e.write=y,x=_(f,u,i,p,a,m,e,h),S=h.next_in_index,g=h.avail_in,U=e.bitb,A=e.bitk,y=e.write,k=y>>=n[b+1],A-=n[b+1],v=n[b],0===v){l=n[b+2],t=6;break}if(0!=(16&v)){d=15&v,r=n[b+2],t=2;break}if(0==(64&v)){o=v,s=b/3+n[b+2];break}if(0!=(32&v)){t=7;break}return t=9,h.msg="invalid literal/length code",x=-3,e.bitb=U,e.bitk=A,h.avail_in=g,h.total_in+=S-h.next_in_index,h.next_in_index=S,e.write=y,e.inflate_flush(h,x);case 2:for(w=d;A>=w,A-=w,o=u,n=a,s=m,t=3;case 3:for(w=o;A>=n[b+1],A-=n[b+1],v=n[b],0!=(16&v)){d=15&v,c=n[b+2],t=4;break}if(0==(64&v)){o=v,s=b/3+n[b+2];break}return t=9,h.msg="invalid distance code",x=-3,e.bitb=U,e.bitk=A,h.avail_in=g,h.total_in+=S-h.next_in_index,h.next_in_index=S,e.write=y,e.inflate_flush(h,x);case 4:for(w=d;A>=w,A-=w,t=5;case 5:for(z=y-c;z<0;)z+=e.end;for(;0!==r;){if(0===k&&(y==e.end&&0!==e.read&&(y=0,k=y7&&(A-=8,g++,S--),e.write=y,x=e.inflate_flush(h,x),y=e.write,k=ye.avail_out&&(i=e.avail_out),0!==i&&-5==t&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.window.subarray(r,r+i),a),a+=i,r+=i,r==n.end&&(r=0,n.write==n.end&&(n.write=0),i=n.write-r,i>e.avail_out&&(i=e.avail_out),0!==i&&-5==t&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.window.subarray(r,r+i),a),a+=i,r+=i),e.next_out_index=a,n.read=r,t},n.proc=function(e,t){let m,_,h,x,w,b,v,g;for(x=e.next_in_index,w=e.avail_in,_=n.bitb,h=n.bitk,b=n.write,v=b>>1){case 0:_>>>=3,h-=3,m=7&h,_>>>=m,h-=m,a=1;break;case 1:y=[],k=[],z=[[]],U=[[]],ee.inflate_trees_fixed(y,k,z,U),c.init(y[0],k[0],z[0],0,U[0],0),_>>>=3,h-=3,a=6;break;case 2:_>>>=3,h-=3,a=3;break;case 3:return _>>>=3,h-=3,a=9,e.msg="invalid block type",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t)}break;case 1:for(;h<32;){if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);t=0,w--,_|=(255&e.read_byte(x++))<>>16&65535)!=(65535&_))return a=9,e.msg="invalid stored block lengths",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);r=65535&_,_=h=0,a=0!==r?2:0!==f?7:0;break;case 2:if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);if(0===v&&(b==n.end&&0!==n.read&&(b=0,v=bw&&(m=w),m>v&&(m=v),n.window.set(e.read_buf(x,m),b),x+=m,w-=m,b+=m,v-=m,0!=(r-=m))break;a=0!==f?7:0;break;case 3:for(;h<14;){if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);t=0,w--,_|=(255&e.read_byte(x++))<29||(m>>5&31)>29)return a=9,e.msg="too many length or distance symbols",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);if(m=258+(31&m)+(m>>5&31),!i||i.length>>=14,h-=14,o=0,a=4;case 4:for(;o<4+(s>>>10);){for(;h<3;){if(0===w)return n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);t=0,w--,_|=(255&e.read_byte(x++))<>>=3,h-=3}for(;o<19;)i[ne[o++]]=0;if(l[0]=7,m=p.inflate_trees_bits(i,l,d,u,e),0!=m)return-3==(t=m)&&(i=null,a=9),n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);o=0,a=5;case 5:for(;m=s,!(o>=258+(31&m)+(m>>5&31));){let r,c;for(m=l[0];h>>=m,h-=m,i[o++]=c;else{for(g=18==c?7:c-14,r=18==c?11:3;h>>=m,h-=m,r+=_&G[g],_>>>=g,h-=g,g=o,m=s,g+r>258+(31&m)+(m>>5&31)||16==c&&g<1)return i=null,a=9,e.msg="invalid bit length repeat",t=-3,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);c=16==c?i[g-1]:0;do{i[g++]=c}while(0!=--r);o=g}}if(d[0]=-1,A=[],S=[],j=[],E=[],A[0]=9,S[0]=6,m=s,m=p.inflate_trees_dynamic(257+(31&m),1+(m>>5&31),i,A,S,j,E,u,e),0!=m)return-3==m&&(i=null,a=9),t=m,n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,n.inflate_flush(e,t);c.init(A[0],S[0],u,j[0],u,E[0]),a=6;case 6:if(n.bitb=_,n.bitk=h,e.avail_in=w,e.total_in+=x-e.next_in_index,e.next_in_index=x,n.write=b,1!=(t=c.proc(n,e,t)))return n.inflate_flush(e,t);if(t=0,c.free(e),x=e.next_in_index,w=e.avail_in,_=n.bitb,h=n.bitk,b=n.write,v=b15?(e.inflateEnd(n),-2):(e.wbits=i,n.istate.blocks=new ie(n,1<>4)>a.wbits){a.mode=13,e.msg="invalid window size",a.marker=5;break}a.mode=1;case 1:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,i=255&e.read_byte(e.next_in_index++),((a.method<<8)+i)%31!=0){a.mode=13,e.msg="incorrect header check",a.marker=5;break}if(0==(32&i)){a.mode=7;break}a.mode=2;case 2:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,a.need=(255&e.read_byte(e.next_in_index++))<<24&4278190080,a.mode=3;case 3:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,a.need+=(255&e.read_byte(e.next_in_index++))<<16&16711680,a.mode=4;case 4:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,a.need+=(255&e.read_byte(e.next_in_index++))<<8&65280,a.mode=5;case 5:return 0===e.avail_in?n:(n=t,e.avail_in--,e.total_in++,a.need+=255&e.read_byte(e.next_in_index++),a.mode=6,2);case 6:return a.mode=13,e.msg="need dictionary",a.marker=0,-2;case 7:if(n=a.blocks.proc(e,n),-3==n){a.mode=13,a.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,a.blocks.reset(e,a.was),a.mode=12;case 12:return 1;case 13:return-3;default:return-2}},e.inflateSetDictionary=function(e,t,n){let i=0,a=n;if(!e||!e.istate||6!=e.istate.mode)return-2;const r=e.istate;return a>=1<0&&t.next_in_index!=d&&(r(t.next_in_index),d=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return s.length>1?(l=new Uint8Array(f),s.forEach((function(e){l.set(e,c),c+=e.length}))):l=s[0]||new Uint8Array(0),l}},this.flush=function(){t.inflateEnd()}}se.prototype={inflateInit:function(e){const t=this;return t.istate=new re,e||(e=15),t.istate.inflateInit(t,e)},inflate:function(e){const t=this;return t.istate?t.istate.inflate(t,e):-2},inflateEnd:function(){const e=this;if(!e.istate)return-2;const t=e.istate.inflateEnd(e);return e.istate=null,t},inflateSync:function(){const e=this;return e.istate?e.istate.inflateSync(e):-2},inflateSetDictionary:function(e,t){const n=this;return n.istate?n.istate.inflateSetDictionary(n,e,t):-2},read_byte:function(e){return this.next_in[e]},read_buf:function(e,t){return this.next_in.subarray(e,e+t)}},self.initCodec=()=>{self.Deflate=K,self.Inflate=oe}}).toString(),t=URL.createObjectURL(new Blob(["("+e+")()"],{type:"text/javascript"}));W({workerScripts:{inflate:[t],deflate:[t]}})}})(),W({Deflate:function(e){const t=new z,n=e&&e.chunkSize?Math.floor(1.05*e.chunkSize):65536,i=new Uint8Array(n);let a=e?e.level:-1;void 0===a&&(a=-1),t.deflateInit(a),t.next_out=i,this.append=function(e,a){let r,s,o=0,l=0,d=0;const c=[];if(e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,r=t.deflate(0),0!=r)throw new Error("deflating: "+t.msg);t.next_out_index&&(t.next_out_index==n?c.push(new Uint8Array(i)):c.push(i.slice(0,t.next_out_index))),d+=t.next_out_index,a&&t.next_in_index>0&&t.next_in_index!=o&&(a(t.next_in_index),o=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return c.length>1?(s=new Uint8Array(d),c.forEach((function(e){s.set(e,l),l+=e.length}))):s=c[0]||new Uint8Array(0),s}},this.flush=function(){let e,a,r=0,s=0;const o=[];do{if(t.next_out_index=0,t.avail_out=n,e=t.deflate(4),1!=e&&0!=e)throw new Error("deflating: "+t.msg);n-t.avail_out>0&&o.push(i.slice(0,t.next_out_index)),s+=t.next_out_index}while(t.avail_in>0||0===t.avail_out);return t.deflateEnd(),a=new Uint8Array(s),o.forEach((function(e){a.set(e,r),r+=e.length})),a}},Inflate:function(e){const t=new M,n=e&&e.chunkSize?Math.floor(2*e.chunkSize):131072,i=new Uint8Array(n);let a=!1;t.inflateInit(),t.next_out=i,this.append=function(e,r){const s=[];let o,l,d=0,c=0,f=0;if(0!==e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,0!==t.avail_in||a||(t.next_in_index=0,a=!0),o=t.inflate(0),a&&-5===o){if(0!==t.avail_in)throw new Error("inflating: bad input")}else if(0!==o&&1!==o)throw new Error("inflating: "+t.msg);if((a||1===o)&&t.avail_in===e.length)throw new Error("inflating: bad input");t.next_out_index&&(t.next_out_index===n?s.push(new Uint8Array(i)):s.push(i.slice(0,t.next_out_index))),f+=t.next_out_index,r&&t.next_in_index>0&&t.next_in_index!=d&&(r(t.next_in_index),d=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return s.length>1?(l=new Uint8Array(f),s.forEach((function(e){l.set(e,c),c+=e.length}))):l=s[0]||new Uint8Array(0),l}},this.flush=function(){t.inflateEnd()}}});const nt=["boot","dt","dtbo","pvmfw","recovery","vbmeta_system","vbmeta_vendor","vbmeta","vendor_boot"],it=["odm","product","system_ext","system","vendor_dlkm","vendor"],at={load:"Loading",unpack:"Unpacking",flash:"Writing",wipe:"Wiping",reboot:"Restarting"};async function rt(e,t,n){try{return await e.getData(t,n)}catch(e){throw e instanceof ProgressEvent&&"error"===e.type&&null!==e.target?e.target.error:e}}async function st(e,t,i,a){n(`Unpacking ${a}`),i("unpack",a,0);let r=await rt(t,new Z("application/octet-stream"),{onprogress:(e,t)=>{i("unpack",a,e/t)}});n(`Flashing ${a}`),i("flash",a,0),await e.flashBlob(a,r,(e=>{i("flash",a,e)}))}async function ot(e,t,n,i){for(let a of i){let i=new RegExp(`${a}(?:-.+)?\\.img$`),r=t.find((e=>e.filename.match(i)));if(void 0!==r)if("bootloader"==a){let t=await e.getVariable("current-slot");if("a"==t)await st(e,r,n,a+"_b"),await e.runCommand("set_active:b");else{if("b"!=t)throw new ft("FAIL","Invalid slot given by bootloader.");await st(e,r,n,a+"_a"),await e.runCommand("set_active:a")}}else await st(e,r,n,a)}}async function lt(e,t,n){try{await e.reboot(t,!1)}catch(e){}await e.waitForConnect(n)}async function dt(e,t,i,a,o=((e,t,n)=>{})){o("load","package",0);let l=new Oe(new G(t)),d=await l.getEntries();"yes"===await e.getVariable("is-userspace")&&await e.reboot("bootloader",!0,a),await ot(e,d,o,["bootloader"]),await s(o,"reboot","device",4e3,lt(e,"bootloader",a)),await ot(e,d,o,["bootloader"]),await s(o,"reboot","device",4e3,lt(e,"bootloader",a)),await ot(e,d,o,["radio"]),await s(o,"reboot","device",4e3,lt(e,"bootloader",a));let c=await e.getVariable("snapshot-update-status");null!==c&&"none"!==c&&await e.runCommand("snapshot-update:cancel"),n("Loading nested images from zip"),o("unpack","images",0);let f=d.find((e=>e.filename.match(/image-.+\.zip$/))),u=await rt(f,new Z("application/zip"),{onprogress:(e,t)=>{o("unpack","images",e/t)}}),p=new Oe(new G(u)),m=await p.getEntries();if(f=m.find((e=>"android-info.txt"===e.filename)),void 0!==f){let t=await rt(f,new K);await async function(e,t){for(let i of t.replace("\r","").split("\n")){let t=i.match(/^require\s+(.+?)=(.+)$/);if(!t)continue;let a=t[1];"board"===a&&(a="product");let r=t[2],s=r.split("|");if("partition-exists"===a){let t=await e.getVariable(`has-slot:${r}`);if("yes"!==t&&"no"!==t)throw new ft("FAIL",`Requirement ${a}=${r} failed, device lacks partition`);if(!nt.includes(r)&&!it.includes(r))throw new ft("FAIL",`Requirement ${a}=${r} failed, unrecognized partition`)}else{let t=await e.getVariable(a);if(!s.includes(t)){let e=`Requirement ${a}=${r} failed, value = ${t}`;throw n(e),new ft("FAIL",e)}n(`Requirement ${a}=${r} passed`)}}}(e,t)}if(await ot(e,m,o,nt),f=m.find((e=>"super_empty.img"===e.filename)),void 0!==f){await s(o,"reboot","device",16e3,e.reboot("fastboot",!0,a));let t=await e.getVariable("super-partition-name");t||(t="super");let n=i?"wipe":"flash";o(n,"super",0);let l=await rt(f,new Z("application/octet-stream"));await e.upload(t,await r(l),(e=>{o(n,"super",e)})),await e.runCommand(`update-super:${t}${i?":wipe":""}`)}await ot(e,m,o,it),"yes"===await e.getVariable("is-userspace")&&await s(o,"reboot","device",4e3,e.reboot("bootloader",!0,a)),f=d.find((e=>e.filename.endsWith("avb_pkmd.bin"))),void 0!==f&&(await e.runCommand("erase:avb_custom_key"),await st(e,f,o,"avb_custom_key")),i&&await s(o,"wipe","data",1e3,e.runCommand("erase:userdata"))}class ct extends Error{constructor(e){super(e),this.name="UsbError"}}class ft extends Error{constructor(e,t){super(`Bootloader replied with ${e}: ${t}`),this.status=e,this.bootloaderMessage=t,this.name="FastbootError"}}class ut{constructor(){this.device=null,this.epIn=null,this.epOut=null,this._registeredUsbListeners=!1,this._connectResolve=null,this._connectReject=null,this._disconnectResolve=null}get isConnected(){return null!==this.device&&this.device.opened&&this.device.configurations[0].interfaces[0].claimed}async _validateAndConnectDevice(){if(null===this.device)throw new ct("Attempted to connect to null device");let e=this.device.configurations[0].interfaces[0].alternates[0];if(2!==e.endpoints.length)throw new ct("Interface has wrong number of endpoints");this.epIn=null,this.epOut=null;for(let t of e.endpoints){if(i("Checking endpoint:",t),"bulk"!==t.type)throw new ct("Interface endpoint is not bulk");if("in"===t.direction){if(null!==this.epIn)throw new ct("Interface has multiple IN endpoints");this.epIn=t.endpointNumber}else if("out"===t.direction){if(null!==this.epOut)throw new ct("Interface has multiple OUT endpoints");this.epOut=t.endpointNumber}}i("Endpoints: in =",this.epIn,", out =",this.epOut);try{await this.device.open();try{await this.device.reset()}catch(e){}await this.device.selectConfiguration(1),await this.device.claimInterface(0)}catch(e){throw null!==this._connectReject&&(this._connectReject(e),this._connectResolve=null,this._connectReject=null),e}null!==this._connectResolve&&(this._connectResolve(void 0),this._connectResolve=null,this._connectReject=null)}async waitForDisconnect(){if(null!==this.device)return await new Promise(((e,t)=>{this._disconnectResolve=e}))}async waitForConnect(e=(()=>{})){return navigator.userAgent.includes("Android")&&(await this.waitForDisconnect(),e()),await new Promise(((e,t)=>{this._connectResolve=e,this._connectReject=t}))}async connect(){let e=await navigator.usb.getDevices();n("Found paired USB devices:",e),1===e.length?this.device=e[0]:(n("No or multiple paired devices are connected, requesting one"),this.device=await navigator.usb.requestDevice({filters:[{classCode:255,subclassCode:66,protocolCode:3}]})),n("Using USB device:",this.device),this._registeredUsbListeners||(navigator.usb.addEventListener("disconnect",(e=>{e.device===this.device&&(n("USB device disconnected"),null!==this._disconnectResolve&&(this._disconnectResolve(void 0),this._disconnectResolve=null))})),navigator.usb.addEventListener("connect",(async e=>{n("USB device connected"),this.device=e.device;let t=null!==this._connectReject;try{await this._validateAndConnectDevice()}catch(e){if(!t)throw e}})),this._registeredUsbListeners=!0),await this._validateAndConnectDevice()}async _readResponse(){let e,t={text:""};do{let i=await this.device.transferIn(this.epIn,64),a=(new TextDecoder).decode(i.data);e=a.substring(0,4);let r=a.substring(4);if(n(`Response: ${e} ${r}`),"OKAY"===e)t.text+=r;else if("INFO"===e)t.text+=r+"\n";else{if("DATA"!==e)throw new ft(e,r);t.dataSize=r}}while("INFO"===e);return t}async runCommand(e){if(e.length>64)throw new RangeError;let t=(new TextEncoder).encode(e);return await this.device.transferOut(this.epOut,t),n("Command:",e),this._readResponse()}async getVariable(e){let t;try{t=(await(n=this.runCommand(`getvar:${e}`),i=1e4,new Promise(((e,t)=>{let a=!1,r=setTimeout((()=>{a=!0,t(new o(i))}),i);n.then((t=>{a||e(t)})).catch((e=>{a||t(e)})).finally((()=>{a||clearTimeout(r)}))})))).text}catch(e){if(!(e instanceof ft&&"FAIL"==e.status))throw e;t=null}var n,i;return t?t.trim():null}async _getDownloadSize(){try{let e=(await this.getVariable("max-download-size")).toLowerCase();if(e)return Math.min(parseInt(e,16),1073741824)}catch(e){}return 536870912}async _sendRawPayload(e,t){let n=0,a=e.byteLength;for(;a>0;){let r=e.slice(16384*n,16384*(n+1));n%1e3==0&&i(` Sending ${r.byteLength} bytes to endpoint, ${a} remaining, i=${n}`),n%10==0&&t((e.byteLength-a)/e.byteLength),await this.device.transferOut(this.epOut,r),a-=r.byteLength,n+=1}t(1)}async upload(e,t,i=(e=>{})){n(`Uploading single sparse to ${e}: ${t.byteLength} bytes`);let a=t.byteLength.toString(16).padStart(8,"0");if(8!==a.length)throw new ft("FAIL",`Transfer size overflow: ${a} is more than 8 digits`);let r=await this.runCommand(`download:${a}`);if(void 0===r.dataSize)throw new ft("FAIL",`Unexpected response to download command: ${r.text}`);if(parseInt(r.dataSize,16)!==t.byteLength)throw new ft("FAIL",`Bootloader wants ${t.byteLength} bytes, requested to send ${t.byteLength} bytes`);n(`Sending payload: ${t.byteLength} bytes`),await this._sendRawPayload(t,i),n("Payload sent, waiting for response..."),await this._readResponse()}async reboot(e="",t=!1,n=(()=>{})){e.length>0?await this.runCommand(`reboot-${e}`):await this.runCommand("reboot"),t&&await this.waitForConnect(n)}async flashBlob(e,t,a=(e=>{})){"yes"===await this.getVariable(`has-slot:${e}`)&&(e+="_"+await this.getVariable("current-slot"));let s=await this._getDownloadSize(),o=await r(t.slice(0,28)),_=t.size,h=!1;try{let e=c(o);null!==e&&(_=e.blocks*e.blockSize,h=!0)}catch(e){}if("yes"===await this.getVariable(`is-logical:${e}`)&&(await this.runCommand(`resize-logical-partition:${e}:0`),await this.runCommand(`resize-logical-partition:${e}:${_}`)),t.size>s&&!h){n(`${e} image is raw, converting to sparse`);let i=function(e){let t={blockSize:4096,blocks:e.byteLength/4096,chunks:1,crc32:0},n=[];for(;e.byteLength>0;){let i=Math.min(e.byteLength,67108864);n.push({type:d.Raw,blocks:i/t.blockSize,data:e.slice(0,i)}),e=e.slice(i)}return m(t,n)}(await r(t));t=new Blob([i])}n(`Flashing ${t.size} bytes to ${e}, ${s} bytes per split`);let x=0,w=0;for await(let o of async function*(e,t){if(n(`Splitting ${e.size}-byte sparse image into ${t}-byte chunks`),e.size<=t)return n("Blob fits in 1 payload, not splitting"),void(yield{data:await r(e),bytes:e.size});let a=c(await r(e.slice(0,28)));if(null===a)throw new l("Blob is not a sparse image");a.crc32=0,e=e.slice(28);let s=[],o=0;for(let l=0;l=c.dataBytes)i(" Space is available, adding chunk"),s.push(c),o+=c.blocks*a.blockSize;else{let e=u(s);s.push({type:d.Skip,blocks:a.blocks-e,data:new ArrayBuffer(0),dataBytes:0}),i(`Partition is ${a.blocks} blocks, used ${e}, padded with ${a.blocks-e}, finishing split with ${u(s)} blocks`);let t=m(a,s);n(`Finished ${t.byteLength}-byte split with ${s.length} chunks`),yield{data:t,bytes:o},i(`Starting new split: skipping first ${e} blocks and adding chunk`),s=[{type:d.Skip,blocks:e,data:new ArrayBuffer(0),dataBytes:0},c],o=0}}if(s.length>0&&(s.length>1||s[0].type!==d.Skip)){let e=m(a,s);n(`Finishing final ${e.byteLength}-byte split with ${s.length} chunks`),yield{data:e,bytes:o}}}(t,s))await this.upload(e,o.data,(e=>{a((w+e*o.bytes)/_)})),n("Flashing payload..."),await this.runCommand(`flash:${e}`),x+=1,w+=o.bytes;n(`Flashed ${e} with ${x} split(s)`)}async bootBlob(e,t=(e=>{})){n(`Booting ${e.size} bytes image`);let i=await r(e);await this.upload("boot.img",i,t),n("Booting payload..."),await this.runCommand("boot"),n(`Booted ${e.size} bytes image`)}async flashFactoryZip(e,t,n,i=(e=>{})){return await dt(this,e,t,n,i)}}export{ut as FastbootDevice,ft as FastbootError,o as TimeoutError,at as USER_ACTION_MAP,ct as UsbError,W as configureZip,a as setDebugLevel}; //# sourceMappingURL=fastboot.min.mjs.map