quake2ts 0.0.68 → 0.0.71

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 (54) 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 +14 -14
  8. package/packages/engine/dist/browser/index.global.js.map +1 -1
  9. package/packages/engine/dist/cjs/index.cjs +84 -0
  10. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  11. package/packages/engine/dist/esm/index.js +81 -0
  12. package/packages/engine/dist/esm/index.js.map +1 -1
  13. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  14. package/packages/engine/dist/types/assets/manager.d.ts +4 -1
  15. package/packages/engine/dist/types/assets/manager.d.ts.map +1 -1
  16. package/packages/engine/dist/types/assets/sprite.d.ts +23 -0
  17. package/packages/engine/dist/types/assets/sprite.d.ts.map +1 -0
  18. package/packages/engine/dist/types/index.d.ts +1 -0
  19. package/packages/engine/dist/types/index.d.ts.map +1 -1
  20. package/packages/game/dist/browser/index.global.js +1 -1
  21. package/packages/game/dist/browser/index.global.js.map +1 -1
  22. package/packages/game/dist/cjs/index.cjs +318 -40
  23. package/packages/game/dist/cjs/index.cjs.map +1 -1
  24. package/packages/game/dist/esm/index.js +318 -40
  25. package/packages/game/dist/esm/index.js.map +1 -1
  26. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  27. package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
  28. package/packages/game/dist/types/entities/entity.d.ts +9 -1
  29. package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
  30. package/packages/game/dist/types/entities/funcs.d.ts +9 -0
  31. package/packages/game/dist/types/entities/funcs.d.ts.map +1 -0
  32. package/packages/game/dist/types/entities/projectiles.d.ts +2 -0
  33. package/packages/game/dist/types/entities/projectiles.d.ts.map +1 -1
  34. package/packages/game/dist/types/entities/spawn.d.ts.map +1 -1
  35. package/packages/game/dist/types/entities/system.d.ts +2 -0
  36. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  37. package/packages/game/dist/types/entities/thinkScheduler.d.ts +1 -1
  38. package/packages/game/dist/types/entities/thinkScheduler.d.ts.map +1 -1
  39. package/packages/game/dist/types/imports.d.ts +1 -0
  40. package/packages/game/dist/types/imports.d.ts.map +1 -1
  41. package/packages/game/dist/types/index.d.ts +4 -1
  42. package/packages/game/dist/types/index.d.ts.map +1 -1
  43. package/packages/game/dist/types/physics/movement.d.ts +2 -0
  44. package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
  45. package/packages/shared/dist/browser/index.global.js +1 -1
  46. package/packages/shared/dist/browser/index.global.js.map +1 -1
  47. package/packages/shared/dist/cjs/index.cjs +18 -8
  48. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  49. package/packages/shared/dist/esm/index.js +16 -8
  50. package/packages/shared/dist/esm/index.js.map +1 -1
  51. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  52. package/packages/shared/dist/types/math/vec3.d.ts +2 -0
  53. package/packages/shared/dist/types/math/vec3.d.ts.map +1 -1
  54. 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 Rr={};Ut(Rr,{CGAME_EXPORT_KEYS:()=>co,CGAME_IMPORT_KEYS:()=>io,CONTENTS_AREAPORTAL:()=>jr,CONTENTS_AUX:()=>Br,CONTENTS_CURRENT_0:()=>Vn,CONTENTS_CURRENT_180:()=>bn,CONTENTS_CURRENT_270:()=>hn,CONTENTS_CURRENT_90:()=>Cn,CONTENTS_CURRENT_DOWN:()=>Pn,CONTENTS_CURRENT_UP:()=>En,CONTENTS_DEADMONSTER:()=>$r,CONTENTS_DETAIL:()=>Qr,CONTENTS_LADDER:()=>lt,CONTENTS_LAVA:()=>Gr,CONTENTS_MIST:()=>Jr,CONTENTS_MONSTER:()=>qr,CONTENTS_MONSTERCLIP:()=>Yr,CONTENTS_NONE:()=>Ce,CONTENTS_NO_WATERJUMP:()=>Sn,CONTENTS_ORIGIN:()=>Zr,CONTENTS_PLAYER:()=>ts,CONTENTS_PLAYERCLIP:()=>Xr,CONTENTS_PROJECTILE:()=>ns,CONTENTS_PROJECTILECLIP:()=>Kr,CONTENTS_SLIME:()=>Ur,CONTENTS_SOLID:()=>kr,CONTENTS_TRANSLUCENT:()=>es,CONTENTS_TRIGGER:()=>Tn,CONTENTS_WATER:()=>Hr,CONTENTS_WINDOW:()=>Ir,CS_MAX_STRING_LENGTH:()=>ks,CS_MAX_STRING_LENGTH_OLD:()=>Is,CollisionEntityIndex:()=>ke,ConfigStringIndex:()=>oe,CvarFlags:()=>Tt,DEFAULT_FORWARD_SPEED:()=>Cr,DEFAULT_MOUSE_SENSITIVITY:()=>_r,DEFAULT_PITCH_SPEED:()=>Pr,DEFAULT_SIDE_SPEED:()=>br,DEFAULT_UP_SPEED:()=>hr,DEFAULT_YAW_SPEED:()=>Er,DEG2RAD:()=>an,DIST_EPSILON:()=>J,GAME_EXPORT_KEYS:()=>ao,GAME_IMPORT_KEYS:()=>so,LAST_VISIBLE_CONTENTS:()=>os,MASK_ALL:()=>Ss,MASK_BLOCK_SIGHT:()=>Ps,MASK_CURRENT:()=>_n,MASK_DEADSOLID:()=>Cs,MASK_LADDER_NAV_SOLID:()=>vs,MASK_MONSTERSOLID:()=>bs,MASK_NAV_SOLID:()=>_s,MASK_OPAQUE:()=>hs,MASK_PLAYERSOLID:()=>Vs,MASK_PROJECTILE:()=>gs,MASK_SHOT:()=>Es,MASK_SOLID:()=>we,MASK_WALK_NAV_SOLID:()=>Ns,MASK_WATER:()=>be,MAX_CLIENTS:()=>jn,MAX_CONFIGSTRINGS:()=>to,MAX_EDICTS:()=>Ws,MAX_GENERAL:()=>Qn,MAX_IMAGES:()=>qn,MAX_ITEMS:()=>$n,MAX_LIGHTSTYLES:()=>Xn,MAX_MODELS:()=>Yn,MAX_OSPATH:()=>Ds,MAX_QPATH:()=>ws,MAX_SHADOW_LIGHTS:()=>eo,MAX_SOUNDS:()=>Zn,MAX_STRING_CHARS:()=>Os,MAX_STRING_TOKENS:()=>Ms,MAX_TOKEN_CHARS:()=>Ls,MAX_WHEEL_ITEMS:()=>He,MersenneTwister19937:()=>Se,PITCH:()=>xe,PlaneSide:()=>ut,PlayerButton:()=>$,PmFlag:()=>q,PmType:()=>se,RAD2DEG:()=>cn,ROLL:()=>Me,RandomGenerator:()=>Ve,SLIDEMOVE_BLOCKED_FLOOR:()=>Ct,SLIDEMOVE_BLOCKED_WALL:()=>bt,STOP_EPSILON:()=>j,SURF_ALPHATEST:()=>ps,SURF_FLOWING:()=>ms,SURF_LIGHT:()=>ss,SURF_N64_SCROLL_FLIP:()=>Ts,SURF_N64_SCROLL_X:()=>ys,SURF_N64_SCROLL_Y:()=>xs,SURF_N64_UV:()=>fs,SURF_NODRAW:()=>ds,SURF_NONE:()=>rs,SURF_SKY:()=>is,SURF_SLICK:()=>as,SURF_TRANS33:()=>ls,SURF_TRANS66:()=>us,SURF_WARP:()=>cs,WaterLevel:()=>re,YAW:()=>Te,ZERO_VEC3:()=>g,addBlendColor:()=>dn,addContents:()=>gn,addPmFlag:()=>W,addPointToBounds:()=>$t,addVec3:()=>_,addViewAngles:()=>Nr,angleMod:()=>le,angleVectors:()=>Le,applyPmove:()=>Fr,applyPmoveAccelerate:()=>U,applyPmoveAddCurrents:()=>Ne,applyPmoveAirAccelerate:()=>je,applyPmoveAirMove:()=>Qo,applyPmoveFlyMove:()=>No,applyPmoveFriction:()=>Ke,applyPmoveWaterMove:()=>er,assertContract:()=>ro,boxContents:()=>In,boxOnPlaneSide:()=>Ln,boxesIntersect:()=>Qt,buildAirGroundWish:()=>Xe,buildCollisionModel:()=>On,buildWaterWish:()=>Ye,categorizePosition:()=>qo,checkDuckState:()=>Do,checkJump:()=>Ro,checkSpecialMovement:()=>pr,clampViewAngles:()=>Vr,clipBoxToBrush:()=>Be,clipVelocityAgainstPlanes:()=>en,clipVelocityVec3:()=>Y,closestPointToBox:()=>Yt,combineSurfaceFlags:()=>Fn,computePlaneSignBits:()=>Ie,computePlayerDimensions:()=>ze,concatRotationMatrices:()=>Oe,configStringSize:()=>no,createDefaultTrace:()=>Ee,createEmptyBounds3:()=>qt,createMat4Identity:()=>ct,createRandomGenerator:()=>pn,crossVec3:()=>X,currentVectorFromContents:()=>et,degToRad:()=>fe,distanceBetweenBoxesSquared:()=>Zt,dotVec3:()=>R,fixStuckObjectGeneric:()=>$e,getWaterLevel:()=>de,goodPosition:()=>ot,groundCurrentVelocity:()=>Ft,hasAllContents:()=>vn,hasAnyContents:()=>Nn,hasPmFlag:()=>O,hasSurfaceFlags:()=>An,inPHS:()=>Gn,inPVS:()=>Bn,initialSnapPosition:()=>xr,isAtLeastWaistDeep:()=>Je,isUnderwater:()=>lo,lengthSquaredVec3:()=>te,lengthVec3:()=>D,lerpAngle:()=>ln,mat4FromBasis:()=>xn,mouseDeltaToViewDelta:()=>gr,multiplyMat4:()=>fn,multiplyVec3:()=>jt,negateVec3:()=>Xt,normalizeVec3:()=>A,perpendicularVec3:()=>st,planeDistanceToPoint:()=>Z,pmoveCmdScale:()=>uo,pointContents:()=>Wn,pointContentsMany:()=>kn,pointInsideBrush:()=>mt,pointOnPlaneSide:()=>Mn,projectPointOnPlane:()=>rt,projectSourceVec3:()=>nn,projectSourceVec3WithUp:()=>on,radToDeg:()=>ye,removeContents:()=>zn,removePmFlag:()=>G,resolveSlideMove:()=>ht,rotatePointAroundVector:()=>sn,scaleVec3:()=>v,slerpVec3:()=>rn,slideClipVelocityVec3:()=>tn,slideMove:()=>Ze,snapPosition:()=>yr,stepSlideMove:()=>Q,subtractVec3:()=>ee,testBoxInBrush:()=>dt,traceBox:()=>xt,transformPointMat4:()=>yn,validateContract:()=>St,vectorToAngles:()=>mn,vectorToYaw:()=>un,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 ee(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 X(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 D(e){return Math.sqrt(te(e))}function A(e){let t=D(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 ee(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 Yt(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 Zt(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 $t(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 Qt(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 Y(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 en(e,t,n,o){if(t.length===0)return e;let r=e;for(let s=0;s<t.length;s++){r=Y(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=X(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 tn(e,t,n){return Y(e,t,n)}function nn(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 on(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 rn(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 sn(e,t,n){if(D(e)===0)return t;let r=A(e),s=st(r),a=X(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,an=at,cn=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 ln(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 un(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 mn(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 dn(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 pn(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 fn(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 yn(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 xn(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,kr=1,Ir=2,Br=4,Gr=8,Ur=16,Hr=32,Jr=64,Tn=1073741824,Sn=8192,Kr=16384,jr=32768,Xr=65536,Yr=131072,Vn=262144,Cn=524288,bn=1048576,hn=2097152,En=4194304,Pn=8388608,Zr=16777216,qr=33554432,$r=67108864,Qr=134217728,es=268435456,lt=536870912,ts=1073741824,ns=-2147483648,os=64,rs=0,ss=1,as=2,is=4,cs=8,ls=16,us=32,ms=64,ds=128,ps=33554432,fs=268435456,ys=536870912,xs=1073741824,Ts=-2147483648,Ss=4294967295,we=3,Vs=1107361795,Cs=65539,bs=1107427331,be=56,hs=25,Es=1174405123,_n=16515072,Ps=1107296281,_s=65539,vs=3,Ns=196611,gs=1174421507;function vn(e,t){return(e&t)===t}function Nn(e,t){return(e&t)!==0}function gn(e,t){return e|t}function zn(e,t){return e&~t}function An(e,t){return(e&t)===t}function Fn(...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,Rn=Number.MAX_SAFE_INTEGER-1,he=1;function On(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 Z(e,t){return e.normal.x*t.x+e.normal.y*t.y+e.normal.z*t.z-e.dist}function Mn(e,t,n=0){let o=Z(e,t);return o>n?1:o<-n?2:3}function Ln(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(Z(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=Z(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>=Rn&&(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 Dn(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(Dn(e,t,n))}function De(e,t,n){return _(e,v(ee(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],w=h.firstLeafBrush,H=w+h.numLeafBrushes;for(let L=w;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=Z(V,s),E=Z(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 Wn(e,t,n=0){let o=Ge(e,t,n);return pt(t,o,e)}function kn(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 In(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=Z(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 Bn(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 Gn(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 Un(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 Hn(e){let t=Un(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 Kn(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,Hn(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);Kn(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 Os=1024,Ms=80,Ls=512,ws=64,Ds=128,jn=256,Ws=8192,Xn=256,Yn=8192,Zn=2048,qn=512,$n=256,Qn=512,eo=256,He=32,ks=96,Is=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+Yn]="Sounds",y[y.Images=y.Sounds+Zn]="Images",y[y.Lights=y.Images+qn]="Lights",y[y.ShadowLights=y.Lights+Xn]="ShadowLights",y[y.Items=y.ShadowLights+eo]="Items",y[y.PlayerSkins=y.Items+$n]="PlayerSkins",y[y.General=y.PlayerSkins+jn]="General",y[y.WheelWeapons=y.General+Qn]="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||{}),to=oe.MaxConfigStrings;function no(e){return e>=5&&e<59?96*(59-e):e>=oe.General&&e<oe.WheelWeapons?96*(oe.MaxConfigStrings-e):96}function oo(e){return e??{}}function St(e,t,n={}){let o=oo(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 ro(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 so=["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"],ao=["PreInit","Init","Shutdown","SpawnEntities","WriteGameJson","ReadGameJson","WriteLevelJson","ReadLevelJson","CanSave","ClientConnect","ClientThink","RunFrame","Pmove"],io=["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"],co=["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 lo(e){return e===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 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||{}),$=(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))($||{});function Ke(e){let{velocity:t,frametime:n,onGround:o,groundIsSlick:r,onLadder:s,waterlevel:a,pmFriction:i,pmStopSpeed:u,pmWaterFriction:l}=e,m=D(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 uo(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=D(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=D(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,mo=4,po=18,fo=.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=Y(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=X(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=mo,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 Q(e){let{mins:t,maxs:n,stepSize:o=po,...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<fo)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 yo(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 xo(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 To(e,t,n){if(!t||n===0)return e;let o=ie(e);return me(o,t,n),o}function So(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}=xo(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=To(x,p,f),d=r(c,l,m,x),d.startsolid)continue;let S=yo(u.normal),E=_(d.endpos??x,v(S,.125)),b=ee(E,x),T=_(t,b);T=So(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 Vo=100,Qe=200,Nt=150,ve=25,Co=15,bo=1,ho={x:0,y:0,z:1},Eo=(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=Vo}=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=Eo}=e,S=t;n&&(S=Po({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 Po(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<Co?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,bo)),E=d(l,S,m,c);if(E.fraction!==1&&!E.allsolid&&E.contents!==void 0&&(E.contents&536870912)!==0&&E.planeNormal){let b=X(E.planeNormal,ho);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 _o=1.5,Rt=.5,vo=1.01;function No(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=vo,stepSize:x,maxBumps:S,maxClipPlanes:E}=e,b=go({velocity:e.velocity,pmFriction:r,pmStopSpeed:s,frametime:o}),T=zo({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 Q({origin:t,velocity:b,frametime:o,overbounce:V,trace:f,mins:d,maxs:p,stepSize:x,maxBumps:S,maxClipPlanes:E})}function go(e){let{velocity:t,pmFriction:n,pmStopSpeed:o,frametime:r}=e,s=D(t);if(s<1)return{x:0,y:0,z:0};let a=n*_o,u=(s<o?o:s)*a*r,l=s-u;return l<0&&(l=0),l===s?t:v(t,l/s)}function zo(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=D(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 Ao=270;function Fo(e,t){return(e&t)!==0}function Ro(e){let{pmFlags:t,pmType:n,buttons:o,waterlevel:r,onGround:s,velocity:a,jumpHeight:i=Ao}=e;if(t&16)return{pmFlags:t,onGround:s,velocity:a,jumpSound:!1,jumped:!1};let u=Fo(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(Oo(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 Oo(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 Mo=4,Lo=32,wo=8;function Do(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):Wo(e)?!O(n,1)&&!ko(e)&&(n=W(n,1),o=!0):O(n,1)&&!Io(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 Wo(e){return(e.buttons&16)===0||e.onLadder||e.n64Physics?!1:!!(e.hasGroundEntity||e.waterlevel<=1&&!Bo(e))}function ko(e){return e.trace({start:e.origin,end:e.origin,mins:e.mins,maxs:Ot(e.maxs,Mo),mask:3}).allsolid}function Io(e){return e.trace({start:e.origin,end:e.origin,mins:e.mins,maxs:Ot(e.maxs,Lo),mask:3}).allsolid}function Bo(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 Go=.25,Uo=180,Ho=100,Jo=.7,Ko=.9,jo=64,Xo=128,Yo=1.01,Zo=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>Uo||t===1)c=G(c,4),f=!1;else{let T={x:s.x,y:s.y,z:s.z-Go},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&=~Zo,d=0);let z=O(c,4);if(!z){!n&&o.z>=Ho&&C.z>=Ko&&!O(c,1)&&(c=W(c,1024),d=jo);let k=Y(o,C,Yo);p=r.z-k.z}c=W(c,4),!z&&(n||O(c,1))&&(c=W(c,16),d=Xo)}}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,$o=60,tt=1.01;function Qo(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},w=tr(c,d,p);w=Ne({wishVelocity:w,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=w,F=D(B);if(F!==0&&(B=A(B)),F>L){let K=L/F;w=v(w,K),F=L,F!==0&&(B=A(w))}return C?(h=U({velocity:h,wishdir:B,wishspeed:F,accel:E,frametime:n}),Math.abs(w.z)<Number.EPSILON&&(h=rr(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 er(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=nr(c,d,p);or(p,V)?N={...N,z:N.z-$o}: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=D(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 tr(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 nr(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 or(e,t){let n=e.forwardmove===0&&e.sidemove===0,o=!((e.buttons??0)&24);return n&&o&&!t}function rr(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 Q({origin:t,velocity:n,frametime:o,trace:a,mins:r,maxs:s,overbounce:i,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c})}var sr=1,ar=40,Fe=50,wt=350,ir=2048,Dt=.1,cr=800,lr=50,Wt=.7,ur=18,mr=1.01,dr=2;function pr(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=mr,stepSize:S=ur,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,sr)),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,ar)),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,w=fr(s);for(let F=0;F<w;F++){N={x:N.x,y:N.y,z:N.z-s*Dt},N.z<0&&(h=!1);let K=Q({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:-dr}),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=ir,C={x:y.x*Fe,y:y.y*Fe,z:wt},{pmFlags:T,pmTime:P,velocity:C,performedWaterJump:!0})}function fr(e){if(e===0)return 0;let t=Math.floor(10*(cr/e));return t<=0?0:Math.min(lr,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 yr(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 xr(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 Tr(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function Sr(e){return e>89&&e<180?89:e<271&&e>=180?271:e}function Vr(e){let{pmFlags:t,cmdAngles:n,deltaAngles:o}=e,r;(t&32)!==0?r={x:0,y:n.y+o.y,z:0}:(r=Tr(n,o),r={...r,x:Sr(r.x)});let s=Le(r);return{viewangles:r,...s}}var Cr=200,br=200,hr=200,Er=140,Pr=150,_r=3;function vr(e){let t=le(e);return t>89&&t<180?89:t<271&&t>=180?271:t}function Nr(e,t){return{x:vr(e.x+t.x),y:le(e.y+t.y),z:le(e.z+t.z)}}function gr(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,zr=(e,t)=>{let n={...e.origin};n.z-=.25;let o=t(e.origin,n);return{...e,onGround:o.fraction<1}},Ar=(e,t)=>{let n={...e.origin};return n.z+=e.mins.z+1,t(n)&33554432?{...e,waterLevel:1}:{...e,waterLevel:0}},Fr=(e,t,n,o)=>{let r={...e};r=zr(r,n),r=Ar(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(Rr);})();
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);})();
2
2
  //# sourceMappingURL=index.global.js.map