@quake2ts/client 0.0.795 → 0.0.797
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -200,7 +200,7 @@ void main() {
|
|
|
200
200
|
v_texCoord = a_texCoord;
|
|
201
201
|
v_position = worldPos.xyz;
|
|
202
202
|
gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
|
|
203
|
-
}`;var x_=class{constructor(e,t){this._position=ee.create(),this._angles=ee.create(),this._bobAngles=ee.create(),this._bobOffset=ee.create(),this._kickAngles=ee.create(),this._rollAngle=0,this._fov=90,this._aspect=1,this._near=.1,this._far=1e3,this._viewMatrix=De.create(),this._projectionMatrix=De.create(),this._viewProjectionMatrix=De.create(),this._dirty=!0,e!==void 0&&t!==void 0&&t>0&&(this._aspect=e/t)}get position(){return this._position}set position(e){ee.equals(this._position,e)||(ee.copy(this._position,e),this._dirty=!0,this.triggerMoveEvent())}get angles(){return this._angles}set angles(e){ee.equals(this._angles,e)||(ee.copy(this._angles,e),this._dirty=!0,this.triggerMoveEvent())}get bobAngles(){return this._bobAngles}set bobAngles(e){ee.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){ee.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){ee.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}setPosition(e,t,i){let n=ee.fromValues(e,t,i);ee.equals(this._position,n)||(ee.copy(this._position,n),this._dirty=!0,this.triggerMoveEvent())}setRotation(e,t,i){let n=ee.fromValues(e,t,i);ee.equals(this._angles,n)||(ee.copy(this._angles,n),this._dirty=!0,this.triggerMoveEvent())}setFov(e){this.fov=e}setAspectRatio(e){this.aspect=e}lookAt(e){let t=ee.create();if(ee.subtract(t,e,this._position),ee.length(t)<.001)return;let n=Math.atan2(t[1],t[0])*Fl,r=Math.hypot(t[0],t[1]),a=-Math.atan2(t[2],r)*Fl;this.setRotation(a,n,0)}triggerMoveEvent(){this.onCameraMove&&this.onCameraMove({position:ee.clone(this._position),angles:ee.clone(this._angles)})}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let t=De.create();return De.perspective(t,e*Er,this._aspect,this._near,this._far),t}screenToWorldRay(e,t){let i=e*2-1,n=1-t*2,r=ee.fromValues(i,n,-1),a=ee.fromValues(i,n,1),s=De.create();De.invert(s,this.viewProjectionMatrix);let o=ee.create(),c=ee.create();ee.transformMat4(o,r,s),ee.transformMat4(c,a,s);let d=ee.create();return ee.subtract(d,c,o),ee.normalize(d,d),{origin:ee.clone(this._position),direction:d}}updateMatrices(){if(!this._dirty)return;De.perspective(this._projectionMatrix,this._fov*Er,this._aspect,this._near,this._far);let e=De.fromValues(0,0,-1,0,-1,0,0,0,0,1,0,0,0,0,0,1),t=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],i=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],n=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,r=t*Er,a=i*Er,s=n*Er,o=De.create();De.identity(o),De.rotateZ(o,o,-a),De.rotateY(o,o,-r),De.rotateX(o,o,-s);let c=De.create();De.multiply(c,e,o);let d=ee.add(ee.create(),this._position,this._bobOffset),l=ee.negate(ee.create(),d),m=ee.create();ee.transformMat4(m,l,o);let u=ee.fromValues(m[1]?-m[1]:0,m[2]||0,m[0]?-m[0]:0);De.copy(this._viewMatrix,c),this._viewMatrix[12]=u[0],this._viewMatrix[13]=u[1],this._viewMatrix[14]=u[2],De.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};function A_(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1}}=e;for(let r=0;r<12;r+=1){let a=200+t.rng.frandom()*180,s=t.rng.frandom()*.35;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*80,y:n.y*a+(t.rng.frandom()-.5)*80,z:Math.max(n.z*a,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+t.rng.frandom()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let r=0;r<8;r+=1)t.spawn({position:i,velocity:{x:(t.rng.frandom()-.5)*40,y:(t.rng.frandom()-.5)*40,z:80+t.rng.frandom()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function E_(e){let{system:t,origin:i}=e;for(let n=0;n<40;n+=1){let r=t.rng.frandom()*Math.PI*2,a=Math.acos(2*t.rng.frandom()-1),s=220+t.rng.frandom()*260,o={x:Math.sin(a)*Math.cos(r),y:Math.sin(a)*Math.sin(r),z:Math.cos(a)};t.spawn({position:i,velocity:{x:o.x*s,y:o.y*s,z:o.z*s},color:[1,.6,.2,1],size:5,lifetime:.9,gravity:700,damping:1,bounce:.35,blendMode:"additive",fade:!0})}for(let n=0;n<16;n+=1)t.spawn({position:i,velocity:{x:(t.rng.frandom()-.5)*30,y:(t.rng.frandom()-.5)*30,z:120+t.rng.frandom()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function T_(e){let{system:t,origin:i,direction:n={x:0,y:0,z:1}}=e;for(let r=0;r<24;r+=1){let a=120+t.rng.frandom()*180;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*70,y:n.y*a+(t.rng.frandom()-.5)*70,z:n.z*a+t.rng.frandom()*80},color:[.6,0,0,.95],size:3,lifetime:.8,gravity:900,damping:1,bounce:.2,blendMode:"alpha",fade:!0})}}function M_(e){let{system:t,origin:i,direction:n={x:1,y:0,z:0}}=e;for(let r=0;r<10;r+=1){let a=350+t.rng.frandom()*100;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*30,y:n.y*a+(t.rng.frandom()-.5)*30,z:n.z*a+(t.rng.frandom()-.5)*30},color:[1,.8,.3,1],size:3,lifetime:.25,gravity:200,damping:1,blendMode:"additive",fade:!0})}}function z_(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1}}=e;for(let r=0;r<30;r+=1){let a=100+t.rng.frandom()*150;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*80,y:n.y*a+(t.rng.frandom()-.5)*80,z:100+t.rng.frandom()*120},color:[.5,.6,.8,.5],size:3,lifetime:.5+t.rng.frandom()*.3,gravity:800,damping:1.5,blendMode:"alpha",fade:!0})}}function R_(e){let{system:t,origin:i}=e;for(let n=0;n<8;n+=1)t.spawn({position:{x:i.x+(t.rng.frandom()-.5)*10,y:i.y+(t.rng.frandom()-.5)*10,z:i.z+(t.rng.frandom()-.5)*10},velocity:{x:(t.rng.frandom()-.5)*20,y:(t.rng.frandom()-.5)*20,z:40+t.rng.frandom()*20},color:[.8,.8,.8,.3],size:5+t.rng.frandom()*4,lifetime:1.5+t.rng.frandom()*.5,gravity:-50,damping:.5,blendMode:"alpha",fade:!0})}function C_(e){let{system:t,start:i,end:n}=e,r=n.x-i.x,a=n.y-i.y,s=n.z-i.z,o=Math.sqrt(r*r+a*a+s*s);if(o<1)return;let c={x:r/o,y:a/o,z:s/o},d=8;for(let l=0;l<o;l+=d){let m=i.x+c.x*l,u=i.y+c.y*l,f=i.z+c.z*l;t.spawn({position:{x:m,y:u,z:f},velocity:{x:0,y:0,z:0},color:[.4,.4,1,.8],size:2,lifetime:.6,blendMode:"additive",fade:!0}),t.spawn({position:{x:m+(t.rng.frandom()-.5)*6,y:u+(t.rng.frandom()-.5)*6,z:f+(t.rng.frandom()-.5)*6},velocity:{x:(t.rng.frandom()-.5)*10,y:(t.rng.frandom()-.5)*10,z:(t.rng.frandom()-.5)*10},color:[.1,.1,.8,.6],size:3,lifetime:.8+t.rng.frandom()*.2,blendMode:"additive",fade:!0})}}function Rm(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1},count:r=12,color:a=[1,.9,.2,1]}=e;for(let s=0;s<r;s++){let o=100+t.rng.frandom()*200,c=.5;t.spawn({position:i,velocity:{x:n.x*o+(t.rng.frandom()-.5)*100*c,y:n.y*o+(t.rng.frandom()-.5)*100*c,z:n.z*o+(t.rng.frandom()-.5)*100*c},color:a,size:1.5,lifetime:.3+t.rng.frandom()*.2,gravity:800,bounce:.5,damping:1,blendMode:"additive",fade:!0})}}function Cm(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1},color:r=[1,.8,0,1]}=e;t.spawn({position:i,velocity:{x:0,y:0,z:0},color:r,size:8,lifetime:.2,blendMode:"additive",fade:!0});for(let a=0;a<8;a++){let s=150+t.rng.frandom()*150;t.spawn({position:i,velocity:{x:n.x*s+(t.rng.frandom()-.5)*120,y:n.y*s+(t.rng.frandom()-.5)*120,z:n.z*s+(t.rng.frandom()-.5)*120},color:r,size:2,lifetime:.4+t.rng.frandom()*.2,gravity:400,blendMode:"additive",fade:!0})}}function I_(e){let{system:t,origin:i}=e;t.spawn({position:i,velocity:{x:0,y:0,z:0},color:[.2,1,.2,1],size:30,lifetime:.5,blendMode:"additive",fade:!0});for(let n=0;n<60;n++){let r=t.rng.frandom()*Math.PI*2,a=Math.acos(2*t.rng.frandom()-1),s=300+t.rng.frandom()*400,o={x:Math.sin(a)*Math.cos(r),y:Math.sin(a)*Math.sin(r),z:Math.cos(a)};t.spawn({position:i,velocity:{x:o.x*s,y:o.y*s,z:o.z*s},color:[.2,1,.2,.8],size:4,lifetime:1,gravity:100,damping:1,blendMode:"additive",fade:!0})}}var L_=class{constructor(e){this.messageOffsets=[],this.currentBlock=null,this.buffer=e,this.view=new DataView(e),this.offset=0,this.scan()}scan(){let e=0;for(this.messageOffsets=[];e+4<=this.buffer.byteLength;){let t=this.view.getInt32(e,!0);if(t===-1)break;if(t<0||t>2097152){console.warn(`DemoReader: Invalid block length ${t} at offset ${e} during scan`);break}if(e+4+t>this.buffer.byteLength){console.warn(`DemoReader: Incomplete block at offset ${e} during scan`);break}this.messageOffsets.push(e),e+=4+t}}hasMore(){return this.offset<this.buffer.byteLength}readNextBlock(){if(this.offset+4>this.buffer.byteLength)return null;let e=this.view.getInt32(this.offset,!0);if(e===-1||e<0||this.offset+4+e>this.buffer.byteLength)return null;this.offset+=4;let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,{length:e,data:new nr(t)}}nextBlock(){let e=this.readNextBlock();return e?(this.currentBlock=e,!0):(this.currentBlock=null,!1)}getBlock(){if(!this.currentBlock)throw new Error("No current block. Call nextBlock() first.");return this.currentBlock}readAllBlocksToBuffer(){let e=0;this.offset;let t=[],i=this.offset;for(;i+4<=this.buffer.byteLength;){let s=this.view.getInt32(i,!0);if(s===-1||s<0||i+4+s>this.buffer.byteLength)break;t.push({offset:i+4,length:s}),e+=s,i+=4+s}let n=new Uint8Array(e),r=0,a=new Uint8Array(this.buffer);for(let s of t)n.set(a.subarray(s.offset,s.offset+s.length),r),r+=s.length;return this.offset=i,n.buffer}reset(){this.offset=0,this.currentBlock=null}seekToMessage(e){return e<0||e>=this.messageOffsets.length?!1:(this.offset=this.messageOffsets[e],this.currentBlock=null,!0)}getMessageCount(){return this.messageOffsets.length}getOffset(){return this.offset}getProgress(){let e=this.offset,t=this.buffer.byteLength;return{current:e,total:t,percent:t>0?e/t*100:0}}},qT=4,I0=0,L0=1,JT=2;function na(e){let t=e.length;for(;--t>=0;)e[t]=0}var QT=0,N_=1,eM=2,tM=3,iM=258,Im=29,ws=256,us=ws+1+Im,ea=30,Lm=19,P_=2*us+1,rr=15,rm=16,nM=7,Nm=256,O_=16,F_=17,D_=18,ym=new Uint8Array([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]),$o=new Uint8Array([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]),rM=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),B_=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),aM=512,rn=new Array((us+2)*2);na(rn);var ds=new Array(ea*2);na(ds);var fs=new Array(aM);na(fs);var hs=new Array(iM-tM+1);na(hs);var Pm=new Array(Im);na(Pm);var Ko=new Array(ea);na(Ko);function am(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}var U_,G_,H_;function sm(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var V_=e=>e<256?fs[e]:fs[256+(e>>>7)],gs=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Lt=(e,t,i)=>{e.bi_valid>rm-i?(e.bi_buf|=t<<e.bi_valid&65535,gs(e,e.bi_buf),e.bi_buf=t>>rm-e.bi_valid,e.bi_valid+=i-rm):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},Ci=(e,t,i)=>{Lt(e,i[t*2],i[t*2+1])},W_=(e,t)=>{let i=0;do i|=e&1,e>>>=1,i<<=1;while(--t>0);return i>>>1},sM=e=>{e.bi_valid===16?(gs(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},oM=(e,t)=>{let i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length,d,l,m,u,f,h,y=0;for(u=0;u<=rr;u++)e.bl_count[u]=0;for(i[e.heap[e.heap_max]*2+1]=0,d=e.heap_max+1;d<P_;d++)l=e.heap[d],u=i[i[l*2+1]*2+1]+1,u>c&&(u=c,y++),i[l*2+1]=u,!(l>n)&&(e.bl_count[u]++,f=0,l>=o&&(f=s[l-o]),h=i[l*2],e.opt_len+=h*(u+f),a&&(e.static_len+=h*(r[l*2+1]+f)));if(y!==0){do{for(u=c-1;e.bl_count[u]===0;)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,y-=2}while(y>0);for(u=c;u!==0;u--)for(l=e.bl_count[u];l!==0;)m=e.heap[--d],!(m>n)&&(i[m*2+1]!==u&&(e.opt_len+=(u-i[m*2+1])*i[m*2],i[m*2+1]=u),l--)}},$_=(e,t,i)=>{let n=new Array(rr+1),r=0,a,s;for(a=1;a<=rr;a++)r=r+i[a-1]<<1,n[a]=r;for(s=0;s<=t;s++){let o=e[s*2+1];o!==0&&(e[s*2]=W_(n[o]++,o))}},cM=()=>{let e,t,i,n,r,a=new Array(rr+1);for(i=0,n=0;n<Im-1;n++)for(Pm[n]=i,e=0;e<1<<ym[n];e++)hs[i++]=n;for(hs[i-1]=n,r=0,n=0;n<16;n++)for(Ko[n]=r,e=0;e<1<<$o[n];e++)fs[r++]=n;for(r>>=7;n<ea;n++)for(Ko[n]=r<<7,e=0;e<1<<$o[n]-7;e++)fs[256+r++]=n;for(t=0;t<=rr;t++)a[t]=0;for(e=0;e<=143;)rn[e*2+1]=8,e++,a[8]++;for(;e<=255;)rn[e*2+1]=9,e++,a[9]++;for(;e<=279;)rn[e*2+1]=7,e++,a[7]++;for(;e<=287;)rn[e*2+1]=8,e++,a[8]++;for($_(rn,us+1,a),e=0;e<ea;e++)ds[e*2+1]=5,ds[e*2]=W_(e,5);U_=new am(rn,ym,ws+1,us,rr),G_=new am(ds,$o,0,ea,rr),H_=new am(new Array(0),rM,0,Lm,nM)},K_=e=>{let t;for(t=0;t<us;t++)e.dyn_ltree[t*2]=0;for(t=0;t<ea;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Lm;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Nm*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},X_=e=>{e.bi_valid>8?gs(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},N0=(e,t,i,n)=>{let r=t*2,a=i*2;return e[r]<e[a]||e[r]===e[a]&&n[t]<=n[i]},om=(e,t,i)=>{let n=e.heap[i],r=i<<1;for(;r<=e.heap_len&&(r<e.heap_len&&N0(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!N0(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n},P0=(e,t,i)=>{let n,r,a=0,s,o;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+a++]&255,n+=(e.pending_buf[e.sym_buf+a++]&255)<<8,r=e.pending_buf[e.sym_buf+a++],n===0?Ci(e,r,t):(s=hs[r],Ci(e,s+ws+1,t),o=ym[s],o!==0&&(r-=Pm[s],Lt(e,r,o)),n--,s=V_(n),Ci(e,s,i),o=$o[s],o!==0&&(n-=Ko[s],Lt(e,n,o)));while(a<e.sym_next);Ci(e,Nm,t)},wm=(e,t)=>{let i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,a=t.stat_desc.elems,s,o,c=-1,d;for(e.heap_len=0,e.heap_max=P_,s=0;s<a;s++)i[s*2]!==0?(e.heap[++e.heap_len]=c=s,e.depth[s]=0):i[s*2+1]=0;for(;e.heap_len<2;)d=e.heap[++e.heap_len]=c<2?++c:0,i[d*2]=1,e.depth[d]=0,e.opt_len--,r&&(e.static_len-=n[d*2+1]);for(t.max_code=c,s=e.heap_len>>1;s>=1;s--)om(e,i,s);d=a;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],om(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,i[d*2]=i[s*2]+i[o*2],e.depth[d]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,i[s*2+1]=i[o*2+1]=d,e.heap[1]=d++,om(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],oM(e,t),$_(i,c,e.bl_count)},O0=(e,t,i)=>{let n,r=-1,a,s=t[1],o=0,c=7,d=4;for(s===0&&(c=138,d=3),t[(i+1)*2+1]=65535,n=0;n<=i;n++)a=s,s=t[(n+1)*2+1],!(++o<c&&a===s)&&(o<d?e.bl_tree[a*2]+=o:a!==0?(a!==r&&e.bl_tree[a*2]++,e.bl_tree[O_*2]++):o<=10?e.bl_tree[F_*2]++:e.bl_tree[D_*2]++,o=0,r=a,s===0?(c=138,d=3):a===s?(c=6,d=3):(c=7,d=4))},F0=(e,t,i)=>{let n,r=-1,a,s=t[1],o=0,c=7,d=4;for(s===0&&(c=138,d=3),n=0;n<=i;n++)if(a=s,s=t[(n+1)*2+1],!(++o<c&&a===s)){if(o<d)do Ci(e,a,e.bl_tree);while(--o!==0);else a!==0?(a!==r&&(Ci(e,a,e.bl_tree),o--),Ci(e,O_,e.bl_tree),Lt(e,o-3,2)):o<=10?(Ci(e,F_,e.bl_tree),Lt(e,o-3,3)):(Ci(e,D_,e.bl_tree),Lt(e,o-11,7));o=0,r=a,s===0?(c=138,d=3):a===s?(c=6,d=3):(c=7,d=4)}},dM=e=>{let t;for(O0(e,e.dyn_ltree,e.l_desc.max_code),O0(e,e.dyn_dtree,e.d_desc.max_code),wm(e,e.bl_desc),t=Lm-1;t>=3&&e.bl_tree[B_[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},lM=(e,t,i,n)=>{let r;for(Lt(e,t-257,5),Lt(e,i-1,5),Lt(e,n-4,4),r=0;r<n;r++)Lt(e,e.bl_tree[B_[r]*2+1],3);F0(e,e.dyn_ltree,t-1),F0(e,e.dyn_dtree,i-1)},mM=e=>{let t=4093624447,i;for(i=0;i<=31;i++,t>>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return I0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return L0;for(i=32;i<ws;i++)if(e.dyn_ltree[i*2]!==0)return L0;return I0},D0=!1,uM=e=>{D0||(cM(),D0=!0),e.l_desc=new sm(e.dyn_ltree,U_),e.d_desc=new sm(e.dyn_dtree,G_),e.bl_desc=new sm(e.bl_tree,H_),e.bi_buf=0,e.bi_valid=0,K_(e)},j_=(e,t,i,n)=>{Lt(e,(QT<<1)+(n?1:0),3),X_(e),gs(e,i),gs(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i},fM=e=>{Lt(e,N_<<1,3),Ci(e,Nm,rn),sM(e)},hM=(e,t,i,n)=>{let r,a,s=0;e.level>0?(e.strm.data_type===JT&&(e.strm.data_type=mM(e)),wm(e,e.l_desc),wm(e,e.d_desc),s=dM(e),r=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=r&&(r=a)):r=a=i+5,i+4<=r&&t!==-1?j_(e,t,i,n):e.strategy===qT||a===r?(Lt(e,(N_<<1)+(n?1:0),3),P0(e,rn,ds)):(Lt(e,(eM<<1)+(n?1:0),3),lM(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),P0(e,e.dyn_ltree,e.dyn_dtree)),K_(e),n&&X_(e)},gM=(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,t===0?e.dyn_ltree[i*2]++:(e.matches++,t--,e.dyn_ltree[(hs[i]+ws+1)*2]++,e.dyn_dtree[V_(t)*2]++),e.sym_next===e.sym_end),_M=uM,pM=j_,vM=hM,yM=gM,wM=fM,SM={_tr_init:_M,_tr_stored_block:pM,_tr_flush_block:vM,_tr_tally:yM,_tr_align:wM},kM=(e,t,i,n)=>{let r=e&65535|0,a=e>>>16&65535|0,s=0;for(;i!==0;){s=i>2e3?2e3:i,i-=s;do r=r+t[n++]|0,a=a+r|0;while(--s);r%=65521,a%=65521}return r|a<<16|0},_s=kM,bM=()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[i]=e}return t},xM=new Uint32Array(bM()),AM=(e,t,i,n)=>{let r=xM,a=n+i;e^=-1;for(let s=n;s<a;s++)e=e>>>8^r[(e^t[s])&255];return e^-1},ft=AM,or={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ss={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:EM,_tr_stored_block:Sm,_tr_flush_block:TM,_tr_tally:Nn,_tr_align:MM}=SM,{Z_NO_FLUSH:Pn,Z_PARTIAL_FLUSH:zM,Z_FULL_FLUSH:RM,Z_FINISH:ni,Z_BLOCK:B0,Z_OK:pt,Z_STREAM_END:U0,Z_STREAM_ERROR:Ii,Z_DATA_ERROR:CM,Z_BUF_ERROR:cm,Z_DEFAULT_COMPRESSION:IM,Z_FILTERED:LM,Z_HUFFMAN_ONLY:Uo,Z_RLE:NM,Z_FIXED:PM,Z_DEFAULT_STRATEGY:OM,Z_UNKNOWN:FM,Z_DEFLATED:Yo}=Ss,DM=9,BM=15,UM=8,GM=29,HM=256,km=HM+1+GM,VM=30,WM=19,$M=2*km+1,KM=15,xe=3,In=258,Li=In+xe+1,XM=32,ta=42,Om=57,bm=69,xm=73,Am=91,Em=103,ar=113,os=666,Tt=1,ra=2,cr=3,aa=4,jM=3,sr=(e,t)=>(e.msg=or[t],t),G0=e=>e*2-(e>4?9:0),Cn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},YM=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do i=e.head[--n],e.head[n]=i>=r?i-r:0;while(--t);t=r,n=t;do i=e.prev[--n],e.prev[n]=i>=r?i-r:0;while(--t)},ZM=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask,On=ZM,Wt=e=>{let t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,t.pending===0&&(t.pending_out=0))},$t=(e,t)=>{TM(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Wt(e.strm)},ze=(e,t)=>{e.pending_buf[e.pending++]=t},ss=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Tm=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),r===0?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),e.state.wrap===1?e.adler=_s(e.adler,t,r,i):e.state.wrap===2&&(e.adler=ft(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},Y_=(e,t)=>{let i=e.max_chain_length,n=e.strstart,r,a,s=e.prev_length,o=e.nice_match,c=e.strstart>e.w_size-Li?e.strstart-(e.w_size-Li):0,d=e.window,l=e.w_mask,m=e.prev,u=e.strstart+In,f=d[n+s-1],h=d[n+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do if(r=t,!(d[r+s]!==h||d[r+s-1]!==f||d[r]!==d[n]||d[++r]!==d[n+1])){n+=2,r++;do;while(d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&n<u);if(a=In-(u-n),n=u-In,a>s){if(e.match_start=t,s=a,a>=o)break;f=d[n+s-1],h=d[n+s]}}while((t=m[t&l])>c&&--i!==0);return s<=e.lookahead?s:e.lookahead},ia=e=>{let t=e.w_size,i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Li)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),YM(e),n+=t),e.strm.avail_in===0)break;if(i=Tm(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=xe)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=On(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=On(e,e.ins_h,e.window[r+xe-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<xe)););}while(e.lookahead<Li&&e.strm.avail_in!==0)},Z_=(e,t)=>{let i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,r,a,s=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,r=e.strstart-e.block_start,n>r+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n<i&&(n===0&&t!==ni||t===Pn||n!==r+e.strm.avail_in)))break;s=t===ni&&n===r+e.strm.avail_in?1:0,Sm(e,0,0,s),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Wt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Tm(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(s===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?aa:t!==Pn&&t!==ni&&e.strm.avail_in===0&&e.strstart===e.block_start?ra:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Tm(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===ni)&&t!==Pn&&e.strm.avail_in===0&&r<=a)&&(n=r>a?a:r,s=t===ni&&e.strm.avail_in===0&&n===r?1:0,Sm(e,e.block_start,n,s),e.block_start+=n,Wt(e.strm)),s?cr:Tt)},dm=(e,t)=>{let i,n;for(;;){if(e.lookahead<Li){if(ia(e),e.lookahead<Li&&t===Pn)return Tt;if(e.lookahead===0)break}if(i=0,e.lookahead>=xe&&(e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),i!==0&&e.strstart-i<=e.w_size-Li&&(e.match_length=Y_(e,i)),e.match_length>=xe)if(n=Nn(e,e.strstart-e.match_start,e.match_length-xe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=xe){e.match_length--;do e.strstart++,e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=On(e,e.ins_h,e.window[e.strstart+1]);else n=Nn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&($t(e,!1),e.strm.avail_out===0))return Tt}return e.insert=e.strstart<xe-1?e.strstart:xe-1,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra},Jr=(e,t)=>{let i,n,r;for(;;){if(e.lookahead<Li){if(ia(e),e.lookahead<Li&&t===Pn)return Tt;if(e.lookahead===0)break}if(i=0,e.lookahead>=xe&&(e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=xe-1,i!==0&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-Li&&(e.match_length=Y_(e,i),e.match_length<=5&&(e.strategy===LM||e.match_length===xe&&e.strstart-e.match_start>4096)&&(e.match_length=xe-1)),e.prev_length>=xe&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-xe,n=Nn(e,e.strstart-1-e.prev_match,e.prev_length-xe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=xe-1,e.strstart++,n&&($t(e,!1),e.strm.avail_out===0))return Tt}else if(e.match_available){if(n=Nn(e,0,e.window[e.strstart-1]),n&&$t(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Tt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Nn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<xe-1?e.strstart:xe-1,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra},qM=(e,t)=>{let i,n,r,a,s=e.window;for(;;){if(e.lookahead<=In){if(ia(e),e.lookahead<=In&&t===Pn)return Tt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=xe&&e.strstart>0&&(r=e.strstart-1,n=s[r],n===s[++r]&&n===s[++r]&&n===s[++r])){a=e.strstart+In;do;while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<a);e.match_length=In-(a-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=xe?(i=Nn(e,1,e.match_length-xe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Nn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&($t(e,!1),e.strm.avail_out===0))return Tt}return e.insert=0,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra},JM=(e,t)=>{let i;for(;;){if(e.lookahead===0&&(ia(e),e.lookahead===0)){if(t===Pn)return Tt;break}if(e.match_length=0,i=Nn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&($t(e,!1),e.strm.avail_out===0))return Tt}return e.insert=0,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra};function Ri(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}var cs=[new Ri(0,0,0,0,Z_),new Ri(4,4,8,4,dm),new Ri(4,5,16,8,dm),new Ri(4,6,32,32,dm),new Ri(4,4,16,16,Jr),new Ri(8,16,32,32,Jr),new Ri(8,16,128,128,Jr),new Ri(8,32,128,256,Jr),new Ri(32,128,258,1024,Jr),new Ri(32,258,258,4096,Jr)],QM=e=>{e.window_size=2*e.w_size,Cn(e.head),e.max_lazy_match=cs[e.level].max_lazy,e.good_match=cs[e.level].good_length,e.nice_match=cs[e.level].nice_length,e.max_chain_length=cs[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=xe-1,e.match_available=0,e.ins_h=0};function e3(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Yo,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array($M*2),this.dyn_dtree=new Uint16Array((2*VM+1)*2),this.bl_tree=new Uint16Array((2*WM+1)*2),Cn(this.dyn_ltree),Cn(this.dyn_dtree),Cn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(KM+1),this.heap=new Uint16Array(2*km+1),Cn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*km+1),Cn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var ks=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==ta&&t.status!==Om&&t.status!==bm&&t.status!==xm&&t.status!==Am&&t.status!==Em&&t.status!==ar&&t.status!==os?1:0},q_=e=>{if(ks(e))return sr(e,Ii);e.total_in=e.total_out=0,e.data_type=FM;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Om:t.wrap?ta:ar,e.adler=t.wrap===2?0:1,t.last_flush=-2,EM(t),pt},J_=e=>{let t=q_(e);return t===pt&&QM(e.state),t},t3=(e,t)=>ks(e)||e.state.wrap!==2?Ii:(e.state.gzhead=t,pt),Q_=(e,t,i,n,r,a)=>{if(!e)return Ii;let s=1;if(t===IM&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>DM||i!==Yo||n<8||n>15||t<0||t>9||a<0||a>PM||n===8&&s!==1)return sr(e,Ii);n===8&&(n=9);let o=new e3;return e.state=o,o.strm=e,o.status=ta,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+xe-1)/xe),o.window=new Uint8Array(o.w_size*2),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=(o.lit_bufsize-1)*3,o.level=t,o.strategy=a,o.method=i,J_(e)},i3=(e,t)=>Q_(e,t,Yo,BM,UM,OM),n3=(e,t)=>{if(ks(e)||t>B0||t<0)return e?sr(e,Ii):Ii;let i=e.state;if(!e.output||e.avail_in!==0&&!e.input||i.status===os&&t!==ni)return sr(e,e.avail_out===0?cm:Ii);let n=i.last_flush;if(i.last_flush=t,i.pending!==0){if(Wt(e),e.avail_out===0)return i.last_flush=-1,pt}else if(e.avail_in===0&&G0(t)<=G0(n)&&t!==ni)return sr(e,cm);if(i.status===os&&e.avail_in!==0)return sr(e,cm);if(i.status===ta&&i.wrap===0&&(i.status=ar),i.status===ta){let r=Yo+(i.w_bits-8<<4)<<8,a=-1;if(i.strategy>=Uo||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,r|=a<<6,i.strstart!==0&&(r|=XM),r+=31-r%31,ss(i,r),i.strstart!==0&&(ss(i,e.adler>>>16),ss(i,e.adler&65535)),e.adler=1,i.status=ar,Wt(e),i.pending!==0)return i.last_flush=-1,pt}if(i.status===Om){if(e.adler=0,ze(i,31),ze(i,139),ze(i,8),i.gzhead)ze(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),ze(i,i.gzhead.time&255),ze(i,i.gzhead.time>>8&255),ze(i,i.gzhead.time>>16&255),ze(i,i.gzhead.time>>24&255),ze(i,i.level===9?2:i.strategy>=Uo||i.level<2?4:0),ze(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(ze(i,i.gzhead.extra.length&255),ze(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ft(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=bm;else if(ze(i,0),ze(i,0),ze(i,0),ze(i,0),ze(i,0),ze(i,i.level===9?2:i.strategy>=Uo||i.level<2?4:0),ze(i,jM),i.status=ar,Wt(e),i.pending!==0)return i.last_flush=-1,pt}if(i.status===bm){if(i.gzhead.extra){let r=i.pending,a=(i.gzhead.extra.length&65535)-i.gzindex;for(;i.pending+a>i.pending_buf_size;){let o=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+o),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex+=o,Wt(e),i.pending!==0)return i.last_flush=-1,pt;r=0,a-=o}let s=new Uint8Array(i.gzhead.extra);i.pending_buf.set(s.subarray(i.gzindex,i.gzindex+a),i.pending),i.pending+=a,i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=xm}if(i.status===xm){if(i.gzhead.name){let r=i.pending,a;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),Wt(e),i.pending!==0)return i.last_flush=-1,pt;r=0}i.gzindex<i.gzhead.name.length?a=i.gzhead.name.charCodeAt(i.gzindex++)&255:a=0,ze(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=Am}if(i.status===Am){if(i.gzhead.comment){let r=i.pending,a;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),Wt(e),i.pending!==0)return i.last_flush=-1,pt;r=0}i.gzindex<i.gzhead.comment.length?a=i.gzhead.comment.charCodeAt(i.gzindex++)&255:a=0,ze(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r))}i.status=Em}if(i.status===Em){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(Wt(e),i.pending!==0))return i.last_flush=-1,pt;ze(i,e.adler&255),ze(i,e.adler>>8&255),e.adler=0}if(i.status=ar,Wt(e),i.pending!==0)return i.last_flush=-1,pt}if(e.avail_in!==0||i.lookahead!==0||t!==Pn&&i.status!==os){let r=i.level===0?Z_(i,t):i.strategy===Uo?JM(i,t):i.strategy===NM?qM(i,t):cs[i.level].func(i,t);if((r===cr||r===aa)&&(i.status=os),r===Tt||r===cr)return e.avail_out===0&&(i.last_flush=-1),pt;if(r===ra&&(t===zM?MM(i):t!==B0&&(Sm(i,0,0,!1),t===RM&&(Cn(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Wt(e),e.avail_out===0))return i.last_flush=-1,pt}return t!==ni?pt:i.wrap<=0?U0:(i.wrap===2?(ze(i,e.adler&255),ze(i,e.adler>>8&255),ze(i,e.adler>>16&255),ze(i,e.adler>>24&255),ze(i,e.total_in&255),ze(i,e.total_in>>8&255),ze(i,e.total_in>>16&255),ze(i,e.total_in>>24&255)):(ss(i,e.adler>>>16),ss(i,e.adler&65535)),Wt(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?pt:U0)},r3=e=>{if(ks(e))return Ii;let t=e.state.status;return e.state=null,t===ar?sr(e,CM):pt},a3=(e,t)=>{let i=t.length;if(ks(e))return Ii;let n=e.state,r=n.wrap;if(r===2||r===1&&n.status!==ta||n.lookahead)return Ii;if(r===1&&(e.adler=_s(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){r===0&&(Cn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let c=new Uint8Array(n.w_size);c.set(t.subarray(i-n.w_size,i),0),t=c,i=n.w_size}let a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,ia(n);n.lookahead>=xe;){let c=n.strstart,d=n.lookahead-(xe-1);do n.ins_h=On(n,n.ins_h,n.window[c+xe-1]),n.prev[c&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=c,c++;while(--d);n.strstart=c,n.lookahead=xe-1,ia(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=xe-1,n.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,n.wrap=r,pt},s3=i3,o3=Q_,c3=J_,d3=q_,l3=t3,m3=n3,u3=r3,f3=a3,h3="pako deflate (from Nodeca project)",ls={deflateInit:s3,deflateInit2:o3,deflateReset:c3,deflateResetKeep:d3,deflateSetHeader:l3,deflate:m3,deflateEnd:u3,deflateSetDictionary:f3,deflateInfo:h3},g3=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_3=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let i=t.shift();if(i){if(typeof i!="object")throw new TypeError(i+"must be non-object");for(let n in i)g3(i,n)&&(e[n]=i[n])}}return e},p3=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let i=new Uint8Array(t);for(let n=0,r=0,a=e.length;n<a;n++){let s=e[n];i.set(s,r),r+=s.length}return i},Zo={assign:_3,flattenChunks:p3},ep=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ep=!1}var ps=new Uint8Array(256);for(let e=0;e<256;e++)ps[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ps[254]=ps[254]=1;var v3=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,i,n,r,a,s=e.length,o=0;for(r=0;r<s;r++)i=e.charCodeAt(r),(i&64512)===55296&&r+1<s&&(n=e.charCodeAt(r+1),(n&64512)===56320&&(i=65536+(i-55296<<10)+(n-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),a=0,r=0;a<o;r++)i=e.charCodeAt(r),(i&64512)===55296&&r+1<s&&(n=e.charCodeAt(r+1),(n&64512)===56320&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[a++]=i:i<2048?(t[a++]=192|i>>>6,t[a++]=128|i&63):i<65536?(t[a++]=224|i>>>12,t[a++]=128|i>>>6&63,t[a++]=128|i&63):(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63,t[a++]=128|i>>>6&63,t[a++]=128|i&63);return t},y3=(e,t)=>{if(t<65534&&e.subarray&&ep)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i},w3=(e,t)=>{let i=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,r,a=new Array(i*2);for(r=0,n=0;n<i;){let s=e[n++];if(s<128){a[r++]=s;continue}let o=ps[s];if(o>4){a[r++]=65533,n+=o-1;continue}for(s&=o===2?31:o===3?15:7;o>1&&n<i;)s=s<<6|e[n++]&63,o--;if(o>1){a[r++]=65533;continue}s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|s&1023)}return y3(a,r)},S3=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let i=t-1;for(;i>=0&&(e[i]&192)===128;)i--;return i<0||i===0?t:i+ps[e[i]]>t?i:t},vs={string2buf:v3,buf2string:w3,utf8border:S3};function k3(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var tp=k3,ip=Object.prototype.toString,{Z_NO_FLUSH:b3,Z_SYNC_FLUSH:x3,Z_FULL_FLUSH:A3,Z_FINISH:E3,Z_OK:Xo,Z_STREAM_END:T3,Z_DEFAULT_COMPRESSION:M3,Z_DEFAULT_STRATEGY:z3,Z_DEFLATED:R3}=Ss;function bs(e){this.options=Zo.assign({level:M3,method:R3,chunkSize:16384,windowBits:15,memLevel:8,strategy:z3},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tp,this.strm.avail_out=0;let i=ls.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Xo)throw new Error(or[i]);if(t.header&&ls.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=vs.string2buf(t.dictionary):ip.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,i=ls.deflateSetDictionary(this.strm,n),i!==Xo)throw new Error(or[i]);this._dict_set=!0}}bs.prototype.push=function(e,t){let i=this.strm,n=this.options.chunkSize,r,a;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?E3:b3,typeof e=="string"?i.input=vs.string2buf(e):ip.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){if(i.avail_out===0&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(a===x3||a===A3)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(r=ls.deflate(i,a),r===T3)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=ls.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Xo;if(i.avail_out===0){this.onData(i.output);continue}if(a>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(i.avail_in===0)break}return!0};bs.prototype.onData=function(e){this.chunks.push(e)};bs.prototype.onEnd=function(e){e===Xo&&(this.result=Zo.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Fm(e,t){let i=new bs(t);if(i.push(e,!0),i.err)throw i.msg||or[i.err];return i.result}function C3(e,t){return t=t||{},t.raw=!0,Fm(e,t)}function I3(e,t){return t=t||{},t.gzip=!0,Fm(e,t)}var L3=bs,N3=Fm,P3=C3,O3=I3,F3={Deflate:L3,deflate:N3,deflateRaw:P3,gzip:O3},Go=16209,D3=16191,B3=function(t,i){let n,r,a,s,o,c,d,l,m,u,f,h,y,p,v,A,x,w,R,b,E,D,H,O,Y=t.state;n=t.next_in,H=t.input,r=n+(t.avail_in-5),a=t.next_out,O=t.output,s=a-(i-t.avail_out),o=a+(t.avail_out-257),c=Y.dmax,d=Y.wsize,l=Y.whave,m=Y.wnext,u=Y.window,f=Y.hold,h=Y.bits,y=Y.lencode,p=Y.distcode,v=(1<<Y.lenbits)-1,A=(1<<Y.distbits)-1;e:do{h<15&&(f+=H[n++]<<h,h+=8,f+=H[n++]<<h,h+=8),x=y[f&v];t:for(;;){if(w=x>>>24,f>>>=w,h-=w,w=x>>>16&255,w===0)O[a++]=x&65535;else if(w&16){R=x&65535,w&=15,w&&(h<w&&(f+=H[n++]<<h,h+=8),R+=f&(1<<w)-1,f>>>=w,h-=w),h<15&&(f+=H[n++]<<h,h+=8,f+=H[n++]<<h,h+=8),x=p[f&A];i:for(;;){if(w=x>>>24,f>>>=w,h-=w,w=x>>>16&255,w&16){if(b=x&65535,w&=15,h<w&&(f+=H[n++]<<h,h+=8,h<w&&(f+=H[n++]<<h,h+=8)),b+=f&(1<<w)-1,b>c){t.msg="invalid distance too far back",Y.mode=Go;break e}if(f>>>=w,h-=w,w=a-s,b>w){if(w=b-w,w>l&&Y.sane){t.msg="invalid distance too far back",Y.mode=Go;break e}if(E=0,D=u,m===0){if(E+=d-w,w<R){R-=w;do O[a++]=u[E++];while(--w);E=a-b,D=O}}else if(m<w){if(E+=d+m-w,w-=m,w<R){R-=w;do O[a++]=u[E++];while(--w);if(E=0,m<R){w=m,R-=w;do O[a++]=u[E++];while(--w);E=a-b,D=O}}}else if(E+=m-w,w<R){R-=w;do O[a++]=u[E++];while(--w);E=a-b,D=O}for(;R>2;)O[a++]=D[E++],O[a++]=D[E++],O[a++]=D[E++],R-=3;R&&(O[a++]=D[E++],R>1&&(O[a++]=D[E++]))}else{E=a-b;do O[a++]=O[E++],O[a++]=O[E++],O[a++]=O[E++],R-=3;while(R>2);R&&(O[a++]=O[E++],R>1&&(O[a++]=O[E++]))}}else if((w&64)===0){x=p[(x&65535)+(f&(1<<w)-1)];continue i}else{t.msg="invalid distance code",Y.mode=Go;break e}break}}else if((w&64)===0){x=y[(x&65535)+(f&(1<<w)-1)];continue t}else if(w&32){Y.mode=D3;break e}else{t.msg="invalid literal/length code",Y.mode=Go;break e}break}}while(n<r&&a<o);R=h>>3,n-=R,h-=R<<3,f&=(1<<h)-1,t.next_in=n,t.next_out=a,t.avail_in=n<r?5+(r-n):5-(n-r),t.avail_out=a<o?257+(o-a):257-(a-o),Y.hold=f,Y.bits=h},Qr=15,H0=852,V0=592,W0=0,lm=1,$0=2,U3=new Uint16Array([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]),G3=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),H3=new Uint16Array([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,0,0]),V3=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),W3=(e,t,i,n,r,a,s,o)=>{let c=o.bits,d=0,l=0,m=0,u=0,f=0,h=0,y=0,p=0,v=0,A=0,x,w,R,b,E,D=null,H,O=new Uint16Array(Qr+1),Y=new Uint16Array(Qr+1),J=null,me,ie,be;for(d=0;d<=Qr;d++)O[d]=0;for(l=0;l<n;l++)O[t[i+l]]++;for(f=c,u=Qr;u>=1&&O[u]===0;u--);if(f>u&&(f=u),u===0)return r[a++]=1<<24|64<<16|0,r[a++]=1<<24|64<<16|0,o.bits=1,0;for(m=1;m<u&&O[m]===0;m++);for(f<m&&(f=m),p=1,d=1;d<=Qr;d++)if(p<<=1,p-=O[d],p<0)return-1;if(p>0&&(e===W0||u!==1))return-1;for(Y[1]=0,d=1;d<Qr;d++)Y[d+1]=Y[d]+O[d];for(l=0;l<n;l++)t[i+l]!==0&&(s[Y[t[i+l]]++]=l);if(e===W0?(D=J=s,H=20):e===lm?(D=U3,J=G3,H=257):(D=H3,J=V3,H=0),A=0,l=0,d=m,E=a,h=f,y=0,R=-1,v=1<<f,b=v-1,e===lm&&v>H0||e===$0&&v>V0)return 1;for(;;){me=d-y,s[l]+1<H?(ie=0,be=s[l]):s[l]>=H?(ie=J[s[l]-H],be=D[s[l]-H]):(ie=96,be=0),x=1<<d-y,w=1<<h,m=w;do w-=x,r[E+(A>>y)+w]=me<<24|ie<<16|be|0;while(w!==0);for(x=1<<d-1;A&x;)x>>=1;if(x!==0?(A&=x-1,A+=x):A=0,l++,--O[d]===0){if(d===u)break;d=t[i+s[l]]}if(d>f&&(A&b)!==R){for(y===0&&(y=f),E+=m,h=d-y,p=1<<h;h+y<u&&(p-=O[h+y],!(p<=0));)h++,p<<=1;if(v+=1<<h,e===lm&&v>H0||e===$0&&v>V0)return 1;R=A&b,r[R]=f<<24|h<<16|E-a|0}}return A!==0&&(r[E+A]=d-y<<24|64<<16|0),o.bits=f,0},ms=W3,$3=0,np=1,rp=2,{Z_FINISH:K0,Z_BLOCK:K3,Z_TREES:Ho,Z_OK:dr,Z_STREAM_END:X3,Z_NEED_DICT:j3,Z_STREAM_ERROR:ri,Z_DATA_ERROR:ap,Z_MEM_ERROR:sp,Z_BUF_ERROR:Y3,Z_DEFLATED:X0}=Ss,qo=16180,j0=16181,Y0=16182,Z0=16183,q0=16184,J0=16185,Q0=16186,e_=16187,t_=16188,i_=16189,jo=16190,nn=16191,mm=16192,n_=16193,um=16194,r_=16195,a_=16196,s_=16197,o_=16198,Vo=16199,Wo=16200,c_=16201,d_=16202,l_=16203,m_=16204,u_=16205,fm=16206,f_=16207,h_=16208,We=16209,op=16210,cp=16211,Z3=852,q3=592,J3=15,Q3=J3,g_=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function e5(){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}var lr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<qo||t.mode>cp?1:0},dp=e=>{if(lr(e))return ri;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=qo,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(Z3),t.distcode=t.distdyn=new Int32Array(q3),t.sane=1,t.back=-1,dr},lp=e=>{if(lr(e))return ri;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,dp(e)},mp=(e,t)=>{let i;if(lr(e))return ri;let n=e.state;return t<0?(i=0,t=-t):(i=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ri:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,lp(e))},up=(e,t)=>{if(!e)return ri;let i=new e5;e.state=i,i.strm=e,i.window=null,i.mode=qo;let n=mp(e,t);return n!==dr&&(e.state=null),n},t5=e=>up(e,Q3),__=!0,hm,gm,i5=e=>{if(__){hm=new Int32Array(512),gm=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(ms(np,e.lens,0,288,hm,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ms(rp,e.lens,0,32,gm,0,e.work,{bits:5}),__=!1}e.lencode=hm,e.lenbits=9,e.distcode=gm,e.distbits=5},fp=(e,t,i,n)=>{let r,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>n&&(r=n),a.window.set(t.subarray(i-n,i-n+r),a.wnext),n-=r,n?(a.window.set(t.subarray(i-n,i),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r))),0},n5=(e,t)=>{let i,n,r,a,s,o,c,d,l,m,u,f,h,y,p=0,v,A,x,w,R,b,E,D,H=new Uint8Array(4),O,Y,J=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(lr(e)||!e.output||!e.input&&e.avail_in!==0)return ri;i=e.state,i.mode===nn&&(i.mode=mm),s=e.next_out,r=e.output,c=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=i.hold,l=i.bits,m=o,u=c,D=dr;e:for(;;)switch(i.mode){case qo:if(i.wrap===0){i.mode=mm;break}for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.wrap&2&&d===35615){i.wbits===0&&(i.wbits=15),i.check=0,H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0),d=0,l=0,i.mode=j0;break}if(i.head&&(i.head.done=!1),!(i.wrap&1)||(((d&255)<<8)+(d>>8))%31){e.msg="incorrect header check",i.mode=We;break}if((d&15)!==X0){e.msg="unknown compression method",i.mode=We;break}if(d>>>=4,l-=4,E=(d&15)+8,i.wbits===0&&(i.wbits=E),E>15||E>i.wbits){e.msg="invalid window size",i.mode=We;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=d&512?i_:nn,d=0,l=0;break;case j0:for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.flags=d,(i.flags&255)!==X0){e.msg="unknown compression method",i.mode=We;break}if(i.flags&57344){e.msg="unknown header flags set",i.mode=We;break}i.head&&(i.head.text=d>>8&1),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0)),d=0,l=0,i.mode=Y0;case Y0:for(;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.head&&(i.head.time=d),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,H[2]=d>>>16&255,H[3]=d>>>24&255,i.check=ft(i.check,H,4,0)),d=0,l=0,i.mode=Z0;case Z0:for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.head&&(i.head.xflags=d&255,i.head.os=d>>8),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0)),d=0,l=0,i.mode=q0;case q0:if(i.flags&1024){for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.length=d,i.head&&(i.head.extra_len=d),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0)),d=0,l=0}else i.head&&(i.head.extra=null);i.mode=J0;case J0:if(i.flags&1024&&(f=i.length,f>o&&(f=o),f&&(i.head&&(E=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(a,a+f),E)),i.flags&512&&i.wrap&4&&(i.check=ft(i.check,n,f,a)),o-=f,a+=f,i.length-=f),i.length))break e;i.length=0,i.mode=Q0;case Q0:if(i.flags&2048){if(o===0)break e;f=0;do E=n[a+f++],i.head&&E&&i.length<65536&&(i.head.name+=String.fromCharCode(E));while(E&&f<o);if(i.flags&512&&i.wrap&4&&(i.check=ft(i.check,n,f,a)),o-=f,a+=f,E)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=e_;case e_:if(i.flags&4096){if(o===0)break e;f=0;do E=n[a+f++],i.head&&E&&i.length<65536&&(i.head.comment+=String.fromCharCode(E));while(E&&f<o);if(i.flags&512&&i.wrap&4&&(i.check=ft(i.check,n,f,a)),o-=f,a+=f,E)break e}else i.head&&(i.head.comment=null);i.mode=t_;case t_:if(i.flags&512){for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.wrap&4&&d!==(i.check&65535)){e.msg="header crc mismatch",i.mode=We;break}d=0,l=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=nn;break;case i_:for(;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}e.adler=i.check=g_(d),d=0,l=0,i.mode=jo;case jo:if(i.havedict===0)return e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,i.hold=d,i.bits=l,j3;e.adler=i.check=1,i.mode=nn;case nn:if(t===K3||t===Ho)break e;case mm:if(i.last){d>>>=l&7,l-=l&7,i.mode=fm;break}for(;l<3;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}switch(i.last=d&1,d>>>=1,l-=1,d&3){case 0:i.mode=n_;break;case 1:if(i5(i),i.mode=Vo,t===Ho){d>>>=2,l-=2;break e}break;case 2:i.mode=a_;break;case 3:e.msg="invalid block type",i.mode=We}d>>>=2,l-=2;break;case n_:for(d>>>=l&7,l-=l&7;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if((d&65535)!==(d>>>16^65535)){e.msg="invalid stored block lengths",i.mode=We;break}if(i.length=d&65535,d=0,l=0,i.mode=um,t===Ho)break e;case um:i.mode=r_;case r_:if(f=i.length,f){if(f>o&&(f=o),f>c&&(f=c),f===0)break e;r.set(n.subarray(a,a+f),s),o-=f,a+=f,c-=f,s+=f,i.length-=f;break}i.mode=nn;break;case a_:for(;l<14;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.nlen=(d&31)+257,d>>>=5,l-=5,i.ndist=(d&31)+1,d>>>=5,l-=5,i.ncode=(d&15)+4,d>>>=4,l-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=We;break}i.have=0,i.mode=s_;case s_:for(;i.have<i.ncode;){for(;l<3;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.lens[J[i.have++]]=d&7,d>>>=3,l-=3}for(;i.have<19;)i.lens[J[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,O={bits:i.lenbits},D=ms($3,i.lens,0,19,i.lencode,0,i.work,O),i.lenbits=O.bits,D){e.msg="invalid code lengths set",i.mode=We;break}i.have=0,i.mode=o_;case o_:for(;i.have<i.nlen+i.ndist;){for(;p=i.lencode[d&(1<<i.lenbits)-1],v=p>>>24,A=p>>>16&255,x=p&65535,!(v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(x<16)d>>>=v,l-=v,i.lens[i.have++]=x;else{if(x===16){for(Y=v+2;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(d>>>=v,l-=v,i.have===0){e.msg="invalid bit length repeat",i.mode=We;break}E=i.lens[i.have-1],f=3+(d&3),d>>>=2,l-=2}else if(x===17){for(Y=v+3;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=v,l-=v,E=0,f=3+(d&7),d>>>=3,l-=3}else{for(Y=v+7;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=v,l-=v,E=0,f=11+(d&127),d>>>=7,l-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=We;break}for(;f--;)i.lens[i.have++]=E}}if(i.mode===We)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=We;break}if(i.lenbits=9,O={bits:i.lenbits},D=ms(np,i.lens,0,i.nlen,i.lencode,0,i.work,O),i.lenbits=O.bits,D){e.msg="invalid literal/lengths set",i.mode=We;break}if(i.distbits=6,i.distcode=i.distdyn,O={bits:i.distbits},D=ms(rp,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,O),i.distbits=O.bits,D){e.msg="invalid distances set",i.mode=We;break}if(i.mode=Vo,t===Ho)break e;case Vo:i.mode=Wo;case Wo:if(o>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,i.hold=d,i.bits=l,B3(e,u),s=e.next_out,r=e.output,c=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=i.hold,l=i.bits,i.mode===nn&&(i.back=-1);break}for(i.back=0;p=i.lencode[d&(1<<i.lenbits)-1],v=p>>>24,A=p>>>16&255,x=p&65535,!(v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(A&&(A&240)===0){for(w=v,R=A,b=x;p=i.lencode[b+((d&(1<<w+R)-1)>>w)],v=p>>>24,A=p>>>16&255,x=p&65535,!(w+v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=w,l-=w,i.back+=w}if(d>>>=v,l-=v,i.back+=v,i.length=x,A===0){i.mode=u_;break}if(A&32){i.back=-1,i.mode=nn;break}if(A&64){e.msg="invalid literal/length code",i.mode=We;break}i.extra=A&15,i.mode=c_;case c_:if(i.extra){for(Y=i.extra;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.length+=d&(1<<i.extra)-1,d>>>=i.extra,l-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=d_;case d_:for(;p=i.distcode[d&(1<<i.distbits)-1],v=p>>>24,A=p>>>16&255,x=p&65535,!(v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if((A&240)===0){for(w=v,R=A,b=x;p=i.distcode[b+((d&(1<<w+R)-1)>>w)],v=p>>>24,A=p>>>16&255,x=p&65535,!(w+v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=w,l-=w,i.back+=w}if(d>>>=v,l-=v,i.back+=v,A&64){e.msg="invalid distance code",i.mode=We;break}i.offset=x,i.extra=A&15,i.mode=l_;case l_:if(i.extra){for(Y=i.extra;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.offset+=d&(1<<i.extra)-1,d>>>=i.extra,l-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=We;break}i.mode=m_;case m_:if(c===0)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=We;break}f>i.wnext?(f-=i.wnext,h=i.wsize-f):h=i.wnext-f,f>i.length&&(f=i.length),y=i.window}else y=r,h=s-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do r[s++]=y[h++];while(--f);i.length===0&&(i.mode=Wo);break;case u_:if(c===0)break e;r[s++]=i.length,c--,i.mode=Wo;break;case fm:if(i.wrap){for(;l<32;){if(o===0)break e;o--,d|=n[a++]<<l,l+=8}if(u-=c,e.total_out+=u,i.total+=u,i.wrap&4&&u&&(e.adler=i.check=i.flags?ft(i.check,r,u,s-u):_s(i.check,r,u,s-u)),u=c,i.wrap&4&&(i.flags?d:g_(d))!==i.check){e.msg="incorrect data check",i.mode=We;break}d=0,l=0}i.mode=f_;case f_:if(i.wrap&&i.flags){for(;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.wrap&4&&d!==(i.total&4294967295)){e.msg="incorrect length check",i.mode=We;break}d=0,l=0}i.mode=h_;case h_:D=X3;break e;case We:D=ap;break e;case op:return sp;case cp:default:return ri}return e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,i.hold=d,i.bits=l,(i.wsize||u!==e.avail_out&&i.mode<We&&(i.mode<fm||t!==K0))&&fp(e,e.output,e.next_out,u-e.avail_out),m-=e.avail_in,u-=e.avail_out,e.total_in+=m,e.total_out+=u,i.total+=u,i.wrap&4&&u&&(e.adler=i.check=i.flags?ft(i.check,r,u,e.next_out-u):_s(i.check,r,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===nn?128:0)+(i.mode===Vo||i.mode===um?256:0),(m===0&&u===0||t===K0)&&D===dr&&(D=Y3),D},r5=e=>{if(lr(e))return ri;let t=e.state;return t.window&&(t.window=null),e.state=null,dr},a5=(e,t)=>{if(lr(e))return ri;let i=e.state;return(i.wrap&2)===0?ri:(i.head=t,t.done=!1,dr)},s5=(e,t)=>{let i=t.length,n,r,a;return lr(e)||(n=e.state,n.wrap!==0&&n.mode!==jo)?ri:n.mode===jo&&(r=1,r=_s(r,t,i,0),r!==n.check)?ap:(a=fp(e,t,i,i),a?(n.mode=op,sp):(n.havedict=1,dr))},o5=lp,c5=mp,d5=dp,l5=t5,m5=up,u5=n5,f5=r5,h5=a5,g5=s5,_5="pako inflate (from Nodeca project)",an={inflateReset:o5,inflateReset2:c5,inflateResetKeep:d5,inflateInit:l5,inflateInit2:m5,inflate:u5,inflateEnd:f5,inflateGetHeader:h5,inflateSetDictionary:g5,inflateInfo:_5};function p5(){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}var v5=p5,hp=Object.prototype.toString,{Z_NO_FLUSH:y5,Z_FINISH:w5,Z_OK:ys,Z_STREAM_END:_m,Z_NEED_DICT:pm,Z_STREAM_ERROR:S5,Z_DATA_ERROR:p_,Z_MEM_ERROR:k5}=Ss;function xs(e){this.options=Zo.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tp,this.strm.avail_out=0;let i=an.inflateInit2(this.strm,t.windowBits);if(i!==ys)throw new Error(or[i]);if(this.header=new v5,an.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=vs.string2buf(t.dictionary):hp.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=an.inflateSetDictionary(this.strm,t.dictionary),i!==ys)))throw new Error(or[i])}xs.prototype.push=function(e,t){let i=this.strm,n=this.options.chunkSize,r=this.options.dictionary,a,s,o;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?w5:y5,hp.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),a=an.inflate(i,s),a===pm&&r&&(a=an.inflateSetDictionary(i,r),a===ys?a=an.inflate(i,s):a===p_&&(a=pm));i.avail_in>0&&a===_m&&i.state.wrap>0&&e[i.next_in]!==0;)an.inflateReset(i),a=an.inflate(i,s);switch(a){case S5:case p_:case pm:case k5:return this.onEnd(a),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(i.avail_out===0||a===_m))if(this.options.to==="string"){let c=vs.utf8border(i.output,i.next_out),d=i.next_out-c,l=vs.buf2string(i.output,c);i.next_out=d,i.avail_out=n-d,d&&i.output.set(i.output.subarray(c,c+d),0),this.onData(l)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(a===ys&&o===0)){if(a===_m)return a=an.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(i.avail_in===0)break}}return!0};xs.prototype.onData=function(e){this.chunks.push(e)};xs.prototype.onEnd=function(e){e===ys&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Zo.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Dm(e,t){let i=new xs(t);if(i.push(e),i.err)throw i.msg||or[i.err];return i.result}function b5(e,t){return t=t||{},t.raw=!0,Dm(e,t)}var x5=xs,A5=Dm,E5=b5,T5=Dm,M5={Inflate:x5,inflate:A5,inflateRaw:E5,ungzip:T5},{Deflate:z5,deflate:R5,deflateRaw:C5,gzip:I5}=F3,{Inflate:L5,inflate:N5,inflateRaw:P5,ungzip:O5}=M5,F5=z5,D5=R5,B5=C5,U5=I5,G5=L5,H5=N5,V5=P5,W5=O5,$5=Ss,v_={Deflate:F5,deflate:D5,deflateRaw:B5,gzip:U5,Inflate:G5,inflate:H5,inflateRaw:V5,ungzip:W5,constants:$5},Bm=class Mm{constructor(t=Mm.INITIAL_SIZE){this.buffer=new Uint8Array(t),this.readOffset=0,this.writeOffset=0}append(t){let i=t instanceof Uint8Array?t:new Uint8Array(t),n=this.writeOffset+i.length;n>this.buffer.length&&this.grow(n),this.buffer.set(i,this.writeOffset),this.writeOffset+=i.length}hasBytes(t){return this.writeOffset-this.readOffset>=t}available(){return this.writeOffset-this.readOffset}readByte(){if(!this.hasBytes(1))throw new Error("Buffer underflow");return this.buffer[this.readOffset++]}readShort(){if(!this.hasBytes(2))throw new Error("Buffer underflow");let t=this.buffer[this.readOffset]|this.buffer[this.readOffset+1]<<8;return this.readOffset+=2,t>32767?t-65536:t}readLong(){if(!this.hasBytes(4))throw new Error("Buffer underflow");let t=this.buffer[this.readOffset]|this.buffer[this.readOffset+1]<<8|this.buffer[this.readOffset+2]<<16|this.buffer[this.readOffset+3]<<24;return this.readOffset+=4,t}readFloat(){if(!this.hasBytes(4))throw new Error("Buffer underflow");let i=new DataView(this.buffer.buffer,this.buffer.byteOffset+this.readOffset,4).getFloat32(0,!0);return this.readOffset+=4,i}readString(){let t=Math.min(Mm.MAX_STRING_LENGTH,this.writeOffset-this.readOffset),i=0;for(;i<t&&this.buffer[this.readOffset+i]!==0;)i++;if(i>=t)throw this.writeOffset-this.readOffset<=t?new Error("Buffer underflow"):new Error("String exceeds max length");let n=this.buffer.slice(this.readOffset,this.readOffset+i);return this.readOffset+=i+1,new TextDecoder("latin1").decode(n)}peekBytes(t){if(!this.hasBytes(t))throw new Error("Buffer underflow");return this.buffer.slice(this.readOffset,this.readOffset+t)}readBytes(t){if(!this.hasBytes(t))throw new Error("Buffer underflow");let i=this.buffer.slice(this.readOffset,this.readOffset+t);return this.readOffset+=t,i}readData(t){return this.readBytes(t)}getReadPosition(){return this.readOffset}getWritePosition(){return this.writeOffset}setReadPosition(t){if(t<0||t>this.writeOffset)throw new Error("Invalid read position");this.readOffset=t}grow(t){let i=t?Math.max(t,this.buffer.length*2):this.buffer.length*2,n=new Uint8Array(i);n.set(this.buffer),this.buffer=n}compact(){if(this.readOffset===0)return;let t=this.writeOffset-this.readOffset;if(t===0){this.readOffset=0,this.writeOffset=0;return}this.buffer.copyWithin(0,this.readOffset,this.writeOffset),this.readOffset=0,this.writeOffset=t}getCapacity(){return this.buffer.length}reset(){this.readOffset=0,this.writeOffset=0}};Bm.INITIAL_SIZE=64*1024;Bm.MAX_STRING_LENGTH=2048;var K5=Bm,Ln=()=>({number:0,modelindex:0,modelindex2:0,modelindex3:0,modelindex4:0,frame:0,skinnum:0,effects:0,renderfx:0,origin:{x:0,y:0,z:0},old_origin:{x:0,y:0,z:0},angles:{x:0,y:0,z:0},sound:0,event:0,solid:0,bits:0,bitsHigh:0,alpha:0,scale:0,instanceBits:0,loopVolume:0,loopAttenuation:0,owner:0,oldFrame:0}),Jo=()=>({pm_type:0,origin:{x:0,y:0,z:0},velocity:{x:0,y:0,z:0},pm_time:0,pm_flags:0,gravity:0,delta_angles:{x:0,y:0,z:0},viewoffset:{x:0,y:0,z:0},viewangles:{x:0,y:0,z:0},kick_angles:{x:0,y:0,z:0},gun_index:0,gun_frame:0,gun_offset:{x:0,y:0,z:0},gun_angles:{x:0,y:0,z:0},blend:[0,0,0,0],fov:0,rdflags:0,stats:new Array(32).fill(0),gunskin:0,gunrate:0,damage_blend:[0,0,0,0],team_id:0,watertype:0}),y_={0:I.bad,1:I.nop,2:I.disconnect,3:I.reconnect,4:I.download,5:I.frame,6:I.inventory,7:I.layout,8:I.muzzleflash,9:I.temp_entity,10:I.sound,11:I.print,12:I.stufftext,13:I.serverdata,14:I.configstring,15:I.spawnbaseline,16:I.centerprint,17:I.playerinfo,18:I.packetentities,19:I.deltapacketentities,20:I.muzzleflash2},X5=class{constructor(){this.protocolVersion=34}translateCommand(e){return y_[e]!==void 0?y_[e]:I.bad}parseServerData(e){let t=e.readLong(),i=e.readLong(),n=e.readByte(),r=e.readString(),a=e.readShort(),s=e.readString();return{protocol:t,serverCount:i,attractLoop:n,gameDir:r,playerNum:a,levelName:s}}parseEntityBits(e){let t=e.readByte();t&zo&&(t|=e.readByte()<<8),t&Io&&(t|=e.readByte()<<16),t&Lo&&(t|=e.readByte()<<24);let i;return t&Ro?i=e.readShort():i=e.readByte(),{number:i,bits:t,bitsHigh:0}}parseDelta(e,t,i,n,r,a){t.number=e.number,t.modelindex=e.modelindex,t.modelindex2=e.modelindex2,t.modelindex3=e.modelindex3,t.modelindex4=e.modelindex4,t.frame=e.frame,t.skinnum=e.skinnum,t.effects=e.effects,t.renderfx=e.renderfx,t.origin.x=e.origin.x,t.origin.y=e.origin.y,t.origin.z=e.origin.z,t.old_origin.x=e.origin.x,t.old_origin.y=e.origin.y,t.old_origin.z=e.origin.z,t.angles.x=e.angles.x,t.angles.y=e.angles.y,t.angles.z=e.angles.z,t.sound=e.sound,t.event=e.event,t.solid=e.solid,t.number=i,t.bits=n,n&Hr&&(t.modelindex=a.readByte()),n&Wr&&(t.modelindex2=a.readByte()),n&$r&&(t.modelindex3=a.readByte()),n&Kr&&(t.modelindex4=a.readByte()),n&Dr&&(t.frame=a.readByte()),n&Vr&&(t.frame=a.readShort()),n&Ji&&n&tn?t.skinnum=a.readLong():n&Ji?t.skinnum=a.readByte():n&tn&&(t.skinnum=a.readShort()),n&qi&&n&en?t.effects=a.readLong():n&qi?t.effects=a.readByte():n&en&&(t.effects=a.readShort()),n&Zi&&n&Qi?t.renderfx=a.readLong():n&Zi?t.renderfx=a.readByte():n&Qi&&(t.renderfx=a.readShort()),n&Nr&&(t.origin.x=a.readShort()*.125),n&Pr&&(t.origin.y=a.readShort()*.125),n&Ur&&(t.origin.z=a.readShort()*.125),n&Gr&&(t.angles.x=a.readByte()*(360/256)),n&Or&&(t.angles.y=a.readByte()*(360/256)),n&Fr&&(t.angles.z=a.readByte()*(360/256)),n&Xr&&(t.old_origin.x=a.readShort()*.125,t.old_origin.y=a.readShort()*.125,t.old_origin.z=a.readShort()*.125),n&jr&&(t.sound=a.readByte()),n&Br?t.event=a.readByte():t.event=0,n&Yr&&(t.solid=a.readShort())}parsePlayerState(e){let t=Jo(),i=e.readShort();i&1&&(t.pm_type=e.readByte()),i&2&&(t.origin.x=e.readShort()*.125,t.origin.y=e.readShort()*.125,t.origin.z=e.readShort()*.125),i&4&&(t.velocity.x=e.readShort()*.125,t.velocity.y=e.readShort()*.125,t.velocity.z=e.readShort()*.125),i&8&&(t.pm_time=e.readByte()),i&16&&(t.pm_flags=e.readByte()),i&32&&(t.gravity=e.readShort()),i&64&&(t.delta_angles.x=e.readShort()*(180/32768),t.delta_angles.y=e.readShort()*(180/32768),t.delta_angles.z=e.readShort()*(180/32768)),i&128&&(t.viewoffset.x=(e.readByte()<<24>>24)*.25,t.viewoffset.y=(e.readByte()<<24>>24)*.25,t.viewoffset.z=(e.readByte()<<24>>24)*.25),i&256&&(t.viewangles.x=e.readShort()*(360/65536),t.viewangles.y=e.readShort()*(360/65536),t.viewangles.z=e.readShort()*(360/65536)),i&512&&(t.kick_angles.x=(e.readByte()<<24>>24)*.25,t.kick_angles.y=(e.readByte()<<24>>24)*.25,t.kick_angles.z=(e.readByte()<<24>>24)*.25),i&4096&&(t.gun_index=e.readByte()),i&8192&&(t.gun_frame=e.readByte(),t.gun_offset.x=(e.readByte()<<24>>24)*.25,t.gun_offset.y=(e.readByte()<<24>>24)*.25,t.gun_offset.z=(e.readByte()<<24>>24)*.25,t.gun_angles.x=(e.readByte()<<24>>24)*.25,t.gun_angles.y=(e.readByte()<<24>>24)*.25,t.gun_angles.z=(e.readByte()<<24>>24)*.25),i&1024&&(t.blend[0]=e.readByte(),t.blend[1]=e.readByte(),t.blend[2]=e.readByte(),t.blend[3]=e.readByte()),i&2048&&(t.fov=e.readByte()),i&16384&&(t.rdflags=e.readByte()),i&32768&&(t.watertype=e.readByte());let n=e.readLong();for(let r=0;r<32;r++)n&1<<r&&(t.stats[r]=e.readShort());return t}},sa=2023,j5=class{constructor(){this.protocolVersion=sa}translateCommand(e){return e}parseServerData(e){let t=e.readLong(),i=e.readLong(),n=e.readByte(),r=e.readByte(),a=e.readString(),s=e.readShort();if(s===-2){let c=e.readShort();for(let d=0;d<c;d++)e.readShort();s=0}else s===-1&&(s=-1);let o=e.readString();return{protocol:t,serverCount:i,spawnCount:i,attractLoop:0,gameDir:a,playerNum:s,levelName:o,tickRate:r,demoType:n}}parseEntityBits(e){let t=e.readByte();t&zo&&(t|=e.readByte()<<8),t&Io&&(t|=e.readByte()<<16),t&Lo&&(t|=e.readByte()<<24);let i=0;t&h0&&(i=e.readByte());let n;return t&Ro?n=e.readShort():n=e.readByte(),{number:n,bits:t,bitsHigh:i}}parseDelta(e,t,i,n,r,a){Object.assign(t,e),t.origin={...e.origin},t.old_origin={...e.old_origin},t.angles={...e.angles},t.number=i,t.bits=n,t.bitsHigh=r,n&Hr&&(t.modelindex=a.readByte()),n&Wr&&(t.modelindex2=a.readByte()),n&$r&&(t.modelindex3=a.readByte()),n&Kr&&(t.modelindex4=a.readByte()),n&Dr&&(t.frame=a.readByte()),n&Vr&&(t.frame=a.readShort()),n&Ji&&n&tn?t.skinnum=a.readLong():n&Ji?t.skinnum=a.readByte():n&tn&&(t.skinnum=a.readShort()),n&qi&&n&en?t.effects=a.readLong():n&qi?t.effects=a.readByte():n&en&&(t.effects=a.readShort()),n&Zi&&n&Qi?t.renderfx=a.readLong():n&Zi?t.renderfx=a.readByte():n&Qi&&(t.renderfx=a.readShort()),n&Nr&&(t.origin.x=a.readShort()*.125),n&Pr&&(t.origin.y=a.readShort()*.125),n&Ur&&(t.origin.z=a.readShort()*.125),n&Gr&&(t.angles.x=a.readByte()*(360/256)),n&Or&&(t.angles.y=a.readByte()*(360/256)),n&Fr&&(t.angles.z=a.readByte()*(360/256)),n&Xr&&(t.old_origin.x=a.readShort()*.125,t.old_origin.y=a.readShort()*.125,t.old_origin.z=a.readShort()*.125),n&jr&&(t.sound=a.readByte()),n&Br?t.event=a.readByte():t.event=0,n&Yr&&(t.solid=a.readShort()),n&Co&&(t.alpha=a.readByte()/255),n&No&&(t.scale=a.readFloat()),n&Po&&(t.instanceBits=a.readLong()),n&Oo&&(t.loopVolume=a.readByte()/255),r&Jl&&(t.loopAttenuation=a.readByte()/255),r&Ql&&(t.owner=a.readShort()),r&em&&(t.oldFrame=a.readShort())}parsePlayerState(e){let t=Jo(),i=e.readShort();i&1&&(t.pm_type=e.readByte()),i&2&&(t.origin.x=e.readShort()*.125,t.origin.y=e.readShort()*.125,t.origin.z=e.readShort()*.125),i&4&&(t.velocity.x=e.readShort()*.125,t.velocity.y=e.readShort()*.125,t.velocity.z=e.readShort()*.125),i&8&&(t.pm_time=e.readByte()),i&16&&(t.pm_flags=e.readByte()),i&32&&(t.gravity=e.readShort()),i&64&&(t.delta_angles.x=e.readShort()*(180/32768),t.delta_angles.y=e.readShort()*(180/32768),t.delta_angles.z=e.readShort()*(180/32768)),i&128&&(t.viewoffset.x=(e.readByte()<<24>>24)*.25,t.viewoffset.y=(e.readByte()<<24>>24)*.25,t.viewoffset.z=(e.readByte()<<24>>24)*.25),i&256&&(t.viewangles.x=e.readShort()*(360/65536),t.viewangles.y=e.readShort()*(360/65536),t.viewangles.z=e.readShort()*(360/65536)),i&512&&(t.kick_angles.x=(e.readByte()<<24>>24)*.25,t.kick_angles.y=(e.readByte()<<24>>24)*.25,t.kick_angles.z=(e.readByte()<<24>>24)*.25),i&4096&&(t.gun_index=e.readByte()),i&8192&&(t.gun_frame=e.readByte(),t.gun_offset.x=(e.readByte()<<24>>24)*.25,t.gun_offset.y=(e.readByte()<<24>>24)*.25,t.gun_offset.z=(e.readByte()<<24>>24)*.25,t.gun_angles.x=(e.readByte()<<24>>24)*.25,t.gun_angles.y=(e.readByte()<<24>>24)*.25,t.gun_angles.z=(e.readByte()<<24>>24)*.25),i&1024&&(t.blend[0]=e.readByte(),t.blend[1]=e.readByte(),t.blend[2]=e.readByte(),t.blend[3]=e.readByte()),i&2048&&(t.fov=e.readByte()),i&16384&&(t.rdflags=e.readByte()),i&32768&&(t.watertype=e.readByte());let n=e.readLong();for(let r=0;r<32;r++)n&1<<r&&(t.stats[r]=e.readShort());return t}},Y5=class{constructor(e=0){this.protocolVersion=e}translateCommand(e){return e}parseServerData(e){let t=e.readLong(),i=e.readLong(),n=e.readByte(),r=e.readString(),a=e.readShort(),s=e.readString();return{protocol:t,serverCount:i,attractLoop:n,gameDir:r,playerNum:a,levelName:s}}parseEntityBits(e){let t=e.readByte();t&zo&&(t|=e.readByte()<<8),t&Io&&(t|=e.readByte()<<16),t&Lo&&(t|=e.readByte()<<24);let i;return t&Ro?i=e.readShort():i=e.readByte(),{number:i,bits:t,bitsHigh:0}}parseDelta(e,t,i,n,r,a){t.number=e.number,t.modelindex=e.modelindex,t.modelindex2=e.modelindex2,t.modelindex3=e.modelindex3,t.modelindex4=e.modelindex4,t.frame=e.frame,t.skinnum=e.skinnum,t.effects=e.effects,t.renderfx=e.renderfx,t.origin.x=e.origin.x,t.origin.y=e.origin.y,t.origin.z=e.origin.z,t.old_origin.x=e.origin.x,t.old_origin.y=e.origin.y,t.old_origin.z=e.origin.z,t.angles.x=e.angles.x,t.angles.y=e.angles.y,t.angles.z=e.angles.z,t.sound=e.sound,t.event=e.event,t.solid=e.solid,t.number=i,t.bits=n,n&Hr&&(t.modelindex=a.readByte()),n&Wr&&(t.modelindex2=a.readByte()),n&$r&&(t.modelindex3=a.readByte()),n&Kr&&(t.modelindex4=a.readByte()),n&Dr&&(t.frame=a.readByte()),n&Vr&&(t.frame=a.readShort()),n&Ji&&n&tn?t.skinnum=a.readLong():n&Ji?t.skinnum=a.readByte():n&tn&&(t.skinnum=a.readShort()),n&qi&&n&en?t.effects=a.readLong():n&qi?t.effects=a.readByte():n&en&&(t.effects=a.readShort()),n&Zi&&n&Qi?t.renderfx=a.readLong():n&Zi?t.renderfx=a.readByte():n&Qi&&(t.renderfx=a.readShort()),n&Nr&&(t.origin.x=a.readShort()*.125),n&Pr&&(t.origin.y=a.readShort()*.125),n&Ur&&(t.origin.z=a.readShort()*.125),n&Gr&&(t.angles.x=a.readByte()*(360/256)),n&Or&&(t.angles.y=a.readByte()*(360/256)),n&Fr&&(t.angles.z=a.readByte()*(360/256)),n&Xr&&(t.old_origin.x=a.readShort()*.125,t.old_origin.y=a.readShort()*.125,t.old_origin.z=a.readShort()*.125),n&jr&&(t.sound=a.readByte()),n&Br?t.event=a.readByte():t.event=0,n&Yr&&(t.solid=a.readShort())}parsePlayerState(e){let t=Jo(),i=e.readShort();i&1&&(t.pm_type=e.readByte()),i&2&&(t.origin.x=e.readShort()*.125,t.origin.y=e.readShort()*.125,t.origin.z=e.readShort()*.125),i&4&&(t.velocity.x=e.readShort()*.125,t.velocity.y=e.readShort()*.125,t.velocity.z=e.readShort()*.125),i&8&&(t.pm_time=e.readByte()),i&16&&(t.pm_flags=e.readByte()),i&32&&(t.gravity=e.readShort()),i&64&&(t.delta_angles.x=e.readShort()*(180/32768),t.delta_angles.y=e.readShort()*(180/32768),t.delta_angles.z=e.readShort()*(180/32768)),i&128&&(t.viewoffset.x=(e.readByte()<<24>>24)*.25,t.viewoffset.y=(e.readByte()<<24>>24)*.25,t.viewoffset.z=(e.readByte()<<24>>24)*.25),i&256&&(t.viewangles.x=e.readShort()*(360/65536),t.viewangles.y=e.readShort()*(360/65536),t.viewangles.z=e.readShort()*(360/65536)),i&512&&(t.kick_angles.x=(e.readByte()<<24>>24)*.25,t.kick_angles.y=(e.readByte()<<24>>24)*.25,t.kick_angles.z=(e.readByte()<<24>>24)*.25),i&4096&&(t.gun_index=e.readByte()),i&8192&&(t.gun_frame=e.readByte(),t.gun_offset.x=(e.readByte()<<24>>24)*.25,t.gun_offset.y=(e.readByte()<<24>>24)*.25,t.gun_offset.z=(e.readByte()<<24>>24)*.25,t.gun_angles.x=(e.readByte()<<24>>24)*.25,t.gun_angles.y=(e.readByte()<<24>>24)*.25,t.gun_angles.z=(e.readByte()<<24>>24)*.25),i&1024&&(t.blend[0]=e.readByte(),t.blend[1]=e.readByte(),t.blend[2]=e.readByte(),t.blend[3]=e.readByte()),i&2048&&(t.fov=e.readByte()),i&16384&&(t.rdflags=e.readByte()),i&32768&&(t.watertype=e.readByte());let n=e.readLong();for(let r=0;r<32;r++)n&1<<r&&(t.stats[r]=e.readShort());return t}},gp=class{constructor(){this.protocolVersion=0}translateCommand(e){return e===7?I.serverdata:e===12?I.serverdata:e===13?I.serverdata:e===I.stufftext?I.stufftext:I.bad}parseServerData(e){let t=e.readLong();if(t===sa){let i=e.readLong(),n=e.readByte(),r=e.readByte(),a=e.readString(),s=e.readShort();if(s===-2){let c=e.readShort();for(let d=0;d<c;d++)e.readShort();s=0}else s===-1&&(s=-1);let o=e.readString();return{protocol:t,serverCount:i,spawnCount:i,attractLoop:0,gameDir:a,playerNum:s,levelName:o,tickRate:r,demoType:n}}else{let i=e.readLong(),n=e.readByte(),r=e.readString(),a=e.readShort(),s=e.readString();return{protocol:t,serverCount:i,attractLoop:n,gameDir:r,playerNum:a,levelName:s}}}parseEntityBits(e){throw new Error("Bootstrap handler cannot parse entities")}parseDelta(e,t,i,n,r,a){throw new Error("Bootstrap handler cannot parse delta")}parsePlayerState(e){throw new Error("Bootstrap handler cannot parse player state")}};function Z5(e){return e===0?new gp:e===sa?new j5:e===34?new X5:new Y5(e)}var w_=1,q5=2,J5=128,Q5=class extends K5{constructor(e){super(0),this.stream=e}readByte(){return this.stream.readByte()}readShort(){return this.stream.readShort()}readLong(){return this.stream.readLong()}readFloat(){return this.stream.readFloat()}readString(){return this.stream.readString()}readData(e){return this.stream.readData(e)}hasBytes(e){return this.stream.hasMore()}available(){return this.stream.getRemaining()}getReadPosition(){return this.stream.getPosition()}peekBytes(e){throw new Error("peekBytes not implemented for BinaryStreamAdapter")}},Qo=class _p{constructor(t,i,n=!1){this.strictMode=!1,this.errorCount=0,this.isDemo=w_,t instanceof nr?this.stream=new Q5(t):this.stream=t,this.handler=i,this.strictMode=n,this.protocolHandler=new gp}setProtocolVersion(t){this.protocolHandler.protocolVersion!==t&&(this.protocolHandler=Z5(t))}getProtocolVersion(){return this.protocolHandler.protocolVersion}getErrorCount(){return this.errorCount}parseMessage(){for(;this.stream.hasBytes(1);){let t=this.stream.getReadPosition(),i=-1;try{if(i=this.stream.readByte(),i===-1)break;let n=i,r=this.protocolHandler.translateCommand(i);switch(r){case I.bad:if(n===0)return;let a=`Unknown server command: ${n} (translated: ${r}) at offset ${t} (Protocol: ${this.getProtocolVersion()})`;if(this.strictMode)throw new Error(a);console.warn(a),this.errorCount++;return;case I.nop:break;case I.disconnect:this.handler?.onDisconnect&&this.handler.onDisconnect();break;case I.reconnect:this.handler?.onReconnect&&this.handler.onReconnect();break;case I.print:this.parsePrint();break;case I.serverdata:this.parseServerData();break;case I.configstring:this.parseConfigString();break;case I.spawnbaseline:this.parseSpawnBaseline();break;case I.centerprint:this.parseCenterPrint();break;case I.download:this.parseDownload();break;case I.frame:this.parseFrame();break;case I.packetentities:this.parsePacketEntities(!1);break;case I.deltapacketentities:this.parsePacketEntities(!0);break;case I.playerinfo:this.parsePlayerState();break;case I.stufftext:this.parseStuffText();break;case I.layout:this.parseLayout();break;case I.inventory:this.parseInventory();break;case I.sound:this.parseSound();break;case I.muzzleflash:this.parseMuzzleFlash();break;case I.muzzleflash2:this.parseMuzzleFlash2();break;case I.temp_entity:this.parseTempEntity();break;case I.splitclient:this.parseSplitClient();break;case I.configblast:this.parseConfigBlast();break;case I.spawnbaselineblast:this.parseSpawnBaselineBlast();break;case I.level_restart:this.handler?.onLevelRestart&&this.handler.onLevelRestart();break;case I.damage:this.parseDamage();break;case I.locprint:this.parseLocPrint();break;case I.fog:this.parseFog();break;case I.waitingforplayers:this.parseWaitingForPlayers();break;case I.bot_chat:this.parseBotChat();break;case I.poi:this.parsePoi();break;case I.help_path:this.parseHelpPath();break;case I.muzzleflash3:this.parseMuzzleFlash3();break;case I.achievement:this.parseAchievement();break;default:let s=`Unknown server command: ${n} (translated: ${r}) at offset ${t}`;if(this.strictMode)throw new Error(s);console.warn(s),this.errorCount++;return}}catch(n){let r=n.message;if(r==="Buffer underflow"||r.includes("StreamingBuffer")){try{this.stream.setReadPosition(t)}catch(s){console.error("Failed to rollback stream position",s)}return}let a=`offset ${t}, cmd ${i}, protocol ${this.getProtocolVersion()}`;if(console.warn(`Error parsing command ${i} (${a}): ${r}`),this.errorCount++,this.strictMode)throw n;return}}}readAngle16(){return this.stream.readShort()*(360/65536)}readCoord(){return this.stream.readShort()*.125}readAngle(){return this.stream.readByte()*(360/256)}readPos(t){t.x=this.stream.readShort()*.125,t.y=this.stream.readShort()*.125,t.z=this.stream.readShort()*.125}readDir(t){let i=this.stream.readByte();if(i>=$i.length)t.x=0,t.y=0,t.z=0;else{let n=$i[i];t.x=n[0],t.y=n[1],t.z=n[2]}}parsePrint(){let t=this.stream.readByte(),i=this.stream.readString();this.handler&&this.handler.onPrint(t,i)}parseStuffText(){let t=this.stream.readString();this.handler&&this.handler.onStuffText(t)}parseLayout(){let t=this.stream.readString();this.handler&&this.handler.onLayout(t)}parseCenterPrint(){let t=this.stream.readString();this.handler&&this.handler.onCenterPrint(t)}parseServerData(){let t=this.protocolHandler.parseServerData(this.stream);this.setProtocolVersion(t.protocol),this.handler&&this.handler.onServerData(t.protocol,t.serverCount,t.attractLoop,t.gameDir,t.playerNum,t.levelName,t.tickRate,t.demoType),t.protocol===sa?this.isDemo=t.demoType??w_:this.isDemo=t.attractLoop}parseConfigString(){let t=this.stream.readShort(),i=this.stream.readString();this.handler&&this.handler.onConfigString(t,i)}parseSplitClient(){let t=this.stream.readByte();this.handler?.onSplitClient&&this.handler.onSplitClient(t)}parseConfigBlast(){let t=this.stream.readShort();this.stream.readShort();let i=this.stream.readData(t);try{let n=v_.inflate(i),r=new nr(n.buffer);for(;r.hasMore();){let a=r.readUShort(),s=r.readString();this.handler&&this.handler.onConfigString(a,s)}}catch(n){console.error("svc_configblast error",n)}}parseSpawnBaselineBlast(){let t=this.stream.readShort();this.stream.readShort();let i=this.stream.readData(t);try{let n=v_.inflate(i),r=new nr(n.buffer),a=new _p(r,this.handler,this.strictMode);for(a.setProtocolVersion(this.getProtocolVersion());r.hasMore();)a.parseSpawnBaseline()}catch(n){console.error("svc_spawnbaselineblast error",n)}}parseLocPrint(){let t=this.stream.readByte(),i=this.stream.readString(),n=this.stream.readByte(),r=[];for(let a=0;a<n;a++)r.push(this.stream.readString());this.handler?.onLocPrint&&this.handler.onLocPrint(t,i,r)}parseWaitingForPlayers(){let t=this.stream.readByte();this.handler?.onWaitingForPlayers&&this.handler.onWaitingForPlayers(t)}parseBotChat(){this.stream.readString(),this.stream.readShort();let t=this.stream.readString();this.handler?.onBotChat&&this.handler.onBotChat(t)}parsePoi(){this.stream.readShort(),this.stream.readShort();let t={x:0,y:0,z:0};this.readPos(t),this.stream.readShort(),this.stream.readByte();let i=this.stream.readByte();this.handler?.onPoi&&this.handler.onPoi(i,t)}parseHelpPath(){this.stream.readByte();let t={x:0,y:0,z:0};this.readPos(t);let i={x:0,y:0,z:0};this.readDir(i),this.handler?.onHelpPath&&this.handler.onHelpPath(t)}parseAchievement(){let t=this.stream.readString();this.handler?.onAchievement&&this.handler.onAchievement(t)}parseDownload(){let t=this.stream.readShort(),i=this.stream.readByte(),n;t>0&&(n=this.stream.readData(t)),this.handler&&this.handler.onDownload(t,i,n)}parseInventory(){let i=new Array(256);for(let n=0;n<256;n++)i[n]=this.stream.readShort();this.handler&&this.handler.onInventory(i)}parseSound(){let t=this.stream.readByte(),i=this.stream.readByte(),n,r,a,s,o;if(t&1&&(n=this.stream.readByte()),t&2&&(r=this.stream.readByte()),t&16&&(a=this.stream.readByte()),t&8&&(s=this.stream.readShort()),t&4){let c={x:0,y:0,z:0};this.readPos(c),o=c}this.handler&&this.handler.onSound(t,i,n,r,a,s,o)}parseMuzzleFlash(){let t=this.stream.readShort(),i=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash(t,i)}parseMuzzleFlash2(){let t=this.stream.readShort(),i=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash2(t,i)}parseMuzzleFlash3(){let t=this.stream.readShort(),i=this.stream.readShort();this.handler?.onMuzzleFlash3&&this.handler.onMuzzleFlash3(t,i)}parseFog(){let t=this.stream.readByte();if(t&128){let n=this.stream.readByte();t|=n<<8}let i={};t&1&&(i.density=this.stream.readFloat(),i.skyfactor=this.stream.readByte()),t&2&&(i.red=this.stream.readByte()),t&4&&(i.green=this.stream.readByte()),t&8&&(i.blue=this.stream.readByte()),t&16&&(i.time=this.stream.readShort()),t&32&&(i.hf_falloff=this.stream.readFloat()),t&64&&(i.hf_density=this.stream.readFloat()),t&256&&(i.hf_start_r=this.stream.readByte()),t&512&&(i.hf_start_g=this.stream.readByte()),t&1024&&(i.hf_start_b=this.stream.readByte()),t&2048&&(i.hf_start_dist=this.stream.readLong()),t&4096&&(i.hf_end_r=this.stream.readByte()),t&8192&&(i.hf_end_g=this.stream.readByte()),t&16384&&(i.hf_end_b=this.stream.readByte()),t&32768&&(i.hf_end_dist=this.stream.readLong()),this.handler?.onFog&&this.handler.onFog(i)}parseDamage(){let t=this.stream.readByte(),i=[];for(let n=0;n<t;n++){let r=this.stream.readByte(),a={x:0,y:0,z:0};this.readDir(a);let s=r&31,o=(r&32)!==0,c=(r&64)!==0,d=(r&128)!==0;i.push({damage:s,health:o,armor:c,power:d,dir:a})}this.handler?.onDamage&&this.handler.onDamage(i)}parseTempEntity(){let t=this.stream.readByte(),i={x:0,y:0,z:0},n={x:0,y:0,z:0},r={x:0,y:0,z:0},a,s,o,c,d;switch(t){case N.EXPLOSION1:case N.EXPLOSION2:case N.ROCKET_EXPLOSION:case N.GRENADE_EXPLOSION:case N.ROCKET_EXPLOSION_WATER:case N.GRENADE_EXPLOSION_WATER:case N.BFG_EXPLOSION:case N.BFG_BIGEXPLOSION:case N.BOSSTPORT:case N.PLASMA_EXPLOSION:case N.PLAIN_EXPLOSION:case N.CHAINFIST_SMOKE:case N.TRACKER_EXPLOSION:case N.TELEPORT_EFFECT:case N.DBALL_GOAL:case N.NUKEBLAST:case N.WIDOWSPLASH:case N.EXPLOSION1_BIG:case N.EXPLOSION1_NP:this.readPos(i);break;case N.GUNSHOT:case N.BLOOD:case N.BLASTER:case N.SHOTGUN:case N.SPARKS:case N.BULLET_SPARKS:case N.SCREEN_SPARKS:case N.SHIELD_SPARKS:case N.BLASTER2:case N.FLECHETTE:case N.MOREBLOOD:case N.ELECTRIC_SPARKS:case N.HEATBEAM_SPARKS:case N.HEATBEAM_STEAM:this.readPos(i),this.readDir(r);break;case N.SPLASH:case N.LASER_SPARKS:case N.WELDING_SPARKS:case N.TUNNEL_SPARKS:a=this.stream.readByte(),this.readPos(i),this.readDir(r),s=this.stream.readByte();break;case N.BLUEHYPERBLASTER:this.getProtocolVersion()>=32?(this.readPos(i),this.readPos(n)):(this.readPos(i),this.readDir(r));break;case N.GREENBLOOD:this.getProtocolVersion()>=32?(this.readPos(i),this.readDir(r)):(this.readPos(i),this.readPos(n));break;case N.RAILTRAIL:case N.BUBBLETRAIL:case N.BFG_LASER:case N.DEBUGTRAIL:case N.BUBBLETRAIL2:this.readPos(i),this.readPos(n);break;case N.PARASITE_ATTACK:case N.MEDIC_CABLE_ATTACK:this.stream.readShort(),this.readPos(i),this.readPos(n);break;case N.GRAPPLE_CABLE:o=this.stream.readShort(),this.readPos(i),this.readPos(n),this.readPos(r);break;case N.LIGHTNING:c=this.stream.readShort(),d=this.stream.readShort(),this.readPos(i),this.readPos(n);break;case N.FLASHLIGHT:this.readPos(i),o=this.stream.readShort();break;case N.FORCEWALL:this.readPos(i),this.readPos(n),s=this.stream.readByte();break;case N.STEAM:let l=this.stream.readShort();a=this.stream.readByte(),this.readPos(i),this.readDir(r),s=this.stream.readByte(),this.stream.readShort(),l!==-1&&this.stream.readLong();break;case N.WIDOWBEAMOUT:this.stream.readShort();case N.HEATBEAM:case N.MONSTER_HEATBEAM:o=this.stream.readShort(),this.readPos(i),this.readPos(n),this.readDir(r);break}this.handler&&this.handler.onTempEntity(t,i,n,r,a,s,o,c,d)}parseSpawnBaseline(){let t=this.protocolHandler.parseEntityBits(this.stream),i=Ln();this.protocolHandler.parseDelta(Ln(),i,t.number,t.bits,t.bitsHigh,this.stream),this.handler&&this.handler.onSpawnBaseline(i)}parseFrame(){let t=this.stream.readLong(),i=this.stream.readLong(),n=0;this.getProtocolVersion()!==26&&this.getProtocolVersion()!==25&&(n=this.stream.readByte());let r=this.stream.readByte(),a=this.stream.readData(r),s=this.stream.readByte();if(s=this.protocolHandler.translateCommand(s),s!==I.playerinfo){if(this.strictMode)throw new Error(`Expected svc_playerinfo after svc_frame, got ${s}`);return}let o=this.parsePlayerState(),c=this.stream.readByte();if(c=this.protocolHandler.translateCommand(c),c!==I.packetentities&&c!==I.deltapacketentities){if(this.strictMode)throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${c}`);return}let d=this.collectPacketEntities();if(this.isDemo===J5){let l=this.stream.readByte();for(let m=0;m<l;m++)this.stream.readByte()}this.isDemo===q5&&this.stream.readLong(),this.handler&&this.handler.onFrame({serverFrame:t,deltaFrame:i,surpressCount:n,areaBytes:r,areaBits:a,playerState:o,packetEntities:{delta:!0,entities:d}})}parsePlayerState(){return this.protocolHandler.parsePlayerState(this.stream)}parsePacketEntities(t){let i=this.collectPacketEntities();this.handler&&this.handler.onFrame({serverFrame:0,deltaFrame:0,surpressCount:0,areaBytes:0,areaBits:new Uint8Array,playerState:Jo(),packetEntities:{delta:t,entities:i}})}collectPacketEntities(){let t=[];for(;;){let i=this.protocolHandler.parseEntityBits(this.stream);if(i.bits&ns){if(i.number===0)break;continue}let n=Ln();if(i.number===0)break;this.protocolHandler.parseDelta(Ln(),n,i.number,i.bits,i.bitsHigh,this.stream),t.push(n)}return t}};var ez=class{constructor(e){this.events=[],this.summary={totalKills:0,totalDeaths:0,damageDealt:0,damageReceived:0,weaponUsage:new Map},this.header=null,this.configStrings=new Map,this.serverInfo={},this.statistics=null,this.playerStats=new Map,this.weaponStats=new Map,this.activeEntities=new Set,this.buffer=e}analyze(){let e=new L_(this.buffer),t=-1,i=0,n=.1,r=0,a={onServerData:(s,o,c,d,l,m,u,f)=>{r=s,this.header={protocolVersion:s,gameDir:d,levelName:m,playerNum:l,serverCount:o,spawnCount:o,tickRate:u,demoType:f},u&&u>0&&(n=1/u)},onConfigString:(s,o)=>{this.configStrings.set(s,o),s===0&&this.parseServerInfo(o)},onSpawnBaseline:s=>{},onFrame:s=>{let o=new Set;if(s.packetEntities&&s.packetEntities.entities)for(let c of s.packetEntities.entities)o.add(c.number),this.activeEntities.has(c.number)||this.recordEvent({type:"spawn",frame:t,time:i,entityId:c.number,position:{x:c.origin.x,y:c.origin.y,z:c.origin.z},description:`Entity ${c.number} spawned`});this.activeEntities=o,s.playerState&&this.header},onPrint:(s,o)=>{let c=o.replace(/\n/g," ").trim();c.includes("died")||c.includes("killed")||c.includes("suicide")?(this.summary.totalDeaths++,this.recordEvent({type:"death",frame:t,time:i,description:c})):c.startsWith("You got the ")?this.recordEvent({type:"pickup",frame:t,time:i,description:c}):(s===3||s===2)&&this.recordEvent({type:"chat",frame:t,time:i,description:c,data:{level:s}})},onCenterPrint:s=>{this.recordEvent({type:"objective",frame:t,time:i,description:s.trim()})},onStuffText:()=>{},onSound:()=>{},onTempEntity:()=>{},onLayout:()=>{},onInventory:()=>{},onMuzzleFlash:(s,o)=>{this.handleWeaponFire(s,o,t,i)},onMuzzleFlash2:(s,o)=>{this.handleWeaponFire(s,o,t,i)},onMuzzleFlash3:(s,o)=>{this.handleWeaponFire(s,o,t,i)},onDisconnect:()=>{},onReconnect:()=>{},onDownload:()=>{},onDamage:s=>{for(let o of s)if(this.recordEvent({type:"damage_received",frame:t,time:i,value:o.damage,position:o.dir,description:`Took ${o.damage} damage`}),this.summary.damageReceived+=o.damage,this.header){let c=this.getOrCreatePlayerStats(this.header.playerNum);c.damageReceived+=o.damage}}};for(;e.hasMore();){let s=e.readNextBlock();if(!s)break;t++,i=t*n;let o=new Qo(s.data,a);o.setProtocolVersion(r),o.parseMessage(),r=o.getProtocolVersion()}return this.statistics={duration:i,frameCount:t+1,averageFps:(t+1)/(i||1),mapName:this.header?.levelName||"unknown",playerCount:1},{events:this.events,summary:this.summary,header:this.header,configStrings:this.configStrings,serverInfo:this.serverInfo,statistics:this.statistics,playerStats:this.playerStats,weaponStats:this.weaponStats}}handleWeaponFire(e,t,i,n){this.recordEvent({type:"weapon_fire",frame:i,time:n,entityId:e,value:t,description:`Weapon ${t} fired by ${e}`});let r=this.summary.weaponUsage.get(t)||0;this.summary.weaponUsage.set(t,r+1);let a=this.getOrCreateWeaponStat(e,t);a.shotsFired++}recordEvent(e){this.events.push(e)}parseServerInfo(e){let t=e.split("\\");for(let i=1;i<t.length;i+=2)i+1<t.length&&(this.serverInfo[t[i]]=t[i+1])}getOrCreatePlayerStats(e){let t=this.playerStats.get(e);return t||(t={kills:0,deaths:0,damageDealt:0,damageReceived:0,suicides:0},this.playerStats.set(e,t)),t}getOrCreateWeaponStat(e,t){let i=this.weaponStats.get(e);i||(i=[],this.weaponStats.set(e,i));let n=i.find(r=>r.weaponId===t);return n||(n={weaponId:t,shotsFired:0,hits:0,kills:0},i.push(n)),n}};var As=(e=>(e[e.Stopped=0]="Stopped",e[e.Playing=1]="Playing",e[e.Paused=2]="Paused",e[e.Finished=3]="Finished",e))(As||{}),tz=()=>({onServerData:()=>{},onConfigString:()=>{},onSpawnBaseline:()=>{},onFrame:()=>{},onCenterPrint:()=>{},onStuffText:()=>{},onPrint:()=>{},onSound:()=>{},onTempEntity:()=>{},onLayout:()=>{},onInventory:()=>{},onMuzzleFlash:()=>{},onMuzzleFlash2:()=>{},onDisconnect:()=>{},onReconnect:()=>{},onDownload:()=>{}}),pp=class{constructor(){this.reader=null,this.buffer=null,this.state=0,this.playbackSpeed=1,this.currentProtocolVersion=0,this.currentFrameIndex=-1,this.lastFrameData=null,this.accumulatedTime=0,this.frameDuration=100,this.snapshotInterval=100,this.snapshots=new Map,this.cachedEvents=null,this.cachedSummary=null,this.cachedHeader=null,this.cachedConfigStrings=null,this.cachedServerInfo=null,this.cachedStatistics=null,this.cachedPlayerStats=null,this.cachedWeaponStats=null,this.tracker=null,this.cameraMode=0,this.thirdPersonDistance=80,this.thirdPersonOffset={x:0,y:0,z:0}}setHandler(e){this.handler=e}setCallbacks(e){this.callbacks=e}loadDemo(e){this.buffer=e,this.reader=new L_(e),this.transitionState(0),this.accumulatedTime=0,this.currentProtocolVersion=0,this.currentFrameIndex=-1,this.snapshots.clear(),this.lastFrameData=null,this.cachedEvents=null,this.cachedSummary=null,this.cachedHeader=null,this.cachedConfigStrings=null,this.cachedServerInfo=null,this.cachedStatistics=null,this.cachedPlayerStats=null,this.cachedWeaponStats=null}play(){this.reader&&this.state!==1&&this.transitionState(1)}pause(){this.state===1&&this.transitionState(2)}stop(){this.transitionState(0),this.reader&&this.reader.reset(),this.accumulatedTime=0,this.currentProtocolVersion=0,this.currentFrameIndex=-1,this.lastFrameData=null}transitionState(e){this.state!==e&&(this.state=e,this.callbacks?.onPlaybackStateChange&&this.callbacks.onPlaybackStateChange(e))}setFrameDuration(e){this.frameDuration=e}setSpeed(e){this.playbackSpeed=Math.max(.1,Math.min(e,16))}getSpeed(){return this.playbackSpeed}getPlaybackSpeed(){return this.playbackSpeed}getInterpolationFactor(){return this.frameDuration<=0?0:Math.max(0,Math.min(1,this.accumulatedTime/this.frameDuration))}update(e){if(!(this.state!==1||!this.reader))for(this.accumulatedTime+=e*1e3*this.playbackSpeed;this.accumulatedTime>=this.frameDuration;){if(!this.processNextFrame())return;this.accumulatedTime-=this.frameDuration,this.callbacks?.onTimeUpdate&&this.callbacks.onTimeUpdate(this.getCurrentTime())}}stepForward(){this.reader&&(this.processNextFrame(),this.callbacks?.onTimeUpdate&&this.callbacks.onTimeUpdate(this.getCurrentTime()))}stepBackward(){this.reader&&this.currentFrameIndex>0&&this.seek(this.currentFrameIndex-1)}seekToTime(e){let t=this.timeToFrame(e);this.seek(t)}seekToFrame(e){this.seek(e)}frameToTime(e){return e*this.frameDuration/1e3}timeToFrame(e){return Math.floor(e*1e3/this.frameDuration)}playFrom(e){if(e.type==="frame")this.seek(e.frame);else if(e.type==="time")this.seekToTime(e.seconds);else throw new Error(`Invalid offset type: ${e.type}`);this.play()}playRange(e,t){let i=e.type==="frame"?e.frame:this.timeToFrame(e.seconds),n=t.type==="frame"?t.frame:this.timeToFrame(t.seconds);if(this.getTotalFrames(),i<0)throw new Error(`Invalid start offset: ${i}`);if(n<i)throw new Error(`End offset (${n}) cannot be before start offset (${i})`);this.playFrom(e);let r=this.callbacks?.onFrameUpdate,a={...this.callbacks,onFrameUpdate:s=>{if(r&&r(s),this.currentFrameIndex>=n){this.pause();let o=this.callbacks?.onPlaybackComplete;this.callbacks===a&&this.setCallbacks({...this.callbacks,onFrameUpdate:r}),o&&o()}}};this.setCallbacks(a)}seek(e){if(!this.reader)return;let t=this.getTotalFrames();if(t>0&&e>=t&&(e=t-1),e<0&&(e=0),e===this.currentFrameIndex+1){this.processNextFrame(),this.callbacks?.onSeekComplete&&this.callbacks.onSeekComplete();return}if(e===this.currentFrameIndex){this.callbacks?.onSeekComplete&&this.callbacks.onSeekComplete();return}let i=-1,n=null;if(e>this.currentFrameIndex&&this.currentFrameIndex!==-1&&(i=this.currentFrameIndex),this.callbacks?.onRestoreSnapshot)for(let[r,a]of this.snapshots)r<=e&&r>i&&(i=r,n=a);for(i===-1&&this.currentFrameIndex>e?(this.reader.reset(),this.currentFrameIndex=-1,this.currentProtocolVersion=0):i===-1&&(this.reader.reset(),this.currentFrameIndex=-1,this.currentProtocolVersion=0),n&&this.callbacks?.onRestoreSnapshot&&(this.callbacks.onRestoreSnapshot(n),this.reader.seekToMessage(i+1)?this.currentFrameIndex=i:(this.reader.reset(),this.currentFrameIndex=-1,this.currentProtocolVersion=0));this.currentFrameIndex<e&&(this.callbacks?.onCaptureSnapshot&&(this.currentFrameIndex+1)%this.snapshotInterval,!!this.processNextFrame()););this.accumulatedTime=0,this.callbacks?.onSeekComplete&&this.callbacks.onSeekComplete(),this.callbacks?.onTimeUpdate&&this.callbacks.onTimeUpdate(this.getCurrentTime())}processNextFrame(){if(!this.reader||!this.reader.hasMore())return this.transitionState(3),this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),!1;let e=this.reader.readNextBlock();if(!e)return this.transitionState(3),this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),!1;this.currentFrameIndex++,this.tracker&&(this.tracker.setCurrentFrame(this.currentFrameIndex),this.tracker.setCurrentTime(this.getCurrentTime()));try{let t={...this.handler||tz(),onFrame:n=>{this.lastFrameData=n,this.handler?.onFrame&&this.handler.onFrame(n),this.callbacks?.onFrameUpdate&&this.callbacks.onFrameUpdate(n)}},i=new Qo(e.data,t);if(i.setProtocolVersion(this.currentProtocolVersion),i.parseMessage(),this.currentProtocolVersion=i.getProtocolVersion(),this.callbacks?.onCaptureSnapshot&&this.currentFrameIndex%this.snapshotInterval===0&&this.currentFrameIndex>0){let n=this.callbacks.onCaptureSnapshot(this.currentFrameIndex);n&&this.snapshots.set(this.currentFrameIndex,n)}}catch(t){return console.error("Error processing demo frame",t),this.callbacks?.onPlaybackError&&this.callbacks.onPlaybackError(t instanceof Error?t:new Error(String(t))),!1}return!0}getState(){return this.state}getCurrentTime(){return this.currentFrameIndex<0?this.accumulatedTime/1e3:(this.currentFrameIndex*this.frameDuration+this.accumulatedTime)/1e3}getFrameCount(){return this.reader?this.reader.getMessageCount():0}getTotalFrames(){return this.getFrameCount()}getCurrentFrame(){return this.currentFrameIndex<0?0:this.currentFrameIndex}getDuration(){return this.getFrameCount()*this.frameDuration/1e3}getTotalBytes(){return this.reader?this.reader.getProgress().total:0}getProcessedBytes(){return this.reader?this.reader.getOffset():0}getFrameData(e){if(e===this.currentFrameIndex&&this.lastFrameData)return this.lastFrameData;let t=this.state;return this.pause(),this.seek(e),t===1&&this.play(),this.lastFrameData}getFramePlayerState(e){if(e===this.currentFrameIndex&&this.handler?.getPlayerState){let i=this.handler.getPlayerState();if(i)return i}let t=this.getFrameData(e);return t?t.playerState:null}getFrameEntities(e){if(e===this.currentFrameIndex&&this.handler?.getEntities){let t=this.handler.getEntities();if(t)return Array.from(t.values())}if(this.seek(e),this.handler?.getEntities){let t=this.handler.getEntities();return t?Array.from(t.values()):[]}return[]}compareFrames(e,t){let i=this.getFramePlayerState(e),n=this.getFrameEntities(e),r=new Map;n.forEach(d=>r.set(d.number,d));let a=this.getFramePlayerState(t),s=this.getFrameEntities(t),o=new Map;s.forEach(d=>o.set(d.number,d));let c={frameA:e,frameB:t,playerStateDiff:{origin:null,viewangles:null,health:null,ammo:null},entityDiffs:{added:[],removed:[],moved:[]}};i&&a&&((i.origin.x!==a.origin.x||i.origin.y!==a.origin.y||i.origin.z!==a.origin.z)&&(c.playerStateDiff.origin={x:a.origin.x-i.origin.x,y:a.origin.y-i.origin.y,z:a.origin.z-i.origin.z}),i.stats[1]!==a.stats[1]&&(c.playerStateDiff.health=a.stats[1]-i.stats[1]),i.stats[2]!==a.stats[2]&&(c.playerStateDiff.ammo=a.stats[2]-i.stats[2]));for(let[d,l]of o){let m=r.get(d);m?(m.origin.x!==l.origin.x||m.origin.y!==l.origin.y||m.origin.z!==l.origin.z)&&c.entityDiffs.moved.push({id:d,delta:{x:l.origin.x-m.origin.x,y:l.origin.y-m.origin.y,z:l.origin.z-m.origin.z}}):c.entityDiffs.added.push(d)}for(let[d,l]of r)o.has(d)||c.entityDiffs.removed.push(d);return c}getEntityTrajectory(e,t,i){let n=[],r=this.getCurrentFrame();for(this.seek(t);this.getCurrentFrame()<=i&&this.state!==3;){let a=null;if(e===-1){let s=this.getFramePlayerState(this.getCurrentFrame());s&&(a={...s.origin})}else if(this.handler?.getEntities){let s=this.handler.getEntities().get(e);s&&(a={...s.origin})}if(a&&n.push(a),this.getCurrentFrame()===i)break;this.stepForward()}return this.seek(r),n}getEvents(){return this.ensureAnalysis(),this.cachedEvents||[]}getDemoEvents(){return this.getEvents()}filterEvents(e,t){return this.getDemoEvents().filter(n=>!(n.type!==e||t!==void 0&&n.entityId!==t))}getEventSummary(){return this.ensureAnalysis(),this.cachedSummary||{totalKills:0,totalDeaths:0,damageDealt:0,damageReceived:0,weaponUsage:new Map}}getMetadata(){let e=this.getDemoHeader();if(!e)return null;let t=this.getDemoServerInfo(),i="Unknown";return this.cachedConfigStrings,{mapName:e.levelName,playerName:i,serverName:t.hostname,demoVersion:e.protocolVersion,tickRate:e.tickRate||10}}getDemoHeader(){return this.ensureAnalysis(),this.cachedHeader}getDemoConfigStrings(){return this.ensureAnalysis(),this.cachedConfigStrings||new Map}getDemoServerInfo(){return this.ensureAnalysis(),this.cachedServerInfo||{}}getDemoStatistics(){return this.ensureAnalysis(),this.cachedStatistics}getPlayerStatistics(e){return this.ensureAnalysis(),this.cachedPlayerStats?.get(e)||null}getWeaponStatistics(e){return this.ensureAnalysis(),this.cachedWeaponStats?.get(e)||null}ensureAnalysis(){if(!this.cachedEvents&&this.buffer){let t=new ez(this.buffer).analyze();this.cachedEvents=t.events,this.cachedSummary=t.summary,this.cachedHeader=t.header,this.cachedConfigStrings=t.configStrings,this.cachedServerInfo=t.serverInfo,this.cachedStatistics=t.statistics,this.cachedPlayerStats=t.playerStats,this.cachedWeaponStats=t.weaponStats}}setCameraMode(e){this.cameraMode=e}getCameraMode(){return this.cameraMode}setThirdPersonDistance(e){this.thirdPersonDistance=e}setThirdPersonOffset(e){this.thirdPersonOffset=e}async playWithTracking(e,t={}){if(this.tracker=e,e.startTracking(),t.fastForward)try{this.state===0&&this.reader,this.transitionState(1);let i=100,n=async()=>{if(this.state!==1)throw new Error("Playback stopped unexpectedly during fast forward");let r=0;for(;r<i;){if(!this.processNextFrame()){this.transitionState(0);let a=e.stopTracking();return this.tracker=null,this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),a}r++}return await new Promise(a=>setTimeout(a,0)),n()};return await n()}catch(i){throw this.transitionState(0),e.stopTracking(),this.tracker=null,i}else return new Promise((i,n)=>{let r=this.callbacks?.onPlaybackComplete,a=this.callbacks?.onPlaybackError,s=()=>{this.setCallbacks({...this.callbacks,onPlaybackComplete:r,onPlaybackError:a}),this.tracker=null};this.setCallbacks({...this.callbacks,onPlaybackComplete:()=>{let o=e.stopTracking();r&&r(),s(),i(o)},onPlaybackError:o=>{e.stopTracking(),a&&a(o),s(),n(o)}}),this.play()})}async playRangeWithTracking(e,t,i,n={}){this.tracker=i,i.startTracking(),e.type==="frame"?e.frame:this.timeToFrame(e.seconds);let r=t.type==="frame"?t.frame:this.timeToFrame(t.seconds);if(n.fastForward)try{this.playFrom(e),this.transitionState(1);let a=100,s=async()=>{if(this.state!==1)throw new Error("Playback stopped unexpectedly during fast forward");let o=0;for(;o<a;){if(this.currentFrameIndex>=r||!this.processNextFrame()){this.transitionState(0);let c=i.stopTracking();return this.tracker=null,this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),c}o++}return await new Promise(c=>setTimeout(c,0)),s()};return await s()}catch(a){throw this.transitionState(0),i.stopTracking(),this.tracker=null,a}else return new Promise((a,s)=>{let o=this.callbacks?.onPlaybackComplete,c=this.callbacks?.onPlaybackError,d=()=>{this.setCallbacks({...this.callbacks,onPlaybackComplete:o,onPlaybackError:c}),this.tracker=null};this.setCallbacks({...this.callbacks,onPlaybackComplete:()=>{let l=i.stopTracking();o&&o(),d(),a(l)},onPlaybackError:l=>{i.stopTracking(),c&&c(l),d(),s(l)}}),this.playRange(e,t)})}},vp=class{constructor(){this.isRecording=!1,this.startTime=0,this.frameCount=0,this.filename=null,this.lastMessageSize=-1,this.messageBuffer=new Zr(1024*1024)}startRecording(e,t=0){this.isRecording||(this.isRecording=!0,this.filename=e,this.startTime=t,this.frameCount=0,this.messageBuffer.reset(),console.log(`DemoRecorder: Started recording to ${e}`))}recordMessage(e){if(this.isRecording){this.messageBuffer.writeLong(e.byteLength);for(let t=0;t<e.length;t++)this.messageBuffer.writeByte(e[t]);this.frameCount++}}stopRecording(){return this.isRecording?(this.isRecording=!1,this.messageBuffer.writeLong(-1),console.log(`DemoRecorder: Stopped recording. Frames: ${this.frameCount}, Size: ${this.messageBuffer.getOffset()} bytes`),this.messageBuffer.getData()):null}getIsRecording(){return this.isRecording}};var yp=class{static validate(e,t){if(t&&!t.toLowerCase().endsWith(".dm2"))return{valid:!1,error:"Invalid file extension (expected .dm2)"};if(e.byteLength<5)return{valid:!1,error:"File too small to be a valid demo"};let i=new DataView(e),n=i.getInt32(0,!0);if(n<=0||n>e.byteLength-4)return{valid:!1,error:`Invalid first block length: ${n}`};let r=i.getUint8(4);if(r!==I.serverdata)return{valid:!1,error:`First command is not svc_serverdata (expected ${I.serverdata}, got ${r})`};let a=-1;return n>=5&&(a=i.getInt32(5,!0)),{valid:!0,version:a}}};function ec(e,t){let i=t.bits;e.bits=i,e.number=t.number,i&Hr&&(e.modelindex=t.modelindex),i&Wr&&(e.modelindex2=t.modelindex2),i&$r&&(e.modelindex3=t.modelindex3),i&Kr&&(e.modelindex4=t.modelindex4),i&Dr&&(e.frame=t.frame),i&Vr&&(e.frame=t.frame),i&Ji&&(e.skinnum=t.skinnum),i&tn&&(e.skinnum=t.skinnum),i&qi&&(e.effects=t.effects),i&en&&(e.effects=t.effects),i&Zi&&(e.renderfx=t.renderfx),i&Qi&&(e.renderfx=t.renderfx),i&Nr&&(e.origin.x=t.origin.x),i&Pr&&(e.origin.y=t.origin.y),i&Ur&&(e.origin.z=t.origin.z),i&Gr&&(e.angles.x=t.angles.x),i&Or&&(e.angles.y=t.angles.y),i&Fr&&(e.angles.z=t.angles.z),i&Xr&&(e.old_origin.x=t.old_origin.x,e.old_origin.y=t.old_origin.y,e.old_origin.z=t.old_origin.z),i&jr&&(e.sound=t.sound),i&Br&&(e.event=t.event),i&Yr&&(e.solid=t.solid),i&Co&&(e.alpha=t.alpha),i&No&&(e.scale=t.scale),i&Po&&(e.instanceBits=t.instanceBits),i&Oo&&(e.loopVolume=t.loopVolume)}var ic=null,tc=[1,1,1,1],wp=["ch1","ch2","ch3"],Um=[null,null,null],iz=e=>{for(let t=0;t<wp.length;t++){let i=wp[t];try{Um[t]=e.Draw_RegisterPic(`pics/${i}.pcx`)}catch{if(t===0)try{Um[t]=e.Draw_RegisterPic("pics/crosshair.pcx")}catch{e.Com_Print(`Failed to load crosshair image
|
|
203
|
+
}`;var x_=class{constructor(e,t){this._position=ee.create(),this._angles=ee.create(),this._bobAngles=ee.create(),this._bobOffset=ee.create(),this._kickAngles=ee.create(),this._rollAngle=0,this._fov=90,this._aspect=1,this._near=.1,this._far=1e3,this._viewMatrix=De.create(),this._projectionMatrix=De.create(),this._viewProjectionMatrix=De.create(),this._dirty=!0,e!==void 0&&t!==void 0&&t>0&&(this._aspect=e/t)}get position(){return this._position}set position(e){ee.equals(this._position,e)||(ee.copy(this._position,e),this._dirty=!0,this.triggerMoveEvent())}get angles(){return this._angles}set angles(e){ee.equals(this._angles,e)||(ee.copy(this._angles,e),this._dirty=!0,this.triggerMoveEvent())}get bobAngles(){return this._bobAngles}set bobAngles(e){ee.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){ee.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){ee.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}toState(){return{position:ee.clone(this._position),angles:ee.clone(this._angles),fov:this._fov,aspect:this._aspect,near:this._near,far:this._far}}setPosition(e,t,i){let n=ee.fromValues(e,t,i);ee.equals(this._position,n)||(ee.copy(this._position,n),this._dirty=!0,this.triggerMoveEvent())}setRotation(e,t,i){let n=ee.fromValues(e,t,i);ee.equals(this._angles,n)||(ee.copy(this._angles,n),this._dirty=!0,this.triggerMoveEvent())}setFov(e){this.fov=e}setAspectRatio(e){this.aspect=e}lookAt(e){let t=ee.create();if(ee.subtract(t,e,this._position),ee.length(t)<.001)return;let n=Math.atan2(t[1],t[0])*Fl,r=Math.hypot(t[0],t[1]),a=-Math.atan2(t[2],r)*Fl;this.setRotation(a,n,0)}triggerMoveEvent(){this.onCameraMove&&this.onCameraMove({position:ee.clone(this._position),angles:ee.clone(this._angles)})}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let t=De.create();return De.perspective(t,e*Er,this._aspect,this._near,this._far),t}screenToWorldRay(e,t){let i=e*2-1,n=1-t*2,r=ee.fromValues(i,n,-1),a=ee.fromValues(i,n,1),s=De.create();De.invert(s,this.viewProjectionMatrix);let o=ee.create(),c=ee.create();ee.transformMat4(o,r,s),ee.transformMat4(c,a,s);let d=ee.create();return ee.subtract(d,c,o),ee.normalize(d,d),{origin:ee.clone(this._position),direction:d}}updateMatrices(){if(!this._dirty)return;De.perspective(this._projectionMatrix,this._fov*Er,this._aspect,this._near,this._far);let e=De.fromValues(0,0,-1,0,-1,0,0,0,0,1,0,0,0,0,0,1),t=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],i=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],n=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,r=t*Er,a=i*Er,s=n*Er,o=De.create();De.identity(o),De.rotateZ(o,o,-a),De.rotateY(o,o,-r),De.rotateX(o,o,-s);let c=De.create();De.multiply(c,e,o);let d=ee.add(ee.create(),this._position,this._bobOffset),l=ee.negate(ee.create(),d),m=ee.create();ee.transformMat4(m,l,o);let u=ee.fromValues(m[1]?-m[1]:0,m[2]||0,m[0]?-m[0]:0);De.copy(this._viewMatrix,c),this._viewMatrix[12]=u[0],this._viewMatrix[13]=u[1],this._viewMatrix[14]=u[2],De.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};function A_(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1}}=e;for(let r=0;r<12;r+=1){let a=200+t.rng.frandom()*180,s=t.rng.frandom()*.35;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*80,y:n.y*a+(t.rng.frandom()-.5)*80,z:Math.max(n.z*a,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+t.rng.frandom()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let r=0;r<8;r+=1)t.spawn({position:i,velocity:{x:(t.rng.frandom()-.5)*40,y:(t.rng.frandom()-.5)*40,z:80+t.rng.frandom()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function E_(e){let{system:t,origin:i}=e;for(let n=0;n<40;n+=1){let r=t.rng.frandom()*Math.PI*2,a=Math.acos(2*t.rng.frandom()-1),s=220+t.rng.frandom()*260,o={x:Math.sin(a)*Math.cos(r),y:Math.sin(a)*Math.sin(r),z:Math.cos(a)};t.spawn({position:i,velocity:{x:o.x*s,y:o.y*s,z:o.z*s},color:[1,.6,.2,1],size:5,lifetime:.9,gravity:700,damping:1,bounce:.35,blendMode:"additive",fade:!0})}for(let n=0;n<16;n+=1)t.spawn({position:i,velocity:{x:(t.rng.frandom()-.5)*30,y:(t.rng.frandom()-.5)*30,z:120+t.rng.frandom()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function T_(e){let{system:t,origin:i,direction:n={x:0,y:0,z:1}}=e;for(let r=0;r<24;r+=1){let a=120+t.rng.frandom()*180;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*70,y:n.y*a+(t.rng.frandom()-.5)*70,z:n.z*a+t.rng.frandom()*80},color:[.6,0,0,.95],size:3,lifetime:.8,gravity:900,damping:1,bounce:.2,blendMode:"alpha",fade:!0})}}function M_(e){let{system:t,origin:i,direction:n={x:1,y:0,z:0}}=e;for(let r=0;r<10;r+=1){let a=350+t.rng.frandom()*100;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*30,y:n.y*a+(t.rng.frandom()-.5)*30,z:n.z*a+(t.rng.frandom()-.5)*30},color:[1,.8,.3,1],size:3,lifetime:.25,gravity:200,damping:1,blendMode:"additive",fade:!0})}}function z_(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1}}=e;for(let r=0;r<30;r+=1){let a=100+t.rng.frandom()*150;t.spawn({position:i,velocity:{x:n.x*a+(t.rng.frandom()-.5)*80,y:n.y*a+(t.rng.frandom()-.5)*80,z:100+t.rng.frandom()*120},color:[.5,.6,.8,.5],size:3,lifetime:.5+t.rng.frandom()*.3,gravity:800,damping:1.5,blendMode:"alpha",fade:!0})}}function R_(e){let{system:t,origin:i}=e;for(let n=0;n<8;n+=1)t.spawn({position:{x:i.x+(t.rng.frandom()-.5)*10,y:i.y+(t.rng.frandom()-.5)*10,z:i.z+(t.rng.frandom()-.5)*10},velocity:{x:(t.rng.frandom()-.5)*20,y:(t.rng.frandom()-.5)*20,z:40+t.rng.frandom()*20},color:[.8,.8,.8,.3],size:5+t.rng.frandom()*4,lifetime:1.5+t.rng.frandom()*.5,gravity:-50,damping:.5,blendMode:"alpha",fade:!0})}function C_(e){let{system:t,start:i,end:n}=e,r=n.x-i.x,a=n.y-i.y,s=n.z-i.z,o=Math.sqrt(r*r+a*a+s*s);if(o<1)return;let c={x:r/o,y:a/o,z:s/o},d=8;for(let l=0;l<o;l+=d){let m=i.x+c.x*l,u=i.y+c.y*l,f=i.z+c.z*l;t.spawn({position:{x:m,y:u,z:f},velocity:{x:0,y:0,z:0},color:[.4,.4,1,.8],size:2,lifetime:.6,blendMode:"additive",fade:!0}),t.spawn({position:{x:m+(t.rng.frandom()-.5)*6,y:u+(t.rng.frandom()-.5)*6,z:f+(t.rng.frandom()-.5)*6},velocity:{x:(t.rng.frandom()-.5)*10,y:(t.rng.frandom()-.5)*10,z:(t.rng.frandom()-.5)*10},color:[.1,.1,.8,.6],size:3,lifetime:.8+t.rng.frandom()*.2,blendMode:"additive",fade:!0})}}function Rm(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1},count:r=12,color:a=[1,.9,.2,1]}=e;for(let s=0;s<r;s++){let o=100+t.rng.frandom()*200,c=.5;t.spawn({position:i,velocity:{x:n.x*o+(t.rng.frandom()-.5)*100*c,y:n.y*o+(t.rng.frandom()-.5)*100*c,z:n.z*o+(t.rng.frandom()-.5)*100*c},color:a,size:1.5,lifetime:.3+t.rng.frandom()*.2,gravity:800,bounce:.5,damping:1,blendMode:"additive",fade:!0})}}function Cm(e){let{system:t,origin:i,normal:n={x:0,y:0,z:1},color:r=[1,.8,0,1]}=e;t.spawn({position:i,velocity:{x:0,y:0,z:0},color:r,size:8,lifetime:.2,blendMode:"additive",fade:!0});for(let a=0;a<8;a++){let s=150+t.rng.frandom()*150;t.spawn({position:i,velocity:{x:n.x*s+(t.rng.frandom()-.5)*120,y:n.y*s+(t.rng.frandom()-.5)*120,z:n.z*s+(t.rng.frandom()-.5)*120},color:r,size:2,lifetime:.4+t.rng.frandom()*.2,gravity:400,blendMode:"additive",fade:!0})}}function I_(e){let{system:t,origin:i}=e;t.spawn({position:i,velocity:{x:0,y:0,z:0},color:[.2,1,.2,1],size:30,lifetime:.5,blendMode:"additive",fade:!0});for(let n=0;n<60;n++){let r=t.rng.frandom()*Math.PI*2,a=Math.acos(2*t.rng.frandom()-1),s=300+t.rng.frandom()*400,o={x:Math.sin(a)*Math.cos(r),y:Math.sin(a)*Math.sin(r),z:Math.cos(a)};t.spawn({position:i,velocity:{x:o.x*s,y:o.y*s,z:o.z*s},color:[.2,1,.2,.8],size:4,lifetime:1,gravity:100,damping:1,blendMode:"additive",fade:!0})}}var L_=class{constructor(e){this.messageOffsets=[],this.currentBlock=null,this.buffer=e,this.view=new DataView(e),this.offset=0,this.scan()}scan(){let e=0;for(this.messageOffsets=[];e+4<=this.buffer.byteLength;){let t=this.view.getInt32(e,!0);if(t===-1)break;if(t<0||t>2097152){console.warn(`DemoReader: Invalid block length ${t} at offset ${e} during scan`);break}if(e+4+t>this.buffer.byteLength){console.warn(`DemoReader: Incomplete block at offset ${e} during scan`);break}this.messageOffsets.push(e),e+=4+t}}hasMore(){return this.offset<this.buffer.byteLength}readNextBlock(){if(this.offset+4>this.buffer.byteLength)return null;let e=this.view.getInt32(this.offset,!0);if(e===-1||e<0||this.offset+4+e>this.buffer.byteLength)return null;this.offset+=4;let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,{length:e,data:new nr(t)}}nextBlock(){let e=this.readNextBlock();return e?(this.currentBlock=e,!0):(this.currentBlock=null,!1)}getBlock(){if(!this.currentBlock)throw new Error("No current block. Call nextBlock() first.");return this.currentBlock}readAllBlocksToBuffer(){let e=0;this.offset;let t=[],i=this.offset;for(;i+4<=this.buffer.byteLength;){let s=this.view.getInt32(i,!0);if(s===-1||s<0||i+4+s>this.buffer.byteLength)break;t.push({offset:i+4,length:s}),e+=s,i+=4+s}let n=new Uint8Array(e),r=0,a=new Uint8Array(this.buffer);for(let s of t)n.set(a.subarray(s.offset,s.offset+s.length),r),r+=s.length;return this.offset=i,n.buffer}reset(){this.offset=0,this.currentBlock=null}seekToMessage(e){return e<0||e>=this.messageOffsets.length?!1:(this.offset=this.messageOffsets[e],this.currentBlock=null,!0)}getMessageCount(){return this.messageOffsets.length}getOffset(){return this.offset}getProgress(){let e=this.offset,t=this.buffer.byteLength;return{current:e,total:t,percent:t>0?e/t*100:0}}},qT=4,I0=0,L0=1,JT=2;function na(e){let t=e.length;for(;--t>=0;)e[t]=0}var QT=0,N_=1,eM=2,tM=3,iM=258,Im=29,ws=256,us=ws+1+Im,ea=30,Lm=19,P_=2*us+1,rr=15,rm=16,nM=7,Nm=256,O_=16,F_=17,D_=18,ym=new Uint8Array([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]),$o=new Uint8Array([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]),rM=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),B_=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),aM=512,rn=new Array((us+2)*2);na(rn);var ds=new Array(ea*2);na(ds);var fs=new Array(aM);na(fs);var hs=new Array(iM-tM+1);na(hs);var Pm=new Array(Im);na(Pm);var Ko=new Array(ea);na(Ko);function am(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}var U_,G_,H_;function sm(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var V_=e=>e<256?fs[e]:fs[256+(e>>>7)],gs=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Lt=(e,t,i)=>{e.bi_valid>rm-i?(e.bi_buf|=t<<e.bi_valid&65535,gs(e,e.bi_buf),e.bi_buf=t>>rm-e.bi_valid,e.bi_valid+=i-rm):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},Ci=(e,t,i)=>{Lt(e,i[t*2],i[t*2+1])},W_=(e,t)=>{let i=0;do i|=e&1,e>>>=1,i<<=1;while(--t>0);return i>>>1},sM=e=>{e.bi_valid===16?(gs(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},oM=(e,t)=>{let i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length,d,l,m,u,f,h,y=0;for(u=0;u<=rr;u++)e.bl_count[u]=0;for(i[e.heap[e.heap_max]*2+1]=0,d=e.heap_max+1;d<P_;d++)l=e.heap[d],u=i[i[l*2+1]*2+1]+1,u>c&&(u=c,y++),i[l*2+1]=u,!(l>n)&&(e.bl_count[u]++,f=0,l>=o&&(f=s[l-o]),h=i[l*2],e.opt_len+=h*(u+f),a&&(e.static_len+=h*(r[l*2+1]+f)));if(y!==0){do{for(u=c-1;e.bl_count[u]===0;)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,y-=2}while(y>0);for(u=c;u!==0;u--)for(l=e.bl_count[u];l!==0;)m=e.heap[--d],!(m>n)&&(i[m*2+1]!==u&&(e.opt_len+=(u-i[m*2+1])*i[m*2],i[m*2+1]=u),l--)}},$_=(e,t,i)=>{let n=new Array(rr+1),r=0,a,s;for(a=1;a<=rr;a++)r=r+i[a-1]<<1,n[a]=r;for(s=0;s<=t;s++){let o=e[s*2+1];o!==0&&(e[s*2]=W_(n[o]++,o))}},cM=()=>{let e,t,i,n,r,a=new Array(rr+1);for(i=0,n=0;n<Im-1;n++)for(Pm[n]=i,e=0;e<1<<ym[n];e++)hs[i++]=n;for(hs[i-1]=n,r=0,n=0;n<16;n++)for(Ko[n]=r,e=0;e<1<<$o[n];e++)fs[r++]=n;for(r>>=7;n<ea;n++)for(Ko[n]=r<<7,e=0;e<1<<$o[n]-7;e++)fs[256+r++]=n;for(t=0;t<=rr;t++)a[t]=0;for(e=0;e<=143;)rn[e*2+1]=8,e++,a[8]++;for(;e<=255;)rn[e*2+1]=9,e++,a[9]++;for(;e<=279;)rn[e*2+1]=7,e++,a[7]++;for(;e<=287;)rn[e*2+1]=8,e++,a[8]++;for($_(rn,us+1,a),e=0;e<ea;e++)ds[e*2+1]=5,ds[e*2]=W_(e,5);U_=new am(rn,ym,ws+1,us,rr),G_=new am(ds,$o,0,ea,rr),H_=new am(new Array(0),rM,0,Lm,nM)},K_=e=>{let t;for(t=0;t<us;t++)e.dyn_ltree[t*2]=0;for(t=0;t<ea;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Lm;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Nm*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},X_=e=>{e.bi_valid>8?gs(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},N0=(e,t,i,n)=>{let r=t*2,a=i*2;return e[r]<e[a]||e[r]===e[a]&&n[t]<=n[i]},om=(e,t,i)=>{let n=e.heap[i],r=i<<1;for(;r<=e.heap_len&&(r<e.heap_len&&N0(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!N0(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n},P0=(e,t,i)=>{let n,r,a=0,s,o;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+a++]&255,n+=(e.pending_buf[e.sym_buf+a++]&255)<<8,r=e.pending_buf[e.sym_buf+a++],n===0?Ci(e,r,t):(s=hs[r],Ci(e,s+ws+1,t),o=ym[s],o!==0&&(r-=Pm[s],Lt(e,r,o)),n--,s=V_(n),Ci(e,s,i),o=$o[s],o!==0&&(n-=Ko[s],Lt(e,n,o)));while(a<e.sym_next);Ci(e,Nm,t)},wm=(e,t)=>{let i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,a=t.stat_desc.elems,s,o,c=-1,d;for(e.heap_len=0,e.heap_max=P_,s=0;s<a;s++)i[s*2]!==0?(e.heap[++e.heap_len]=c=s,e.depth[s]=0):i[s*2+1]=0;for(;e.heap_len<2;)d=e.heap[++e.heap_len]=c<2?++c:0,i[d*2]=1,e.depth[d]=0,e.opt_len--,r&&(e.static_len-=n[d*2+1]);for(t.max_code=c,s=e.heap_len>>1;s>=1;s--)om(e,i,s);d=a;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],om(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,i[d*2]=i[s*2]+i[o*2],e.depth[d]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,i[s*2+1]=i[o*2+1]=d,e.heap[1]=d++,om(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],oM(e,t),$_(i,c,e.bl_count)},O0=(e,t,i)=>{let n,r=-1,a,s=t[1],o=0,c=7,d=4;for(s===0&&(c=138,d=3),t[(i+1)*2+1]=65535,n=0;n<=i;n++)a=s,s=t[(n+1)*2+1],!(++o<c&&a===s)&&(o<d?e.bl_tree[a*2]+=o:a!==0?(a!==r&&e.bl_tree[a*2]++,e.bl_tree[O_*2]++):o<=10?e.bl_tree[F_*2]++:e.bl_tree[D_*2]++,o=0,r=a,s===0?(c=138,d=3):a===s?(c=6,d=3):(c=7,d=4))},F0=(e,t,i)=>{let n,r=-1,a,s=t[1],o=0,c=7,d=4;for(s===0&&(c=138,d=3),n=0;n<=i;n++)if(a=s,s=t[(n+1)*2+1],!(++o<c&&a===s)){if(o<d)do Ci(e,a,e.bl_tree);while(--o!==0);else a!==0?(a!==r&&(Ci(e,a,e.bl_tree),o--),Ci(e,O_,e.bl_tree),Lt(e,o-3,2)):o<=10?(Ci(e,F_,e.bl_tree),Lt(e,o-3,3)):(Ci(e,D_,e.bl_tree),Lt(e,o-11,7));o=0,r=a,s===0?(c=138,d=3):a===s?(c=6,d=3):(c=7,d=4)}},dM=e=>{let t;for(O0(e,e.dyn_ltree,e.l_desc.max_code),O0(e,e.dyn_dtree,e.d_desc.max_code),wm(e,e.bl_desc),t=Lm-1;t>=3&&e.bl_tree[B_[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},lM=(e,t,i,n)=>{let r;for(Lt(e,t-257,5),Lt(e,i-1,5),Lt(e,n-4,4),r=0;r<n;r++)Lt(e,e.bl_tree[B_[r]*2+1],3);F0(e,e.dyn_ltree,t-1),F0(e,e.dyn_dtree,i-1)},mM=e=>{let t=4093624447,i;for(i=0;i<=31;i++,t>>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return I0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return L0;for(i=32;i<ws;i++)if(e.dyn_ltree[i*2]!==0)return L0;return I0},D0=!1,uM=e=>{D0||(cM(),D0=!0),e.l_desc=new sm(e.dyn_ltree,U_),e.d_desc=new sm(e.dyn_dtree,G_),e.bl_desc=new sm(e.bl_tree,H_),e.bi_buf=0,e.bi_valid=0,K_(e)},j_=(e,t,i,n)=>{Lt(e,(QT<<1)+(n?1:0),3),X_(e),gs(e,i),gs(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i},fM=e=>{Lt(e,N_<<1,3),Ci(e,Nm,rn),sM(e)},hM=(e,t,i,n)=>{let r,a,s=0;e.level>0?(e.strm.data_type===JT&&(e.strm.data_type=mM(e)),wm(e,e.l_desc),wm(e,e.d_desc),s=dM(e),r=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=r&&(r=a)):r=a=i+5,i+4<=r&&t!==-1?j_(e,t,i,n):e.strategy===qT||a===r?(Lt(e,(N_<<1)+(n?1:0),3),P0(e,rn,ds)):(Lt(e,(eM<<1)+(n?1:0),3),lM(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),P0(e,e.dyn_ltree,e.dyn_dtree)),K_(e),n&&X_(e)},gM=(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,t===0?e.dyn_ltree[i*2]++:(e.matches++,t--,e.dyn_ltree[(hs[i]+ws+1)*2]++,e.dyn_dtree[V_(t)*2]++),e.sym_next===e.sym_end),_M=uM,pM=j_,vM=hM,yM=gM,wM=fM,SM={_tr_init:_M,_tr_stored_block:pM,_tr_flush_block:vM,_tr_tally:yM,_tr_align:wM},kM=(e,t,i,n)=>{let r=e&65535|0,a=e>>>16&65535|0,s=0;for(;i!==0;){s=i>2e3?2e3:i,i-=s;do r=r+t[n++]|0,a=a+r|0;while(--s);r%=65521,a%=65521}return r|a<<16|0},_s=kM,bM=()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[i]=e}return t},xM=new Uint32Array(bM()),AM=(e,t,i,n)=>{let r=xM,a=n+i;e^=-1;for(let s=n;s<a;s++)e=e>>>8^r[(e^t[s])&255];return e^-1},ft=AM,or={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ss={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:EM,_tr_stored_block:Sm,_tr_flush_block:TM,_tr_tally:Nn,_tr_align:MM}=SM,{Z_NO_FLUSH:Pn,Z_PARTIAL_FLUSH:zM,Z_FULL_FLUSH:RM,Z_FINISH:ni,Z_BLOCK:B0,Z_OK:pt,Z_STREAM_END:U0,Z_STREAM_ERROR:Ii,Z_DATA_ERROR:CM,Z_BUF_ERROR:cm,Z_DEFAULT_COMPRESSION:IM,Z_FILTERED:LM,Z_HUFFMAN_ONLY:Uo,Z_RLE:NM,Z_FIXED:PM,Z_DEFAULT_STRATEGY:OM,Z_UNKNOWN:FM,Z_DEFLATED:Yo}=Ss,DM=9,BM=15,UM=8,GM=29,HM=256,km=HM+1+GM,VM=30,WM=19,$M=2*km+1,KM=15,xe=3,In=258,Li=In+xe+1,XM=32,ta=42,Om=57,bm=69,xm=73,Am=91,Em=103,ar=113,os=666,Tt=1,ra=2,cr=3,aa=4,jM=3,sr=(e,t)=>(e.msg=or[t],t),G0=e=>e*2-(e>4?9:0),Cn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},YM=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do i=e.head[--n],e.head[n]=i>=r?i-r:0;while(--t);t=r,n=t;do i=e.prev[--n],e.prev[n]=i>=r?i-r:0;while(--t)},ZM=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask,On=ZM,Wt=e=>{let t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,t.pending===0&&(t.pending_out=0))},$t=(e,t)=>{TM(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Wt(e.strm)},ze=(e,t)=>{e.pending_buf[e.pending++]=t},ss=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Tm=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),r===0?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),e.state.wrap===1?e.adler=_s(e.adler,t,r,i):e.state.wrap===2&&(e.adler=ft(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},Y_=(e,t)=>{let i=e.max_chain_length,n=e.strstart,r,a,s=e.prev_length,o=e.nice_match,c=e.strstart>e.w_size-Li?e.strstart-(e.w_size-Li):0,d=e.window,l=e.w_mask,m=e.prev,u=e.strstart+In,f=d[n+s-1],h=d[n+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do if(r=t,!(d[r+s]!==h||d[r+s-1]!==f||d[r]!==d[n]||d[++r]!==d[n+1])){n+=2,r++;do;while(d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&d[++n]===d[++r]&&n<u);if(a=In-(u-n),n=u-In,a>s){if(e.match_start=t,s=a,a>=o)break;f=d[n+s-1],h=d[n+s]}}while((t=m[t&l])>c&&--i!==0);return s<=e.lookahead?s:e.lookahead},ia=e=>{let t=e.w_size,i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Li)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),YM(e),n+=t),e.strm.avail_in===0)break;if(i=Tm(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=xe)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=On(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=On(e,e.ins_h,e.window[r+xe-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<xe)););}while(e.lookahead<Li&&e.strm.avail_in!==0)},Z_=(e,t)=>{let i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,r,a,s=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,r=e.strstart-e.block_start,n>r+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n<i&&(n===0&&t!==ni||t===Pn||n!==r+e.strm.avail_in)))break;s=t===ni&&n===r+e.strm.avail_in?1:0,Sm(e,0,0,s),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Wt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Tm(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(s===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?aa:t!==Pn&&t!==ni&&e.strm.avail_in===0&&e.strstart===e.block_start?ra:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Tm(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===ni)&&t!==Pn&&e.strm.avail_in===0&&r<=a)&&(n=r>a?a:r,s=t===ni&&e.strm.avail_in===0&&n===r?1:0,Sm(e,e.block_start,n,s),e.block_start+=n,Wt(e.strm)),s?cr:Tt)},dm=(e,t)=>{let i,n;for(;;){if(e.lookahead<Li){if(ia(e),e.lookahead<Li&&t===Pn)return Tt;if(e.lookahead===0)break}if(i=0,e.lookahead>=xe&&(e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),i!==0&&e.strstart-i<=e.w_size-Li&&(e.match_length=Y_(e,i)),e.match_length>=xe)if(n=Nn(e,e.strstart-e.match_start,e.match_length-xe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=xe){e.match_length--;do e.strstart++,e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=On(e,e.ins_h,e.window[e.strstart+1]);else n=Nn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&($t(e,!1),e.strm.avail_out===0))return Tt}return e.insert=e.strstart<xe-1?e.strstart:xe-1,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra},Jr=(e,t)=>{let i,n,r;for(;;){if(e.lookahead<Li){if(ia(e),e.lookahead<Li&&t===Pn)return Tt;if(e.lookahead===0)break}if(i=0,e.lookahead>=xe&&(e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=xe-1,i!==0&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-Li&&(e.match_length=Y_(e,i),e.match_length<=5&&(e.strategy===LM||e.match_length===xe&&e.strstart-e.match_start>4096)&&(e.match_length=xe-1)),e.prev_length>=xe&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-xe,n=Nn(e,e.strstart-1-e.prev_match,e.prev_length-xe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=On(e,e.ins_h,e.window[e.strstart+xe-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=xe-1,e.strstart++,n&&($t(e,!1),e.strm.avail_out===0))return Tt}else if(e.match_available){if(n=Nn(e,0,e.window[e.strstart-1]),n&&$t(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Tt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Nn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<xe-1?e.strstart:xe-1,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra},qM=(e,t)=>{let i,n,r,a,s=e.window;for(;;){if(e.lookahead<=In){if(ia(e),e.lookahead<=In&&t===Pn)return Tt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=xe&&e.strstart>0&&(r=e.strstart-1,n=s[r],n===s[++r]&&n===s[++r]&&n===s[++r])){a=e.strstart+In;do;while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<a);e.match_length=In-(a-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=xe?(i=Nn(e,1,e.match_length-xe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Nn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&($t(e,!1),e.strm.avail_out===0))return Tt}return e.insert=0,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra},JM=(e,t)=>{let i;for(;;){if(e.lookahead===0&&(ia(e),e.lookahead===0)){if(t===Pn)return Tt;break}if(e.match_length=0,i=Nn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&($t(e,!1),e.strm.avail_out===0))return Tt}return e.insert=0,t===ni?($t(e,!0),e.strm.avail_out===0?cr:aa):e.sym_next&&($t(e,!1),e.strm.avail_out===0)?Tt:ra};function Ri(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}var cs=[new Ri(0,0,0,0,Z_),new Ri(4,4,8,4,dm),new Ri(4,5,16,8,dm),new Ri(4,6,32,32,dm),new Ri(4,4,16,16,Jr),new Ri(8,16,32,32,Jr),new Ri(8,16,128,128,Jr),new Ri(8,32,128,256,Jr),new Ri(32,128,258,1024,Jr),new Ri(32,258,258,4096,Jr)],QM=e=>{e.window_size=2*e.w_size,Cn(e.head),e.max_lazy_match=cs[e.level].max_lazy,e.good_match=cs[e.level].good_length,e.nice_match=cs[e.level].nice_length,e.max_chain_length=cs[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=xe-1,e.match_available=0,e.ins_h=0};function e3(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Yo,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array($M*2),this.dyn_dtree=new Uint16Array((2*VM+1)*2),this.bl_tree=new Uint16Array((2*WM+1)*2),Cn(this.dyn_ltree),Cn(this.dyn_dtree),Cn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(KM+1),this.heap=new Uint16Array(2*km+1),Cn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*km+1),Cn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var ks=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==ta&&t.status!==Om&&t.status!==bm&&t.status!==xm&&t.status!==Am&&t.status!==Em&&t.status!==ar&&t.status!==os?1:0},q_=e=>{if(ks(e))return sr(e,Ii);e.total_in=e.total_out=0,e.data_type=FM;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Om:t.wrap?ta:ar,e.adler=t.wrap===2?0:1,t.last_flush=-2,EM(t),pt},J_=e=>{let t=q_(e);return t===pt&&QM(e.state),t},t3=(e,t)=>ks(e)||e.state.wrap!==2?Ii:(e.state.gzhead=t,pt),Q_=(e,t,i,n,r,a)=>{if(!e)return Ii;let s=1;if(t===IM&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>DM||i!==Yo||n<8||n>15||t<0||t>9||a<0||a>PM||n===8&&s!==1)return sr(e,Ii);n===8&&(n=9);let o=new e3;return e.state=o,o.strm=e,o.status=ta,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+xe-1)/xe),o.window=new Uint8Array(o.w_size*2),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=(o.lit_bufsize-1)*3,o.level=t,o.strategy=a,o.method=i,J_(e)},i3=(e,t)=>Q_(e,t,Yo,BM,UM,OM),n3=(e,t)=>{if(ks(e)||t>B0||t<0)return e?sr(e,Ii):Ii;let i=e.state;if(!e.output||e.avail_in!==0&&!e.input||i.status===os&&t!==ni)return sr(e,e.avail_out===0?cm:Ii);let n=i.last_flush;if(i.last_flush=t,i.pending!==0){if(Wt(e),e.avail_out===0)return i.last_flush=-1,pt}else if(e.avail_in===0&&G0(t)<=G0(n)&&t!==ni)return sr(e,cm);if(i.status===os&&e.avail_in!==0)return sr(e,cm);if(i.status===ta&&i.wrap===0&&(i.status=ar),i.status===ta){let r=Yo+(i.w_bits-8<<4)<<8,a=-1;if(i.strategy>=Uo||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,r|=a<<6,i.strstart!==0&&(r|=XM),r+=31-r%31,ss(i,r),i.strstart!==0&&(ss(i,e.adler>>>16),ss(i,e.adler&65535)),e.adler=1,i.status=ar,Wt(e),i.pending!==0)return i.last_flush=-1,pt}if(i.status===Om){if(e.adler=0,ze(i,31),ze(i,139),ze(i,8),i.gzhead)ze(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),ze(i,i.gzhead.time&255),ze(i,i.gzhead.time>>8&255),ze(i,i.gzhead.time>>16&255),ze(i,i.gzhead.time>>24&255),ze(i,i.level===9?2:i.strategy>=Uo||i.level<2?4:0),ze(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(ze(i,i.gzhead.extra.length&255),ze(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ft(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=bm;else if(ze(i,0),ze(i,0),ze(i,0),ze(i,0),ze(i,0),ze(i,i.level===9?2:i.strategy>=Uo||i.level<2?4:0),ze(i,jM),i.status=ar,Wt(e),i.pending!==0)return i.last_flush=-1,pt}if(i.status===bm){if(i.gzhead.extra){let r=i.pending,a=(i.gzhead.extra.length&65535)-i.gzindex;for(;i.pending+a>i.pending_buf_size;){let o=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+o),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex+=o,Wt(e),i.pending!==0)return i.last_flush=-1,pt;r=0,a-=o}let s=new Uint8Array(i.gzhead.extra);i.pending_buf.set(s.subarray(i.gzindex,i.gzindex+a),i.pending),i.pending+=a,i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=xm}if(i.status===xm){if(i.gzhead.name){let r=i.pending,a;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),Wt(e),i.pending!==0)return i.last_flush=-1,pt;r=0}i.gzindex<i.gzhead.name.length?a=i.gzhead.name.charCodeAt(i.gzindex++)&255:a=0,ze(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=Am}if(i.status===Am){if(i.gzhead.comment){let r=i.pending,a;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r)),Wt(e),i.pending!==0)return i.last_flush=-1,pt;r=0}i.gzindex<i.gzhead.comment.length?a=i.gzhead.comment.charCodeAt(i.gzindex++)&255:a=0,ze(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=ft(e.adler,i.pending_buf,i.pending-r,r))}i.status=Em}if(i.status===Em){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(Wt(e),i.pending!==0))return i.last_flush=-1,pt;ze(i,e.adler&255),ze(i,e.adler>>8&255),e.adler=0}if(i.status=ar,Wt(e),i.pending!==0)return i.last_flush=-1,pt}if(e.avail_in!==0||i.lookahead!==0||t!==Pn&&i.status!==os){let r=i.level===0?Z_(i,t):i.strategy===Uo?JM(i,t):i.strategy===NM?qM(i,t):cs[i.level].func(i,t);if((r===cr||r===aa)&&(i.status=os),r===Tt||r===cr)return e.avail_out===0&&(i.last_flush=-1),pt;if(r===ra&&(t===zM?MM(i):t!==B0&&(Sm(i,0,0,!1),t===RM&&(Cn(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Wt(e),e.avail_out===0))return i.last_flush=-1,pt}return t!==ni?pt:i.wrap<=0?U0:(i.wrap===2?(ze(i,e.adler&255),ze(i,e.adler>>8&255),ze(i,e.adler>>16&255),ze(i,e.adler>>24&255),ze(i,e.total_in&255),ze(i,e.total_in>>8&255),ze(i,e.total_in>>16&255),ze(i,e.total_in>>24&255)):(ss(i,e.adler>>>16),ss(i,e.adler&65535)),Wt(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?pt:U0)},r3=e=>{if(ks(e))return Ii;let t=e.state.status;return e.state=null,t===ar?sr(e,CM):pt},a3=(e,t)=>{let i=t.length;if(ks(e))return Ii;let n=e.state,r=n.wrap;if(r===2||r===1&&n.status!==ta||n.lookahead)return Ii;if(r===1&&(e.adler=_s(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){r===0&&(Cn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let c=new Uint8Array(n.w_size);c.set(t.subarray(i-n.w_size,i),0),t=c,i=n.w_size}let a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,ia(n);n.lookahead>=xe;){let c=n.strstart,d=n.lookahead-(xe-1);do n.ins_h=On(n,n.ins_h,n.window[c+xe-1]),n.prev[c&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=c,c++;while(--d);n.strstart=c,n.lookahead=xe-1,ia(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=xe-1,n.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,n.wrap=r,pt},s3=i3,o3=Q_,c3=J_,d3=q_,l3=t3,m3=n3,u3=r3,f3=a3,h3="pako deflate (from Nodeca project)",ls={deflateInit:s3,deflateInit2:o3,deflateReset:c3,deflateResetKeep:d3,deflateSetHeader:l3,deflate:m3,deflateEnd:u3,deflateSetDictionary:f3,deflateInfo:h3},g3=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_3=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let i=t.shift();if(i){if(typeof i!="object")throw new TypeError(i+"must be non-object");for(let n in i)g3(i,n)&&(e[n]=i[n])}}return e},p3=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let i=new Uint8Array(t);for(let n=0,r=0,a=e.length;n<a;n++){let s=e[n];i.set(s,r),r+=s.length}return i},Zo={assign:_3,flattenChunks:p3},ep=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ep=!1}var ps=new Uint8Array(256);for(let e=0;e<256;e++)ps[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ps[254]=ps[254]=1;var v3=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,i,n,r,a,s=e.length,o=0;for(r=0;r<s;r++)i=e.charCodeAt(r),(i&64512)===55296&&r+1<s&&(n=e.charCodeAt(r+1),(n&64512)===56320&&(i=65536+(i-55296<<10)+(n-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),a=0,r=0;a<o;r++)i=e.charCodeAt(r),(i&64512)===55296&&r+1<s&&(n=e.charCodeAt(r+1),(n&64512)===56320&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[a++]=i:i<2048?(t[a++]=192|i>>>6,t[a++]=128|i&63):i<65536?(t[a++]=224|i>>>12,t[a++]=128|i>>>6&63,t[a++]=128|i&63):(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63,t[a++]=128|i>>>6&63,t[a++]=128|i&63);return t},y3=(e,t)=>{if(t<65534&&e.subarray&&ep)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i},w3=(e,t)=>{let i=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,r,a=new Array(i*2);for(r=0,n=0;n<i;){let s=e[n++];if(s<128){a[r++]=s;continue}let o=ps[s];if(o>4){a[r++]=65533,n+=o-1;continue}for(s&=o===2?31:o===3?15:7;o>1&&n<i;)s=s<<6|e[n++]&63,o--;if(o>1){a[r++]=65533;continue}s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|s&1023)}return y3(a,r)},S3=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let i=t-1;for(;i>=0&&(e[i]&192)===128;)i--;return i<0||i===0?t:i+ps[e[i]]>t?i:t},vs={string2buf:v3,buf2string:w3,utf8border:S3};function k3(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var tp=k3,ip=Object.prototype.toString,{Z_NO_FLUSH:b3,Z_SYNC_FLUSH:x3,Z_FULL_FLUSH:A3,Z_FINISH:E3,Z_OK:Xo,Z_STREAM_END:T3,Z_DEFAULT_COMPRESSION:M3,Z_DEFAULT_STRATEGY:z3,Z_DEFLATED:R3}=Ss;function bs(e){this.options=Zo.assign({level:M3,method:R3,chunkSize:16384,windowBits:15,memLevel:8,strategy:z3},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tp,this.strm.avail_out=0;let i=ls.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Xo)throw new Error(or[i]);if(t.header&&ls.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=vs.string2buf(t.dictionary):ip.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,i=ls.deflateSetDictionary(this.strm,n),i!==Xo)throw new Error(or[i]);this._dict_set=!0}}bs.prototype.push=function(e,t){let i=this.strm,n=this.options.chunkSize,r,a;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?E3:b3,typeof e=="string"?i.input=vs.string2buf(e):ip.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){if(i.avail_out===0&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(a===x3||a===A3)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(r=ls.deflate(i,a),r===T3)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=ls.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Xo;if(i.avail_out===0){this.onData(i.output);continue}if(a>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(i.avail_in===0)break}return!0};bs.prototype.onData=function(e){this.chunks.push(e)};bs.prototype.onEnd=function(e){e===Xo&&(this.result=Zo.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Fm(e,t){let i=new bs(t);if(i.push(e,!0),i.err)throw i.msg||or[i.err];return i.result}function C3(e,t){return t=t||{},t.raw=!0,Fm(e,t)}function I3(e,t){return t=t||{},t.gzip=!0,Fm(e,t)}var L3=bs,N3=Fm,P3=C3,O3=I3,F3={Deflate:L3,deflate:N3,deflateRaw:P3,gzip:O3},Go=16209,D3=16191,B3=function(t,i){let n,r,a,s,o,c,d,l,m,u,f,h,y,p,v,A,x,w,R,b,E,D,H,O,Y=t.state;n=t.next_in,H=t.input,r=n+(t.avail_in-5),a=t.next_out,O=t.output,s=a-(i-t.avail_out),o=a+(t.avail_out-257),c=Y.dmax,d=Y.wsize,l=Y.whave,m=Y.wnext,u=Y.window,f=Y.hold,h=Y.bits,y=Y.lencode,p=Y.distcode,v=(1<<Y.lenbits)-1,A=(1<<Y.distbits)-1;e:do{h<15&&(f+=H[n++]<<h,h+=8,f+=H[n++]<<h,h+=8),x=y[f&v];t:for(;;){if(w=x>>>24,f>>>=w,h-=w,w=x>>>16&255,w===0)O[a++]=x&65535;else if(w&16){R=x&65535,w&=15,w&&(h<w&&(f+=H[n++]<<h,h+=8),R+=f&(1<<w)-1,f>>>=w,h-=w),h<15&&(f+=H[n++]<<h,h+=8,f+=H[n++]<<h,h+=8),x=p[f&A];i:for(;;){if(w=x>>>24,f>>>=w,h-=w,w=x>>>16&255,w&16){if(b=x&65535,w&=15,h<w&&(f+=H[n++]<<h,h+=8,h<w&&(f+=H[n++]<<h,h+=8)),b+=f&(1<<w)-1,b>c){t.msg="invalid distance too far back",Y.mode=Go;break e}if(f>>>=w,h-=w,w=a-s,b>w){if(w=b-w,w>l&&Y.sane){t.msg="invalid distance too far back",Y.mode=Go;break e}if(E=0,D=u,m===0){if(E+=d-w,w<R){R-=w;do O[a++]=u[E++];while(--w);E=a-b,D=O}}else if(m<w){if(E+=d+m-w,w-=m,w<R){R-=w;do O[a++]=u[E++];while(--w);if(E=0,m<R){w=m,R-=w;do O[a++]=u[E++];while(--w);E=a-b,D=O}}}else if(E+=m-w,w<R){R-=w;do O[a++]=u[E++];while(--w);E=a-b,D=O}for(;R>2;)O[a++]=D[E++],O[a++]=D[E++],O[a++]=D[E++],R-=3;R&&(O[a++]=D[E++],R>1&&(O[a++]=D[E++]))}else{E=a-b;do O[a++]=O[E++],O[a++]=O[E++],O[a++]=O[E++],R-=3;while(R>2);R&&(O[a++]=O[E++],R>1&&(O[a++]=O[E++]))}}else if((w&64)===0){x=p[(x&65535)+(f&(1<<w)-1)];continue i}else{t.msg="invalid distance code",Y.mode=Go;break e}break}}else if((w&64)===0){x=y[(x&65535)+(f&(1<<w)-1)];continue t}else if(w&32){Y.mode=D3;break e}else{t.msg="invalid literal/length code",Y.mode=Go;break e}break}}while(n<r&&a<o);R=h>>3,n-=R,h-=R<<3,f&=(1<<h)-1,t.next_in=n,t.next_out=a,t.avail_in=n<r?5+(r-n):5-(n-r),t.avail_out=a<o?257+(o-a):257-(a-o),Y.hold=f,Y.bits=h},Qr=15,H0=852,V0=592,W0=0,lm=1,$0=2,U3=new Uint16Array([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]),G3=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),H3=new Uint16Array([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,0,0]),V3=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),W3=(e,t,i,n,r,a,s,o)=>{let c=o.bits,d=0,l=0,m=0,u=0,f=0,h=0,y=0,p=0,v=0,A=0,x,w,R,b,E,D=null,H,O=new Uint16Array(Qr+1),Y=new Uint16Array(Qr+1),J=null,me,ie,be;for(d=0;d<=Qr;d++)O[d]=0;for(l=0;l<n;l++)O[t[i+l]]++;for(f=c,u=Qr;u>=1&&O[u]===0;u--);if(f>u&&(f=u),u===0)return r[a++]=1<<24|64<<16|0,r[a++]=1<<24|64<<16|0,o.bits=1,0;for(m=1;m<u&&O[m]===0;m++);for(f<m&&(f=m),p=1,d=1;d<=Qr;d++)if(p<<=1,p-=O[d],p<0)return-1;if(p>0&&(e===W0||u!==1))return-1;for(Y[1]=0,d=1;d<Qr;d++)Y[d+1]=Y[d]+O[d];for(l=0;l<n;l++)t[i+l]!==0&&(s[Y[t[i+l]]++]=l);if(e===W0?(D=J=s,H=20):e===lm?(D=U3,J=G3,H=257):(D=H3,J=V3,H=0),A=0,l=0,d=m,E=a,h=f,y=0,R=-1,v=1<<f,b=v-1,e===lm&&v>H0||e===$0&&v>V0)return 1;for(;;){me=d-y,s[l]+1<H?(ie=0,be=s[l]):s[l]>=H?(ie=J[s[l]-H],be=D[s[l]-H]):(ie=96,be=0),x=1<<d-y,w=1<<h,m=w;do w-=x,r[E+(A>>y)+w]=me<<24|ie<<16|be|0;while(w!==0);for(x=1<<d-1;A&x;)x>>=1;if(x!==0?(A&=x-1,A+=x):A=0,l++,--O[d]===0){if(d===u)break;d=t[i+s[l]]}if(d>f&&(A&b)!==R){for(y===0&&(y=f),E+=m,h=d-y,p=1<<h;h+y<u&&(p-=O[h+y],!(p<=0));)h++,p<<=1;if(v+=1<<h,e===lm&&v>H0||e===$0&&v>V0)return 1;R=A&b,r[R]=f<<24|h<<16|E-a|0}}return A!==0&&(r[E+A]=d-y<<24|64<<16|0),o.bits=f,0},ms=W3,$3=0,np=1,rp=2,{Z_FINISH:K0,Z_BLOCK:K3,Z_TREES:Ho,Z_OK:dr,Z_STREAM_END:X3,Z_NEED_DICT:j3,Z_STREAM_ERROR:ri,Z_DATA_ERROR:ap,Z_MEM_ERROR:sp,Z_BUF_ERROR:Y3,Z_DEFLATED:X0}=Ss,qo=16180,j0=16181,Y0=16182,Z0=16183,q0=16184,J0=16185,Q0=16186,e_=16187,t_=16188,i_=16189,jo=16190,nn=16191,mm=16192,n_=16193,um=16194,r_=16195,a_=16196,s_=16197,o_=16198,Vo=16199,Wo=16200,c_=16201,d_=16202,l_=16203,m_=16204,u_=16205,fm=16206,f_=16207,h_=16208,We=16209,op=16210,cp=16211,Z3=852,q3=592,J3=15,Q3=J3,g_=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function e5(){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}var lr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<qo||t.mode>cp?1:0},dp=e=>{if(lr(e))return ri;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=qo,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(Z3),t.distcode=t.distdyn=new Int32Array(q3),t.sane=1,t.back=-1,dr},lp=e=>{if(lr(e))return ri;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,dp(e)},mp=(e,t)=>{let i;if(lr(e))return ri;let n=e.state;return t<0?(i=0,t=-t):(i=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ri:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,lp(e))},up=(e,t)=>{if(!e)return ri;let i=new e5;e.state=i,i.strm=e,i.window=null,i.mode=qo;let n=mp(e,t);return n!==dr&&(e.state=null),n},t5=e=>up(e,Q3),__=!0,hm,gm,i5=e=>{if(__){hm=new Int32Array(512),gm=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(ms(np,e.lens,0,288,hm,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ms(rp,e.lens,0,32,gm,0,e.work,{bits:5}),__=!1}e.lencode=hm,e.lenbits=9,e.distcode=gm,e.distbits=5},fp=(e,t,i,n)=>{let r,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>n&&(r=n),a.window.set(t.subarray(i-n,i-n+r),a.wnext),n-=r,n?(a.window.set(t.subarray(i-n,i),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r))),0},n5=(e,t)=>{let i,n,r,a,s,o,c,d,l,m,u,f,h,y,p=0,v,A,x,w,R,b,E,D,H=new Uint8Array(4),O,Y,J=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(lr(e)||!e.output||!e.input&&e.avail_in!==0)return ri;i=e.state,i.mode===nn&&(i.mode=mm),s=e.next_out,r=e.output,c=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=i.hold,l=i.bits,m=o,u=c,D=dr;e:for(;;)switch(i.mode){case qo:if(i.wrap===0){i.mode=mm;break}for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.wrap&2&&d===35615){i.wbits===0&&(i.wbits=15),i.check=0,H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0),d=0,l=0,i.mode=j0;break}if(i.head&&(i.head.done=!1),!(i.wrap&1)||(((d&255)<<8)+(d>>8))%31){e.msg="incorrect header check",i.mode=We;break}if((d&15)!==X0){e.msg="unknown compression method",i.mode=We;break}if(d>>>=4,l-=4,E=(d&15)+8,i.wbits===0&&(i.wbits=E),E>15||E>i.wbits){e.msg="invalid window size",i.mode=We;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=d&512?i_:nn,d=0,l=0;break;case j0:for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.flags=d,(i.flags&255)!==X0){e.msg="unknown compression method",i.mode=We;break}if(i.flags&57344){e.msg="unknown header flags set",i.mode=We;break}i.head&&(i.head.text=d>>8&1),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0)),d=0,l=0,i.mode=Y0;case Y0:for(;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.head&&(i.head.time=d),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,H[2]=d>>>16&255,H[3]=d>>>24&255,i.check=ft(i.check,H,4,0)),d=0,l=0,i.mode=Z0;case Z0:for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.head&&(i.head.xflags=d&255,i.head.os=d>>8),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0)),d=0,l=0,i.mode=q0;case q0:if(i.flags&1024){for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.length=d,i.head&&(i.head.extra_len=d),i.flags&512&&i.wrap&4&&(H[0]=d&255,H[1]=d>>>8&255,i.check=ft(i.check,H,2,0)),d=0,l=0}else i.head&&(i.head.extra=null);i.mode=J0;case J0:if(i.flags&1024&&(f=i.length,f>o&&(f=o),f&&(i.head&&(E=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(a,a+f),E)),i.flags&512&&i.wrap&4&&(i.check=ft(i.check,n,f,a)),o-=f,a+=f,i.length-=f),i.length))break e;i.length=0,i.mode=Q0;case Q0:if(i.flags&2048){if(o===0)break e;f=0;do E=n[a+f++],i.head&&E&&i.length<65536&&(i.head.name+=String.fromCharCode(E));while(E&&f<o);if(i.flags&512&&i.wrap&4&&(i.check=ft(i.check,n,f,a)),o-=f,a+=f,E)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=e_;case e_:if(i.flags&4096){if(o===0)break e;f=0;do E=n[a+f++],i.head&&E&&i.length<65536&&(i.head.comment+=String.fromCharCode(E));while(E&&f<o);if(i.flags&512&&i.wrap&4&&(i.check=ft(i.check,n,f,a)),o-=f,a+=f,E)break e}else i.head&&(i.head.comment=null);i.mode=t_;case t_:if(i.flags&512){for(;l<16;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.wrap&4&&d!==(i.check&65535)){e.msg="header crc mismatch",i.mode=We;break}d=0,l=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=nn;break;case i_:for(;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}e.adler=i.check=g_(d),d=0,l=0,i.mode=jo;case jo:if(i.havedict===0)return e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,i.hold=d,i.bits=l,j3;e.adler=i.check=1,i.mode=nn;case nn:if(t===K3||t===Ho)break e;case mm:if(i.last){d>>>=l&7,l-=l&7,i.mode=fm;break}for(;l<3;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}switch(i.last=d&1,d>>>=1,l-=1,d&3){case 0:i.mode=n_;break;case 1:if(i5(i),i.mode=Vo,t===Ho){d>>>=2,l-=2;break e}break;case 2:i.mode=a_;break;case 3:e.msg="invalid block type",i.mode=We}d>>>=2,l-=2;break;case n_:for(d>>>=l&7,l-=l&7;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if((d&65535)!==(d>>>16^65535)){e.msg="invalid stored block lengths",i.mode=We;break}if(i.length=d&65535,d=0,l=0,i.mode=um,t===Ho)break e;case um:i.mode=r_;case r_:if(f=i.length,f){if(f>o&&(f=o),f>c&&(f=c),f===0)break e;r.set(n.subarray(a,a+f),s),o-=f,a+=f,c-=f,s+=f,i.length-=f;break}i.mode=nn;break;case a_:for(;l<14;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.nlen=(d&31)+257,d>>>=5,l-=5,i.ndist=(d&31)+1,d>>>=5,l-=5,i.ncode=(d&15)+4,d>>>=4,l-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=We;break}i.have=0,i.mode=s_;case s_:for(;i.have<i.ncode;){for(;l<3;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.lens[J[i.have++]]=d&7,d>>>=3,l-=3}for(;i.have<19;)i.lens[J[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,O={bits:i.lenbits},D=ms($3,i.lens,0,19,i.lencode,0,i.work,O),i.lenbits=O.bits,D){e.msg="invalid code lengths set",i.mode=We;break}i.have=0,i.mode=o_;case o_:for(;i.have<i.nlen+i.ndist;){for(;p=i.lencode[d&(1<<i.lenbits)-1],v=p>>>24,A=p>>>16&255,x=p&65535,!(v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(x<16)d>>>=v,l-=v,i.lens[i.have++]=x;else{if(x===16){for(Y=v+2;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(d>>>=v,l-=v,i.have===0){e.msg="invalid bit length repeat",i.mode=We;break}E=i.lens[i.have-1],f=3+(d&3),d>>>=2,l-=2}else if(x===17){for(Y=v+3;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=v,l-=v,E=0,f=3+(d&7),d>>>=3,l-=3}else{for(Y=v+7;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=v,l-=v,E=0,f=11+(d&127),d>>>=7,l-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=We;break}for(;f--;)i.lens[i.have++]=E}}if(i.mode===We)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=We;break}if(i.lenbits=9,O={bits:i.lenbits},D=ms(np,i.lens,0,i.nlen,i.lencode,0,i.work,O),i.lenbits=O.bits,D){e.msg="invalid literal/lengths set",i.mode=We;break}if(i.distbits=6,i.distcode=i.distdyn,O={bits:i.distbits},D=ms(rp,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,O),i.distbits=O.bits,D){e.msg="invalid distances set",i.mode=We;break}if(i.mode=Vo,t===Ho)break e;case Vo:i.mode=Wo;case Wo:if(o>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,i.hold=d,i.bits=l,B3(e,u),s=e.next_out,r=e.output,c=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=i.hold,l=i.bits,i.mode===nn&&(i.back=-1);break}for(i.back=0;p=i.lencode[d&(1<<i.lenbits)-1],v=p>>>24,A=p>>>16&255,x=p&65535,!(v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(A&&(A&240)===0){for(w=v,R=A,b=x;p=i.lencode[b+((d&(1<<w+R)-1)>>w)],v=p>>>24,A=p>>>16&255,x=p&65535,!(w+v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=w,l-=w,i.back+=w}if(d>>>=v,l-=v,i.back+=v,i.length=x,A===0){i.mode=u_;break}if(A&32){i.back=-1,i.mode=nn;break}if(A&64){e.msg="invalid literal/length code",i.mode=We;break}i.extra=A&15,i.mode=c_;case c_:if(i.extra){for(Y=i.extra;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.length+=d&(1<<i.extra)-1,d>>>=i.extra,l-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=d_;case d_:for(;p=i.distcode[d&(1<<i.distbits)-1],v=p>>>24,A=p>>>16&255,x=p&65535,!(v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if((A&240)===0){for(w=v,R=A,b=x;p=i.distcode[b+((d&(1<<w+R)-1)>>w)],v=p>>>24,A=p>>>16&255,x=p&65535,!(w+v<=l);){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}d>>>=w,l-=w,i.back+=w}if(d>>>=v,l-=v,i.back+=v,A&64){e.msg="invalid distance code",i.mode=We;break}i.offset=x,i.extra=A&15,i.mode=l_;case l_:if(i.extra){for(Y=i.extra;l<Y;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}i.offset+=d&(1<<i.extra)-1,d>>>=i.extra,l-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=We;break}i.mode=m_;case m_:if(c===0)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=We;break}f>i.wnext?(f-=i.wnext,h=i.wsize-f):h=i.wnext-f,f>i.length&&(f=i.length),y=i.window}else y=r,h=s-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do r[s++]=y[h++];while(--f);i.length===0&&(i.mode=Wo);break;case u_:if(c===0)break e;r[s++]=i.length,c--,i.mode=Wo;break;case fm:if(i.wrap){for(;l<32;){if(o===0)break e;o--,d|=n[a++]<<l,l+=8}if(u-=c,e.total_out+=u,i.total+=u,i.wrap&4&&u&&(e.adler=i.check=i.flags?ft(i.check,r,u,s-u):_s(i.check,r,u,s-u)),u=c,i.wrap&4&&(i.flags?d:g_(d))!==i.check){e.msg="incorrect data check",i.mode=We;break}d=0,l=0}i.mode=f_;case f_:if(i.wrap&&i.flags){for(;l<32;){if(o===0)break e;o--,d+=n[a++]<<l,l+=8}if(i.wrap&4&&d!==(i.total&4294967295)){e.msg="incorrect length check",i.mode=We;break}d=0,l=0}i.mode=h_;case h_:D=X3;break e;case We:D=ap;break e;case op:return sp;case cp:default:return ri}return e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,i.hold=d,i.bits=l,(i.wsize||u!==e.avail_out&&i.mode<We&&(i.mode<fm||t!==K0))&&fp(e,e.output,e.next_out,u-e.avail_out),m-=e.avail_in,u-=e.avail_out,e.total_in+=m,e.total_out+=u,i.total+=u,i.wrap&4&&u&&(e.adler=i.check=i.flags?ft(i.check,r,u,e.next_out-u):_s(i.check,r,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===nn?128:0)+(i.mode===Vo||i.mode===um?256:0),(m===0&&u===0||t===K0)&&D===dr&&(D=Y3),D},r5=e=>{if(lr(e))return ri;let t=e.state;return t.window&&(t.window=null),e.state=null,dr},a5=(e,t)=>{if(lr(e))return ri;let i=e.state;return(i.wrap&2)===0?ri:(i.head=t,t.done=!1,dr)},s5=(e,t)=>{let i=t.length,n,r,a;return lr(e)||(n=e.state,n.wrap!==0&&n.mode!==jo)?ri:n.mode===jo&&(r=1,r=_s(r,t,i,0),r!==n.check)?ap:(a=fp(e,t,i,i),a?(n.mode=op,sp):(n.havedict=1,dr))},o5=lp,c5=mp,d5=dp,l5=t5,m5=up,u5=n5,f5=r5,h5=a5,g5=s5,_5="pako inflate (from Nodeca project)",an={inflateReset:o5,inflateReset2:c5,inflateResetKeep:d5,inflateInit:l5,inflateInit2:m5,inflate:u5,inflateEnd:f5,inflateGetHeader:h5,inflateSetDictionary:g5,inflateInfo:_5};function p5(){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}var v5=p5,hp=Object.prototype.toString,{Z_NO_FLUSH:y5,Z_FINISH:w5,Z_OK:ys,Z_STREAM_END:_m,Z_NEED_DICT:pm,Z_STREAM_ERROR:S5,Z_DATA_ERROR:p_,Z_MEM_ERROR:k5}=Ss;function xs(e){this.options=Zo.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tp,this.strm.avail_out=0;let i=an.inflateInit2(this.strm,t.windowBits);if(i!==ys)throw new Error(or[i]);if(this.header=new v5,an.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=vs.string2buf(t.dictionary):hp.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=an.inflateSetDictionary(this.strm,t.dictionary),i!==ys)))throw new Error(or[i])}xs.prototype.push=function(e,t){let i=this.strm,n=this.options.chunkSize,r=this.options.dictionary,a,s,o;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?w5:y5,hp.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),a=an.inflate(i,s),a===pm&&r&&(a=an.inflateSetDictionary(i,r),a===ys?a=an.inflate(i,s):a===p_&&(a=pm));i.avail_in>0&&a===_m&&i.state.wrap>0&&e[i.next_in]!==0;)an.inflateReset(i),a=an.inflate(i,s);switch(a){case S5:case p_:case pm:case k5:return this.onEnd(a),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(i.avail_out===0||a===_m))if(this.options.to==="string"){let c=vs.utf8border(i.output,i.next_out),d=i.next_out-c,l=vs.buf2string(i.output,c);i.next_out=d,i.avail_out=n-d,d&&i.output.set(i.output.subarray(c,c+d),0),this.onData(l)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(a===ys&&o===0)){if(a===_m)return a=an.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(i.avail_in===0)break}}return!0};xs.prototype.onData=function(e){this.chunks.push(e)};xs.prototype.onEnd=function(e){e===ys&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Zo.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Dm(e,t){let i=new xs(t);if(i.push(e),i.err)throw i.msg||or[i.err];return i.result}function b5(e,t){return t=t||{},t.raw=!0,Dm(e,t)}var x5=xs,A5=Dm,E5=b5,T5=Dm,M5={Inflate:x5,inflate:A5,inflateRaw:E5,ungzip:T5},{Deflate:z5,deflate:R5,deflateRaw:C5,gzip:I5}=F3,{Inflate:L5,inflate:N5,inflateRaw:P5,ungzip:O5}=M5,F5=z5,D5=R5,B5=C5,U5=I5,G5=L5,H5=N5,V5=P5,W5=O5,$5=Ss,v_={Deflate:F5,deflate:D5,deflateRaw:B5,gzip:U5,Inflate:G5,inflate:H5,inflateRaw:V5,ungzip:W5,constants:$5},Bm=class Mm{constructor(t=Mm.INITIAL_SIZE){this.buffer=new Uint8Array(t),this.readOffset=0,this.writeOffset=0}append(t){let i=t instanceof Uint8Array?t:new Uint8Array(t),n=this.writeOffset+i.length;n>this.buffer.length&&this.grow(n),this.buffer.set(i,this.writeOffset),this.writeOffset+=i.length}hasBytes(t){return this.writeOffset-this.readOffset>=t}available(){return this.writeOffset-this.readOffset}readByte(){if(!this.hasBytes(1))throw new Error("Buffer underflow");return this.buffer[this.readOffset++]}readShort(){if(!this.hasBytes(2))throw new Error("Buffer underflow");let t=this.buffer[this.readOffset]|this.buffer[this.readOffset+1]<<8;return this.readOffset+=2,t>32767?t-65536:t}readLong(){if(!this.hasBytes(4))throw new Error("Buffer underflow");let t=this.buffer[this.readOffset]|this.buffer[this.readOffset+1]<<8|this.buffer[this.readOffset+2]<<16|this.buffer[this.readOffset+3]<<24;return this.readOffset+=4,t}readFloat(){if(!this.hasBytes(4))throw new Error("Buffer underflow");let i=new DataView(this.buffer.buffer,this.buffer.byteOffset+this.readOffset,4).getFloat32(0,!0);return this.readOffset+=4,i}readString(){let t=Math.min(Mm.MAX_STRING_LENGTH,this.writeOffset-this.readOffset),i=0;for(;i<t&&this.buffer[this.readOffset+i]!==0;)i++;if(i>=t)throw this.writeOffset-this.readOffset<=t?new Error("Buffer underflow"):new Error("String exceeds max length");let n=this.buffer.slice(this.readOffset,this.readOffset+i);return this.readOffset+=i+1,new TextDecoder("latin1").decode(n)}peekBytes(t){if(!this.hasBytes(t))throw new Error("Buffer underflow");return this.buffer.slice(this.readOffset,this.readOffset+t)}readBytes(t){if(!this.hasBytes(t))throw new Error("Buffer underflow");let i=this.buffer.slice(this.readOffset,this.readOffset+t);return this.readOffset+=t,i}readData(t){return this.readBytes(t)}getReadPosition(){return this.readOffset}getWritePosition(){return this.writeOffset}setReadPosition(t){if(t<0||t>this.writeOffset)throw new Error("Invalid read position");this.readOffset=t}grow(t){let i=t?Math.max(t,this.buffer.length*2):this.buffer.length*2,n=new Uint8Array(i);n.set(this.buffer),this.buffer=n}compact(){if(this.readOffset===0)return;let t=this.writeOffset-this.readOffset;if(t===0){this.readOffset=0,this.writeOffset=0;return}this.buffer.copyWithin(0,this.readOffset,this.writeOffset),this.readOffset=0,this.writeOffset=t}getCapacity(){return this.buffer.length}reset(){this.readOffset=0,this.writeOffset=0}};Bm.INITIAL_SIZE=64*1024;Bm.MAX_STRING_LENGTH=2048;var K5=Bm,Ln=()=>({number:0,modelindex:0,modelindex2:0,modelindex3:0,modelindex4:0,frame:0,skinnum:0,effects:0,renderfx:0,origin:{x:0,y:0,z:0},old_origin:{x:0,y:0,z:0},angles:{x:0,y:0,z:0},sound:0,event:0,solid:0,bits:0,bitsHigh:0,alpha:0,scale:0,instanceBits:0,loopVolume:0,loopAttenuation:0,owner:0,oldFrame:0}),Jo=()=>({pm_type:0,origin:{x:0,y:0,z:0},velocity:{x:0,y:0,z:0},pm_time:0,pm_flags:0,gravity:0,delta_angles:{x:0,y:0,z:0},viewoffset:{x:0,y:0,z:0},viewangles:{x:0,y:0,z:0},kick_angles:{x:0,y:0,z:0},gun_index:0,gun_frame:0,gun_offset:{x:0,y:0,z:0},gun_angles:{x:0,y:0,z:0},blend:[0,0,0,0],fov:0,rdflags:0,stats:new Array(32).fill(0),gunskin:0,gunrate:0,damage_blend:[0,0,0,0],team_id:0,watertype:0}),y_={0:I.bad,1:I.nop,2:I.disconnect,3:I.reconnect,4:I.download,5:I.frame,6:I.inventory,7:I.layout,8:I.muzzleflash,9:I.temp_entity,10:I.sound,11:I.print,12:I.stufftext,13:I.serverdata,14:I.configstring,15:I.spawnbaseline,16:I.centerprint,17:I.playerinfo,18:I.packetentities,19:I.deltapacketentities,20:I.muzzleflash2},X5=class{constructor(){this.protocolVersion=34}translateCommand(e){return y_[e]!==void 0?y_[e]:I.bad}parseServerData(e){let t=e.readLong(),i=e.readLong(),n=e.readByte(),r=e.readString(),a=e.readShort(),s=e.readString();return{protocol:t,serverCount:i,attractLoop:n,gameDir:r,playerNum:a,levelName:s}}parseEntityBits(e){let t=e.readByte();t&zo&&(t|=e.readByte()<<8),t&Io&&(t|=e.readByte()<<16),t&Lo&&(t|=e.readByte()<<24);let i;return t&Ro?i=e.readShort():i=e.readByte(),{number:i,bits:t,bitsHigh:0}}parseDelta(e,t,i,n,r,a){t.number=e.number,t.modelindex=e.modelindex,t.modelindex2=e.modelindex2,t.modelindex3=e.modelindex3,t.modelindex4=e.modelindex4,t.frame=e.frame,t.skinnum=e.skinnum,t.effects=e.effects,t.renderfx=e.renderfx,t.origin.x=e.origin.x,t.origin.y=e.origin.y,t.origin.z=e.origin.z,t.old_origin.x=e.origin.x,t.old_origin.y=e.origin.y,t.old_origin.z=e.origin.z,t.angles.x=e.angles.x,t.angles.y=e.angles.y,t.angles.z=e.angles.z,t.sound=e.sound,t.event=e.event,t.solid=e.solid,t.number=i,t.bits=n,n&Hr&&(t.modelindex=a.readByte()),n&Wr&&(t.modelindex2=a.readByte()),n&$r&&(t.modelindex3=a.readByte()),n&Kr&&(t.modelindex4=a.readByte()),n&Dr&&(t.frame=a.readByte()),n&Vr&&(t.frame=a.readShort()),n&Ji&&n&tn?t.skinnum=a.readLong():n&Ji?t.skinnum=a.readByte():n&tn&&(t.skinnum=a.readShort()),n&qi&&n&en?t.effects=a.readLong():n&qi?t.effects=a.readByte():n&en&&(t.effects=a.readShort()),n&Zi&&n&Qi?t.renderfx=a.readLong():n&Zi?t.renderfx=a.readByte():n&Qi&&(t.renderfx=a.readShort()),n&Nr&&(t.origin.x=a.readShort()*.125),n&Pr&&(t.origin.y=a.readShort()*.125),n&Ur&&(t.origin.z=a.readShort()*.125),n&Gr&&(t.angles.x=a.readByte()*(360/256)),n&Or&&(t.angles.y=a.readByte()*(360/256)),n&Fr&&(t.angles.z=a.readByte()*(360/256)),n&Xr&&(t.old_origin.x=a.readShort()*.125,t.old_origin.y=a.readShort()*.125,t.old_origin.z=a.readShort()*.125),n&jr&&(t.sound=a.readByte()),n&Br?t.event=a.readByte():t.event=0,n&Yr&&(t.solid=a.readShort())}parsePlayerState(e){let t=Jo(),i=e.readShort();i&1&&(t.pm_type=e.readByte()),i&2&&(t.origin.x=e.readShort()*.125,t.origin.y=e.readShort()*.125,t.origin.z=e.readShort()*.125),i&4&&(t.velocity.x=e.readShort()*.125,t.velocity.y=e.readShort()*.125,t.velocity.z=e.readShort()*.125),i&8&&(t.pm_time=e.readByte()),i&16&&(t.pm_flags=e.readByte()),i&32&&(t.gravity=e.readShort()),i&64&&(t.delta_angles.x=e.readShort()*(180/32768),t.delta_angles.y=e.readShort()*(180/32768),t.delta_angles.z=e.readShort()*(180/32768)),i&128&&(t.viewoffset.x=(e.readByte()<<24>>24)*.25,t.viewoffset.y=(e.readByte()<<24>>24)*.25,t.viewoffset.z=(e.readByte()<<24>>24)*.25),i&256&&(t.viewangles.x=e.readShort()*(360/65536),t.viewangles.y=e.readShort()*(360/65536),t.viewangles.z=e.readShort()*(360/65536)),i&512&&(t.kick_angles.x=(e.readByte()<<24>>24)*.25,t.kick_angles.y=(e.readByte()<<24>>24)*.25,t.kick_angles.z=(e.readByte()<<24>>24)*.25),i&4096&&(t.gun_index=e.readByte()),i&8192&&(t.gun_frame=e.readByte(),t.gun_offset.x=(e.readByte()<<24>>24)*.25,t.gun_offset.y=(e.readByte()<<24>>24)*.25,t.gun_offset.z=(e.readByte()<<24>>24)*.25,t.gun_angles.x=(e.readByte()<<24>>24)*.25,t.gun_angles.y=(e.readByte()<<24>>24)*.25,t.gun_angles.z=(e.readByte()<<24>>24)*.25),i&1024&&(t.blend[0]=e.readByte(),t.blend[1]=e.readByte(),t.blend[2]=e.readByte(),t.blend[3]=e.readByte()),i&2048&&(t.fov=e.readByte()),i&16384&&(t.rdflags=e.readByte()),i&32768&&(t.watertype=e.readByte());let n=e.readLong();for(let r=0;r<32;r++)n&1<<r&&(t.stats[r]=e.readShort());return t}},sa=2023,j5=class{constructor(){this.protocolVersion=sa}translateCommand(e){return e}parseServerData(e){let t=e.readLong(),i=e.readLong(),n=e.readByte(),r=e.readByte(),a=e.readString(),s=e.readShort();if(s===-2){let c=e.readShort();for(let d=0;d<c;d++)e.readShort();s=0}else s===-1&&(s=-1);let o=e.readString();return{protocol:t,serverCount:i,spawnCount:i,attractLoop:0,gameDir:a,playerNum:s,levelName:o,tickRate:r,demoType:n}}parseEntityBits(e){let t=e.readByte();t&zo&&(t|=e.readByte()<<8),t&Io&&(t|=e.readByte()<<16),t&Lo&&(t|=e.readByte()<<24);let i=0;t&h0&&(i=e.readByte());let n;return t&Ro?n=e.readShort():n=e.readByte(),{number:n,bits:t,bitsHigh:i}}parseDelta(e,t,i,n,r,a){Object.assign(t,e),t.origin={...e.origin},t.old_origin={...e.old_origin},t.angles={...e.angles},t.number=i,t.bits=n,t.bitsHigh=r,n&Hr&&(t.modelindex=a.readByte()),n&Wr&&(t.modelindex2=a.readByte()),n&$r&&(t.modelindex3=a.readByte()),n&Kr&&(t.modelindex4=a.readByte()),n&Dr&&(t.frame=a.readByte()),n&Vr&&(t.frame=a.readShort()),n&Ji&&n&tn?t.skinnum=a.readLong():n&Ji?t.skinnum=a.readByte():n&tn&&(t.skinnum=a.readShort()),n&qi&&n&en?t.effects=a.readLong():n&qi?t.effects=a.readByte():n&en&&(t.effects=a.readShort()),n&Zi&&n&Qi?t.renderfx=a.readLong():n&Zi?t.renderfx=a.readByte():n&Qi&&(t.renderfx=a.readShort()),n&Nr&&(t.origin.x=a.readShort()*.125),n&Pr&&(t.origin.y=a.readShort()*.125),n&Ur&&(t.origin.z=a.readShort()*.125),n&Gr&&(t.angles.x=a.readByte()*(360/256)),n&Or&&(t.angles.y=a.readByte()*(360/256)),n&Fr&&(t.angles.z=a.readByte()*(360/256)),n&Xr&&(t.old_origin.x=a.readShort()*.125,t.old_origin.y=a.readShort()*.125,t.old_origin.z=a.readShort()*.125),n&jr&&(t.sound=a.readByte()),n&Br?t.event=a.readByte():t.event=0,n&Yr&&(t.solid=a.readShort()),n&Co&&(t.alpha=a.readByte()/255),n&No&&(t.scale=a.readFloat()),n&Po&&(t.instanceBits=a.readLong()),n&Oo&&(t.loopVolume=a.readByte()/255),r&Jl&&(t.loopAttenuation=a.readByte()/255),r&Ql&&(t.owner=a.readShort()),r&em&&(t.oldFrame=a.readShort())}parsePlayerState(e){let t=Jo(),i=e.readShort();i&1&&(t.pm_type=e.readByte()),i&2&&(t.origin.x=e.readShort()*.125,t.origin.y=e.readShort()*.125,t.origin.z=e.readShort()*.125),i&4&&(t.velocity.x=e.readShort()*.125,t.velocity.y=e.readShort()*.125,t.velocity.z=e.readShort()*.125),i&8&&(t.pm_time=e.readByte()),i&16&&(t.pm_flags=e.readByte()),i&32&&(t.gravity=e.readShort()),i&64&&(t.delta_angles.x=e.readShort()*(180/32768),t.delta_angles.y=e.readShort()*(180/32768),t.delta_angles.z=e.readShort()*(180/32768)),i&128&&(t.viewoffset.x=(e.readByte()<<24>>24)*.25,t.viewoffset.y=(e.readByte()<<24>>24)*.25,t.viewoffset.z=(e.readByte()<<24>>24)*.25),i&256&&(t.viewangles.x=e.readShort()*(360/65536),t.viewangles.y=e.readShort()*(360/65536),t.viewangles.z=e.readShort()*(360/65536)),i&512&&(t.kick_angles.x=(e.readByte()<<24>>24)*.25,t.kick_angles.y=(e.readByte()<<24>>24)*.25,t.kick_angles.z=(e.readByte()<<24>>24)*.25),i&4096&&(t.gun_index=e.readByte()),i&8192&&(t.gun_frame=e.readByte(),t.gun_offset.x=(e.readByte()<<24>>24)*.25,t.gun_offset.y=(e.readByte()<<24>>24)*.25,t.gun_offset.z=(e.readByte()<<24>>24)*.25,t.gun_angles.x=(e.readByte()<<24>>24)*.25,t.gun_angles.y=(e.readByte()<<24>>24)*.25,t.gun_angles.z=(e.readByte()<<24>>24)*.25),i&1024&&(t.blend[0]=e.readByte(),t.blend[1]=e.readByte(),t.blend[2]=e.readByte(),t.blend[3]=e.readByte()),i&2048&&(t.fov=e.readByte()),i&16384&&(t.rdflags=e.readByte()),i&32768&&(t.watertype=e.readByte());let n=e.readLong();for(let r=0;r<32;r++)n&1<<r&&(t.stats[r]=e.readShort());return t}},Y5=class{constructor(e=0){this.protocolVersion=e}translateCommand(e){return e}parseServerData(e){let t=e.readLong(),i=e.readLong(),n=e.readByte(),r=e.readString(),a=e.readShort(),s=e.readString();return{protocol:t,serverCount:i,attractLoop:n,gameDir:r,playerNum:a,levelName:s}}parseEntityBits(e){let t=e.readByte();t&zo&&(t|=e.readByte()<<8),t&Io&&(t|=e.readByte()<<16),t&Lo&&(t|=e.readByte()<<24);let i;return t&Ro?i=e.readShort():i=e.readByte(),{number:i,bits:t,bitsHigh:0}}parseDelta(e,t,i,n,r,a){t.number=e.number,t.modelindex=e.modelindex,t.modelindex2=e.modelindex2,t.modelindex3=e.modelindex3,t.modelindex4=e.modelindex4,t.frame=e.frame,t.skinnum=e.skinnum,t.effects=e.effects,t.renderfx=e.renderfx,t.origin.x=e.origin.x,t.origin.y=e.origin.y,t.origin.z=e.origin.z,t.old_origin.x=e.origin.x,t.old_origin.y=e.origin.y,t.old_origin.z=e.origin.z,t.angles.x=e.angles.x,t.angles.y=e.angles.y,t.angles.z=e.angles.z,t.sound=e.sound,t.event=e.event,t.solid=e.solid,t.number=i,t.bits=n,n&Hr&&(t.modelindex=a.readByte()),n&Wr&&(t.modelindex2=a.readByte()),n&$r&&(t.modelindex3=a.readByte()),n&Kr&&(t.modelindex4=a.readByte()),n&Dr&&(t.frame=a.readByte()),n&Vr&&(t.frame=a.readShort()),n&Ji&&n&tn?t.skinnum=a.readLong():n&Ji?t.skinnum=a.readByte():n&tn&&(t.skinnum=a.readShort()),n&qi&&n&en?t.effects=a.readLong():n&qi?t.effects=a.readByte():n&en&&(t.effects=a.readShort()),n&Zi&&n&Qi?t.renderfx=a.readLong():n&Zi?t.renderfx=a.readByte():n&Qi&&(t.renderfx=a.readShort()),n&Nr&&(t.origin.x=a.readShort()*.125),n&Pr&&(t.origin.y=a.readShort()*.125),n&Ur&&(t.origin.z=a.readShort()*.125),n&Gr&&(t.angles.x=a.readByte()*(360/256)),n&Or&&(t.angles.y=a.readByte()*(360/256)),n&Fr&&(t.angles.z=a.readByte()*(360/256)),n&Xr&&(t.old_origin.x=a.readShort()*.125,t.old_origin.y=a.readShort()*.125,t.old_origin.z=a.readShort()*.125),n&jr&&(t.sound=a.readByte()),n&Br?t.event=a.readByte():t.event=0,n&Yr&&(t.solid=a.readShort())}parsePlayerState(e){let t=Jo(),i=e.readShort();i&1&&(t.pm_type=e.readByte()),i&2&&(t.origin.x=e.readShort()*.125,t.origin.y=e.readShort()*.125,t.origin.z=e.readShort()*.125),i&4&&(t.velocity.x=e.readShort()*.125,t.velocity.y=e.readShort()*.125,t.velocity.z=e.readShort()*.125),i&8&&(t.pm_time=e.readByte()),i&16&&(t.pm_flags=e.readByte()),i&32&&(t.gravity=e.readShort()),i&64&&(t.delta_angles.x=e.readShort()*(180/32768),t.delta_angles.y=e.readShort()*(180/32768),t.delta_angles.z=e.readShort()*(180/32768)),i&128&&(t.viewoffset.x=(e.readByte()<<24>>24)*.25,t.viewoffset.y=(e.readByte()<<24>>24)*.25,t.viewoffset.z=(e.readByte()<<24>>24)*.25),i&256&&(t.viewangles.x=e.readShort()*(360/65536),t.viewangles.y=e.readShort()*(360/65536),t.viewangles.z=e.readShort()*(360/65536)),i&512&&(t.kick_angles.x=(e.readByte()<<24>>24)*.25,t.kick_angles.y=(e.readByte()<<24>>24)*.25,t.kick_angles.z=(e.readByte()<<24>>24)*.25),i&4096&&(t.gun_index=e.readByte()),i&8192&&(t.gun_frame=e.readByte(),t.gun_offset.x=(e.readByte()<<24>>24)*.25,t.gun_offset.y=(e.readByte()<<24>>24)*.25,t.gun_offset.z=(e.readByte()<<24>>24)*.25,t.gun_angles.x=(e.readByte()<<24>>24)*.25,t.gun_angles.y=(e.readByte()<<24>>24)*.25,t.gun_angles.z=(e.readByte()<<24>>24)*.25),i&1024&&(t.blend[0]=e.readByte(),t.blend[1]=e.readByte(),t.blend[2]=e.readByte(),t.blend[3]=e.readByte()),i&2048&&(t.fov=e.readByte()),i&16384&&(t.rdflags=e.readByte()),i&32768&&(t.watertype=e.readByte());let n=e.readLong();for(let r=0;r<32;r++)n&1<<r&&(t.stats[r]=e.readShort());return t}},gp=class{constructor(){this.protocolVersion=0}translateCommand(e){return e===7?I.serverdata:e===12?I.serverdata:e===13?I.serverdata:e===I.stufftext?I.stufftext:I.bad}parseServerData(e){let t=e.readLong();if(t===sa){let i=e.readLong(),n=e.readByte(),r=e.readByte(),a=e.readString(),s=e.readShort();if(s===-2){let c=e.readShort();for(let d=0;d<c;d++)e.readShort();s=0}else s===-1&&(s=-1);let o=e.readString();return{protocol:t,serverCount:i,spawnCount:i,attractLoop:0,gameDir:a,playerNum:s,levelName:o,tickRate:r,demoType:n}}else{let i=e.readLong(),n=e.readByte(),r=e.readString(),a=e.readShort(),s=e.readString();return{protocol:t,serverCount:i,attractLoop:n,gameDir:r,playerNum:a,levelName:s}}}parseEntityBits(e){throw new Error("Bootstrap handler cannot parse entities")}parseDelta(e,t,i,n,r,a){throw new Error("Bootstrap handler cannot parse delta")}parsePlayerState(e){throw new Error("Bootstrap handler cannot parse player state")}};function Z5(e){return e===0?new gp:e===sa?new j5:e===34?new X5:new Y5(e)}var w_=1,q5=2,J5=128,Q5=class extends K5{constructor(e){super(0),this.stream=e}readByte(){return this.stream.readByte()}readShort(){return this.stream.readShort()}readLong(){return this.stream.readLong()}readFloat(){return this.stream.readFloat()}readString(){return this.stream.readString()}readData(e){return this.stream.readData(e)}hasBytes(e){return this.stream.hasMore()}available(){return this.stream.getRemaining()}getReadPosition(){return this.stream.getPosition()}peekBytes(e){throw new Error("peekBytes not implemented for BinaryStreamAdapter")}},Qo=class _p{constructor(t,i,n=!1){this.strictMode=!1,this.errorCount=0,this.isDemo=w_,t instanceof nr?this.stream=new Q5(t):this.stream=t,this.handler=i,this.strictMode=n,this.protocolHandler=new gp}setProtocolVersion(t){this.protocolHandler.protocolVersion!==t&&(this.protocolHandler=Z5(t))}getProtocolVersion(){return this.protocolHandler.protocolVersion}getErrorCount(){return this.errorCount}parseMessage(){for(;this.stream.hasBytes(1);){let t=this.stream.getReadPosition(),i=-1;try{if(i=this.stream.readByte(),i===-1)break;let n=i,r=this.protocolHandler.translateCommand(i);switch(r){case I.bad:if(n===0)return;let a=`Unknown server command: ${n} (translated: ${r}) at offset ${t} (Protocol: ${this.getProtocolVersion()})`;if(this.strictMode)throw new Error(a);console.warn(a),this.errorCount++;return;case I.nop:break;case I.disconnect:this.handler?.onDisconnect&&this.handler.onDisconnect();break;case I.reconnect:this.handler?.onReconnect&&this.handler.onReconnect();break;case I.print:this.parsePrint();break;case I.serverdata:this.parseServerData();break;case I.configstring:this.parseConfigString();break;case I.spawnbaseline:this.parseSpawnBaseline();break;case I.centerprint:this.parseCenterPrint();break;case I.download:this.parseDownload();break;case I.frame:this.parseFrame();break;case I.packetentities:this.parsePacketEntities(!1);break;case I.deltapacketentities:this.parsePacketEntities(!0);break;case I.playerinfo:this.parsePlayerState();break;case I.stufftext:this.parseStuffText();break;case I.layout:this.parseLayout();break;case I.inventory:this.parseInventory();break;case I.sound:this.parseSound();break;case I.muzzleflash:this.parseMuzzleFlash();break;case I.muzzleflash2:this.parseMuzzleFlash2();break;case I.temp_entity:this.parseTempEntity();break;case I.splitclient:this.parseSplitClient();break;case I.configblast:this.parseConfigBlast();break;case I.spawnbaselineblast:this.parseSpawnBaselineBlast();break;case I.level_restart:this.handler?.onLevelRestart&&this.handler.onLevelRestart();break;case I.damage:this.parseDamage();break;case I.locprint:this.parseLocPrint();break;case I.fog:this.parseFog();break;case I.waitingforplayers:this.parseWaitingForPlayers();break;case I.bot_chat:this.parseBotChat();break;case I.poi:this.parsePoi();break;case I.help_path:this.parseHelpPath();break;case I.muzzleflash3:this.parseMuzzleFlash3();break;case I.achievement:this.parseAchievement();break;default:let s=`Unknown server command: ${n} (translated: ${r}) at offset ${t}`;if(this.strictMode)throw new Error(s);console.warn(s),this.errorCount++;return}}catch(n){let r=n.message;if(r==="Buffer underflow"||r.includes("StreamingBuffer")){try{this.stream.setReadPosition(t)}catch(s){console.error("Failed to rollback stream position",s)}return}let a=`offset ${t}, cmd ${i}, protocol ${this.getProtocolVersion()}`;if(console.warn(`Error parsing command ${i} (${a}): ${r}`),this.errorCount++,this.strictMode)throw n;return}}}readAngle16(){return this.stream.readShort()*(360/65536)}readCoord(){return this.stream.readShort()*.125}readAngle(){return this.stream.readByte()*(360/256)}readPos(t){t.x=this.stream.readShort()*.125,t.y=this.stream.readShort()*.125,t.z=this.stream.readShort()*.125}readDir(t){let i=this.stream.readByte();if(i>=$i.length)t.x=0,t.y=0,t.z=0;else{let n=$i[i];t.x=n[0],t.y=n[1],t.z=n[2]}}parsePrint(){let t=this.stream.readByte(),i=this.stream.readString();this.handler&&this.handler.onPrint(t,i)}parseStuffText(){let t=this.stream.readString();this.handler&&this.handler.onStuffText(t)}parseLayout(){let t=this.stream.readString();this.handler&&this.handler.onLayout(t)}parseCenterPrint(){let t=this.stream.readString();this.handler&&this.handler.onCenterPrint(t)}parseServerData(){let t=this.protocolHandler.parseServerData(this.stream);this.setProtocolVersion(t.protocol),this.handler&&this.handler.onServerData(t.protocol,t.serverCount,t.attractLoop,t.gameDir,t.playerNum,t.levelName,t.tickRate,t.demoType),t.protocol===sa?this.isDemo=t.demoType??w_:this.isDemo=t.attractLoop}parseConfigString(){let t=this.stream.readShort(),i=this.stream.readString();this.handler&&this.handler.onConfigString(t,i)}parseSplitClient(){let t=this.stream.readByte();this.handler?.onSplitClient&&this.handler.onSplitClient(t)}parseConfigBlast(){let t=this.stream.readShort();this.stream.readShort();let i=this.stream.readData(t);try{let n=v_.inflate(i),r=new nr(n.buffer);for(;r.hasMore();){let a=r.readUShort(),s=r.readString();this.handler&&this.handler.onConfigString(a,s)}}catch(n){console.error("svc_configblast error",n)}}parseSpawnBaselineBlast(){let t=this.stream.readShort();this.stream.readShort();let i=this.stream.readData(t);try{let n=v_.inflate(i),r=new nr(n.buffer),a=new _p(r,this.handler,this.strictMode);for(a.setProtocolVersion(this.getProtocolVersion());r.hasMore();)a.parseSpawnBaseline()}catch(n){console.error("svc_spawnbaselineblast error",n)}}parseLocPrint(){let t=this.stream.readByte(),i=this.stream.readString(),n=this.stream.readByte(),r=[];for(let a=0;a<n;a++)r.push(this.stream.readString());this.handler?.onLocPrint&&this.handler.onLocPrint(t,i,r)}parseWaitingForPlayers(){let t=this.stream.readByte();this.handler?.onWaitingForPlayers&&this.handler.onWaitingForPlayers(t)}parseBotChat(){this.stream.readString(),this.stream.readShort();let t=this.stream.readString();this.handler?.onBotChat&&this.handler.onBotChat(t)}parsePoi(){this.stream.readShort(),this.stream.readShort();let t={x:0,y:0,z:0};this.readPos(t),this.stream.readShort(),this.stream.readByte();let i=this.stream.readByte();this.handler?.onPoi&&this.handler.onPoi(i,t)}parseHelpPath(){this.stream.readByte();let t={x:0,y:0,z:0};this.readPos(t);let i={x:0,y:0,z:0};this.readDir(i),this.handler?.onHelpPath&&this.handler.onHelpPath(t)}parseAchievement(){let t=this.stream.readString();this.handler?.onAchievement&&this.handler.onAchievement(t)}parseDownload(){let t=this.stream.readShort(),i=this.stream.readByte(),n;t>0&&(n=this.stream.readData(t)),this.handler&&this.handler.onDownload(t,i,n)}parseInventory(){let i=new Array(256);for(let n=0;n<256;n++)i[n]=this.stream.readShort();this.handler&&this.handler.onInventory(i)}parseSound(){let t=this.stream.readByte(),i=this.stream.readByte(),n,r,a,s,o;if(t&1&&(n=this.stream.readByte()),t&2&&(r=this.stream.readByte()),t&16&&(a=this.stream.readByte()),t&8&&(s=this.stream.readShort()),t&4){let c={x:0,y:0,z:0};this.readPos(c),o=c}this.handler&&this.handler.onSound(t,i,n,r,a,s,o)}parseMuzzleFlash(){let t=this.stream.readShort(),i=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash(t,i)}parseMuzzleFlash2(){let t=this.stream.readShort(),i=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash2(t,i)}parseMuzzleFlash3(){let t=this.stream.readShort(),i=this.stream.readShort();this.handler?.onMuzzleFlash3&&this.handler.onMuzzleFlash3(t,i)}parseFog(){let t=this.stream.readByte();if(t&128){let n=this.stream.readByte();t|=n<<8}let i={};t&1&&(i.density=this.stream.readFloat(),i.skyfactor=this.stream.readByte()),t&2&&(i.red=this.stream.readByte()),t&4&&(i.green=this.stream.readByte()),t&8&&(i.blue=this.stream.readByte()),t&16&&(i.time=this.stream.readShort()),t&32&&(i.hf_falloff=this.stream.readFloat()),t&64&&(i.hf_density=this.stream.readFloat()),t&256&&(i.hf_start_r=this.stream.readByte()),t&512&&(i.hf_start_g=this.stream.readByte()),t&1024&&(i.hf_start_b=this.stream.readByte()),t&2048&&(i.hf_start_dist=this.stream.readLong()),t&4096&&(i.hf_end_r=this.stream.readByte()),t&8192&&(i.hf_end_g=this.stream.readByte()),t&16384&&(i.hf_end_b=this.stream.readByte()),t&32768&&(i.hf_end_dist=this.stream.readLong()),this.handler?.onFog&&this.handler.onFog(i)}parseDamage(){let t=this.stream.readByte(),i=[];for(let n=0;n<t;n++){let r=this.stream.readByte(),a={x:0,y:0,z:0};this.readDir(a);let s=r&31,o=(r&32)!==0,c=(r&64)!==0,d=(r&128)!==0;i.push({damage:s,health:o,armor:c,power:d,dir:a})}this.handler?.onDamage&&this.handler.onDamage(i)}parseTempEntity(){let t=this.stream.readByte(),i={x:0,y:0,z:0},n={x:0,y:0,z:0},r={x:0,y:0,z:0},a,s,o,c,d;switch(t){case N.EXPLOSION1:case N.EXPLOSION2:case N.ROCKET_EXPLOSION:case N.GRENADE_EXPLOSION:case N.ROCKET_EXPLOSION_WATER:case N.GRENADE_EXPLOSION_WATER:case N.BFG_EXPLOSION:case N.BFG_BIGEXPLOSION:case N.BOSSTPORT:case N.PLASMA_EXPLOSION:case N.PLAIN_EXPLOSION:case N.CHAINFIST_SMOKE:case N.TRACKER_EXPLOSION:case N.TELEPORT_EFFECT:case N.DBALL_GOAL:case N.NUKEBLAST:case N.WIDOWSPLASH:case N.EXPLOSION1_BIG:case N.EXPLOSION1_NP:this.readPos(i);break;case N.GUNSHOT:case N.BLOOD:case N.BLASTER:case N.SHOTGUN:case N.SPARKS:case N.BULLET_SPARKS:case N.SCREEN_SPARKS:case N.SHIELD_SPARKS:case N.BLASTER2:case N.FLECHETTE:case N.MOREBLOOD:case N.ELECTRIC_SPARKS:case N.HEATBEAM_SPARKS:case N.HEATBEAM_STEAM:this.readPos(i),this.readDir(r);break;case N.SPLASH:case N.LASER_SPARKS:case N.WELDING_SPARKS:case N.TUNNEL_SPARKS:a=this.stream.readByte(),this.readPos(i),this.readDir(r),s=this.stream.readByte();break;case N.BLUEHYPERBLASTER:this.getProtocolVersion()>=32?(this.readPos(i),this.readPos(n)):(this.readPos(i),this.readDir(r));break;case N.GREENBLOOD:this.getProtocolVersion()>=32?(this.readPos(i),this.readDir(r)):(this.readPos(i),this.readPos(n));break;case N.RAILTRAIL:case N.BUBBLETRAIL:case N.BFG_LASER:case N.DEBUGTRAIL:case N.BUBBLETRAIL2:this.readPos(i),this.readPos(n);break;case N.PARASITE_ATTACK:case N.MEDIC_CABLE_ATTACK:this.stream.readShort(),this.readPos(i),this.readPos(n);break;case N.GRAPPLE_CABLE:o=this.stream.readShort(),this.readPos(i),this.readPos(n),this.readPos(r);break;case N.LIGHTNING:c=this.stream.readShort(),d=this.stream.readShort(),this.readPos(i),this.readPos(n);break;case N.FLASHLIGHT:this.readPos(i),o=this.stream.readShort();break;case N.FORCEWALL:this.readPos(i),this.readPos(n),s=this.stream.readByte();break;case N.STEAM:let l=this.stream.readShort();a=this.stream.readByte(),this.readPos(i),this.readDir(r),s=this.stream.readByte(),this.stream.readShort(),l!==-1&&this.stream.readLong();break;case N.WIDOWBEAMOUT:this.stream.readShort();case N.HEATBEAM:case N.MONSTER_HEATBEAM:o=this.stream.readShort(),this.readPos(i),this.readPos(n),this.readDir(r);break}this.handler&&this.handler.onTempEntity(t,i,n,r,a,s,o,c,d)}parseSpawnBaseline(){let t=this.protocolHandler.parseEntityBits(this.stream),i=Ln();this.protocolHandler.parseDelta(Ln(),i,t.number,t.bits,t.bitsHigh,this.stream),this.handler&&this.handler.onSpawnBaseline(i)}parseFrame(){let t=this.stream.readLong(),i=this.stream.readLong(),n=0;this.getProtocolVersion()!==26&&this.getProtocolVersion()!==25&&(n=this.stream.readByte());let r=this.stream.readByte(),a=this.stream.readData(r),s=this.stream.readByte();if(s=this.protocolHandler.translateCommand(s),s!==I.playerinfo){if(this.strictMode)throw new Error(`Expected svc_playerinfo after svc_frame, got ${s}`);return}let o=this.parsePlayerState(),c=this.stream.readByte();if(c=this.protocolHandler.translateCommand(c),c!==I.packetentities&&c!==I.deltapacketentities){if(this.strictMode)throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${c}`);return}let d=this.collectPacketEntities();if(this.isDemo===J5){let l=this.stream.readByte();for(let m=0;m<l;m++)this.stream.readByte()}this.isDemo===q5&&this.stream.readLong(),this.handler&&this.handler.onFrame({serverFrame:t,deltaFrame:i,surpressCount:n,areaBytes:r,areaBits:a,playerState:o,packetEntities:{delta:!0,entities:d}})}parsePlayerState(){return this.protocolHandler.parsePlayerState(this.stream)}parsePacketEntities(t){let i=this.collectPacketEntities();this.handler&&this.handler.onFrame({serverFrame:0,deltaFrame:0,surpressCount:0,areaBytes:0,areaBits:new Uint8Array,playerState:Jo(),packetEntities:{delta:t,entities:i}})}collectPacketEntities(){let t=[];for(;;){let i=this.protocolHandler.parseEntityBits(this.stream);if(i.bits&ns){if(i.number===0)break;continue}let n=Ln();if(i.number===0)break;this.protocolHandler.parseDelta(Ln(),n,i.number,i.bits,i.bitsHigh,this.stream),t.push(n)}return t}};var ez=class{constructor(e){this.events=[],this.summary={totalKills:0,totalDeaths:0,damageDealt:0,damageReceived:0,weaponUsage:new Map},this.header=null,this.configStrings=new Map,this.serverInfo={},this.statistics=null,this.playerStats=new Map,this.weaponStats=new Map,this.activeEntities=new Set,this.buffer=e}analyze(){let e=new L_(this.buffer),t=-1,i=0,n=.1,r=0,a={onServerData:(s,o,c,d,l,m,u,f)=>{r=s,this.header={protocolVersion:s,gameDir:d,levelName:m,playerNum:l,serverCount:o,spawnCount:o,tickRate:u,demoType:f},u&&u>0&&(n=1/u)},onConfigString:(s,o)=>{this.configStrings.set(s,o),s===0&&this.parseServerInfo(o)},onSpawnBaseline:s=>{},onFrame:s=>{let o=new Set;if(s.packetEntities&&s.packetEntities.entities)for(let c of s.packetEntities.entities)o.add(c.number),this.activeEntities.has(c.number)||this.recordEvent({type:"spawn",frame:t,time:i,entityId:c.number,position:{x:c.origin.x,y:c.origin.y,z:c.origin.z},description:`Entity ${c.number} spawned`});this.activeEntities=o,s.playerState&&this.header},onPrint:(s,o)=>{let c=o.replace(/\n/g," ").trim();c.includes("died")||c.includes("killed")||c.includes("suicide")?(this.summary.totalDeaths++,this.recordEvent({type:"death",frame:t,time:i,description:c})):c.startsWith("You got the ")?this.recordEvent({type:"pickup",frame:t,time:i,description:c}):(s===3||s===2)&&this.recordEvent({type:"chat",frame:t,time:i,description:c,data:{level:s}})},onCenterPrint:s=>{this.recordEvent({type:"objective",frame:t,time:i,description:s.trim()})},onStuffText:()=>{},onSound:()=>{},onTempEntity:()=>{},onLayout:()=>{},onInventory:()=>{},onMuzzleFlash:(s,o)=>{this.handleWeaponFire(s,o,t,i)},onMuzzleFlash2:(s,o)=>{this.handleWeaponFire(s,o,t,i)},onMuzzleFlash3:(s,o)=>{this.handleWeaponFire(s,o,t,i)},onDisconnect:()=>{},onReconnect:()=>{},onDownload:()=>{},onDamage:s=>{for(let o of s)if(this.recordEvent({type:"damage_received",frame:t,time:i,value:o.damage,position:o.dir,description:`Took ${o.damage} damage`}),this.summary.damageReceived+=o.damage,this.header){let c=this.getOrCreatePlayerStats(this.header.playerNum);c.damageReceived+=o.damage}}};for(;e.hasMore();){let s=e.readNextBlock();if(!s)break;t++,i=t*n;let o=new Qo(s.data,a);o.setProtocolVersion(r),o.parseMessage(),r=o.getProtocolVersion()}return this.statistics={duration:i,frameCount:t+1,averageFps:(t+1)/(i||1),mapName:this.header?.levelName||"unknown",playerCount:1},{events:this.events,summary:this.summary,header:this.header,configStrings:this.configStrings,serverInfo:this.serverInfo,statistics:this.statistics,playerStats:this.playerStats,weaponStats:this.weaponStats}}handleWeaponFire(e,t,i,n){this.recordEvent({type:"weapon_fire",frame:i,time:n,entityId:e,value:t,description:`Weapon ${t} fired by ${e}`});let r=this.summary.weaponUsage.get(t)||0;this.summary.weaponUsage.set(t,r+1);let a=this.getOrCreateWeaponStat(e,t);a.shotsFired++}recordEvent(e){this.events.push(e)}parseServerInfo(e){let t=e.split("\\");for(let i=1;i<t.length;i+=2)i+1<t.length&&(this.serverInfo[t[i]]=t[i+1])}getOrCreatePlayerStats(e){let t=this.playerStats.get(e);return t||(t={kills:0,deaths:0,damageDealt:0,damageReceived:0,suicides:0},this.playerStats.set(e,t)),t}getOrCreateWeaponStat(e,t){let i=this.weaponStats.get(e);i||(i=[],this.weaponStats.set(e,i));let n=i.find(r=>r.weaponId===t);return n||(n={weaponId:t,shotsFired:0,hits:0,kills:0},i.push(n)),n}};var As=(e=>(e[e.Stopped=0]="Stopped",e[e.Playing=1]="Playing",e[e.Paused=2]="Paused",e[e.Finished=3]="Finished",e))(As||{}),tz=()=>({onServerData:()=>{},onConfigString:()=>{},onSpawnBaseline:()=>{},onFrame:()=>{},onCenterPrint:()=>{},onStuffText:()=>{},onPrint:()=>{},onSound:()=>{},onTempEntity:()=>{},onLayout:()=>{},onInventory:()=>{},onMuzzleFlash:()=>{},onMuzzleFlash2:()=>{},onDisconnect:()=>{},onReconnect:()=>{},onDownload:()=>{}}),pp=class{constructor(){this.reader=null,this.buffer=null,this.state=0,this.playbackSpeed=1,this.currentProtocolVersion=0,this.currentFrameIndex=-1,this.lastFrameData=null,this.accumulatedTime=0,this.frameDuration=100,this.snapshotInterval=100,this.snapshots=new Map,this.cachedEvents=null,this.cachedSummary=null,this.cachedHeader=null,this.cachedConfigStrings=null,this.cachedServerInfo=null,this.cachedStatistics=null,this.cachedPlayerStats=null,this.cachedWeaponStats=null,this.tracker=null,this.cameraMode=0,this.thirdPersonDistance=80,this.thirdPersonOffset={x:0,y:0,z:0}}setHandler(e){this.handler=e}setCallbacks(e){this.callbacks=e}loadDemo(e){this.buffer=e,this.reader=new L_(e),this.transitionState(0),this.accumulatedTime=0,this.currentProtocolVersion=0,this.currentFrameIndex=-1,this.snapshots.clear(),this.lastFrameData=null,this.cachedEvents=null,this.cachedSummary=null,this.cachedHeader=null,this.cachedConfigStrings=null,this.cachedServerInfo=null,this.cachedStatistics=null,this.cachedPlayerStats=null,this.cachedWeaponStats=null}play(){this.reader&&this.state!==1&&this.transitionState(1)}pause(){this.state===1&&this.transitionState(2)}stop(){this.transitionState(0),this.reader&&this.reader.reset(),this.accumulatedTime=0,this.currentProtocolVersion=0,this.currentFrameIndex=-1,this.lastFrameData=null}transitionState(e){this.state!==e&&(this.state=e,this.callbacks?.onPlaybackStateChange&&this.callbacks.onPlaybackStateChange(e))}setFrameDuration(e){this.frameDuration=e}setSpeed(e){this.playbackSpeed=Math.max(.1,Math.min(e,16))}getSpeed(){return this.playbackSpeed}getPlaybackSpeed(){return this.playbackSpeed}getInterpolationFactor(){return this.frameDuration<=0?0:Math.max(0,Math.min(1,this.accumulatedTime/this.frameDuration))}update(e){if(!(this.state!==1||!this.reader))for(this.accumulatedTime+=e*1e3*this.playbackSpeed;this.accumulatedTime>=this.frameDuration;){if(!this.processNextFrame())return;this.accumulatedTime-=this.frameDuration,this.callbacks?.onTimeUpdate&&this.callbacks.onTimeUpdate(this.getCurrentTime())}}stepForward(){this.reader&&(this.processNextFrame(),this.callbacks?.onTimeUpdate&&this.callbacks.onTimeUpdate(this.getCurrentTime()))}stepBackward(){this.reader&&this.currentFrameIndex>0&&this.seek(this.currentFrameIndex-1)}seekToTime(e){let t=this.timeToFrame(e);this.seek(t)}seekToFrame(e){this.seek(e)}frameToTime(e){return e*this.frameDuration/1e3}timeToFrame(e){return Math.floor(e*1e3/this.frameDuration)}playFrom(e){if(e.type==="frame")this.seek(e.frame);else if(e.type==="time")this.seekToTime(e.seconds);else throw new Error(`Invalid offset type: ${e.type}`);this.play()}playRange(e,t){let i=e.type==="frame"?e.frame:this.timeToFrame(e.seconds),n=t.type==="frame"?t.frame:this.timeToFrame(t.seconds);if(this.getTotalFrames(),i<0)throw new Error(`Invalid start offset: ${i}`);if(n<i)throw new Error(`End offset (${n}) cannot be before start offset (${i})`);this.playFrom(e);let r=this.callbacks?.onFrameUpdate,a={...this.callbacks,onFrameUpdate:s=>{if(r&&r(s),this.currentFrameIndex>=n){this.pause();let o=this.callbacks?.onPlaybackComplete;this.callbacks===a&&this.setCallbacks({...this.callbacks,onFrameUpdate:r}),o&&o()}}};this.setCallbacks(a)}seek(e){if(!this.reader)return;let t=this.getTotalFrames();if(t>0&&e>=t&&(e=t-1),e<0&&(e=0),e===this.currentFrameIndex+1){this.processNextFrame(),this.callbacks?.onSeekComplete&&this.callbacks.onSeekComplete();return}if(e===this.currentFrameIndex){this.callbacks?.onSeekComplete&&this.callbacks.onSeekComplete();return}let i=-1,n=null;if(e>this.currentFrameIndex&&this.currentFrameIndex!==-1&&(i=this.currentFrameIndex),this.callbacks?.onRestoreSnapshot)for(let[r,a]of this.snapshots)r<=e&&r>i&&(i=r,n=a);for(i===-1&&this.currentFrameIndex>e?(this.reader.reset(),this.currentFrameIndex=-1,this.currentProtocolVersion=0):i===-1&&(this.reader.reset(),this.currentFrameIndex=-1,this.currentProtocolVersion=0),n&&this.callbacks?.onRestoreSnapshot&&(this.callbacks.onRestoreSnapshot(n),this.reader.seekToMessage(i+1)?this.currentFrameIndex=i:(this.reader.reset(),this.currentFrameIndex=-1,this.currentProtocolVersion=0));this.currentFrameIndex<e&&(this.callbacks?.onCaptureSnapshot&&(this.currentFrameIndex+1)%this.snapshotInterval,!!this.processNextFrame()););this.accumulatedTime=0,this.callbacks?.onSeekComplete&&this.callbacks.onSeekComplete(),this.callbacks?.onTimeUpdate&&this.callbacks.onTimeUpdate(this.getCurrentTime())}processNextFrame(){if(!this.reader||!this.reader.hasMore())return this.transitionState(3),this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),!1;let e=this.reader.readNextBlock();if(!e)return this.transitionState(3),this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),!1;this.currentFrameIndex++,this.tracker&&(this.tracker.setCurrentFrame(this.currentFrameIndex),this.tracker.setCurrentTime(this.getCurrentTime()));try{let t={...this.handler||tz(),onFrame:n=>{this.lastFrameData=n,this.handler?.onFrame&&this.handler.onFrame(n),this.callbacks?.onFrameUpdate&&this.callbacks.onFrameUpdate(n)}},i=new Qo(e.data,t);if(i.setProtocolVersion(this.currentProtocolVersion),i.parseMessage(),this.currentProtocolVersion=i.getProtocolVersion(),this.callbacks?.onCaptureSnapshot&&this.currentFrameIndex%this.snapshotInterval===0&&this.currentFrameIndex>0){let n=this.callbacks.onCaptureSnapshot(this.currentFrameIndex);n&&this.snapshots.set(this.currentFrameIndex,n)}}catch(t){return console.error("Error processing demo frame",t),this.callbacks?.onPlaybackError&&this.callbacks.onPlaybackError(t instanceof Error?t:new Error(String(t))),!1}return!0}getState(){return this.state}getCurrentTime(){return this.currentFrameIndex<0?this.accumulatedTime/1e3:(this.currentFrameIndex*this.frameDuration+this.accumulatedTime)/1e3}getFrameCount(){return this.reader?this.reader.getMessageCount():0}getTotalFrames(){return this.getFrameCount()}getCurrentFrame(){return this.currentFrameIndex<0?0:this.currentFrameIndex}getDuration(){return this.getFrameCount()*this.frameDuration/1e3}getTotalBytes(){return this.reader?this.reader.getProgress().total:0}getProcessedBytes(){return this.reader?this.reader.getOffset():0}getFrameData(e){if(e===this.currentFrameIndex&&this.lastFrameData)return this.lastFrameData;let t=this.state;return this.pause(),this.seek(e),t===1&&this.play(),this.lastFrameData}getFramePlayerState(e){if(e===this.currentFrameIndex&&this.handler?.getPlayerState){let i=this.handler.getPlayerState();if(i)return i}let t=this.getFrameData(e);return t?t.playerState:null}getFrameEntities(e){if(e===this.currentFrameIndex&&this.handler?.getEntities){let t=this.handler.getEntities();if(t)return Array.from(t.values())}if(this.seek(e),this.handler?.getEntities){let t=this.handler.getEntities();return t?Array.from(t.values()):[]}return[]}compareFrames(e,t){let i=this.getFramePlayerState(e),n=this.getFrameEntities(e),r=new Map;n.forEach(d=>r.set(d.number,d));let a=this.getFramePlayerState(t),s=this.getFrameEntities(t),o=new Map;s.forEach(d=>o.set(d.number,d));let c={frameA:e,frameB:t,playerStateDiff:{origin:null,viewangles:null,health:null,ammo:null},entityDiffs:{added:[],removed:[],moved:[]}};i&&a&&((i.origin.x!==a.origin.x||i.origin.y!==a.origin.y||i.origin.z!==a.origin.z)&&(c.playerStateDiff.origin={x:a.origin.x-i.origin.x,y:a.origin.y-i.origin.y,z:a.origin.z-i.origin.z}),i.stats[1]!==a.stats[1]&&(c.playerStateDiff.health=a.stats[1]-i.stats[1]),i.stats[2]!==a.stats[2]&&(c.playerStateDiff.ammo=a.stats[2]-i.stats[2]));for(let[d,l]of o){let m=r.get(d);m?(m.origin.x!==l.origin.x||m.origin.y!==l.origin.y||m.origin.z!==l.origin.z)&&c.entityDiffs.moved.push({id:d,delta:{x:l.origin.x-m.origin.x,y:l.origin.y-m.origin.y,z:l.origin.z-m.origin.z}}):c.entityDiffs.added.push(d)}for(let[d,l]of r)o.has(d)||c.entityDiffs.removed.push(d);return c}getEntityTrajectory(e,t,i){let n=[],r=this.getCurrentFrame();for(this.seek(t);this.getCurrentFrame()<=i&&this.state!==3;){let a=null;if(e===-1){let s=this.getFramePlayerState(this.getCurrentFrame());s&&(a={...s.origin})}else if(this.handler?.getEntities){let s=this.handler.getEntities().get(e);s&&(a={...s.origin})}if(a&&n.push(a),this.getCurrentFrame()===i)break;this.stepForward()}return this.seek(r),n}getEvents(){return this.ensureAnalysis(),this.cachedEvents||[]}getDemoEvents(){return this.getEvents()}filterEvents(e,t){return this.getDemoEvents().filter(n=>!(n.type!==e||t!==void 0&&n.entityId!==t))}getEventSummary(){return this.ensureAnalysis(),this.cachedSummary||{totalKills:0,totalDeaths:0,damageDealt:0,damageReceived:0,weaponUsage:new Map}}getMetadata(){let e=this.getDemoHeader();if(!e)return null;let t=this.getDemoServerInfo(),i="Unknown";return this.cachedConfigStrings,{mapName:e.levelName,playerName:i,serverName:t.hostname,demoVersion:e.protocolVersion,tickRate:e.tickRate||10}}getDemoHeader(){return this.ensureAnalysis(),this.cachedHeader}getDemoConfigStrings(){return this.ensureAnalysis(),this.cachedConfigStrings||new Map}getDemoServerInfo(){return this.ensureAnalysis(),this.cachedServerInfo||{}}getDemoStatistics(){return this.ensureAnalysis(),this.cachedStatistics}getPlayerStatistics(e){return this.ensureAnalysis(),this.cachedPlayerStats?.get(e)||null}getWeaponStatistics(e){return this.ensureAnalysis(),this.cachedWeaponStats?.get(e)||null}ensureAnalysis(){if(!this.cachedEvents&&this.buffer){let t=new ez(this.buffer).analyze();this.cachedEvents=t.events,this.cachedSummary=t.summary,this.cachedHeader=t.header,this.cachedConfigStrings=t.configStrings,this.cachedServerInfo=t.serverInfo,this.cachedStatistics=t.statistics,this.cachedPlayerStats=t.playerStats,this.cachedWeaponStats=t.weaponStats}}setCameraMode(e){this.cameraMode=e}getCameraMode(){return this.cameraMode}setThirdPersonDistance(e){this.thirdPersonDistance=e}setThirdPersonOffset(e){this.thirdPersonOffset=e}async playWithTracking(e,t={}){if(this.tracker=e,e.startTracking(),t.fastForward)try{this.state===0&&this.reader,this.transitionState(1);let i=100,n=async()=>{if(this.state!==1)throw new Error("Playback stopped unexpectedly during fast forward");let r=0;for(;r<i;){if(!this.processNextFrame()){this.transitionState(0);let a=e.stopTracking();return this.tracker=null,this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),a}r++}return await new Promise(a=>setTimeout(a,0)),n()};return await n()}catch(i){throw this.transitionState(0),e.stopTracking(),this.tracker=null,i}else return new Promise((i,n)=>{let r=this.callbacks?.onPlaybackComplete,a=this.callbacks?.onPlaybackError,s=()=>{this.setCallbacks({...this.callbacks,onPlaybackComplete:r,onPlaybackError:a}),this.tracker=null};this.setCallbacks({...this.callbacks,onPlaybackComplete:()=>{let o=e.stopTracking();r&&r(),s(),i(o)},onPlaybackError:o=>{e.stopTracking(),a&&a(o),s(),n(o)}}),this.play()})}async playRangeWithTracking(e,t,i,n={}){this.tracker=i,i.startTracking(),e.type==="frame"?e.frame:this.timeToFrame(e.seconds);let r=t.type==="frame"?t.frame:this.timeToFrame(t.seconds);if(n.fastForward)try{this.playFrom(e),this.transitionState(1);let a=100,s=async()=>{if(this.state!==1)throw new Error("Playback stopped unexpectedly during fast forward");let o=0;for(;o<a;){if(this.currentFrameIndex>=r||!this.processNextFrame()){this.transitionState(0);let c=i.stopTracking();return this.tracker=null,this.callbacks?.onPlaybackComplete&&this.callbacks.onPlaybackComplete(),c}o++}return await new Promise(c=>setTimeout(c,0)),s()};return await s()}catch(a){throw this.transitionState(0),i.stopTracking(),this.tracker=null,a}else return new Promise((a,s)=>{let o=this.callbacks?.onPlaybackComplete,c=this.callbacks?.onPlaybackError,d=()=>{this.setCallbacks({...this.callbacks,onPlaybackComplete:o,onPlaybackError:c}),this.tracker=null};this.setCallbacks({...this.callbacks,onPlaybackComplete:()=>{let l=i.stopTracking();o&&o(),d(),a(l)},onPlaybackError:l=>{i.stopTracking(),c&&c(l),d(),s(l)}}),this.playRange(e,t)})}},vp=class{constructor(){this.isRecording=!1,this.startTime=0,this.frameCount=0,this.filename=null,this.lastMessageSize=-1,this.messageBuffer=new Zr(1024*1024)}startRecording(e,t=0){this.isRecording||(this.isRecording=!0,this.filename=e,this.startTime=t,this.frameCount=0,this.messageBuffer.reset(),console.log(`DemoRecorder: Started recording to ${e}`))}recordMessage(e){if(this.isRecording){this.messageBuffer.writeLong(e.byteLength);for(let t=0;t<e.length;t++)this.messageBuffer.writeByte(e[t]);this.frameCount++}}stopRecording(){return this.isRecording?(this.isRecording=!1,this.messageBuffer.writeLong(-1),console.log(`DemoRecorder: Stopped recording. Frames: ${this.frameCount}, Size: ${this.messageBuffer.getOffset()} bytes`),this.messageBuffer.getData()):null}getIsRecording(){return this.isRecording}};var yp=class{static validate(e,t){if(t&&!t.toLowerCase().endsWith(".dm2"))return{valid:!1,error:"Invalid file extension (expected .dm2)"};if(e.byteLength<5)return{valid:!1,error:"File too small to be a valid demo"};let i=new DataView(e),n=i.getInt32(0,!0);if(n<=0||n>e.byteLength-4)return{valid:!1,error:`Invalid first block length: ${n}`};let r=i.getUint8(4);if(r!==I.serverdata)return{valid:!1,error:`First command is not svc_serverdata (expected ${I.serverdata}, got ${r})`};let a=-1;return n>=5&&(a=i.getInt32(5,!0)),{valid:!0,version:a}}};function ec(e,t){let i=t.bits;e.bits=i,e.number=t.number,i&Hr&&(e.modelindex=t.modelindex),i&Wr&&(e.modelindex2=t.modelindex2),i&$r&&(e.modelindex3=t.modelindex3),i&Kr&&(e.modelindex4=t.modelindex4),i&Dr&&(e.frame=t.frame),i&Vr&&(e.frame=t.frame),i&Ji&&(e.skinnum=t.skinnum),i&tn&&(e.skinnum=t.skinnum),i&qi&&(e.effects=t.effects),i&en&&(e.effects=t.effects),i&Zi&&(e.renderfx=t.renderfx),i&Qi&&(e.renderfx=t.renderfx),i&Nr&&(e.origin.x=t.origin.x),i&Pr&&(e.origin.y=t.origin.y),i&Ur&&(e.origin.z=t.origin.z),i&Gr&&(e.angles.x=t.angles.x),i&Or&&(e.angles.y=t.angles.y),i&Fr&&(e.angles.z=t.angles.z),i&Xr&&(e.old_origin.x=t.old_origin.x,e.old_origin.y=t.old_origin.y,e.old_origin.z=t.old_origin.z),i&jr&&(e.sound=t.sound),i&Br&&(e.event=t.event),i&Yr&&(e.solid=t.solid),i&Co&&(e.alpha=t.alpha),i&No&&(e.scale=t.scale),i&Po&&(e.instanceBits=t.instanceBits),i&Oo&&(e.loopVolume=t.loopVolume)}var ic=null,tc=[1,1,1,1],wp=["ch1","ch2","ch3"],Um=[null,null,null],iz=e=>{for(let t=0;t<wp.length;t++){let i=wp[t];try{Um[t]=e.Draw_RegisterPic(`pics/${i}.pcx`)}catch{if(t===0)try{Um[t]=e.Draw_RegisterPic("pics/crosshair.pcx")}catch{e.Com_Print(`Failed to load crosshair image
|
|
204
204
|
`)}}}ic=Um[0]},nz=(e,t,i)=>{if(ic){let n=e.Draw_GetPicSize(ic),r=(t-n.width)/2,a=(i-n.height)/2;e.SCR_DrawColorPic(r,a,ic,{x:tc[0],y:tc[1],z:tc[2]},tc[3])}},Ap=new Map,rz=["w_blaster","w_shotgun","w_sshotgun","w_machinegun","w_chaingun","w_glauncher","w_rlauncher","w_hyperblaster","w_railgun","w_bfg","w_grapple","a_grenades","a_bullets","a_cells","a_rockets","a_shells","a_slugs","p_quad","p_invulnerability","p_silencer","p_rebreather","p_envirosuit","p_adrenaline","p_megahealth","i_jacketarmor","i_combatarmor","i_bodyarmor","i_powerscreen","i_powershield","k_datacd","k_powercube","k_pyramid","k_dataspin","k_security","k_bluekey","k_redkey"],az=e=>{for(let t of rz)try{let i=e.Draw_RegisterPic(`pics/${t}.pcx`);Ap.set(t,i)}catch{e.Com_Print(`Failed to load HUD image: pics/${t}.pcx
|
|
205
205
|
`)}},Ep=new Map,sz=["d_left","d_right","d_up","d_down"],oz=e=>{for(let t of sz)try{let i=e.Draw_RegisterPic(`pics/${t}.pcx`);Ep.set(t,i)}catch{e.Com_Print(`Failed to load HUD image: pics/${t}.pcx
|
|
206
206
|
`)}},cz={x:1,y:1,z:1},dz=(e,t,i,n)=>{if((!t.damageAlpha||t.damageAlpha<=0)&&(!t.damageIndicators||t.damageIndicators.length===0)||!t.damageIndicators||t.damageIndicators.length===0)return;let r=i*.5,a=n*.5,{forward:s,right:o}=G(t.viewAngles),c=Math.min(i,n)*.25;for(let d of t.damageIndicators){let l=Ne(d.direction,o),m=Ne(d.direction,s),u=Math.atan2(m,l)*(180/Math.PI),f="",h=0,y=0;u>=45&&u<135?(f="d_up",y=-c):u>=-45&&u<45?(f="d_right",h=c):u>=-135&&u<-45?(f="d_down",y=c):(f="d_left",h=-c);let p=Ep.get(f);if(p){let v=e.Draw_GetPicSize(p),A=r+h-v.width*.5,x=a+y-v.height*.5,w=Math.max(0,Math.min(1,d.strength));e.SCR_DrawColorPic(A,x,p,cz,w)}}},Sp=3e3,kp=5e3,bp=4,lz=class{constructor(){this.centerPrintMsg=null,this.notifyMessages=[]}addCenterPrint(e,t){this.centerPrintMsg={text:e,startTime:t,duration:Sp}}addNotify(e,t){this.notifyMessages.push({text:e,startTime:t,duration:kp}),this.notifyMessages.length>bp&&this.notifyMessages.shift()}setCenterPrint(e,t){this.centerPrintMsg={text:e,startTime:t,duration:Sp}}addNotification(e,t,i){this.notifyMessages.push({text:e,startTime:i,duration:kp}),this.notifyMessages.length>bp&&this.notifyMessages.shift()}clearNotifications(){this.notifyMessages=[]}clearCenterPrint(){this.centerPrintMsg=null}drawCenterPrint(e,t,i){if(!this.centerPrintMsg)return;if(t>this.centerPrintMsg.startTime+this.centerPrintMsg.duration){this.centerPrintMsg=null;return}let n=i.CENTER_PRINT_Y;e.SCR_DrawCenterString(n,this.centerPrintMsg.text)}drawNotifications(e,t){for(;this.notifyMessages.length>0&&t>this.notifyMessages[0].startTime+this.notifyMessages[0].duration;)this.notifyMessages.shift();let i=10;for(let n of this.notifyMessages)e.SCR_DrawFontString(10,i,n.text),i+=e.SCR_FontLineHeight()}},mz=3e3,uz=class{constructor(){this.subtitle=null}addSubtitle(e,t){this.subtitle={text:e,startTime:t,duration:mz}}drawSubtitles(e,t){if(!this.subtitle)return;if(t>this.subtitle.startTime+this.subtitle.duration){this.subtitle=null;return}e.SCR_DrawCenterString(200,this.subtitle.text)}},fz=(e,t,i,n)=>{if(!t.blend)return;let[r,a,s,o]=t.blend},hz=(e,t,i,n)=>{if(!t.pickupIcon)return;let r=Ap.get(t.pickupIcon);if(r){let a=e.Draw_GetPicSize(r),s=i-a.width-10,o=n-a.height-10;e.SCR_DrawPic(s,o,r)}},Gm=(e,t,i,n,r,a,s)=>{let o=Math.abs(n).toString();for(let c=0;c<o.length;c++){let d=parseInt(o[c]),l=r[d];l&&(s?e.SCR_DrawColorPic(t+c*a,i,l,{x:s[0],y:s[1],z:s[2]},s[3]):e.SCR_DrawPic(t+c*a,i,l))}},gz=(e,t,i,n,r,a)=>{let s=t.stats[ke.STAT_HEALTH]||0,o=t.stats[ke.STAT_ARMOR]||0,c=t.stats[ke.STAT_AMMO]||0,d=t.stats[ke.STAT_ARMOR_ICON]||0,l;if(s<=25&&(l=[1,0,0,1]),i.length>0&&(Gm(e,a.HEALTH_X,a.HEALTH_Y,s,i,n,l),Gm(e,a.ARMOR_X,a.ARMOR_Y,o,i,n),Gm(e,a.AMMO_X,a.AMMO_Y,c,i,n)),d>0){let m=e.get_configstring(ae.Images+d);if(m){let u=e.Draw_RegisterPic(m);u&&e.SCR_DrawPic(a.ARMOR_X-24,a.ARMOR_Y-2,u)}}if(t.pickupIcon){let m=e.Draw_RegisterPic(t.pickupIcon);m&&e.SCR_DrawPic(a.WEAPON_ICON_X,a.WEAPON_ICON_Y,m)}else{let m=t.stats[ke.STAT_SELECTED_ICON]||0;if(m>0){let u=e.get_configstring(ae.Images+m);if(u){let f=e.Draw_RegisterPic(u);f&&e.SCR_DrawPic(a.WEAPON_ICON_X,a.WEAPON_ICON_Y,f)}}}},Hm=640,oa=480,_z=(e,t)=>{let i=e/Hm,n=t/oa,r=Math.min(i,n);return{HEALTH_X:100*r,HEALTH_Y:t-(oa-450)*r,ARMOR_X:200*r,ARMOR_Y:t-(oa-450)*r,AMMO_X:e-(Hm-540)*r,AMMO_Y:t-(oa-450)*r,CENTER_PRINT_X:e/2,CENTER_PRINT_Y:100*r,WEAPON_ICON_X:10*r,WEAPON_ICON_Y:t-(oa-450)*r,POWERUP_X:e-(Hm-610)*r,POWERUP_Y:t-(oa-450)*r,scale:r}},st=null,$m=[],Tp=0,Km=new lz,Mp=new uz;function pz(e){st=e}function vz(){if(st){$m.length=0;for(let e=0;e<10;e++)try{let t=st.Draw_RegisterPic(`pics/hud/num_${e}.pcx`);$m.push(t),e===0&&(Tp=st.Draw_GetPicSize(t).width)}catch{st.Com_Print(`Warning: Failed to load HUD image: pics/hud/num_${e}.pcx
|