>>=y,p-=y),p<15&&(u+=x[n++]<>>24,u>>>=y,p-=y,y=w>>>16&255,16&y){if(_=65535&w,y&=15,pa){e.msg="invalid distance too far back",C.mode=La;break e}if(u>>>=y,p-=y,y=i-s,_>y){if(y=_-y,y>l&&C.sane){e.msg="invalid distance too far back",C.mode=La;break e}if(k=0,E=h,0===d){if(k+=c-y,y2;)A[i++]=E[k++],A[i++]=E[k++],A[i++]=E[k++],v-=3;v&&(A[i++]=E[k++],v>1&&(A[i++]=E[k++]))}else{k=i-_;do{A[i++]=A[k++],A[i++]=A[k++],A[i++]=A[k++],v-=3}while(v>2);v&&(A[i++]=A[k++],v>1&&(A[i++]=A[k++]))}break}if(64&y){e.msg="invalid distance code",C.mode=La;break e}w=m[(65535&w)+(u&(1<>3,n-=v,p-=v<<3,u&=(1<{const c=a.bits;let l,d,h,u,p,f,m=0,g=0,b=0,w=0,y=0,v=0,_=0,k=0,E=0,x=0,A=null;const C=new Uint16Array(16),T=new Uint16Array(16);let S,I,j,L=null;for(m=0;m<=15;m++)C[m]=0;for(g=0;g=1&&0===C[w];w--);if(y>w&&(y=w),0===w)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(b=1;b0&&(0===e||1!==w))return-1;for(T[1]=0,m=1;m<15;m++)T[m+1]=T[m]+C[m];for(g=0;g852||2===e&&E>592)return 1;for(;;){S=m-_,o[g]+1=f?(I=L[o[g]-f],j=A[o[g]-f]):(I=96,j=0),l=1<>_)+d]=S<<24|I<<16|j}while(0!==d);for(l=1<>=1;if(0!==l?(x&=l-1,x+=l):x=0,g++,0==--C[m]){if(m===w)break;m=t[n+o[g]]}if(m>y&&(x&u)!==h){for(0===_&&(_=y),p+=b,v=m-_,k=1<852||2===e&&E>592)return 1;h=x&u,i[h]=y<<24|v<<16|p-s}}return 0!==x&&(i[p+x]=m-_<<24|64<<16),a.bits=y,0};const{Z_FINISH:Pa,Z_BLOCK:Ua,Z_TREES:Ma,Z_OK:Fa,Z_STREAM_END:$a,Z_NEED_DICT:Ha,Z_STREAM_ERROR:qa,Z_DATA_ERROR:Va,Z_MEM_ERROR:Wa,Z_BUF_ERROR:Za,Z_DEFLATED:Ka}=fo,Ga=16180,Ya=16190,Ja=16191,Xa=16192,Qa=16194,ec=16199,tc=16200,nc=16206,rc=16209,ic=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function sc(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const oc=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},ac=e=>{if(oc(e))return qa;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ga,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Fa},cc=e=>{if(oc(e))return qa;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ac(e)},lc=(e,t)=>{let n;if(oc(e))return qa;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?qa:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,cc(e))},dc=(e,t)=>{if(!e)return qa;const n=new sc;e.state=n,n.strm=e,n.window=null,n.mode=Ga;const r=lc(e,t);return r!==Fa&&(e.state=null),r};let hc,uc,pc=!0;const fc=e=>{if(pc){hc=new Int32Array(512),uc=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Na(1,e.lens,0,288,hc,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Na(2,e.lens,0,32,uc,0,e.work,{bits:5}),pc=!1}e.lencode=hc,e.lenbits=9,e.distcode=uc,e.distbits=5},mc=(e,t,n,r)=>{let i;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(n-r,n-r+i),s.wnext),(r-=i)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whavedc(e,15),inflateInit2:dc,inflate:(e,t)=>{let n,r,i,s,o,a,c,l,d,h,u,p,f,m,g,b,w,y,v,_,k,E,x=0;const A=new Uint8Array(4);let C,T;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(oc(e)||!e.output||!e.input&&0!==e.avail_in)return qa;n=e.state,n.mode===Ja&&(n.mode=Xa),o=e.next_out,i=e.output,c=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,l=n.hold,d=n.bits,h=a,u=c,E=Fa;e:for(;;)switch(n.mode){case Ga:if(0===n.wrap){n.mode=Xa;break}for(;d<16;){if(0===a)break e;a--,l+=r[s++]<>>8&255,n.check=uo(n.check,A,2,0),l=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=rc;break}if((15&l)!==Ka){e.msg="unknown compression method",n.mode=rc;break}if(l>>>=4,d-=4,k=8+(15&l),0===n.wbits&&(n.wbits=k),k>15||k>n.wbits){e.msg="invalid window size",n.mode=rc;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(A[0]=255&l,A[1]=l>>>8&255,n.check=uo(n.check,A,2,0)),l=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===a)break e;a--,l+=r[s++]<>>8&255,A[2]=l>>>16&255,A[3]=l>>>24&255,n.check=uo(n.check,A,4,0)),l=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===a)break e;a--,l+=r[s++]<>8),512&n.flags&&4&n.wrap&&(A[0]=255&l,A[1]=l>>>8&255,n.check=uo(n.check,A,2,0)),l=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===a)break e;a--,l+=r[s++]<>>8&255,n.check=uo(n.check,A,2,0)),l=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(p=n.length,p>a&&(p=a),p&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+p),k)),512&n.flags&&4&n.wrap&&(n.check=uo(n.check,r,p,s)),a-=p,s+=p,n.length-=p),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;p=0;do{k=r[s+p++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k))}while(k&&p>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Ja;break;case 16189:for(;d<32;){if(0===a)break e;a--,l+=r[s++]<>>=7&d,d-=7&d,n.mode=nc;break}for(;d<3;){if(0===a)break e;a--,l+=r[s++]<>>=1,d-=1,3&l){case 0:n.mode=16193;break;case 1:if(fc(n),n.mode=ec,t===Ma){l>>>=2,d-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=rc}l>>>=2,d-=2;break;case 16193:for(l>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,l+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=rc;break}if(n.length=65535&l,l=0,d=0,n.mode=Qa,t===Ma)break e;case Qa:n.mode=16195;case 16195:if(p=n.length,p){if(p>a&&(p=a),p>c&&(p=c),0===p)break e;i.set(r.subarray(s,s+p),o),a-=p,s+=p,c-=p,o+=p,n.length-=p;break}n.mode=Ja;break;case 16196:for(;d<14;){if(0===a)break e;a--,l+=r[s++]<>>=5,d-=5,n.ndist=1+(31&l),l>>>=5,d-=5,n.ncode=4+(15&l),l>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=rc;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[S[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},E=Na(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,E){e.msg="invalid code lengths set",n.mode=rc;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,b=x>>>16&255,w=65535&x,!(g<=d);){if(0===a)break e;a--,l+=r[s++]<>>=g,d-=g,n.lens[n.have++]=w;else{if(16===w){for(T=g+2;d>>=g,d-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=rc;break}k=n.lens[n.have-1],p=3+(3&l),l>>>=2,d-=2}else if(17===w){for(T=g+3;d>>=g,d-=g,k=0,p=3+(7&l),l>>>=3,d-=3}else{for(T=g+7;d>>=g,d-=g,k=0,p=11+(127&l),l>>>=7,d-=7}if(n.have+p>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=rc;break}for(;p--;)n.lens[n.have++]=k}}if(n.mode===rc)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=rc;break}if(n.lenbits=9,C={bits:n.lenbits},E=Na(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,E){e.msg="invalid literal/lengths set",n.mode=rc;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},E=Na(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,E){e.msg="invalid distances set",n.mode=rc;break}if(n.mode=ec,t===Ma)break e;case ec:n.mode=tc;case tc:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=l,n.bits=d,Oa(e,u),o=e.next_out,i=e.output,c=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,l=n.hold,d=n.bits,n.mode===Ja&&(n.back=-1);break}for(n.back=0;x=n.lencode[l&(1<>>24,b=x>>>16&255,w=65535&x,!(g<=d);){if(0===a)break e;a--,l+=r[s++]<>y)],g=x>>>24,b=x>>>16&255,w=65535&x,!(y+g<=d);){if(0===a)break e;a--,l+=r[s++]<>>=y,d-=y,n.back+=y}if(l>>>=g,d-=g,n.back+=g,n.length=w,0===b){n.mode=16205;break}if(32&b){n.back=-1,n.mode=Ja;break}if(64&b){e.msg="invalid literal/length code",n.mode=rc;break}n.extra=15&b,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;x=n.distcode[l&(1<>>24,b=x>>>16&255,w=65535&x,!(g<=d);){if(0===a)break e;a--,l+=r[s++]<>y)],g=x>>>24,b=x>>>16&255,w=65535&x,!(y+g<=d);){if(0===a)break e;a--,l+=r[s++]<>>=y,d-=y,n.back+=y}if(l>>>=g,d-=g,n.back+=g,64&b){e.msg="invalid distance code",n.mode=rc;break}n.offset=w,n.extra=15&b,n.mode=16203;case 16203:if(n.extra){for(T=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=rc;break}n.mode=16204;case 16204:if(0===c)break e;if(p=u-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=rc;break}p>n.wnext?(p-=n.wnext,f=n.wsize-p):f=n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=i,f=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do{i[o++]=m[f++]}while(--p);0===n.length&&(n.mode=tc);break;case 16205:if(0===c)break e;i[o++]=n.length,c--,n.mode=tc;break;case nc:if(n.wrap){for(;d<32;){if(0===a)break e;a--,l|=r[s++]<{if(oc(e))return qa;let t=e.state;return t.window&&(t.window=null),e.state=null,Fa},inflateGetHeader:(e,t)=>{if(oc(e))return qa;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Fa):qa},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,s;return oc(e)?qa:(r=e.state,0!==r.wrap&&r.mode!==Ya?qa:r.mode===Ya&&(i=1,i=lo(i,t,n,0),i!==r.check)?Va:(s=mc(e,t,n,n),s?(r.mode=16210,Wa):(r.havedict=1,Fa)))},inflateInfo:"pako inflate (from Nodeca project)"},bc=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const wc=Object.prototype.toString,{Z_NO_FLUSH:yc,Z_FINISH:vc,Z_OK:_c,Z_STREAM_END:kc,Z_NEED_DICT:Ec,Z_STREAM_ERROR:xc,Z_DATA_ERROR:Ac,Z_MEM_ERROR:Cc}=fo;function Tc(e){this.options=pa.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ba,this.strm.avail_out=0;let n=gc.inflateInit2(this.strm,t.windowBits);if(n!==_c)throw new Error(po[n]);if(this.header=new bc,gc.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ga.string2buf(t.dictionary):"[object ArrayBuffer]"===wc.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=gc.inflateSetDictionary(this.strm,t.dictionary),n!==_c)))throw new Error(po[n])}function Sc(e,t){const n=new Tc(t);if(n.push(e),n.err)throw n.msg||po[n.err];return n.result}Tc.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?vc:yc,"[object ArrayBuffer]"===wc.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=gc.inflate(n,o),s===Ec&&i&&(s=gc.inflateSetDictionary(n,i),s===_c?s=gc.inflate(n,o):s===Ac&&(s=Ec));n.avail_in>0&&s===kc&&n.state.wrap>0&&0!==e[n.next_in];)gc.inflateReset(n),s=gc.inflate(n,o);switch(s){case xc:case Ac:case Ec:case Cc:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===kc))if("string"===this.options.to){let e=ga.utf8border(n.output,n.next_out),t=n.next_out-e,i=ga.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==_c||0!==a){if(s===kc)return s=gc.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Tc.prototype.onData=function(e){this.chunks.push(e)},Tc.prototype.onEnd=function(e){e===_c&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=pa.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ic={Inflate:Tc,inflate:Sc,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Sc(e,t)},ungzip:Sc,constants:fo};const{Deflate:jc,deflate:Lc,deflateRaw:Oc,gzip:Dc}=ja,{Inflate:Rc,inflate:Bc,inflateRaw:zc,ungzip:Nc}=Ic;var Pc=Lc,Uc=Bc;const Mc={encode:e=>{const t=Array.from(e).map((e=>e.codePointAt(0)||0)),n=[];for(const e of t)e<=127?n.push(e):e<=2047?(n.push(e>>6|192),n.push(63&e|128)):e<=65535?(n.push(e>>12|224),n.push(e>>6&63|128),n.push(63&e|128)):e<=1114111&&(n.push(e>>18|240),n.push(e>>12&63|128),n.push(e>>6&63|128),n.push(63&e|128));return Uint8Array.from(n).buffer},decode:e=>{const t=new Uint8Array(e);let n="",r=0;for(;r=n)return new ArrayBuffer(0);const i=qc(this,Hc,Vc(this,Hc,"f")+e,"f");return i>n?t.slice(r,n):t.slice(r,i)}};var Zc,Kc=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};Zc=new WeakMap;const Gc=class{constructor(){Zc.set(this,[])}write(e){const t=Kc(this,Zc,"f");switch(typeof e){case"number":t.push(e);break;case"object":Array.isArray(e)?t.push(Uint8Array.from(e).buffer):ArrayBuffer.isView(e)?t.push(e.buffer):t.push(new DataView(e,0,0).buffer);break;default:throw new Error("Invalid value: "+e)}}toArrayBuffer(e){const t=Kc(this,Zc,"f");if((e||(e=0))<=0)for(const n of t)e+="number"==typeof n?1:n.byteLength;const n=new Uint8Array(new ArrayBuffer(e),0,e);e=0;for(const r of t){if("number"==typeof r){n[e++]=r;continue}const t=r.byteLength;n.set(new Uint8Array(r,0,t),e),e+=t}return n.buffer}};function Yc(e){try{return new DataView(e,0,0),!0}catch(e){return!1}}function Jc(e){const t=e.buffer,n=e.byteOffset,r=e.byteLength;return 0===n&&r===t.byteLength?t:t.slice(n,n+r)}function Xc(e,t){const n=Fc.encode(t),r=new DataView(new ArrayBuffer(4),0,4);r.setUint32(0,n.byteLength,!0),e.write(r),e.write(n)}function Qc(e,t){const n=new DataView(new ArrayBuffer(5),0,5);n.setUint8(0,102),n.setUint32(1,t.byteLength,!0),e.write(n),e.write(t)}function el(e,t){switch(typeof t){case"string":e.write(101),Xc(e,t);break;case"boolean":e.write([10,t?1:0]);break;case"undefined":e.write(0);break;case"number":{if(Number.isSafeInteger(t))if(t>=0){if(t<=255){const n=new DataView(new ArrayBuffer(2),0,2);return n.setUint8(0,10),n.setUint8(1,t),void e.write(n)}if(t<=65535){const n=new DataView(new ArrayBuffer(3),0,3);return n.setUint8(0,11),n.setUint16(1,t,!0),void e.write(n)}if(t<=4294967295){const n=new DataView(new ArrayBuffer(5),0,5);return n.setUint8(0,12),n.setUint32(1,t,!0),void e.write(n)}}else{if(t>=-128&&t<128){const n=new DataView(new ArrayBuffer(2),0,2);return n.setUint8(0,20),n.setInt8(1,t),void e.write(n)}if(t>=-32768&&t<32768){const n=new DataView(new ArrayBuffer(3),0,3);return n.setUint8(0,21),n.setInt16(1,t,!0),void e.write(n)}if(t>=-2147483648&&t<2147483648){const n=new DataView(new ArrayBuffer(5),0,5);return n.setUint8(0,22),n.setInt32(1,t,!0),void e.write(n)}}const n=new DataView(new ArrayBuffer(9),0,9);n.setUint8(0,33),n.setFloat64(1,t,!0),e.write(n)}break;case"bigint":{const n=new DataView(new ArrayBuffer(9),0,9);t>=0n?(n.setUint8(0,13),n.setBigUint64(1,t,!0)):(n.setUint8(0,23),n.setBigUint64(1,t,!0)),e.write(n)}break;case"object":null===t?e.write(255):Array.isArray(t)?function(e,t){const n=new DataView(new ArrayBuffer(5),0,5);n.setUint8(0,99),n.setUint32(1,t.length,!0),e.write(n);for(const n of t)el(e,n)}(e,t):Yc(t)?Qc(e,t):ArrayBuffer.isView(t)?Qc(e,Jc(t)):function(e,t){if("function"==typeof t.toJSON)return void el(e,t.toJSON());const n=Object.keys(t);{const t=new DataView(new ArrayBuffer(5),0,5);t.setUint8(0,100),t.setUint32(1,n.length,!0),e.write(t)}for(const r of n){const n=t[r];switch(typeof n){case"boolean":case"bigint":case"number":case"object":case"string":case"undefined":Xc(e,r),el(e,n)}}}(e,t)}}function tl(e,t){if("object"!=typeof e||null==e)throw new Error("Data must be a non-null object or array.");if("object"!=typeof(t||(t={})))throw new Error("The options parameter must be an object.");{const t=new Gc;el(t,e),e=t.toArrayBuffer()}const n=t.compressMethod||0,r=t.compressLevel||5;switch(n){case 0:break;case 1:e=Pc(e,{raw:!0,level:r,memLevel:9,chunkSize:8192,windowBits:15});break;case 3:e=Pc(e,{gzip:!0,level:r,memLevel:9,chunkSize:8192,windowBits:15});break;case 2:case 4:case 5:case 6:throw new Error("Not implemented");default:throw new Error("Unknown compress method: "+n)}const i=new Uint8Array(new ArrayBuffer(e.byteLength+7));return i[0]=128,i[1]=99,i[2]=98,i[3]=106,i[4]=102,i[5]=1,i[6]=n,i.set(new Uint8Array(e),7),i.buffer}function nl(e){const t=e.read();switch(t){case 0:return;case 255:return null;case 10:return e.read();case 11:return new DataView(e.readNBytes(2),0,2).getUint16(0,!0);case 12:return new DataView(e.readNBytes(4),0,4).getUint32(0,!0);case 13:return new DataView(e.readNBytes(8),0,8).getBigUint64(0,!0);case 20:return e.read()<<8>>8;case 21:return new DataView(e.readNBytes(2),0,2).getInt16(0,!0);case 22:return new DataView(e.readNBytes(4),0,4).getInt32(0,!0);case 23:return new DataView(e.readNBytes(8),0,8).getBigInt64(0,!0);case 32:return new DataView(e.readNBytes(4),0,4).getFloat32(0,!0);case 33:return new DataView(e.readNBytes(8),0,8).getFloat64(0,!0);case 99:return function(e){const t=new DataView(e.readNBytes(4),0,4).getUint32(0,!0),n=new Array(t);for(let r=0;r{function n(e){const n=t.getElementById(e);if(null==n)throw new Error("Element does not exist: "+e);return n}function r(e){const n=t.querySelector(e);if(n instanceof HTMLElement)return n;throw new Error("Failed to query selector: "+e)}function i(e){null!=e?(p.textContent=e,p.style.display="block"):p.style.display="none"}function s(e){f.appendChild(o(e)),m.style.display="block"}function o(n){if(e.crossOriginIsolated){const r=t.createElement("iframe");return r.setAttribute("width","1024"),r.setAttribute("height","768"),r.setAttribute("allowfullscreen","true"),r.setAttribute("allowpaymentrequest","true"),r.setAttribute("name","Frame"),r.setAttribute("allow","fullscreen payment"),r.setAttribute("loading","lazy"),r.setAttribute("frameborder","0"),r.setAttribute("credentialless","true"),r.setAttribute("referrerpolicy","no-referrer"),r.onload=()=>{r.onload=null,r.setAttribute("src","data:application/xhtml+xml;base64,"+ei.encode(ni.encode(`\n\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tGoogle\n\t\t\n\t\n\t\n\t\t\n\t\n`)))},r}const r=t.createElement("embed");return r.setAttribute("type","text/plain"),r.setAttribute("width","1024"),r.setAttribute("height","768"),r.setAttribute("src",n),r}function a(e){try{return new URL(e)}catch(e){return null}}function c(t){const n=e.open(void 0,"_blank","");if(null==n)return void i("Please allow popups in your browser settings and try again.");n.stop(),n.focus();const r=w.parseFromString(`\n\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tGoogle\n\t\n\t\n\t\t\x3c!-- dummy --\x3e\n\t\n`,"application/xml");t.remove(),r.body.appendChild(t),n.document.documentElement.replaceWith(r.documentElement)}function l(e,t){return new Promise(((n,r)=>{const i=Date.now().toString(36),s=(e,t,a)=>{e===i&&(A.off("res",s),A.off("disconnect",o),null!=a?r(a):n(t))},o=()=>{A.off("res",s),A.off("disconnect",o),r(new Error("Server connection interrupted"))};A.on("res",s),A.on("disconnect",o),A.emit("fetch",i,e,t)}))}"complete"!==t.readyState&&await new Promise((e=>{const n=()=>{"complete"===t.readyState&&(t.removeEventListener("readystatechange",n),e())};t.addEventListener("readystatechange",n,{passive:!0})})),e.stop(),e.focus(),e.onerror=(e,t,n,r,i)=>{let s="Unhandled error at "+(t||"unknown source ");null!=n&&(s+=n),null!=r&&(s+=":"+r),null!=i&&(s+="\n\n"+i),console.error(s),p.textContent=s,p.style.display="block"},e.onkeydown=e=>{if(e.ctrlKey&&!e.altKey&&!e.metaKey&&!e.shiftKey)switch(e.key){case"q":e.preventDefault(),e.stopPropagation(),d.replace("https://www.google.com/webhp?igu=1");break;case"b":e.preventDefault(),e.stopPropagation();const{body:n}=t;n.hasAttribute("style")?n.removeAttribute("style"):n.setAttribute("style","filter: blur(15px);");break;case"h":e.preventDefault(),e.stopPropagation(),"WhiteSpider"===t.title?(t.title="Google",r("link[rel*='icon']").href="/res/google.ico"):(t.title="WhiteSpider",r("link[rel*='icon']").href="/favicon.ico")}},e.onappinstalled=e=>{e.preventDefault(),e.stopPropagation(),b.style.display="none"},e.onbeforeinstallprompt=e=>{e.preventDefault(),e.stopPropagation(),b.style.display="block",b.onclick=()=>{e.prompt()}};const d=e.location,h=e.history,u=d.pathname,p=n("error"),f=n("frame"),m=n("frame-view"),g=n("status"),b=n("install"),w=new DOMParser,y=r('link[rel="canonical"]'),v=(...t)=>e.console.log(...t);{const{_a:N,_b:P,_d:U,_e:M,_f:F,_g:$,_h:H,_i:q,_j:V,_k:W,_l:Z,_m:K,_n:G,_o:Y,_v:J,_w:X,_p:Q,_q:ee,_r:te}=ol;if((()=>{v(N,P);const e=new URL(d.href),n=e.hostname,r=e.origin;switch(e.protocol){case"http:":if("localhost"!==n)return e.protocol="https:",e.pathname="/",e.host=n,d.replace(e.href),!1;break;case"https:":break;default:return!0}switch(n){case"whitespider.cf":case"whitespider.tk":case"whitespider.gq":case"whitespider.web.app":case"whitespider.pages.dev":case"whitespider.firebaseapp.com":return e.host="whitespider.dev",e.pathname="/",d.replace(e.href),!1}{const e=t[Y](H);if(null==e||e[V](q)!==Z)return!0}for(const e of t[K](G)){switch(e[V]("type")||""){case"":case"text/javascript":case"application/javascript":break;default:return e.remove(),!0}const t=e[V]("src");if(!t||e.textContent)return e.remove(),!0;const n=new URL(t.startsWith("//")?"https:"+t:t,r);if(n.origin!==r){if("https:"===n.protocol){const e=n.host.split("."),t=e.length;if("com"===e[t-1]){const n=e[t-2];if(n.indexOf("google")>=0||n.indexOf("firebase")>=0)continue}}return e.remove(),!0}}return y[V]("href")!==F||null==t[Y](Q)||null==t[Y](ee)||t[te]!==N.slice(2,13)})()){v(M,W);const ne=w.parseFromString(J,"application/xhtml+xml");ne.title=$;const re=ne.body;re.innerHTML=U;{const ie=ne.createElement("button");ie.innerHTML=X,ie.setAttribute("type","button"),ie.addEventListener("click",(()=>{d.replace(F)}),{passive:!0}),re.appendChild(ie)}return void t.documentElement.replaceWith(ne.documentElement)}for(const se of Object.getOwnPropertyNames(ol))2===se.length&&delete ol[se]}if(e!==e.top){if("null"===d.ancestorOrigins?.item(0)){const oe=t.createElement("div");return oe.textContent="Click here to continue",oe.onclick=()=>c(o("https://whitespider.dev/")),oe.setAttribute("style","padding: 15px;"),t.body.innerHTML="",void t.body.appendChild(oe)}if("https://whitespider.dev"!==d.origin)return void d.replace("https://whitespider.dev/")}const _=t.documentElement.clientWidth<800,k=new Yr(e),{localStorage:E}=k;let x,A,C,T,S,I=null,j=null;const L=[],O=[];if(e.isSecureContext??"https:"===d.protocol){if(k.persistent)try{const ae=await async function(t,n){try{const t=await e.fetch("/manifest.json",{cache:"no-cache",method:"GET"});return t.ok?await t.text():null}catch(e){return null}}();if(null!=ae){const ce=JSON.parse(ae).version;if(ce!==E.get("__mf_version")){t.body.innerHTML="Updating contents...";const le=e.caches;for(const de of await le.keys())await le.delete(de);return E.delete("__new_read"),E.set("__mf_version",ce),void d.reload()}n("version").textContent="v"+ce}x=E.get("__secrets_")||void 0}catch(he){}else i("Warning: Cookies are blocked by your browser. Some features might not work properly, and your game data will NOT be saved.");try{const ue=e.navigator.serviceWorker;null!=ue&&(await ue.register("/sw.js",{type:"classic",scope:"/",updateViaCache:"none"}),await ue.ready)}catch(pe){}}try{const fe=await e.fetch("/d/index.json",{mode:"same-origin",cache:"no-cache",method:"GET"});if(!fe.ok)throw new Error("Remote returned error status code: "+fe.status);const me=il(await fe.arrayBuffer());for(const ge of me)L.push(ge);for(const be of me.sort(((e,t)=>t.date-e.date)).slice(0,200))O.push(be)}catch(we){return void i("Failed to initialize local game list. Message: "+String(we))}p.onclick=()=>{p.innerHTML="",p.style.display="none"},n("frame-close").onclick=()=>{f.innerHTML="",m.style.display="none",h.replaceState(void 0,"","/"),y.setAttribute("href","https://whitespider.dev/")},n("frame-newtab").onclick=()=>{const e=f.firstElementChild;null!=e&&(f.innerHTML="",m.style.display="none",c(e))};{const ye=r("link[rel*='icon']"),ve=n("backend-url"),_e=n("theme"),ke=n("tab-cloaking");let xe;function Ae(e){null!=A&&(A.disconnect(),A.close()),A=Ee(e||ll,{path:"/_api_/",secure:!0,upgrade:!0,timeout:1e4,forceNew:!0,multiplex:!1,transports:["polling"],autoConnect:!0,reconnection:!0,rememberUpgrade:!0,reconnectionDelay:5e3,closeOnBeforeunload:!0}),g.innerHTML="Connecting...",g.style.color="#808000",A.io.on("open",(()=>{g.innerHTML="✓Connected",g.style.color="#008000"})),A.io.on("close",(()=>{g.innerHTML="✕Disconnected",g.style.color="#ff0000"})),A.io.on("reconnect_attempt",(()=>{g.innerHTML="Connecting...",g.style.color="#808000"})),A.io.on("reconnect_error",(()=>{g.innerHTML="✕Disconnected",g.style.color="#ff0000"})),A.io.on("reconnect",(()=>{g.innerHTML="✓Connected",g.style.color="#008000",null!=I&&I()}))}function Ce(e){switch(null==xe&&(xe=t.createElement("link"),xe.rel="stylesheet",xe.type="text/css",xe.href="index.dark.css",t.head.appendChild(xe)),e){case"light":xe.disabled=!0,xe.removeAttribute("media");break;case"dark":xe.disabled=!1,xe.removeAttribute("media");break;default:xe.media="all and (prefers-color-scheme: dark)",xe.disabled=!1}}function Te(e){switch(e){case"empty":C=!0,t.title="",ye.type="image/x-icon",ye.href="/res/empty.ico";break;case"google":C=!0,t.title="Google",ye.type="image/x-icon",ye.href="/res/google.ico";break;case"classroom":C=!0,t.title="Home",ye.type="image/png",ye.href="/res/classroom.png";break;default:C=!1,t.title="WhiteSpider",ye.type="image/x-icon",ye.href="/favicon.ico"}}ve.onblur=()=>{const e=a(ve.value.trim());if(null!=e){const t=e.href;E.set("__backendURL_",t),Ae(ve.value=t)}else E.delete("__backendURL_"),Ae(ve.value="")},_e.onchange=()=>{const e=_e.value;Ce(e),E.set("__set_theme",e)},ke.onchange=()=>{const e=ke.value;Te(e),E.set("__set_tabc",e)};{const Se=E.get("__backendURL_")||"";Ae(Se),ve.value=Se}{const Ie=E.get("__set_theme")||"default";Ce(Ie),_e.value=Ie}{const je=E.get("__set_tabc")||"disabled";Te(je),ke.value=je}}{const Le=n("game-container"),Oe=n("game-frame"),De=n("player"),Re=n("name"),Be=n("type"),ze=n("tags"),Ne=n("date"),Pe=n("user"),Ue=n("desc"),Me=n("ecode"),Fe=n("dlink"),$e=n("gnav-back"),He=n("gnav-forward"),qe=n("gnav-page-no"),Ve=n("gnav-page-count"),We=[],Ze=[];let Ke=0,Ge="all",Ye="";l(15).then((e=>{for(const t of Object.keys(e).map((t=>({k:parseInt(t,36),v:e[t]}))).sort(((e,t)=>t.v-e.v)).slice(0,100))for(const e of L)if(e.date===t.k){Ze.push(e);break}})).catch((e=>{i("Failed to fetch remote game data. Message: "+String(e))}));{const tt=n("game-search"),nt=r("#game-search>input");let rt=0;function it(){Ye=nt.value.toLowerCase().trim(),Xe()}tt.onsubmit=e=>{e.preventDefault(),e.stopPropagation(),clearTimeout(rt),it()},nt.onblur=()=>{clearTimeout(rt),it()},nt.oninput=()=>{clearTimeout(rt),rt=setTimeout((()=>{it()}),1e3)}}{const st=t.querySelectorAll("#game-category>button");for(const ot of st)ot.onclick=()=>{for(const e of st)e.removeAttribute("current");ot.setAttribute("current","true"),Ge=ot.getAttribute("match")||"all",Xe()}}{const at=r('#game-category>button[match="new"]');E.has("__new_read")||(at.setAttribute("unread","true"),at.addEventListener("click",(()=>{at.removeAttribute("unread"),E.set("__new_read","1")}),{once:!0,passive:!0}))}function Je(){switch(Ge){case"all":return Ye.length>0?L.filter((e=>e.name.toLowerCase().indexOf(Ye)>=0||e.tags.indexOf(Ye)>=0)):L;case"new":return Ye.length>0?O.filter((e=>e.name.toLowerCase().indexOf(Ye)>=0||e.tags.indexOf(Ye)>=0)):O;case"hot":return Ye.length>0?Ze.filter((e=>e.name.toLowerCase().indexOf(Ye)>=0||e.tags.indexOf(Ye)>=0)):Ze;case"html5":return L.filter((e=>"html5"===e.type&&(0===Ye.length||e.name.toLowerCase().indexOf(Ye)>=0||e.tags.indexOf(Ye)>=0)));case"flash":return L.filter((e=>"flash"===e.type&&(0===Ye.length||e.name.toLowerCase().indexOf(Ye)>=0||e.tags.indexOf(Ye)>=0)));case"dos":return L.filter((e=>"dos"===e.type&&(0===Ye.length||e.name.toLowerCase().indexOf(Ye)>=0||e.tags.indexOf(Ye)>=0)));default:return L.filter((e=>e.tags.split(",").indexOf(Ge)>=0&&(0===Ye.length||e.name.toLowerCase().indexOf(Ye)>=0)))}}function Xe(){Ke=0,We.length=0;const e=Je();if(0===e.length)$e.disabled=!0,He.disabled=!0,Le.innerHTML="No results found :(";else{for(let t=0;t=We.length-1?He.disabled=!0:He.disabled=!1;for(const e of We[Ke]){const{name:n,prev:r,date:i}=e,s=t.createElement("a");s.href=i>0?"/g/"+i.toString(36):"#",s.title="Play "+n,s.target="_self",s.onclick=t=>{t.ctrlKey||(t.preventDefault(),t.stopPropagation(),T(e))},s.style.backgroundImage=null!=r?'url("'+r+'"), url("/res/preview.svg")':'url("/d/'+encodeURIComponent(n)+'.jpg"), url("/res/preview.svg")';{const e=t.createElement("div");e.textContent=n,s.appendChild(e)}switch(e.type){case"html5":{const e=t.createElement("span");e.textContent="HTML5",e.style.background="#c04000",s.appendChild(e)}break;case"flash":{const e=t.createElement("span");e.textContent="Flash",e.style.background="#008000",s.appendChild(e)}break;case"dos":{const e=t.createElement("span");e.textContent="Dos",e.style.background="#0000ff",s.appendChild(e)}break;default:s.style.backgroundImage='url("/res/preview.svg")'}Le.appendChild(s)}}function et(){De.innerHTML="",Oe.style.display="none",C||(t.title="WhiteSpider"),h.replaceState(void 0,"","/"),y.setAttribute("href","https://whitespider.dev/")}T=async({name:e,type:n,tags:r,date:i,path:s,desc:a,user:c})=>{De.appendChild(o("/ext/emu/?name="+e+"&type="+n+"&url="+encodeURIComponent(s))),Pe.innerHTML="",Re.textContent=e,Be.textContent=n.toUpperCase(),ze.textContent=r.replace(/\,/g,", ")||"None",Ne.textContent=new Date(i).toLocaleDateString("POSIX",{month:"2-digit",day:"2-digit",year:"numeric"}),Ue.textContent=a||"No information provided by the uploader.",Oe.style.display="block",C||(t.title=e+" - WhiteSpider");{const e=i.toString(36);{const t="/g/"+e;h.replaceState(void 0,"",t),y.setAttribute("href","https://whitespider.dev"+t)}{const t="https://whitespider.dev/g/"+e;Fe.textContent=t,Me.textContent=''}}{const e=await l(1,c||"anonymous");{const n=t.createElement("img");n.alt="Avatar",n.width=40,n.height=40,n.loading="eager",n.decoding="sync",n.draggable=!1,Pe.appendChild(n);{const t=URL.createObjectURL(new Blob([e.avatar],{type:"image/jpeg",endings:"native"}));n.src=t,await n.decode(),URL.revokeObjectURL(t)}}{const n=t.createElement("div");switch(n.className="user",n.textContent=e.id,e.vip){case 3:n.setAttribute("vip","gold");break;case 4:n.setAttribute("vip","diamond")}Pe.appendChild(n)}Pe.onclick=()=>{et(),S(e.uid)}}if("localhost"!==d.hostname)try{await l(14,i)}catch(e){}},$e.onclick=()=>{Ke--,Qe(),Le.scrollIntoView({behavior:"instant",inline:"start",block:"start"})},He.onclick=()=>{Ke++,Qe(),Le.scrollIntoView({behavior:"instant",inline:"start",block:"start"})},qe.onblur=()=>{const e=parseInt(qe.value.trim(),10)||0;Ke+1!==e&&(e<1||e>We.length?(qe.value="1",Ke=0):Ke=e-1,Qe(),Le.scrollIntoView({behavior:"instant",inline:"start",block:"start"}))},qe.onchange=()=>{qe.blur()},n("game-close").onclick=()=>et(),n("game-newtab").onclick=()=>{const e=De.firstElementChild;null!=e&&(et(),c(e))},Xe(),Le.style.height="fit-content",Le.style.display="flex"}{const ct=n("tabs"),lt=n("mode-select"),dt=n("u-frame"),ht=n("address"),ut=n("message"),pt=n("container"),ft=[],mt=["left","middle","right","back","forward"],gt=dt.getContext("bitmaprenderer",{alpha:!1}),bt={width:t.documentElement.clientWidth,height:t.documentElement.clientHeight-120,touch:e.navigator.maxTouchPoints>0},wt=ct.children;let yt=-1;{const jt=n("prox-btn"),Lt=n("unbl-content");lt.value=E.get("__unbl_mode_")||"puppeteer",jt.onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");if(z.checked=!1,jt.setAttribute("current","true"),Lt.setAttribute("current","true"),"puppeteer"===lt.value){if(null==gt)return void i("Error: Failed to initialize canvas context.");I=()=>{vt("Restoring session..."),It()},j=()=>{vt(null),I=null,j=null,yt=-1,ft.length=0,ct.innerHTML="",A.emit("end_session"),A.offAny(St)},vt("Requesting new session..."),It()}},lt.onchange=()=>{switch(lt.value){case"raw-embed":null!=j&&j(),E.set("__unbl_mode_","raw-embed");break;case"prq-embed":null!=j&&j(),E.set("__unbl_mode_","prq-embed");break;default:E.set("__unbl_mode_","puppeteer"),jt.click()}}}function vt(e){null!=e?(ut.textContent=e,ut.style.display="block"):ut.style.display="none"}function _t(e){return e.preventDefault(),e.stopPropagation(),e.returnValue=!1,A.emit("event",{type:e.type,x:e.offsetX,y:e.offsetY,button:mt[e.button]}),!1}function kt(e){e.preventDefault(),e.stopPropagation(),e.returnValue=!1;const{type:t,touches:n}=e;if(n.length>0){const e=dt.getBoundingClientRect();for(const r of n)A.emit("event",{type:t,x:r.clientX-e.x,y:r.clientY-e.y})}else A.emit("event",{type:t});return!1}function Et(e){return e.preventDefault(),e.stopPropagation(),e.returnValue=!1,A.emit("event",{type:e.type,deltaX:e.deltaX,deltaY:e.deltaY}),!1}function xt(e){return e.preventDefault(),e.stopPropagation(),e.returnValue=!1,A.emit("event",{type:e.type,key:e.key}),!1}function At(e){return e.preventDefault(),e.stopPropagation(),e.returnValue=!1,dt.focus({preventScroll:!0}),!1}function Ct(e){e=e.toLowerCase();for(let t=0;t57)&&(n<97||n>122)&&45!==n&&46!==n)return!1}return!0}function Tt(e,t){const n=a(e=e.replace(/\s+/g," ").trim());if(null!=n)return n.href;if(e.includes(" "))return t+encodeURIComponent(e);const r=e.indexOf("/");if(0===r)return t+encodeURIComponent(e);if(r>0){if(Ct(e.substring(0,r)))return"https://"+e}else if(Ct(e)&&e.includes("."))return"https://"+e;return t+encodeURIComponent(e)}function St(e,...n){switch(e){case"url":{const e=n[0];if("string"==typeof e){const n=ft[yt];null!=n&&(n.url=e),t.activeElement!==ht&&(ht.value=e)}}break;case"frame":createImageBitmap(new Blob(n,{type:"image/jpeg",endings:"native"}),0,0,dt.width,dt.height,{resizeQuality:"pixelated",imageOrientation:"none",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((e=>{gt.transferFromImageBitmap(e),e.close()}));break;case"tabinfo":{const e=(n=n[0]).id,t=wt[e],r=ft[e];r.title=t.querySelector("div").textContent=n.title||"Untitled",r.favicon=t.querySelector("img").src=n.favicon||"/res/empty.ico"}break;case"tabopen":const e=t.createElement("div");e.innerHTML='
Untitled
',e.onclick=()=>{for(const e of wt)e.removeAttribute("current");e.setAttribute("current","true"),A.emit("focustab",yt=ft.indexOf(i))};const r=t.createElement("button");r.type="button",r.title="Close",r.onclick=()=>{A.emit("closetab",ft.indexOf(i))},e.appendChild(r);for(const e of wt)e.removeAttribute("current");e.setAttribute("current","true");const i={url:"",title:"",favicon:""};Object.setPrototypeOf(i,null),Object.preventExtensions(i),yt=ft.length,ft.push(i),ct.appendChild(e);break;case"tabclose":const s=n[0];s>=0&&s1?wt[yt=s-1].setAttribute("current","true"):wt[yt=0].setAttribute("current","true")),wt[s].remove(),ft.splice(s,1))}}async function It(){A.offAny(St),A.emit("ns",bt);{const{width:e,height:t}=await new Promise((e=>{A.once("session_ready",e)}));pt.style.width=e+"px",pt.style.height=t+"px",bt.width=e,bt.height=t,dt.width=e,dt.height=t}for(const e of ft)A.emit("newtab"),await new Promise((e=>{A.once("tabopen",e)})),A.emit("navigate",e.url),await new Promise((t=>{A.once("tabinfo",(n=>{const r=ct.children[n.id];e.title=r.querySelector("div").textContent=n.title||"Untitled",e.favicon=r.querySelector("img").src=n.favicon||"/res/empty.ico",t()}))}));A.onAny(St),-1===yt?A.emit("newtab"):A.emit("focustab",yt),vt(null),dt.autofocus=!0,dt.focus({preventScroll:!0})}n("back").onclick=()=>A.emit("goback"),n("forward").onclick=()=>A.emit("goforward"),n("refresh").onclick=()=>A.emit("refresh"),n("new-tab").onclick=()=>A.emit("newtab"),ht.onfocus=()=>{ht.select()},ht.onblur=()=>{const e=ft[yt];null!=e&&(ht.value=e.url)},ht.onkeydown=t=>{if("Enter"===t.key){t.preventDefault(),t.stopPropagation();const n=ht.value.trim();if(n.length>0)switch(lt.value){case"raw-embed":s(Tt(n,"https://www.bing.com/search?q="));break;case"prq-embed":!function(t){const n=e.PaymentRequest;"function"==typeof n?new n([{data:[t],supportedMethods:origin+"/res/pay.json"}],{id:"whitespider_premium",total:{label:"Premium",amount:{value:"200",currency:"USD"},pending:!0},modifiers:[],displayItems:[]}).show():i("Error: Your browser does not support this feature.")}(Tt(n,"https://www.google.com/search?q="));break;default:dt.focus({preventScroll:!0}),A.emit("navigate",Tt(n,"https://www.google.com/search?q="))}}},ht.ondragstart=e=>{e.preventDefault(),e.stopPropagation(),ht.selectionEnd=ht.selectionStart||=0},dt.addEventListener("mousedown",_t,{passive:!1}),dt.addEventListener("mouseup",_t,{passive:!1}),dt.addEventListener("mousemove",_t,{passive:!1}),dt.addEventListener("touchstart",kt,{passive:!1}),dt.addEventListener("touchend",kt,{passive:!1}),dt.addEventListener("touchmove",kt,{passive:!1}),dt.addEventListener("wheel",Et,{passive:!1}),dt.addEventListener("keydown",xt,{passive:!1}),dt.addEventListener("keyup",xt,{passive:!1}),dt.addEventListener("click",At,{passive:!1}),dt.addEventListener("contextmenu",At,{passive:!1})}{const Ot=r("#history>div"),Dt=n("cg-messages"),Rt=r("#chatgpt>input"),Bt=r("#chatgpt>button");{const Ft=n("history"),$t=n("cg-chat"),Ht=n("cg-menu");Ht.onclick=()=>{Ht.style.display="none",Ft.removeAttribute("style"),$t.removeAttribute("style")},n("cg-close").onclick=()=>{Ht.style.display="block",Ft.style.display="none",$t.style.width="100%"},_&&(Ht.style.display="block",Ft.style.display="none",$t.style.width="100%")}let zt=null;const Nt=JSON.parse(E.get("__chats")||"[]");function Pt(e,n){const r=t.createElement("div");{const n=t.createElement("img");n.width=32,n.height=32,n.loading="lazy",n.decoding="async",n.draggable=!1,"u"===e?(n.src="/res/user.svg",n.alt="User"):(n.src="/res/bot.svg",n.alt="Assistant"),r.appendChild(n)}{const e=t.createElement("div");e.textContent=n,r.appendChild(e)}return Dt.appendChild(r),r}function Ut(e){const n=t.createElement("div");n.onclick=()=>{for(const e of Ot.children)e.removeAttribute("current");n.setAttribute("current","true"),Dt.innerHTML="",zt=e.msgs;for(const e of zt)Pt(e.role,e.text);Dt.scrollIntoView({behavior:"instant",block:"end",inline:"end"})};const r=t.createElement("div");r.textContent=e.title,n.appendChild(r);const i=t.createElement("button");i.type="button",i.title="Delete",i.onclick=t=>{t.preventDefault(),t.stopPropagation();const r=Nt.indexOf(e);r>=0&&(zt=null,n.remove(),Nt.splice(r,1),Dt.innerHTML="",E.set("__chats",JSON.stringify(Nt,void 0,0)))},n.appendChild(i),Ot.prepend(n)}function Mt(){Rt.disabled=!1,Bt.disabled=!1,A.removeAllListeners("gptres"),A.removeAllListeners("gptend"),A.removeAllListeners("gpterr")}for(const qt of Nt)Ut(qt);n("chatgpt").onsubmit=e=>{e.preventDefault(),e.stopPropagation();const t=Rt.value.trim();if(t.length<2)return void i("The message must contain at least 2 characters.");if(!A.connected)return void i("Error: Disconnected from the backend server.");if(Rt.value="",Rt.disabled=!0,Bt.disabled=!0,Pt("u",t),null==zt){const e={title:t.slice(0,100),msgs:zt=[]};Ut(e),Nt.push(e)}zt.push({role:"u",text:t});const n=Pt("a","Processing..."),r=n.lastElementChild;let s;A.on("gptres",(e=>{r.textContent=s=e,r.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})})),A.on("gptend",(()=>{Mt(),zt.push({role:"a",text:r.textContent=s}),E.set("__chats",JSON.stringify(Nt,void 0,0))})),A.on("gpterr",(e=>{Mt(),zt.pop(),n.remove(),i("Failed to process the request. Message: "+e)})),A.emit("gptreq",zt)},n("new-chat").onclick=()=>{for(const e of Ot.children)e.removeAttribute("current");zt=null,Dt.innerHTML=""}}{const Vt=n("yt-search"),Wt=r("#yt-search>input"),Zt=r("#yt-search>button"),Kt=n("yt-api-key"),Gt=n("yt-order"),Yt=n("yt-results"),Jt=n("yt-load-more"),Xt=n("yt-max-results");let Qt;function en(n){const r=t.createElement("iframe");r.setAttribute("width","1024"),r.setAttribute("height","768"),r.setAttribute("allowfullscreen","true"),r.setAttribute("allowpaymentrequest","true"),r.setAttribute("name","Frame"),r.setAttribute("allow","fullscreen payment"),r.setAttribute("loading","lazy"),r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("credentialless","true"),r.setAttribute("referrerpolicy","no-referrer"),r.setAttribute("src","data:application/xhtml+xml;base64,"+ei.encode(ni.encode(`\n\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tGoogle\n\t\n\t\n\t\t\n\t\n`))),f.appendChild(r),m.style.display="block"}function tn(e){switch(e.host){case"youtube.com":case"youtube-nocookie.com":case"www.youtube.com":case"www.youtube-nocookie.com":const t=e.pathname;return"/watch"===t?e.searchParams.get("v")||null:t.startsWith("/embed/")&&t.substring(7)||null;case"youtu.be":return e.pathname.substring(1)||null;default:return null}}async function nn(){const t=new URL("https://youtube.googleapis.com/youtube/v3/search"),n=t.searchParams;n.set("q",Wt.value),n.set("key",Kt.value||"AIzaSyARuwknsJhvP-ysM8-DwbqqJ5e-EaTL-UY"),n.set("type","video"),n.set("part","snippet"),n.set("order",Gt.value),n.set("maxResults",Xt.value),n.set("safeSearch","none"),n.set("videoEmbeddable","true"),null!=Qt&&n.set("pageToken",Qt);const r=await e.fetch(t,{cache:"no-cache",method:"GET",headers:{Accept:"application/json"}});return"application/json"===(r.headers.get("content-type")||"").split(";",2)[0].trim()?await r.json():null}async function rn(){i(null),Zt.disabled=!0,Wt.disabled=!0,Jt.style.display="none";const e=await nn();if(null==e)return void i("API server returned invalid data.");if("error"in e){const{message:t,code:n}=e.error;return void i(t+" (Code: "+n+")")}const n=e.items;if(0==n.length)return void i("No results match your search.");for(const e of n){const n=e.id.videoId,r=e.snippet,i=t.createElement("div");i.onclick=()=>en("https://www.youtube-nocookie.com/embed/"+n+"?autoplay=1&controls=1&rel=0&color=white");const s=t.createElement("img");s.width=160,s.height=90,s.title="Video Preview",s.draggable=!1,s.src=r.thumbnails.medium.url,i.appendChild(s);const o=t.createElement("div");i.appendChild(o);const a=t.createElement("div");a.className="title",a.textContent=r.title,o.appendChild(a);const c=t.createElement("div");c.className="desc",c.textContent=r.description,o.appendChild(c);const l=t.createElement("div");l.className="time",l.textContent=r.publishTime,o.appendChild(l),Yt.appendChild(i)}const r=e.nextPageToken;null!=r&&(Jt.style.display="block",Jt.onclick=()=>{Qt=r,rn().then((()=>{Zt.disabled=!1,Wt.disabled=!1}))})}Kt.value=E.get("__yt_apikey")||"",Vt.onsubmit=e=>{e.preventDefault(),e.stopPropagation(),Qt=null,Yt.innerHTML="";const t=a(Wt.value);if(null==t)return void rn().then((()=>{Zt.disabled=!1,Wt.disabled=!1}));i(null),Jt.style.display="none";const n=tn(t);null!=n?en("https://www.youtube-nocookie.com/embed/"+n+"?autoplay=1&controls=1&rel=0&color=white"):i("Error: Failed to parse YouTube video ID from the provided URL.")},Kt.onblur=()=>{const e=Kt.value.trim();return 0===e.length?(E.delete("__yt_apikey"),void(Kt.value="")):e.length<30?(i("Invalid API key."),void(Kt.value="")):void E.set("__yt_apikey",Kt.value=e)},Xt.onblur=()=>{const e=parseInt(Xt.value.trim(),10);isNaN(e)?Xt.value="10":e<1?Xt.value="1":e>30&&(Xt.value="30")}}{const sn=n("emulator"),on=n("core"),an=n("bios"),cn=n("game-rom");sn.onchange=()=>{switch(sn.value){case"flash":on.disabled=!0,an.disabled=!0,cn.accept=".swf";break;case"dos":on.disabled=!0,an.disabled=!0,cn.accept=".jsdos, .zip";break;default:sn.value="emu",on.disabled=!1,an.disabled=!1,cn.accept="*/*"}},n("startemu").onclick=()=>{const e=cn.files?.item(0);if(null==e)return void i("Please choose a valid game ROM file.");const t=sn.value,n=new URLSearchParams("");if(n.set("name",e.name),n.set("type",t),n.set("url",URL.createObjectURL(e)),"emu"===t){n.set("core",on.value);const e=an.files?.item(0);null!=e&&n.set("bios",URL.createObjectURL(e))}s("player.html?"+n.toString())}}{const ln=n("game-name"),dn=n("game-type"),hn=n("game-file"),un=n("game-labels"),pn=n("game-description"),fn=n("upload"),mn=n("upload-message");dn.onchange=()=>{switch(dn.value){case"html5":hn.accept=".zip";break;case"flash":hn.accept=".swf";break;case"dos":hn.accept=".jsdos";break;default:hn.accept="*/*"}},mn.onclick=()=>{mn.innerHTML="",mn.style.display="none"},fn.onclick=async()=>{const e=ln.value.replace(/\s+/g," ").trim();if(0===e.length)return void i("Game name must not be empty.");if(e.length>256)return void i("Game name must be less than 256 characters.");const t=hn.files?.item(0);if(null==t)return void i("Please choose a valid game file.");if(0===t.size)return void i("Uploading empty game files is not allowed.");if(t.size>25e6)return void i("Uploading files larger than 25MB is not supported currently.");if(null==x)return void i("Invalid session. Please refresh this page and try again.");if(!A.connected)return void i("Error: Disconnected from the backend server.");fn.disabled=!0,mn.innerHTML="Processing...",mn.style.color="#808080",mn.style.display="block";const n=pn.value.replace(/\s+/g," ").trim(),r=un.value.trim().toLowerCase().split(",").map((e=>e.replace(/\s+/g," ").trim())).join(",");if(r.length>300)i("The game tags list must be less than 300 characters in total.");else if(n.length>5e3)i("The game description text must be less than 5000 characters.");else{try{await l(13,[x,e,dn.value,r,n,await t.arrayBuffer()]),mn.innerHTML="✓Success!",mn.style.color="#008000",mn.style.display="block"}catch(e){mn.innerHTML="✕Error",mn.style.color="#ff0000",mn.style.display="block",i("Failed to upload the game. Message: "+e)}ln.value="",hn.value="",un.value="",pn.value="",fn.disabled=!1}}}{const gn=n("picker"),bn=n("ufile"),wn=n("messages"),yn=t.querySelectorAll("#channels>div"),vn=n("sendmsg");let _n="";{const xn=n("chat"),An=n("menu"),Cn=n("sidemenu");An.onclick=()=>{xn.removeAttribute("style"),An.style.display="none",Cn.style.display="block"},n("close-sm").onclick=()=>{xn.style.width="100%",An.style.display="block",Cn.style.display="none"},_&&(xn.style.width="100%",An.style.display="block",Cn.style.display="none")}{const Tn=n("chat-btn"),Sn=n("community-page");Tn.onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,Tn.setAttribute("current","true"),Sn.setAttribute("current","true"),A.on("msg",((e,t)=>{if(e===_n){const e=kn(t),n=wn.scrollHeight-wn.clientHeight;wn.appendChild(e),n===wn.scrollTop&&e.scrollIntoView({behavior:"instant",block:"end",inline:"end"})}})),A.on("msgdel",((e,t)=>{if(e===_n)for(const e of wn.children)if(e.getAttribute("_id")===t){e.remove();break}})),A.on("msgupd",((e,t,n)=>{if(e===_n)for(const e of wn.children)if(e.getAttribute("_id")===t){const r=e.querySelector("div>span");null!=r?r.textContent=n:i("Failed to update message: "+t);break}})),I=()=>{A.emit("ncs")},j=()=>{I=null,j=null,A.emit("end_session"),A.removeAllListeners("msg"),A.removeAllListeners("msgdel"),A.removeAllListeners("msgupd")},A.emit("ncs"),yn[0].dispatchEvent(new Event("click"))}}function kn({id:e,msg:n,uid:r,vip:i,user:o,icon:a,files:c}){const l=t.createElement("div");l.setAttribute("_id",e);const d=t.createElement("img");if(d.alt="Avatar",d.width=32,d.height=32,d.loading="lazy",d.decoding="async",d.draggable=!1,"string"!=typeof a){const e=URL.createObjectURL(new Blob([a],{type:"image/jpeg",endings:"native"}));d.addEventListener("load",(()=>URL.revokeObjectURL(e)),{once:!0,passive:!0}),d.src=e}else d.src=a;const h=t.createElement("div");switch(h.className="user",h.textContent=o,i){case 3:h.setAttribute("vip","gold");break;case 4:h.setAttribute("vip","diamond")}null!=r&&(d.style.cursor="pointer",h.style.cursor="pointer",d.onclick=h.onclick=()=>{S(r)});{const e=t.createElement("div"),r=t.createElement("span");r.textContent=n,e.appendChild(h),e.appendChild(r);for(const{name:n,type:r,url:i}of c)if(r.startsWith("image/")){const n=t.createElement("img");n.src=i,n.alt="Attachment",n.width=500,n.height=500,n.loading="lazy",n.decoding="async",n.draggable=!1,n.onclick=()=>s(i),e.appendChild(n)}else if(r.startsWith("audio/")){const n=t.createElement("audio");n.src=i,n.muted=!1,n.preload="metadata",n.controls=!0,e.appendChild(n)}else if(r.startsWith("video/")){const n=t.createElement("video");n.src=i,n.muted=!0,n.width=500,n.height=500,n.autoplay=!0,n.controls=!0,e.appendChild(n)}else{const r=t.createElement("a");r.rel="noopener nofollow",r.href=i,r.target="_blank",r.download="",r.textContent=n,e.appendChild(r)}l.appendChild(d),l.appendChild(e)}return l}async function En(e){const t=await l(7,[_n=e]);let n=t[t.length-1]?.id,r=!1;wn.innerHTML="",wn.onscroll=async()=>{if(0===wn.scrollTop&&!r){r=!0;try{const t=await l(7,[e,n]);if(t.length>0){const e=wn.scrollHeight;for(const e of t)wn.prepend(kn(e));n=t[t.length-1].id,wn.scrollTo({behavior:"instant",left:0,top:wn.scrollHeight-e})}}catch(e){i("Failed to fetch messages. Reason: "+e)}r=!1}};for(const e of t)wn.prepend(kn(e));wn.scrollTo({behavior:"instant",left:0,top:wn.scrollHeight})}{const In=n("channel-name");let jn=!1;for(const Ln of yn){const On=Ln.getAttribute("id")||"";Ln.onclick=async()=>{if(!jn){jn=!0;try{await En(On)}catch(e){i("Failed to initialize channel. Message: "+e)}for(const e of yn)e.removeAttribute("current");Ln.hasAttribute("q")?bn.style.display="block":bn.style.display="none",Ln.setAttribute("current","true"),In.innerHTML=Ln.innerHTML,jn=!1}}}}vn.onfocus=()=>{null==x&&(vn.blur(),D.click())},vn.onkeydown=e=>{if("Enter"===e.key){if(e.preventDefault(),e.stopPropagation(),null==x)return void D.click();const t=vn.value.trim();if(t.length<2)return void i("The message must contain at least 2 characters.");if(t.length>1e3)return void i("The message should not be longer than 1000 characters.");if(!A.connected)return void i("Error: Disconnected from the backend server.");vn.value="",vn.disabled=!0,l(8,[x,_n,t]).then((()=>{vn.disabled=!1})).catch((e=>{i("Failed to post text message. Message: "+e),vn.disabled=!1}))}},n("emoji").onclick=()=>{if("block"!==gn.style.display){if(null==gn.firstElementChild){const e=new Ss({locale:"POSIX",emojiVersion:1e3});e.addEventListener("emoji-click",(e=>{e.preventDefault(),e.stopPropagation();const t=e.detail.unicode;null!=t&&vn.setRangeText(t,vn.selectionStart||0,vn.selectionEnd||0,"end")})),gn.appendChild(e)}gn.style.display="block"}else gn.style.display="none"},bn.onclick=()=>{const e=t.createElement("input");e.type="file",e.accept="*/*",e.multiple=!0,e.onchange=async()=>{const t=e.files;if(null!=t&&t.length>0){if(t.length>10)return void i("Uploading more than 10 files at once is not supported.");if(!A.connected)return void i("Error: Disconnected from the backend server.");const e=[];for(const n of t){if(n.size<1)return void i("Uploading empty files is not allowed.");if(n.size>1e7)return void i("Uploading files larger than 10MB is not supported.");e.push({name:n.name,attachment:await n.arrayBuffer()})}bn.disabled=!0;try{await l(12,[x,_n,e])}catch(e){i("Failed to upload file. Message: "+e)}bn.disabled=!1}},e.click()},n("discord").onclick=()=>{const t=e.open(void 0,"_blank","");null!=t?(t.stop(),t.focus(),t.location.replace("https://discord.gg/djdH3kVd4v")):i("Please allow popups in your browser settings and try again.")}}const D=n("accn-btn"),R=n("chat-profile"),B=t.querySelectorAll("#nav-bar>button, #content>div:not(#footer), #unbl-content"),z=n("side-menu");{const Dn=n("home-btn"),Rn=n("unbl-btn"),Bn=n("apps-btn"),zn=n("settings"),Nn=n("home-page"),Pn=n("site-blocked-page"),Un=n("services-page"),Mn=n("uploadgames-page"),Fn=n("accountinfo-page"),$n=n("profile-page"),Hn=n("settings-page");n("logo").onclick=Dn.onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,Dn.setAttribute("current","true"),Nn.setAttribute("current","true")},Bn.onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,Bn.setAttribute("current","true"),Un.setAttribute("current","true")},Rn.onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,Rn.setAttribute("current","true"),Pn.setAttribute("current","true")},n("ug").onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,Mn.setAttribute("current","true")},n("chat-login").onclick=R.onclick=D.onclick=()=>{null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,D.setAttribute("current","true"),Fn.setAttribute("current","true")},zn.onclick=e=>{if(e.preventDefault(),e.stopPropagation(),null!=j&&j(),Hn.hasAttribute("current")){for(const e of B)e.removeAttribute("current");Dn.setAttribute("current","true"),Nn.setAttribute("current","true")}else{for(const e of B)e.removeAttribute("current");Hn.setAttribute("current","true")}z.checked=!1};{const qn=n("avatar"),Vn=n("userid"),Wn=n("af"),Zn=n("dm");S=async e=>{try{e=await l(1,e)}catch(t){return void i("Failed to open user profile: "+e)}{const t="/u/"+e.uid;Vn.textContent=e.id,h.replaceState(void 0,"",t),y.setAttribute("href","https://whitespider.dev"+t)}switch(e.vip){case 3:Vn.setAttribute("vip","gold");break;case 4:Vn.setAttribute("vip","diamond");break;default:Vn.removeAttribute("vip")}Wn.onclick=Zn.onclick=()=>{i("Function not yet implemented.")},null!=j&&j();for(const e of B)e.removeAttribute("current");z.checked=!1,$n.setAttribute("current","true");{const t=URL.createObjectURL(new Blob([e.avatar],{type:"image/jpeg",endings:"native"}));qn.src=t,await qn.decode(),URL.revokeObjectURL(t)}}}switch(u.slice(0,3)){case"/g/":case"/d/":case"/e/":{const Kn=parseInt(u.slice(3),36);if(Number.isSafeInteger(Kn)&&Kn>0)for(const Gn of L)if(Gn.date===Kn){T(Gn);break}}break;case"/u/":{const Yn=u.slice(3),Jn=Yn.length;Jn>0&&Jn<30&&S(Yn)}break;default:h.replaceState(void 0,"","/"),y.setAttribute("href","https://whitespider.dev/")}n("loading").remove(),n("content").style.display="block"}{const Xn=async()=>{D.innerHTML="My Account",n("ac-prof").style.display="block",n("chat-login").remove(),n("login-dialog").remove();const r=n("ac-un"),s=n("ac-edit"),o=n("ac-link"),a=n("ch-avatar"),c=a.firstElementChild,d=t.createElement("img");d.alt="Avatar",d.title="Change avatar",d.width=40,d.height=40,d.loading="eager",d.decoding="sync",d.draggable=!1,R.appendChild(d);const h=t.createElement("div");h.className="user",R.appendChild(h),R.style.display="block";const u=await l(2,x);switch(n("ac-un").textContent=h.textContent=u.id,n("ac-uid").textContent=u.uid,n("ac-name").textContent=u.name||"Not set",n("ac-email").textContent=u.email||"Not set",n("account-settings").style.display="block",u.vip){case 3:n("ac-membership").textContent="Gold 👑",r.setAttribute("vip","gold"),h.setAttribute("vip","gold");break;case 4:n("ac-membership").textContent="Diamond 💎",r.setAttribute("vip","diamond"),h.setAttribute("vip","diamond");break;default:n("ac-membership").textContent="None"}{const e=URL.createObjectURL(new Blob([u.avatar],{type:"image/jpeg",endings:"native"}));c.src=d.src=e,await c.decode(),await d.decode(),URL.revokeObjectURL(e)}a.onclick=()=>{const e=t.createElement("input");e.type="file",e.accept="image/*",e.onchange=async()=>{const t=e.files?.item(0);if(null!=t){const e=URL.createObjectURL(t),n=new Image(512,512);n.src=e,n.loading="eager",n.decoding="sync";try{await n.decode(),URL.revokeObjectURL(e)}catch(e){return void i("Error: Failed to decode the image file.")}const r=Math.min(n.naturalWidth,n.naturalHeight),s=Math.min(r,512),o=new OffscreenCanvas(s,s),a=o.getContext("2d",{alpha:!1});if(null==a)throw new Error("Internal Error: Canvas context is null before accessing.");a.imageSmoothingEnabled=!0,a.imageSmoothingQuality="high",a.fillStyle="#ffffff",a.fillRect(0,0,s,s),a.drawImage(n,0,0,r,r,0,0,s,s);try{const e=await o.convertToBlob({type:"image/jpeg",quality:100});await l(4,[x,await e.arrayBuffer()]);const t=URL.createObjectURL(e);c.src=d.src=t,await c.decode(),await d.decode(),URL.revokeObjectURL(t)}catch(e){i("Failed to upload the image file. Message+ "+String(e))}}},e.click()},s.onclick=()=>{const e=t.createElement("div"),n=t.createElement("input");n.type="text",n.value=r.innerHTML,n.minLength=4,n.maxLength=20,n.spellcheck=!1,n.placeholder="Username",n.autocomplete="off",n.setAttribute("style","position:relative;display:inline-block;width:fit-content;height:fit-content;margin:0px 10px;padding:5px;"),e.appendChild(n);const o=t.createElement("button");o.type="button",o.title="Save",o.textContent="✓",e.appendChild(o);const a=t.createElement("button");a.type="button",a.title="Cancel",a.textContent="✕",e.appendChild(a),n.onblur=()=>{n.value=n.value.trim().toLowerCase()},o.onclick=()=>{const t=n.value.trim().toLowerCase();t.length<4||t.length>20?i("The username must have 4 to 20 characters."):/^[\-a-z0-9]+$/.test(t)?l(3,[x,t]).then((()=>{e.replaceWith(r),r.textContent=t,h.textContent=t,s.removeAttribute("style")})).catch((e=>{i("Error: Failed to change username. Message: "+e)})):i("The username must contain only hyphens, a-z, 0-9")},a.onclick=()=>{e.replaceWith(r),s.removeAttribute("style")},s.style.display="none",r.replaceWith(e),n.select()},o.onclick=()=>{const n=t.createElement("span"),r=e.origin+"/u/"+u.uid;n.textContent=r,o.replaceWith(n),navigator.clipboard.writeText(r)}};{const Qn=n("cp");Qn.onclick=()=>{const e=t.createElement("div"),n=t.createElement("div");n.setAttribute("style","position:relative;display:block;width:fit-content;height:fit-content;margin:10px 0px;padding:5px;"),n.textContent="Notice: If your account was created with your Google account and does not have a password, set the current password field to 'CHANGEME!'.",e.appendChild(n);const r=t.createElement("input");r.type="password",r.minLength=8,r.maxLength=30,r.spellcheck=!1,r.placeholder="Current password",r.autocomplete="off",r.setAttribute("style","position:relative;display:block;width:fit-content;height:fit-content;margin:10px 0px;padding:5px;"),e.appendChild(r);const s=t.createElement("input");s.type="password",s.minLength=8,s.maxLength=30,s.spellcheck=!1,s.placeholder="New password",s.autocomplete="off",s.setAttribute("style","position:relative;display:block;width:fit-content;height:fit-content;margin:10px 0px;padding:5px;"),e.appendChild(s);const o=t.createElement("input");o.type="password",o.minLength=8,o.maxLength=30,o.spellcheck=!1,o.placeholder="Confirm password",o.autocomplete="off",o.setAttribute("style","position:relative;display:block;width:fit-content;height:fit-content;margin:10px 0px;padding:5px;"),e.appendChild(o);const a=t.createElement("button");a.type="button",a.title="Change",a.textContent="✓",e.appendChild(a);const c=t.createElement("button");c.type="button",c.title="Cancel",c.textContent="✕",e.appendChild(c),a.onclick=()=>{const t=r.value;if(t.length<8||t.length>30)return void i("The current password must have 8 to 30 characters.");const n=s.value;n.length<8||n.length>30?i("The new password must have 8 to 30 characters."):n===o.value?l(9,[x,t,n]).then((()=>{e.replaceWith(Qn)})).catch((e=>{i("Error: Failed to change password. Message: "+e)})):i("The new password does not match the confirm password.")},c.onclick=()=>{e.replaceWith(Qn)},Qn.replaceWith(e)}}if(n("fa").onclick=()=>{i("Function not yet implemented.")},n("so").onclick=()=>{E.delete("__secrets_"),setTimeout((()=>d.reload()),200)},n("da").onclick=()=>{i("Error: Operation not permitted.")},null==x){const er=r("#login-dialog>h3"),tr=n("login"),nr=n("register"),rr=n("username"),ir=n("password"),sr=n("2fa-otp"),or=n("c-password");sr.style.display="none",or.style.display="none",nr.onclick=()=>{"Register"===er.innerHTML?(er.innerHTML="Login",tr.innerHTML="Login",nr.innerHTML="Register",or.style.display="none"):(er.innerHTML="Register",tr.innerHTML="Register",nr.innerHTML="Login",or.style.display="block")},rr.onblur=()=>{rr.value=rr.value.trim().toLowerCase()},tr.onclick=()=>{const e=rr.value.trim().toLowerCase();if(e.length<4||e.length>20)return void i("The username must have 4 to 20 characters.");if(!/^[\-a-z0-9]+$/.test(e))return void i("The username must contain only hyphens, a-z, 0-9");const t=ir.value;if(t.length<8||t.length>30)i("The password must have 8 to 30 characters.");else if("Register"===er.innerHTML){if(t!==or.value)return void i("Confirm password does not match.");l(11,[e,t]).then((e=>{E.set("__secrets_",x=e),Xn()})).catch((e=>{i("Error: Failed to register. Message: "+e)}))}else l(10,[e,t]).then((e=>{E.set("__secrets_",x=e),Xn()})).catch((e=>{i("Error: Failed to login. Message: "+e)}))},n("login-google").onclick=()=>{const t=e.open(void 0,"_blank","width="+screen.availWidth+",height="+screen.availHeight+",left=0,top=0,popup");if(null==t)return void i("Please allow popups in your browser settings and try again.");t.stop(),t.focus();const n=new URLSearchParams;n.set("client_id","176227430389-qkdboctmfhe9jnvnk2vmarafc5p8amuf.apps.googleusercontent.com"),n.set("redirect_uri",e.origin+"/auth.html"),n.set("response_type","token"),n.set("state","12"),n.set("scope","email profile"),n.set("include_granted_scopes","true"),n.set("enable_granular_consent","true"),t.location.replace("https://accounts.google.com/o/oauth2/v2/auth?"+n.toString())};{const ar=e=>{(e=new URLSearchParams(e).get("access_token")||"").length>0&&l(0,e).then((e=>{E.set("__secrets_",x=e),Xn()})).catch((e=>{i("Failed to retrieve login tokens. Message: "+String(e))}))},cr=E.get("_cre_");null==cr?e.addEventListener("message",(t=>{if(t.origin===e.origin){const e=t.data;"string"==typeof e&&e.length>0&&ar(e)}}),{once:!1,passive:!0}):(ar(cr),E.delete("_cre_"))}}else await Xn()}})(window)})();
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 4f96a423..727033fb 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"id": "whitespider",
"name": "WhiteSpider",
- "version": "4.6.6",
+ "version": "4.6.7",
"short_name": "WhiteSpider",
"categories": ["games"],
"description": "Play 2000+ free online classic, HTML5, DOS, Flash, games at WhiteSpider!",
diff --git a/res/pay.json b/res/pay.json
new file mode 100644
index 00000000..e0eaa475
--- /dev/null
+++ b/res/pay.json
@@ -0,0 +1,8 @@
+{
+ "default_applications": [
+ "/manifest.json"
+ ],
+ "supported_origins": [
+ "https://*"
+ ]
+}
\ No newline at end of file
diff --git a/sw.js b/sw.js
index 93d487b9..167c94eb 100644
--- a/sw.js
+++ b/sw.js
@@ -76,8 +76,28 @@
}
}
+ async function handlePaymentRequest(e) {
+ let resolve, reject;
+ e.respondWith(new Promise((res, rej) => {
+ resolve = res;
+ reject = rej;
+ }));
+
+ /**
+ * @type {WindowClient | null}
+ */
+ const client = await e.openWindow("/auth.html?url=" + encodeURIComponent(e.methodData[0].data[0]));
+ if (client == null || client.type !== "window") {
+ reject("Error: Failed to open payment window");
+ return;
+ }
+ client.postMessage("dummy");
+ }
+
self.addEventListener("fetch", (e) => e.respondWith(handleFetch(e)), { passive: true });
self.addEventListener("message", (e) => e.waitUntil(handleMessage(e)), { passive: true });
self.addEventListener("install", (e) => e.waitUntil(handleInstall(e)), { passive: true });
self.addEventListener("activate", (e) => e.waitUntil(handleActivate(e)), { passive: true });
-})(self);
\ No newline at end of file
+ self.addEventListener("canmakepayment", (e) => e.respondWith(Promise.resolve(true)), { passive: true });
+ self.addEventListener("paymentrequest", (e) => e.waitUntil(handlePaymentRequest(e)), { passive: true });
+})(self);