quake2ts 0.0.74 → 0.0.76

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +1 -1
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs.map +1 -1
  5. package/packages/client/dist/esm/index.js.map +1 -1
  6. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  7. package/packages/engine/dist/browser/index.global.js +10 -10
  8. package/packages/engine/dist/browser/index.global.js.map +1 -1
  9. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  10. package/packages/engine/dist/esm/index.js.map +1 -1
  11. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  12. package/packages/engine/dist/types/demo/parser.d.ts +45 -0
  13. package/packages/engine/dist/types/demo/parser.d.ts.map +1 -0
  14. package/packages/engine/dist/types/demo/playback.d.ts +22 -0
  15. package/packages/engine/dist/types/demo/playback.d.ts.map +1 -0
  16. package/packages/engine/dist/types/demo/reader.d.ts +15 -0
  17. package/packages/engine/dist/types/demo/reader.d.ts.map +1 -0
  18. package/packages/game/dist/browser/index.global.js +1 -1
  19. package/packages/game/dist/browser/index.global.js.map +1 -1
  20. package/packages/game/dist/cjs/index.cjs +751 -602
  21. package/packages/game/dist/cjs/index.cjs.map +1 -1
  22. package/packages/game/dist/esm/index.js +749 -602
  23. package/packages/game/dist/esm/index.js.map +1 -1
  24. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  25. package/packages/game/dist/types/ai/index.d.ts +1 -0
  26. package/packages/game/dist/types/ai/index.d.ts.map +1 -1
  27. package/packages/game/dist/types/ai/monster.d.ts +4 -0
  28. package/packages/game/dist/types/ai/monster.d.ts.map +1 -0
  29. package/packages/game/dist/types/entities/entity.d.ts +21 -0
  30. package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
  31. package/packages/game/dist/types/entities/monsters/soldier.d.ts +3 -0
  32. package/packages/game/dist/types/entities/monsters/soldier.d.ts.map +1 -0
  33. package/packages/game/dist/types/entities/spawn.d.ts.map +1 -1
  34. package/packages/shared/dist/browser/index.global.js +1 -1
  35. package/packages/shared/dist/browser/index.global.js.map +1 -1
  36. package/packages/shared/dist/cjs/index.cjs +209 -0
  37. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  38. package/packages/shared/dist/esm/index.js +205 -0
  39. package/packages/shared/dist/esm/index.js.map +1 -1
  40. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  41. package/packages/shared/dist/types/index.d.ts +1 -0
  42. package/packages/shared/dist/types/index.d.ts.map +1 -1
  43. package/packages/shared/dist/types/io/binaryStream.d.ts +31 -0
  44. package/packages/shared/dist/types/io/binaryStream.d.ts.map +1 -0
  45. package/packages/shared/dist/types/protocol/index.d.ts +2 -0
  46. package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
  47. package/packages/shared/dist/types/protocol/ops.d.ts +31 -0
  48. package/packages/shared/dist/types/protocol/ops.d.ts.map +1 -0
  49. package/packages/shared/dist/types/protocol/tempEntity.d.ts +59 -0
  50. package/packages/shared/dist/types/protocol/tempEntity.d.ts.map +1 -0
  51. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";var Quake2Shared=(()=>{var Re=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Gt=Object.prototype.hasOwnProperty;var Ut=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},Ht=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Bt(t))!Gt.call(e,r)&&r!==n&&Re(e,r,{get:()=>t[r],enumerable:!(o=It(t,r))||o.enumerable});return e};var Jt=e=>Ht(Re({},"__esModule",{value:!0}),e);var Mr={};Ut(Mr,{CGAME_EXPORT_KEYS:()=>uo,CGAME_IMPORT_KEYS:()=>lo,CONTENTS_AREAPORTAL:()=>Yr,CONTENTS_AUX:()=>Ur,CONTENTS_CURRENT_0:()=>bn,CONTENTS_CURRENT_180:()=>En,CONTENTS_CURRENT_270:()=>Pn,CONTENTS_CURRENT_90:()=>hn,CONTENTS_CURRENT_DOWN:()=>vn,CONTENTS_CURRENT_UP:()=>_n,CONTENTS_DEADMONSTER:()=>es,CONTENTS_DETAIL:()=>ts,CONTENTS_LADDER:()=>lt,CONTENTS_LAVA:()=>Hr,CONTENTS_MIST:()=>jr,CONTENTS_MONSTER:()=>Qr,CONTENTS_MONSTERCLIP:()=>qr,CONTENTS_NONE:()=>Ce,CONTENTS_NO_WATERJUMP:()=>Cn,CONTENTS_ORIGIN:()=>$r,CONTENTS_PLAYER:()=>os,CONTENTS_PLAYERCLIP:()=>Zr,CONTENTS_PROJECTILE:()=>rs,CONTENTS_PROJECTILECLIP:()=>Xr,CONTENTS_SLIME:()=>Jr,CONTENTS_SOLID:()=>Br,CONTENTS_TRANSLUCENT:()=>ns,CONTENTS_TRIGGER:()=>Vn,CONTENTS_WATER:()=>Kr,CONTENTS_WINDOW:()=>Gr,CS_MAX_STRING_LENGTH:()=>Bs,CS_MAX_STRING_LENGTH_OLD:()=>Gs,CollisionEntityIndex:()=>ke,ConfigStringIndex:()=>oe,CvarFlags:()=>Tt,DEFAULT_FORWARD_SPEED:()=>hr,DEFAULT_MOUSE_SENSITIVITY:()=>Nr,DEFAULT_PITCH_SPEED:()=>vr,DEFAULT_SIDE_SPEED:()=>Er,DEFAULT_UP_SPEED:()=>Pr,DEFAULT_YAW_SPEED:()=>_r,DEG2RAD:()=>ln,DIST_EPSILON:()=>J,GAME_EXPORT_KEYS:()=>co,GAME_IMPORT_KEYS:()=>io,LAST_VISIBLE_CONTENTS:()=>ss,MASK_ALL:()=>Cs,MASK_BLOCK_SIGHT:()=>vs,MASK_CURRENT:()=>Nn,MASK_DEADSOLID:()=>hs,MASK_LADDER_NAV_SOLID:()=>gs,MASK_MONSTERSOLID:()=>Es,MASK_NAV_SOLID:()=>Ns,MASK_OPAQUE:()=>Ps,MASK_PLAYERSOLID:()=>bs,MASK_PROJECTILE:()=>As,MASK_SHOT:()=>_s,MASK_SOLID:()=>we,MASK_WALK_NAV_SOLID:()=>zs,MASK_WATER:()=>be,MAX_CLIENTS:()=>Yn,MAX_CONFIGSTRINGS:()=>oo,MAX_EDICTS:()=>Is,MAX_GENERAL:()=>to,MAX_IMAGES:()=>Qn,MAX_ITEMS:()=>eo,MAX_LIGHTSTYLES:()=>Zn,MAX_MODELS:()=>qn,MAX_OSPATH:()=>ks,MAX_QPATH:()=>Ws,MAX_SHADOW_LIGHTS:()=>no,MAX_SOUNDS:()=>$n,MAX_STRING_CHARS:()=>Ls,MAX_STRING_TOKENS:()=>ws,MAX_TOKEN_CHARS:()=>Ds,MAX_WHEEL_ITEMS:()=>He,MersenneTwister19937:()=>Se,PITCH:()=>xe,PlaneSide:()=>ut,PlayerButton:()=>Q,PmFlag:()=>$,PmType:()=>se,RAD2DEG:()=>un,ROLL:()=>Me,RandomGenerator:()=>Ve,SLIDEMOVE_BLOCKED_FLOOR:()=>Ct,SLIDEMOVE_BLOCKED_WALL:()=>bt,STOP_EPSILON:()=>j,SURF_ALPHATEST:()=>ys,SURF_FLOWING:()=>ps,SURF_LIGHT:()=>is,SURF_N64_SCROLL_FLIP:()=>Vs,SURF_N64_SCROLL_X:()=>Ts,SURF_N64_SCROLL_Y:()=>Ss,SURF_N64_UV:()=>xs,SURF_NODRAW:()=>fs,SURF_NONE:()=>as,SURF_SKY:()=>ls,SURF_SLICK:()=>cs,SURF_TRANS33:()=>ms,SURF_TRANS66:()=>ds,SURF_WARP:()=>us,WaterLevel:()=>re,YAW:()=>Te,ZERO_VEC3:()=>g,addBlendColor:()=>fn,addContents:()=>An,addPmFlag:()=>W,addPointToBounds:()=>en,addVec3:()=>_,addViewAngles:()=>zr,angleMod:()=>le,angleVectors:()=>Le,applyPmove:()=>Or,applyPmoveAccelerate:()=>U,applyPmoveAddCurrents:()=>Ne,applyPmoveAirAccelerate:()=>je,applyPmoveAirMove:()=>tr,applyPmoveFlyMove:()=>zo,applyPmoveFriction:()=>Ke,applyPmoveWaterMove:()=>nr,assertContract:()=>ao,boxContents:()=>Gn,boxOnPlaneSide:()=>Dn,boxesIntersect:()=>tn,buildAirGroundWish:()=>Xe,buildCollisionModel:()=>Ln,buildWaterWish:()=>Ye,categorizePosition:()=>Qo,checkDuckState:()=>ko,checkJump:()=>Mo,checkSpecialMovement:()=>yr,clampViewAngles:()=>br,clipBoxToBrush:()=>Be,clipVelocityAgainstPlanes:()=>nn,clipVelocityVec3:()=>Z,closestPointToBox:()=>qt,combineSurfaceFlags:()=>On,computePlaneSignBits:()=>Ie,computePlayerDimensions:()=>ze,concatRotationMatrices:()=>Oe,configStringSize:()=>ro,createDefaultTrace:()=>Ee,createEmptyBounds3:()=>Qt,createMat4Identity:()=>ct,createRandomGenerator:()=>yn,crossVec3:()=>Y,currentVectorFromContents:()=>et,degToRad:()=>fe,distance:()=>Yt,distanceBetweenBoxesSquared:()=>$t,dotVec3:()=>R,fixStuckObjectGeneric:()=>$e,getWaterLevel:()=>de,goodPosition:()=>ot,groundCurrentVelocity:()=>Ft,hasAllContents:()=>gn,hasAnyContents:()=>zn,hasPmFlag:()=>O,hasSurfaceFlags:()=>Rn,inPHS:()=>Hn,inPVS:()=>Un,initialSnapPosition:()=>Sr,isAtLeastWaistDeep:()=>Je,isUnderwater:()=>mo,lengthSquaredVec3:()=>te,lengthVec3:()=>w,lerpAngle:()=>mn,mat4FromBasis:()=>Sn,mouseDeltaToViewDelta:()=>Ar,multiplyMat4:()=>xn,multiplyVec3:()=>jt,negateVec3:()=>Xt,normalizeVec3:()=>A,perpendicularVec3:()=>st,planeDistanceToPoint:()=>q,pmoveCmdScale:()=>po,pointContents:()=>In,pointContentsMany:()=>Bn,pointInsideBrush:()=>mt,pointOnPlaneSide:()=>wn,projectPointOnPlane:()=>rt,projectSourceVec3:()=>rn,projectSourceVec3WithUp:()=>sn,radToDeg:()=>ye,removeContents:()=>Fn,removePmFlag:()=>G,resolveSlideMove:()=>ht,rotatePointAroundVector:()=>cn,scaleVec3:()=>v,slerpVec3:()=>an,slideClipVelocityVec3:()=>on,slideMove:()=>Ze,snapPosition:()=>Tr,stepSlideMove:()=>ee,subtractVec3:()=>X,testBoxInBrush:()=>dt,traceBox:()=>xt,transformPointMat4:()=>Tn,validateContract:()=>St,vec3Equals:()=>Zt,vectorToAngles:()=>pn,vectorToYaw:()=>dn,waterCurrentVelocity:()=>At});var g={x:0,y:0,z:0},j=.1,Kt=Math.PI/180;function _(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function X(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function jt(e,t){return{x:e.x*t.x,y:e.y*t.y,z:e.z*t.z}}function v(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Xt(e){return v(e,-1)}function R(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Y(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function te(e){return R(e,e)}function w(e){return Math.sqrt(te(e))}function Yt(e,t){return w(X(e,t))}function Zt(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}function A(e){let t=w(e);return t===0?e:v(e,1/t)}function rt(e,t){let n=1/R(t,t),o=R(t,e)*n;return X(e,v(t,n*o))}function st(e){let t=0,n=Math.abs(e.x);return Math.abs(e.y)<n&&(t=1,n=Math.abs(e.y)),Math.abs(e.z)<n&&(t=2),A(rt(t===0?{x:1,y:0,z:0}:t===1?{x:0,y:1,z:0}:{x:0,y:0,z:1},e))}function qt(e,t,n){return{x:e.x<t.x?t.x:e.x>n.x?n.x:e.x,y:e.y<t.y?t.y:e.y>n.y?n.y:e.y,z:e.z<t.z?t.z:e.z>n.z?n.z:e.z}}function $t(e,t,n,o){let r=0;if(t.x<n.x){let s=t.x-n.x;r+=s*s}else if(e.x>o.x){let s=e.x-o.x;r+=s*s}if(t.y<n.y){let s=t.y-n.y;r+=s*s}else if(e.y>o.y){let s=e.y-o.y;r+=s*s}if(t.z<n.z){let s=t.z-n.z;r+=s*s}else if(e.z>o.z){let s=e.z-o.z;r+=s*s}return r}function Qt(){return{mins:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY,z:Number.POSITIVE_INFINITY},maxs:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY,z:Number.NEGATIVE_INFINITY}}}function en(e,t){return{mins:{x:Math.min(t.mins.x,e.x),y:Math.min(t.mins.y,e.y),z:Math.min(t.mins.z,e.z)},maxs:{x:Math.max(t.maxs.x,e.x),y:Math.max(t.maxs.y,e.y),z:Math.max(t.maxs.z,e.z)}}}function tn(e,t){return e.mins.x<=t.maxs.x&&e.maxs.x>=t.mins.x&&e.mins.y<=t.maxs.y&&e.maxs.y>=t.mins.y&&e.mins.z<=t.maxs.z&&e.maxs.z>=t.mins.z}function Z(e,t,n){let o=R(e,t)*n,r=e.x-t.x*o,s=e.y-t.y*o,a=e.z-t.z*o;return r>-j&&r<j&&(r=0),s>-j&&s<j&&(s=0),a>-j&&a<j&&(a=0),{x:r,y:s,z:a}}function nn(e,t,n,o){if(t.length===0)return e;let r=e;for(let s=0;s<t.length;s++){r=Z(r,t[s],n);let a=0;for(;a<t.length&&!(a!==s&&R(r,t[a])<0);a++);if(a===t.length)return o&&R(r,o)<=0?g:r}if(t.length===2){let s=Y(t[0],t[1]),a=R(s,e),i=v(s,a);return o&&R(i,o)<=0?g:i}return o&&R(r,o)<=0,g}function on(e,t,n){return Z(e,t,n)}function rn(e,t,n,o){return{x:e.x+n.x*t.x+o.x*t.y,y:e.y+n.y*t.x+o.y*t.y,z:e.z+n.z*t.x+o.z*t.y+t.z}}function sn(e,t,n,o,r){return{x:e.x+n.x*t.x+o.x*t.y+r.x*t.z,y:e.y+n.y*t.x+o.y*t.y+r.y*t.z,z:e.z+n.z*t.x+o.z*t.y+r.z*t.z}}function an(e,t,n){let o=R(e,t),r,s;if(Math.abs(o)>.9995)r=1-n,s=n;else{let a=Math.acos(o),i=Math.sin(a),u=Math.sin((1-n)*a),l=Math.sin(n*a);r=u/i,s=l/i}return{x:e.x*r+t.x*s,y:e.y*r+t.y*s,z:e.z*r+t.z*s}}function Oe(e,t){let n=r=>[e[r][0]*t[0][0]+e[r][1]*t[1][0]+e[r][2]*t[2][0],e[r][0]*t[0][1]+e[r][1]*t[1][1]+e[r][2]*t[2][1],e[r][0]*t[0][2]+e[r][1]*t[1][2]+e[r][2]*t[2][2]];return[n(0),n(1),n(2)]}function cn(e,t,n){if(w(e)===0)return t;let r=A(e),s=st(r),a=Y(s,r),i=[[s.x,a.x,r.x],[s.y,a.y,r.y],[s.z,a.z,r.z]],u=[[i[0][0],i[1][0],i[2][0]],[i[0][1],i[1][1],i[2][1]],[i[0][2],i[1][2],i[2][2]]],l=n*Kt,m=Math.cos(l),c=Math.sin(l),d=[[m,c,0],[-c,m,0],[0,0,1]],p=Oe(Oe(i,d),u);return{x:p[0][0]*t.x+p[0][1]*t.y+p[0][2]*t.z,y:p[1][0]*t.x+p[1][1]*t.y+p[1][2]*t.z,z:p[2][0]*t.x+p[2][1]*t.y+p[2][2]*t.z}}var xe=0,Te=1,Me=2,at=Math.PI/180,it=180/Math.PI,ln=at,un=it;function ce(e,t){switch(t){case xe:return e.x;case Te:return e.y;case Me:default:return e.z}}function fe(e){return e*at}function ye(e){return e*it}function mn(e,t,n){let o=t;return o-e>180?o-=360:o-e<-180&&(o+=360),e+n*(o-e)}function le(e){let t=e%360;return t<0?360+t:t}function Le(e){let t=fe(ce(e,Te)),n=fe(ce(e,xe)),o=fe(ce(e,Me)),r=Math.sin(t),s=Math.cos(t),a=Math.sin(n),i=Math.cos(n),u=Math.sin(o),l=Math.cos(o),m={x:i*s,y:i*r,z:-a},c={x:-u*a*s-l*-r,y:-u*a*r-l*s,z:-u*i},d={x:l*a*s-u*-r,y:l*a*r-u*s,z:l*i};return{forward:m,right:c,up:d}}function dn(e){let t=ce(e,xe),n=ce(e,Te);if(t===0)return n===0?0:n>0?90:270;let o=ye(Math.atan2(n,t));return o<0?o+360:o}function pn(e){let t=e.x,n=e.y,o=e.z;if(n===0&&t===0)return{x:o>0?-90:-270,y:0,z:0};let r;t?r=ye(Math.atan2(n,t)):n>0?r=90:r=270,r<0&&(r+=360);let s=Math.sqrt(t*t+n*n),a=ye(Math.atan2(o,s));return a<0&&(a+=360),{x:-a,y:r,z:0}}function fn(e,t,n,o,r){if(o<=0)return r;let s=r[0],a=r[1],i=r[2],u=r[3],l=u+(1-u)*o;if(l<=0)return[0,0,0,0];let m=u/l,c=s*m+e*(1-m),d=a*m+t*(1-m),p=i*m+n*(1-m);return[c,d,p,l]}var Se=class{constructor(t=5489){this.state=new Uint32Array(624);this.index=624;this.seed(t)}seed(t){this.state[0]=t>>>0;for(let n=1;n<624;n++){let o=this.state[n-1]^this.state[n-1]>>>30,r=Math.imul(o>>>0,1812433253)+n;this.state[n]=r>>>0}this.index=624}nextUint32(){this.index>=624&&this.twist();let t=this.state[this.index++];return t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}twist(){for(let t=0;t<624;t++){let n=this.state[t]&2147483648|this.state[(t+1)%624]&2147483647,o=this.state[(t+397)%624]^n>>>1;(n&1)!==0&&(o^=2567483615),this.state[t]=o>>>0}this.index=0}getState(){return{index:this.index,state:Array.from(this.state)}}setState(t){if(t.state.length!==624)throw new Error(`Expected 624 MT state values, received ${t.state.length}`);this.index=t.index,this.state=Uint32Array.from(t.state,n=>n>>>0)}},Ve=class{constructor(t={}){this.mt=new Se(t.seed)}frandom(){return this.mt.nextUint32()/4294967296}frandomRange(t,n){return t+(n-t)*this.frandom()}frandomMax(t){return this.frandomRange(0,t)}crandom(){return this.frandomRange(-1,1)}crandomOpen(){let t=Number.EPSILON;return this.frandomRange(-1+t,1)}irandomUint32(){return this.mt.nextUint32()}irandomRange(t,n){if(n-t<=1)return t;let o=n-t,r=4294967296-4294967296%o,s;do s=this.mt.nextUint32();while(s>=r);return t+s%o}irandom(t){return t<=0?0:this.irandomRange(0,t)}randomTimeRange(t,n){return n<=t?t:this.irandomRange(t,n)}randomTime(t){return this.irandom(t)}randomIndex(t){return this.irandom(t.length)}getState(){return{mt:this.mt.getState()}}setState(t){this.mt.setState(t.mt)}};function yn(e){return new Ve(e)}function ct(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function xn(e,t){let n=new Float32Array(16);for(let o=0;o<4;o+=1)for(let r=0;r<4;r+=1)n[r*4+o]=e[0+o]*t[r*4+0]+e[4+o]*t[r*4+1]+e[8+o]*t[r*4+2]+e[12+o]*t[r*4+3];return n}function Tn(e,t){let n=t.x,o=t.y,r=t.z;return{x:e[0]*n+e[4]*o+e[8]*r+e[12],y:e[1]*n+e[5]*o+e[9]*r+e[13],z:e[2]*n+e[6]*o+e[10]*r+e[14]}}function Sn(e,t){let n=ct();return n[0]=t[0].x,n[1]=t[0].y,n[2]=t[0].z,n[4]=t[1].x,n[5]=t[1].y,n[6]=t[1].z,n[8]=t[2].x,n[9]=t[2].y,n[10]=t[2].z,n[12]=e.x,n[13]=e.y,n[14]=e.z,n}var Ce=0,Br=1,Gr=2,Ur=4,Hr=8,Jr=16,Kr=32,jr=64,Vn=1073741824,Cn=8192,Xr=16384,Yr=32768,Zr=65536,qr=131072,bn=262144,hn=524288,En=1048576,Pn=2097152,_n=4194304,vn=8388608,$r=16777216,Qr=33554432,es=67108864,ts=134217728,ns=268435456,lt=536870912,os=1073741824,rs=-2147483648,ss=64,as=0,is=1,cs=2,ls=4,us=8,ms=16,ds=32,ps=64,fs=128,ys=33554432,xs=268435456,Ts=536870912,Ss=1073741824,Vs=-2147483648,Cs=4294967295,we=3,bs=1107361795,hs=65539,Es=1107427331,be=56,Ps=25,_s=1174405123,Nn=16515072,vs=1107296281,Ns=65539,gs=3,zs=196611,As=1174421507;function gn(e,t){return(e&t)===t}function zn(e,t){return(e&t)!==0}function An(e,t){return e|t}function Fn(e,t){return e&~t}function Rn(e,t){return(e&t)===t}function On(...e){let t=0;for(let n of e)t|=n;return t}var ut=(o=>(o[o.FRONT=1]="FRONT",o[o.BACK=2]="BACK",o[o.CROSS=3]="CROSS",o))(ut||{}),J=.03125,Mn=Number.MAX_SAFE_INTEGER-1,he=1;function Ln(e){let t=e.planes.map(a=>({...a,signbits:Ie(a.normal)})),n=e.nodes.map(a=>({plane:t[a.planenum],children:a.children})),o=e.brushes.map(a=>{let i=e.brushSides.slice(a.firstSide,a.firstSide+a.numSides).map(u=>({plane:t[u.planenum],surfaceFlags:u.surfaceFlags}));return{contents:a.contents,sides:i,checkcount:0}}),r=e.leaves.map(a=>({contents:a.contents,cluster:a.cluster,area:a.area,firstLeafBrush:a.firstLeafBrush,numLeafBrushes:a.numLeafBrushes})),s=e.bmodels.map(a=>({mins:a.mins,maxs:a.maxs,origin:a.origin,headnode:a.headnode}));return{planes:t,nodes:n,leaves:r,brushes:o,leafBrushes:e.leafBrushes,bmodels:s,visibility:e.visibility}}function Ie(e){let t=0;return e.x<0&&(t|=1),e.y<0&&(t|=2),e.z<0&&(t|=4),t}function q(e,t){return e.normal.x*t.x+e.normal.y*t.y+e.normal.z*t.z-e.dist}function wn(e,t,n=0){let o=q(e,t);return o>n?1:o<-n?2:3}function Dn(e,t,n,o=0){let r,s;switch(n.signbits){case 0:r=n.normal.x*t.x+n.normal.y*t.y+n.normal.z*t.z,s=n.normal.x*e.x+n.normal.y*e.y+n.normal.z*e.z;break;case 1:r=n.normal.x*e.x+n.normal.y*t.y+n.normal.z*t.z,s=n.normal.x*t.x+n.normal.y*e.y+n.normal.z*e.z;break;case 2:r=n.normal.x*t.x+n.normal.y*e.y+n.normal.z*t.z,s=n.normal.x*e.x+n.normal.y*t.y+n.normal.z*e.z;break;case 3:r=n.normal.x*e.x+n.normal.y*e.y+n.normal.z*t.z,s=n.normal.x*t.x+n.normal.y*t.y+n.normal.z*e.z;break;case 4:r=n.normal.x*t.x+n.normal.y*t.y+n.normal.z*e.z,s=n.normal.x*e.x+n.normal.y*e.y+n.normal.z*t.z;break;case 5:r=n.normal.x*e.x+n.normal.y*t.y+n.normal.z*e.z,s=n.normal.x*t.x+n.normal.y*e.y+n.normal.z*t.z;break;case 6:r=n.normal.x*t.x+n.normal.y*e.y+n.normal.z*e.z,s=n.normal.x*e.x+n.normal.y*t.y+n.normal.z*t.z;break;default:r=n.normal.x*e.x+n.normal.y*e.y+n.normal.z*e.z,s=n.normal.x*t.x+n.normal.y*t.y+n.normal.z*t.z;break}let a=0;return r-n.dist>=-o&&(a=1),s-n.dist<=o&&(a|=2),a}function mt(e,t,n=J){for(let o of t.sides)if(q(o.plane,e)>n)return!1;return!0}function dt(e,t,n,o){for(let r of o.sides){let s=r.plane.normal.x*(r.plane.normal.x<0?n.x:t.x)+r.plane.normal.y*(r.plane.normal.y<0?n.y:t.y)+r.plane.normal.z*(r.plane.normal.z<0?n.z:t.z),a=r.plane.dist-s;if(e.x*r.plane.normal.x+e.y*r.plane.normal.y+e.z*r.plane.normal.z-a>0)return{startsolid:!1,allsolid:!1,contents:0}}return{startsolid:!0,allsolid:!0,contents:o.contents}}function Be({start:e,end:t,mins:n,maxs:o,brush:r,trace:s}){if(r.sides.length===0)return;let a=n.x===0&&n.y===0&&n.z===0&&o.x===0&&o.y===0&&o.z===0,i=-1,u=1,l=null,m=null,c=!1,d=!1;for(let p of r.sides){let{plane:f}=p,V=f.dist;if(!a){let E=f.normal.x<0?o.x:n.x,b=f.normal.y<0?o.y:n.y,T=f.normal.z<0?o.z:n.z;V-=f.normal.x*E+f.normal.y*b+f.normal.z*T}let x=e.x*f.normal.x+e.y*f.normal.y+e.z*f.normal.z-V,S=t.x*f.normal.x+t.y*f.normal.y+t.z*f.normal.z-V;if(S>0&&(c=!0),x>0&&(d=!0),x>0&&S>=x)return;if(!(x<=0&&S<=0))if(x>S){let E=(x-J)/(x-S);E>i&&(i=E,l=f,m=p)}else{let E=(x+J)/(x-S);E<u&&(u=E)}}if(!d){s.startsolid=!0,c||(s.allsolid=!0),s.fraction=0;return}i<u&&i>-1&&i<s.fraction&&(s.fraction=i<0?0:i,s.plane=l,s.contents=r.contents,s.surfaceFlags=m?.surfaceFlags??0)}function Ee(){return{fraction:1,plane:null,contents:0,surfaceFlags:0,startsolid:!1,allsolid:!1}}function Ge(e,t,n){let o=n;for(;o>=0;){let r=t.nodes[o];o=q(r.plane,e)>=0?r.children[0]:r.children[1]}return-1-o}function pt(e,t,n){let o=e.leaves[t],r=o.contents,s=Ue(),a=o.firstLeafBrush,i=a+o.numLeafBrushes;for(let u=a;u<i;u+=1){let l=e.leafBrushes[u],m=e.brushes[l];m.checkcount!==s&&(m.checkcount=s,m.sides.length!==0&&mt(n,m)&&(r|=m.contents))}return r}function Ue(){let e=he;return he+=1,he>=Mn&&(he=1),e}function Wn(e,t){return e.x===0&&e.y===0&&e.z===0&&t.x===0&&t.y===0&&t.z===0}function kn(e,t,n){return Wn(t,n)?0:e.normal.x*(e.normal.x<0?n.x:t.x)+e.normal.y*(e.normal.y<0?n.y:t.y)+e.normal.z*(e.normal.z<0?n.z:t.z)}function ft(e,t,n){return Math.abs(kn(e,t,n))}function De(e,t,n){return _(e,v(X(t,e),n))}function We(e,t,n){let o=e.allsolid?0:e.fraction,r=De(t,n,o);return{fraction:o,endpos:r,plane:e.plane,planeNormal:e.startsolid?void 0:e.plane?.normal,contents:e.contents,surfaceFlags:e.surfaceFlags,startsolid:e.startsolid,allsolid:e.allsolid}}function Pe(e,t,n){let o=Ge(e,t,n);return t.leaves[o]?.cluster??-1}function yt(e,t,n,o){if(!e||e.numClusters===0)return!0;if(t<0||n<0||t>=e.clusters.length||n>=e.numClusters)return!1;let r=e.clusters[t],a=(o?r.phs:r.pvs)[n>>3];return a===void 0?!1:(a&1<<(n&7))!==0}function ue(e){let{model:t,nodeIndex:n,startFraction:o,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:d,brushCheckCount:p}=e;if(d.fraction<=o)return;if(n<0){let M=-1-n,h=t.leaves[M],D=h.firstLeafBrush,H=D+h.numLeafBrushes;for(let L=D;L<H;L+=1){let B=t.leafBrushes[L],F=t.brushes[B];if((F.contents&c)!==0&&F.sides.length&&F.checkcount!==p&&(F.checkcount=p,Be({start:i,end:u,mins:l,maxs:m,brush:F,trace:d}),d.allsolid))return}return}let f=t.nodes[n],V=f.plane,x=ft(V,l,m),S=q(V,s),E=q(V,a);if(S>=x&&E>=x){ue({model:t,nodeIndex:f.children[0],startFraction:o,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:d,brushCheckCount:p});return}if(S<-x&&E<-x){ue({model:t,nodeIndex:f.children[1],startFraction:o,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:d,brushCheckCount:p});return}let b=0,T=1/(S-E),P,C;S<E?(b=1,C=(S+x+J)*T,P=(S-x+J)*T):(b=0,C=(S-x-J)*T,P=(S+x+J)*T),P<0?P=0:P>1&&(P=1),C<0?C=0:C>1&&(C=1);let y=o+(r-o)*P,z=De(s,a,P);if(ue({model:t,nodeIndex:f.children[b],startFraction:o,endFraction:y,start:s,end:z,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:d,brushCheckCount:p}),d.fraction<=y)return;let I=o+(r-o)*C,N=De(s,a,C);ue({model:t,nodeIndex:f.children[1-b],startFraction:I,endFraction:r,start:N,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:d,brushCheckCount:p})}function xt(e){let{model:t,start:n,end:o}=e,r=e.mins??g,s=e.maxs??g,a=e.contentMask??4294967295,i=e.headnode??0,u=Ee(),l=Ue();return ue({model:t,nodeIndex:i,startFraction:0,endFraction:1,start:n,end:o,traceStart:n,traceEnd:o,mins:r,maxs:s,contentMask:a,trace:u,brushCheckCount:l}),We(u,n,o)}function In(e,t,n=0){let o=Ge(e,t,n);return pt(t,o,e)}function Bn(e,t,n=0){let o=new Map;return e.map(r=>{let s=Ge(r,t,n),a=t.leaves[s];if(a.numLeafBrushes===0){let i=o.get(s);return i!==void 0?i:(o.set(s,a.contents),a.contents)}return pt(t,s,r)})}function Gn(e,t,n,o,r=0){let s=Ue(),a=0;function i(u){if(u<0){let p=-1-u,f=o.leaves[p];a|=f.contents;let V=f.firstLeafBrush,x=V+f.numLeafBrushes;for(let S=V;S<x;S+=1){let E=o.leafBrushes[S],b=o.brushes[E];if(b.checkcount===s||(b.checkcount=s,b.sides.length===0))continue;let T=dt(e,t,n,b);T.startsolid&&(a|=T.contents)}return}let l=o.nodes[u],m=l.plane,c=ft(m,t,n),d=q(m,e);if(c===0){i(d>=0?l.children[0]:l.children[1]);return}if(d>c){i(l.children[0]);return}if(d<-c){i(l.children[1]);return}i(l.children[0]),i(l.children[1])}return i(r),a}function Un(e,t,n,o=0){let{visibility:r}=n;if(!r)return!0;let s=Pe(e,n,o),a=Pe(t,n,o);return yt(r,s,a,!1)}function Hn(e,t,n,o=0){let{visibility:r}=n;if(!r)return!0;let s=Pe(e,n,o),a=Pe(t,n,o);return yt(r,s,a,!0)}function ne(e,t,n){return{normal:e,dist:t,type:n,signbits:Ie(e)}}function Jn(e){let t=e.surfaceFlags??0,n=e.origin.x+e.maxs.x,o=e.origin.x+e.mins.x,r=e.origin.y+e.maxs.y,s=e.origin.y+e.mins.y,a=e.origin.z+e.maxs.z,i=e.origin.z+e.mins.z,l=[ne({x:1,y:0,z:0},n,0),ne({x:-1,y:0,z:0},-o,0),ne({x:0,y:1,z:0},r,1),ne({x:0,y:-1,z:0},-s,1),ne({x:0,y:0,z:1},a,2),ne({x:0,y:0,z:-1},-i,2)].map(m=>({plane:m,surfaceFlags:t}));return{contents:e.contents,sides:l,checkcount:0}}function Kn(e){let t=Jn(e);return{...e,brush:t,bounds:{mins:{x:e.origin.x+e.mins.x,y:e.origin.y+e.mins.y,z:e.origin.z+e.mins.z},maxs:{x:e.origin.x+e.maxs.x,y:e.origin.y+e.maxs.y,z:e.origin.z+e.maxs.z}}}}function jn(e,t){return!(e.mins.x>t.maxs.x||e.maxs.x<t.mins.x||e.mins.y>t.maxs.y||e.maxs.y<t.mins.y||e.mins.z>t.maxs.z||e.maxs.z<t.mins.z)}function Xn(e,t){return t.allsolid&&!e.allsolid||t.startsolid&&!e.startsolid?!0:t.fraction<e.fraction}var ke=class{constructor(){this.entities=new Map}link(t){this.entities.set(t.id,Kn(t))}unlink(t){this.entities.delete(t)}trace(t){let{passId:n}=t,o=t.mins??g,r=t.maxs??g,s=t.contentMask??4294967295,a,i=null;t.model?a=xt(t):a=We(Ee(),t.start,t.end);for(let u of this.entities.values()){if(u.id===n||(u.contents&s)===0)continue;let l=Ee();Be({start:t.start,end:t.end,mins:o,maxs:r,brush:u.brush,trace:l}),l.contents===0&&(l.contents=u.contents);let m=We(l,t.start,t.end);Xn(a,m)&&(a=m,i=u.id)}return{...a,entityId:i}}gatherTriggerTouches(t,n,o,r=1073741824){let s=[],a={mins:_(t,n),maxs:_(t,o)};for(let i of this.entities.values())(i.contents&r)!==0&&jn(a,i.bounds)&&s.push(i.id);return s}};var Tt=(a=>(a[a.None=0]="None",a[a.Archive=1]="Archive",a[a.UserInfo=2]="UserInfo",a[a.ServerInfo=4]="ServerInfo",a[a.Latch=8]="Latch",a[a.Cheat=16]="Cheat",a))(Tt||{});var Ls=1024,ws=80,Ds=512,Ws=64,ks=128,Yn=256,Is=8192,Zn=256,qn=8192,$n=2048,Qn=512,eo=256,to=512,no=256,He=32,Bs=96,Gs=64,oe=(y=>(y[y.Name=0]="Name",y[y.CdTrack=1]="CdTrack",y[y.Sky=2]="Sky",y[y.SkyAxis=3]="SkyAxis",y[y.SkyRotate=4]="SkyRotate",y[y.StatusBar=5]="StatusBar",y[y.AirAccel=59]="AirAccel",y[y.MaxClients=60]="MaxClients",y[y.MapChecksum=61]="MapChecksum",y[y.Models=62]="Models",y[y.Sounds=62+qn]="Sounds",y[y.Images=y.Sounds+$n]="Images",y[y.Lights=y.Images+Qn]="Lights",y[y.ShadowLights=y.Lights+Zn]="ShadowLights",y[y.Items=y.ShadowLights+no]="Items",y[y.PlayerSkins=y.Items+eo]="PlayerSkins",y[y.General=y.PlayerSkins+Yn]="General",y[y.WheelWeapons=y.General+to]="WheelWeapons",y[y.WheelAmmo=y.WheelWeapons+He]="WheelAmmo",y[y.WheelPowerups=y.WheelAmmo+He]="WheelPowerups",y[y.CdLoopCount=y.WheelPowerups+He]="CdLoopCount",y[y.GameStyle=y.CdLoopCount+1]="GameStyle",y[y.MaxConfigStrings=y.GameStyle+1]="MaxConfigStrings",y))(oe||{}),oo=oe.MaxConfigStrings;function ro(e){return e>=5&&e<59?96*(59-e):e>=oe.General&&e<oe.WheelWeapons?96*(oe.MaxConfigStrings-e):96}function so(e){return e??{}}function St(e,t,n={}){let o=so(e),r=[],s=[];for(let i of t){if(!(i in o)){r.push(i);continue}typeof o[i]!="function"&&s.push(i)}let a=n.allowExtra===!1?Object.keys(o).filter(i=>!t.includes(i)):[];return{missing:r,nonFunctions:s,extras:a}}function ao(e,t,n={}){let{missing:o,nonFunctions:r,extras:s}=St(e,t,n);if(o.length===0&&r.length===0&&s.length===0)return;let a=[];o.length>0&&a.push(`missing: ${o.join(", ")}`),r.length>0&&a.push(`non-functions: ${r.join(", ")}`),s.length>0&&a.push(`extras: ${s.join(", ")}`);let i=n.name??"contract";throw new Error(`${i} validation failed (${a.join("; ")})`)}var io=["Broadcast_Print","Com_Print","Client_Print","Center_Print","sound","positioned_sound","local_sound","configstring","get_configstring","Com_Error","modelindex","soundindex","imageindex","setmodel","trace","clip","pointcontents","inPVS","inPHS","SetAreaPortalState","AreasConnected","linkentity","unlinkentity","BoxEdicts","multicast","unicast"],co=["PreInit","Init","Shutdown","SpawnEntities","WriteGameJson","ReadGameJson","WriteLevelJson","ReadLevelJson","CanSave","ClientConnect","ClientThink","RunFrame","Pmove"],lo=["Com_Print","get_configstring","Com_Error","TagMalloc","TagFree","AddCommandString","CL_FrameValid","CL_FrameTime","CL_ClientTime","CL_ServerFrame","Draw_RegisterPic","Draw_GetPicSize","SCR_DrawChar","SCR_DrawPic","SCR_DrawColorPic"],uo=["Init","Shutdown","DrawHUD","TouchPics","LayoutFlags","GetActiveWeaponWheelWeapon","GetOwnedWeaponWheelWeapons","GetWeaponWheelAmmoCount","GetPowerupWheelCount","GetHitMarkerDamage","Pmove","ParseConfigString","ParseCenterPrint","ClearNotify","ClearCenterprint","NotifyMessage","GetMonsterFlashOffset"];var re=(r=>(r[r.None=0]="None",r[r.Feet=1]="Feet",r[r.Waist=2]="Waist",r[r.Under=3]="Under",r))(re||{});function Je(e){return e>=2}function mo(e){return e===3}var $=(c=>(c[c.Ducked=1]="Ducked",c[c.JumpHeld=2]="JumpHeld",c[c.OnGround=4]="OnGround",c[c.TimeWaterJump=8]="TimeWaterJump",c[c.TimeLand=16]="TimeLand",c[c.TimeTeleport=32]="TimeTeleport",c[c.NoPositionalPrediction=64]="NoPositionalPrediction",c[c.OnLadder=128]="OnLadder",c[c.NoAngularPrediction=256]="NoAngularPrediction",c[c.IgnorePlayerCollision=512]="IgnorePlayerCollision",c[c.TimeTrick=1024]="TimeTrick",c))($||{});function O(e,t){return(e&t)!==0}function W(e,t){return e|t}function G(e,t){return e&~t}var se=(i=>(i[i.Normal=0]="Normal",i[i.Grapple=1]="Grapple",i[i.NoClip=2]="NoClip",i[i.Spectator=3]="Spectator",i[i.Dead=4]="Dead",i[i.Gib=5]="Gib",i[i.Freeze=6]="Freeze",i))(se||{}),Q=(i=>(i[i.None=0]="None",i[i.Attack=1]="Attack",i[i.Use=2]="Use",i[i.Holster=4]="Holster",i[i.Jump=8]="Jump",i[i.Crouch=16]="Crouch",i[i.Any=128]="Any",i))(Q||{});function Ke(e){let{velocity:t,frametime:n,onGround:o,groundIsSlick:r,onLadder:s,waterlevel:a,pmFriction:i,pmStopSpeed:u,pmWaterFriction:l}=e,m=w(t);if(m<1)return{x:0,y:0,z:t.z};let c=0;if(o&&!r||s){let f=m<u?u:m;c+=f*i*n}a>0&&!s&&(c+=m*l*a*n);let d=m-c;if(d<0&&(d=0),d===m)return t;let p=d/m;return v(t,p)}function U(e){let{velocity:t,wishdir:n,wishspeed:o,accel:r,frametime:s}=e,a=R(t,n),i=o-a;if(i<=0)return t;let u=r*s*o;return u>i&&(u=i),{x:t.x+n.x*u,y:t.y+n.y*u,z:t.z+n.z*u}}function je(e){let{velocity:t,wishdir:n,wishspeed:o,accel:r,frametime:s}=e,a=Math.min(o,30),i=R(t,n),u=a-i;if(u<=0)return t;let l=r*o*s;return l>u&&(l=u),{x:t.x+n.x*l,y:t.y+n.y*l,z:t.z+n.z*l}}function po(e,t){let n=Math.abs(e.forwardmove),o=Math.abs(e.sidemove),r=Math.abs(e.upmove),s=Math.max(n,o,r);if(s===0)return 0;let a=Math.sqrt(e.forwardmove*e.forwardmove+e.sidemove*e.sidemove+e.upmove*e.upmove);return t*s/(127*a)}function Xe(e){let{forward:t,right:n,cmd:o,maxSpeed:r}=e,s={x:t.x*o.forwardmove+n.x*o.sidemove,y:t.y*o.forwardmove+n.y*o.sidemove,z:0},a=w(s);if(a>r){let i=r/a;s=v(s,i),a=r}return{wishdir:a===0?s:A(s),wishspeed:a}}function Ye(e){let{forward:t,right:n,cmd:o,maxSpeed:r}=e,s={x:t.x*o.forwardmove+n.x*o.sidemove,y:t.y*o.forwardmove+n.y*o.sidemove,z:0};o.upmove>10?s=_(s,{x:0,y:0,z:o.upmove}):o.upmove<-10?s=_(s,{x:0,y:0,z:o.upmove}):s=_(s,{x:0,y:0,z:10});let a=w(s);if(a>r){let i=r/a;s=v(s,i),a=r}return a*=.5,{wishdir:a===0?s:A(s),wishspeed:a}}var Vt=5,fo=4,yo=18,xo=.7,Ct=1,bt=2;function ht(e,t,n,o=Vt,r=e){if(t.length===0)return{velocity:e,planes:[],stopped:!1};let s=[],a=e;for(let u of t){if(s.length>=o)return{velocity:g,planes:s,stopped:!0};if(s.find(d=>R(d,u)>.99))continue;s.push(u);let m,c=0;for(;c<s.length;c++){let d=Z(a,s[c],n),p=0;for(;p<s.length&&!(p!==c&&R(d,s[p])<0);p++);if(p===s.length){m=d;break}}if(m)a=m;else{if(s.length!==2)return{velocity:g,planes:s,stopped:!0};let d=Y(s[0],s[1]),p=R(d,a);a=v(d,p)}if(R(a,r)<=0)return{velocity:g,planes:s,stopped:!0}}let i=a.x===0&&a.y===0&&a.z===0;return{velocity:a,planes:s,stopped:i}}function Ze(e){let{origin:t,velocity:n,frametime:o,overbounce:r,trace:s,maxBumps:a=fo,maxClipPlanes:i=Vt,mins:u,maxs:l,hasTime:m=!1}=e,c=t,d=n,p=[],f=n,V=o,x=0;for(let E=0;E<a&&!(d.x===0&&d.y===0&&d.z===0);E++){let b=_(c,v(d,V)),T=s(c,b,u,l);if(T.allsolid){let C=m?f:g;return{origin:T.endpos,velocity:C,planes:p,stopped:!0,blocked:x}}if(T.startsolid){let C=m?f:g;return{origin:T.endpos,velocity:C,planes:p,stopped:!0,blocked:x}}if(T.fraction>0&&(c=T.endpos),T.fraction===1)break;if(!T.planeNormal)return{origin:c,velocity:m?f:g,planes:p,stopped:!0,blocked:x};T.planeNormal.z>.7&&(x|=Ct),T.planeNormal.z===0&&(x|=bt),p.push(T.planeNormal),V-=V*T.fraction;let P=ht(d,p,r,i,f);if(d=P.velocity,p.splice(0,p.length,...P.planes),f.z>0&&d.z<0&&(d={...d,z:0}),P.stopped)return{origin:c,velocity:m?f:d,planes:p,stopped:!0,blocked:x}}let S=m?f:d;return{origin:c,velocity:S,planes:p,stopped:S.x===0&&S.y===0&&S.z===0,blocked:x}}function ee(e){let{mins:t,maxs:n,stepSize:o=yo,...r}=e,s=e.origin,a=e.velocity,i=Ze({...r,mins:t,maxs:n}),u=_(s,{x:0,y:0,z:o}),l=r.trace(s,u,t,n);if(l.allsolid)return{...i,stepped:!1,stepHeight:0};let m=l.endpos.z-s.z,c=Ze({...r,origin:l.endpos,velocity:a,mins:t,maxs:n}),d=_(c.origin,{x:0,y:0,z:-m}),p=r.trace(c.origin,d,t,n),f=c.origin,V=p.planeNormal;p.allsolid||(f=p.endpos);let x=(C,y)=>(C.x-y.x)**2+(C.y-y.y)**2,S=x(i.origin,s),E=x(f,s);if(S>E||V&&V.z<xo)return{...i,stepped:!1,stepHeight:0};let b={...c.velocity,z:i.velocity.z},T=c.blocked,P=b.x===0&&b.y===0&&b.z===0;return{origin:f,velocity:b,planes:c.planes,blocked:T,stopped:P,stepped:!0,stepHeight:m,stepNormal:V}}var ae=["x","y","z"],qe=[{normal:[0,0,1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[0,0,-1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[-1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[0,1,0],mins:[-1,0,-1],maxs:[1,0,1]},{normal:[0,-1,0],mins:[-1,0,-1],maxs:[1,0,1]}],Et={x:0,y:0,z:0};function ie(e){return{x:e.x,y:e.y,z:e.z}}function To(e){return{x:e[0],y:e[1],z:e[2]}}function me(e,t,n){if(n!==0)switch(t){case"x":e.x+=n;break;case"y":e.y+=n;break;case"z":e.z+=n;break}}function Pt(e,t,n){switch(t){case"x":e.x=n;break;case"y":e.y=n;break;case"z":e.z=n;break}}function _e(e,t){switch(t){case"x":return e.x;case"y":return e.y;case"z":default:return e.z}}function _t(e,t,n,o){return e===-1?_e(n,t):e===1?_e(o,t):0}function vt(e,t,n,o){let r=ie(e);for(let s=0;s<ae.length;s++){let a=ae[s],i=t.normal[s];i<0?me(r,a,_e(n,a)):i>0&&me(r,a,_e(o,a))}return r}function So(e,t,n){let o=ie(Et),r=ie(Et);for(let s=0;s<ae.length;s++){let a=ae[s];Pt(o,a,_t(e.mins[s],a,t,n)),Pt(r,a,_t(e.maxs[s],a,t,n))}return{mins:o,maxs:r}}function Vo(e,t,n){if(!t||n===0)return e;let o=ie(e);return me(o,t,n),o}function Co(e,t,n){if(!t||n===0)return e;switch(t){case"x":return{...e,x:e.x+n};case"y":return{...e,y:e.y+n};case"z":default:return{...e,z:e.z+n}}}function $e(e){let{origin:t,mins:n,maxs:o,trace:r}=e;if(!r(t,n,o,t).startsolid)return{result:"good-position",origin:{...t}};let a=[];for(let i=0;i<qe.length;i++){let u=qe[i],{mins:l,maxs:m}=So(u,n,o),c=vt(t,u,n,o),d=r(c,l,m,c),p,f=0;if(d.startsolid)for(let C=0;C<ae.length;C++){if(u.normal[C]!==0)continue;let y=ae[C],z=ie(c);if(me(z,y,1),d=r(z,l,m,z),!d.startsolid){c=z,p=y,f=1;break}if(z=ie(c),me(z,y,-1),d=r(z,l,m,z),!d.startsolid){c=z,p=y,f=-1;break}}if(d.startsolid)continue;let V=qe[i^1],x=vt(t,V,n,o);if(x=Vo(x,p,f),d=r(c,l,m,x),d.startsolid)continue;let S=To(u.normal),E=_(d.endpos??x,v(S,.125)),b=X(E,x),T=_(t,b);T=Co(T,p,f),!r(T,n,o,T).startsolid&&a.push({origin:T,distance:te(b)})}return a.length===0?{result:"no-good-position",origin:{...t}}:(a.sort((i,u)=>i.distance-u.distance),{result:"fixed",origin:{...a[0].origin}})}var bo=100,Qe=200,Nt=150,ve=25,ho=15,Eo=1,Po={x:0,y:0,z:1},_o=(e,t)=>({fraction:1,endpos:t,allsolid:!1,startsolid:!1});function et(e){let t=0,n=0,o=0;return e&262144&&(t+=1),e&524288&&(n+=1),e&1048576&&(t-=1),e&2097152&&(n-=1),e&4194304&&(o+=1),e&8388608&&(o-=1),t===0&&n===0&&o===0?g:{x:t,y:n,z:o}}function At(e){let{watertype:t,waterlevel:n,onGround:o,waterSpeed:r}=e;if((t&16515072)===0)return g;let s=et(t);if(s===g)return g;let a=r;return n===1&&o&&(a*=.5),v(s,a)}function Ft(e){let{groundContents:t,scale:n=bo}=e,o=et(t);return o===g?g:v(o,n)}function Ne(e){let{wishVelocity:t,onLadder:n,onGround:o,waterlevel:r,watertype:s,groundContents:a,cmd:i,viewPitch:u,maxSpeed:l,ladderMod:m,waterSpeed:c,forward:d,origin:p,mins:f,maxs:V,trace:x=_o}=e,S=t;n&&(S=vo({wishVelocity:S,cmd:i,waterlevel:r,viewPitch:u,maxSpeed:l,ladderMod:m,onGround:o,forward:d,origin:p,mins:f,maxs:V,trace:x}));let E=At({watertype:s,waterlevel:r,onGround:o,waterSpeed:c});if(E!==g&&(S=_(S,E)),o){let b=Ft({groundContents:a});b!==g&&(S=_(S,b))}return S}function vo(e){let{wishVelocity:t,cmd:n,waterlevel:o,viewPitch:r,maxSpeed:s,ladderMod:a,onGround:i,forward:u,origin:l,mins:m,maxs:c,trace:d}=e,p=n.buttons??0,f={...t};if((p&24)!==0){let V=Je(o)?s:Qe;f={...f,z:p&8?V:-V}}else if(n.forwardmove){let V=gt(n.forwardmove,-Qe,Qe);if(n.forwardmove>0){let x=r<ho?V:-V;f={...f,z:x}}else i||(f={...f,x:0,y:0}),f={...f,z:V}}else f={...f,z:0};if(!i)if(n.sidemove){let V=gt(n.sidemove,-Nt,Nt);o<2&&(V*=a);let x=A({x:u.x,y:u.y,z:0});if(x.x!==0||x.y!==0){let S=_(l,v(x,Eo)),E=d(l,S,m,c);if(E.fraction!==1&&!E.allsolid&&E.contents!==void 0&&(E.contents&536870912)!==0&&E.planeNormal){let b=Y(E.planeNormal,Po);f={...f,x:0,y:0},f=_(f,v(b,-V))}}}else f={...f,x:zt(f.x),y:zt(f.y)};return f}function gt(e,t,n){return Math.max(t,Math.min(n,e))}function zt(e){return e<-ve?-ve:e>ve?ve:e}var No=1.5,Rt=.5,go=1.01;function zo(e){let{origin:t,cmd:n,frametime:o,pmFriction:r,pmStopSpeed:s,pmMaxSpeed:a,pmAccelerate:i,pmWaterSpeed:u,doclip:l,forward:m,right:c,mins:d,maxs:p,trace:f,overbounce:V=go,stepSize:x,maxBumps:S,maxClipPlanes:E}=e,b=Ao({velocity:e.velocity,pmFriction:r,pmStopSpeed:s,frametime:o}),T=Fo({cmd:n,forward:m,right:c,pmMaxSpeed:a,pmWaterSpeed:u});if(T.wishspeed>0&&(b=U({velocity:b,wishdir:T.wishdir,wishspeed:T.accelSpeed,accel:i,frametime:o})),!l){let P=v(b,o);return{origin:_(t,P),velocity:b,planes:[],blocked:0,stopped:b.x===0&&b.y===0&&b.z===0,stepped:!1,stepHeight:0}}if(!f||!d||!p)throw new Error("applyPmoveFlyMove: doclip=true requires trace/mins/maxs");return ee({origin:t,velocity:b,frametime:o,overbounce:V,trace:f,mins:d,maxs:p,stepSize:x,maxBumps:S,maxClipPlanes:E})}function Ao(e){let{velocity:t,pmFriction:n,pmStopSpeed:o,frametime:r}=e,s=w(t);if(s<1)return{x:0,y:0,z:0};let a=n*No,u=(s<o?o:s)*a*r,l=s-u;return l<0&&(l=0),l===s?t:v(t,l/s)}function Fo(e){let{cmd:t,forward:n,right:o,pmMaxSpeed:r,pmWaterSpeed:s}=e,a=A(n),i=A(o),l={x:a.x*t.forwardmove+i.x*t.sidemove,y:a.y*t.forwardmove+i.y*t.sidemove,z:a.z*t.forwardmove+i.z*t.sidemove},m=t.buttons??0;m&8&&(l=_(l,{x:0,y:0,z:s*Rt})),m&16&&(l=_(l,{x:0,y:0,z:-s*Rt}));let c=w(l),d=c===0?{x:0,y:0,z:0}:A(l);if(c>r){let f=r/c;l=v(l,f),c=r,d=c===0?{x:0,y:0,z:0}:A(l)}let p=c*2;return{wishdir:d,wishspeed:c,accelSpeed:p}}function de(e){let{origin:t,mins:n,viewheight:o,pointContents:r}=e,s=o-n.z,a=s/2,i={x:t.x,y:t.y,z:t.z+n.z+1},u=r(i);if((u&56)===0)return{waterlevel:0,watertype:0};let l=u,m=1,c={x:i.x,y:i.y,z:t.z+n.z+a};if(u=r(c),(u&56)!==0){m=2;let d={x:i.x,y:i.y,z:t.z+n.z+s};u=r(d),(u&56)!==0&&(m=3)}return{waterlevel:m,watertype:l}}var Ro=270;function Oo(e,t){return(e&t)!==0}function Mo(e){let{pmFlags:t,pmType:n,buttons:o,waterlevel:r,onGround:s,velocity:a,jumpHeight:i=Ro}=e;if(t&16)return{pmFlags:t,onGround:s,velocity:a,jumpSound:!1,jumped:!1};let u=Oo(o,8),l=t,m=s,c=!1,d=!1,p=a;if(!u)return l=G(l,2),{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:d};if(Lo(l))return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:d};if(n===4)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:d};if(r>=2)return m=!1,{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:d};if(!m)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:d};l=W(l,2),l=G(l,4),m=!1,c=!0,d=!0;let f=a.z+i,V=f<i?i:f;return p={...a,z:V},{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:d}}function Lo(e){return(e&2)!==0}function ge(e,t,n){return{x:e,y:t,z:n}}function ze(e,t){let n=ge(-16,-16,0),o=ge(16,16,16);if(e===5)return{mins:n,maxs:o,viewheight:8};let r=e===4||(t&1)!==0,s=ge(n.x,n.y,-24),a=ge(o.x,o.y,r?4:32);return{mins:s,maxs:a,viewheight:r?-2:22}}var wo=4,Do=32,Wo=8;function ko(e){let{pmType:t}=e;if(t===5){let a=ze(t,e.pmFlags);return{pmFlags:e.pmFlags,ducked:O(e.pmFlags,1),changed:!1,...a}}let n=e.pmFlags,o=!1;t===4?O(n,1)||(n=W(n,1),o=!0):Io(e)?!O(n,1)&&!Bo(e)&&(n=W(n,1),o=!0):O(n,1)&&!Go(e)&&(n=G(n,1),o=!0);let r=ze(t,n),s=t===4||O(n,1);return{pmFlags:n,ducked:s,changed:o,...r}}function Io(e){return(e.buttons&16)===0||e.onLadder||e.n64Physics?!1:!!(e.hasGroundEntity||e.waterlevel<=1&&!Uo(e))}function Bo(e){return e.trace({start:e.origin,end:e.origin,mins:e.mins,maxs:Ot(e.maxs,wo),mask:3}).allsolid}function Go(e){return e.trace({start:e.origin,end:e.origin,mins:e.mins,maxs:Ot(e.maxs,Do),mask:3}).allsolid}function Uo(e){let t={x:e.origin.x,y:e.origin.y,z:e.origin.z-Wo};return e.trace({start:e.origin,end:t,mins:e.mins,maxs:e.maxs,mask:3}).fraction<1?!1:e.trace({start:e.origin,end:t,mins:e.mins,maxs:e.maxs,mask:56}).fraction<1}function Ot(e,t){return{x:e.x,y:e.y,z:t}}var Ho=.25,Jo=180,Ko=100,jo=.7,Xo=.9,Yo=64,Zo=128,qo=1.01,$o=1080;function Qo(e){let{pmType:t,n64Physics:n,velocity:o,startVelocity:r,origin:s,mins:a,maxs:i,viewheight:u,trace:l,pointContents:m}=e,c=e.pmFlags,d=e.pmTime,p,f=O(c,4),V,x=0;if(o.z>Jo||t===1)c=G(c,4),f=!1;else{let T={x:s.x,y:s.y,z:s.z-Ho},P=l(s,T,a,i);V=P,x=P.contents??0;let C=P.planeNormal,y=P.fraction<1&&!!C&&C.z<jo;if(y&&C){let z=_(s,C),k=l(s,z,a,i);k.fraction<1&&!k.startsolid&&(y=!1)}if(P.fraction===1||!C||y&&!P.startsolid)c=G(c,4),f=!1;else{f=!0,O(c,8)&&(c&=~$o,d=0);let z=O(c,4);if(!z){!n&&o.z>=Ko&&C.z>=Xo&&!O(c,1)&&(c=W(c,1024),d=Yo);let k=Z(o,C,qo);p=r.z-k.z}c=W(c,4),!z&&(n||O(c,1))&&(c=W(c,16),d=Zo)}}let{waterlevel:E,watertype:b}=de({origin:s,mins:a,viewheight:u,pointContents:m});return{pmFlags:c,pmTime:d,onGround:O(c,4),groundTrace:V,groundContents:x,waterlevel:E,watertype:b,impactDelta:p}}var Mt=1,er=60,tt=1.01;function tr(e){let{origin:t,frametime:n,mins:o,maxs:r,trace:s,overbounce:a=tt,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:d,cmd:p,pmFlags:f,onGround:V,gravity:x,pmType:S,pmAccelerate:E,pmAirAccelerate:b=Mt,pmMaxSpeed:T,pmDuckSpeed:P,onLadder:C,waterlevel:y,watertype:z,groundContents:k,viewPitch:I,ladderMod:N,pmWaterSpeed:M}=e,h={...e.velocity},D=or(c,d,p);D=Ne({wishVelocity:D,onLadder:C,onGround:V,waterlevel:y,watertype:z,groundContents:k,cmd:p,viewPitch:I,maxSpeed:O(f,1)?P:T,ladderMod:N,waterSpeed:M,forward:c,origin:t,mins:o,maxs:r,trace:s});let L=O(f,1)?P:T,B=D,F=w(B);if(F!==0&&(B=A(B)),F>L){let K=L/F;D=v(D,K),F=L,F!==0&&(B=A(D))}return C?(h=U({velocity:h,wishdir:B,wishspeed:F,accel:E,frametime:n}),Math.abs(D.z)<Number.EPSILON&&(h=ar(h,x,n)),Ae({origin:t,velocity:h,frametime:n,mins:o,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):V?(h={...h,z:0},h=U({velocity:h,wishdir:B,wishspeed:F,accel:E,frametime:n}),x>0?h={...h,z:0}:h={...h,z:h.z-x*n},h.x===0&&h.y===0?{origin:t,velocity:h,planes:[],blocked:0,stopped:!0,stepped:!1,stepHeight:0}:Ae({origin:t,velocity:h,frametime:n,mins:o,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):(b>0?h=je({velocity:h,wishdir:B,wishspeed:F,accel:b,frametime:n}):h=U({velocity:h,wishdir:B,wishspeed:F,accel:Mt,frametime:n}),S!==1&&(h={...h,z:h.z-x*n}),Ae({origin:t,velocity:h,frametime:n,mins:o,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m}))}function nr(e){let{origin:t,frametime:n,mins:o,maxs:r,trace:s,overbounce:a=tt,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:d,cmd:p,pmFlags:f,onGround:V,pmMaxSpeed:x,pmDuckSpeed:S,pmWaterAccelerate:E,pmWaterSpeed:b,onLadder:T,watertype:P,groundContents:C,waterlevel:y,viewPitch:z,ladderMod:k}=e,I={...e.velocity},N=rr(c,d,p);sr(p,V)?N={...N,z:N.z-er}:Lt(p,16)?N=_(N,{x:0,y:0,z:-b*.5}):Lt(p,8)&&(N=_(N,{x:0,y:0,z:b*.5})),N=Ne({wishVelocity:N,onLadder:T,onGround:V,waterlevel:y,watertype:P,groundContents:C,cmd:p,viewPitch:z,maxSpeed:O(f,1)?S:x,ladderMod:k,waterSpeed:b,forward:c,origin:t,mins:o,maxs:r,trace:s});let M=N,h=w(M);if(h!==0&&(M=A(M)),h>x){let H=x/h;N=v(N,H),h=x,h!==0&&(M=A(N))}if(h*=.5,O(f,1)&&h>S){let H=S/h;N=v(N,H),h=S,h!==0&&(M=A(N))}return I=U({velocity:I,wishdir:M,wishspeed:h,accel:E,frametime:n}),Ae({origin:t,velocity:I,frametime:n,mins:o,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})}function or(e,t,n){return{x:e.x*n.forwardmove+t.x*n.sidemove,y:e.y*n.forwardmove+t.y*n.sidemove,z:0}}function rr(e,t,n){return{x:e.x*n.forwardmove+t.x*n.sidemove,y:e.y*n.forwardmove+t.y*n.sidemove,z:e.z*n.forwardmove+t.z*n.sidemove}}function Lt(e,t){return!!((e.buttons??0)&t)}function sr(e,t){let n=e.forwardmove===0&&e.sidemove===0,o=!((e.buttons??0)&24);return n&&o&&!t}function ar(e,t,n){let o=e.z,r=t*n;return o>0?(o-=r,o<0&&(o=0)):(o+=r,o>0&&(o=0)),{...e,z:o}}function Ae(e){let{origin:t,velocity:n,frametime:o,mins:r,maxs:s,trace:a,overbounce:i=tt,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c}=e;return ee({origin:t,velocity:n,frametime:o,trace:a,mins:r,maxs:s,overbounce:i,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c})}var ir=1,cr=40,Fe=50,wt=350,lr=2048,Dt=.1,ur=800,mr=50,Wt=.7,dr=18,pr=1.01,fr=2;function yr(e){let{pmFlags:t,pmTime:n,waterlevel:o,watertype:r,gravity:s,cmd:a,forward:i,origin:u,velocity:l,mins:m,maxs:c,viewheight:d,trace:p,pointContents:f,onGround:V,overbounce:x=pr,stepSize:S=dr,maxBumps:E,maxClipPlanes:b}=e;if(n>0)return{pmFlags:t,pmTime:n,velocity:l,performedWaterJump:!1};let T=G(t,128),P=n,C=l,y=A({x:i.x,y:i.y,z:0}),z=te(y)>0;if(o<2&&z){let F=_(u,v(y,ir)),K=p(u,F,m,c),kt=K.contents??0;K.fraction<1&&(kt&536870912)!==0&&(T=W(T,128))}if(s===0)return{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1};if(((a.buttons??0)&8)===0&&a.forwardmove<=0)return{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1};if(o!==2)return{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1};if((r&8192)!==0)return{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1};if(!z)return{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1};let k=_(u,v(y,cr)),I=p(u,k,m,c);if(I.fraction===1||!I.planeNormal||I.planeNormal.z>=Wt)return{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1};let N={x:y.x*Fe,y:y.y*Fe,z:wt},M=u,h=!0,D=xr(s);for(let F=0;F<D;F++){N={x:N.x,y:N.y,z:N.z-s*Dt},N.z<0&&(h=!1);let K=ee({origin:M,velocity:N,frametime:Dt,trace:p,mins:m,maxs:c,overbounce:x,stepSize:S,maxBumps:E,maxClipPlanes:b,hasTime:h});M=K.origin,N=K.velocity}let H=_(M,{x:0,y:0,z:-fr}),L=p(M,H,m,c);return L.fraction===1||!L.planeNormal||L.planeNormal.z<Wt||L.endpos.z<u.z?{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1}:V&&Math.abs(u.z-L.endpos.z)<=S?{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1}:de({origin:L.endpos,mins:m,viewheight:d,pointContents:f}).waterlevel>=2?{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!1}:(T=W(T,8),P=lr,C={x:y.x*Fe,y:y.y*Fe,z:wt},{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!0})}function xr(e){if(e===0)return 0;let t=Math.floor(10*(ur/e));return t<=0?0:Math.min(mr,t)}var nt=[0,-1,1];function ot(e){let{origin:t,mins:n,maxs:o,trace:r}=e;return!r(t,t,n,o).allsolid}function Tr(e){let{origin:t,velocity:n,mins:o,maxs:r,previousOrigin:s,trace:a}=e;if(ot({origin:t,mins:o,maxs:r,trace:a}))return{origin:{...t},velocity:{...n},resolution:"unchanged"};let i=$e({origin:t,mins:o,maxs:r,trace:(u,l,m,c)=>a(u,c,l,m)});return i.result==="fixed"||i.result==="good-position"?{origin:i.origin,velocity:{...n},resolution:"fixed"}:{origin:{...s},velocity:{...n},resolution:"reverted"}}function Sr(e){let{origin:t,mins:n,maxs:o,trace:r}=e;for(let s of nt)for(let a of nt)for(let i of nt){let u={x:t.x+i,y:t.y+a,z:t.z+s};if(ot({origin:u,mins:n,maxs:o,trace:r}))return{origin:u,snapped:i!==0||a!==0||s!==0}}return{origin:{...t},snapped:!1}}function Vr(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function Cr(e){return e>89&&e<180?89:e<271&&e>=180?271:e}function br(e){let{pmFlags:t,cmdAngles:n,deltaAngles:o}=e,r;(t&32)!==0?r={x:0,y:n.y+o.y,z:0}:(r=Vr(n,o),r={...r,x:Cr(r.x)});let s=Le(r);return{viewangles:r,...s}}var hr=200,Er=200,Pr=200,_r=140,vr=150,Nr=3;function gr(e){let t=le(e);return t>89&&t<180?89:t<271&&t>=180?271:t}function zr(e,t){return{x:gr(e.x+t.x),y:le(e.y+t.y),z:le(e.z+t.z)}}function Ar(e,t){let n=t.sensitivityX??t.sensitivity,o=(t.sensitivityY??t.sensitivity)*(t.invertY?-1:1);return{x:e.deltaY*o,y:e.deltaX*n,z:0}}var pe=.025,Fr=(e,t)=>{let n={...e.origin};n.z-=.25;let o=t(e.origin,n);return{...e,onGround:o.fraction<1}},Rr=(e,t)=>{let n={...e.origin};return n.z+=e.mins.z+1,t(n)&33554432?{...e,waterLevel:1}:{...e,waterLevel:0}},Or=(e,t,n,o)=>{let r={...e};r=Fr(r,n),r=Rr(r,o);let{origin:s,velocity:a,onGround:i,waterLevel:u}=r,l=Ke({velocity:a,frametime:pe,onGround:i,groundIsSlick:!1,onLadder:!1,waterlevel:u,pmFriction:6,pmStopSpeed:100,pmWaterFriction:1}),m=u>=2?Ye({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:t,maxSpeed:320}):Xe({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:t,maxSpeed:320}),c=U({velocity:l,wishdir:m.wishdir,wishspeed:m.wishspeed,accel:i?10:1,frametime:pe}),d=n(s,{x:s.x+c.x*pe,y:s.y+c.y*pe,z:s.z+c.z*pe});return{...r,origin:d.endpos,velocity:c}};return Jt(Mr);})();
1
+ "use strict";var Quake2Shared=(()=>{var Fe=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var jt=(t,e)=>{for(var o in e)Fe(t,o,{get:e[o],enumerable:!0})},Yt=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Jt(e))!Xt.call(t,r)&&r!==o&&Fe(t,r,{get:()=>e[r],enumerable:!(n=Kt(e,r))||n.enumerable});return t};var Zt=t=>Yt(Fe({},"__esModule",{value:!0}),t);var Wr={};jt(Wr,{BinaryStream:()=>st,CGAME_EXPORT_KEYS:()=>xn,CGAME_IMPORT_KEYS:()=>yn,CONTENTS_AREAPORTAL:()=>es,CONTENTS_AUX:()=>jr,CONTENTS_CURRENT_0:()=>No,CONTENTS_CURRENT_180:()=>go,CONTENTS_CURRENT_270:()=>Ro,CONTENTS_CURRENT_90:()=>Eo,CONTENTS_CURRENT_DOWN:()=>vo,CONTENTS_CURRENT_UP:()=>Oo,CONTENTS_DEADMONSTER:()=>ss,CONTENTS_DETAIL:()=>as,CONTENTS_LADDER:()=>dt,CONTENTS_LAVA:()=>Yr,CONTENTS_MIST:()=>$r,CONTENTS_MONSTER:()=>rs,CONTENTS_MONSTERCLIP:()=>os,CONTENTS_NONE:()=>Te,CONTENTS_NO_WATERJUMP:()=>Ao,CONTENTS_ORIGIN:()=>ns,CONTENTS_PLAYER:()=>cs,CONTENTS_PLAYERCLIP:()=>ts,CONTENTS_PROJECTILE:()=>ls,CONTENTS_PROJECTILECLIP:()=>Qr,CONTENTS_SLIME:()=>Zr,CONTENTS_SOLID:()=>Jr,CONTENTS_TRANSLUCENT:()=>is,CONTENTS_TRIGGER:()=>_o,CONTENTS_WATER:()=>qr,CONTENTS_WINDOW:()=>Xr,CS_MAX_STRING_LENGTH:()=>Js,CS_MAX_STRING_LENGTH_OLD:()=>Xs,ClientCommand:()=>Gt,CollisionEntityIndex:()=>Be,ConfigStringIndex:()=>re,CvarFlags:()=>bt,DEFAULT_FORWARD_SPEED:()=>Er,DEFAULT_MOUSE_SENSITIVITY:()=>zr,DEFAULT_PITCH_SPEED:()=>vr,DEFAULT_SIDE_SPEED:()=>gr,DEFAULT_UP_SPEED:()=>Rr,DEFAULT_YAW_SPEED:()=>Or,DEG2RAD:()=>po,DIST_EPSILON:()=>J,GAME_EXPORT_KEYS:()=>pn,GAME_IMPORT_KEYS:()=>fn,LAST_VISIBLE_CONTENTS:()=>us,MASK_ALL:()=>As,MASK_BLOCK_SIGHT:()=>vs,MASK_CURRENT:()=>zo,MASK_DEADSOLID:()=>Es,MASK_LADDER_NAV_SOLID:()=>Fs,MASK_MONSTERSOLID:()=>gs,MASK_NAV_SOLID:()=>zs,MASK_OPAQUE:()=>Rs,MASK_PLAYERSOLID:()=>Ns,MASK_PROJECTILE:()=>Ls,MASK_SHOT:()=>Os,MASK_SOLID:()=>De,MASK_WALK_NAV_SOLID:()=>Ms,MASK_WATER:()=>Pe,MAX_CLIENTS:()=>en,MAX_CONFIGSTRINGS:()=>ln,MAX_EDICTS:()=>Ks,MAX_GENERAL:()=>an,MAX_IMAGES:()=>rn,MAX_ITEMS:()=>sn,MAX_LIGHTSTYLES:()=>tn,MAX_MODELS:()=>on,MAX_OSPATH:()=>Hs,MAX_QPATH:()=>Us,MAX_SHADOW_LIGHTS:()=>cn,MAX_SOUNDS:()=>nn,MAX_STRING_CHARS:()=>Bs,MAX_STRING_TOKENS:()=>ks,MAX_TOKEN_CHARS:()=>Gs,MAX_WHEEL_ITEMS:()=>Ke,MersenneTwister19937:()=>be,PITCH:()=>Se,PlaneSide:()=>mt,PlayerButton:()=>ee,PmFlag:()=>Q,PmType:()=>ae,RAD2DEG:()=>yo,ROLL:()=>Le,RandomGenerator:()=>Ve,SLIDEMOVE_BLOCKED_FLOOR:()=>Pt,SLIDEMOVE_BLOCKED_WALL:()=>Ct,STOP_EPSILON:()=>j,SURF_ALPHATEST:()=>Vs,SURF_FLOWING:()=>hs,SURF_LIGHT:()=>ms,SURF_N64_SCROLL_FLIP:()=>_s,SURF_N64_SCROLL_X:()=>Ps,SURF_N64_SCROLL_Y:()=>Cs,SURF_N64_UV:()=>Ts,SURF_NODRAW:()=>bs,SURF_NONE:()=>ds,SURF_SKY:()=>ps,SURF_SLICK:()=>fs,SURF_TRANS33:()=>xs,SURF_TRANS66:()=>Ss,SURF_WARP:()=>ys,ServerCommand:()=>kt,TempEntity:()=>Ut,WaterLevel:()=>se,YAW:()=>he,ZERO_VEC3:()=>R,addBlendColor:()=>bo,addContents:()=>Lo,addPmFlag:()=>W,addPointToBounds:()=>so,addVec3:()=>N,addViewAngles:()=>Mr,angleMod:()=>ue,angleVectors:()=>we,applyPmove:()=>Ir,applyPmoveAccelerate:()=>H,applyPmoveAddCurrents:()=>ge,applyPmoveAirAccelerate:()=>je,applyPmoveAirMove:()=>ar,applyPmoveFlyMove:()=>Mn,applyPmoveFriction:()=>Xe,applyPmoveWaterMove:()=>ir,assertContract:()=>mn,boxContents:()=>Xo,boxOnPlaneSide:()=>Go,boxesIntersect:()=>ao,buildAirGroundWish:()=>Ye,buildCollisionModel:()=>Bo,buildWaterWish:()=>Ze,categorizePosition:()=>rr,checkDuckState:()=>Hn,checkJump:()=>Wn,checkSpecialMovement:()=>Vr,clampViewAngles:()=>Nr,clipBoxToBrush:()=>Ge,clipVelocityAgainstPlanes:()=>io,clipVelocityVec3:()=>q,closestPointToBox:()=>oo,combineSurfaceFlags:()=>Io,computePlaneSignBits:()=>ke,computePlayerDimensions:()=>Oe,concatRotationMatrices:()=>Me,configStringSize:()=>un,createDefaultTrace:()=>_e,createEmptyBounds3:()=>ro,createMat4Identity:()=>ut,createRandomGenerator:()=>Vo,crossVec3:()=>Z,currentVectorFromContents:()=>tt,degToRad:()=>ye,distance:()=>eo,distanceBetweenBoxesSquared:()=>no,dotVec3:()=>F,fixStuckObjectGeneric:()=>Qe,getWaterLevel:()=>fe,goodPosition:()=>rt,groundCurrentVelocity:()=>Ft,hasAllContents:()=>Fo,hasAnyContents:()=>Mo,hasPmFlag:()=>M,hasSurfaceFlags:()=>Do,inPHS:()=>Yo,inPVS:()=>jo,initialSnapPosition:()=>Cr,isAtLeastWaistDeep:()=>Je,isUnderwater:()=>Sn,lengthSquaredVec3:()=>oe,lengthVec3:()=>D,lerpAngle:()=>xo,mat4FromBasis:()=>Co,mouseDeltaToViewDelta:()=>Lr,multiplyMat4:()=>To,multiplyVec3:()=>$t,negateVec3:()=>Qt,normalizeVec3:()=>v,perpendicularVec3:()=>it,planeDistanceToPoint:()=>$,pmoveCmdScale:()=>hn,pointContents:()=>Ko,pointContentsMany:()=>Jo,pointInsideBrush:()=>ft,pointOnPlaneSide:()=>ko,projectPointOnPlane:()=>at,projectSourceVec3:()=>lo,projectSourceVec3WithUp:()=>uo,radToDeg:()=>xe,removeContents:()=>wo,removePmFlag:()=>U,resolveSlideMove:()=>_t,rotatePointAroundVector:()=>fo,scaleVec3:()=>E,slerpVec3:()=>mo,slideClipVelocityVec3:()=>co,slideMove:()=>qe,snapPosition:()=>Pr,stepSlideMove:()=>te,subtractVec3:()=>Y,testBoxInBrush:()=>pt,traceBox:()=>ht,transformPointMat4:()=>Po,validateContract:()=>Vt,vec3Equals:()=>to,vectorToAngles:()=>ho,vectorToYaw:()=>So,waterCurrentVelocity:()=>zt});var R={x:0,y:0,z:0},j=.1,qt=Math.PI/180;function N(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function Y(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function $t(t,e){return{x:t.x*e.x,y:t.y*e.y,z:t.z*e.z}}function E(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}function Qt(t){return E(t,-1)}function F(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function Z(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}function oe(t){return F(t,t)}function D(t){return Math.sqrt(oe(t))}function eo(t,e){return D(Y(t,e))}function to(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z}function v(t){let e=D(t);return e===0?t:E(t,1/e)}function at(t,e){let o=1/F(e,e),n=F(e,t)*o;return Y(t,E(e,o*n))}function it(t){let e=0,o=Math.abs(t.x);return Math.abs(t.y)<o&&(e=1,o=Math.abs(t.y)),Math.abs(t.z)<o&&(e=2),v(at(e===0?{x:1,y:0,z:0}:e===1?{x:0,y:1,z:0}:{x:0,y:0,z:1},t))}function oo(t,e,o){return{x:t.x<e.x?e.x:t.x>o.x?o.x:t.x,y:t.y<e.y?e.y:t.y>o.y?o.y:t.y,z:t.z<e.z?e.z:t.z>o.z?o.z:t.z}}function no(t,e,o,n){let r=0;if(e.x<o.x){let s=e.x-o.x;r+=s*s}else if(t.x>n.x){let s=t.x-n.x;r+=s*s}if(e.y<o.y){let s=e.y-o.y;r+=s*s}else if(t.y>n.y){let s=t.y-n.y;r+=s*s}if(e.z<o.z){let s=e.z-o.z;r+=s*s}else if(t.z>n.z){let s=t.z-n.z;r+=s*s}return r}function ro(){return{mins:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY,z:Number.POSITIVE_INFINITY},maxs:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY,z:Number.NEGATIVE_INFINITY}}}function so(t,e){return{mins:{x:Math.min(e.mins.x,t.x),y:Math.min(e.mins.y,t.y),z:Math.min(e.mins.z,t.z)},maxs:{x:Math.max(e.maxs.x,t.x),y:Math.max(e.maxs.y,t.y),z:Math.max(e.maxs.z,t.z)}}}function ao(t,e){return t.mins.x<=e.maxs.x&&t.maxs.x>=e.mins.x&&t.mins.y<=e.maxs.y&&t.maxs.y>=e.mins.y&&t.mins.z<=e.maxs.z&&t.maxs.z>=e.mins.z}function q(t,e,o){let n=F(t,e)*o,r=t.x-e.x*n,s=t.y-e.y*n,a=t.z-e.z*n;return r>-j&&r<j&&(r=0),s>-j&&s<j&&(s=0),a>-j&&a<j&&(a=0),{x:r,y:s,z:a}}function io(t,e,o,n){if(e.length===0)return t;let r=t;for(let s=0;s<e.length;s++){r=q(r,e[s],o);let a=0;for(;a<e.length&&!(a!==s&&F(r,e[a])<0);a++);if(a===e.length)return n&&F(r,n)<=0?R:r}if(e.length===2){let s=Z(e[0],e[1]),a=F(s,t),i=E(s,a);return n&&F(i,n)<=0?R:i}return n&&F(r,n)<=0,R}function co(t,e,o){return q(t,e,o)}function lo(t,e,o,n){return{x:t.x+o.x*e.x+n.x*e.y,y:t.y+o.y*e.x+n.y*e.y,z:t.z+o.z*e.x+n.z*e.y+e.z}}function uo(t,e,o,n,r){return{x:t.x+o.x*e.x+n.x*e.y+r.x*e.z,y:t.y+o.y*e.x+n.y*e.y+r.y*e.z,z:t.z+o.z*e.x+n.z*e.y+r.z*e.z}}function mo(t,e,o){let n=F(t,e),r,s;if(Math.abs(n)>.9995)r=1-o,s=o;else{let a=Math.acos(n),i=Math.sin(a),u=Math.sin((1-o)*a),l=Math.sin(o*a);r=u/i,s=l/i}return{x:t.x*r+e.x*s,y:t.y*r+e.y*s,z:t.z*r+e.z*s}}function Me(t,e){let o=r=>[t[r][0]*e[0][0]+t[r][1]*e[1][0]+t[r][2]*e[2][0],t[r][0]*e[0][1]+t[r][1]*e[1][1]+t[r][2]*e[2][1],t[r][0]*e[0][2]+t[r][1]*e[1][2]+t[r][2]*e[2][2]];return[o(0),o(1),o(2)]}function fo(t,e,o){if(D(t)===0)return e;let r=v(t),s=it(r),a=Z(s,r),i=[[s.x,a.x,r.x],[s.y,a.y,r.y],[s.z,a.z,r.z]],u=[[i[0][0],i[1][0],i[2][0]],[i[0][1],i[1][1],i[2][1]],[i[0][2],i[1][2],i[2][2]]],l=o*qt,m=Math.cos(l),c=Math.sin(l),f=[[m,c,0],[-c,m,0],[0,0,1]],p=Me(Me(i,f),u);return{x:p[0][0]*e.x+p[0][1]*e.y+p[0][2]*e.z,y:p[1][0]*e.x+p[1][1]*e.y+p[1][2]*e.z,z:p[2][0]*e.x+p[2][1]*e.y+p[2][2]*e.z}}var Se=0,he=1,Le=2,ct=Math.PI/180,lt=180/Math.PI,po=ct,yo=lt;function le(t,e){switch(e){case Se:return t.x;case he:return t.y;case Le:default:return t.z}}function ye(t){return t*ct}function xe(t){return t*lt}function xo(t,e,o){let n=e;return n-t>180?n-=360:n-t<-180&&(n+=360),t+o*(n-t)}function ue(t){let e=t%360;return e<0?360+e:e}function we(t){let e=ye(le(t,he)),o=ye(le(t,Se)),n=ye(le(t,Le)),r=Math.sin(e),s=Math.cos(e),a=Math.sin(o),i=Math.cos(o),u=Math.sin(n),l=Math.cos(n),m={x:i*s,y:i*r,z:-a},c={x:-u*a*s-l*-r,y:-u*a*r-l*s,z:-u*i},f={x:l*a*s-u*-r,y:l*a*r-u*s,z:l*i};return{forward:m,right:c,up:f}}function So(t){let e=le(t,Se),o=le(t,he);if(e===0)return o===0?0:o>0?90:270;let n=xe(Math.atan2(o,e));return n<0?n+360:n}function ho(t){let e=t.x,o=t.y,n=t.z;if(o===0&&e===0)return{x:n>0?-90:-270,y:0,z:0};let r;e?r=xe(Math.atan2(o,e)):o>0?r=90:r=270,r<0&&(r+=360);let s=Math.sqrt(e*e+o*o),a=xe(Math.atan2(n,s));return a<0&&(a+=360),{x:-a,y:r,z:0}}function bo(t,e,o,n,r){if(n<=0)return r;let s=r[0],a=r[1],i=r[2],u=r[3],l=u+(1-u)*n;if(l<=0)return[0,0,0,0];let m=u/l,c=s*m+t*(1-m),f=a*m+e*(1-m),p=i*m+o*(1-m);return[c,f,p,l]}var be=class{constructor(e=5489){this.state=new Uint32Array(624);this.index=624;this.seed(e)}seed(e){this.state[0]=e>>>0;for(let o=1;o<624;o++){let n=this.state[o-1]^this.state[o-1]>>>30,r=Math.imul(n>>>0,1812433253)+o;this.state[o]=r>>>0}this.index=624}nextUint32(){this.index>=624&&this.twist();let e=this.state[this.index++];return e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0}twist(){for(let e=0;e<624;e++){let o=this.state[e]&2147483648|this.state[(e+1)%624]&2147483647,n=this.state[(e+397)%624]^o>>>1;(o&1)!==0&&(n^=2567483615),this.state[e]=n>>>0}this.index=0}getState(){return{index:this.index,state:Array.from(this.state)}}setState(e){if(e.state.length!==624)throw new Error(`Expected 624 MT state values, received ${e.state.length}`);this.index=e.index,this.state=Uint32Array.from(e.state,o=>o>>>0)}},Ve=class{constructor(e={}){this.mt=new be(e.seed)}frandom(){return this.mt.nextUint32()/4294967296}frandomRange(e,o){return e+(o-e)*this.frandom()}frandomMax(e){return this.frandomRange(0,e)}crandom(){return this.frandomRange(-1,1)}crandomOpen(){let e=Number.EPSILON;return this.frandomRange(-1+e,1)}irandomUint32(){return this.mt.nextUint32()}irandomRange(e,o){if(o-e<=1)return e;let n=o-e,r=4294967296-4294967296%n,s;do s=this.mt.nextUint32();while(s>=r);return e+s%n}irandom(e){return e<=0?0:this.irandomRange(0,e)}randomTimeRange(e,o){return o<=e?e:this.irandomRange(e,o)}randomTime(e){return this.irandom(e)}randomIndex(e){return this.irandom(e.length)}getState(){return{mt:this.mt.getState()}}setState(e){this.mt.setState(e.mt)}};function Vo(t){return new Ve(t)}function ut(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function To(t,e){let o=new Float32Array(16);for(let n=0;n<4;n+=1)for(let r=0;r<4;r+=1)o[r*4+n]=t[0+n]*e[r*4+0]+t[4+n]*e[r*4+1]+t[8+n]*e[r*4+2]+t[12+n]*e[r*4+3];return o}function Po(t,e){let o=e.x,n=e.y,r=e.z;return{x:t[0]*o+t[4]*n+t[8]*r+t[12],y:t[1]*o+t[5]*n+t[9]*r+t[13],z:t[2]*o+t[6]*n+t[10]*r+t[14]}}function Co(t,e){let o=ut();return o[0]=e[0].x,o[1]=e[0].y,o[2]=e[0].z,o[4]=e[1].x,o[5]=e[1].y,o[6]=e[1].z,o[8]=e[2].x,o[9]=e[2].y,o[10]=e[2].z,o[12]=t.x,o[13]=t.y,o[14]=t.z,o}var Te=0,Jr=1,Xr=2,jr=4,Yr=8,Zr=16,qr=32,$r=64,_o=1073741824,Ao=8192,Qr=16384,es=32768,ts=65536,os=131072,No=262144,Eo=524288,go=1048576,Ro=2097152,Oo=4194304,vo=8388608,ns=16777216,rs=33554432,ss=67108864,as=134217728,is=268435456,dt=536870912,cs=1073741824,ls=-2147483648,us=64,ds=0,ms=1,fs=2,ps=4,ys=8,xs=16,Ss=32,hs=64,bs=128,Vs=33554432,Ts=268435456,Ps=536870912,Cs=1073741824,_s=-2147483648,As=4294967295,De=3,Ns=1107361795,Es=65539,gs=1107427331,Pe=56,Rs=25,Os=1174405123,zo=16515072,vs=1107296281,zs=65539,Fs=3,Ms=196611,Ls=1174421507;function Fo(t,e){return(t&e)===e}function Mo(t,e){return(t&e)!==0}function Lo(t,e){return t|e}function wo(t,e){return t&~e}function Do(t,e){return(t&e)===e}function Io(...t){let e=0;for(let o of t)e|=o;return e}var mt=(n=>(n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n[n.CROSS=3]="CROSS",n))(mt||{}),J=.03125,Wo=Number.MAX_SAFE_INTEGER-1,Ce=1;function Bo(t){let e=t.planes.map(a=>({...a,signbits:ke(a.normal)})),o=t.nodes.map(a=>({plane:e[a.planenum],children:a.children})),n=t.brushes.map(a=>{let i=t.brushSides.slice(a.firstSide,a.firstSide+a.numSides).map(u=>({plane:e[u.planenum],surfaceFlags:u.surfaceFlags}));return{contents:a.contents,sides:i,checkcount:0}}),r=t.leaves.map(a=>({contents:a.contents,cluster:a.cluster,area:a.area,firstLeafBrush:a.firstLeafBrush,numLeafBrushes:a.numLeafBrushes})),s=t.bmodels.map(a=>({mins:a.mins,maxs:a.maxs,origin:a.origin,headnode:a.headnode}));return{planes:e,nodes:o,leaves:r,brushes:n,leafBrushes:t.leafBrushes,bmodels:s,visibility:t.visibility}}function ke(t){let e=0;return t.x<0&&(e|=1),t.y<0&&(e|=2),t.z<0&&(e|=4),e}function $(t,e){return t.normal.x*e.x+t.normal.y*e.y+t.normal.z*e.z-t.dist}function ko(t,e,o=0){let n=$(t,e);return n>o?1:n<-o?2:3}function Go(t,e,o,n=0){let r,s;switch(o.signbits){case 0:r=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*e.z,s=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*t.z;break;case 1:r=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*e.z,s=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*t.z;break;case 2:r=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*e.z,s=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*t.z;break;case 3:r=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*e.z,s=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*t.z;break;case 4:r=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*t.z,s=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*e.z;break;case 5:r=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*t.z,s=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*e.z;break;case 6:r=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*t.z,s=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*e.z;break;default:r=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*t.z,s=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*e.z;break}let a=0;return r-o.dist>=-n&&(a=1),s-o.dist<=n&&(a|=2),a}function ft(t,e,o=J){for(let n of e.sides)if($(n.plane,t)>o)return!1;return!0}function pt(t,e,o,n){for(let r of n.sides){let s=r.plane.normal.x*(r.plane.normal.x<0?o.x:e.x)+r.plane.normal.y*(r.plane.normal.y<0?o.y:e.y)+r.plane.normal.z*(r.plane.normal.z<0?o.z:e.z),a=r.plane.dist-s;if(t.x*r.plane.normal.x+t.y*r.plane.normal.y+t.z*r.plane.normal.z-a>0)return{startsolid:!1,allsolid:!1,contents:0}}return{startsolid:!0,allsolid:!0,contents:n.contents}}function Ge({start:t,end:e,mins:o,maxs:n,brush:r,trace:s}){if(r.sides.length===0)return;let a=o.x===0&&o.y===0&&o.z===0&&n.x===0&&n.y===0&&n.z===0,i=-1,u=1,l=null,m=null,c=!1,f=!1;for(let p of r.sides){let{plane:y}=p,T=y.dist;if(!a){let A=y.normal.x<0?n.x:o.x,C=y.normal.y<0?n.y:o.y,b=y.normal.z<0?n.z:o.z;T-=y.normal.x*A+y.normal.y*C+y.normal.z*b}let h=t.x*y.normal.x+t.y*y.normal.y+t.z*y.normal.z-T,V=e.x*y.normal.x+e.y*y.normal.y+e.z*y.normal.z-T;if(V>0&&(c=!0),h>0&&(f=!0),h>0&&V>=h)return;if(!(h<=0&&V<=0))if(h>V){let A=(h-J)/(h-V);A>i&&(i=A,l=y,m=p)}else{let A=(h+J)/(h-V);A<u&&(u=A)}}if(!f){s.startsolid=!0,c||(s.allsolid=!0),s.fraction=0;return}i<u&&i>-1&&i<s.fraction&&(s.fraction=i<0?0:i,s.plane=l,s.contents=r.contents,s.surfaceFlags=m?.surfaceFlags??0)}function _e(){return{fraction:1,plane:null,contents:0,surfaceFlags:0,startsolid:!1,allsolid:!1}}function Ue(t,e,o){let n=o;for(;n>=0;){let r=e.nodes[n];n=$(r.plane,t)>=0?r.children[0]:r.children[1]}return-1-n}function yt(t,e,o){let n=t.leaves[e],r=n.contents,s=He(),a=n.firstLeafBrush,i=a+n.numLeafBrushes;for(let u=a;u<i;u+=1){let l=t.leafBrushes[u],m=t.brushes[l];m.checkcount!==s&&(m.checkcount=s,m.sides.length!==0&&ft(o,m)&&(r|=m.contents))}return r}function He(){let t=Ce;return Ce+=1,Ce>=Wo&&(Ce=1),t}function Uo(t,e){return t.x===0&&t.y===0&&t.z===0&&e.x===0&&e.y===0&&e.z===0}function Ho(t,e,o){return Uo(e,o)?0:t.normal.x*(t.normal.x<0?o.x:e.x)+t.normal.y*(t.normal.y<0?o.y:e.y)+t.normal.z*(t.normal.z<0?o.z:e.z)}function xt(t,e,o){return Math.abs(Ho(t,e,o))}function Ie(t,e,o){return N(t,E(Y(e,t),o))}function We(t,e,o){let n=t.allsolid?0:t.fraction,r=Ie(e,o,n);return{fraction:n,endpos:r,plane:t.plane,planeNormal:t.startsolid?void 0:t.plane?.normal,contents:t.contents,surfaceFlags:t.surfaceFlags,startsolid:t.startsolid,allsolid:t.allsolid}}function Ae(t,e,o){let n=Ue(t,e,o);return e.leaves[n]?.cluster??-1}function St(t,e,o,n){if(!t||t.numClusters===0)return!0;if(e<0||o<0||e>=t.clusters.length||o>=t.numClusters)return!1;let r=t.clusters[e],a=(n?r.phs:r.pvs)[o>>3];return a===void 0?!1:(a&1<<(o&7))!==0}function de(t){let{model:e,nodeIndex:o,startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p}=t;if(f.fraction<=n)return;if(o<0){let L=-1-o,_=e.leaves[L],I=_.firstLeafBrush,K=I+_.numLeafBrushes;for(let w=I;w<K;w+=1){let G=e.leafBrushes[w],z=e.brushes[G];if((z.contents&c)!==0&&z.sides.length&&z.checkcount!==p&&(z.checkcount=p,Ge({start:i,end:u,mins:l,maxs:m,brush:z,trace:f}),f.allsolid))return}return}let y=e.nodes[o],T=y.plane,h=xt(T,l,m),V=$(T,s),A=$(T,a);if(V>=h&&A>=h){de({model:e,nodeIndex:y.children[0],startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p});return}if(V<-h&&A<-h){de({model:e,nodeIndex:y.children[1],startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p});return}let C=0,b=1/(V-A),x,P;V<A?(C=1,P=(V+h+J)*b,x=(V-h+J)*b):(C=0,P=(V-h-J)*b,x=(V+h+J)*b),x<0?x=0:x>1&&(x=1),P<0?P=0:P>1&&(P=1);let S=n+(r-n)*x,O=Ie(s,a,x);if(de({model:e,nodeIndex:y.children[C],startFraction:n,endFraction:S,start:s,end:O,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p}),f.fraction<=S)return;let k=n+(r-n)*P,g=Ie(s,a,P);de({model:e,nodeIndex:y.children[1-C],startFraction:k,endFraction:r,start:g,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p})}function ht(t){let{model:e,start:o,end:n}=t,r=t.mins??R,s=t.maxs??R,a=t.contentMask??4294967295,i=t.headnode??0,u=_e(),l=He();return de({model:e,nodeIndex:i,startFraction:0,endFraction:1,start:o,end:n,traceStart:o,traceEnd:n,mins:r,maxs:s,contentMask:a,trace:u,brushCheckCount:l}),We(u,o,n)}function Ko(t,e,o=0){let n=Ue(t,e,o);return yt(e,n,t)}function Jo(t,e,o=0){let n=new Map;return t.map(r=>{let s=Ue(r,e,o),a=e.leaves[s];if(a.numLeafBrushes===0){let i=n.get(s);return i!==void 0?i:(n.set(s,a.contents),a.contents)}return yt(e,s,r)})}function Xo(t,e,o,n,r=0){let s=He(),a=0;function i(u){if(u<0){let p=-1-u,y=n.leaves[p];a|=y.contents;let T=y.firstLeafBrush,h=T+y.numLeafBrushes;for(let V=T;V<h;V+=1){let A=n.leafBrushes[V],C=n.brushes[A];if(C.checkcount===s||(C.checkcount=s,C.sides.length===0))continue;let b=pt(t,e,o,C);b.startsolid&&(a|=b.contents)}return}let l=n.nodes[u],m=l.plane,c=xt(m,e,o),f=$(m,t);if(c===0){i(f>=0?l.children[0]:l.children[1]);return}if(f>c){i(l.children[0]);return}if(f<-c){i(l.children[1]);return}i(l.children[0]),i(l.children[1])}return i(r),a}function jo(t,e,o,n=0){let{visibility:r}=o;if(!r)return!0;let s=Ae(t,o,n),a=Ae(e,o,n);return St(r,s,a,!1)}function Yo(t,e,o,n=0){let{visibility:r}=o;if(!r)return!0;let s=Ae(t,o,n),a=Ae(e,o,n);return St(r,s,a,!0)}function ne(t,e,o){return{normal:t,dist:e,type:o,signbits:ke(t)}}function Zo(t){let e=t.surfaceFlags??0,o=t.origin.x+t.maxs.x,n=t.origin.x+t.mins.x,r=t.origin.y+t.maxs.y,s=t.origin.y+t.mins.y,a=t.origin.z+t.maxs.z,i=t.origin.z+t.mins.z,l=[ne({x:1,y:0,z:0},o,0),ne({x:-1,y:0,z:0},-n,0),ne({x:0,y:1,z:0},r,1),ne({x:0,y:-1,z:0},-s,1),ne({x:0,y:0,z:1},a,2),ne({x:0,y:0,z:-1},-i,2)].map(m=>({plane:m,surfaceFlags:e}));return{contents:t.contents,sides:l,checkcount:0}}function qo(t){let e=Zo(t);return{...t,brush:e,bounds:{mins:{x:t.origin.x+t.mins.x,y:t.origin.y+t.mins.y,z:t.origin.z+t.mins.z},maxs:{x:t.origin.x+t.maxs.x,y:t.origin.y+t.maxs.y,z:t.origin.z+t.maxs.z}}}}function $o(t,e){return!(t.mins.x>e.maxs.x||t.maxs.x<e.mins.x||t.mins.y>e.maxs.y||t.maxs.y<e.mins.y||t.mins.z>e.maxs.z||t.maxs.z<e.mins.z)}function Qo(t,e){return e.allsolid&&!t.allsolid||e.startsolid&&!t.startsolid?!0:e.fraction<t.fraction}var Be=class{constructor(){this.entities=new Map}link(e){this.entities.set(e.id,qo(e))}unlink(e){this.entities.delete(e)}trace(e){let{passId:o}=e,n=e.mins??R,r=e.maxs??R,s=e.contentMask??4294967295,a,i=null;e.model?a=ht(e):a=We(_e(),e.start,e.end);for(let u of this.entities.values()){if(u.id===o||(u.contents&s)===0)continue;let l=_e();Ge({start:e.start,end:e.end,mins:n,maxs:r,brush:u.brush,trace:l}),l.contents===0&&(l.contents=u.contents);let m=We(l,e.start,e.end);Qo(a,m)&&(a=m,i=u.id)}return{...a,entityId:i}}gatherTriggerTouches(e,o,n,r=1073741824){let s=[],a={mins:N(e,o),maxs:N(e,n)};for(let i of this.entities.values())(i.contents&r)!==0&&$o(a,i.bounds)&&s.push(i.id);return s}};var bt=(a=>(a[a.None=0]="None",a[a.Archive=1]="Archive",a[a.UserInfo=2]="UserInfo",a[a.ServerInfo=4]="ServerInfo",a[a.Latch=8]="Latch",a[a.Cheat=16]="Cheat",a))(bt||{});var Bs=1024,ks=80,Gs=512,Us=64,Hs=128,en=256,Ks=8192,tn=256,on=8192,nn=2048,rn=512,sn=256,an=512,cn=256,Ke=32,Js=96,Xs=64,re=(S=>(S[S.Name=0]="Name",S[S.CdTrack=1]="CdTrack",S[S.Sky=2]="Sky",S[S.SkyAxis=3]="SkyAxis",S[S.SkyRotate=4]="SkyRotate",S[S.StatusBar=5]="StatusBar",S[S.AirAccel=59]="AirAccel",S[S.MaxClients=60]="MaxClients",S[S.MapChecksum=61]="MapChecksum",S[S.Models=62]="Models",S[S.Sounds=62+on]="Sounds",S[S.Images=S.Sounds+nn]="Images",S[S.Lights=S.Images+rn]="Lights",S[S.ShadowLights=S.Lights+tn]="ShadowLights",S[S.Items=S.ShadowLights+cn]="Items",S[S.PlayerSkins=S.Items+sn]="PlayerSkins",S[S.General=S.PlayerSkins+en]="General",S[S.WheelWeapons=S.General+an]="WheelWeapons",S[S.WheelAmmo=S.WheelWeapons+Ke]="WheelAmmo",S[S.WheelPowerups=S.WheelAmmo+Ke]="WheelPowerups",S[S.CdLoopCount=S.WheelPowerups+Ke]="CdLoopCount",S[S.GameStyle=S.CdLoopCount+1]="GameStyle",S[S.MaxConfigStrings=S.GameStyle+1]="MaxConfigStrings",S))(re||{}),ln=re.MaxConfigStrings;function un(t){return t>=5&&t<59?96*(59-t):t>=re.General&&t<re.WheelWeapons?96*(re.MaxConfigStrings-t):96}function dn(t){return t??{}}function Vt(t,e,o={}){let n=dn(t),r=[],s=[];for(let i of e){if(!(i in n)){r.push(i);continue}typeof n[i]!="function"&&s.push(i)}let a=o.allowExtra===!1?Object.keys(n).filter(i=>!e.includes(i)):[];return{missing:r,nonFunctions:s,extras:a}}function mn(t,e,o={}){let{missing:n,nonFunctions:r,extras:s}=Vt(t,e,o);if(n.length===0&&r.length===0&&s.length===0)return;let a=[];n.length>0&&a.push(`missing: ${n.join(", ")}`),r.length>0&&a.push(`non-functions: ${r.join(", ")}`),s.length>0&&a.push(`extras: ${s.join(", ")}`);let i=o.name??"contract";throw new Error(`${i} validation failed (${a.join("; ")})`)}var fn=["Broadcast_Print","Com_Print","Client_Print","Center_Print","sound","positioned_sound","local_sound","configstring","get_configstring","Com_Error","modelindex","soundindex","imageindex","setmodel","trace","clip","pointcontents","inPVS","inPHS","SetAreaPortalState","AreasConnected","linkentity","unlinkentity","BoxEdicts","multicast","unicast"],pn=["PreInit","Init","Shutdown","SpawnEntities","WriteGameJson","ReadGameJson","WriteLevelJson","ReadLevelJson","CanSave","ClientConnect","ClientThink","RunFrame","Pmove"],yn=["Com_Print","get_configstring","Com_Error","TagMalloc","TagFree","AddCommandString","CL_FrameValid","CL_FrameTime","CL_ClientTime","CL_ServerFrame","Draw_RegisterPic","Draw_GetPicSize","SCR_DrawChar","SCR_DrawPic","SCR_DrawColorPic"],xn=["Init","Shutdown","DrawHUD","TouchPics","LayoutFlags","GetActiveWeaponWheelWeapon","GetOwnedWeaponWheelWeapons","GetWeaponWheelAmmoCount","GetPowerupWheelCount","GetHitMarkerDamage","Pmove","ParseConfigString","ParseCenterPrint","ClearNotify","ClearCenterprint","NotifyMessage","GetMonsterFlashOffset"];var se=(r=>(r[r.None=0]="None",r[r.Feet=1]="Feet",r[r.Waist=2]="Waist",r[r.Under=3]="Under",r))(se||{});function Je(t){return t>=2}function Sn(t){return t===3}var Q=(c=>(c[c.Ducked=1]="Ducked",c[c.JumpHeld=2]="JumpHeld",c[c.OnGround=4]="OnGround",c[c.TimeWaterJump=8]="TimeWaterJump",c[c.TimeLand=16]="TimeLand",c[c.TimeTeleport=32]="TimeTeleport",c[c.NoPositionalPrediction=64]="NoPositionalPrediction",c[c.OnLadder=128]="OnLadder",c[c.NoAngularPrediction=256]="NoAngularPrediction",c[c.IgnorePlayerCollision=512]="IgnorePlayerCollision",c[c.TimeTrick=1024]="TimeTrick",c))(Q||{});function M(t,e){return(t&e)!==0}function W(t,e){return t|e}function U(t,e){return t&~e}var ae=(i=>(i[i.Normal=0]="Normal",i[i.Grapple=1]="Grapple",i[i.NoClip=2]="NoClip",i[i.Spectator=3]="Spectator",i[i.Dead=4]="Dead",i[i.Gib=5]="Gib",i[i.Freeze=6]="Freeze",i))(ae||{}),ee=(i=>(i[i.None=0]="None",i[i.Attack=1]="Attack",i[i.Use=2]="Use",i[i.Holster=4]="Holster",i[i.Jump=8]="Jump",i[i.Crouch=16]="Crouch",i[i.Any=128]="Any",i))(ee||{});function Xe(t){let{velocity:e,frametime:o,onGround:n,groundIsSlick:r,onLadder:s,waterlevel:a,pmFriction:i,pmStopSpeed:u,pmWaterFriction:l}=t,m=D(e);if(m<1)return{x:0,y:0,z:e.z};let c=0;if(n&&!r||s){let y=m<u?u:m;c+=y*i*o}a>0&&!s&&(c+=m*l*a*o);let f=m-c;if(f<0&&(f=0),f===m)return e;let p=f/m;return E(e,p)}function H(t){let{velocity:e,wishdir:o,wishspeed:n,accel:r,frametime:s}=t,a=F(e,o),i=n-a;if(i<=0)return e;let u=r*s*n;return u>i&&(u=i),{x:e.x+o.x*u,y:e.y+o.y*u,z:e.z+o.z*u}}function je(t){let{velocity:e,wishdir:o,wishspeed:n,accel:r,frametime:s}=t,a=Math.min(n,30),i=F(e,o),u=a-i;if(u<=0)return e;let l=r*n*s;return l>u&&(l=u),{x:e.x+o.x*l,y:e.y+o.y*l,z:e.z+o.z*l}}function hn(t,e){let o=Math.abs(t.forwardmove),n=Math.abs(t.sidemove),r=Math.abs(t.upmove),s=Math.max(o,n,r);if(s===0)return 0;let a=Math.sqrt(t.forwardmove*t.forwardmove+t.sidemove*t.sidemove+t.upmove*t.upmove);return e*s/(127*a)}function Ye(t){let{forward:e,right:o,cmd:n,maxSpeed:r}=t,s={x:e.x*n.forwardmove+o.x*n.sidemove,y:e.y*n.forwardmove+o.y*n.sidemove,z:0},a=D(s);if(a>r){let i=r/a;s=E(s,i),a=r}return{wishdir:a===0?s:v(s),wishspeed:a}}function Ze(t){let{forward:e,right:o,cmd:n,maxSpeed:r}=t,s={x:e.x*n.forwardmove+o.x*n.sidemove,y:e.y*n.forwardmove+o.y*n.sidemove,z:0};n.upmove>10?s=N(s,{x:0,y:0,z:n.upmove}):n.upmove<-10?s=N(s,{x:0,y:0,z:n.upmove}):s=N(s,{x:0,y:0,z:10});let a=D(s);if(a>r){let i=r/a;s=E(s,i),a=r}return a*=.5,{wishdir:a===0?s:v(s),wishspeed:a}}var Tt=5,bn=4,Vn=18,Tn=.7,Pt=1,Ct=2;function _t(t,e,o,n=Tt,r=t){if(e.length===0)return{velocity:t,planes:[],stopped:!1};let s=[],a=t;for(let u of e){if(s.length>=n)return{velocity:R,planes:s,stopped:!0};if(s.find(f=>F(f,u)>.99))continue;s.push(u);let m,c=0;for(;c<s.length;c++){let f=q(a,s[c],o),p=0;for(;p<s.length&&!(p!==c&&F(f,s[p])<0);p++);if(p===s.length){m=f;break}}if(m)a=m;else{if(s.length!==2)return{velocity:R,planes:s,stopped:!0};let f=Z(s[0],s[1]),p=F(f,a);a=E(f,p)}if(F(a,r)<=0)return{velocity:R,planes:s,stopped:!0}}let i=a.x===0&&a.y===0&&a.z===0;return{velocity:a,planes:s,stopped:i}}function qe(t){let{origin:e,velocity:o,frametime:n,overbounce:r,trace:s,maxBumps:a=bn,maxClipPlanes:i=Tt,mins:u,maxs:l,hasTime:m=!1}=t,c=e,f=o,p=[],y=o,T=n,h=0;for(let A=0;A<a&&!(f.x===0&&f.y===0&&f.z===0);A++){let C=N(c,E(f,T)),b=s(c,C,u,l);if(b.allsolid){let P=m?y:R;return{origin:b.endpos,velocity:P,planes:p,stopped:!0,blocked:h}}if(b.startsolid){let P=m?y:R;return{origin:b.endpos,velocity:P,planes:p,stopped:!0,blocked:h}}if(b.fraction>0&&(c=b.endpos),b.fraction===1)break;if(!b.planeNormal)return{origin:c,velocity:m?y:R,planes:p,stopped:!0,blocked:h};b.planeNormal.z>.7&&(h|=Pt),b.planeNormal.z===0&&(h|=Ct),p.push(b.planeNormal),T-=T*b.fraction;let x=_t(f,p,r,i,y);if(f=x.velocity,p.splice(0,p.length,...x.planes),y.z>0&&f.z<0&&(f={...f,z:0}),x.stopped)return{origin:c,velocity:m?y:f,planes:p,stopped:!0,blocked:h}}let V=m?y:f;return{origin:c,velocity:V,planes:p,stopped:V.x===0&&V.y===0&&V.z===0,blocked:h}}function te(t){let{mins:e,maxs:o,stepSize:n=Vn,...r}=t,s=t.origin,a=t.velocity,i=qe({...r,mins:e,maxs:o}),u=N(s,{x:0,y:0,z:n}),l=r.trace(s,u,e,o);if(l.allsolid)return{...i,stepped:!1,stepHeight:0};let m=l.endpos.z-s.z,c=qe({...r,origin:l.endpos,velocity:a,mins:e,maxs:o}),f=N(c.origin,{x:0,y:0,z:-m}),p=r.trace(c.origin,f,e,o),y=c.origin,T=p.planeNormal;p.allsolid||(y=p.endpos);let h=(P,S)=>(P.x-S.x)**2+(P.y-S.y)**2,V=h(i.origin,s),A=h(y,s);if(V>A||T&&T.z<Tn)return{...i,stepped:!1,stepHeight:0};let C={...c.velocity,z:i.velocity.z},b=c.blocked,x=C.x===0&&C.y===0&&C.z===0;return{origin:y,velocity:C,planes:c.planes,blocked:b,stopped:x,stepped:!0,stepHeight:m,stepNormal:T}}var ie=["x","y","z"],$e=[{normal:[0,0,1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[0,0,-1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[-1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[0,1,0],mins:[-1,0,-1],maxs:[1,0,1]},{normal:[0,-1,0],mins:[-1,0,-1],maxs:[1,0,1]}],At={x:0,y:0,z:0};function ce(t){return{x:t.x,y:t.y,z:t.z}}function Pn(t){return{x:t[0],y:t[1],z:t[2]}}function me(t,e,o){if(o!==0)switch(e){case"x":t.x+=o;break;case"y":t.y+=o;break;case"z":t.z+=o;break}}function Nt(t,e,o){switch(e){case"x":t.x=o;break;case"y":t.y=o;break;case"z":t.z=o;break}}function Ne(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":default:return t.z}}function Et(t,e,o,n){return t===-1?Ne(o,e):t===1?Ne(n,e):0}function gt(t,e,o,n){let r=ce(t);for(let s=0;s<ie.length;s++){let a=ie[s],i=e.normal[s];i<0?me(r,a,Ne(o,a)):i>0&&me(r,a,Ne(n,a))}return r}function Cn(t,e,o){let n=ce(At),r=ce(At);for(let s=0;s<ie.length;s++){let a=ie[s];Nt(n,a,Et(t.mins[s],a,e,o)),Nt(r,a,Et(t.maxs[s],a,e,o))}return{mins:n,maxs:r}}function _n(t,e,o){if(!e||o===0)return t;let n=ce(t);return me(n,e,o),n}function An(t,e,o){if(!e||o===0)return t;switch(e){case"x":return{...t,x:t.x+o};case"y":return{...t,y:t.y+o};case"z":default:return{...t,z:t.z+o}}}function Qe(t){let{origin:e,mins:o,maxs:n,trace:r}=t;if(!r(e,o,n,e).startsolid)return{result:"good-position",origin:{...e}};let a=[];for(let i=0;i<$e.length;i++){let u=$e[i],{mins:l,maxs:m}=Cn(u,o,n),c=gt(e,u,o,n),f=r(c,l,m,c),p,y=0;if(f.startsolid)for(let P=0;P<ie.length;P++){if(u.normal[P]!==0)continue;let S=ie[P],O=ce(c);if(me(O,S,1),f=r(O,l,m,O),!f.startsolid){c=O,p=S,y=1;break}if(O=ce(c),me(O,S,-1),f=r(O,l,m,O),!f.startsolid){c=O,p=S,y=-1;break}}if(f.startsolid)continue;let T=$e[i^1],h=gt(e,T,o,n);if(h=_n(h,p,y),f=r(c,l,m,h),f.startsolid)continue;let V=Pn(u.normal),A=N(f.endpos??h,E(V,.125)),C=Y(A,h),b=N(e,C);b=An(b,p,y),!r(b,o,n,b).startsolid&&a.push({origin:b,distance:oe(C)})}return a.length===0?{result:"no-good-position",origin:{...e}}:(a.sort((i,u)=>i.distance-u.distance),{result:"fixed",origin:{...a[0].origin}})}var Nn=100,et=200,Rt=150,Ee=25,En=15,gn=1,Rn={x:0,y:0,z:1},On=(t,e)=>({fraction:1,endpos:e,allsolid:!1,startsolid:!1});function tt(t){let e=0,o=0,n=0;return t&262144&&(e+=1),t&524288&&(o+=1),t&1048576&&(e-=1),t&2097152&&(o-=1),t&4194304&&(n+=1),t&8388608&&(n-=1),e===0&&o===0&&n===0?R:{x:e,y:o,z:n}}function zt(t){let{watertype:e,waterlevel:o,onGround:n,waterSpeed:r}=t;if((e&16515072)===0)return R;let s=tt(e);if(s===R)return R;let a=r;return o===1&&n&&(a*=.5),E(s,a)}function Ft(t){let{groundContents:e,scale:o=Nn}=t,n=tt(e);return n===R?R:E(n,o)}function ge(t){let{wishVelocity:e,onLadder:o,onGround:n,waterlevel:r,watertype:s,groundContents:a,cmd:i,viewPitch:u,maxSpeed:l,ladderMod:m,waterSpeed:c,forward:f,origin:p,mins:y,maxs:T,trace:h=On}=t,V=e;o&&(V=vn({wishVelocity:V,cmd:i,waterlevel:r,viewPitch:u,maxSpeed:l,ladderMod:m,onGround:n,forward:f,origin:p,mins:y,maxs:T,trace:h}));let A=zt({watertype:s,waterlevel:r,onGround:n,waterSpeed:c});if(A!==R&&(V=N(V,A)),n){let C=Ft({groundContents:a});C!==R&&(V=N(V,C))}return V}function vn(t){let{wishVelocity:e,cmd:o,waterlevel:n,viewPitch:r,maxSpeed:s,ladderMod:a,onGround:i,forward:u,origin:l,mins:m,maxs:c,trace:f}=t,p=o.buttons??0,y={...e};if((p&24)!==0){let T=Je(n)?s:et;y={...y,z:p&8?T:-T}}else if(o.forwardmove){let T=Ot(o.forwardmove,-et,et);if(o.forwardmove>0){let h=r<En?T:-T;y={...y,z:h}}else i||(y={...y,x:0,y:0}),y={...y,z:T}}else y={...y,z:0};if(!i)if(o.sidemove){let T=Ot(o.sidemove,-Rt,Rt);n<2&&(T*=a);let h=v({x:u.x,y:u.y,z:0});if(h.x!==0||h.y!==0){let V=N(l,E(h,gn)),A=f(l,V,m,c);if(A.fraction!==1&&!A.allsolid&&A.contents!==void 0&&(A.contents&536870912)!==0&&A.planeNormal){let C=Z(A.planeNormal,Rn);y={...y,x:0,y:0},y=N(y,E(C,-T))}}}else y={...y,x:vt(y.x),y:vt(y.y)};return y}function Ot(t,e,o){return Math.max(e,Math.min(o,t))}function vt(t){return t<-Ee?-Ee:t>Ee?Ee:t}var zn=1.5,Mt=.5,Fn=1.01;function Mn(t){let{origin:e,cmd:o,frametime:n,pmFriction:r,pmStopSpeed:s,pmMaxSpeed:a,pmAccelerate:i,pmWaterSpeed:u,doclip:l,forward:m,right:c,mins:f,maxs:p,trace:y,overbounce:T=Fn,stepSize:h,maxBumps:V,maxClipPlanes:A}=t,C=Ln({velocity:t.velocity,pmFriction:r,pmStopSpeed:s,frametime:n}),b=wn({cmd:o,forward:m,right:c,pmMaxSpeed:a,pmWaterSpeed:u});if(b.wishspeed>0&&(C=H({velocity:C,wishdir:b.wishdir,wishspeed:b.accelSpeed,accel:i,frametime:n})),!l){let x=E(C,n);return{origin:N(e,x),velocity:C,planes:[],blocked:0,stopped:C.x===0&&C.y===0&&C.z===0,stepped:!1,stepHeight:0}}if(!y||!f||!p)throw new Error("applyPmoveFlyMove: doclip=true requires trace/mins/maxs");return te({origin:e,velocity:C,frametime:n,overbounce:T,trace:y,mins:f,maxs:p,stepSize:h,maxBumps:V,maxClipPlanes:A})}function Ln(t){let{velocity:e,pmFriction:o,pmStopSpeed:n,frametime:r}=t,s=D(e);if(s<1)return{x:0,y:0,z:0};let a=o*zn,u=(s<n?n:s)*a*r,l=s-u;return l<0&&(l=0),l===s?e:E(e,l/s)}function wn(t){let{cmd:e,forward:o,right:n,pmMaxSpeed:r,pmWaterSpeed:s}=t,a=v(o),i=v(n),l={x:a.x*e.forwardmove+i.x*e.sidemove,y:a.y*e.forwardmove+i.y*e.sidemove,z:a.z*e.forwardmove+i.z*e.sidemove},m=e.buttons??0;m&8&&(l=N(l,{x:0,y:0,z:s*Mt})),m&16&&(l=N(l,{x:0,y:0,z:-s*Mt}));let c=D(l),f=c===0?{x:0,y:0,z:0}:v(l);if(c>r){let y=r/c;l=E(l,y),c=r,f=c===0?{x:0,y:0,z:0}:v(l)}let p=c*2;return{wishdir:f,wishspeed:c,accelSpeed:p}}function fe(t){let{origin:e,mins:o,viewheight:n,pointContents:r}=t,s=n-o.z,a=s/2,i={x:e.x,y:e.y,z:e.z+o.z+1},u=r(i);if((u&56)===0)return{waterlevel:0,watertype:0};let l=u,m=1,c={x:i.x,y:i.y,z:e.z+o.z+a};if(u=r(c),(u&56)!==0){m=2;let f={x:i.x,y:i.y,z:e.z+o.z+s};u=r(f),(u&56)!==0&&(m=3)}return{waterlevel:m,watertype:l}}var Dn=270;function In(t,e){return(t&e)!==0}function Wn(t){let{pmFlags:e,pmType:o,buttons:n,waterlevel:r,onGround:s,velocity:a,jumpHeight:i=Dn}=t;if(e&16)return{pmFlags:e,onGround:s,velocity:a,jumpSound:!1,jumped:!1};let u=In(n,8),l=e,m=s,c=!1,f=!1,p=a;if(!u)return l=U(l,2),{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(Bn(l))return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(o===4)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(r>=2)return m=!1,{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(!m)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};l=W(l,2),l=U(l,4),m=!1,c=!0,f=!0;let y=a.z+i,T=y<i?i:y;return p={...a,z:T},{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f}}function Bn(t){return(t&2)!==0}function Re(t,e,o){return{x:t,y:e,z:o}}function Oe(t,e){let o=Re(-16,-16,0),n=Re(16,16,16);if(t===5)return{mins:o,maxs:n,viewheight:8};let r=t===4||(e&1)!==0,s=Re(o.x,o.y,-24),a=Re(n.x,n.y,r?4:32);return{mins:s,maxs:a,viewheight:r?-2:22}}var kn=4,Gn=32,Un=8;function Hn(t){let{pmType:e}=t;if(e===5){let a=Oe(e,t.pmFlags);return{pmFlags:t.pmFlags,ducked:M(t.pmFlags,1),changed:!1,...a}}let o=t.pmFlags,n=!1;e===4?M(o,1)||(o=W(o,1),n=!0):Kn(t)?!M(o,1)&&!Jn(t)&&(o=W(o,1),n=!0):M(o,1)&&!Xn(t)&&(o=U(o,1),n=!0);let r=Oe(e,o),s=e===4||M(o,1);return{pmFlags:o,ducked:s,changed:n,...r}}function Kn(t){return(t.buttons&16)===0||t.onLadder||t.n64Physics?!1:!!(t.hasGroundEntity||t.waterlevel<=1&&!jn(t))}function Jn(t){return t.trace({start:t.origin,end:t.origin,mins:t.mins,maxs:Lt(t.maxs,kn),mask:3}).allsolid}function Xn(t){return t.trace({start:t.origin,end:t.origin,mins:t.mins,maxs:Lt(t.maxs,Gn),mask:3}).allsolid}function jn(t){let e={x:t.origin.x,y:t.origin.y,z:t.origin.z-Un};return t.trace({start:t.origin,end:e,mins:t.mins,maxs:t.maxs,mask:3}).fraction<1?!1:t.trace({start:t.origin,end:e,mins:t.mins,maxs:t.maxs,mask:56}).fraction<1}function Lt(t,e){return{x:t.x,y:t.y,z:e}}var Yn=.25,Zn=180,qn=100,$n=.7,Qn=.9,er=64,tr=128,or=1.01,nr=1080;function rr(t){let{pmType:e,n64Physics:o,velocity:n,startVelocity:r,origin:s,mins:a,maxs:i,viewheight:u,trace:l,pointContents:m}=t,c=t.pmFlags,f=t.pmTime,p,y=M(c,4),T,h=0;if(n.z>Zn||e===1)c=U(c,4),y=!1;else{let b={x:s.x,y:s.y,z:s.z-Yn},x=l(s,b,a,i);T=x,h=x.contents??0;let P=x.planeNormal,S=x.fraction<1&&!!P&&P.z<$n;if(S&&P){let O=N(s,P),B=l(s,O,a,i);B.fraction<1&&!B.startsolid&&(S=!1)}if(x.fraction===1||!P||S&&!x.startsolid)c=U(c,4),y=!1;else{y=!0,M(c,8)&&(c&=~nr,f=0);let O=M(c,4);if(!O){!o&&n.z>=qn&&P.z>=Qn&&!M(c,1)&&(c=W(c,1024),f=er);let B=q(n,P,or);p=r.z-B.z}c=W(c,4),!O&&(o||M(c,1))&&(c=W(c,16),f=tr)}}let{waterlevel:A,watertype:C}=fe({origin:s,mins:a,viewheight:u,pointContents:m});return{pmFlags:c,pmTime:f,onGround:M(c,4),groundTrace:T,groundContents:h,waterlevel:A,watertype:C,impactDelta:p}}var wt=1,sr=60,ot=1.01;function ar(t){let{origin:e,frametime:o,mins:n,maxs:r,trace:s,overbounce:a=ot,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:f,cmd:p,pmFlags:y,onGround:T,gravity:h,pmType:V,pmAccelerate:A,pmAirAccelerate:C=wt,pmMaxSpeed:b,pmDuckSpeed:x,onLadder:P,waterlevel:S,watertype:O,groundContents:B,viewPitch:k,ladderMod:g,pmWaterSpeed:L}=t,_={...t.velocity},I=cr(c,f,p);I=ge({wishVelocity:I,onLadder:P,onGround:T,waterlevel:S,watertype:O,groundContents:B,cmd:p,viewPitch:k,maxSpeed:M(y,1)?x:b,ladderMod:g,waterSpeed:L,forward:c,origin:e,mins:n,maxs:r,trace:s});let w=M(y,1)?x:b,G=I,z=D(G);if(z!==0&&(G=v(G)),z>w){let X=w/z;I=E(I,X),z=w,z!==0&&(G=v(I))}return P?(_=H({velocity:_,wishdir:G,wishspeed:z,accel:A,frametime:o}),Math.abs(I.z)<Number.EPSILON&&(_=dr(_,h,o)),ve({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):T?(_={..._,z:0},_=H({velocity:_,wishdir:G,wishspeed:z,accel:A,frametime:o}),h>0?_={..._,z:0}:_={..._,z:_.z-h*o},_.x===0&&_.y===0?{origin:e,velocity:_,planes:[],blocked:0,stopped:!0,stepped:!1,stepHeight:0}:ve({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):(C>0?_=je({velocity:_,wishdir:G,wishspeed:z,accel:C,frametime:o}):_=H({velocity:_,wishdir:G,wishspeed:z,accel:wt,frametime:o}),V!==1&&(_={..._,z:_.z-h*o}),ve({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m}))}function ir(t){let{origin:e,frametime:o,mins:n,maxs:r,trace:s,overbounce:a=ot,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:f,cmd:p,pmFlags:y,onGround:T,pmMaxSpeed:h,pmDuckSpeed:V,pmWaterAccelerate:A,pmWaterSpeed:C,onLadder:b,watertype:x,groundContents:P,waterlevel:S,viewPitch:O,ladderMod:B}=t,k={...t.velocity},g=lr(c,f,p);ur(p,T)?g={...g,z:g.z-sr}:Dt(p,16)?g=N(g,{x:0,y:0,z:-C*.5}):Dt(p,8)&&(g=N(g,{x:0,y:0,z:C*.5})),g=ge({wishVelocity:g,onLadder:b,onGround:T,waterlevel:S,watertype:x,groundContents:P,cmd:p,viewPitch:O,maxSpeed:M(y,1)?V:h,ladderMod:B,waterSpeed:C,forward:c,origin:e,mins:n,maxs:r,trace:s});let L=g,_=D(L);if(_!==0&&(L=v(L)),_>h){let K=h/_;g=E(g,K),_=h,_!==0&&(L=v(g))}if(_*=.5,M(y,1)&&_>V){let K=V/_;g=E(g,K),_=V,_!==0&&(L=v(g))}return k=H({velocity:k,wishdir:L,wishspeed:_,accel:A,frametime:o}),ve({origin:e,velocity:k,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})}function cr(t,e,o){return{x:t.x*o.forwardmove+e.x*o.sidemove,y:t.y*o.forwardmove+e.y*o.sidemove,z:0}}function lr(t,e,o){return{x:t.x*o.forwardmove+e.x*o.sidemove,y:t.y*o.forwardmove+e.y*o.sidemove,z:t.z*o.forwardmove+e.z*o.sidemove}}function Dt(t,e){return!!((t.buttons??0)&e)}function ur(t,e){let o=t.forwardmove===0&&t.sidemove===0,n=!((t.buttons??0)&24);return o&&n&&!e}function dr(t,e,o){let n=t.z,r=e*o;return n>0?(n-=r,n<0&&(n=0)):(n+=r,n>0&&(n=0)),{...t,z:n}}function ve(t){let{origin:e,velocity:o,frametime:n,mins:r,maxs:s,trace:a,overbounce:i=ot,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c}=t;return te({origin:e,velocity:o,frametime:n,trace:a,mins:r,maxs:s,overbounce:i,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c})}var mr=1,fr=40,ze=50,It=350,pr=2048,Wt=.1,yr=800,xr=50,Bt=.7,Sr=18,hr=1.01,br=2;function Vr(t){let{pmFlags:e,pmTime:o,waterlevel:n,watertype:r,gravity:s,cmd:a,forward:i,origin:u,velocity:l,mins:m,maxs:c,viewheight:f,trace:p,pointContents:y,onGround:T,overbounce:h=hr,stepSize:V=Sr,maxBumps:A,maxClipPlanes:C}=t;if(o>0)return{pmFlags:e,pmTime:o,velocity:l,performedWaterJump:!1};let b=U(e,128),x=o,P=l,S=v({x:i.x,y:i.y,z:0}),O=oe(S)>0;if(n<2&&O){let z=N(u,E(S,mr)),X=p(u,z,m,c),Ht=X.contents??0;X.fraction<1&&(Ht&536870912)!==0&&(b=W(b,128))}if(s===0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(((a.buttons??0)&8)===0&&a.forwardmove<=0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(n!==2)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if((r&8192)!==0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(!O)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};let B=N(u,E(S,fr)),k=p(u,B,m,c);if(k.fraction===1||!k.planeNormal||k.planeNormal.z>=Bt)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};let g={x:S.x*ze,y:S.y*ze,z:It},L=u,_=!0,I=Tr(s);for(let z=0;z<I;z++){g={x:g.x,y:g.y,z:g.z-s*Wt},g.z<0&&(_=!1);let X=te({origin:L,velocity:g,frametime:Wt,trace:p,mins:m,maxs:c,overbounce:h,stepSize:V,maxBumps:A,maxClipPlanes:C,hasTime:_});L=X.origin,g=X.velocity}let K=N(L,{x:0,y:0,z:-br}),w=p(L,K,m,c);return w.fraction===1||!w.planeNormal||w.planeNormal.z<Bt||w.endpos.z<u.z?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:T&&Math.abs(u.z-w.endpos.z)<=V?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:fe({origin:w.endpos,mins:m,viewheight:f,pointContents:y}).waterlevel>=2?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:(b=W(b,8),x=pr,P={x:S.x*ze,y:S.y*ze,z:It},{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!0})}function Tr(t){if(t===0)return 0;let e=Math.floor(10*(yr/t));return e<=0?0:Math.min(xr,e)}var nt=[0,-1,1];function rt(t){let{origin:e,mins:o,maxs:n,trace:r}=t;return!r(e,e,o,n).allsolid}function Pr(t){let{origin:e,velocity:o,mins:n,maxs:r,previousOrigin:s,trace:a}=t;if(rt({origin:e,mins:n,maxs:r,trace:a}))return{origin:{...e},velocity:{...o},resolution:"unchanged"};let i=Qe({origin:e,mins:n,maxs:r,trace:(u,l,m,c)=>a(u,c,l,m)});return i.result==="fixed"||i.result==="good-position"?{origin:i.origin,velocity:{...o},resolution:"fixed"}:{origin:{...s},velocity:{...o},resolution:"reverted"}}function Cr(t){let{origin:e,mins:o,maxs:n,trace:r}=t;for(let s of nt)for(let a of nt)for(let i of nt){let u={x:e.x+i,y:e.y+a,z:e.z+s};if(rt({origin:u,mins:o,maxs:n,trace:r}))return{origin:u,snapped:i!==0||a!==0||s!==0}}return{origin:{...e},snapped:!1}}function _r(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function Ar(t){return t>89&&t<180?89:t<271&&t>=180?271:t}function Nr(t){let{pmFlags:e,cmdAngles:o,deltaAngles:n}=t,r;(e&32)!==0?r={x:0,y:o.y+n.y,z:0}:(r=_r(o,n),r={...r,x:Ar(r.x)});let s=we(r);return{viewangles:r,...s}}var Er=200,gr=200,Rr=200,Or=140,vr=150,zr=3;function Fr(t){let e=ue(t);return e>89&&e<180?89:e<271&&e>=180?271:e}function Mr(t,e){return{x:Fr(t.x+e.x),y:ue(t.y+e.y),z:ue(t.z+e.z)}}function Lr(t,e){let o=e.sensitivityX??e.sensitivity,n=(e.sensitivityY??e.sensitivity)*(e.invertY?-1:1);return{x:t.deltaY*n,y:t.deltaX*o,z:0}}var kt=(x=>(x[x.bad=0]="bad",x[x.muzzleflash=1]="muzzleflash",x[x.muzzleflash2=2]="muzzleflash2",x[x.temp_entity=3]="temp_entity",x[x.layout=4]="layout",x[x.inventory=5]="inventory",x[x.nop=6]="nop",x[x.disconnect=7]="disconnect",x[x.reconnect=8]="reconnect",x[x.sound=9]="sound",x[x.print=10]="print",x[x.stufftext=11]="stufftext",x[x.serverdata=12]="serverdata",x[x.configstring=13]="configstring",x[x.spawnbaseline=14]="spawnbaseline",x[x.centerprint=15]="centerprint",x[x.download=16]="download",x[x.playerinfo=17]="playerinfo",x[x.packetentities=18]="packetentities",x[x.deltapacketentities=19]="deltapacketentities",x[x.frame=20]="frame",x))(kt||{}),Gt=(s=>(s[s.bad=0]="bad",s[s.nop=1]="nop",s[s.move=2]="move",s[s.userinfo=3]="userinfo",s[s.stringcmd=4]="stringcmd",s))(Gt||{});var Ut=(d=>(d[d.GUNSHOT=0]="GUNSHOT",d[d.BLOOD=1]="BLOOD",d[d.BLASTER=2]="BLASTER",d[d.RAILTRAIL=3]="RAILTRAIL",d[d.SHOTGUN=4]="SHOTGUN",d[d.EXPLOSION1=5]="EXPLOSION1",d[d.EXPLOSION2=6]="EXPLOSION2",d[d.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",d[d.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",d[d.SPARKS=9]="SPARKS",d[d.SPLASH=10]="SPLASH",d[d.BUBBLETRAIL=11]="BUBBLETRAIL",d[d.SCREEN_SPARKS=12]="SCREEN_SPARKS",d[d.SHIELD_SPARKS=13]="SHIELD_SPARKS",d[d.BULLET_SPARKS=14]="BULLET_SPARKS",d[d.LASER_SPARKS=15]="LASER_SPARKS",d[d.PARASITE_ATTACK=16]="PARASITE_ATTACK",d[d.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",d[d.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",d[d.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",d[d.BFG_EXPLOSION=20]="BFG_EXPLOSION",d[d.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",d[d.BOSSTPORT=22]="BOSSTPORT",d[d.BFG_LASER=23]="BFG_LASER",d[d.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",d[d.WELDING_SPARKS=25]="WELDING_SPARKS",d[d.GREENBLOOD=26]="GREENBLOOD",d[d.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",d[d.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",d[d.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",d[d.BLASTER2=30]="BLASTER2",d[d.RAILTRAIL2=31]="RAILTRAIL2",d[d.FLAME=32]="FLAME",d[d.LIGHTNING=33]="LIGHTNING",d[d.DEBUGTRAIL=34]="DEBUGTRAIL",d[d.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",d[d.FLASHLIGHT=36]="FLASHLIGHT",d[d.FORCEWALL=37]="FORCEWALL",d[d.HEATBEAM=38]="HEATBEAM",d[d.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",d[d.STEAM=40]="STEAM",d[d.BUBBLETRAIL2=41]="BUBBLETRAIL2",d[d.MOREBLOOD=42]="MOREBLOOD",d[d.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",d[d.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",d[d.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",d[d.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",d[d.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",d[d.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",d[d.DBALL_GOAL=49]="DBALL_GOAL",d[d.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",d[d.NUKEBLAST=51]="NUKEBLAST",d[d.WIDOWSPLASH=52]="WIDOWSPLASH",d[d.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",d[d.EXPLOSION1_NP=54]="EXPLOSION1_NP",d[d.FLECHETTE=55]="FLECHETTE",d))(Ut||{});var pe=.025,wr=(t,e)=>{let o={...t.origin};o.z-=.25;let n=e(t.origin,o);return{...t,onGround:n.fraction<1}},Dr=(t,e)=>{let o={...t.origin};return o.z+=t.mins.z+1,e(o)&33554432?{...t,waterLevel:1}:{...t,waterLevel:0}},Ir=(t,e,o,n)=>{let r={...t};r=wr(r,o),r=Dr(r,n);let{origin:s,velocity:a,onGround:i,waterLevel:u}=r,l=Xe({velocity:a,frametime:pe,onGround:i,groundIsSlick:!1,onLadder:!1,waterlevel:u,pmFriction:6,pmStopSpeed:100,pmWaterFriction:1}),m=u>=2?Ze({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:e,maxSpeed:320}):Ye({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:e,maxSpeed:320}),c=H({velocity:l,wishdir:m.wishdir,wishspeed:m.wishspeed,accel:i?10:1,frametime:pe}),f=o(s,{x:s.x+c.x*pe,y:s.y+c.y*pe,z:s.z+c.z*pe});return{...r,origin:f.endpos,velocity:c}};var st=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let o=this.readChar();if(o===-1||o===0)break;e+=String.fromCharCode(o)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let o=this.readChar();if(o===-1||o===0||o===10)break;e+=String.fromCharCode(o)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let o=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(o)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){if(this.readByte()>=162){e.x=0,e.y=0,e.z=0;return}e.x=0,e.y=0,e.z=0}};return Zt(Wr);})();
2
2
  //# sourceMappingURL=index.global.js.map