quake2ts 0.0.277 → 0.0.282

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 (70) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +13 -13
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +46 -10
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +45 -10
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/client/dist/types/index.d.ts +10 -0
  10. package/packages/client/dist/types/index.d.ts.map +1 -1
  11. package/packages/engine/dist/browser/index.global.js +9 -9
  12. package/packages/engine/dist/browser/index.global.js.map +1 -1
  13. package/packages/engine/dist/cjs/index.cjs +3 -0
  14. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  15. package/packages/engine/dist/esm/index.js +3 -0
  16. package/packages/engine/dist/esm/index.js.map +1 -1
  17. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  18. package/packages/engine/dist/types/demo/playback.d.ts +1 -0
  19. package/packages/engine/dist/types/demo/playback.d.ts.map +1 -1
  20. package/packages/game/dist/browser/index.global.js +3 -3
  21. package/packages/game/dist/browser/index.global.js.map +1 -1
  22. package/packages/game/dist/cjs/index.cjs +2108 -1193
  23. package/packages/game/dist/cjs/index.cjs.map +1 -1
  24. package/packages/game/dist/esm/index.js +1879 -957
  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/animation.d.ts +3 -2
  28. package/packages/game/dist/types/combat/weapons/animation.d.ts.map +1 -1
  29. package/packages/game/dist/types/combat/weapons/bfg.d.ts +4 -0
  30. package/packages/game/dist/types/combat/weapons/bfg.d.ts.map +1 -0
  31. package/packages/game/dist/types/combat/weapons/blaster.d.ts +4 -0
  32. package/packages/game/dist/types/combat/weapons/blaster.d.ts.map +1 -0
  33. package/packages/game/dist/types/combat/weapons/chaingun.d.ts.map +1 -1
  34. package/packages/game/dist/types/combat/weapons/firing.d.ts +10 -0
  35. package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
  36. package/packages/game/dist/types/combat/weapons/frames.d.ts +43 -0
  37. package/packages/game/dist/types/combat/weapons/frames.d.ts.map +1 -1
  38. package/packages/game/dist/types/combat/weapons/grenadelauncher.d.ts +4 -0
  39. package/packages/game/dist/types/combat/weapons/grenadelauncher.d.ts.map +1 -0
  40. package/packages/game/dist/types/combat/weapons/hyperblaster.d.ts +4 -0
  41. package/packages/game/dist/types/combat/weapons/hyperblaster.d.ts.map +1 -0
  42. package/packages/game/dist/types/combat/weapons/machinegun.d.ts +4 -0
  43. package/packages/game/dist/types/combat/weapons/machinegun.d.ts.map +1 -0
  44. package/packages/game/dist/types/combat/weapons/railgun.d.ts +4 -0
  45. package/packages/game/dist/types/combat/weapons/railgun.d.ts.map +1 -0
  46. package/packages/game/dist/types/combat/weapons/rocket.d.ts +4 -0
  47. package/packages/game/dist/types/combat/weapons/rocket.d.ts.map +1 -0
  48. package/packages/game/dist/types/combat/weapons/shotgun.d.ts +4 -0
  49. package/packages/game/dist/types/combat/weapons/shotgun.d.ts.map +1 -0
  50. package/packages/game/dist/types/combat/weapons/supershotgun.d.ts +4 -0
  51. package/packages/game/dist/types/combat/weapons/supershotgun.d.ts.map +1 -0
  52. package/packages/game/dist/types/entities/entity.d.ts +17 -0
  53. package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
  54. package/packages/game/dist/types/entities/system.d.ts +2 -1
  55. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  56. package/packages/game/dist/types/entities/targets.d.ts.map +1 -1
  57. package/packages/game/dist/types/index.d.ts.map +1 -1
  58. package/packages/game/dist/types/inventory/items.d.ts.map +1 -1
  59. package/packages/shared/dist/browser/index.global.js +1 -1
  60. package/packages/shared/dist/browser/index.global.js.map +1 -1
  61. package/packages/shared/dist/cjs/index.cjs +26 -0
  62. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  63. package/packages/shared/dist/esm/index.js +25 -0
  64. package/packages/shared/dist/esm/index.js.map +1 -1
  65. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  66. package/packages/shared/dist/types/protocol/index.d.ts +1 -0
  67. package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
  68. package/packages/shared/dist/types/protocol/renderFx.d.ts +22 -0
  69. package/packages/shared/dist/types/protocol/renderFx.d.ts.map +1 -0
  70. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
@@ -1,7 +1,7 @@
1
- "use strict";var Quake2Engine=(()=>{var Uu=Object.create;var mo=Object.defineProperty;var Hu=Object.getOwnPropertyDescriptor;var Vu=Object.getOwnPropertyNames;var Gu=Object.getPrototypeOf,Wu=Object.prototype.hasOwnProperty;var Xu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ua=(e,t)=>{for(var r in t)mo(e,r,{get:t[r],enumerable:!0})},yc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vu(t))!Wu.call(e,i)&&i!==r&&mo(e,i,{get:()=>t[i],enumerable:!(n=Hu(t,i))||n.enumerable});return e};var Ku=(e,t,r)=>(r=e!=null?Uu(Gu(e)):{},yc(t||!e||!e.__esModule?mo(r,"default",{value:e,enumerable:!0}):r,e)),$u=e=>yc(mo({},"__esModule",{value:!0}),e);var Jc=Xu((N_,Qc)=>{"use strict";Qc.exports=Worker});var hx={};ua(hx,{ATTN_IDLE:()=>Rd,ATTN_LOOP_NONE:()=>Td,ATTN_NONE:()=>us,ATTN_NORM:()=>Id,ATTN_STATIC:()=>Cd,AssetDependencyError:()=>Sr,AssetDependencyTracker:()=>Fi,AssetManager:()=>cs,AudioApi:()=>Hr,AudioContextController:()=>hs,AudioRegistry:()=>fn,AudioRegistryError:()=>Ci,AudioSystem:()=>bs,BSP_SURFACE_FRAGMENT_SOURCE:()=>sl,BSP_SURFACE_VERTEX_SOURCE:()=>ol,BSP_VERTEX_LAYOUT:()=>rl,BspLoader:()=>Gr,BspParseError:()=>j,BspSurfacePipeline:()=>As,Camera:()=>Is,Command:()=>Rn,CommandRegistry:()=>Dr,ConfigStringRegistry:()=>Ur,Cvar:()=>Fn,CvarRegistry:()=>Br,DemoPlaybackController:()=>lo,DemoReader:()=>Ar,EngineHost:()=>Nr,EngineRuntime:()=>Pn,FixedTimestepLoop:()=>or,Framebuffer:()=>Ss,IndexBuffer:()=>ye,LruCache:()=>kt,MAX_SOUND_CHANNELS:()=>Qa,MD2_FRAGMENT_SHADER:()=>hl,MD2_VERTEX_SHADER:()=>fl,MD3_FRAGMENT_SHADER:()=>Sl,MD3_VERTEX_SHADER:()=>vl,Md2Loader:()=>Wr,Md2MeshBuffers:()=>Es,Md2ParseError:()=>me,Md2Pipeline:()=>Ls,Md3Loader:()=>Xr,Md3ModelMesh:()=>Rs,Md3ParseError:()=>Ve,Md3Pipeline:()=>Cs,Md3SurfaceMesh:()=>Oi,MusicSystem:()=>vs,NetworkMessageParser:()=>Fr,PARTICLE_FRAGMENT_SHADER:()=>Al,PARTICLE_VERTEX_SHADER:()=>wl,PROTOCOL_VERSION_RERELEASE:()=>Ks,PakArchive:()=>Vr,PakIndexStore:()=>ls,PakIngestionError:()=>zt,PakParseError:()=>He,PakValidationError:()=>sr,PakValidator:()=>So,ParticleRenderer:()=>ks,ParticleSystem:()=>zs,PlaybackState:()=>da,RERELEASE_KNOWN_PAKS:()=>wa,SKYBOX_FRAGMENT_SHADER:()=>dl,SKYBOX_VERTEX_SHADER:()=>cl,SOUND_FULLVOLUME:()=>hn,SOUND_LOOP_ATTENUATE:()=>zd,ShaderProgram:()=>Me,SkyboxPipeline:()=>Ms,SoundChannel:()=>ds,SoundPrecache:()=>gs,SoundRegistry:()=>ps,SpriteLoader:()=>Kr,SpriteParseError:()=>Ft,Texture2D:()=>mn,TextureCache:()=>$r,TextureCubeMap:()=>pn,TgaParseError:()=>pt,U_ALPHA:()=>nc,U_ANGLE1:()=>ta,U_ANGLE2:()=>qs,U_ANGLE3:()=>js,U_EFFECTS16:()=>so,U_EFFECTS8:()=>no,U_EVENT:()=>Js,U_FRAME16:()=>na,U_FRAME8:()=>Qs,U_INSTANCE_BITS:()=>oc,U_LOOP_ATTENUATION_HIGH:()=>ac,U_LOOP_VOLUME:()=>sc,U_MODEL:()=>ra,U_MODEL2:()=>ia,U_MODEL3:()=>oa,U_MODEL4:()=>sa,U_OLDORIGIN:()=>aa,U_OLD_FRAME_HIGH:()=>cc,U_ORIGIN1:()=>Zs,U_ORIGIN2:()=>Ys,U_ORIGIN3:()=>ea,U_OWNER_HIGH:()=>lc,U_REMOVE:()=>rc,U_RENDERFX16:()=>oo,U_RENDERFX8:()=>ro,U_SCALE:()=>ic,U_SKIN16:()=>ao,U_SKIN8:()=>io,U_SOLID:()=>ca,U_SOUND:()=>la,VertexArray:()=>Ce,VertexBuffer:()=>Ee,VirtualFileSystem:()=>vo,advanceAnimation:()=>$c,applySurfaceState:()=>Xd,attenuationToDistanceMultiplier:()=>wr,boxIntersectsFrustum:()=>Di,buildBspGeometry:()=>Bd,buildMd2Geometry:()=>ml,buildMd2VertexData:()=>pl,buildMd3SurfaceGeometry:()=>_l,buildMd3VertexData:()=>bl,calculateMaxAudibleDistance:()=>fs,calculatePakChecksum:()=>Pc,computeFrameBlend:()=>Zc,computeSkyScroll:()=>Zd,createAnimationState:()=>Yc,createAudioGraph:()=>ms,createBspSurfaces:()=>Od,createEmptyEntityState:()=>kr,createEmptyProtocolPlayerState:()=>$s,createEngine:()=>fx,createEngineRuntime:()=>kc,createFaceLightmap:()=>Ao,createInitialChannels:()=>ys,createProgramFromSources:()=>Dd,createWebGLContext:()=>Fd,decodeOgg:()=>as,deriveSurfaceRenderState:()=>ll,extractFrustumPlanes:()=>Nd,filesToPakSources:()=>Aa,findLeafForPoint:()=>il,gatherVisibleFaces:()=>Gd,groupMd2Animations:()=>Gc,ingestPakFiles:()=>Dc,ingestPaks:()=>wo,interpolateMd3Tag:()=>f0,interpolateVec3:()=>qc,parseBsp:()=>Ma,parseMd2:()=>Ea,parseMd3:()=>La,parsePcx:()=>Nn,parseSprite:()=>Ta,parseTga:()=>Ia,parseWal:()=>Eo,parseWalTexture:()=>Io,parseWav:()=>Ro,pcxToRgba:()=>Lo,pickChannel:()=>xs,preparePcxTexture:()=>To,removeViewTranslation:()=>$d,resolveLightStyles:()=>al,spatializeOrigin:()=>_s,spawnBlood:()=>p0,spawnBulletImpact:()=>h0,spawnExplosion:()=>m0,spawnMuzzleFlash:()=>y0,spawnTeleportFlash:()=>g0,spawnTrail:()=>x0,walToRgba:()=>Ra,wireDropTarget:()=>Oc,wireFileInput:()=>Bc});var Zu=()=>typeof performance<"u"?performance.now():Date.now(),Yu=e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>e()):setTimeout(e,25)},or=class{constructor(t,r={}){this.callbacks=t;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let t=this.options.now(),r=this.lastTimeMs===void 0?0:t-this.lastTimeMs;this.lastTimeMs=t,this.advance(r,t),this.running&&this.options.schedule(this.tick)};let n=r.fixedDeltaMs??25,i=r.maxSubSteps??5;this.options={fixedDeltaMs:n,maxSubSteps:i,maxDeltaMs:r.maxDeltaMs??n*i,startTimeMs:r.startTimeMs,now:r.now??Zu,schedule:r.schedule??Yu}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(t){let r=(this.lastTimeMs??0)+t;this.lastTimeMs=r,this.advance(t,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(t,r){let n=Math.min(Math.max(t,0),this.options.maxDeltaMs);this.accumulatorMs=Math.min(this.accumulatorMs+n,this.options.fixedDeltaMs*this.options.maxSubSteps);let i=0;for(;this.accumulatorMs>=this.options.fixedDeltaMs&&i<this.options.maxSubSteps;)this.frame+=1,this.callbacks.simulate({frame:this.frame,deltaMs:this.options.fixedDeltaMs,nowMs:r}),this.accumulatorMs-=this.options.fixedDeltaMs,i+=1;let o=this.options.fixedDeltaMs===0?0:this.accumulatorMs/this.options.fixedDeltaMs;this.callbacks.render?.({alpha:o,nowMs:r,accumulatorMs:this.accumulatorMs,frame:this.frame})}};var Rn=class{constructor(t,r,n){this.name=t,this.callback=r,this.description=n}execute(t){this.callback(t)}},Dr=class{constructor(){this.commands=new Map}register(t,r,n){let i=new Rn(t,r,n);return this.commands.set(t,i),i}get(t){return this.commands.get(t)}execute(t){let r=this.tokenize(t);if(r.length===0)return!1;let n=r[0],i=r.slice(1),o=this.get(n);return o?(o.execute(i),!0):!1}tokenize(t){return t.trim().split(/\s+/)}list(){return[...this.commands.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var qu=Object.defineProperty,xc=(e,t)=>{for(var r in t)qu(e,r,{get:t[r],enumerable:!0})},_c={x:0,y:0,z:0};var yx=Math.PI/180;function bc(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function ju(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function ha(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Qu(e){return ha(e,e)}function ma(e){return Math.sqrt(Qu(e))}function Qe(e){let t=ma(e);return t===0?e:ju(e,1/t)}var Ju=Math.PI/180,xx=180/Math.PI,Or=Ju;var ef=[[-.525731,0,.850651],[-.442863,.238856,.864188],[-.295242,0,.955423],[-.309017,.5,.809017],[-.16246,.262866,.951056],[0,0,1],[0,.850651,.525731],[-.147621,.716567,.681718],[.147621,.716567,.681718],[0,.525731,.850651],[.309017,.5,.809017],[.525731,0,.850651],[.295242,0,.955423],[.442863,.238856,.864188],[.16246,.262866,.951056],[-.681718,.147621,.716567],[-.809017,.309017,.5],[-.587785,.425325,.688191],[-.850651,.525731,0],[-.864188,.442863,.238856],[-.716567,.681718,.147621],[-.688191,.587785,.425325],[-.5,.809017,.309017],[-.238856,.864188,.442863],[-.425325,.688191,.587785],[-.716567,.681718,-.147621],[-.5,.809017,-.309017],[-.525731,.850651,0],[0,.850651,-.525731],[-.238856,.864188,-.442863],[0,.955423,-.295242],[-.262866,.951056,-.16246],[0,1,0],[0,.955423,.295242],[-.262866,.951056,.16246],[.238856,.864188,.442863],[.262866,.951056,.16246],[.5,.809017,.309017],[.238856,.864188,-.442863],[.262866,.951056,-.16246],[.5,.809017,-.309017],[.850651,.525731,0],[.716567,.681718,.147621],[.716567,.681718,-.147621],[.525731,.850651,0],[.425325,.688191,.587785],[.864188,.442863,.238856],[.688191,.587785,.425325],[.809017,.309017,.5],[.681718,.147621,.716567],[.587785,.425325,.688191],[.955423,.295242,0],[1,0,0],[.951056,.16246,.262866],[.850651,-.525731,0],[.955423,-.295242,0],[.864188,-.442863,.238856],[.951056,-.16246,.262866],[.809017,-.309017,.5],[.681718,-.147621,.716567],[.850651,0,.525731],[.864188,.442863,-.238856],[.809017,.309017,-.5],[.951056,.16246,-.262866],[.525731,0,-.850651],[.681718,.147621,-.716567],[.681718,-.147621,-.716567],[.850651,0,-.525731],[.809017,-.309017,-.5],[.864188,-.442863,-.238856],[.951056,-.16246,-.262866],[.147621,.716567,-.681718],[.309017,.5,-.809017],[.425325,.688191,-.587785],[.442863,.238856,-.864188],[.587785,.425325,-.688191],[.688191,.587785,-.425325],[-.147621,.716567,-.681718],[-.309017,.5,-.809017],[0,.525731,-.850651],[-.525731,0,-.850651],[-.442863,.238856,-.864188],[-.295242,0,-.955423],[-.16246,.262866,-.951056],[0,0,-1],[.295242,0,-.955423],[.16246,.262866,-.951056],[-.442863,-.238856,-.864188],[-.309017,-.5,-.809017],[-.16246,-.262866,-.951056],[0,-.850651,-.525731],[-.147621,-.716567,-.681718],[.147621,-.716567,-.681718],[0,-.525731,-.850651],[.309017,-.5,-.809017],[.442863,-.238856,-.864188],[.16246,-.262866,-.951056],[.238856,-.864188,-.442863],[.5,-.809017,-.309017],[.425325,-.688191,-.587785],[.716567,-.681718,-.147621],[.688191,-.587785,-.425325],[.587785,-.425325,-.688191],[0,-.955423,-.295242],[0,-1,0],[.262866,-.951056,-.16246],[0,-.850651,.525731],[0,-.955423,.295242],[.238856,-.864188,.442863],[.262866,-.951056,.16246],[.5,-.809017,.309017],[.716567,-.681718,.147621],[.525731,-.850651,0],[-.238856,-.864188,-.442863],[-.5,-.809017,-.309017],[-.262866,-.951056,-.16246],[-.850651,-.525731,0],[-.716567,-.681718,-.147621],[-.716567,-.681718,.147621],[-.525731,-.850651,0],[-.5,-.809017,.309017],[-.238856,-.864188,.442863],[-.262866,-.951056,.16246],[-.864188,-.442863,.238856],[-.809017,-.309017,.5],[-.688191,-.587785,.425325],[-.681718,-.147621,.716567],[-.442863,-.238856,.864188],[-.587785,-.425325,.688191],[-.309017,-.5,.809017],[-.147621,-.716567,.681718],[-.425325,-.688191,.587785],[-.16246,-.262866,.951056],[.442863,-.238856,.864188],[.16246,-.262866,.951056],[.309017,-.5,.809017],[.147621,-.716567,.681718],[0,-.525731,.850651],[.425325,-.688191,.587785],[.587785,-.425325,.688191],[.688191,-.587785,.425325],[-.955423,.295242,0],[-.951056,.16246,.262866],[-1,0,0],[-.850651,0,.525731],[-.955423,-.295242,0],[-.951056,-.16246,.262866],[-.864188,.442863,-.238856],[-.951056,.16246,-.262866],[-.809017,.309017,-.5],[-.864188,-.442863,-.238856],[-.951056,-.16246,-.262866],[-.809017,-.309017,-.5],[-.681718,.147621,-.716567],[-.681718,-.147621,-.716567],[-.850651,0,-.525731],[-.688191,.587785,-.425325],[-.587785,.425325,-.688191],[-.425325,.688191,-.587785],[-.425325,-.688191,-.587785],[-.587785,-.425325,-.688191],[-.688191,-.587785,-.425325]];function tf(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function vc(e,t){let r=t.x,n=t.y,i=t.z;return{x:e[0]*r+e[4]*n+e[8]*i+e[12],y:e[1]*r+e[5]*n+e[9]*i+e[13],z:e[2]*r+e[6]*n+e[10]*i+e[14]}}function Sc(e,t){let r=tf();return r[0]=t[0].x,r[1]=t[0].y,r[2]=t[0].z,r[4]=t[1].x,r[5]=t[1].y,r[6]=t[1].z,r[8]=t[2].x,r[9]=t[2].y,r[10]=t[2].z,r[12]=e.x,r[13]=e.y,r[14]=e.z,r}var nt=1,Ct=2;var pa=8,ga=16,rf=32;var nf=16384;var po=65536,wc=1<<17,of=1<<18,sf=1<<19,af=1<<20,lf=1<<21,cf=1<<22,df=1<<23,_x=1<<24,go=1<<25,uf=1<<26,bx=1<<27,vx=1<<28,Sx=1<<29,yo=1<<30,wx=1<<31;var zn=0;var Ac=4,Mc=8,Ec=16,Lc=32,Tc=64;var Ax=1<<25,Mx=1<<28,Ex=1<<29,Lx=1<<30,Tx=1<<31;var Ix=nt|Ct,Rx=nt|po|Ct|go|yo,Cx=nt|po|Ct,zx=nt|wc|Ct|go|yo,kx=rf|pa|ga,Fx=nt|ga|pa,ff=nt|go|yo|Ct|uf,Px=of|sf|af|lf|cf|df,Dx=nt|pa|ga|go|yo,Ox=nt|po|Ct,Bx=nt|Ct,Nx=nt|po|Ct|wc,Ux=ff|nf;var Hx=Number.MAX_SAFE_INTEGER-1;var xo=(e=>(e[e.None=0]="None",e[e.Archive=1]="Archive",e[e.UserInfo=2]="UserInfo",e[e.ServerInfo=4]="ServerInfo",e[e.Latch=8]="Latch",e[e.Cheat=16]="Cheat",e))(xo||{});var _o=256;var ya=256,xa=8192,bo=2048,_a=512,ba=256,va=_o*2,Sa=256,fa=32,Cn=96;var q=(e=>(e[e.Name=0]="Name",e[e.CdTrack=1]="CdTrack",e[e.Sky=2]="Sky",e[e.SkyAxis=3]="SkyAxis",e[e.SkyRotate=4]="SkyRotate",e[e.StatusBar=5]="StatusBar",e[e.CONFIG_N64_PHYSICS=56]="CONFIG_N64_PHYSICS",e[e.CONFIG_CTF_TEAMS=57]="CONFIG_CTF_TEAMS",e[e.CONFIG_COOP_RESPAWN_STRING=58]="CONFIG_COOP_RESPAWN_STRING",e[e.AirAccel=59]="AirAccel",e[e.MaxClients=60]="MaxClients",e[e.MapChecksum=61]="MapChecksum",e[e.Models=62]="Models",e[e.Sounds=62+xa]="Sounds",e[e.Images=e.Sounds+bo]="Images",e[e.Lights=e.Images+_a]="Lights",e[e.ShadowLights=e.Lights+ya]="ShadowLights",e[e.Items=e.ShadowLights+Sa]="Items",e[e.PlayerSkins=e.Items+ba]="PlayerSkins",e[e.General=e.PlayerSkins+_o]="General",e[e.WheelWeapons=e.General+va]="WheelWeapons",e[e.WheelAmmo=e.WheelWeapons+fa]="WheelAmmo",e[e.WheelPowerups=e.WheelAmmo+fa]="WheelPowerups",e[e.CdLoopCount=e.WheelPowerups+fa]="CdLoopCount",e[e.GameStyle=e.CdLoopCount+1]="GameStyle",e[e.MaxConfigStrings=e.GameStyle+1]="MaxConfigStrings",e))(q||{}),Ic=q.MaxConfigStrings;function Rc(e){return e>=5&&e<59?Cn*(59-e):e>=q.General&&e<q.WheelWeapons?Cn*(q.MaxConfigStrings-e):Cn}var hf={};xc(hf,{addReplayFrame:()=>yf,createReplaySession:()=>gf,deserializeReplay:()=>pf,serializeReplay:()=>mf});function mf(e){return JSON.stringify(e,null,2)}function pf(e){let t=JSON.parse(e);if(!t.metadata||!Array.isArray(t.frames))throw new Error("Invalid replay format: missing metadata or frames");return t}function gf(e,t){return{metadata:{map:e,date:new Date().toISOString(),version:"1.0",seed:t},frames:[]}}function yf(e,t,r,n){e.frames.push({serverFrame:r,cmd:t,timestamp:Date.now()-n})}var P=(e=>(e[e.bad=0]="bad",e[e.muzzleflash=1]="muzzleflash",e[e.muzzleflash2=2]="muzzleflash2",e[e.temp_entity=3]="temp_entity",e[e.layout=4]="layout",e[e.inventory=5]="inventory",e[e.nop=6]="nop",e[e.disconnect=7]="disconnect",e[e.reconnect=8]="reconnect",e[e.sound=9]="sound",e[e.print=10]="print",e[e.stufftext=11]="stufftext",e[e.serverdata=12]="serverdata",e[e.configstring=13]="configstring",e[e.spawnbaseline=14]="spawnbaseline",e[e.centerprint=15]="centerprint",e[e.download=16]="download",e[e.playerinfo=17]="playerinfo",e[e.packetentities=18]="packetentities",e[e.deltapacketentities=19]="deltapacketentities",e[e.frame=20]="frame",e[e.splitclient=21]="splitclient",e[e.configblast=22]="configblast",e[e.spawnbaselineblast=23]="spawnbaselineblast",e[e.level_restart=24]="level_restart",e[e.damage=25]="damage",e[e.locprint=26]="locprint",e[e.fog=27]="fog",e[e.waitingforplayers=28]="waitingforplayers",e[e.bot_chat=29]="bot_chat",e[e.poi=30]="poi",e[e.help_path=31]="help_path",e[e.muzzleflash3=32]="muzzleflash3",e[e.achievement=33]="achievement",e))(P||{});var I=(e=>(e[e.GUNSHOT=0]="GUNSHOT",e[e.BLOOD=1]="BLOOD",e[e.BLASTER=2]="BLASTER",e[e.RAILTRAIL=3]="RAILTRAIL",e[e.SHOTGUN=4]="SHOTGUN",e[e.EXPLOSION1=5]="EXPLOSION1",e[e.EXPLOSION2=6]="EXPLOSION2",e[e.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",e[e.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",e[e.SPARKS=9]="SPARKS",e[e.SPLASH=10]="SPLASH",e[e.BUBBLETRAIL=11]="BUBBLETRAIL",e[e.SCREEN_SPARKS=12]="SCREEN_SPARKS",e[e.SHIELD_SPARKS=13]="SHIELD_SPARKS",e[e.BULLET_SPARKS=14]="BULLET_SPARKS",e[e.LASER_SPARKS=15]="LASER_SPARKS",e[e.PARASITE_ATTACK=16]="PARASITE_ATTACK",e[e.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",e[e.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",e[e.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",e[e.BFG_EXPLOSION=20]="BFG_EXPLOSION",e[e.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",e[e.BOSSTPORT=22]="BOSSTPORT",e[e.BFG_LASER=23]="BFG_LASER",e[e.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",e[e.WELDING_SPARKS=25]="WELDING_SPARKS",e[e.GREENBLOOD=26]="GREENBLOOD",e[e.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",e[e.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",e[e.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",e[e.BLASTER2=30]="BLASTER2",e[e.RAILTRAIL2=31]="RAILTRAIL2",e[e.FLAME=32]="FLAME",e[e.LIGHTNING=33]="LIGHTNING",e[e.DEBUGTRAIL=34]="DEBUGTRAIL",e[e.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",e[e.FLASHLIGHT=36]="FLASHLIGHT",e[e.FORCEWALL=37]="FORCEWALL",e[e.HEATBEAM=38]="HEATBEAM",e[e.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",e[e.STEAM=40]="STEAM",e[e.BUBBLETRAIL2=41]="BUBBLETRAIL2",e[e.MOREBLOOD=42]="MOREBLOOD",e[e.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",e[e.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",e[e.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",e[e.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",e[e.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",e[e.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",e[e.DBALL_GOAL=49]="DBALL_GOAL",e[e.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",e[e.NUKEBLAST=51]="NUKEBLAST",e[e.WIDOWSPLASH=52]="WIDOWSPLASH",e[e.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",e[e.EXPLOSION1_NP=54]="EXPLOSION1_NP",e[e.FLECHETTE=55]="FLECHETTE",e[e.BLUEHYPERBLASTER_KEX=56]="BLUEHYPERBLASTER_KEX",e[e.BFG_ZAP=57]="BFG_ZAP",e[e.BERSERK_SLAM=58]="BERSERK_SLAM",e[e.GRAPPLE_CABLE_2=59]="GRAPPLE_CABLE_2",e[e.POWER_SPLASH=60]="POWER_SPLASH",e[e.LIGHTNING_BEAM=61]="LIGHTNING_BEAM",e[e.EXPLOSION1_NL=62]="EXPLOSION1_NL",e[e.EXPLOSION2_NL=63]="EXPLOSION2_NL",e))(I||{});var xf=12,_f=9,Vx=Math.ceil(xf*_f/16),bf=23,vf=2,Gx=Math.ceil(bf*vf/16);var Sf={};xc(Sf,{U_ANGLE1:()=>If,U_ANGLE2:()=>Rf,U_ANGLE3:()=>Cf,U_EFFECTS:()=>Ff,U_EVENT:()=>Of,U_FRAME:()=>zf,U_MODEL:()=>Af,U_MODEL2:()=>Nf,U_MODEL3:()=>Uf,U_MODEL4:()=>Hf,U_MOREBITS:()=>Bf,U_NUMBER:()=>wf,U_ORIGIN1:()=>Ef,U_ORIGIN2:()=>Lf,U_ORIGIN3:()=>Tf,U_REMOVE:()=>Vf,U_RENDERFX:()=>Pf,U_SKIN:()=>kf,U_SOLID:()=>Df,U_SOUND:()=>Mf});var wf=1,Af=2,Mf=4,Ef=8,Lf=16,Tf=32,If=64,Rf=128,Cf=256,zf=512,kf=1024,Ff=2048,Pf=4096,Df=8192,Of=16384,Bf=32768,Nf=1,Uf=2,Hf=4,Vf=32768;var kn=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readUShort(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readULong(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0)break;e+=String.fromCharCode(t)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0||t===10)break;e+=String.fromCharCode(t)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let t=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(t)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){let t=this.readByte();if(t>=162){e.x=0,e.y=0,e.z=0;return}let r=ef[t];e.x=r[0],e.y=r[1],e.z=r[2]}};var Cc=(e=>(e[e.Bullets=0]="Bullets",e[e.Shells=1]="Shells",e[e.Rockets=2]="Rockets",e[e.Grenades=3]="Grenades",e[e.Cells=4]="Cells",e[e.Slugs=5]="Slugs",e[e.MagSlugs=6]="MagSlugs",e[e.Trap=7]="Trap",e[e.Flechettes=8]="Flechettes",e[e.Tesla=9]="Tesla",e[e.Disruptor=10]="Disruptor",e[e.Prox=11]="Prox",e[e.Nuke=12]="Nuke",e[e.Rounds=13]="Rounds",e))(Cc||{}),Wx=Object.keys(Cc).length/2;var Fn=class{constructor({name:t,defaultValue:r,description:n,flags:i=xo.None,onChange:o}){this.modifiedCount=0;this.name=t,this.defaultValue=r,this.description=n,this.flags=i,this._value=r,this.onChange=o}get string(){return this._value}get number(){return Number(this._value)}get integer(){return Math.trunc(this.number)}get boolean(){return!!this.integer}set(t){if(this.flags&xo.Latch){if(t===this._value){this.latched=void 0;return}if(this.latched===t)return;this.latched!==t&&(this.latched=t);return}this.apply(t)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let t=this.latched;return this.latched=void 0,t===this._value?!1:(this.apply(t),!0)}apply(t){if(this._value===t)return;let r=this._value;this._value=t,this.modifiedCount+=1,this.onChange?.(this,r)}},Br=class{constructor(){this.cvars=new Map}register(t){let r=this.cvars.get(t.name);if(r)return r;let n=new Fn(t);return this.cvars.set(t.name,n),n}get(t){return this.cvars.get(t)}setValue(t,r){let n=this.get(t);if(!n)throw new Error(`Unknown cvar: ${t}`);return n.set(r),n}resetAll(){for(let t of this.cvars.values())t.reset()}applyLatched(){let t=!1;for(let r of this.cvars.values())t=r.applyLatched()||t;return t}list(){return[...this.cvars.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var Nr=class{constructor(t,r,n={}){this.game=t;this.client=r;this.started=!1;this.commands=new Dr;this.cvars=new Br;this.stepSimulation=t=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(t,this.latestCommand)};this.renderClient=t=>{this.client&&(this.latestCommand=this.client.render({...t,previous:this.previousFrame,latest:this.latestFrame}))};let i=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??i,this.loop=new or({simulate:this.stepSimulation,render:this.renderClient},{...n.loop,startTimeMs:this.startTimeMs})}start(){if(!this.started){try{this.latestFrame=this.game.init(this.startTimeMs)??this.latestFrame,this.client?.init(this.latestFrame)}catch(t){throw this.game.shutdown(),this.client?.shutdown(),t}this.started=!0,this.loop.start()}}stop(){this.started&&(this.loop.stop(),this.client?.shutdown(),this.game.shutdown(),this.previousFrame=void 0,this.latestFrame=void 0,this.started=!1)}pump(t){this.loop.pump(t)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};function Gf(e){if(e<0||e>=q.MaxConfigStrings)throw new RangeError(`Configstring index ${e} is out of range (0-${q.MaxConfigStrings-1})`)}function zc(e,t){let r=Rc(e);if(t.length>r)throw new RangeError(`Configstring ${e} exceeds maximum length (${t.length} > ${r}); limit is ${Cn} chars per slot`)}var Ur=class{constructor(){this.values=new Map;this.modelCursor=q.Models;this.soundCursor=q.Sounds;this.imageCursor=q.Images;this.lightCursor=q.Lights;this.shadowLightCursor=q.ShadowLights;this.itemCursor=q.Items;this.playerSkinCursor=q.PlayerSkins;this.generalCursor=q.General}set(t,r){return Gf(t),zc(t,r),this.values.set(t,r),t}get(t){return this.values.get(t)}getName(t){return this.get(t)}getAll(){let t=new Array(Ic).fill("");for(let[r,n]of this.values.entries())t[r]=n;return t}modelIndex(t){return this.register(t,q.Models,xa,"modelCursor")}soundIndex(t){return this.register(t,q.Sounds,bo,"soundCursor")}findSoundIndex(t){for(let r=q.Sounds;r<q.Sounds+bo;r+=1)if(this.values.get(r)===t)return r}imageIndex(t){return this.register(t,q.Images,_a,"imageCursor")}lightIndex(t){return this.register(t,q.Lights,ya,"lightCursor")}shadowLightIndex(t){return this.register(t,q.ShadowLights,Sa,"shadowLightCursor")}itemIndex(t){return this.register(t,q.Items,ba,"itemCursor")}playerSkinIndex(t){return this.register(t,q.PlayerSkins,_o,"playerSkinCursor")}generalIndex(t){return this.register(t,q.General,va,"generalCursor")}register(t,r,n,i){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===t)return a;let o=this[i],s=r+n;if(o>=s)throw new RangeError(`Out of configstring slots for range starting at ${r}`);return zc(o,t),this.values.set(o,t),this[i]=o+1,o}};var Hr=class{constructor(t){this.registry=t.registry,this.system=t.system,this.music=t.music,this.client=t.client}soundindex(t){return this.registry.registerName(t)}sound(t,r,n,i,o,s){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,timeOffsetMs:s}),this.triggerSubtitle(n)}positioned_sound(t,r,n,i){this.system.positionedSound(t,r,n,i),this.triggerSubtitle(r)}loop_sound(t,r,n,i,o){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,looping:!0}),this.triggerSubtitle(n)}stop_entity_sounds(t){this.system.stopEntitySounds(t)}set_listener(t){this.system.setListener(t)}play_music(t,r=!0){return this.music?this.music.play(t,{loop:r}):Promise.resolve()}pause_music(){this.music?.pause()}resume_music(){return this.music?.resume()??Promise.resolve()}stop_music(){this.music?.stop()}set_music_volume(t){this.music?.setVolume(t)}play_ambient(t,r,n){this.system.ambientSound(t,r,n),this.triggerSubtitle(r)}play_channel(t){this.system.play({...t}),this.triggerSubtitle(t.soundIndex)}triggerSubtitle(t){if(!this.client)return;let r=this.registry.getName(t);if(!r)return;let n=r.match(/\[(.*?)\]/);n&&this.client.showSubtitle(n[1],r)}};var Pn=class{constructor(t,r){this.engine=t;this.host=r;this.started=!1}start(){this.started||(this.engine.init(),this.host.start(),this.started=!0)}stop(){this.started&&(this.host.stop(),this.engine.shutdown(),this.started=!1)}pump(t){this.host.pump(t)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function kc(e,t,r,n,i){let o=new Hr({...n,client:r}),s=new Nr(t,r,i);return{runtime:new Pn(e,s),audio:o}}var Wf="PACK";function Xf(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function ae(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function Kf(){let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let r=t;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e}var $f=Kf();function Fc(e){let t=4294967295;for(let r=0;r<e.length;r+=1){let n=e[r];t=$f[(t^n)&255]^t>>>8}return(t^4294967295)>>>0}var He=class extends Error{},Vr=class e{constructor(t,r,n,i){this.name=t;this.buffer=r;this.entries=new Map(n.map(o=>[o.name,o])),this.checksum=i,this.size=r.byteLength}static fromArrayBuffer(t,r){let n=new DataView(r);if(r.byteLength<12)throw new He("PAK buffer too small to contain header");let i=String.fromCharCode(n.getUint8(0),n.getUint8(1),n.getUint8(2),n.getUint8(3));if(i!==Wf)throw new He(`Invalid PAK header magic: ${i}`);let o=n.getInt32(4,!0),s=n.getInt32(8,!0);if(o<12)throw new He(`Invalid directory offset: ${o}`);if(s<=0||s%64!==0)throw new He(`Invalid directory length: ${s}`);if(o+s>r.byteLength)throw new He("Directory exceeds buffer length");let d=s/64,l=[],c=new Map;for(let h=0;h<d;h+=1){let u=o+h*64,f=Xf(n,u,56),m=ae(f),g=n.getInt32(u+56,!0),p=n.getInt32(u+60,!0);if(g<0||p<0||g+p>r.byteLength)throw new He(`Invalid entry bounds for ${f||"<unnamed>"} (offset=${g}, length=${p})`);if(!m)throw new He(`Entry ${h} has an empty name`);let x={name:m,offset:g,length:p};c.set(m,x)}return l.push(...c.values()),new e(t,r,l,Fc(new Uint8Array(r)))}getEntry(t){return this.entries.get(ae(t))}listEntries(){return Array.from(this.entries.values())}readFile(t){let r=this.getEntry(t);if(!r)throw new He(`File not found in PAK: ${t}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function Pc(e){return Fc(new Uint8Array(e))}var vo=class{constructor(t=[]){this.mounts=[];this.files=new Map;t.forEach(r=>this.mountPak(r))}mountPak(t){this.mounts.push(t);for(let r of t.listEntries()){let n=ae(r.name);this.files.set(n,{archive:t,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(t){return this.files.has(ae(t))}stat(t){let r=this.files.get(ae(t));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(t){let r=this.files.get(ae(t));if(!r)throw new Error(`File not found in VFS: ${t}`);return r.archive.readFile(t)}list(t=""){let r=ae(t).replace(/\/+$|^\//g,""),n=[],i=new Set,o=r?`${r}/`:"";for(let s of this.files.values()){if(r&&!s.entry.name.startsWith(o))continue;let a=r?s.entry.name.slice(o.length):s.entry.name,d=a.indexOf("/");d===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):i.add(a.slice(0,d))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...i].sort()}}findByExtension(t){let r=t.startsWith(".")?t.toLowerCase():`.${t.toLowerCase()}`,n=[];for(let i of this.files.values())i.entry.name.toLowerCase().endsWith(r)&&n.push({path:i.entry.name,size:i.entry.length,sourcePak:i.archive.name});return n.sort((i,o)=>i.path.localeCompare(o.path))}};var wa=Object.freeze([{name:"pak0.pak",checksum:2378051181,description:"Base game assets"},{name:"pak0.pak@baseq2",checksum:2378051181,description:"Base game assets (baseq2)"},{name:"pak0.pak@rogue",checksum:3373211245,description:"Ground Zero (rogue) mission pack"},{name:"pak0.pak@xatrix",checksum:1358269824,description:"The Reckoning (xatrix) mission pack"}]),sr=class extends Error{constructor(r){super(r.status==="unknown"?`Unknown PAK not allowed: ${r.name}`:`PAK checksum mismatch for ${r.name}`);this.result=r;this.name="PakValidationError"}},So=class{constructor(t=wa){this.known=new Map;t.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(t,r){let n=this.normalizePakName(r??("name"in t?t.name:"unknown")),i=t.checksum,o="size"in t?t.size:void 0,s=this.known.get(n);return s?s.checksum!==i?{name:n,checksum:i,expectedChecksum:s.checksum,status:"mismatch",size:o,description:s.description}:{name:n,checksum:i,expectedChecksum:s.checksum,status:"valid",size:o,description:s.description}:{name:n,checksum:i,status:"unknown",size:o}}assertValid(t,r){let n=this.validateArchive(t,r);if(n.status==="mismatch")throw new sr(n);return n}normalizePakName(t){let r=ae(t),n=r.split("/"),i=n.pop()??r,o=n.pop();return o?`${i}@${o}`:i}};var zt=class extends Error{constructor(r,n){super(`Failed to ingest PAK: ${r}`);this.file=r;this.name="PakIngestionError",n instanceof Error&&n.stack&&(this.stack=n.stack),this.cause=n}};async function Zf(e,t){if(typeof e.arrayBuffer=="function"){let r=await e.arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof FileReader<"u")return new Promise((r,n)=>{let i=new FileReader;i.onerror=()=>n(i.error??new Error("Unknown FileReader error")),i.onprogress=o=>{t?.({file:"blob",loadedBytes:o.loaded,totalBytes:o.total||e.size,state:"reading"})},i.onload=()=>{let o=i.result;o instanceof ArrayBuffer?r(o):n(new Error("Unexpected FileReader result"))},i.readAsArrayBuffer(e)});if(typeof Response<"u"){let r=await new Response(e).arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof e.stream=="function"){let r=e.stream().getReader(),n=[],i=0;for(;;){let{done:a,value:d}=await r.read();if(a)break;if(!d)continue;let l=d;n.push(l),i+=l.byteLength,t?.({file:"blob",loadedBytes:i,totalBytes:e.size,state:"reading"})}let o=new Uint8Array(i),s=0;for(let a of n)o.set(a,s),s+=a.byteLength;return o.buffer}throw new zt("blob",new Error("Unsupported Blob type"))}async function Yf(e,t){if(e.data instanceof ArrayBuffer)return t?.({file:e.name,loadedBytes:e.data.byteLength,totalBytes:e.data.byteLength,state:"reading"}),e.data;if(e.data instanceof Blob){let n=e.data.size;return Zf(e.data,i=>t?.({...i,file:e.name,totalBytes:n}))}let r=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength);return t?.({file:e.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function wo(e,t,r){let n=typeof r=="function"?{onProgress:r}:r??{},i=n.persistIndexes??!!n.pakIndexStore,o=n.enforceValidation??!!n.validator,s=n.allowUnknownPaks??!0,a=n.stopOnError??!1,d=[];for(let l of t)try{let c=await Yf(l,n.onProgress),h=Vr.fromArrayBuffer(l.name,c),u=n.validator?.validateArchive(h);if(u){n.onValidationResult?.(u);let f=u.status==="mismatch",m=u.status==="unknown";if(f&&o||m&&!s){let g=new sr(u);if(n.onError?.(l.name,g),a)throw new zt(l.name,g);d.push({archive:h,mounted:!1,validation:u});continue}}if(e.mountPak(h),i&&n.pakIndexStore)try{await n.pakIndexStore.persist(h)}catch(f){if(n.onError?.(l.name,f),a)throw new zt(l.name,f)}n.onProgress?.({file:l.name,loadedBytes:c.byteLength,totalBytes:c.byteLength,state:"parsed"}),d.push({archive:h,mounted:!0,validation:u})}catch(c){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,c),a)throw new zt(l.name,c)}return d}var kt=class{constructor(t){this.capacity=t;this.map=new Map;if(t<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(t){return this.map.has(t)}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}set(t,r){if(this.map.has(t)&&this.map.delete(t),this.map.set(t,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([t,r])=>({key:t,value:r}))}};function qf(e){return Array.isArray(e)?e:Array.from(e)}function Aa(e){return qf(e).map(t=>({name:t.name,data:t}))}async function Dc(e,t,r){let n=Aa(t);return wo(e,n,r??{})}function Oc(e,t){let r=i=>{i.preventDefault(),i.dataTransfer?.dropEffect&&(i.dataTransfer.dropEffect="copy")},n=i=>{i.preventDefault();let o=i.dataTransfer?.files;o&&o.length>0&&t(Array.from(o))};return e.addEventListener("dragover",r),e.addEventListener("drop",n),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",n)}}function Bc(e,t){let r=n=>{let i=n.target;!i||!i.files||i.files.length===0||(t(i.files),i.value="")};return e.addEventListener("change",r),()=>e.removeEventListener("change",r)}var jf="IBSP",Qf=38,Uc=19,Jf=8+Uc*8;var j=class extends Error{},Gr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Ma(n.buffer)}};function Ma(e){if(e.byteLength<Jf)throw new j("BSP too small to contain header");let t=new DataView(e),r=String.fromCharCode(t.getUint8(0),t.getUint8(1),t.getUint8(2),t.getUint8(3));if(r!==jf)throw new j(`Invalid BSP magic ${r}`);let n=t.getInt32(4,!0);if(n!==Qf)throw new j(`Unsupported BSP version ${n}`);let i=new Map;for(let v=0;v<Uc;v+=1){let E=t.getInt32(8+v*8,!0),L=t.getInt32(12+v*8,!0);if(E<0||L<0||E+L>e.byteLength)throw new j(`Invalid lump bounds for index ${v}`);i.set(v,{offset:E,length:L})}let o={version:n,lumps:i},s=th(e,i.get(0)),a=nh(e,i.get(1)),d=ih(e,i.get(2)),l=oh(e,i.get(4)),c=sh(e,i.get(5)),h=ah(e,i.get(6)),u=new Uint8Array(e,i.get(7).offset,i.get(7).length),f=gh(h,i.get(7)),m=lh(e,i.get(8)),g=ch(e,i.get(11)),p=dh(e,i.get(12)),x=uh(e,i.get(13)),S=fh(e,i.get(14)),_=hh(e,i.get(15)),y=mh(e,i.get(9),i.get(10),m),b=ph(e,i.get(3));return{header:o,entities:s,planes:a,vertices:d,nodes:l,texInfo:c,faces:h,lightMaps:u,lightMapInfo:f,leafs:m,leafLists:y,edges:g,surfEdges:p,models:x,brushes:S,brushSides:_,visibility:b,pickEntity(v){let E=null,L=1/0;for(let w of s.entities){let T=w.properties.model;if(!T||!T.startsWith("*"))continue;let z=parseInt(T.substring(1),10);if(isNaN(z)||z<0||z>=x.length)continue;let U=x[z],C=eh(v.origin,v.direction,U.mins,U.maxs);C!==null&&C<L&&(L=C,E={entity:w,model:U,distance:C})}return E}}}function eh(e,t,r,n){let i=0,o=1/0;for(let s=0;s<3;s++)if(Math.abs(t[s])<1e-8){if(e[s]<r[s]||e[s]>n[s])return null}else{let a=1/t[s],d=(r[s]-e[s])*a,l=(n[s]-e[s])*a;if(d>l){let c=d;d=l,l=c}if(i=Math.max(i,d),o=Math.min(o,l),i>o)return null}return i}function th(e,t){let r=new TextDecoder().decode(new Uint8Array(e,t.offset,t.length)),n=rh(r),i=n.find(o=>o.classname==="worldspawn");return{raw:r,entities:n,worldspawn:i,getUniqueClassnames(){let o=new Set;for(let s of n)s.classname&&o.add(s.classname);return Array.from(o).sort()}}}function rh(e){let t=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(e))!==null;){let i=n[1],o={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(i))!==null;)o[a[1]]=a[2];t.push({classname:o.classname,properties:o})}return t}function nh(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/20;if(n%1!==0)throw new j("Plane lump has invalid length");let i=[];for(let o=0;o<n;o+=1){let s=[r.getFloat32(o*20,!0),r.getFloat32(o*20+4,!0),r.getFloat32(o*20+8,!0)],a=r.getFloat32(o*20+12,!0),d=r.getInt32(o*20+16,!0);i.push({normal:s,dist:a,type:d})}return i}function ih(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/12;if(n%1!==0)throw new j("Vertex lump has invalid length");let i=[];for(let o=0;o<n;o+=1)i.push([r.getFloat32(o*12,!0),r.getFloat32(o*12+4,!0),r.getFloat32(o*12+8,!0)]);return i}function oh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Node lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],c=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],h=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],u=r.getUint16(a+24,!0),f=r.getUint16(a+26,!0);o.push({planeIndex:d,children:l,mins:c,maxs:h,firstFace:u,numFaces:f})}return o}function sh(e,t){let r=new DataView(e,t.offset,t.length),n=76,i=t.length/n;if(i%1!==0)throw new j("TexInfo lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),c=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],h=r.getFloat32(a+28,!0),u=r.getInt32(a+32,!0),f=r.getInt32(a+36,!0),m=new Uint8Array(e,t.offset+a+40,32),g=new TextDecoder("utf-8").decode(m).replace(/\0.*$/,""),p=r.getInt32(a+72,!0);o.push({s:d,sOffset:l,t:c,tOffset:h,flags:u,value:f,texture:g,nextTexInfo:p})}return o}function ah(e,t){let r=new DataView(e,t.offset,t.length),n=20,i=t.length/n;if(i%1!==0)throw new j("Face lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getUint16(a,!0),l=r.getInt16(a+2,!0),c=r.getInt32(a+4,!0),h=r.getInt16(a+8,!0),u=r.getInt16(a+10,!0),f=[r.getUint8(a+12),r.getUint8(a+13),r.getUint8(a+14),r.getUint8(a+15)],m=r.getInt32(a+16,!0);o.push({planeIndex:d,side:l,firstEdge:c,numEdges:h,texInfo:u,styles:f,lightOffset:m})}return o}function lh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Leaf lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=r.getInt16(a+4,!0),c=r.getInt16(a+6,!0),h=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],u=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],f=r.getUint16(a+20,!0),m=r.getUint16(a+22,!0),g=r.getUint16(a+24,!0),p=r.getUint16(a+26,!0);o.push({contents:d,cluster:l,area:c,mins:h,maxs:u,firstLeafFace:f,numLeafFaces:m,firstLeafBrush:g,numLeafBrushes:p})}return o}function ch(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Edge lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({vertices:[r.getUint16(a,!0),r.getUint16(a+2,!0)]})}return o}function dh(e,t){let r=t.length/4;if(r%1!==0)throw new j("SurfEdge lump has invalid length");let n=new DataView(e,t.offset,t.length),i=new Int32Array(r);for(let o=0;o<r;o+=1)i[o]=n.getInt32(o*4,!0);return i}function uh(e,t){let r=new DataView(e,t.offset,t.length),n=48;if(t.length%n!==0)throw new j("Model lump has invalid length");let i=t.length/n,o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=[r.getFloat32(a+12,!0),r.getFloat32(a+16,!0),r.getFloat32(a+20,!0)],c=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],h=r.getInt32(a+36,!0),u=r.getInt32(a+40,!0),f=r.getInt32(a+44,!0);o.push({mins:d,maxs:l,origin:c,headNode:h,firstFace:u,numFaces:f})}return o}function fh(e,t){let r=new DataView(e,t.offset,t.length),n=12,i=t.length/n;if(i%1!==0)throw new j("Brush lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({firstSide:r.getInt32(a,!0),numSides:r.getInt32(a+4,!0),contents:r.getInt32(a+8,!0)})}return o}function hh(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Brush side lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({planeIndex:r.getUint16(a,!0),texInfo:r.getInt16(a+2,!0)})}return o}function mh(e,t,r,n){let i=[],o=[],s=t.length/2,a=r.length/2,d=new DataView(e,t.offset,t.length),l=new DataView(e,r.offset,r.length);for(let c of n){if(c.firstLeafFace+c.numLeafFaces>s)throw new j("Leaf faces reference data past lump bounds");if(c.firstLeafBrush+c.numLeafBrushes>a)throw new j("Leaf brushes reference data past lump bounds");let h=[];for(let f=0;f<c.numLeafFaces;f+=1)h.push(d.getUint16((c.firstLeafFace+f)*2,!0));let u=[];for(let f=0;f<c.numLeafBrushes;f+=1)u.push(l.getUint16((c.firstLeafBrush+f)*2,!0));i.push(h),o.push(u)}return{leafFaces:i,leafBrushes:o}}function ph(e,t){if(t.length===0)return;if(t.length<4)throw new j("Visibility lump too small");let r=new DataView(e,t.offset,t.length),n=r.getInt32(0,!0),i=4+n*8;if(n<0||i>t.length)throw new j("Visibility lump truncated");let o=4,s=[];for(let a=0;a<n;a+=1){let d=r.getInt32(o,!0),l=r.getInt32(o+4,!0);o+=8;let c=t.offset+d,h=t.offset+l,u=t.offset+t.length;if(d<0||l<0||c>=u||h>=u)throw new j("Visibility offsets out of range");s.push({pvs:Nc(e,c,n,t),phs:Nc(e,h,n,t)})}return{numClusters:n,clusters:s}}function Nc(e,t,r,n){let i=Math.ceil(r/8),o=new Uint8Array(i),s=new Uint8Array(e),a=t,d=0,l=n.offset+n.length;for(;d<i;){if(a>=l)throw new j("Visibility data truncated");let c=s[a++];if(c!==0){o[d++]=c;continue}if(a>=l)throw new j("Visibility run exceeds lump bounds");let h=s[a++];for(let u=0;u<h&&d<i;u+=1)o[d++]=0}return o}function gh(e,t){return e.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,t.length-r.lightOffset)}})}function Ao(e,t,r){if(e.lightOffset<0||e.lightOffset>=t.byteLength)return;let n=t.byteLength-e.lightOffset,i=Math.min(r?.length??n,n);if(!(i<=0))return t.subarray(e.lightOffset,e.lightOffset+i)}var yh=844121161,xh=8,Hc=68,_h=[{x:-.525731,y:0,z:.850651},{x:-.442863,y:.238856,z:.864188},{x:-.295242,y:0,z:.955423},{x:-.309017,y:.5,z:.809017},{x:-.16246,y:.262866,z:.951056},{x:0,y:0,z:1},{x:0,y:.850651,z:.525731},{x:-.147621,y:.716567,z:.681718},{x:.147621,y:.716567,z:.681718},{x:0,y:.525731,z:.850651},{x:.309017,y:.5,z:.809017},{x:.525731,y:0,z:.850651},{x:.295242,y:0,z:.955423},{x:.442863,y:.238856,z:.864188},{x:.16246,y:.262866,z:.951056},{x:-.681718,y:.147621,z:.716567},{x:-.809017,y:.309017,z:.5},{x:-.587785,y:.425325,z:.688191},{x:-.850651,y:.525731,z:0},{x:-.864188,y:.442863,z:.238856},{x:-.716567,y:.681718,z:.147621},{x:-.688191,y:.587785,z:.425325},{x:-.5,y:.809017,z:.309017},{x:-.238856,y:.864188,z:.442863},{x:-.425325,y:.688191,z:.587785},{x:-.716567,y:.681718,z:-.147621},{x:-.5,y:.809017,z:-.309017},{x:-.525731,y:.850651,z:0},{x:0,y:.850651,z:-.525731},{x:-.238856,y:.864188,z:-.442863},{x:0,y:.955423,z:-.295242},{x:-.262866,y:.951056,z:-.16246},{x:0,y:1,z:0},{x:0,y:.955423,z:.295242},{x:-.262866,y:.951056,z:.16246},{x:.238856,y:.864188,z:.442863},{x:.262866,y:.951056,z:.16246},{x:.5,y:.809017,z:.309017},{x:.238856,y:.864188,z:-.442863},{x:.262866,y:.951056,z:-.16246},{x:.5,y:.809017,z:-.309017},{x:.850651,y:.525731,z:0},{x:.716567,y:.681718,z:.147621},{x:.716567,y:.681718,z:-.147621},{x:.525731,y:.850651,z:0},{x:.425325,y:.688191,z:.587785},{x:.864188,y:.442863,z:.238856},{x:.688191,y:.587785,z:.425325},{x:.809017,y:.309017,z:.5},{x:.681718,y:.147621,z:.716567},{x:.587785,y:.425325,z:.688191},{x:.955423,y:.295242,z:0},{x:1,y:0,z:0},{x:.951056,y:.16246,z:.262866},{x:.850651,y:-.525731,z:0},{x:.955423,y:-.295242,z:0},{x:.864188,y:-.442863,z:.238856},{x:.951056,y:-.16246,z:.262866},{x:.809017,y:-.309017,z:.5},{x:.681718,y:-.147621,z:.716567},{x:.850651,y:0,z:.525731},{x:.864188,y:.442863,z:-.238856},{x:.809017,y:.309017,z:-.5},{x:.951056,y:.16246,z:-.262866},{x:.525731,y:0,z:-.850651},{x:.681718,y:.147621,z:-.716567},{x:.681718,y:-.147621,z:-.716567},{x:.850651,y:0,z:-.525731},{x:.809017,y:-.309017,z:-.5},{x:.864188,y:-.442863,z:-.238856},{x:.951056,y:-.16246,z:-.262866},{x:.147621,y:.716567,z:-.681718},{x:.309017,y:.5,z:-.809017},{x:.425325,y:.688191,z:-.587785},{x:.442863,y:.238856,z:-.864188},{x:.587785,y:.425325,z:-.688191},{x:.688191,y:.587785,z:-.425325},{x:-.147621,y:.716567,z:-.681718},{x:-.309017,y:.5,z:-.809017},{x:0,y:.525731,z:-.850651},{x:-.525731,y:0,z:-.850651},{x:-.442863,y:.238856,z:-.864188},{x:-.295242,y:0,z:-.955423},{x:-.16246,y:.262866,z:-.951056},{x:0,y:0,z:-1},{x:.295242,y:0,z:-.955423},{x:.16246,y:.262866,z:-.951056},{x:-.442863,y:-.238856,z:-.864188},{x:-.309017,y:-.5,z:-.809017},{x:-.16246,y:-.262866,z:-.951056},{x:0,y:-.850651,z:-.525731},{x:-.147621,y:-.716567,z:-.681718},{x:.147621,y:-.716567,z:-.681718},{x:0,y:-.525731,z:-.850651},{x:.309017,y:-.5,z:-.809017},{x:.442863,y:-.238856,z:-.864188},{x:.16246,y:-.262866,z:-.951056},{x:.238856,y:-.864188,z:-.442863},{x:.5,y:-.809017,z:-.309017},{x:.425325,y:-.688191,z:-.587785},{x:.716567,y:-.681718,z:-.147621},{x:.688191,y:-.587785,z:-.425325},{x:.587785,y:-.425325,z:-.688191},{x:0,y:-.955423,z:-.295242},{x:0,y:-1,z:0},{x:.262866,y:-.951056,z:-.16246},{x:0,y:-.850651,z:.525731},{x:0,y:-.955423,z:.295242},{x:.238856,y:-.864188,z:.442863},{x:.262866,y:-.951056,z:.16246},{x:.5,y:-.809017,z:.309017},{x:.716567,y:-.681718,z:.147621},{x:.525731,y:-.850651,z:0},{x:-.238856,y:-.864188,z:-.442863},{x:-.5,y:-.809017,z:-.309017},{x:-.262866,y:-.951056,z:-.16246},{x:-.850651,y:-.525731,z:0},{x:-.716567,y:-.681718,z:-.147621},{x:-.716567,y:-.681718,z:.147621},{x:-.525731,y:-.850651,z:0},{x:-.5,y:-.809017,z:.309017},{x:-.238856,y:-.864188,z:.442863},{x:-.262866,y:-.951056,z:.16246},{x:-.864188,y:-.442863,z:.238856},{x:-.809017,y:-.309017,z:.5},{x:-.688191,y:-.587785,z:.425325},{x:-.681718,y:-.147621,z:.716567},{x:-.442863,y:-.238856,z:.864188},{x:-.587785,y:-.425325,z:.688191},{x:-.309017,y:-.5,z:.809017},{x:-.147621,y:-.716567,z:.681718},{x:-.425325,y:-.688191,z:.587785},{x:-.16246,y:-.262866,z:.951056},{x:.442863,y:-.238856,z:.864188},{x:.16246,y:-.262866,z:.951056},{x:.309017,y:-.5,z:.809017},{x:.147621,y:-.716567,z:.681718},{x:0,y:-.525731,z:.850651},{x:.425325,y:-.688191,z:.587785},{x:.587785,y:-.425325,z:.688191},{x:.688191,y:-.587785,z:.425325},{x:-.955423,y:.295242,z:0},{x:-.951056,y:.16246,z:.262866},{x:-1,y:0,z:0},{x:-.850651,y:0,z:.525731},{x:-.955423,y:-.295242,z:0},{x:-.951056,y:-.16246,z:.262866},{x:-.864188,y:.442863,z:-.238856},{x:-.951056,y:.16246,z:-.262866},{x:-.809017,y:.309017,z:-.5},{x:-.864188,y:-.442863,z:-.238856},{x:-.951056,y:-.16246,z:-.262866},{x:-.809017,y:-.309017,z:-.5},{x:-.681718,y:.147621,z:-.716567},{x:-.681718,y:-.147621,z:-.716567},{x:-.850651,y:0,z:-.525731},{x:-.688191,y:.587785,z:-.425325},{x:-.587785,y:.425325,z:-.688191},{x:-.425325,y:.688191,z:-.587785},{x:-.425325,y:-.688191,z:-.587785},{x:-.587785,y:-.425325,z:-.688191},{x:-.688191,y:-.587785,z:-.425325}],me=class extends Error{},Wr=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);n.set(r);let i=Ea(n.buffer);return this.cache.set(t,i),i}get(t){return this.cache.get(t)}};function Vc(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Dn(e,t,r,n){if(r!==0&&(t<Hc||t+r>e.byteLength))throw new me(`${n} section is out of bounds`)}function bh(e){if(e.byteLength<Hc)throw new me("MD2 buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0);if(r!==yh)throw new me(`Invalid MD2 ident: ${r}`);if(n!==xh)throw new me(`Unsupported MD2 version: ${n}`);let i={ident:r,version:n,skinWidth:t.getInt32(8,!0),skinHeight:t.getInt32(12,!0),frameSize:t.getInt32(16,!0),numSkins:t.getInt32(20,!0),numVertices:t.getInt32(24,!0),numTexCoords:t.getInt32(28,!0),numTriangles:t.getInt32(32,!0),numGlCommands:t.getInt32(36,!0),numFrames:t.getInt32(40,!0),offsetSkins:t.getInt32(44,!0),offsetTexCoords:t.getInt32(48,!0),offsetTriangles:t.getInt32(52,!0),offsetFrames:t.getInt32(56,!0),offsetGlCommands:t.getInt32(60,!0),offsetEnd:t.getInt32(64,!0),magic:r},o=40+i.numVertices*4;if(i.frameSize!==o)throw new me(`Unexpected frame size ${i.frameSize}, expected ${o}`);if(i.offsetEnd>e.byteLength)throw new me("MD2 offset_end exceeds buffer length");return i}function vh(e,t){let r=t.numSkins*64;Dn(e,t.offsetSkins,r,"skins");let n=new DataView(e,t.offsetSkins,r),i=[];for(let o=0;o<t.numSkins;o+=1)i.push({name:Vc(n,o*64,64)});return i}function Sh(e,t){let r=t.numTexCoords*4;Dn(e,t.offsetTexCoords,r,"texcoords");let n=new DataView(e,t.offsetTexCoords,r),i=[];for(let o=0;o<t.numTexCoords;o+=1){let s=o*4;i.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return i}function wh(e,t){let r=t.numTriangles*12;Dn(e,t.offsetTriangles,r,"triangles");let n=new DataView(e,t.offsetTriangles,r),i=[];for(let o=0;o<t.numTriangles;o+=1){let s=o*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],d=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=t.numVertices)||d.some(l=>l>=t.numTexCoords))throw new me("Triangle references out of range vertex or texcoord");i.push({vertexIndices:a,texCoordIndices:d})}return i}function Ah(e,t){let r=t.numFrames*t.frameSize;Dn(e,t.offsetFrames,r,"frames");let n=[];for(let i=0;i<t.numFrames;i+=1){let o=t.offsetFrames+i*t.frameSize,s=new DataView(e,o,t.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},d={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=Vc(s,24,16),c=[],h=1/0,u=1/0,f=1/0,m=-1/0,g=-1/0,p=-1/0;for(let x=0;x<t.numVertices;x+=1){let S=40+x*4,_=s.getUint8(S)*a.x+d.x,y=s.getUint8(S+1)*a.y+d.y,b=s.getUint8(S+2)*a.z+d.z;_<h&&(h=_),y<u&&(u=y),b<f&&(f=b),_>m&&(m=_),y>g&&(g=y),b>p&&(p=b);let A={x:_,y,z:b},v=s.getUint8(S+3),E=_h[v];if(!E)throw new me(`Invalid normal index ${v} in frame ${l}`);c.push({position:A,normalIndex:v,normal:E})}n.push({name:l,vertices:c,minBounds:{x:h,y:u,z:f},maxBounds:{x:m,y:g,z:p}})}return n}function Mh(e,t){let r=t.numGlCommands*4;if(Dn(e,t.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(e,t.offsetGlCommands,r),i=[],o=0;for(;;){if(o+4>r)throw new me("GL command list ended unexpectedly");let s=n.getInt32(o,!0);if(o+=4,s===0)break;let a=Math.abs(s),d=[],l=a*12;if(o+l>r)throw new me("GL command vertex block exceeds buffer");for(let c=0;c<a;c+=1){let h=n.getFloat32(o,!0),u=n.getFloat32(o+4,!0),f=n.getInt32(o+8,!0);if(o+=12,f<0||f>=t.numVertices)throw new me("GL command references invalid vertex index");d.push({s:h,t:u,vertexIndex:f})}i.push({mode:s>0?"strip":"fan",vertices:d})}if(o!==r)throw new me("GL command list did not consume expected data");return i}function Ea(e){let t=bh(e),r=vh(e,t),n=Sh(e,t),i=wh(e,t),o=Ah(e,t),s=Mh(e,t);return{header:t,skins:r,texCoords:n,triangles:i,frames:o,glCommands:s}}function Gc(e){let t=[],r=0;for(;r<e.length;){let n=e[r].name,i=n.replace(/\d+$/,"")||n,o=r;for(;o+1<e.length&&(e[o+1].name.replace(/\d+$/,"")||e[o+1].name)===i;)o+=1;t.push({name:i,firstFrame:r,lastFrame:o}),r=o+1}return t}var Wc=860898377,Eh=15,Ve=class extends Error{constructor(t){super(t),this.name="Md3ParseError"}};function On(e,t,r){let n=new Uint8Array(e.buffer,e.byteOffset+t,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function Lh(e){let t=(e>>8&255)*(2*Math.PI/255),r=(e&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(t)*n,y:Math.sin(t)*n,z:Math.cos(r)}}function Mo(e,t,r,n){if(t<0||t+r>n)throw new Ve(`${e} exceeds buffer bounds`)}function Th(e){let t=e.getInt32(0,!0);if(t!==Wc)throw new Ve(`Invalid MD3 ident: ${t}`);let r=e.getInt32(4,!0);if(r!==Eh)throw new Ve(`Unsupported MD3 version: ${r}`);let n=On(e,8,64),i=e.getInt32(72,!0),o=e.getInt32(76,!0),s=e.getInt32(80,!0),a=e.getInt32(84,!0),d=e.getInt32(88,!0),l=e.getInt32(92,!0),c=e.getInt32(96,!0),h=e.getInt32(100,!0),u=e.getInt32(104,!0);if(o<=0||a<0||s<0)throw new Ve("Invalid MD3 counts");return{ident:t,version:r,name:n,flags:i,numFrames:o,numTags:s,numSurfaces:a,numSkins:d,ofsFrames:l,ofsTags:c,ofsSurfaces:h,ofsEnd:u,magic:t}}function Ih(e,t){let r=[];Mo("Frames",t.ofsFrames,t.numFrames*56,e.byteLength);for(let i=0;i<t.numFrames;i+=1){let o=t.ofsFrames+i*56;r.push({minBounds:{x:e.getFloat32(o,!0),y:e.getFloat32(o+4,!0),z:e.getFloat32(o+8,!0)},maxBounds:{x:e.getFloat32(o+12,!0),y:e.getFloat32(o+16,!0),z:e.getFloat32(o+20,!0)},localOrigin:{x:e.getFloat32(o+24,!0),y:e.getFloat32(o+28,!0),z:e.getFloat32(o+32,!0)},radius:e.getFloat32(o+36,!0),name:On(e,o+40,16)})}return r}function Rh(e,t){let r=[],i=t.numFrames*t.numTags*112;Mo("Tags",t.ofsTags,i,e.byteLength);for(let o=0;o<t.numFrames;o+=1){let s=[];for(let a=0;a<t.numTags;a+=1){let d=t.ofsTags+(o*t.numTags+a)*112,l=d+64,c=l+12;s.push({name:On(e,d,64),origin:{x:e.getFloat32(l,!0),y:e.getFloat32(l+4,!0),z:e.getFloat32(l+8,!0)},axis:[{x:e.getFloat32(c,!0),y:e.getFloat32(c+4,!0),z:e.getFloat32(c+8,!0)},{x:e.getFloat32(c+12,!0),y:e.getFloat32(c+16,!0),z:e.getFloat32(c+20,!0)},{x:e.getFloat32(c+24,!0),y:e.getFloat32(c+28,!0),z:e.getFloat32(c+32,!0)}]})}r.push(s)}return r}function Ch(e,t){let r=e.getInt32(t,!0);if(r!==Wc)throw new Ve(`Invalid surface ident at ${t}: ${r}`);let n=On(e,t+4,64),i=e.getInt32(t+68,!0),o=e.getInt32(t+72,!0),s=e.getInt32(t+76,!0),a=e.getInt32(t+80,!0),d=e.getInt32(t+84,!0),l=e.getInt32(t+88,!0),c=e.getInt32(t+92,!0),h=e.getInt32(t+96,!0),u=e.getInt32(t+100,!0),f=e.getInt32(t+104,!0);if(o<=0||a<=0||d<=0)throw new Ve(`Invalid surface counts for ${n}`);let m=f;Mo(`Surface ${n}`,t,m,e.byteLength);let g=[],p=t+l;for(let v=0;v<d;v+=1){let E=p+v*12;g.push({indices:[e.getInt32(E,!0),e.getInt32(E+4,!0),e.getInt32(E+8,!0)]})}let x=[],S=t+c;for(let v=0;v<s;v+=1){let E=S+v*68;x.push({name:On(e,E,64),shaderIndex:e.getInt32(E+64,!0)})}let _=[],y=t+h;for(let v=0;v<a;v+=1){let E=y+v*8;_.push({s:e.getFloat32(E,!0),t:e.getFloat32(E+4,!0)})}let b=[],A=t+u;for(let v=0;v<o;v+=1){let E=[];for(let L=0;L<a;L+=1){let w=A+(v*a+L)*8,T=e.getInt16(w,!0)/64,z=e.getInt16(w+2,!0)/64,U=e.getInt16(w+4,!0)/64,C=e.getUint16(w+6,!0);E.push({position:{x:T,y:z,z:U},latLng:C,normal:Lh(C)})}b.push(E)}return{surface:{name:n,flags:i,numFrames:o,shaders:x,triangles:g,texCoords:_,vertices:b},nextOffset:t+f}}function La(e){if(e.byteLength<108)throw new Ve("MD3 buffer too small for header");let t=new DataView(e),r=Th(t);Mo("MD3 end",r.ofsEnd,0,e.byteLength);let n=Ih(t,r),i=Rh(t,r),o=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:d,nextOffset:l}=Ch(t,s);o.push(d),s=l}if(s!==r.ofsEnd)throw new Ve("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:i,surfaces:o}}var Xr=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=La(r.slice().buffer);return this.cache.set(t,n),n}get(t){return this.cache.get(t)}};var zh=844317769,kh=2,Xc=64,Kc=12,Ft=class extends Error{};function Fh(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Ta(e){if(e.byteLength<Kc)throw new Ft("Sprite buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0),i=t.getInt32(8,!0);if(r!==zh)throw new Ft(`Invalid Sprite ident: ${r}`);if(n!==kh)throw new Ft(`Unsupported Sprite version: ${n}`);let o=[],s=16+Xc,a=Kc;for(let d=0;d<i;d+=1){if(a+s>e.byteLength)throw new Ft("Sprite frame data exceeds buffer length");let l=t.getInt32(a,!0),c=t.getInt32(a+4,!0),h=t.getInt32(a+8,!0),u=t.getInt32(a+12,!0),f=Fh(t,a+16,Xc);o.push({width:l,height:c,originX:h,originY:u,name:f}),a+=s}return{ident:r,version:n,numFrames:i,frames:o}}var Kr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Ta(n.buffer)}};function $c(e,t){let r=(e.sequence.end-e.sequence.start+1)/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time+t;return n?i=(i%r+r)%r:i>r&&(i=r),{...e,time:Math.max(0,Math.min(i,r))}}function Zc(e){let t=e.sequence.end-e.sequence.start+1,r=1/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time/r;if(!n&&i>=t)return{frame0:e.sequence.end,frame1:e.sequence.end,lerp:0};let o=n?i%t:Math.min(i,t-1),s=Math.floor(o),a=e.sequence.start+s,d=s+1>=t?n?e.sequence.start:e.sequence.end:a+1,l=!n&&s>=t-1?0:o-s;return{frame0:a,frame1:d,lerp:l}}function Yc(e){return{sequence:e,time:0}}function qc(e,t,r){return{x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r,z:e.z+(t.z-e.z)*r}}var Bn=class extends Error{constructor(t){super(t),this.name="WalParseError"}};function Eo(e){if(e.byteLength<100)throw new Bn("WAL buffer too small");let t=new DataView(e),r=new Uint8Array(e,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),i=t.getInt32(32,!0),o=t.getInt32(36,!0),s=[t.getInt32(40,!0),t.getInt32(44,!0),t.getInt32(48,!0),t.getInt32(52,!0)],a=new Uint8Array(e,56,32),d=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=t.getInt32(88,!0),c=t.getInt32(92,!0),h=t.getInt32(96,!0);if(i<=0||o<=0)throw new Bn("Invalid WAL dimensions");let u=[],f=i,m=o;for(let g=0;g<s.length;g+=1){let p=s[g],x=Math.max(1,f*m|0);if(p<=0||p+x>e.byteLength)throw new Bn(`Invalid WAL mip offset for level ${g}`);let S=new Uint8Array(e,p,x);u.push({level:g,width:f,height:m,data:S}),f=Math.max(1,f>>1),m=Math.max(1,m>>1)}return{name:n,width:i,height:o,mipmaps:u,animName:d,flags:l,contents:c,value:h}}var ar=class extends Error{constructor(t){super(t),this.name="PcxParseError"}};function Nn(e){if(e.byteLength<128)throw new ar("PCX buffer too small for header");let t=new DataView(e),r=t.getUint8(0),n=t.getUint8(2),i=t.getUint8(3),o=t.getUint16(4,!0),s=t.getUint16(6,!0),a=t.getUint16(8,!0),d=t.getUint16(10,!0);if(r!==10||n!==1)throw new ar("Unsupported PCX encoding");if(i!==8)throw new ar("Only 8bpp PCX files are supported");let l=a-o+1,c=d-s+1,h=t.getUint16(66,!0),u=e.byteLength-769;if(u<128||new DataView(e,u,1).getUint8(0)!==12)throw new ar("Missing PCX palette");let f=new Uint8Array(e,u+1,768),m=new Uint8Array(e,128,u-128),g=new Uint8Array(l*c),p=0,x=0;for(let S=0;S<c;S+=1){let _=0;for(;_<h&&p<m.length;){let y=1,b=m[p++];if((b&192)===192){if(y=b&63,p>=m.length)throw new ar("Unexpected end of PCX RLE data");b=m[p++]}for(let A=0;A<y&&_<h;A+=1)_<l&&(g[x++]=b),_+=1}}return{width:l,height:c,bitsPerPixel:i,pixels:g,palette:f}}function Lo(e){let t=new Uint8Array(e.width*e.height*4);for(let r=0;r<e.pixels.length;r+=1){let n=e.pixels[r],i=n*3,o=r*4;t[o]=e.palette[i],t[o+1]=e.palette[i+1],t[o+2]=e.palette[i+2],t[o+3]=n===255?0:255}return t}var pt=class extends Error{constructor(t){super(t),this.name="TgaParseError"}};function Ia(e){let t=new DataView(e);if(e.byteLength<18)throw new pt("Buffer too small for TGA header");let r=t.getUint8(0),n=t.getUint8(1),i=t.getUint8(2),o=t.getUint16(12,!0),s=t.getUint16(14,!0),a=t.getUint8(16),d=t.getUint8(17);if(i!==2&&i!==10&&i!==3&&i!==11)throw new pt(`Unsupported TGA image type: ${i} (only RGB/Grayscale supported)`);if(a!==24&&a!==32&&a!==8)throw new pt(`Unsupported pixel depth: ${a} (only 8, 24, 32 bpp supported)`);let l=i>=9,c=i===3||i===11,h=a/8,u=18+r;if(n===1){let _=t.getUint16(5,!0),y=t.getUint8(7);u+=_*(y/8)}let f=o*s,m=new Uint8Array(f*4),g=(d&32)!==0,p=0,x=new Uint8Array(e),S=_=>{if(c){let y=x[u++];m[_]=y,m[_+1]=y,m[_+2]=y,m[_+3]=255}else{let y=x[u++],b=x[u++],A=x[u++],v=a===32?x[u++]:255;m[_]=A,m[_+1]=b,m[_+2]=y,m[_+3]=v}};if(l){let _=0;for(;_<f;){if(u>=e.byteLength)throw new pt("Unexpected end of TGA RLE data");let y=x[u++],b=(y&127)+1,A=(y&128)!==0;if(_+b>f)throw new pt("TGA RLE packet exceeds image bounds");if(A){let v=c?x[u]:x[u+2],E=c?x[u]:x[u+1],L=x[u],w=c?255:a===32?x[u+3]:255;u+=h;for(let T=0;T<b;T++){let z=(_+T)*4;m[z]=v,m[z+1]=E,m[z+2]=L,m[z+3]=w}}else for(let v=0;v<b;v++)S((_+v)*4);_+=b}}else for(let _=0;_<f;_++){if(u>=e.byteLength)throw new pt("Unexpected end of TGA data");S(_*4)}if(!g){let _=o*4,y=new Uint8Array(_);for(let b=0;b<s/2;b++){let A=b*_,v=(s-1-b)*_;y.set(m.subarray(A,A+_)),m.set(m.subarray(v,v+_),A),m.set(y,v)}}return{width:o,height:s,bitsPerPixel:32,pixels:m}}var $r=class{constructor(t={}){this.cache=new kt(t.capacity??128)}get size(){return this.cache.size}get(t){return this.cache.get(t.toLowerCase())}set(t,r){this.cache.set(t.toLowerCase(),r)}clear(){this.cache.clear()}};function Ra(e,t){let r=[];for(let n of e.mipmaps){let i=new Uint8Array(n.width*n.height*4);for(let o=0;o<n.data.length;o+=1){let s=n.data[o],a=s*3,d=o*4;i[d]=t[a],i[d+1]=t[a+1],i[d+2]=t[a+2],i[d+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:i})}return{width:e.width,height:e.height,levels:r,source:"wal"}}function To(e){let t=Lo(e),r={level:0,width:e.width,height:e.height,rgba:t};return{width:e.width,height:e.height,levels:[r],source:"pcx"}}function jc(e){let t={level:0,width:e.width,height:e.height,rgba:e.pixels};return{width:e.width,height:e.height,levels:[t],source:"tga"}}function Io(e,t){return Ra(Eo(e),t)}var lr=class extends Error{constructor(t){super(t),this.name="WavParseError"}};function Ca(e,t,r){return new TextDecoder("ascii").decode(new Uint8Array(e.buffer,e.byteOffset+t,r))}function Ro(e){if(e.byteLength<44)throw new lr("WAV buffer too small");let t=new DataView(e);if(Ca(t,0,4)!=="RIFF"||Ca(t,8,4)!=="WAVE")throw new lr("Invalid WAV header");let r=12,n=-1,i=-1,o=0,s=0;for(;r+8<=e.byteLength;){let m=Ca(t,r,4),g=t.getUint32(r+4,!0),p=r+8;m==="fmt "?(n=p,o=g):m==="data"&&(i=p,s=g),r=p+g}if(n===-1||i===-1)throw new lr("Missing fmt or data chunk");let a=t.getUint16(n,!0),d=t.getUint16(n+2,!0),l=t.getUint32(n+4,!0),c=t.getUint16(n+14,!0);if(a!==1)throw new lr("Only PCM WAV is supported");let h=c/8,u=s/(h*d),f=new Float32Array(u*d);for(let m=0;m<u;m+=1)for(let g=0;g<d;g+=1){let p=m*d+g,x=i+p*h,S=0;if(c===8)S=t.getUint8(x),f[p]=(S-128)/128;else if(c===16)S=t.getInt16(x,!0),f[p]=S/32768;else if(c===24){let _=t.getUint8(x),y=t.getUint8(x+1),b=t.getInt8(x+2);S=_|y<<8|b<<16,f[p]=S/8388608}else throw new lr(`Unsupported bitsPerSample: ${c}`)}return{sampleRate:l,channels:d,bitsPerSample:c,samples:f}}var Ph=(e,t=4294967295,r=79764919)=>{let n=new Int32Array(256),i,o,s,a=t;for(i=0;i<256;i++){for(s=i<<24,o=8;o>0;--o)s=2147483648&s?s<<1^r:s<<1;n[i]=s}for(i=0;i<e.length;i++)a=a<<8^n[255&(a>>24^e[i])];return a};var za=(e,t=Ph)=>{let r=p=>new Uint8Array(p.length/2).map(((x,S)=>parseInt(p.substring(2*S,2*(S+1)),16))),n=p=>r(p)[0],i=new Map;[,8364,,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,,381,,,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,,382,376].forEach(((p,x)=>i.set(p,x)));let o=new Uint8Array(e.length),s,a,d,l=!1,c=0,h=42,u=e.length>13&&e.substring(0,9)==="dynEncode",f=0;u&&(f=11,a=n(e.substring(9,f)),a<=1&&(f+=2,h=n(e.substring(11,f))),a===1&&(f+=8,d=(p=>new DataView(r(p).buffer).getInt32(0,!0))(e.substring(13,f))));let m=256-h;for(let p=f;p<e.length;p++)if(s=e.charCodeAt(p),s!==61||l){if(s===92&&p<e.length-5&&u){let x=e.charCodeAt(p+1);x!==117&&x!==85||(s=parseInt(e.substring(p+2,p+6),16),p+=5)}if(s>255){let x=i.get(s);x&&(s=x+127)}l&&(l=!1,s-=64),o[c++]=s<h&&s>0?s+m:s-h}else l=!0;let g=o.subarray(0,c);if(u&&a===1){let p=t(g);if(p!==d){let x="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",x+`
1
+ "use strict";var Quake2Engine=(()=>{var Uu=Object.create;var mo=Object.defineProperty;var Hu=Object.getOwnPropertyDescriptor;var Vu=Object.getOwnPropertyNames;var Gu=Object.getPrototypeOf,Wu=Object.prototype.hasOwnProperty;var Xu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ua=(e,t)=>{for(var r in t)mo(e,r,{get:t[r],enumerable:!0})},yc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vu(t))!Wu.call(e,i)&&i!==r&&mo(e,i,{get:()=>t[i],enumerable:!(n=Hu(t,i))||n.enumerable});return e};var Ku=(e,t,r)=>(r=e!=null?Uu(Gu(e)):{},yc(t||!e||!e.__esModule?mo(r,"default",{value:e,enumerable:!0}):r,e)),$u=e=>yc(mo({},"__esModule",{value:!0}),e);var Jc=Xu((N_,Qc)=>{"use strict";Qc.exports=Worker});var hx={};ua(hx,{ATTN_IDLE:()=>Cd,ATTN_LOOP_NONE:()=>Td,ATTN_NONE:()=>us,ATTN_NORM:()=>Id,ATTN_STATIC:()=>zd,AssetDependencyError:()=>Sr,AssetDependencyTracker:()=>Fi,AssetManager:()=>cs,AudioApi:()=>Hr,AudioContextController:()=>hs,AudioRegistry:()=>fn,AudioRegistryError:()=>zi,AudioSystem:()=>bs,BSP_SURFACE_FRAGMENT_SOURCE:()=>sl,BSP_SURFACE_VERTEX_SOURCE:()=>ol,BSP_VERTEX_LAYOUT:()=>rl,BspLoader:()=>Gr,BspParseError:()=>j,BspSurfacePipeline:()=>As,Camera:()=>Is,Command:()=>Cn,CommandRegistry:()=>Pr,ConfigStringRegistry:()=>Ur,Cvar:()=>Fn,CvarRegistry:()=>Br,DemoPlaybackController:()=>lo,DemoReader:()=>Ar,EngineHost:()=>Nr,EngineRuntime:()=>Dn,FixedTimestepLoop:()=>or,Framebuffer:()=>Ss,IndexBuffer:()=>ye,LruCache:()=>kt,MAX_SOUND_CHANNELS:()=>Qa,MD2_FRAGMENT_SHADER:()=>hl,MD2_VERTEX_SHADER:()=>fl,MD3_FRAGMENT_SHADER:()=>Sl,MD3_VERTEX_SHADER:()=>vl,Md2Loader:()=>Wr,Md2MeshBuffers:()=>Es,Md2ParseError:()=>me,Md2Pipeline:()=>Ls,Md3Loader:()=>Xr,Md3ModelMesh:()=>Cs,Md3ParseError:()=>Ve,Md3Pipeline:()=>zs,Md3SurfaceMesh:()=>Oi,MusicSystem:()=>vs,NetworkMessageParser:()=>Fr,PARTICLE_FRAGMENT_SHADER:()=>Al,PARTICLE_VERTEX_SHADER:()=>wl,PROTOCOL_VERSION_RERELEASE:()=>Ks,PakArchive:()=>Vr,PakIndexStore:()=>ls,PakIngestionError:()=>Rt,PakParseError:()=>He,PakValidationError:()=>sr,PakValidator:()=>So,ParticleRenderer:()=>ks,ParticleSystem:()=>Rs,PlaybackState:()=>da,RERELEASE_KNOWN_PAKS:()=>wa,SKYBOX_FRAGMENT_SHADER:()=>dl,SKYBOX_VERTEX_SHADER:()=>cl,SOUND_FULLVOLUME:()=>hn,SOUND_LOOP_ATTENUATE:()=>Rd,ShaderProgram:()=>Me,SkyboxPipeline:()=>Ms,SoundChannel:()=>ds,SoundPrecache:()=>gs,SoundRegistry:()=>ps,SpriteLoader:()=>Kr,SpriteParseError:()=>Ft,Texture2D:()=>mn,TextureCache:()=>$r,TextureCubeMap:()=>pn,TgaParseError:()=>pt,U_ALPHA:()=>nc,U_ANGLE1:()=>ta,U_ANGLE2:()=>qs,U_ANGLE3:()=>js,U_EFFECTS16:()=>so,U_EFFECTS8:()=>no,U_EVENT:()=>Js,U_FRAME16:()=>na,U_FRAME8:()=>Qs,U_INSTANCE_BITS:()=>oc,U_LOOP_ATTENUATION_HIGH:()=>ac,U_LOOP_VOLUME:()=>sc,U_MODEL:()=>ra,U_MODEL2:()=>ia,U_MODEL3:()=>oa,U_MODEL4:()=>sa,U_OLDORIGIN:()=>aa,U_OLD_FRAME_HIGH:()=>cc,U_ORIGIN1:()=>Zs,U_ORIGIN2:()=>Ys,U_ORIGIN3:()=>ea,U_OWNER_HIGH:()=>lc,U_REMOVE:()=>rc,U_RENDERFX16:()=>oo,U_RENDERFX8:()=>ro,U_SCALE:()=>ic,U_SKIN16:()=>ao,U_SKIN8:()=>io,U_SOLID:()=>ca,U_SOUND:()=>la,VertexArray:()=>ze,VertexBuffer:()=>Ee,VirtualFileSystem:()=>vo,advanceAnimation:()=>$c,applySurfaceState:()=>Xd,attenuationToDistanceMultiplier:()=>wr,boxIntersectsFrustum:()=>Pi,buildBspGeometry:()=>Bd,buildMd2Geometry:()=>ml,buildMd2VertexData:()=>pl,buildMd3SurfaceGeometry:()=>_l,buildMd3VertexData:()=>bl,calculateMaxAudibleDistance:()=>fs,calculatePakChecksum:()=>Dc,computeFrameBlend:()=>Zc,computeSkyScroll:()=>Zd,createAnimationState:()=>Yc,createAudioGraph:()=>ms,createBspSurfaces:()=>Od,createEmptyEntityState:()=>kr,createEmptyProtocolPlayerState:()=>$s,createEngine:()=>fx,createEngineRuntime:()=>kc,createFaceLightmap:()=>Ao,createInitialChannels:()=>ys,createProgramFromSources:()=>Pd,createWebGLContext:()=>Fd,decodeOgg:()=>as,deriveSurfaceRenderState:()=>ll,extractFrustumPlanes:()=>Nd,filesToPakSources:()=>Aa,findLeafForPoint:()=>il,gatherVisibleFaces:()=>Gd,groupMd2Animations:()=>Gc,ingestPakFiles:()=>Pc,ingestPaks:()=>wo,interpolateMd3Tag:()=>f0,interpolateVec3:()=>qc,parseBsp:()=>Ma,parseMd2:()=>Ea,parseMd3:()=>La,parsePcx:()=>Nn,parseSprite:()=>Ta,parseTga:()=>Ia,parseWal:()=>Eo,parseWalTexture:()=>Io,parseWav:()=>Co,pcxToRgba:()=>Lo,pickChannel:()=>xs,preparePcxTexture:()=>To,removeViewTranslation:()=>$d,resolveLightStyles:()=>al,spatializeOrigin:()=>_s,spawnBlood:()=>p0,spawnBulletImpact:()=>h0,spawnExplosion:()=>m0,spawnMuzzleFlash:()=>y0,spawnTeleportFlash:()=>g0,spawnTrail:()=>x0,walToRgba:()=>Ca,wireDropTarget:()=>Oc,wireFileInput:()=>Bc});var Zu=()=>typeof performance<"u"?performance.now():Date.now(),Yu=e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>e()):setTimeout(e,25)},or=class{constructor(t,r={}){this.callbacks=t;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let t=this.options.now(),r=this.lastTimeMs===void 0?0:t-this.lastTimeMs;this.lastTimeMs=t,this.advance(r,t),this.running&&this.options.schedule(this.tick)};let n=r.fixedDeltaMs??25,i=r.maxSubSteps??5;this.options={fixedDeltaMs:n,maxSubSteps:i,maxDeltaMs:r.maxDeltaMs??n*i,startTimeMs:r.startTimeMs,now:r.now??Zu,schedule:r.schedule??Yu}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(t){let r=(this.lastTimeMs??0)+t;this.lastTimeMs=r,this.advance(t,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(t,r){let n=Math.min(Math.max(t,0),this.options.maxDeltaMs);this.accumulatorMs=Math.min(this.accumulatorMs+n,this.options.fixedDeltaMs*this.options.maxSubSteps);let i=0;for(;this.accumulatorMs>=this.options.fixedDeltaMs&&i<this.options.maxSubSteps;)this.frame+=1,this.callbacks.simulate({frame:this.frame,deltaMs:this.options.fixedDeltaMs,nowMs:r}),this.accumulatorMs-=this.options.fixedDeltaMs,i+=1;let o=this.options.fixedDeltaMs===0?0:this.accumulatorMs/this.options.fixedDeltaMs;this.callbacks.render?.({alpha:o,nowMs:r,accumulatorMs:this.accumulatorMs,frame:this.frame})}};var Cn=class{constructor(t,r,n){this.name=t,this.callback=r,this.description=n}execute(t){this.callback(t)}},Pr=class{constructor(){this.commands=new Map}register(t,r,n){let i=new Cn(t,r,n);return this.commands.set(t,i),i}get(t){return this.commands.get(t)}execute(t){let r=this.tokenize(t);if(r.length===0)return!1;let n=r[0],i=r.slice(1),o=this.get(n);return o?(o.execute(i),!0):!1}tokenize(t){return t.trim().split(/\s+/)}list(){return[...this.commands.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var qu=Object.defineProperty,xc=(e,t)=>{for(var r in t)qu(e,r,{get:t[r],enumerable:!0})},_c={x:0,y:0,z:0};var yx=Math.PI/180;function bc(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function ju(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function ha(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Qu(e){return ha(e,e)}function ma(e){return Math.sqrt(Qu(e))}function Qe(e){let t=ma(e);return t===0?e:ju(e,1/t)}var Ju=Math.PI/180,xx=180/Math.PI,Or=Ju;var ef=[[-.525731,0,.850651],[-.442863,.238856,.864188],[-.295242,0,.955423],[-.309017,.5,.809017],[-.16246,.262866,.951056],[0,0,1],[0,.850651,.525731],[-.147621,.716567,.681718],[.147621,.716567,.681718],[0,.525731,.850651],[.309017,.5,.809017],[.525731,0,.850651],[.295242,0,.955423],[.442863,.238856,.864188],[.16246,.262866,.951056],[-.681718,.147621,.716567],[-.809017,.309017,.5],[-.587785,.425325,.688191],[-.850651,.525731,0],[-.864188,.442863,.238856],[-.716567,.681718,.147621],[-.688191,.587785,.425325],[-.5,.809017,.309017],[-.238856,.864188,.442863],[-.425325,.688191,.587785],[-.716567,.681718,-.147621],[-.5,.809017,-.309017],[-.525731,.850651,0],[0,.850651,-.525731],[-.238856,.864188,-.442863],[0,.955423,-.295242],[-.262866,.951056,-.16246],[0,1,0],[0,.955423,.295242],[-.262866,.951056,.16246],[.238856,.864188,.442863],[.262866,.951056,.16246],[.5,.809017,.309017],[.238856,.864188,-.442863],[.262866,.951056,-.16246],[.5,.809017,-.309017],[.850651,.525731,0],[.716567,.681718,.147621],[.716567,.681718,-.147621],[.525731,.850651,0],[.425325,.688191,.587785],[.864188,.442863,.238856],[.688191,.587785,.425325],[.809017,.309017,.5],[.681718,.147621,.716567],[.587785,.425325,.688191],[.955423,.295242,0],[1,0,0],[.951056,.16246,.262866],[.850651,-.525731,0],[.955423,-.295242,0],[.864188,-.442863,.238856],[.951056,-.16246,.262866],[.809017,-.309017,.5],[.681718,-.147621,.716567],[.850651,0,.525731],[.864188,.442863,-.238856],[.809017,.309017,-.5],[.951056,.16246,-.262866],[.525731,0,-.850651],[.681718,.147621,-.716567],[.681718,-.147621,-.716567],[.850651,0,-.525731],[.809017,-.309017,-.5],[.864188,-.442863,-.238856],[.951056,-.16246,-.262866],[.147621,.716567,-.681718],[.309017,.5,-.809017],[.425325,.688191,-.587785],[.442863,.238856,-.864188],[.587785,.425325,-.688191],[.688191,.587785,-.425325],[-.147621,.716567,-.681718],[-.309017,.5,-.809017],[0,.525731,-.850651],[-.525731,0,-.850651],[-.442863,.238856,-.864188],[-.295242,0,-.955423],[-.16246,.262866,-.951056],[0,0,-1],[.295242,0,-.955423],[.16246,.262866,-.951056],[-.442863,-.238856,-.864188],[-.309017,-.5,-.809017],[-.16246,-.262866,-.951056],[0,-.850651,-.525731],[-.147621,-.716567,-.681718],[.147621,-.716567,-.681718],[0,-.525731,-.850651],[.309017,-.5,-.809017],[.442863,-.238856,-.864188],[.16246,-.262866,-.951056],[.238856,-.864188,-.442863],[.5,-.809017,-.309017],[.425325,-.688191,-.587785],[.716567,-.681718,-.147621],[.688191,-.587785,-.425325],[.587785,-.425325,-.688191],[0,-.955423,-.295242],[0,-1,0],[.262866,-.951056,-.16246],[0,-.850651,.525731],[0,-.955423,.295242],[.238856,-.864188,.442863],[.262866,-.951056,.16246],[.5,-.809017,.309017],[.716567,-.681718,.147621],[.525731,-.850651,0],[-.238856,-.864188,-.442863],[-.5,-.809017,-.309017],[-.262866,-.951056,-.16246],[-.850651,-.525731,0],[-.716567,-.681718,-.147621],[-.716567,-.681718,.147621],[-.525731,-.850651,0],[-.5,-.809017,.309017],[-.238856,-.864188,.442863],[-.262866,-.951056,.16246],[-.864188,-.442863,.238856],[-.809017,-.309017,.5],[-.688191,-.587785,.425325],[-.681718,-.147621,.716567],[-.442863,-.238856,.864188],[-.587785,-.425325,.688191],[-.309017,-.5,.809017],[-.147621,-.716567,.681718],[-.425325,-.688191,.587785],[-.16246,-.262866,.951056],[.442863,-.238856,.864188],[.16246,-.262866,.951056],[.309017,-.5,.809017],[.147621,-.716567,.681718],[0,-.525731,.850651],[.425325,-.688191,.587785],[.587785,-.425325,.688191],[.688191,-.587785,.425325],[-.955423,.295242,0],[-.951056,.16246,.262866],[-1,0,0],[-.850651,0,.525731],[-.955423,-.295242,0],[-.951056,-.16246,.262866],[-.864188,.442863,-.238856],[-.951056,.16246,-.262866],[-.809017,.309017,-.5],[-.864188,-.442863,-.238856],[-.951056,-.16246,-.262866],[-.809017,-.309017,-.5],[-.681718,.147621,-.716567],[-.681718,-.147621,-.716567],[-.850651,0,-.525731],[-.688191,.587785,-.425325],[-.587785,.425325,-.688191],[-.425325,.688191,-.587785],[-.425325,-.688191,-.587785],[-.587785,-.425325,-.688191],[-.688191,-.587785,-.425325]];function tf(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function vc(e,t){let r=t.x,n=t.y,i=t.z;return{x:e[0]*r+e[4]*n+e[8]*i+e[12],y:e[1]*r+e[5]*n+e[9]*i+e[13],z:e[2]*r+e[6]*n+e[10]*i+e[14]}}function Sc(e,t){let r=tf();return r[0]=t[0].x,r[1]=t[0].y,r[2]=t[0].z,r[4]=t[1].x,r[5]=t[1].y,r[6]=t[1].z,r[8]=t[2].x,r[9]=t[2].y,r[10]=t[2].z,r[12]=e.x,r[13]=e.y,r[14]=e.z,r}var nt=1,zt=2;var pa=8,ga=16,rf=32;var nf=16384;var po=65536,wc=1<<17,of=1<<18,sf=1<<19,af=1<<20,lf=1<<21,cf=1<<22,df=1<<23,_x=1<<24,go=1<<25,uf=1<<26,bx=1<<27,vx=1<<28,Sx=1<<29,yo=1<<30,wx=1<<31;var Rn=0;var Ac=4,Mc=8,Ec=16,Lc=32,Tc=64;var Ax=1<<25,Mx=1<<28,Ex=1<<29,Lx=1<<30,Tx=1<<31;var Ix=nt|zt,Cx=nt|po|zt|go|yo,zx=nt|po|zt,Rx=nt|wc|zt|go|yo,kx=rf|pa|ga,Fx=nt|ga|pa,ff=nt|go|yo|zt|uf,Dx=of|sf|af|lf|cf|df,Px=nt|pa|ga|go|yo,Ox=nt|po|zt,Bx=nt|zt,Nx=nt|po|zt|wc,Ux=ff|nf;var Hx=Number.MAX_SAFE_INTEGER-1;var xo=(e=>(e[e.None=0]="None",e[e.Archive=1]="Archive",e[e.UserInfo=2]="UserInfo",e[e.ServerInfo=4]="ServerInfo",e[e.Latch=8]="Latch",e[e.Cheat=16]="Cheat",e))(xo||{});var _o=256;var ya=256,xa=8192,bo=2048,_a=512,ba=256,va=_o*2,Sa=256,fa=32,zn=96;var q=(e=>(e[e.Name=0]="Name",e[e.CdTrack=1]="CdTrack",e[e.Sky=2]="Sky",e[e.SkyAxis=3]="SkyAxis",e[e.SkyRotate=4]="SkyRotate",e[e.StatusBar=5]="StatusBar",e[e.CONFIG_N64_PHYSICS=56]="CONFIG_N64_PHYSICS",e[e.CONFIG_CTF_TEAMS=57]="CONFIG_CTF_TEAMS",e[e.CONFIG_COOP_RESPAWN_STRING=58]="CONFIG_COOP_RESPAWN_STRING",e[e.AirAccel=59]="AirAccel",e[e.MaxClients=60]="MaxClients",e[e.MapChecksum=61]="MapChecksum",e[e.Models=62]="Models",e[e.Sounds=62+xa]="Sounds",e[e.Images=e.Sounds+bo]="Images",e[e.Lights=e.Images+_a]="Lights",e[e.ShadowLights=e.Lights+ya]="ShadowLights",e[e.Items=e.ShadowLights+Sa]="Items",e[e.PlayerSkins=e.Items+ba]="PlayerSkins",e[e.General=e.PlayerSkins+_o]="General",e[e.WheelWeapons=e.General+va]="WheelWeapons",e[e.WheelAmmo=e.WheelWeapons+fa]="WheelAmmo",e[e.WheelPowerups=e.WheelAmmo+fa]="WheelPowerups",e[e.CdLoopCount=e.WheelPowerups+fa]="CdLoopCount",e[e.GameStyle=e.CdLoopCount+1]="GameStyle",e[e.MaxConfigStrings=e.GameStyle+1]="MaxConfigStrings",e))(q||{}),Ic=q.MaxConfigStrings;function Cc(e){return e>=5&&e<59?zn*(59-e):e>=q.General&&e<q.WheelWeapons?zn*(q.MaxConfigStrings-e):zn}var hf={};xc(hf,{addReplayFrame:()=>yf,createReplaySession:()=>gf,deserializeReplay:()=>pf,serializeReplay:()=>mf});function mf(e){return JSON.stringify(e,null,2)}function pf(e){let t=JSON.parse(e);if(!t.metadata||!Array.isArray(t.frames))throw new Error("Invalid replay format: missing metadata or frames");return t}function gf(e,t){return{metadata:{map:e,date:new Date().toISOString(),version:"1.0",seed:t},frames:[]}}function yf(e,t,r,n){e.frames.push({serverFrame:r,cmd:t,timestamp:Date.now()-n})}var D=(e=>(e[e.bad=0]="bad",e[e.muzzleflash=1]="muzzleflash",e[e.muzzleflash2=2]="muzzleflash2",e[e.temp_entity=3]="temp_entity",e[e.layout=4]="layout",e[e.inventory=5]="inventory",e[e.nop=6]="nop",e[e.disconnect=7]="disconnect",e[e.reconnect=8]="reconnect",e[e.sound=9]="sound",e[e.print=10]="print",e[e.stufftext=11]="stufftext",e[e.serverdata=12]="serverdata",e[e.configstring=13]="configstring",e[e.spawnbaseline=14]="spawnbaseline",e[e.centerprint=15]="centerprint",e[e.download=16]="download",e[e.playerinfo=17]="playerinfo",e[e.packetentities=18]="packetentities",e[e.deltapacketentities=19]="deltapacketentities",e[e.frame=20]="frame",e[e.splitclient=21]="splitclient",e[e.configblast=22]="configblast",e[e.spawnbaselineblast=23]="spawnbaselineblast",e[e.level_restart=24]="level_restart",e[e.damage=25]="damage",e[e.locprint=26]="locprint",e[e.fog=27]="fog",e[e.waitingforplayers=28]="waitingforplayers",e[e.bot_chat=29]="bot_chat",e[e.poi=30]="poi",e[e.help_path=31]="help_path",e[e.muzzleflash3=32]="muzzleflash3",e[e.achievement=33]="achievement",e))(D||{});var I=(e=>(e[e.GUNSHOT=0]="GUNSHOT",e[e.BLOOD=1]="BLOOD",e[e.BLASTER=2]="BLASTER",e[e.RAILTRAIL=3]="RAILTRAIL",e[e.SHOTGUN=4]="SHOTGUN",e[e.EXPLOSION1=5]="EXPLOSION1",e[e.EXPLOSION2=6]="EXPLOSION2",e[e.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",e[e.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",e[e.SPARKS=9]="SPARKS",e[e.SPLASH=10]="SPLASH",e[e.BUBBLETRAIL=11]="BUBBLETRAIL",e[e.SCREEN_SPARKS=12]="SCREEN_SPARKS",e[e.SHIELD_SPARKS=13]="SHIELD_SPARKS",e[e.BULLET_SPARKS=14]="BULLET_SPARKS",e[e.LASER_SPARKS=15]="LASER_SPARKS",e[e.PARASITE_ATTACK=16]="PARASITE_ATTACK",e[e.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",e[e.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",e[e.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",e[e.BFG_EXPLOSION=20]="BFG_EXPLOSION",e[e.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",e[e.BOSSTPORT=22]="BOSSTPORT",e[e.BFG_LASER=23]="BFG_LASER",e[e.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",e[e.WELDING_SPARKS=25]="WELDING_SPARKS",e[e.GREENBLOOD=26]="GREENBLOOD",e[e.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",e[e.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",e[e.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",e[e.BLASTER2=30]="BLASTER2",e[e.RAILTRAIL2=31]="RAILTRAIL2",e[e.FLAME=32]="FLAME",e[e.LIGHTNING=33]="LIGHTNING",e[e.DEBUGTRAIL=34]="DEBUGTRAIL",e[e.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",e[e.FLASHLIGHT=36]="FLASHLIGHT",e[e.FORCEWALL=37]="FORCEWALL",e[e.HEATBEAM=38]="HEATBEAM",e[e.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",e[e.STEAM=40]="STEAM",e[e.BUBBLETRAIL2=41]="BUBBLETRAIL2",e[e.MOREBLOOD=42]="MOREBLOOD",e[e.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",e[e.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",e[e.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",e[e.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",e[e.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",e[e.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",e[e.DBALL_GOAL=49]="DBALL_GOAL",e[e.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",e[e.NUKEBLAST=51]="NUKEBLAST",e[e.WIDOWSPLASH=52]="WIDOWSPLASH",e[e.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",e[e.EXPLOSION1_NP=54]="EXPLOSION1_NP",e[e.FLECHETTE=55]="FLECHETTE",e[e.BLUEHYPERBLASTER_KEX=56]="BLUEHYPERBLASTER_KEX",e[e.BFG_ZAP=57]="BFG_ZAP",e[e.BERSERK_SLAM=58]="BERSERK_SLAM",e[e.GRAPPLE_CABLE_2=59]="GRAPPLE_CABLE_2",e[e.POWER_SPLASH=60]="POWER_SPLASH",e[e.LIGHTNING_BEAM=61]="LIGHTNING_BEAM",e[e.EXPLOSION1_NL=62]="EXPLOSION1_NL",e[e.EXPLOSION2_NL=63]="EXPLOSION2_NL",e))(I||{});var xf=12,_f=9,Vx=Math.ceil(xf*_f/16),bf=23,vf=2,Gx=Math.ceil(bf*vf/16);var Sf={};xc(Sf,{U_ANGLE1:()=>If,U_ANGLE2:()=>Cf,U_ANGLE3:()=>zf,U_EFFECTS:()=>Ff,U_EVENT:()=>Of,U_FRAME:()=>Rf,U_MODEL:()=>Af,U_MODEL2:()=>Nf,U_MODEL3:()=>Uf,U_MODEL4:()=>Hf,U_MOREBITS:()=>Bf,U_NUMBER:()=>wf,U_ORIGIN1:()=>Ef,U_ORIGIN2:()=>Lf,U_ORIGIN3:()=>Tf,U_REMOVE:()=>Vf,U_RENDERFX:()=>Df,U_SKIN:()=>kf,U_SOLID:()=>Pf,U_SOUND:()=>Mf});var wf=1,Af=2,Mf=4,Ef=8,Lf=16,Tf=32,If=64,Cf=128,zf=256,Rf=512,kf=1024,Ff=2048,Df=4096,Pf=8192,Of=16384,Bf=32768,Nf=1,Uf=2,Hf=4,Vf=32768;var kn=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readUShort(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readULong(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0)break;e+=String.fromCharCode(t)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0||t===10)break;e+=String.fromCharCode(t)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let t=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(t)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){let t=this.readByte();if(t>=162){e.x=0,e.y=0,e.z=0;return}let r=ef[t];e.x=r[0],e.y=r[1],e.z=r[2]}};var zc=(e=>(e[e.Bullets=0]="Bullets",e[e.Shells=1]="Shells",e[e.Rockets=2]="Rockets",e[e.Grenades=3]="Grenades",e[e.Cells=4]="Cells",e[e.Slugs=5]="Slugs",e[e.MagSlugs=6]="MagSlugs",e[e.Trap=7]="Trap",e[e.Flechettes=8]="Flechettes",e[e.Tesla=9]="Tesla",e[e.Disruptor=10]="Disruptor",e[e.Prox=11]="Prox",e[e.Nuke=12]="Nuke",e[e.Rounds=13]="Rounds",e))(zc||{}),Wx=Object.keys(zc).length/2;var Fn=class{constructor({name:t,defaultValue:r,description:n,flags:i=xo.None,onChange:o}){this.modifiedCount=0;this.name=t,this.defaultValue=r,this.description=n,this.flags=i,this._value=r,this.onChange=o}get string(){return this._value}get number(){return Number(this._value)}get integer(){return Math.trunc(this.number)}get boolean(){return!!this.integer}set(t){if(this.flags&xo.Latch){if(t===this._value){this.latched=void 0;return}if(this.latched===t)return;this.latched!==t&&(this.latched=t);return}this.apply(t)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let t=this.latched;return this.latched=void 0,t===this._value?!1:(this.apply(t),!0)}apply(t){if(this._value===t)return;let r=this._value;this._value=t,this.modifiedCount+=1,this.onChange?.(this,r)}},Br=class{constructor(){this.cvars=new Map}register(t){let r=this.cvars.get(t.name);if(r)return r;let n=new Fn(t);return this.cvars.set(t.name,n),n}get(t){return this.cvars.get(t)}setValue(t,r){let n=this.get(t);if(!n)throw new Error(`Unknown cvar: ${t}`);return n.set(r),n}resetAll(){for(let t of this.cvars.values())t.reset()}applyLatched(){let t=!1;for(let r of this.cvars.values())t=r.applyLatched()||t;return t}list(){return[...this.cvars.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var Nr=class{constructor(t,r,n={}){this.game=t;this.client=r;this.started=!1;this.commands=new Pr;this.cvars=new Br;this.stepSimulation=t=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(t,this.latestCommand)};this.renderClient=t=>{this.client&&(this.latestCommand=this.client.render({...t,previous:this.previousFrame,latest:this.latestFrame}))};let i=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??i,this.loop=new or({simulate:this.stepSimulation,render:this.renderClient},{...n.loop,startTimeMs:this.startTimeMs})}start(){if(!this.started){try{this.latestFrame=this.game.init(this.startTimeMs)??this.latestFrame,this.client?.init(this.latestFrame)}catch(t){throw this.game.shutdown(),this.client?.shutdown(),t}this.started=!0,this.loop.start()}}stop(){this.started&&(this.loop.stop(),this.client?.shutdown(),this.game.shutdown(),this.previousFrame=void 0,this.latestFrame=void 0,this.started=!1)}pump(t){this.loop.pump(t)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};function Gf(e){if(e<0||e>=q.MaxConfigStrings)throw new RangeError(`Configstring index ${e} is out of range (0-${q.MaxConfigStrings-1})`)}function Rc(e,t){let r=Cc(e);if(t.length>r)throw new RangeError(`Configstring ${e} exceeds maximum length (${t.length} > ${r}); limit is ${zn} chars per slot`)}var Ur=class{constructor(){this.values=new Map;this.modelCursor=q.Models;this.soundCursor=q.Sounds;this.imageCursor=q.Images;this.lightCursor=q.Lights;this.shadowLightCursor=q.ShadowLights;this.itemCursor=q.Items;this.playerSkinCursor=q.PlayerSkins;this.generalCursor=q.General}set(t,r){return Gf(t),Rc(t,r),this.values.set(t,r),t}get(t){return this.values.get(t)}getName(t){return this.get(t)}getAll(){let t=new Array(Ic).fill("");for(let[r,n]of this.values.entries())t[r]=n;return t}modelIndex(t){return this.register(t,q.Models,xa,"modelCursor")}soundIndex(t){return this.register(t,q.Sounds,bo,"soundCursor")}findSoundIndex(t){for(let r=q.Sounds;r<q.Sounds+bo;r+=1)if(this.values.get(r)===t)return r}imageIndex(t){return this.register(t,q.Images,_a,"imageCursor")}lightIndex(t){return this.register(t,q.Lights,ya,"lightCursor")}shadowLightIndex(t){return this.register(t,q.ShadowLights,Sa,"shadowLightCursor")}itemIndex(t){return this.register(t,q.Items,ba,"itemCursor")}playerSkinIndex(t){return this.register(t,q.PlayerSkins,_o,"playerSkinCursor")}generalIndex(t){return this.register(t,q.General,va,"generalCursor")}register(t,r,n,i){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===t)return a;let o=this[i],s=r+n;if(o>=s)throw new RangeError(`Out of configstring slots for range starting at ${r}`);return Rc(o,t),this.values.set(o,t),this[i]=o+1,o}};var Hr=class{constructor(t){this.registry=t.registry,this.system=t.system,this.music=t.music,this.client=t.client}soundindex(t){return this.registry.registerName(t)}sound(t,r,n,i,o,s){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,timeOffsetMs:s}),this.triggerSubtitle(n)}positioned_sound(t,r,n,i){this.system.positionedSound(t,r,n,i),this.triggerSubtitle(r)}loop_sound(t,r,n,i,o){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,looping:!0}),this.triggerSubtitle(n)}stop_entity_sounds(t){this.system.stopEntitySounds(t)}set_listener(t){this.system.setListener(t)}play_music(t,r=!0){return this.music?this.music.play(t,{loop:r}):Promise.resolve()}pause_music(){this.music?.pause()}resume_music(){return this.music?.resume()??Promise.resolve()}stop_music(){this.music?.stop()}set_music_volume(t){this.music?.setVolume(t)}play_ambient(t,r,n){this.system.ambientSound(t,r,n),this.triggerSubtitle(r)}play_channel(t){this.system.play({...t}),this.triggerSubtitle(t.soundIndex)}triggerSubtitle(t){if(!this.client)return;let r=this.registry.getName(t);if(!r)return;let n=r.match(/\[(.*?)\]/);n&&this.client.showSubtitle(n[1],r)}};var Dn=class{constructor(t,r){this.engine=t;this.host=r;this.started=!1}start(){this.started||(this.engine.init(),this.host.start(),this.started=!0)}stop(){this.started&&(this.host.stop(),this.engine.shutdown(),this.started=!1)}pump(t){this.host.pump(t)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function kc(e,t,r,n,i){let o=new Hr({...n,client:r}),s=new Nr(t,r,i);return{runtime:new Dn(e,s),audio:o}}var Wf="PACK";function Xf(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function ae(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function Kf(){let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let r=t;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e}var $f=Kf();function Fc(e){let t=4294967295;for(let r=0;r<e.length;r+=1){let n=e[r];t=$f[(t^n)&255]^t>>>8}return(t^4294967295)>>>0}var He=class extends Error{},Vr=class e{constructor(t,r,n,i){this.name=t;this.buffer=r;this.entries=new Map(n.map(o=>[o.name,o])),this.checksum=i,this.size=r.byteLength}static fromArrayBuffer(t,r){let n=new DataView(r);if(r.byteLength<12)throw new He("PAK buffer too small to contain header");let i=String.fromCharCode(n.getUint8(0),n.getUint8(1),n.getUint8(2),n.getUint8(3));if(i!==Wf)throw new He(`Invalid PAK header magic: ${i}`);let o=n.getInt32(4,!0),s=n.getInt32(8,!0);if(o<12)throw new He(`Invalid directory offset: ${o}`);if(s<=0||s%64!==0)throw new He(`Invalid directory length: ${s}`);if(o+s>r.byteLength)throw new He("Directory exceeds buffer length");let d=s/64,l=[],c=new Map;for(let h=0;h<d;h+=1){let u=o+h*64,f=Xf(n,u,56),m=ae(f),g=n.getInt32(u+56,!0),p=n.getInt32(u+60,!0);if(g<0||p<0||g+p>r.byteLength)throw new He(`Invalid entry bounds for ${f||"<unnamed>"} (offset=${g}, length=${p})`);if(!m)throw new He(`Entry ${h} has an empty name`);let x={name:m,offset:g,length:p};c.set(m,x)}return l.push(...c.values()),new e(t,r,l,Fc(new Uint8Array(r)))}getEntry(t){return this.entries.get(ae(t))}listEntries(){return Array.from(this.entries.values())}readFile(t){let r=this.getEntry(t);if(!r)throw new He(`File not found in PAK: ${t}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function Dc(e){return Fc(new Uint8Array(e))}var vo=class{constructor(t=[]){this.mounts=[];this.files=new Map;t.forEach(r=>this.mountPak(r))}mountPak(t){this.mounts.push(t);for(let r of t.listEntries()){let n=ae(r.name);this.files.set(n,{archive:t,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(t){return this.files.has(ae(t))}stat(t){let r=this.files.get(ae(t));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(t){let r=this.files.get(ae(t));if(!r)throw new Error(`File not found in VFS: ${t}`);return r.archive.readFile(t)}list(t=""){let r=ae(t).replace(/\/+$|^\//g,""),n=[],i=new Set,o=r?`${r}/`:"";for(let s of this.files.values()){if(r&&!s.entry.name.startsWith(o))continue;let a=r?s.entry.name.slice(o.length):s.entry.name,d=a.indexOf("/");d===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):i.add(a.slice(0,d))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...i].sort()}}findByExtension(t){let r=t.startsWith(".")?t.toLowerCase():`.${t.toLowerCase()}`,n=[];for(let i of this.files.values())i.entry.name.toLowerCase().endsWith(r)&&n.push({path:i.entry.name,size:i.entry.length,sourcePak:i.archive.name});return n.sort((i,o)=>i.path.localeCompare(o.path))}};var wa=Object.freeze([{name:"pak0.pak",checksum:2378051181,description:"Base game assets"},{name:"pak0.pak@baseq2",checksum:2378051181,description:"Base game assets (baseq2)"},{name:"pak0.pak@rogue",checksum:3373211245,description:"Ground Zero (rogue) mission pack"},{name:"pak0.pak@xatrix",checksum:1358269824,description:"The Reckoning (xatrix) mission pack"}]),sr=class extends Error{constructor(r){super(r.status==="unknown"?`Unknown PAK not allowed: ${r.name}`:`PAK checksum mismatch for ${r.name}`);this.result=r;this.name="PakValidationError"}},So=class{constructor(t=wa){this.known=new Map;t.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(t,r){let n=this.normalizePakName(r??("name"in t?t.name:"unknown")),i=t.checksum,o="size"in t?t.size:void 0,s=this.known.get(n);return s?s.checksum!==i?{name:n,checksum:i,expectedChecksum:s.checksum,status:"mismatch",size:o,description:s.description}:{name:n,checksum:i,expectedChecksum:s.checksum,status:"valid",size:o,description:s.description}:{name:n,checksum:i,status:"unknown",size:o}}assertValid(t,r){let n=this.validateArchive(t,r);if(n.status==="mismatch")throw new sr(n);return n}normalizePakName(t){let r=ae(t),n=r.split("/"),i=n.pop()??r,o=n.pop();return o?`${i}@${o}`:i}};var Rt=class extends Error{constructor(r,n){super(`Failed to ingest PAK: ${r}`);this.file=r;this.name="PakIngestionError",n instanceof Error&&n.stack&&(this.stack=n.stack),this.cause=n}};async function Zf(e,t){if(typeof e.arrayBuffer=="function"){let r=await e.arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof FileReader<"u")return new Promise((r,n)=>{let i=new FileReader;i.onerror=()=>n(i.error??new Error("Unknown FileReader error")),i.onprogress=o=>{t?.({file:"blob",loadedBytes:o.loaded,totalBytes:o.total||e.size,state:"reading"})},i.onload=()=>{let o=i.result;o instanceof ArrayBuffer?r(o):n(new Error("Unexpected FileReader result"))},i.readAsArrayBuffer(e)});if(typeof Response<"u"){let r=await new Response(e).arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof e.stream=="function"){let r=e.stream().getReader(),n=[],i=0;for(;;){let{done:a,value:d}=await r.read();if(a)break;if(!d)continue;let l=d;n.push(l),i+=l.byteLength,t?.({file:"blob",loadedBytes:i,totalBytes:e.size,state:"reading"})}let o=new Uint8Array(i),s=0;for(let a of n)o.set(a,s),s+=a.byteLength;return o.buffer}throw new Rt("blob",new Error("Unsupported Blob type"))}async function Yf(e,t){if(e.data instanceof ArrayBuffer)return t?.({file:e.name,loadedBytes:e.data.byteLength,totalBytes:e.data.byteLength,state:"reading"}),e.data;if(e.data instanceof Blob){let n=e.data.size;return Zf(e.data,i=>t?.({...i,file:e.name,totalBytes:n}))}let r=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength);return t?.({file:e.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function wo(e,t,r){let n=typeof r=="function"?{onProgress:r}:r??{},i=n.persistIndexes??!!n.pakIndexStore,o=n.enforceValidation??!!n.validator,s=n.allowUnknownPaks??!0,a=n.stopOnError??!1,d=[];for(let l of t)try{let c=await Yf(l,n.onProgress),h=Vr.fromArrayBuffer(l.name,c),u=n.validator?.validateArchive(h);if(u){n.onValidationResult?.(u);let f=u.status==="mismatch",m=u.status==="unknown";if(f&&o||m&&!s){let g=new sr(u);if(n.onError?.(l.name,g),a)throw new Rt(l.name,g);d.push({archive:h,mounted:!1,validation:u});continue}}if(e.mountPak(h),i&&n.pakIndexStore)try{await n.pakIndexStore.persist(h)}catch(f){if(n.onError?.(l.name,f),a)throw new Rt(l.name,f)}n.onProgress?.({file:l.name,loadedBytes:c.byteLength,totalBytes:c.byteLength,state:"parsed"}),d.push({archive:h,mounted:!0,validation:u})}catch(c){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,c),a)throw new Rt(l.name,c)}return d}var kt=class{constructor(t){this.capacity=t;this.map=new Map;if(t<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(t){return this.map.has(t)}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}set(t,r){if(this.map.has(t)&&this.map.delete(t),this.map.set(t,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([t,r])=>({key:t,value:r}))}};function qf(e){return Array.isArray(e)?e:Array.from(e)}function Aa(e){return qf(e).map(t=>({name:t.name,data:t}))}async function Pc(e,t,r){let n=Aa(t);return wo(e,n,r??{})}function Oc(e,t){let r=i=>{i.preventDefault(),i.dataTransfer?.dropEffect&&(i.dataTransfer.dropEffect="copy")},n=i=>{i.preventDefault();let o=i.dataTransfer?.files;o&&o.length>0&&t(Array.from(o))};return e.addEventListener("dragover",r),e.addEventListener("drop",n),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",n)}}function Bc(e,t){let r=n=>{let i=n.target;!i||!i.files||i.files.length===0||(t(i.files),i.value="")};return e.addEventListener("change",r),()=>e.removeEventListener("change",r)}var jf="IBSP",Qf=38,Uc=19,Jf=8+Uc*8;var j=class extends Error{},Gr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Ma(n.buffer)}};function Ma(e){if(e.byteLength<Jf)throw new j("BSP too small to contain header");let t=new DataView(e),r=String.fromCharCode(t.getUint8(0),t.getUint8(1),t.getUint8(2),t.getUint8(3));if(r!==jf)throw new j(`Invalid BSP magic ${r}`);let n=t.getInt32(4,!0);if(n!==Qf)throw new j(`Unsupported BSP version ${n}`);let i=new Map;for(let v=0;v<Uc;v+=1){let E=t.getInt32(8+v*8,!0),L=t.getInt32(12+v*8,!0);if(E<0||L<0||E+L>e.byteLength)throw new j(`Invalid lump bounds for index ${v}`);i.set(v,{offset:E,length:L})}let o={version:n,lumps:i},s=th(e,i.get(0)),a=nh(e,i.get(1)),d=ih(e,i.get(2)),l=oh(e,i.get(4)),c=sh(e,i.get(5)),h=ah(e,i.get(6)),u=new Uint8Array(e,i.get(7).offset,i.get(7).length),f=gh(h,i.get(7)),m=lh(e,i.get(8)),g=ch(e,i.get(11)),p=dh(e,i.get(12)),x=uh(e,i.get(13)),S=fh(e,i.get(14)),_=hh(e,i.get(15)),y=mh(e,i.get(9),i.get(10),m),b=ph(e,i.get(3));return{header:o,entities:s,planes:a,vertices:d,nodes:l,texInfo:c,faces:h,lightMaps:u,lightMapInfo:f,leafs:m,leafLists:y,edges:g,surfEdges:p,models:x,brushes:S,brushSides:_,visibility:b,pickEntity(v){let E=null,L=1/0;for(let w of s.entities){let T=w.properties.model;if(!T||!T.startsWith("*"))continue;let R=parseInt(T.substring(1),10);if(isNaN(R)||R<0||R>=x.length)continue;let U=x[R],z=eh(v.origin,v.direction,U.mins,U.maxs);z!==null&&z<L&&(L=z,E={entity:w,model:U,distance:z})}return E}}}function eh(e,t,r,n){let i=0,o=1/0;for(let s=0;s<3;s++)if(Math.abs(t[s])<1e-8){if(e[s]<r[s]||e[s]>n[s])return null}else{let a=1/t[s],d=(r[s]-e[s])*a,l=(n[s]-e[s])*a;if(d>l){let c=d;d=l,l=c}if(i=Math.max(i,d),o=Math.min(o,l),i>o)return null}return i}function th(e,t){let r=new TextDecoder().decode(new Uint8Array(e,t.offset,t.length)),n=rh(r),i=n.find(o=>o.classname==="worldspawn");return{raw:r,entities:n,worldspawn:i,getUniqueClassnames(){let o=new Set;for(let s of n)s.classname&&o.add(s.classname);return Array.from(o).sort()}}}function rh(e){let t=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(e))!==null;){let i=n[1],o={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(i))!==null;)o[a[1]]=a[2];t.push({classname:o.classname,properties:o})}return t}function nh(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/20;if(n%1!==0)throw new j("Plane lump has invalid length");let i=[];for(let o=0;o<n;o+=1){let s=[r.getFloat32(o*20,!0),r.getFloat32(o*20+4,!0),r.getFloat32(o*20+8,!0)],a=r.getFloat32(o*20+12,!0),d=r.getInt32(o*20+16,!0);i.push({normal:s,dist:a,type:d})}return i}function ih(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/12;if(n%1!==0)throw new j("Vertex lump has invalid length");let i=[];for(let o=0;o<n;o+=1)i.push([r.getFloat32(o*12,!0),r.getFloat32(o*12+4,!0),r.getFloat32(o*12+8,!0)]);return i}function oh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Node lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],c=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],h=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],u=r.getUint16(a+24,!0),f=r.getUint16(a+26,!0);o.push({planeIndex:d,children:l,mins:c,maxs:h,firstFace:u,numFaces:f})}return o}function sh(e,t){let r=new DataView(e,t.offset,t.length),n=76,i=t.length/n;if(i%1!==0)throw new j("TexInfo lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),c=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],h=r.getFloat32(a+28,!0),u=r.getInt32(a+32,!0),f=r.getInt32(a+36,!0),m=new Uint8Array(e,t.offset+a+40,32),g=new TextDecoder("utf-8").decode(m).replace(/\0.*$/,""),p=r.getInt32(a+72,!0);o.push({s:d,sOffset:l,t:c,tOffset:h,flags:u,value:f,texture:g,nextTexInfo:p})}return o}function ah(e,t){let r=new DataView(e,t.offset,t.length),n=20,i=t.length/n;if(i%1!==0)throw new j("Face lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getUint16(a,!0),l=r.getInt16(a+2,!0),c=r.getInt32(a+4,!0),h=r.getInt16(a+8,!0),u=r.getInt16(a+10,!0),f=[r.getUint8(a+12),r.getUint8(a+13),r.getUint8(a+14),r.getUint8(a+15)],m=r.getInt32(a+16,!0);o.push({planeIndex:d,side:l,firstEdge:c,numEdges:h,texInfo:u,styles:f,lightOffset:m})}return o}function lh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Leaf lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=r.getInt16(a+4,!0),c=r.getInt16(a+6,!0),h=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],u=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],f=r.getUint16(a+20,!0),m=r.getUint16(a+22,!0),g=r.getUint16(a+24,!0),p=r.getUint16(a+26,!0);o.push({contents:d,cluster:l,area:c,mins:h,maxs:u,firstLeafFace:f,numLeafFaces:m,firstLeafBrush:g,numLeafBrushes:p})}return o}function ch(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Edge lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({vertices:[r.getUint16(a,!0),r.getUint16(a+2,!0)]})}return o}function dh(e,t){let r=t.length/4;if(r%1!==0)throw new j("SurfEdge lump has invalid length");let n=new DataView(e,t.offset,t.length),i=new Int32Array(r);for(let o=0;o<r;o+=1)i[o]=n.getInt32(o*4,!0);return i}function uh(e,t){let r=new DataView(e,t.offset,t.length),n=48;if(t.length%n!==0)throw new j("Model lump has invalid length");let i=t.length/n,o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=[r.getFloat32(a+12,!0),r.getFloat32(a+16,!0),r.getFloat32(a+20,!0)],c=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],h=r.getInt32(a+36,!0),u=r.getInt32(a+40,!0),f=r.getInt32(a+44,!0);o.push({mins:d,maxs:l,origin:c,headNode:h,firstFace:u,numFaces:f})}return o}function fh(e,t){let r=new DataView(e,t.offset,t.length),n=12,i=t.length/n;if(i%1!==0)throw new j("Brush lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({firstSide:r.getInt32(a,!0),numSides:r.getInt32(a+4,!0),contents:r.getInt32(a+8,!0)})}return o}function hh(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Brush side lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({planeIndex:r.getUint16(a,!0),texInfo:r.getInt16(a+2,!0)})}return o}function mh(e,t,r,n){let i=[],o=[],s=t.length/2,a=r.length/2,d=new DataView(e,t.offset,t.length),l=new DataView(e,r.offset,r.length);for(let c of n){if(c.firstLeafFace+c.numLeafFaces>s)throw new j("Leaf faces reference data past lump bounds");if(c.firstLeafBrush+c.numLeafBrushes>a)throw new j("Leaf brushes reference data past lump bounds");let h=[];for(let f=0;f<c.numLeafFaces;f+=1)h.push(d.getUint16((c.firstLeafFace+f)*2,!0));let u=[];for(let f=0;f<c.numLeafBrushes;f+=1)u.push(l.getUint16((c.firstLeafBrush+f)*2,!0));i.push(h),o.push(u)}return{leafFaces:i,leafBrushes:o}}function ph(e,t){if(t.length===0)return;if(t.length<4)throw new j("Visibility lump too small");let r=new DataView(e,t.offset,t.length),n=r.getInt32(0,!0),i=4+n*8;if(n<0||i>t.length)throw new j("Visibility lump truncated");let o=4,s=[];for(let a=0;a<n;a+=1){let d=r.getInt32(o,!0),l=r.getInt32(o+4,!0);o+=8;let c=t.offset+d,h=t.offset+l,u=t.offset+t.length;if(d<0||l<0||c>=u||h>=u)throw new j("Visibility offsets out of range");s.push({pvs:Nc(e,c,n,t),phs:Nc(e,h,n,t)})}return{numClusters:n,clusters:s}}function Nc(e,t,r,n){let i=Math.ceil(r/8),o=new Uint8Array(i),s=new Uint8Array(e),a=t,d=0,l=n.offset+n.length;for(;d<i;){if(a>=l)throw new j("Visibility data truncated");let c=s[a++];if(c!==0){o[d++]=c;continue}if(a>=l)throw new j("Visibility run exceeds lump bounds");let h=s[a++];for(let u=0;u<h&&d<i;u+=1)o[d++]=0}return o}function gh(e,t){return e.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,t.length-r.lightOffset)}})}function Ao(e,t,r){if(e.lightOffset<0||e.lightOffset>=t.byteLength)return;let n=t.byteLength-e.lightOffset,i=Math.min(r?.length??n,n);if(!(i<=0))return t.subarray(e.lightOffset,e.lightOffset+i)}var yh=844121161,xh=8,Hc=68,_h=[{x:-.525731,y:0,z:.850651},{x:-.442863,y:.238856,z:.864188},{x:-.295242,y:0,z:.955423},{x:-.309017,y:.5,z:.809017},{x:-.16246,y:.262866,z:.951056},{x:0,y:0,z:1},{x:0,y:.850651,z:.525731},{x:-.147621,y:.716567,z:.681718},{x:.147621,y:.716567,z:.681718},{x:0,y:.525731,z:.850651},{x:.309017,y:.5,z:.809017},{x:.525731,y:0,z:.850651},{x:.295242,y:0,z:.955423},{x:.442863,y:.238856,z:.864188},{x:.16246,y:.262866,z:.951056},{x:-.681718,y:.147621,z:.716567},{x:-.809017,y:.309017,z:.5},{x:-.587785,y:.425325,z:.688191},{x:-.850651,y:.525731,z:0},{x:-.864188,y:.442863,z:.238856},{x:-.716567,y:.681718,z:.147621},{x:-.688191,y:.587785,z:.425325},{x:-.5,y:.809017,z:.309017},{x:-.238856,y:.864188,z:.442863},{x:-.425325,y:.688191,z:.587785},{x:-.716567,y:.681718,z:-.147621},{x:-.5,y:.809017,z:-.309017},{x:-.525731,y:.850651,z:0},{x:0,y:.850651,z:-.525731},{x:-.238856,y:.864188,z:-.442863},{x:0,y:.955423,z:-.295242},{x:-.262866,y:.951056,z:-.16246},{x:0,y:1,z:0},{x:0,y:.955423,z:.295242},{x:-.262866,y:.951056,z:.16246},{x:.238856,y:.864188,z:.442863},{x:.262866,y:.951056,z:.16246},{x:.5,y:.809017,z:.309017},{x:.238856,y:.864188,z:-.442863},{x:.262866,y:.951056,z:-.16246},{x:.5,y:.809017,z:-.309017},{x:.850651,y:.525731,z:0},{x:.716567,y:.681718,z:.147621},{x:.716567,y:.681718,z:-.147621},{x:.525731,y:.850651,z:0},{x:.425325,y:.688191,z:.587785},{x:.864188,y:.442863,z:.238856},{x:.688191,y:.587785,z:.425325},{x:.809017,y:.309017,z:.5},{x:.681718,y:.147621,z:.716567},{x:.587785,y:.425325,z:.688191},{x:.955423,y:.295242,z:0},{x:1,y:0,z:0},{x:.951056,y:.16246,z:.262866},{x:.850651,y:-.525731,z:0},{x:.955423,y:-.295242,z:0},{x:.864188,y:-.442863,z:.238856},{x:.951056,y:-.16246,z:.262866},{x:.809017,y:-.309017,z:.5},{x:.681718,y:-.147621,z:.716567},{x:.850651,y:0,z:.525731},{x:.864188,y:.442863,z:-.238856},{x:.809017,y:.309017,z:-.5},{x:.951056,y:.16246,z:-.262866},{x:.525731,y:0,z:-.850651},{x:.681718,y:.147621,z:-.716567},{x:.681718,y:-.147621,z:-.716567},{x:.850651,y:0,z:-.525731},{x:.809017,y:-.309017,z:-.5},{x:.864188,y:-.442863,z:-.238856},{x:.951056,y:-.16246,z:-.262866},{x:.147621,y:.716567,z:-.681718},{x:.309017,y:.5,z:-.809017},{x:.425325,y:.688191,z:-.587785},{x:.442863,y:.238856,z:-.864188},{x:.587785,y:.425325,z:-.688191},{x:.688191,y:.587785,z:-.425325},{x:-.147621,y:.716567,z:-.681718},{x:-.309017,y:.5,z:-.809017},{x:0,y:.525731,z:-.850651},{x:-.525731,y:0,z:-.850651},{x:-.442863,y:.238856,z:-.864188},{x:-.295242,y:0,z:-.955423},{x:-.16246,y:.262866,z:-.951056},{x:0,y:0,z:-1},{x:.295242,y:0,z:-.955423},{x:.16246,y:.262866,z:-.951056},{x:-.442863,y:-.238856,z:-.864188},{x:-.309017,y:-.5,z:-.809017},{x:-.16246,y:-.262866,z:-.951056},{x:0,y:-.850651,z:-.525731},{x:-.147621,y:-.716567,z:-.681718},{x:.147621,y:-.716567,z:-.681718},{x:0,y:-.525731,z:-.850651},{x:.309017,y:-.5,z:-.809017},{x:.442863,y:-.238856,z:-.864188},{x:.16246,y:-.262866,z:-.951056},{x:.238856,y:-.864188,z:-.442863},{x:.5,y:-.809017,z:-.309017},{x:.425325,y:-.688191,z:-.587785},{x:.716567,y:-.681718,z:-.147621},{x:.688191,y:-.587785,z:-.425325},{x:.587785,y:-.425325,z:-.688191},{x:0,y:-.955423,z:-.295242},{x:0,y:-1,z:0},{x:.262866,y:-.951056,z:-.16246},{x:0,y:-.850651,z:.525731},{x:0,y:-.955423,z:.295242},{x:.238856,y:-.864188,z:.442863},{x:.262866,y:-.951056,z:.16246},{x:.5,y:-.809017,z:.309017},{x:.716567,y:-.681718,z:.147621},{x:.525731,y:-.850651,z:0},{x:-.238856,y:-.864188,z:-.442863},{x:-.5,y:-.809017,z:-.309017},{x:-.262866,y:-.951056,z:-.16246},{x:-.850651,y:-.525731,z:0},{x:-.716567,y:-.681718,z:-.147621},{x:-.716567,y:-.681718,z:.147621},{x:-.525731,y:-.850651,z:0},{x:-.5,y:-.809017,z:.309017},{x:-.238856,y:-.864188,z:.442863},{x:-.262866,y:-.951056,z:.16246},{x:-.864188,y:-.442863,z:.238856},{x:-.809017,y:-.309017,z:.5},{x:-.688191,y:-.587785,z:.425325},{x:-.681718,y:-.147621,z:.716567},{x:-.442863,y:-.238856,z:.864188},{x:-.587785,y:-.425325,z:.688191},{x:-.309017,y:-.5,z:.809017},{x:-.147621,y:-.716567,z:.681718},{x:-.425325,y:-.688191,z:.587785},{x:-.16246,y:-.262866,z:.951056},{x:.442863,y:-.238856,z:.864188},{x:.16246,y:-.262866,z:.951056},{x:.309017,y:-.5,z:.809017},{x:.147621,y:-.716567,z:.681718},{x:0,y:-.525731,z:.850651},{x:.425325,y:-.688191,z:.587785},{x:.587785,y:-.425325,z:.688191},{x:.688191,y:-.587785,z:.425325},{x:-.955423,y:.295242,z:0},{x:-.951056,y:.16246,z:.262866},{x:-1,y:0,z:0},{x:-.850651,y:0,z:.525731},{x:-.955423,y:-.295242,z:0},{x:-.951056,y:-.16246,z:.262866},{x:-.864188,y:.442863,z:-.238856},{x:-.951056,y:.16246,z:-.262866},{x:-.809017,y:.309017,z:-.5},{x:-.864188,y:-.442863,z:-.238856},{x:-.951056,y:-.16246,z:-.262866},{x:-.809017,y:-.309017,z:-.5},{x:-.681718,y:.147621,z:-.716567},{x:-.681718,y:-.147621,z:-.716567},{x:-.850651,y:0,z:-.525731},{x:-.688191,y:.587785,z:-.425325},{x:-.587785,y:.425325,z:-.688191},{x:-.425325,y:.688191,z:-.587785},{x:-.425325,y:-.688191,z:-.587785},{x:-.587785,y:-.425325,z:-.688191},{x:-.688191,y:-.587785,z:-.425325}],me=class extends Error{},Wr=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);n.set(r);let i=Ea(n.buffer);return this.cache.set(t,i),i}get(t){return this.cache.get(t)}};function Vc(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Pn(e,t,r,n){if(r!==0&&(t<Hc||t+r>e.byteLength))throw new me(`${n} section is out of bounds`)}function bh(e){if(e.byteLength<Hc)throw new me("MD2 buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0);if(r!==yh)throw new me(`Invalid MD2 ident: ${r}`);if(n!==xh)throw new me(`Unsupported MD2 version: ${n}`);let i={ident:r,version:n,skinWidth:t.getInt32(8,!0),skinHeight:t.getInt32(12,!0),frameSize:t.getInt32(16,!0),numSkins:t.getInt32(20,!0),numVertices:t.getInt32(24,!0),numTexCoords:t.getInt32(28,!0),numTriangles:t.getInt32(32,!0),numGlCommands:t.getInt32(36,!0),numFrames:t.getInt32(40,!0),offsetSkins:t.getInt32(44,!0),offsetTexCoords:t.getInt32(48,!0),offsetTriangles:t.getInt32(52,!0),offsetFrames:t.getInt32(56,!0),offsetGlCommands:t.getInt32(60,!0),offsetEnd:t.getInt32(64,!0),magic:r},o=40+i.numVertices*4;if(i.frameSize!==o)throw new me(`Unexpected frame size ${i.frameSize}, expected ${o}`);if(i.offsetEnd>e.byteLength)throw new me("MD2 offset_end exceeds buffer length");return i}function vh(e,t){let r=t.numSkins*64;Pn(e,t.offsetSkins,r,"skins");let n=new DataView(e,t.offsetSkins,r),i=[];for(let o=0;o<t.numSkins;o+=1)i.push({name:Vc(n,o*64,64)});return i}function Sh(e,t){let r=t.numTexCoords*4;Pn(e,t.offsetTexCoords,r,"texcoords");let n=new DataView(e,t.offsetTexCoords,r),i=[];for(let o=0;o<t.numTexCoords;o+=1){let s=o*4;i.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return i}function wh(e,t){let r=t.numTriangles*12;Pn(e,t.offsetTriangles,r,"triangles");let n=new DataView(e,t.offsetTriangles,r),i=[];for(let o=0;o<t.numTriangles;o+=1){let s=o*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],d=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=t.numVertices)||d.some(l=>l>=t.numTexCoords))throw new me("Triangle references out of range vertex or texcoord");i.push({vertexIndices:a,texCoordIndices:d})}return i}function Ah(e,t){let r=t.numFrames*t.frameSize;Pn(e,t.offsetFrames,r,"frames");let n=[];for(let i=0;i<t.numFrames;i+=1){let o=t.offsetFrames+i*t.frameSize,s=new DataView(e,o,t.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},d={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=Vc(s,24,16),c=[],h=1/0,u=1/0,f=1/0,m=-1/0,g=-1/0,p=-1/0;for(let x=0;x<t.numVertices;x+=1){let S=40+x*4,_=s.getUint8(S)*a.x+d.x,y=s.getUint8(S+1)*a.y+d.y,b=s.getUint8(S+2)*a.z+d.z;_<h&&(h=_),y<u&&(u=y),b<f&&(f=b),_>m&&(m=_),y>g&&(g=y),b>p&&(p=b);let A={x:_,y,z:b},v=s.getUint8(S+3),E=_h[v];if(!E)throw new me(`Invalid normal index ${v} in frame ${l}`);c.push({position:A,normalIndex:v,normal:E})}n.push({name:l,vertices:c,minBounds:{x:h,y:u,z:f},maxBounds:{x:m,y:g,z:p}})}return n}function Mh(e,t){let r=t.numGlCommands*4;if(Pn(e,t.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(e,t.offsetGlCommands,r),i=[],o=0;for(;;){if(o+4>r)throw new me("GL command list ended unexpectedly");let s=n.getInt32(o,!0);if(o+=4,s===0)break;let a=Math.abs(s),d=[],l=a*12;if(o+l>r)throw new me("GL command vertex block exceeds buffer");for(let c=0;c<a;c+=1){let h=n.getFloat32(o,!0),u=n.getFloat32(o+4,!0),f=n.getInt32(o+8,!0);if(o+=12,f<0||f>=t.numVertices)throw new me("GL command references invalid vertex index");d.push({s:h,t:u,vertexIndex:f})}i.push({mode:s>0?"strip":"fan",vertices:d})}if(o!==r)throw new me("GL command list did not consume expected data");return i}function Ea(e){let t=bh(e),r=vh(e,t),n=Sh(e,t),i=wh(e,t),o=Ah(e,t),s=Mh(e,t);return{header:t,skins:r,texCoords:n,triangles:i,frames:o,glCommands:s}}function Gc(e){let t=[],r=0;for(;r<e.length;){let n=e[r].name,i=n.replace(/\d+$/,"")||n,o=r;for(;o+1<e.length&&(e[o+1].name.replace(/\d+$/,"")||e[o+1].name)===i;)o+=1;t.push({name:i,firstFrame:r,lastFrame:o}),r=o+1}return t}var Wc=860898377,Eh=15,Ve=class extends Error{constructor(t){super(t),this.name="Md3ParseError"}};function On(e,t,r){let n=new Uint8Array(e.buffer,e.byteOffset+t,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function Lh(e){let t=(e>>8&255)*(2*Math.PI/255),r=(e&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(t)*n,y:Math.sin(t)*n,z:Math.cos(r)}}function Mo(e,t,r,n){if(t<0||t+r>n)throw new Ve(`${e} exceeds buffer bounds`)}function Th(e){let t=e.getInt32(0,!0);if(t!==Wc)throw new Ve(`Invalid MD3 ident: ${t}`);let r=e.getInt32(4,!0);if(r!==Eh)throw new Ve(`Unsupported MD3 version: ${r}`);let n=On(e,8,64),i=e.getInt32(72,!0),o=e.getInt32(76,!0),s=e.getInt32(80,!0),a=e.getInt32(84,!0),d=e.getInt32(88,!0),l=e.getInt32(92,!0),c=e.getInt32(96,!0),h=e.getInt32(100,!0),u=e.getInt32(104,!0);if(o<=0||a<0||s<0)throw new Ve("Invalid MD3 counts");return{ident:t,version:r,name:n,flags:i,numFrames:o,numTags:s,numSurfaces:a,numSkins:d,ofsFrames:l,ofsTags:c,ofsSurfaces:h,ofsEnd:u,magic:t}}function Ih(e,t){let r=[];Mo("Frames",t.ofsFrames,t.numFrames*56,e.byteLength);for(let i=0;i<t.numFrames;i+=1){let o=t.ofsFrames+i*56;r.push({minBounds:{x:e.getFloat32(o,!0),y:e.getFloat32(o+4,!0),z:e.getFloat32(o+8,!0)},maxBounds:{x:e.getFloat32(o+12,!0),y:e.getFloat32(o+16,!0),z:e.getFloat32(o+20,!0)},localOrigin:{x:e.getFloat32(o+24,!0),y:e.getFloat32(o+28,!0),z:e.getFloat32(o+32,!0)},radius:e.getFloat32(o+36,!0),name:On(e,o+40,16)})}return r}function Ch(e,t){let r=[],i=t.numFrames*t.numTags*112;Mo("Tags",t.ofsTags,i,e.byteLength);for(let o=0;o<t.numFrames;o+=1){let s=[];for(let a=0;a<t.numTags;a+=1){let d=t.ofsTags+(o*t.numTags+a)*112,l=d+64,c=l+12;s.push({name:On(e,d,64),origin:{x:e.getFloat32(l,!0),y:e.getFloat32(l+4,!0),z:e.getFloat32(l+8,!0)},axis:[{x:e.getFloat32(c,!0),y:e.getFloat32(c+4,!0),z:e.getFloat32(c+8,!0)},{x:e.getFloat32(c+12,!0),y:e.getFloat32(c+16,!0),z:e.getFloat32(c+20,!0)},{x:e.getFloat32(c+24,!0),y:e.getFloat32(c+28,!0),z:e.getFloat32(c+32,!0)}]})}r.push(s)}return r}function zh(e,t){let r=e.getInt32(t,!0);if(r!==Wc)throw new Ve(`Invalid surface ident at ${t}: ${r}`);let n=On(e,t+4,64),i=e.getInt32(t+68,!0),o=e.getInt32(t+72,!0),s=e.getInt32(t+76,!0),a=e.getInt32(t+80,!0),d=e.getInt32(t+84,!0),l=e.getInt32(t+88,!0),c=e.getInt32(t+92,!0),h=e.getInt32(t+96,!0),u=e.getInt32(t+100,!0),f=e.getInt32(t+104,!0);if(o<=0||a<=0||d<=0)throw new Ve(`Invalid surface counts for ${n}`);let m=f;Mo(`Surface ${n}`,t,m,e.byteLength);let g=[],p=t+l;for(let v=0;v<d;v+=1){let E=p+v*12;g.push({indices:[e.getInt32(E,!0),e.getInt32(E+4,!0),e.getInt32(E+8,!0)]})}let x=[],S=t+c;for(let v=0;v<s;v+=1){let E=S+v*68;x.push({name:On(e,E,64),shaderIndex:e.getInt32(E+64,!0)})}let _=[],y=t+h;for(let v=0;v<a;v+=1){let E=y+v*8;_.push({s:e.getFloat32(E,!0),t:e.getFloat32(E+4,!0)})}let b=[],A=t+u;for(let v=0;v<o;v+=1){let E=[];for(let L=0;L<a;L+=1){let w=A+(v*a+L)*8,T=e.getInt16(w,!0)/64,R=e.getInt16(w+2,!0)/64,U=e.getInt16(w+4,!0)/64,z=e.getUint16(w+6,!0);E.push({position:{x:T,y:R,z:U},latLng:z,normal:Lh(z)})}b.push(E)}return{surface:{name:n,flags:i,numFrames:o,shaders:x,triangles:g,texCoords:_,vertices:b},nextOffset:t+f}}function La(e){if(e.byteLength<108)throw new Ve("MD3 buffer too small for header");let t=new DataView(e),r=Th(t);Mo("MD3 end",r.ofsEnd,0,e.byteLength);let n=Ih(t,r),i=Ch(t,r),o=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:d,nextOffset:l}=zh(t,s);o.push(d),s=l}if(s!==r.ofsEnd)throw new Ve("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:i,surfaces:o}}var Xr=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=La(r.slice().buffer);return this.cache.set(t,n),n}get(t){return this.cache.get(t)}};var Rh=844317769,kh=2,Xc=64,Kc=12,Ft=class extends Error{};function Fh(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Ta(e){if(e.byteLength<Kc)throw new Ft("Sprite buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0),i=t.getInt32(8,!0);if(r!==Rh)throw new Ft(`Invalid Sprite ident: ${r}`);if(n!==kh)throw new Ft(`Unsupported Sprite version: ${n}`);let o=[],s=16+Xc,a=Kc;for(let d=0;d<i;d+=1){if(a+s>e.byteLength)throw new Ft("Sprite frame data exceeds buffer length");let l=t.getInt32(a,!0),c=t.getInt32(a+4,!0),h=t.getInt32(a+8,!0),u=t.getInt32(a+12,!0),f=Fh(t,a+16,Xc);o.push({width:l,height:c,originX:h,originY:u,name:f}),a+=s}return{ident:r,version:n,numFrames:i,frames:o}}var Kr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Ta(n.buffer)}};function $c(e,t){let r=(e.sequence.end-e.sequence.start+1)/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time+t;return n?i=(i%r+r)%r:i>r&&(i=r),{...e,time:Math.max(0,Math.min(i,r))}}function Zc(e){let t=e.sequence.end-e.sequence.start+1,r=1/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time/r;if(!n&&i>=t)return{frame0:e.sequence.end,frame1:e.sequence.end,lerp:0};let o=n?i%t:Math.min(i,t-1),s=Math.floor(o),a=e.sequence.start+s,d=s+1>=t?n?e.sequence.start:e.sequence.end:a+1,l=!n&&s>=t-1?0:o-s;return{frame0:a,frame1:d,lerp:l}}function Yc(e){return{sequence:e,time:0}}function qc(e,t,r){return{x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r,z:e.z+(t.z-e.z)*r}}var Bn=class extends Error{constructor(t){super(t),this.name="WalParseError"}};function Eo(e){if(e.byteLength<100)throw new Bn("WAL buffer too small");let t=new DataView(e),r=new Uint8Array(e,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),i=t.getInt32(32,!0),o=t.getInt32(36,!0),s=[t.getInt32(40,!0),t.getInt32(44,!0),t.getInt32(48,!0),t.getInt32(52,!0)],a=new Uint8Array(e,56,32),d=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=t.getInt32(88,!0),c=t.getInt32(92,!0),h=t.getInt32(96,!0);if(i<=0||o<=0)throw new Bn("Invalid WAL dimensions");let u=[],f=i,m=o;for(let g=0;g<s.length;g+=1){let p=s[g],x=Math.max(1,f*m|0);if(p<=0||p+x>e.byteLength)throw new Bn(`Invalid WAL mip offset for level ${g}`);let S=new Uint8Array(e,p,x);u.push({level:g,width:f,height:m,data:S}),f=Math.max(1,f>>1),m=Math.max(1,m>>1)}return{name:n,width:i,height:o,mipmaps:u,animName:d,flags:l,contents:c,value:h}}var ar=class extends Error{constructor(t){super(t),this.name="PcxParseError"}};function Nn(e){if(e.byteLength<128)throw new ar("PCX buffer too small for header");let t=new DataView(e),r=t.getUint8(0),n=t.getUint8(2),i=t.getUint8(3),o=t.getUint16(4,!0),s=t.getUint16(6,!0),a=t.getUint16(8,!0),d=t.getUint16(10,!0);if(r!==10||n!==1)throw new ar("Unsupported PCX encoding");if(i!==8)throw new ar("Only 8bpp PCX files are supported");let l=a-o+1,c=d-s+1,h=t.getUint16(66,!0),u=e.byteLength-769;if(u<128||new DataView(e,u,1).getUint8(0)!==12)throw new ar("Missing PCX palette");let f=new Uint8Array(e,u+1,768),m=new Uint8Array(e,128,u-128),g=new Uint8Array(l*c),p=0,x=0;for(let S=0;S<c;S+=1){let _=0;for(;_<h&&p<m.length;){let y=1,b=m[p++];if((b&192)===192){if(y=b&63,p>=m.length)throw new ar("Unexpected end of PCX RLE data");b=m[p++]}for(let A=0;A<y&&_<h;A+=1)_<l&&(g[x++]=b),_+=1}}return{width:l,height:c,bitsPerPixel:i,pixels:g,palette:f}}function Lo(e){let t=new Uint8Array(e.width*e.height*4);for(let r=0;r<e.pixels.length;r+=1){let n=e.pixels[r],i=n*3,o=r*4;t[o]=e.palette[i],t[o+1]=e.palette[i+1],t[o+2]=e.palette[i+2],t[o+3]=n===255?0:255}return t}var pt=class extends Error{constructor(t){super(t),this.name="TgaParseError"}};function Ia(e){let t=new DataView(e);if(e.byteLength<18)throw new pt("Buffer too small for TGA header");let r=t.getUint8(0),n=t.getUint8(1),i=t.getUint8(2),o=t.getUint16(12,!0),s=t.getUint16(14,!0),a=t.getUint8(16),d=t.getUint8(17);if(i!==2&&i!==10&&i!==3&&i!==11)throw new pt(`Unsupported TGA image type: ${i} (only RGB/Grayscale supported)`);if(a!==24&&a!==32&&a!==8)throw new pt(`Unsupported pixel depth: ${a} (only 8, 24, 32 bpp supported)`);let l=i>=9,c=i===3||i===11,h=a/8,u=18+r;if(n===1){let _=t.getUint16(5,!0),y=t.getUint8(7);u+=_*(y/8)}let f=o*s,m=new Uint8Array(f*4),g=(d&32)!==0,p=0,x=new Uint8Array(e),S=_=>{if(c){let y=x[u++];m[_]=y,m[_+1]=y,m[_+2]=y,m[_+3]=255}else{let y=x[u++],b=x[u++],A=x[u++],v=a===32?x[u++]:255;m[_]=A,m[_+1]=b,m[_+2]=y,m[_+3]=v}};if(l){let _=0;for(;_<f;){if(u>=e.byteLength)throw new pt("Unexpected end of TGA RLE data");let y=x[u++],b=(y&127)+1,A=(y&128)!==0;if(_+b>f)throw new pt("TGA RLE packet exceeds image bounds");if(A){let v=c?x[u]:x[u+2],E=c?x[u]:x[u+1],L=x[u],w=c?255:a===32?x[u+3]:255;u+=h;for(let T=0;T<b;T++){let R=(_+T)*4;m[R]=v,m[R+1]=E,m[R+2]=L,m[R+3]=w}}else for(let v=0;v<b;v++)S((_+v)*4);_+=b}}else for(let _=0;_<f;_++){if(u>=e.byteLength)throw new pt("Unexpected end of TGA data");S(_*4)}if(!g){let _=o*4,y=new Uint8Array(_);for(let b=0;b<s/2;b++){let A=b*_,v=(s-1-b)*_;y.set(m.subarray(A,A+_)),m.set(m.subarray(v,v+_),A),m.set(y,v)}}return{width:o,height:s,bitsPerPixel:32,pixels:m}}var $r=class{constructor(t={}){this.cache=new kt(t.capacity??128)}get size(){return this.cache.size}get(t){return this.cache.get(t.toLowerCase())}set(t,r){this.cache.set(t.toLowerCase(),r)}clear(){this.cache.clear()}};function Ca(e,t){let r=[];for(let n of e.mipmaps){let i=new Uint8Array(n.width*n.height*4);for(let o=0;o<n.data.length;o+=1){let s=n.data[o],a=s*3,d=o*4;i[d]=t[a],i[d+1]=t[a+1],i[d+2]=t[a+2],i[d+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:i})}return{width:e.width,height:e.height,levels:r,source:"wal"}}function To(e){let t=Lo(e),r={level:0,width:e.width,height:e.height,rgba:t};return{width:e.width,height:e.height,levels:[r],source:"pcx"}}function jc(e){let t={level:0,width:e.width,height:e.height,rgba:e.pixels};return{width:e.width,height:e.height,levels:[t],source:"tga"}}function Io(e,t){return Ca(Eo(e),t)}var lr=class extends Error{constructor(t){super(t),this.name="WavParseError"}};function za(e,t,r){return new TextDecoder("ascii").decode(new Uint8Array(e.buffer,e.byteOffset+t,r))}function Co(e){if(e.byteLength<44)throw new lr("WAV buffer too small");let t=new DataView(e);if(za(t,0,4)!=="RIFF"||za(t,8,4)!=="WAVE")throw new lr("Invalid WAV header");let r=12,n=-1,i=-1,o=0,s=0;for(;r+8<=e.byteLength;){let m=za(t,r,4),g=t.getUint32(r+4,!0),p=r+8;m==="fmt "?(n=p,o=g):m==="data"&&(i=p,s=g),r=p+g}if(n===-1||i===-1)throw new lr("Missing fmt or data chunk");let a=t.getUint16(n,!0),d=t.getUint16(n+2,!0),l=t.getUint32(n+4,!0),c=t.getUint16(n+14,!0);if(a!==1)throw new lr("Only PCM WAV is supported");let h=c/8,u=s/(h*d),f=new Float32Array(u*d);for(let m=0;m<u;m+=1)for(let g=0;g<d;g+=1){let p=m*d+g,x=i+p*h,S=0;if(c===8)S=t.getUint8(x),f[p]=(S-128)/128;else if(c===16)S=t.getInt16(x,!0),f[p]=S/32768;else if(c===24){let _=t.getUint8(x),y=t.getUint8(x+1),b=t.getInt8(x+2);S=_|y<<8|b<<16,f[p]=S/8388608}else throw new lr(`Unsupported bitsPerSample: ${c}`)}return{sampleRate:l,channels:d,bitsPerSample:c,samples:f}}var Dh=(e,t=4294967295,r=79764919)=>{let n=new Int32Array(256),i,o,s,a=t;for(i=0;i<256;i++){for(s=i<<24,o=8;o>0;--o)s=2147483648&s?s<<1^r:s<<1;n[i]=s}for(i=0;i<e.length;i++)a=a<<8^n[255&(a>>24^e[i])];return a};var Ra=(e,t=Dh)=>{let r=p=>new Uint8Array(p.length/2).map(((x,S)=>parseInt(p.substring(2*S,2*(S+1)),16))),n=p=>r(p)[0],i=new Map;[,8364,,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,,381,,,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,,382,376].forEach(((p,x)=>i.set(p,x)));let o=new Uint8Array(e.length),s,a,d,l=!1,c=0,h=42,u=e.length>13&&e.substring(0,9)==="dynEncode",f=0;u&&(f=11,a=n(e.substring(9,f)),a<=1&&(f+=2,h=n(e.substring(11,f))),a===1&&(f+=8,d=(p=>new DataView(r(p).buffer).getInt32(0,!0))(e.substring(13,f))));let m=256-h;for(let p=f;p<e.length;p++)if(s=e.charCodeAt(p),s!==61||l){if(s===92&&p<e.length-5&&u){let x=e.charCodeAt(p+1);x!==117&&x!==85||(s=parseInt(e.substring(p+2,p+6),16),p+=5)}if(s>255){let x=i.get(s);x&&(s=x+127)}l&&(l=!1,s-=64),o[c++]=s<h&&s>0?s+m:s-h}else l=!0;let g=o.subarray(0,c);if(u&&a===1){let p=t(g);if(p!==d){let x="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",x+`
2
2
  `,"Expected: "+d+"; Got: "+p+`
3
- `,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(x)}}return g};function te(){let e=Uint8Array,t=Float32Array;te.modules||Object.defineProperties(te,{modules:{value:new WeakMap},setModule:{value(r,n){te.modules.set(r,Promise.resolve(n))}},getModule:{value(r,n){let i=te.modules.get(r);return i||(n?i=WebAssembly.compile(za(n)):(n=r.wasm,i=te.inflateDynEncodeString(n).then(o=>WebAssembly.compile(o))),te.modules.set(r,i)),i}},concatFloat32:{value(r,n){let i=new t(n),o=0,s=0;for(;o<r.length;)i.set(r[o],s),s+=r[o++].length;return i}},getDecodedAudio:{value:(r,n,i,o,s)=>({errors:r,channelData:n,samplesDecoded:i,sampleRate:o,bitDepth:s})},getDecodedAudioMultiChannel:{value(r,n,i,o,s,a){let d=[],l,c;for(l=0;l<i;l++){let h=[];for(c=0;c<n.length;)h.push(n[c++][l]||[]);d.push(te.concatFloat32(h,o))}return te.getDecodedAudio(r,d,o,s,a)}},inflateDynEncodeString:{value(r){return r=za(r),new Promise(n=>{let i=String.raw`dynEncode012804c7886d(‰›•)((()>+ˆ*§§)§ˆ,§§§§)§ˆ+§§§)§+.-()(*)-+)(ˆ.7*§)i¸¸,3§(i¸¸,3/G+.••—š¡*(,˜ŽŽ(,3‡‡‰˜‡Š‰›+)2å:-œ),§H(P*DI*H(P*@I++hH)H*r,hH(H(P*<J,i)’^*<H,H(P*4’U((I-H(H*i0’J,^*DH+H-H*œšI+H,I*4)33H(H*H)“^*DH(H+H)^*@H+i§H)œi§›™3æ*).§K(iH“I/+§H,iHn,§H+i(H+i(rCJ0I,H*I-+hH,,hH(H-V)(i)œ’J.H.W)(i)’c)(H,i)“I,H-i*’I-4)33i(I.*hH(V)(H+n5(H(i*’I-i(I,i)I.+hH,i*’J+iHn,hi(I-i*I,+hH,H/’H-c)(H,iFn,hi(I,+hH,H0n5-H*V)(J(,hH/H(i)œ’J(H(V)(J(i)’c)(H)H(i)œ’H,c)(3H*i*’I*H,i)’I,4(3(-H(H,’W)(H-’I-H,i*’I,4)3(3(3H,H-’I1H+I,H.i)œH1V)(“J.i(v5(33H.-H(H,’i(c)(H,i*’I,4)333–)-§i*I*+§H*iHn,hiž73H,H(i)8(H+šJ+H)P*(H*’V)(J-“r,§H)P*,H.i)œ’H+H,“i)œ’V)(-H*i*’I*H+i)œI+H-H.’I.H,H-’i)œI,4)333Ã+)-§iø7i(^*(iü7I,*h+hH+iDn,h*hilI+i)I,+hH+,hH+iô7’H,c)(i)H+i´8’W)(œH,’I,H+i*’I+4)-+hH(H)8*J-i(p5.*h*h*hH-i')u,hH(P*(J+,hH(P*0J,H(P*,n50H+H,’H-b((3H(P*0i)’I.4)3H-i¨*n5*H-iÅ*s,hiž73H-i)œJ+V)&+I,H(H+V)æ,8(I.H(H*8*J-i(p51H-i)œJ+i¸7’V)(H(H+iø7’V)(8(’J/H(P*0J+s,hi73H+H,H.’J,’I.H(P*(m5(H.H(P*,s5.+hH,m5*H(P*(J.H+’H.H+H/“’U((b((H(H(P*0i)’J+^*0H,i)“I,4(3(3H(H.^*03H-i¨*o5)33i(73(3(3-H,H+i)žc)(H,i*’I,H+i)’I+4)33i)I-3H-3!2)0§K(i2“J,L(H,H(^*(H,H*^*4H,i(^*0H,i(^*DH,j(_*<H,H)P*(^*,H,H+P*(^*8*h*h+hH,i)8(I3i§I**h*h*h*h*h*h*hH,i*8(6+(),03H,j(_*@i*I-H,P*<J.i,’J(H,P*8J/s50H,H.i+’J0^*<i¦I*H.H,P*4J1’J.U(*H.U((J2›i')o5/H.U()I.H,H(^*<H0H1’U((H.i0œJ.i§›i0ži')™o5/H/H.H2šJ*H(’J.q50H,P*0J/H*’I-H,P*(J0,hH,P*,H-q,hi)I-423+hH*m5+H/H0’H(H1’U((b((H/i)’I/H(i)’I(H*i)“I*4(3(3H,H.^*<H,H-^*04*3iØ1U((5+i(I(i¨7i1^*(i$6iè1^*(i°7iè6^*(i¬7iÈ6^*(+hH(iÈ*n,hiÈ*I(+hH(i¨,n,hi¨,I(+hH(iØ,n,hiØ,I(+hH(iè,o,hH,i-’H(’i0c)(H(i*’I(4)33iè1i1H,i-’iÈ*8)Bi(I(+hH(ido,hH,i-’H(’i-c)(H(i*’I(4)33iÈ6iè6H,i-’iF8)BiØ1i)b((41-H,i-’H(’i/c)(H(i*’I(4)3(3(-H,i-’H(’i1c)(H(i*’I(4)3(3(-H,i-’H(’i0c)(H(i*’I(4)3(3(3H,H/^*0H,H(^*<3i(I*4*3H,H,i¸)’^*TH,H,iø-’^*PH,H,iX’^*LH,H,i(’^*HH,i-8(I(H,i-8(I-i¥I*H,i,8(I.H(iErH-iErš5)H(i©*’I1H-i)’I0i(i;H.i,’J(i(H(i(rCJ(“J*H*i;sCI*i¨1I-H(I/+hH/,hH,i-’H-V)(i)œ’H,i+8(c)(H/i)“I/H-i*’I-H*i)’I*4)-H(i)œi¨1’I/+hH(H*o,hH,i-’H/V)(i)œ’i(c)(H/i*’I/H(i)’I(4)33i¤I*H,iø-’H,i¸)’H,i-’i;8)5+H0H1’I2i(I-+hH-H2p,hH,H,iP’8*J*i(p5-H*i7u,hH,i-’H-i)œ’H*c)(H-i)’I-4*3i(I/i+I.i+I(*h*h*hH*i8“6*(*)3H-m,hi£I*403H-i)œH,’W)-I/i*I(4)3i3I.i/I(3H2H,H(8(H.’J(H-’J.p,hi¢I*4.3H,i-’H-i)œ’I*+hH(,hH*H/c)(H*i*’I*H(i)“I(4)-H.I-4+3(3(33H,W)1m,hiŸI*4,3H,iø-’H,i¸)’H,i-’H18)J(,hi¡I*H(i(p5,H1H,V)ú-H,V)ø-’o5,3H,i(’H,iX’H,i-’H1i)œ’H08)J(,hi I*H(i(p5,H0H,V)šH,V)˜’o5,3H,H,iP’H,iH’8+I*4+3(3(3H,i$6i¬78+I*3H*H3šm5(3i)I-H*i(r5)3H)H,P*0^*(H+H,P*<^*(H*I-3H,i2’L(H-33Á)+(i¨03b+(,(-(.(/(0(1(2(3(5(7(9(;(?(C(G(K(S([(c(k({(‹(›(«(Ë(ë( (*)(iø03O)()()()(*(*(*(*(+(+(+(+(,(,(,(,(-(-(-(-(i¨13M8(9(:(((0(/(1(.(2(-(3(,(4(+(5(*(6()(7(T7œ‰šœ‡Ž‰œš›*S7•œ‰Š”U”—Љ”›S0›‘–U œ`;te.getModule(te,i).then(o=>WebAssembly.instantiate(o,{})).then(({exports:o})=>{let s=new Map(Object.entries(o)),a=s.get("puff"),d=s.get("memory").buffer,l=new e(d),c=new DataView(d),h=s.get("__heap_base"),u=r.length,f=h;h+=4,c.setInt32(f,u,!0);let m=h;h+=u,l.set(r,m);let g=h;h+=4,c.setInt32(g,l.byteLength-h,!0),a(h,g,m,f),n(l.slice(h,h+c.getInt32(g,!0)))})})}}}),Object.defineProperty(this,"wasm",{enumerable:!0,get:()=>this._wasm}),this.getOutputChannels=(r,n,i)=>{let o=[],s=0;for(;s<n;)o.push(r.slice(s*i,s++*i+i));return o},this.allocateTypedArray=(r,n,i=!0)=>{let o=this._wasm.malloc(n.BYTES_PER_ELEMENT*r);return i&&this._pointers.add(o),{ptr:o,len:r,buf:new n(this._wasm.HEAP,o,r)}},this.free=()=>{this._pointers.forEach(r=>{this._wasm.free(r)}),this._pointers.clear()},this.codeToString=r=>{let n=[],i=new Uint8Array(this._wasm.HEAP);for(let o=i[r];o!==0;o=i[++r])n.push(o);return String.fromCharCode.apply(null,n)},this.addError=(r,n,i,o,s,a)=>{r.push({message:n,frameLength:i,frameNumber:o,inputBytes:s,outputSamples:a})},this.instantiate=(r,n)=>(n&&te.setModule(r,n),this._wasm=new r(te).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var ed=Ku(Jc(),1);var Dh=()=>globalThis.Worker||ed.default,Zr=class extends Dh(){constructor(t,r,n,i){te.modules||new te;let o=te.modules.get(n);if(!o){let s="text/javascript",a,d=`'use strict';(${((l,c,h)=>{let u,f,m=new Promise(g=>{f=g});self.onmessage=({data:{id:g,command:p,data:x}})=>{let S=m,_={id:g},y;p==="init"?(Object.defineProperties(l,{WASMAudioDecoderCommon:{value:c},EmscriptenWASM:{value:h},module:{value:x.module},isWebWorker:{value:!0}}),u=new l(x.options),f()):p==="free"?u.free():p==="ready"?S=S.then(()=>u.ready):p==="reset"?S=S.then(()=>u.reset()):(Object.assign(_,u[p](Array.isArray(x)?x.map(b=>new Uint8Array(b)):new Uint8Array(x))),y=_.channelData?_.channelData.map(b=>b.buffer):[]),S.then(()=>self.postMessage(_,y))}}).toString()})(${n}, ${te}, ${i})`;try{a=typeof process.versions.node<"u"}catch{}o=a?`data:${s};base64,${Buffer.from(d).toString("base64")}`:URL.createObjectURL(new Blob([d],{type:s})),te.modules.set(n,o)}super(o,{name:r}),this._id=Number.MIN_SAFE_INTEGER,this._enqueuedOperations=new Map,this.onmessage=({data:s})=>{let{id:a,...d}=s;this._enqueuedOperations.get(a)(d),this._enqueuedOperations.delete(a)},new i(te).getModule().then(s=>{this.postToDecoder("init",{module:s,options:t})})}async postToDecoder(t,r){return new Promise(n=>{this.postMessage({command:t,id:this._id,data:r}),this._enqueuedOperations.set(this._id++,n)})}get ready(){return this.postToDecoder("ready")}async free(){await this.postToDecoder("free").finally(()=>{this.terminate()})}async reset(){await this.postToDecoder("reset")}};var Co=(e,t)=>{Object.defineProperty(e,"name",{value:t})};var re=Symbol,td=", ",D=(()=>{let e="front",t="side",r="rear",n="left",i="center",o="right";return["",e+" ",t+" ",r+" "].map(s=>[[n,o],[n,o,i],[n,i,o],[i,n,o],[i]].flatMap(a=>a.map(d=>s+d).join(td)))})(),it="LFE",Pt="monophonic (mono)",Dt="stereo",Un="surround",ie=(e,...t)=>`${[Pt,Dt,`linear ${Un}`,"quadraphonic",`5.0 ${Un}`,`5.1 ${Un}`,`6.1 ${Un}`,`7.1 ${Un}`][e-1]} (${t.join(td)})`,Hn=[Pt,ie(2,D[0][0]),ie(3,D[0][2]),ie(4,D[1][0],D[3][0]),ie(5,D[1][2],D[3][0]),ie(6,D[1][2],D[3][0],it),ie(7,D[1][2],D[2][0],D[3][4],it),ie(8,D[1][2],D[2][0],D[3][0],it)],rd=192e3,nd=176400,zo=96e3,ko=88200,id=64e3,Ot=48e3,Yr=44100,qr=32e3,jr=24e3,Qr=22050,Jr=16e3,Fo=12e3,Po=11025,en=8e3,od=7350,Je="absoluteGranulePosition",N="bandwidth",xe="bitDepth",_e="bitrate",Vn=_e+"Maximum",Gn=_e+"Minimum",Wn=_e+"Nominal",ot="buffer",Xn=ot+"Fullness",ee="codec",be=ee+"Frames",Kn="coupledStreamCount",tn="crc",$n=tn+"16",Zn=tn+"32",Q="data",F="description",st="duration",rn="emphasis",Yn="hasOpusPadding",ke="header",Bt="isContinuedPacket",qn="isCopyrighted",Nt="isFirstPage",jn="isHome",Fe="isLastPage",gt="isOriginal",yt="isPrivate",Qn="isVbr",Ie="layer",M="length",B="mode",xt=B+"Extension",Do="mpeg",_t=Do+"Version",Jn="numberAACFrames",ei="outputGain",cr="preSkip",ti="profile",Oo=re(),bt="protection",ka="rawData",Ge="segments",H="subarray",Ut="version",dr="vorbis",ri=dr+"Comments",nn=dr+"Setup",Bo="block",ni=Bo+"ingStrategy",No=re(),vt=Bo+"Size",Ht=Bo+"size0",Vt=Bo+"size1",ii=re(),Uo="channel",St=Uo+"MappingFamily",oi=Uo+"MappingTable",ve=Uo+"Mode",si=re(),k=Uo+"s",sd="copyright",ai=sd+"Id",li=sd+"IdStart",wt="frame",At=wt+"Count",Re=wt+"Length",Ho="Number",Mt=wt+Ho,at=wt+"Padding",O=wt+"Size",ad="Rate",ci="inputSample"+ad,Fa="page",ur=Fa+"Checksum",on=re(),Gt=Fa+"SegmentTable",le=Fa+"Sequence"+Ho,Pa="sample",di=Pa+Ho,G=Pa+ad,lt=re(),W=Pa+"s",Vo="stream",ui=Vo+"Count",fi=Vo+"Info",ct=Vo+"Serial"+Ho,Da=Vo+"StructureVersion",Oa="total",fr=Oa+"BytesOut",hr=Oa+"Duration",mr=Oa+"Samples",K=re(),We=re(),hi=re(),Wt=re(),et=re(),Go=re(),Ba=re(),Xt=re(),Z=re(),Xe=re(),Ke=re(),dt=re(),Kt=re(),Wo=re(),tt=re(),rt=re(),$e=re(),Xo=re(),Se=Uint8Array,$t=DataView,Y="reserved",we="bad",sn="free",mi="none",Ko="16bit CRC";var Na=(e,t,r)=>{for(let n=0;n<e[M];n++){let i=t(n);for(let o=8;o>0;o--)i=r(i);e[n]=i}return e},Bh=Na(new Se(256),e=>e,e=>e&128?7^e<<1:e<<1),oe=[Na(new Uint16Array(256),e=>e<<8,e=>e<<1^(e&32768?32773:0))],se=[Na(new Uint32Array(256),e=>e,e=>e>>>1^(e&1)*3988292384)];for(let e=0;e<15;e++){oe.push(new Uint16Array(256)),se.push(new Uint32Array(256));for(let t=0;t<=255;t++)oe[e+1][t]=oe[0][oe[e][t]>>>8]^oe[e][t]<<8,se[e+1][t]=se[e][t]>>>8^se[0][se[e][t]&255]}var cd=e=>{let t=0,r=e[M];for(let n=0;n!==r;n++)t=Bh[t^e[n]];return t},dd=e=>{let t=e[M],r=t-16,n=0,i=0;for(;i<=r;)n^=e[i++]<<8|e[i++],n=oe[15][n>>8]^oe[14][n&255]^oe[13][e[i++]]^oe[12][e[i++]]^oe[11][e[i++]]^oe[10][e[i++]]^oe[9][e[i++]]^oe[8][e[i++]]^oe[7][e[i++]]^oe[6][e[i++]]^oe[5][e[i++]]^oe[4][e[i++]]^oe[3][e[i++]]^oe[2][e[i++]]^oe[1][e[i++]]^oe[0][e[i++]];for(;i!==t;)n=(n&255)<<8^oe[0][n>>8^e[i++]];return n},ud=e=>{let t=e[M],r=t-16,n=0,i=0;for(;i<=r;)n=se[15][(e[i++]^n)&255]^se[14][(e[i++]^n>>>8)&255]^se[13][(e[i++]^n>>>16)&255]^se[12][e[i++]^n>>>24]^se[11][e[i++]]^se[10][e[i++]]^se[9][e[i++]]^se[8][e[i++]]^se[7][e[i++]]^se[6][e[i++]]^se[5][e[i++]]^se[4][e[i++]]^se[3][e[i++]]^se[2][e[i++]]^se[1][e[i++]]^se[0][e[i++]];for(;i!==t;)n=se[0][(n^e[i++])&255]^n>>>8;return n^-1},gi=(...e)=>{let t=new Se(e.reduce((r,n)=>r+n[M],0));return e.reduce((r,n)=>(t.set(n,r),r+n[M]),0),t},Pe=e=>String.fromCharCode(...e),ld=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],pi=e=>ld[e&15]<<4|ld[e>>4],$o=class{constructor(t){this._data=t,this._pos=t[M]*8}set position(t){this._pos=t}get position(){return this._pos}read(t){let r=Math.floor(this._pos/8),n=this._pos%8;return this._pos-=t,(pi(this._data[r-1])<<8)+pi(this._data[r])>>7-n&255}},fd=(e,t)=>{try{return e.getBigInt64(t,!0)}catch{let r=e.getUint8(t+7)&128?-1:1,n=e.getUint32(t,!0),i=e.getUint32(t+4,!0);return r===-1&&(n=~n+1,i=~i+1),i>1048575&&console.warn("This platform does not support BigInt"),r*(n+i*2**32)}};var yi=class{constructor(t,r){this._onCodecHeader=t,this._onCodecUpdate=r,this[tt]()}[rt](){this._isEnabled=!0}[tt](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[Wo](t,r){if(this._onCodecUpdate){this._bitrate!==t&&(this._bitrate=t,this._codecShouldUpdate=!0);let n=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&n&&this._onCodecUpdate({bitrate:t,...n},r),this._codecShouldUpdate=!1}}[Z](t){let r=this._headerCache.get(t);return r&&this._updateCurrentHeader(t),r}[Xe](t,r,n){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...r}),this._codecHeaderSent=!0),this._updateCurrentHeader(t),this._headerCache.set(t,r),this._codecUpdateData.set(r,n))}_updateCurrentHeader(t){this._onCodecUpdate&&t!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=t)}};var ue=new WeakMap,pe=new WeakMap;var Ae=class{constructor(t,r){this._codecParser=t,this._headerCache=r}*[Ba](){let t;do{if(t=yield*this.Frame[Ke](this._codecParser,this._headerCache,0),t)return t;this._codecParser[We](1)}while(!0)}*[Xt](t){let r=yield*this[Ba](),n=pe.get(r)[M];if(t||this._codecParser._flushing||(yield*this.Header[Z](this._codecParser,this._headerCache,n)))return this._headerCache[rt](),this._codecParser[We](n),this._codecParser[Wt](r),r;this._codecParser[et](`Missing ${wt} at ${n} bytes from current position.`,`Dropping current ${wt} and trying again.`),this._headerCache[tt](),this._codecParser[We](1)}};var pr=class{constructor(t,r){pe.set(this,{[ke]:t}),this[Q]=r}};var De=class extends pr{static*[Ke](t,r,n,i,o){let s=yield*t[Z](n,i,o);if(s){let a=ue.get(s)[Re],d=ue.get(s)[W],l=(yield*n[K](a,o))[H](0,a);return new r(s,l,d)}else return null}constructor(t,r,n){super(t,r),this[ke]=t,this[W]=n,this[st]=n/t[G]*1e3,this[Mt]=null,this[fr]=null,this[mr]=null,this[hr]=null,pe.get(this)[M]=r[M]}};var Ua="unsynchronizationFlag",Ha="extendedHeaderFlag",Va="experimentalFlag",Ga="footerPresent",xi=class e{static*getID3v2Header(t,r,n){let o={},s=yield*t[K](3,n);if(s[0]!==73||s[1]!==68||s[2]!==51||(s=yield*t[K](10,n),o[Ut]=`id3v2.${s[3]}.${s[4]}`,s[5]&15)||(o[Ua]=!!(s[5]&128),o[Ha]=!!(s[5]&64),o[Va]=!!(s[5]&32),o[Ga]=!!(s[5]&16),s[6]&128||s[7]&128||s[8]&128||s[9]&128))return null;let a=s[6]<<21|s[7]<<14|s[8]<<7|s[9];return o[M]=10+a,new e(o)}constructor(t){this[Ut]=t[Ut],this[Ua]=t[Ua],this[Ha]=t[Ha],this[Va]=t[Va],this[Ga]=t[Ga],this[M]=t[M]}};var Oe=class{constructor(t){ue.set(this,t),this[xe]=t[xe],this[_e]=null,this[k]=t[k],this[ve]=t[ve],this[G]=t[G]}};var yd={0:[sn,sn,sn,sn,sn],16:[32,32,32,32,8],240:[we,we,we,we,we]},Zo=(e,t,r)=>8*((e+r)%t+t)*(1<<(e+r)/t)-8*t*(t/8|0);for(let e=2;e<15;e++)yd[e<<4]=[e*32,Zo(e,4,0),Zo(e,4,-1),Zo(e,8,4),Zo(e,8,0)];var Nh=0,Uh=1,Hh=2,Vh=3,hd=4,Yo="bands ",qo=" to 31",md={0:Yo+4+qo,16:Yo+8+qo,32:Yo+12+qo,48:Yo+16+qo},gr="bitrateIndex",_i="v2",ts="v1",jo="Intensity stereo ",Qo=", MS stereo ",Jo="on",es="off",Gh={0:jo+es+Qo+es,16:jo+Jo+Qo+es,32:jo+es+Qo+Jo,48:jo+Jo+Qo+Jo},Wa={0:{[F]:Y},2:{[F]:"Layer III",[at]:1,[xt]:Gh,[ts]:{[gr]:Hh,[W]:1152},[_i]:{[gr]:hd,[W]:576}},4:{[F]:"Layer II",[at]:1,[xt]:md,[W]:1152,[ts]:{[gr]:Uh},[_i]:{[gr]:hd}},6:{[F]:"Layer I",[at]:4,[xt]:md,[W]:384,[ts]:{[gr]:Nh},[_i]:{[gr]:Vh}}},Xa="MPEG Version ",pd="ISO/IEC ",Wh={0:{[F]:`${Xa}2.5 (later extension of MPEG 2)`,[Ie]:_i,[G]:{0:Po,4:Fo,8:en,12:Y}},8:{[F]:Y},16:{[F]:`${Xa}2 (${pd}13818-3)`,[Ie]:_i,[G]:{0:Qr,4:jr,8:Jr,12:Y}},24:{[F]:`${Xa}1 (${pd}11172-3)`,[Ie]:ts,[G]:{0:Yr,4:Ot,8:qr,12:Y}},length:M},Xh={0:Ko,1:mi},Kh={0:mi,1:"50/15 ms",2:Y,3:"CCIT J.17"},gd={0:{[k]:2,[F]:Dt},64:{[k]:2,[F]:"joint "+Dt},128:{[k]:2,[F]:"dual channel"},192:{[k]:1,[F]:Pt}},yr=class e extends Oe{static*[Z](t,r,n){let i={},o=yield*xi.getID3v2Header(t,r,n);o&&(yield*t[K](o[M],n),t[We](o[M]));let s=yield*t[K](4,n),a=Pe(s[H](0,4)),d=r[Z](a);if(d)return new e(d);if(s[0]!==255||s[1]<224)return null;let l=Wh[s[1]&24];if(l[F]===Y)return null;let c=s[1]&6;if(Wa[c][F]===Y)return null;let h={...Wa[c],...Wa[c][l[Ie]]};if(i[_t]=l[F],i[Ie]=h[F],i[W]=h[W],i[bt]=Xh[s[1]&1],i[M]=4,i[_e]=yd[s[2]&240][h[gr]],i[_e]===we||(i[G]=l[G][s[2]&12],i[G]===Y)||(i[at]=s[2]&2&&h[at],i[yt]=!!(s[2]&1),i[Re]=Math.floor(125*i[_e]*i[W]/i[G]+i[at]),!i[Re]))return null;let u=s[3]&192;if(i[ve]=gd[u][F],i[k]=gd[u][k],i[xt]=h[xt][s[3]&48],i[qn]=!!(s[3]&8),i[gt]=!!(s[3]&4),i[rn]=Kh[s[3]&3],i[rn]===Y)return null;i[xe]=16;{let{length:f,frameLength:m,samples:g,...p}=i;r[Xe](a,i,p)}return new e(i)}constructor(t){super(t),this[_e]=t[_e],this[rn]=t[rn],this[at]=t[at],this[qn]=t[qn],this[gt]=t[gt],this[yt]=t[yt],this[Ie]=t[Ie],this[xt]=t[xt],this[_t]=t[_t],this[bt]=t[bt]}};var bi=class e extends De{static*[Ke](t,r,n){return yield*super[Ke](yr,e,t,r,n)}constructor(t,r,n){super(t,r,n)}};var vi=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=bi,this.Header=yr,n(this[ee])}get[ee](){return Do}*[dt](){return yield*this[Xt]()}};var $h={0:"MPEG-4",8:"MPEG-2"},Zh={0:"valid",2:we,4:we,6:we},Yh={0:Ko,1:mi},qh={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},jh={0:zo,4:ko,8:id,12:Ot,16:Yr,20:qr,24:jr,28:Qr,32:Jr,36:Fo,40:Po,44:en,48:od,52:Y,56:Y,60:"frequency is written explicitly"},xd={0:{[k]:0,[F]:"Defined in AOT Specific Config"},64:{[k]:1,[F]:Pt},128:{[k]:2,[F]:ie(2,D[0][0])},192:{[k]:3,[F]:ie(3,D[1][3])},256:{[k]:4,[F]:ie(4,D[1][3],D[3][4])},320:{[k]:5,[F]:ie(5,D[1][3],D[3][0])},384:{[k]:6,[F]:ie(6,D[1][3],D[3][0],it)},448:{[k]:8,[F]:ie(8,D[1][3],D[2][0],D[3][0],it)}},xr=class e extends Oe{static*[Z](t,r,n){let i={},o=yield*t[K](7,n),s=Pe([o[0],o[1],o[2],o[3]&252|o[6]&3]),a=r[Z](s);if(a)Object.assign(i,a);else{if(o[0]!==255||o[1]<240||(i[_t]=$h[o[1]&8],i[Ie]=Zh[o[1]&6],i[Ie]===we))return null;let l=o[1]&1;i[bt]=Yh[l],i[M]=l?7:9,i[Oo]=o[2]&192,i[lt]=o[2]&60;let c=o[2]&2;if(i[ti]=qh[i[Oo]],i[G]=jh[i[lt]],i[G]===Y)return null;i[yt]=!!c,i[si]=(o[2]<<8|o[3])&448,i[ve]=xd[i[si]][F],i[k]=xd[i[si]][k],i[gt]=!!(o[3]&32),i[jn]=!!(o[3]&8),i[ai]=!!(o[3]&8),i[li]=!!(o[3]&4),i[xe]=16,i[W]=1024,i[Jn]=o[6]&3;{let{length:h,channelModeBits:u,profileBits:f,sampleRateBits:m,frameLength:g,samples:p,numberAACFrames:x,...S}=i;r[Xe](s,i,S)}}if(i[Re]=(o[3]<<11|o[4]<<3|o[5]>>5)&8191,!i[Re])return null;let d=(o[5]<<6|o[6]>>2)&2047;return i[Xn]=d===2047?"VBR":d,new e(i)}constructor(t){super(t),this[ai]=t[ai],this[li]=t[li],this[Xn]=t[Xn],this[jn]=t[jn],this[gt]=t[gt],this[yt]=t[yt],this[Ie]=t[Ie],this[M]=t[M],this[_t]=t[_t],this[Jn]=t[Jn],this[ti]=t[ti],this[bt]=t[bt]}get audioSpecificConfig(){let t=ue.get(this),r=t[Oo]+64<<5|t[lt]<<5|t[si]>>3,n=new Se(2);return new $t(n[ot]).setUint16(0,r,!1),n}};var Si=class e extends De{static*[Ke](t,r,n){return yield*super[Ke](xr,e,t,r,n)}constructor(t,r,n){super(t,r,n)}};var wi=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=Si,this.Header=xr,n(this[ee])}get[ee](){return"aac"}*[dt](){return yield*this[Xt]()}};var Zt=class e extends De{static _getFrameFooterCrc16(t){return(t[t[M]-2]<<8)+t[t[M]-1]}static[Xo](t){let r=e._getFrameFooterCrc16(t),n=dd(t[H](0,-2));return r===n}constructor(t,r,n){r[fi]=n,r[$n]=e._getFrameFooterCrc16(t),super(r,t,ue.get(r)[W])}};var _d="get from STREAMINFO metadata block",Qh={0:"Fixed",1:"Variable"},bd={0:Y,16:192};for(let e=2;e<16;e++)bd[e<<4]=e<6?576*2**(e-2):2**e;var Jh={0:_d,1:ko,2:nd,3:rd,4:en,5:Jr,6:Qr,7:jr,8:qr,9:Yr,10:Ot,11:zo,15:we},em={0:{[k]:1,[F]:Pt},16:{[k]:2,[F]:ie(2,D[0][0])},32:{[k]:3,[F]:ie(3,D[0][1])},48:{[k]:4,[F]:ie(4,D[1][0],D[3][0])},64:{[k]:5,[F]:ie(5,D[1][1],D[3][0])},80:{[k]:6,[F]:ie(6,D[1][1],it,D[3][0])},96:{[k]:7,[F]:ie(7,D[1][1],it,D[3][4],D[2][0])},112:{[k]:8,[F]:ie(8,D[1][1],it,D[3][0],D[2][0])},128:{[k]:2,[F]:`${Dt} (left, diff)`},144:{[k]:2,[F]:`${Dt} (diff, right)`},160:{[k]:2,[F]:`${Dt} (avg, diff)`},176:Y,192:Y,208:Y,224:Y,240:Y},tm={0:_d,2:8,4:12,6:Y,8:16,10:20,12:24,14:Y},Yt=class e extends Oe{static _decodeUTF8Int(t){if(t[0]>254)return null;if(t[0]<128)return{value:t[0],length:1};let r=1;for(let s=64;s&t[0];s>>=1)r++;let n=r-1,i=0,o=0;for(;n>0;o+=6,n--){if((t[n]&192)!==128)return null;i|=(t[n]&63)<<o}return i|=(t[n]&127>>r)<<o,{value:i,length:r}}static[$e](t,r){let n={[K]:function*(){return t}};return e[Z](n,r,0).next().value}static*[Z](t,r,n){let i=yield*t[K](6,n);if(i[0]!==255||!(i[1]===248||i[1]===249))return null;let o={},s=Pe(i[H](0,4)),a=r[Z](s);if(a)Object.assign(o,a);else{if(o[No]=i[1]&1,o[ni]=Qh[o[No]],o[ii]=i[2]&240,o[lt]=i[2]&15,o[vt]=bd[o[ii]],o[vt]===Y||(o[G]=Jh[o[lt]],o[G]===we)||i[3]&1)return null;let l=em[i[3]&240];if(l===Y||(o[k]=l[k],o[ve]=l[F],o[xe]=tm[i[3]&14],o[xe]===Y))return null}o[M]=5,i=yield*t[K](o[M]+8,n);let d=e._decodeUTF8Int(i[H](4));if(!d||(o[No]?o[di]=d.value:o[Mt]=d.value,o[M]+=d[M],o[ii]===96?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[vt]=i[o[M]-1]+1,o[M]+=1):o[ii]===112&&(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[vt]=(i[o[M]-1]<<8)+i[o[M]]+1,o[M]+=2),o[W]=o[vt],o[lt]===12?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=i[o[M]-1]*1e3,o[M]+=1):o[lt]===13?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=(i[o[M]-1]<<8)+i[o[M]],o[M]+=2):o[lt]===14&&(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=((i[o[M]-1]<<8)+i[o[M]])*10,o[M]+=2),i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[tn]=i[o[M]-1],o[tn]!==cd(i[H](0,o[M]-1))))return null;if(!a){let{blockingStrategyBits:l,frameNumber:c,sampleNumber:h,samples:u,sampleRateBits:f,blockSizeBits:m,crc:g,length:p,...x}=o;r[Xe](s,o,x)}return new e(o)}constructor(t){super(t),this[$n]=null,this[ni]=t[ni],this[vt]=t[vt],this[Mt]=t[Mt],this[di]=t[di],this[fi]=null}};var rm=2,nm=512*1024,_r=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=Zt,this.Header=Yt,n(this[ee])}get[ee](){return"flac"}*_getNextFrameSyncOffset(t){let r=yield*this._codecParser[K](2,0),n=r[M]-2;for(;t<n;){if(r[t]===255){let o=r[t+1];if(o===248||o===249)break;o!==255&&t++}t++}return t}*[dt](){do{let t=yield*Yt[Z](this._codecParser,this._headerCache,0);if(t){let r=ue.get(t)[M]+rm;for(;r<=nm;){if(this._codecParser._flushing||(yield*Yt[Z](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[K](r);if(this._codecParser._flushing||(n=n[H](0,r)),Zt[Xo](n)){let i=new Zt(n,t);return this._headerCache[rt](),this._codecParser[We](r),this._codecParser[Wt](i),i}}r=yield*this._getNextFrameSyncOffset(r+1)}this._codecParser[et](`Unable to sync FLAC frame after searching ${r} bytes.`),this._codecParser[We](r)}else this._codecParser[We](yield*this._getNextFrameSyncOffset(1))}while(!0)}[Kt](t){return t[le]===0?(this._headerCache[rt](),this._streamInfo=t[Q][H](13)):t[le]===1||(t[be]=pe.get(t)[Ge].map(r=>{let n=Yt[$e](r,this._headerCache);if(n)return new Zt(r,n,this._streamInfo);this._codecParser[et]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(r=>!!r)),t}};var br=class e{static*[Z](t,r,n){let i={},o=yield*t[K](28,n);if(o[0]!==79||o[1]!==103||o[2]!==103||o[3]!==83||(i[Da]=o[4],o[5]&248))return null;i[Fe]=!!(o[5]&4),i[Nt]=!!(o[5]&2),i[Bt]=!!(o[5]&1);let a=new $t(Se.from(o[H](0,28))[ot]);i[Je]=fd(a,6),i[ct]=a.getInt32(14,!0),i[le]=a.getInt32(18,!0),i[ur]=a.getInt32(22,!0);let d=o[26];i[M]=d+27,o=yield*t[K](i[M],n),i[Re]=0,i[Gt]=[],i[on]=Se.from(o[H](27,i[M]));for(let l=0,c=0;l<d;l++){let h=i[on][l];i[Re]+=h,c+=h,(h!==255||l===d-1)&&(i[Gt].push(c),c=0)}return new e(i)}constructor(t){ue.set(this,t),this[Je]=t[Je],this[Bt]=t[Bt],this[Nt]=t[Nt],this[Fe]=t[Fe],this[Gt]=t[Gt],this[le]=t[le],this[ur]=t[ur],this[ct]=t[ct]}};var Ai=class e extends pr{static*[Ke](t,r,n){let i=yield*br[Z](t,r,n);if(i){let o=ue.get(i)[Re],s=ue.get(i)[M],a=s+o,d=(yield*t[K](a,0))[H](0,a),l=d[H](s,a);return new e(i,l,d)}else return null}constructor(t,r,n){super(t,r),pe.get(this)[M]=n[M],this[be]=[],this[ka]=n,this[Je]=t[Je],this[Zn]=t[ur],this[st]=0,this[Bt]=t[Bt],this[Nt]=t[Nt],this[Fe]=t[Fe],this[le]=t[le],this[W]=0,this[ct]=t[ct]}};var an=class extends De{constructor(t,r,n){super(r,t,n)}};var vd={0:Hn.slice(0,2),1:Hn},Ze="SILK-only",ge="CELT-only",rs="Hybrid",qt="narrowband",ns="medium-band",jt="wideband",ln="super-wideband",cn="fullband",im={0:{[B]:Ze,[N]:qt,[O]:10},8:{[B]:Ze,[N]:qt,[O]:20},16:{[B]:Ze,[N]:qt,[O]:40},24:{[B]:Ze,[N]:qt,[O]:60},32:{[B]:Ze,[N]:ns,[O]:10},40:{[B]:Ze,[N]:ns,[O]:20},48:{[B]:Ze,[N]:ns,[O]:40},56:{[B]:Ze,[N]:ns,[O]:60},64:{[B]:Ze,[N]:jt,[O]:10},72:{[B]:Ze,[N]:jt,[O]:20},80:{[B]:Ze,[N]:jt,[O]:40},88:{[B]:Ze,[N]:jt,[O]:60},96:{[B]:rs,[N]:ln,[O]:10},104:{[B]:rs,[N]:ln,[O]:20},112:{[B]:rs,[N]:cn,[O]:10},120:{[B]:rs,[N]:cn,[O]:20},128:{[B]:ge,[N]:qt,[O]:2.5},136:{[B]:ge,[N]:qt,[O]:5},144:{[B]:ge,[N]:qt,[O]:10},152:{[B]:ge,[N]:qt,[O]:20},160:{[B]:ge,[N]:jt,[O]:2.5},168:{[B]:ge,[N]:jt,[O]:5},176:{[B]:ge,[N]:jt,[O]:10},184:{[B]:ge,[N]:jt,[O]:20},192:{[B]:ge,[N]:ln,[O]:2.5},200:{[B]:ge,[N]:ln,[O]:5},208:{[B]:ge,[N]:ln,[O]:10},216:{[B]:ge,[N]:ln,[O]:20},224:{[B]:ge,[N]:cn,[O]:2.5},232:{[B]:ge,[N]:cn,[O]:5},240:{[B]:ge,[N]:cn,[O]:10},248:{[B]:ge,[N]:cn,[O]:20}},dn=class e extends Oe{static[$e](t,r,n){let i={};if(i[k]=t[9],i[St]=t[18],i[M]=i[St]!==0?21+i[k]:19,t[M]<i[M])throw new Error("Out of data while inside an Ogg Page");let o=r[0]&3,s=o===3?2:1,a=Pe(t[H](0,i[M]))+Pe(r[H](0,s)),d=n[Z](a);if(d)return new e(d);if(a.substr(0,8)!=="OpusHead"||t[8]!==1)return null;i[Q]=Se.from(t[H](0,i[M]));let l=new $t(i[Q][ot]);if(i[xe]=16,i[cr]=l.getUint16(10,!0),i[ci]=l.getUint32(12,!0),i[G]=Ot,i[ei]=l.getInt16(16,!0),i[St]in vd&&(i[ve]=vd[i[St]][i[k]-1],!i[ve]))return null;i[St]!==0&&(i[ui]=t[19],i[Kn]=t[20],i[oi]=[...t[H](21,i[k]+21)]);let c=im[248&r[0]];switch(i[B]=c[B],i[N]=c[N],i[O]=c[O],o){case 0:i[At]=1;break;case 1:case 2:i[At]=2;break;case 3:i[Qn]=!!(128&r[1]),i[Yn]=!!(64&r[1]),i[At]=63&r[1];break;default:return null}{let{length:h,data:u,channelMappingFamily:f,...m}=i;n[Xe](a,i,m)}return new e(i)}constructor(t){super(t),this[Q]=t[Q],this[N]=t[N],this[St]=t[St],this[oi]=t[oi],this[Kn]=t[Kn],this[At]=t[At],this[O]=t[O],this[Yn]=t[Yn],this[ci]=t[ci],this[Qn]=t[Qn],this[B]=t[B],this[ei]=t[ei],this[cr]=t[cr],this[ui]=t[ui]}};var Mi=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=an,this.Header=dn,n(this[ee]),this._identificationHeader=null,this._preSkipRemaining=null}get[ee](){return"opus"}[Kt](t){return t[le]===0?(this._headerCache[rt](),this._identificationHeader=t[Q]):t[le]===1||(t[be]=pe.get(t)[Ge].map(r=>{let n=dn[$e](this._identificationHeader,r,this._headerCache);if(n){this._preSkipRemaining===null&&(this._preSkipRemaining=n[cr]);let i=n[O]*n[At]/1e3*n[G];return this._preSkipRemaining>0&&(this._preSkipRemaining-=i,i=this._preSkipRemaining<0?-this._preSkipRemaining:0),new an(r,n,i)}this._codecParser[Go]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),t}};var un=class extends De{constructor(t,r,n){super(r,t,n)}};var Ka={};for(let e=0;e<8;e++)Ka[e+6]=2**(6+e);var Ei=class e extends Oe{static[$e](t,r,n,i){if(t[M]<30)throw new Error("Out of data while inside an Ogg Page");let o=Pe(t[H](0,30)),s=r[Z](o);if(s)return new e(s);let a={[M]:30};if(o.substr(0,7)!=="vorbis")return null;a[Q]=Se.from(t[H](0,30));let d=new $t(a[Q][ot]);if(a[Ut]=d.getUint32(7,!0),a[Ut]!==0||(a[k]=t[11],a[ve]=Hn[a[k]-1]||"application defined",a[G]=d.getUint32(12,!0),a[Vn]=d.getInt32(16,!0),a[Wn]=d.getInt32(20,!0),a[Gn]=d.getInt32(24,!0),a[Vt]=Ka[(t[28]&240)>>4],a[Ht]=Ka[t[28]&15],a[Ht]>a[Vt])||t[29]!==1)return null;a[xe]=32,a[nn]=i,a[ri]=n;{let{length:l,data:c,version:h,vorbisSetup:u,vorbisComments:f,...m}=a;r[Xe](o,a,m)}return new e(a)}constructor(t){super(t),this[Vn]=t[Vn],this[Gn]=t[Gn],this[Wn]=t[Wn],this[Ht]=t[Ht],this[Vt]=t[Vt],this[Q]=t[Q],this[ri]=t[ri],this[nn]=t[nn]}};var Li=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=un,n(this[ee]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[ee](){return dr}[Kt](t){t[be]=[];for(let r of pe.get(t)[Ge])if(r[0]===1)this._headerCache[rt](),this._identificationHeader=t[Q],this._setupComplete=!1;else if(r[0]===3)this._vorbisComments=r;else if(r[0]===5)this._vorbisSetup=r,this._mode=this._parseSetupHeader(r),this._setupComplete=!0;else if(this._setupComplete){let n=Ei[$e](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);n?t[be].push(new un(r,n,this._getSamples(r,n))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return t}_getSamples(t,r){let i=this._mode.blockFlags[t[0]>>1&this._mode.mask]?r[Vt]:r[Ht],o=this._prevBlockSize===null?0:(this._prevBlockSize+i)/4;return this._prevBlockSize=i,o}_parseSetupHeader(t){let r=new $o(t),n={count:0,blockFlags:[]};for(;(r.read(1)&1)!==1;);let i;for(;n.count<64&&r.position>0;){pi(r.read(8));let o=0;for(;r.read(8)===0&&o++<3;);if(o===4)i=r.read(7),n.blockFlags.unshift(i&1),r.position+=6,n.count++;else{((pi(i)&126)>>1)+1!==n.count&&this._codecParser[et]("vorbis derived mode count did not match actual mode count");break}}return n.mask=(1<<Math.log2(n.count))-1,n}};var $a=class{constructor(t,r,n){this._codecParser=t,this._headerCache=r,this._onCodec=n,this._continuedPacket=new Se,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[ee](){return this._codec||""}_updateCodec(t,r){this._codec!==t&&(this._headerCache[tt](),this._parser=new r(this._codecParser,this._headerCache,this._onCodec),this._codec=t)}_checkCodecSupport({data:t}){let r=Pe(t[H](0,8));switch(r){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",Mi),!0;case(/^\x7fFLAC/.test(r)&&r):return this._updateCodec("flac",_r),!0;case(/^\x01vorbis/.test(r)&&r):return this._updateCodec(dr,Li),!0;default:return!1}}_checkPageSequenceNumber(t){t[le]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&t[le]>1&&this._codecParser[et]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${t[le]}`),this._pageSequenceNumber=t[le]}_parsePage(t){this._isSupported===null&&(this._pageSequenceNumber=t[le],this._isSupported=this._checkCodecSupport(t)),this._checkPageSequenceNumber(t);let r=pe.get(t),n=ue.get(r[ke]),i=0;if(r[Ge]=n[Gt].map(o=>t[Q][H](i,i+=o)),this._continuedPacket[M]&&(r[Ge][0]=gi(this._continuedPacket,r[Ge][0]),this._continuedPacket=new Se),n[on][n[on][M]-1]===255&&(this._continuedPacket=gi(this._continuedPacket,r[Ge].pop())),this._previousAbsoluteGranulePosition!==null&&(t[W]=Number(t[Je]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=t[Je],this._isSupported){let o=this._parser[Kt](t);return this._codecParser[Wt](o),o}else return t}},Ti=class extends Ae{constructor(t,r,n){super(t,r),this._onCodec=n,this.Frame=Ai,this.Header=br,this._streams=new Map,this._currentSerialNumber=null}get[ee](){let t=this._streams.get(this._currentSerialNumber);return t?t.codec:""}*[dt](){let t=yield*this[Xt](!0);this._currentSerialNumber=t[ct];let r=this._streams.get(this._currentSerialNumber);return r||(r=new $a(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),t[Fe]&&this._streams.delete(this._currentSerialNumber),r._parsePage(t)}};var Za=()=>{},Ii=class{constructor(t,{onCodec:r,onCodecHeader:n,onCodecUpdate:i,enableLogging:o=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=t,this._onCodec=r||Za,this._onCodecHeader=n||Za,this._onCodecUpdate=i,this._enableLogging=o,this._crc32=s?ud:Za,this[tt]()}get[ee](){return this._parser?this._parser[ee]:""}[tt](){this._headerCache=new yi(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let t=this._generator.next();t.value;t=this._generator.next())yield t.value;this._flushing=!1,this[tt]()}*parseChunk(t){for(let r=this._generator.next(t);r.value;r=this._generator.next())yield r.value}parseAll(t){return[...this.parseChunk(t),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new wi(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new vi(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new _r(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new Ti(this,this._headerCache,this._onCodec);else throw new Error(`Unsupported Codec ${mimeType}`);for(this._frameNumber=0,this._currentReadPosition=0,this._totalBytesIn=0,this._totalBytesOut=0,this._totalSamples=0,this._sampleRate=void 0,this._rawData=new Uint8Array(0);;){let t=yield*this._parser[dt]();t&&(yield t)}}*[K](t=0,r=0){let n;for(;this._rawData[M]<=t+r;){if(n=yield,this._flushing)return this._rawData[H](r);n&&(this._totalBytesIn+=n[M],this._rawData=gi(this._rawData,n))}return this._rawData[H](r)}[We](t){this._currentReadPosition+=t,this._rawData=this._rawData[H](t)}[hi](t){this._sampleRate=t[ke][G],t[ke][_e]=t[st]>0?Math.round(t[Q][M]/t[st])*8:0,t[Mt]=this._frameNumber++,t[fr]=this._totalBytesOut,t[mr]=this._totalSamples,t[hr]=this._totalSamples/this._sampleRate*1e3,t[Zn]=this._crc32(t[Q]),this._headerCache[Wo](t[ke][_e],t[hr]),this._totalBytesOut+=t[Q][M],this._totalSamples+=t[W]}[Wt](t){if(t[be]){if(t[Fe]){let r=t[W];t[be].forEach(n=>{let i=n[W];r<i&&(n[W]=r>0?r:0,n[st]=n[W]/n[ke][G]*1e3),r-=i,this[hi](n)})}else t[W]=0,t[be].forEach(r=>{t[W]+=r[W],this[hi](r)});t[st]=t[W]/this._sampleRate*1e3||0,t[mr]=this._totalSamples,t[hr]=this._totalSamples/this._sampleRate*1e3||0,t[fr]=this._totalBytesOut}else this[hi](t)}_log(t,r){if(this._enableLogging){let n=[`${ee}: ${this[ee]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${fr}: ${this._totalBytesOut}`],i=Math.max(...n.map(o=>o[M]));r.push(`--stats--${"-".repeat(i-9)}`,...n,"-".repeat(i)),t("codec-parser",r.reduce((o,s)=>o+`
4
- `+s,""))}}[et](...t){this._log(console.warn,t)}[Go](...t){this._log(console.error,t)}};var Sd=Ii;var is=be;var os=Q;var wd=ke;var Ad=Fe;var Md=nn;var Ed=mr;function Et(e){var t=t;function r(){}t={};function n(R){throw R}var i,o,s,a,d,l,c,h,u,f,m;function g(){var R=m.buffer;i=new Int8Array(R),o=new Int16Array(R),a=new Uint8Array(R),d=new Uint16Array(R),s=new Int32Array(R),l=new Uint32Array(R),c=new Float32Array(R),h=new Float64Array(R),u=new BigInt64Array(R),f=new BigUint64Array(R)}for(var p=R=>{for(var Ue,In,Pr=0,uo=0,fo=R.length,ho=new Uint8Array((fo*3>>2)-(R[fo-2]=="=")-(R[fo-1]=="="));Pr<fo;Pr+=4,uo+=3)Ue=$[R.charCodeAt(Pr+1)],In=$[R.charCodeAt(Pr+2)],ho[uo]=$[R.charCodeAt(Pr)]<<2|Ue>>4,ho[uo+1]=Ue<<4|In>>2,ho[uo+2]=In<<6|$[R.charCodeAt(Pr+3)];return ho},x=()=>n(""),S=()=>{},_={},y=R=>R(),b=()=>performance.now(),A=(R,Ue)=>{if(_[R]&&(clearTimeout(_[R].id),delete _[R]),!Ue)return 0;var In=setTimeout(()=>{delete _[R],y(()=>gc(R,b()))},Ue);return _[R]={id:In,timeout_ms:Ue},0},v=Math.atan,E=Math.cos,L=Math.exp,w=Math.log,T=Math.pow,z=Math.sin,U=R=>{var Ue=a.length;return R>>>=0,!1},C=R=>{throw`exit(${R})`},$=new Uint8Array(123),Te=25;Te>=0;--Te)$[48+Te]=52+Te,$[65+Te]=Te,$[97+Te]=26+Te;$[43]=62,$[47]=63;var ir={e:x,d:S,f:A,b:v,a:E,i:L,h:w,g:T,c:z,k:U,j:C};function co(R){Tn=R.n,dc=R.o,uc=R.p,fc=R.q,hc=R.r,mc=R.s,pc=R.t,gc=R.v}var Tn,dc,uc,fc,hc,mc,pc,gc;function Bu(R){R.m()}Et.wasm||Object.defineProperty(Et,"wasm",{get:()=>String.raw`dynEncode012091253f87dì%nä= 4&¿nÝØä‘ÂLÚªã9ÚØ[äº\ ¼¡³R=}L]ŸÈÿ2 ÿù¶J1jj¡é,zäV|i¸Qk¹‡= 
3
+ `,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(x)}}return g};function te(){let e=Uint8Array,t=Float32Array;te.modules||Object.defineProperties(te,{modules:{value:new WeakMap},setModule:{value(r,n){te.modules.set(r,Promise.resolve(n))}},getModule:{value(r,n){let i=te.modules.get(r);return i||(n?i=WebAssembly.compile(Ra(n)):(n=r.wasm,i=te.inflateDynEncodeString(n).then(o=>WebAssembly.compile(o))),te.modules.set(r,i)),i}},concatFloat32:{value(r,n){let i=new t(n),o=0,s=0;for(;o<r.length;)i.set(r[o],s),s+=r[o++].length;return i}},getDecodedAudio:{value:(r,n,i,o,s)=>({errors:r,channelData:n,samplesDecoded:i,sampleRate:o,bitDepth:s})},getDecodedAudioMultiChannel:{value(r,n,i,o,s,a){let d=[],l,c;for(l=0;l<i;l++){let h=[];for(c=0;c<n.length;)h.push(n[c++][l]||[]);d.push(te.concatFloat32(h,o))}return te.getDecodedAudio(r,d,o,s,a)}},inflateDynEncodeString:{value(r){return r=Ra(r),new Promise(n=>{let i=String.raw`dynEncode012804c7886d(‰›•)((()>+ˆ*§§)§ˆ,§§§§)§ˆ+§§§)§+.-()(*)-+)(ˆ.7*§)i¸¸,3§(i¸¸,3/G+.••—š¡*(,˜ŽŽ(,3‡‡‰˜‡Š‰›+)2å:-œ),§H(P*DI*H(P*@I++hH)H*r,hH(H(P*<J,i)’^*<H,H(P*4’U((I-H(H*i0’J,^*DH+H-H*œšI+H,I*4)33H(H*H)“^*DH(H+H)^*@H+i§H)œi§›™3æ*).§K(iH“I/+§H,iHn,§H+i(H+i(rCJ0I,H*I-+hH,,hH(H-V)(i)œ’J.H.W)(i)’c)(H,i)“I,H-i*’I-4)33i(I.*hH(V)(H+n5(H(i*’I-i(I,i)I.+hH,i*’J+iHn,hi(I-i*I,+hH,H/’H-c)(H,iFn,hi(I,+hH,H0n5-H*V)(J(,hH/H(i)œ’J(H(V)(J(i)’c)(H)H(i)œ’H,c)(3H*i*’I*H,i)’I,4(3(-H(H,’W)(H-’I-H,i*’I,4)3(3(3H,H-’I1H+I,H.i)œH1V)(“J.i(v5(33H.-H(H,’i(c)(H,i*’I,4)333–)-§i*I*+§H*iHn,hiž73H,H(i)8(H+šJ+H)P*(H*’V)(J-“r,§H)P*,H.i)œ’H+H,“i)œ’V)(-H*i*’I*H+i)œI+H-H.’I.H,H-’i)œI,4)333Ã+)-§iø7i(^*(iü7I,*h+hH+iDn,h*hilI+i)I,+hH+,hH+iô7’H,c)(i)H+i´8’W)(œH,’I,H+i*’I+4)-+hH(H)8*J-i(p5.*h*h*hH-i')u,hH(P*(J+,hH(P*0J,H(P*,n50H+H,’H-b((3H(P*0i)’I.4)3H-i¨*n5*H-iÅ*s,hiž73H-i)œJ+V)&+I,H(H+V)æ,8(I.H(H*8*J-i(p51H-i)œJ+i¸7’V)(H(H+iø7’V)(8(’J/H(P*0J+s,hi73H+H,H.’J,’I.H(P*(m5(H.H(P*,s5.+hH,m5*H(P*(J.H+’H.H+H/“’U((b((H(H(P*0i)’J+^*0H,i)“I,4(3(3H(H.^*03H-i¨*o5)33i(73(3(3-H,H+i)žc)(H,i*’I,H+i)’I+4)33i)I-3H-3!2)0§K(i2“J,L(H,H(^*(H,H*^*4H,i(^*0H,i(^*DH,j(_*<H,H)P*(^*,H,H+P*(^*8*h*h+hH,i)8(I3i§I**h*h*h*h*h*h*hH,i*8(6+(),03H,j(_*@i*I-H,P*<J.i,’J(H,P*8J/s50H,H.i+’J0^*<i¦I*H.H,P*4J1’J.U(*H.U((J2›i')o5/H.U()I.H,H(^*<H0H1’U((H.i0œJ.i§›i0ži')™o5/H/H.H2šJ*H(’J.q50H,P*0J/H*’I-H,P*(J0,hH,P*,H-q,hi)I-423+hH*m5+H/H0’H(H1’U((b((H/i)’I/H(i)’I(H*i)“I*4(3(3H,H.^*<H,H-^*04*3iØ1U((5+i(I(i¨7i1^*(i$6iè1^*(i°7iè6^*(i¬7iÈ6^*(+hH(iÈ*n,hiÈ*I(+hH(i¨,n,hi¨,I(+hH(iØ,n,hiØ,I(+hH(iè,o,hH,i-’H(’i0c)(H(i*’I(4)33iè1i1H,i-’iÈ*8)Bi(I(+hH(ido,hH,i-’H(’i-c)(H(i*’I(4)33iÈ6iè6H,i-’iF8)BiØ1i)b((41-H,i-’H(’i/c)(H(i*’I(4)3(3(-H,i-’H(’i1c)(H(i*’I(4)3(3(-H,i-’H(’i0c)(H(i*’I(4)3(3(3H,H/^*0H,H(^*<3i(I*4*3H,H,i¸)’^*TH,H,iø-’^*PH,H,iX’^*LH,H,i(’^*HH,i-8(I(H,i-8(I-i¥I*H,i,8(I.H(iErH-iErš5)H(i©*’I1H-i)’I0i(i;H.i,’J(i(H(i(rCJ(“J*H*i;sCI*i¨1I-H(I/+hH/,hH,i-’H-V)(i)œ’H,i+8(c)(H/i)“I/H-i*’I-H*i)’I*4)-H(i)œi¨1’I/+hH(H*o,hH,i-’H/V)(i)œ’i(c)(H/i*’I/H(i)’I(4)33i¤I*H,iø-’H,i¸)’H,i-’i;8)5+H0H1’I2i(I-+hH-H2p,hH,H,iP’8*J*i(p5-H*i7u,hH,i-’H-i)œ’H*c)(H-i)’I-4*3i(I/i+I.i+I(*h*h*hH*i8“6*(*)3H-m,hi£I*403H-i)œH,’W)-I/i*I(4)3i3I.i/I(3H2H,H(8(H.’J(H-’J.p,hi¢I*4.3H,i-’H-i)œ’I*+hH(,hH*H/c)(H*i*’I*H(i)“I(4)-H.I-4+3(3(33H,W)1m,hiŸI*4,3H,iø-’H,i¸)’H,i-’H18)J(,hi¡I*H(i(p5,H1H,V)ú-H,V)ø-’o5,3H,i(’H,iX’H,i-’H1i)œ’H08)J(,hi I*H(i(p5,H0H,V)šH,V)˜’o5,3H,H,iP’H,iH’8+I*4+3(3(3H,i$6i¬78+I*3H*H3šm5(3i)I-H*i(r5)3H)H,P*0^*(H+H,P*<^*(H*I-3H,i2’L(H-33Á)+(i¨03b+(,(-(.(/(0(1(2(3(5(7(9(;(?(C(G(K(S([(c(k({(‹(›(«(Ë(ë( (*)(iø03O)()()()(*(*(*(*(+(+(+(+(,(,(,(,(-(-(-(-(i¨13M8(9(:(((0(/(1(.(2(-(3(,(4(+(5(*(6()(7(T7œ‰šœ‡Ž‰œš›*S7•œ‰Š”U”—Љ”›S0›‘–U œ`;te.getModule(te,i).then(o=>WebAssembly.instantiate(o,{})).then(({exports:o})=>{let s=new Map(Object.entries(o)),a=s.get("puff"),d=s.get("memory").buffer,l=new e(d),c=new DataView(d),h=s.get("__heap_base"),u=r.length,f=h;h+=4,c.setInt32(f,u,!0);let m=h;h+=u,l.set(r,m);let g=h;h+=4,c.setInt32(g,l.byteLength-h,!0),a(h,g,m,f),n(l.slice(h,h+c.getInt32(g,!0)))})})}}}),Object.defineProperty(this,"wasm",{enumerable:!0,get:()=>this._wasm}),this.getOutputChannels=(r,n,i)=>{let o=[],s=0;for(;s<n;)o.push(r.slice(s*i,s++*i+i));return o},this.allocateTypedArray=(r,n,i=!0)=>{let o=this._wasm.malloc(n.BYTES_PER_ELEMENT*r);return i&&this._pointers.add(o),{ptr:o,len:r,buf:new n(this._wasm.HEAP,o,r)}},this.free=()=>{this._pointers.forEach(r=>{this._wasm.free(r)}),this._pointers.clear()},this.codeToString=r=>{let n=[],i=new Uint8Array(this._wasm.HEAP);for(let o=i[r];o!==0;o=i[++r])n.push(o);return String.fromCharCode.apply(null,n)},this.addError=(r,n,i,o,s,a)=>{r.push({message:n,frameLength:i,frameNumber:o,inputBytes:s,outputSamples:a})},this.instantiate=(r,n)=>(n&&te.setModule(r,n),this._wasm=new r(te).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var ed=Ku(Jc(),1);var Ph=()=>globalThis.Worker||ed.default,Zr=class extends Ph(){constructor(t,r,n,i){te.modules||new te;let o=te.modules.get(n);if(!o){let s="text/javascript",a,d=`'use strict';(${((l,c,h)=>{let u,f,m=new Promise(g=>{f=g});self.onmessage=({data:{id:g,command:p,data:x}})=>{let S=m,_={id:g},y;p==="init"?(Object.defineProperties(l,{WASMAudioDecoderCommon:{value:c},EmscriptenWASM:{value:h},module:{value:x.module},isWebWorker:{value:!0}}),u=new l(x.options),f()):p==="free"?u.free():p==="ready"?S=S.then(()=>u.ready):p==="reset"?S=S.then(()=>u.reset()):(Object.assign(_,u[p](Array.isArray(x)?x.map(b=>new Uint8Array(b)):new Uint8Array(x))),y=_.channelData?_.channelData.map(b=>b.buffer):[]),S.then(()=>self.postMessage(_,y))}}).toString()})(${n}, ${te}, ${i})`;try{a=typeof process.versions.node<"u"}catch{}o=a?`data:${s};base64,${Buffer.from(d).toString("base64")}`:URL.createObjectURL(new Blob([d],{type:s})),te.modules.set(n,o)}super(o,{name:r}),this._id=Number.MIN_SAFE_INTEGER,this._enqueuedOperations=new Map,this.onmessage=({data:s})=>{let{id:a,...d}=s;this._enqueuedOperations.get(a)(d),this._enqueuedOperations.delete(a)},new i(te).getModule().then(s=>{this.postToDecoder("init",{module:s,options:t})})}async postToDecoder(t,r){return new Promise(n=>{this.postMessage({command:t,id:this._id,data:r}),this._enqueuedOperations.set(this._id++,n)})}get ready(){return this.postToDecoder("ready")}async free(){await this.postToDecoder("free").finally(()=>{this.terminate()})}async reset(){await this.postToDecoder("reset")}};var zo=(e,t)=>{Object.defineProperty(e,"name",{value:t})};var re=Symbol,td=", ",P=(()=>{let e="front",t="side",r="rear",n="left",i="center",o="right";return["",e+" ",t+" ",r+" "].map(s=>[[n,o],[n,o,i],[n,i,o],[i,n,o],[i]].flatMap(a=>a.map(d=>s+d).join(td)))})(),it="LFE",Dt="monophonic (mono)",Pt="stereo",Un="surround",ie=(e,...t)=>`${[Dt,Pt,`linear ${Un}`,"quadraphonic",`5.0 ${Un}`,`5.1 ${Un}`,`6.1 ${Un}`,`7.1 ${Un}`][e-1]} (${t.join(td)})`,Hn=[Dt,ie(2,P[0][0]),ie(3,P[0][2]),ie(4,P[1][0],P[3][0]),ie(5,P[1][2],P[3][0]),ie(6,P[1][2],P[3][0],it),ie(7,P[1][2],P[2][0],P[3][4],it),ie(8,P[1][2],P[2][0],P[3][0],it)],rd=192e3,nd=176400,Ro=96e3,ko=88200,id=64e3,Ot=48e3,Yr=44100,qr=32e3,jr=24e3,Qr=22050,Jr=16e3,Fo=12e3,Do=11025,en=8e3,od=7350,Je="absoluteGranulePosition",N="bandwidth",xe="bitDepth",_e="bitrate",Vn=_e+"Maximum",Gn=_e+"Minimum",Wn=_e+"Nominal",ot="buffer",Xn=ot+"Fullness",ee="codec",be=ee+"Frames",Kn="coupledStreamCount",tn="crc",$n=tn+"16",Zn=tn+"32",Q="data",F="description",st="duration",rn="emphasis",Yn="hasOpusPadding",ke="header",Bt="isContinuedPacket",qn="isCopyrighted",Nt="isFirstPage",jn="isHome",Fe="isLastPage",gt="isOriginal",yt="isPrivate",Qn="isVbr",Ie="layer",M="length",B="mode",xt=B+"Extension",Po="mpeg",_t=Po+"Version",Jn="numberAACFrames",ei="outputGain",cr="preSkip",ti="profile",Oo=re(),bt="protection",ka="rawData",Ge="segments",H="subarray",Ut="version",dr="vorbis",ri=dr+"Comments",nn=dr+"Setup",Bo="block",ni=Bo+"ingStrategy",No=re(),vt=Bo+"Size",Ht=Bo+"size0",Vt=Bo+"size1",ii=re(),Uo="channel",St=Uo+"MappingFamily",oi=Uo+"MappingTable",ve=Uo+"Mode",si=re(),k=Uo+"s",sd="copyright",ai=sd+"Id",li=sd+"IdStart",wt="frame",At=wt+"Count",Ce=wt+"Length",Ho="Number",Mt=wt+Ho,at=wt+"Padding",O=wt+"Size",ad="Rate",ci="inputSample"+ad,Fa="page",ur=Fa+"Checksum",on=re(),Gt=Fa+"SegmentTable",le=Fa+"Sequence"+Ho,Da="sample",di=Da+Ho,G=Da+ad,lt=re(),W=Da+"s",Vo="stream",ui=Vo+"Count",fi=Vo+"Info",ct=Vo+"Serial"+Ho,Pa=Vo+"StructureVersion",Oa="total",fr=Oa+"BytesOut",hr=Oa+"Duration",mr=Oa+"Samples",K=re(),We=re(),hi=re(),Wt=re(),et=re(),Go=re(),Ba=re(),Xt=re(),Z=re(),Xe=re(),Ke=re(),dt=re(),Kt=re(),Wo=re(),tt=re(),rt=re(),$e=re(),Xo=re(),Se=Uint8Array,$t=DataView,Y="reserved",we="bad",sn="free",mi="none",Ko="16bit CRC";var Na=(e,t,r)=>{for(let n=0;n<e[M];n++){let i=t(n);for(let o=8;o>0;o--)i=r(i);e[n]=i}return e},Bh=Na(new Se(256),e=>e,e=>e&128?7^e<<1:e<<1),oe=[Na(new Uint16Array(256),e=>e<<8,e=>e<<1^(e&32768?32773:0))],se=[Na(new Uint32Array(256),e=>e,e=>e>>>1^(e&1)*3988292384)];for(let e=0;e<15;e++){oe.push(new Uint16Array(256)),se.push(new Uint32Array(256));for(let t=0;t<=255;t++)oe[e+1][t]=oe[0][oe[e][t]>>>8]^oe[e][t]<<8,se[e+1][t]=se[e][t]>>>8^se[0][se[e][t]&255]}var cd=e=>{let t=0,r=e[M];for(let n=0;n!==r;n++)t=Bh[t^e[n]];return t},dd=e=>{let t=e[M],r=t-16,n=0,i=0;for(;i<=r;)n^=e[i++]<<8|e[i++],n=oe[15][n>>8]^oe[14][n&255]^oe[13][e[i++]]^oe[12][e[i++]]^oe[11][e[i++]]^oe[10][e[i++]]^oe[9][e[i++]]^oe[8][e[i++]]^oe[7][e[i++]]^oe[6][e[i++]]^oe[5][e[i++]]^oe[4][e[i++]]^oe[3][e[i++]]^oe[2][e[i++]]^oe[1][e[i++]]^oe[0][e[i++]];for(;i!==t;)n=(n&255)<<8^oe[0][n>>8^e[i++]];return n},ud=e=>{let t=e[M],r=t-16,n=0,i=0;for(;i<=r;)n=se[15][(e[i++]^n)&255]^se[14][(e[i++]^n>>>8)&255]^se[13][(e[i++]^n>>>16)&255]^se[12][e[i++]^n>>>24]^se[11][e[i++]]^se[10][e[i++]]^se[9][e[i++]]^se[8][e[i++]]^se[7][e[i++]]^se[6][e[i++]]^se[5][e[i++]]^se[4][e[i++]]^se[3][e[i++]]^se[2][e[i++]]^se[1][e[i++]]^se[0][e[i++]];for(;i!==t;)n=se[0][(n^e[i++])&255]^n>>>8;return n^-1},gi=(...e)=>{let t=new Se(e.reduce((r,n)=>r+n[M],0));return e.reduce((r,n)=>(t.set(n,r),r+n[M]),0),t},De=e=>String.fromCharCode(...e),ld=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],pi=e=>ld[e&15]<<4|ld[e>>4],$o=class{constructor(t){this._data=t,this._pos=t[M]*8}set position(t){this._pos=t}get position(){return this._pos}read(t){let r=Math.floor(this._pos/8),n=this._pos%8;return this._pos-=t,(pi(this._data[r-1])<<8)+pi(this._data[r])>>7-n&255}},fd=(e,t)=>{try{return e.getBigInt64(t,!0)}catch{let r=e.getUint8(t+7)&128?-1:1,n=e.getUint32(t,!0),i=e.getUint32(t+4,!0);return r===-1&&(n=~n+1,i=~i+1),i>1048575&&console.warn("This platform does not support BigInt"),r*(n+i*2**32)}};var yi=class{constructor(t,r){this._onCodecHeader=t,this._onCodecUpdate=r,this[tt]()}[rt](){this._isEnabled=!0}[tt](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[Wo](t,r){if(this._onCodecUpdate){this._bitrate!==t&&(this._bitrate=t,this._codecShouldUpdate=!0);let n=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&n&&this._onCodecUpdate({bitrate:t,...n},r),this._codecShouldUpdate=!1}}[Z](t){let r=this._headerCache.get(t);return r&&this._updateCurrentHeader(t),r}[Xe](t,r,n){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...r}),this._codecHeaderSent=!0),this._updateCurrentHeader(t),this._headerCache.set(t,r),this._codecUpdateData.set(r,n))}_updateCurrentHeader(t){this._onCodecUpdate&&t!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=t)}};var ue=new WeakMap,pe=new WeakMap;var Ae=class{constructor(t,r){this._codecParser=t,this._headerCache=r}*[Ba](){let t;do{if(t=yield*this.Frame[Ke](this._codecParser,this._headerCache,0),t)return t;this._codecParser[We](1)}while(!0)}*[Xt](t){let r=yield*this[Ba](),n=pe.get(r)[M];if(t||this._codecParser._flushing||(yield*this.Header[Z](this._codecParser,this._headerCache,n)))return this._headerCache[rt](),this._codecParser[We](n),this._codecParser[Wt](r),r;this._codecParser[et](`Missing ${wt} at ${n} bytes from current position.`,`Dropping current ${wt} and trying again.`),this._headerCache[tt](),this._codecParser[We](1)}};var pr=class{constructor(t,r){pe.set(this,{[ke]:t}),this[Q]=r}};var Pe=class extends pr{static*[Ke](t,r,n,i,o){let s=yield*t[Z](n,i,o);if(s){let a=ue.get(s)[Ce],d=ue.get(s)[W],l=(yield*n[K](a,o))[H](0,a);return new r(s,l,d)}else return null}constructor(t,r,n){super(t,r),this[ke]=t,this[W]=n,this[st]=n/t[G]*1e3,this[Mt]=null,this[fr]=null,this[mr]=null,this[hr]=null,pe.get(this)[M]=r[M]}};var Ua="unsynchronizationFlag",Ha="extendedHeaderFlag",Va="experimentalFlag",Ga="footerPresent",xi=class e{static*getID3v2Header(t,r,n){let o={},s=yield*t[K](3,n);if(s[0]!==73||s[1]!==68||s[2]!==51||(s=yield*t[K](10,n),o[Ut]=`id3v2.${s[3]}.${s[4]}`,s[5]&15)||(o[Ua]=!!(s[5]&128),o[Ha]=!!(s[5]&64),o[Va]=!!(s[5]&32),o[Ga]=!!(s[5]&16),s[6]&128||s[7]&128||s[8]&128||s[9]&128))return null;let a=s[6]<<21|s[7]<<14|s[8]<<7|s[9];return o[M]=10+a,new e(o)}constructor(t){this[Ut]=t[Ut],this[Ua]=t[Ua],this[Ha]=t[Ha],this[Va]=t[Va],this[Ga]=t[Ga],this[M]=t[M]}};var Oe=class{constructor(t){ue.set(this,t),this[xe]=t[xe],this[_e]=null,this[k]=t[k],this[ve]=t[ve],this[G]=t[G]}};var yd={0:[sn,sn,sn,sn,sn],16:[32,32,32,32,8],240:[we,we,we,we,we]},Zo=(e,t,r)=>8*((e+r)%t+t)*(1<<(e+r)/t)-8*t*(t/8|0);for(let e=2;e<15;e++)yd[e<<4]=[e*32,Zo(e,4,0),Zo(e,4,-1),Zo(e,8,4),Zo(e,8,0)];var Nh=0,Uh=1,Hh=2,Vh=3,hd=4,Yo="bands ",qo=" to 31",md={0:Yo+4+qo,16:Yo+8+qo,32:Yo+12+qo,48:Yo+16+qo},gr="bitrateIndex",_i="v2",ts="v1",jo="Intensity stereo ",Qo=", MS stereo ",Jo="on",es="off",Gh={0:jo+es+Qo+es,16:jo+Jo+Qo+es,32:jo+es+Qo+Jo,48:jo+Jo+Qo+Jo},Wa={0:{[F]:Y},2:{[F]:"Layer III",[at]:1,[xt]:Gh,[ts]:{[gr]:Hh,[W]:1152},[_i]:{[gr]:hd,[W]:576}},4:{[F]:"Layer II",[at]:1,[xt]:md,[W]:1152,[ts]:{[gr]:Uh},[_i]:{[gr]:hd}},6:{[F]:"Layer I",[at]:4,[xt]:md,[W]:384,[ts]:{[gr]:Nh},[_i]:{[gr]:Vh}}},Xa="MPEG Version ",pd="ISO/IEC ",Wh={0:{[F]:`${Xa}2.5 (later extension of MPEG 2)`,[Ie]:_i,[G]:{0:Do,4:Fo,8:en,12:Y}},8:{[F]:Y},16:{[F]:`${Xa}2 (${pd}13818-3)`,[Ie]:_i,[G]:{0:Qr,4:jr,8:Jr,12:Y}},24:{[F]:`${Xa}1 (${pd}11172-3)`,[Ie]:ts,[G]:{0:Yr,4:Ot,8:qr,12:Y}},length:M},Xh={0:Ko,1:mi},Kh={0:mi,1:"50/15 ms",2:Y,3:"CCIT J.17"},gd={0:{[k]:2,[F]:Pt},64:{[k]:2,[F]:"joint "+Pt},128:{[k]:2,[F]:"dual channel"},192:{[k]:1,[F]:Dt}},yr=class e extends Oe{static*[Z](t,r,n){let i={},o=yield*xi.getID3v2Header(t,r,n);o&&(yield*t[K](o[M],n),t[We](o[M]));let s=yield*t[K](4,n),a=De(s[H](0,4)),d=r[Z](a);if(d)return new e(d);if(s[0]!==255||s[1]<224)return null;let l=Wh[s[1]&24];if(l[F]===Y)return null;let c=s[1]&6;if(Wa[c][F]===Y)return null;let h={...Wa[c],...Wa[c][l[Ie]]};if(i[_t]=l[F],i[Ie]=h[F],i[W]=h[W],i[bt]=Xh[s[1]&1],i[M]=4,i[_e]=yd[s[2]&240][h[gr]],i[_e]===we||(i[G]=l[G][s[2]&12],i[G]===Y)||(i[at]=s[2]&2&&h[at],i[yt]=!!(s[2]&1),i[Ce]=Math.floor(125*i[_e]*i[W]/i[G]+i[at]),!i[Ce]))return null;let u=s[3]&192;if(i[ve]=gd[u][F],i[k]=gd[u][k],i[xt]=h[xt][s[3]&48],i[qn]=!!(s[3]&8),i[gt]=!!(s[3]&4),i[rn]=Kh[s[3]&3],i[rn]===Y)return null;i[xe]=16;{let{length:f,frameLength:m,samples:g,...p}=i;r[Xe](a,i,p)}return new e(i)}constructor(t){super(t),this[_e]=t[_e],this[rn]=t[rn],this[at]=t[at],this[qn]=t[qn],this[gt]=t[gt],this[yt]=t[yt],this[Ie]=t[Ie],this[xt]=t[xt],this[_t]=t[_t],this[bt]=t[bt]}};var bi=class e extends Pe{static*[Ke](t,r,n){return yield*super[Ke](yr,e,t,r,n)}constructor(t,r,n){super(t,r,n)}};var vi=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=bi,this.Header=yr,n(this[ee])}get[ee](){return Po}*[dt](){return yield*this[Xt]()}};var $h={0:"MPEG-4",8:"MPEG-2"},Zh={0:"valid",2:we,4:we,6:we},Yh={0:Ko,1:mi},qh={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},jh={0:Ro,4:ko,8:id,12:Ot,16:Yr,20:qr,24:jr,28:Qr,32:Jr,36:Fo,40:Do,44:en,48:od,52:Y,56:Y,60:"frequency is written explicitly"},xd={0:{[k]:0,[F]:"Defined in AOT Specific Config"},64:{[k]:1,[F]:Dt},128:{[k]:2,[F]:ie(2,P[0][0])},192:{[k]:3,[F]:ie(3,P[1][3])},256:{[k]:4,[F]:ie(4,P[1][3],P[3][4])},320:{[k]:5,[F]:ie(5,P[1][3],P[3][0])},384:{[k]:6,[F]:ie(6,P[1][3],P[3][0],it)},448:{[k]:8,[F]:ie(8,P[1][3],P[2][0],P[3][0],it)}},xr=class e extends Oe{static*[Z](t,r,n){let i={},o=yield*t[K](7,n),s=De([o[0],o[1],o[2],o[3]&252|o[6]&3]),a=r[Z](s);if(a)Object.assign(i,a);else{if(o[0]!==255||o[1]<240||(i[_t]=$h[o[1]&8],i[Ie]=Zh[o[1]&6],i[Ie]===we))return null;let l=o[1]&1;i[bt]=Yh[l],i[M]=l?7:9,i[Oo]=o[2]&192,i[lt]=o[2]&60;let c=o[2]&2;if(i[ti]=qh[i[Oo]],i[G]=jh[i[lt]],i[G]===Y)return null;i[yt]=!!c,i[si]=(o[2]<<8|o[3])&448,i[ve]=xd[i[si]][F],i[k]=xd[i[si]][k],i[gt]=!!(o[3]&32),i[jn]=!!(o[3]&8),i[ai]=!!(o[3]&8),i[li]=!!(o[3]&4),i[xe]=16,i[W]=1024,i[Jn]=o[6]&3;{let{length:h,channelModeBits:u,profileBits:f,sampleRateBits:m,frameLength:g,samples:p,numberAACFrames:x,...S}=i;r[Xe](s,i,S)}}if(i[Ce]=(o[3]<<11|o[4]<<3|o[5]>>5)&8191,!i[Ce])return null;let d=(o[5]<<6|o[6]>>2)&2047;return i[Xn]=d===2047?"VBR":d,new e(i)}constructor(t){super(t),this[ai]=t[ai],this[li]=t[li],this[Xn]=t[Xn],this[jn]=t[jn],this[gt]=t[gt],this[yt]=t[yt],this[Ie]=t[Ie],this[M]=t[M],this[_t]=t[_t],this[Jn]=t[Jn],this[ti]=t[ti],this[bt]=t[bt]}get audioSpecificConfig(){let t=ue.get(this),r=t[Oo]+64<<5|t[lt]<<5|t[si]>>3,n=new Se(2);return new $t(n[ot]).setUint16(0,r,!1),n}};var Si=class e extends Pe{static*[Ke](t,r,n){return yield*super[Ke](xr,e,t,r,n)}constructor(t,r,n){super(t,r,n)}};var wi=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=Si,this.Header=xr,n(this[ee])}get[ee](){return"aac"}*[dt](){return yield*this[Xt]()}};var Zt=class e extends Pe{static _getFrameFooterCrc16(t){return(t[t[M]-2]<<8)+t[t[M]-1]}static[Xo](t){let r=e._getFrameFooterCrc16(t),n=dd(t[H](0,-2));return r===n}constructor(t,r,n){r[fi]=n,r[$n]=e._getFrameFooterCrc16(t),super(r,t,ue.get(r)[W])}};var _d="get from STREAMINFO metadata block",Qh={0:"Fixed",1:"Variable"},bd={0:Y,16:192};for(let e=2;e<16;e++)bd[e<<4]=e<6?576*2**(e-2):2**e;var Jh={0:_d,1:ko,2:nd,3:rd,4:en,5:Jr,6:Qr,7:jr,8:qr,9:Yr,10:Ot,11:Ro,15:we},em={0:{[k]:1,[F]:Dt},16:{[k]:2,[F]:ie(2,P[0][0])},32:{[k]:3,[F]:ie(3,P[0][1])},48:{[k]:4,[F]:ie(4,P[1][0],P[3][0])},64:{[k]:5,[F]:ie(5,P[1][1],P[3][0])},80:{[k]:6,[F]:ie(6,P[1][1],it,P[3][0])},96:{[k]:7,[F]:ie(7,P[1][1],it,P[3][4],P[2][0])},112:{[k]:8,[F]:ie(8,P[1][1],it,P[3][0],P[2][0])},128:{[k]:2,[F]:`${Pt} (left, diff)`},144:{[k]:2,[F]:`${Pt} (diff, right)`},160:{[k]:2,[F]:`${Pt} (avg, diff)`},176:Y,192:Y,208:Y,224:Y,240:Y},tm={0:_d,2:8,4:12,6:Y,8:16,10:20,12:24,14:Y},Yt=class e extends Oe{static _decodeUTF8Int(t){if(t[0]>254)return null;if(t[0]<128)return{value:t[0],length:1};let r=1;for(let s=64;s&t[0];s>>=1)r++;let n=r-1,i=0,o=0;for(;n>0;o+=6,n--){if((t[n]&192)!==128)return null;i|=(t[n]&63)<<o}return i|=(t[n]&127>>r)<<o,{value:i,length:r}}static[$e](t,r){let n={[K]:function*(){return t}};return e[Z](n,r,0).next().value}static*[Z](t,r,n){let i=yield*t[K](6,n);if(i[0]!==255||!(i[1]===248||i[1]===249))return null;let o={},s=De(i[H](0,4)),a=r[Z](s);if(a)Object.assign(o,a);else{if(o[No]=i[1]&1,o[ni]=Qh[o[No]],o[ii]=i[2]&240,o[lt]=i[2]&15,o[vt]=bd[o[ii]],o[vt]===Y||(o[G]=Jh[o[lt]],o[G]===we)||i[3]&1)return null;let l=em[i[3]&240];if(l===Y||(o[k]=l[k],o[ve]=l[F],o[xe]=tm[i[3]&14],o[xe]===Y))return null}o[M]=5,i=yield*t[K](o[M]+8,n);let d=e._decodeUTF8Int(i[H](4));if(!d||(o[No]?o[di]=d.value:o[Mt]=d.value,o[M]+=d[M],o[ii]===96?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[vt]=i[o[M]-1]+1,o[M]+=1):o[ii]===112&&(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[vt]=(i[o[M]-1]<<8)+i[o[M]]+1,o[M]+=2),o[W]=o[vt],o[lt]===12?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=i[o[M]-1]*1e3,o[M]+=1):o[lt]===13?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=(i[o[M]-1]<<8)+i[o[M]],o[M]+=2):o[lt]===14&&(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=((i[o[M]-1]<<8)+i[o[M]])*10,o[M]+=2),i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[tn]=i[o[M]-1],o[tn]!==cd(i[H](0,o[M]-1))))return null;if(!a){let{blockingStrategyBits:l,frameNumber:c,sampleNumber:h,samples:u,sampleRateBits:f,blockSizeBits:m,crc:g,length:p,...x}=o;r[Xe](s,o,x)}return new e(o)}constructor(t){super(t),this[$n]=null,this[ni]=t[ni],this[vt]=t[vt],this[Mt]=t[Mt],this[di]=t[di],this[fi]=null}};var rm=2,nm=512*1024,_r=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=Zt,this.Header=Yt,n(this[ee])}get[ee](){return"flac"}*_getNextFrameSyncOffset(t){let r=yield*this._codecParser[K](2,0),n=r[M]-2;for(;t<n;){if(r[t]===255){let o=r[t+1];if(o===248||o===249)break;o!==255&&t++}t++}return t}*[dt](){do{let t=yield*Yt[Z](this._codecParser,this._headerCache,0);if(t){let r=ue.get(t)[M]+rm;for(;r<=nm;){if(this._codecParser._flushing||(yield*Yt[Z](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[K](r);if(this._codecParser._flushing||(n=n[H](0,r)),Zt[Xo](n)){let i=new Zt(n,t);return this._headerCache[rt](),this._codecParser[We](r),this._codecParser[Wt](i),i}}r=yield*this._getNextFrameSyncOffset(r+1)}this._codecParser[et](`Unable to sync FLAC frame after searching ${r} bytes.`),this._codecParser[We](r)}else this._codecParser[We](yield*this._getNextFrameSyncOffset(1))}while(!0)}[Kt](t){return t[le]===0?(this._headerCache[rt](),this._streamInfo=t[Q][H](13)):t[le]===1||(t[be]=pe.get(t)[Ge].map(r=>{let n=Yt[$e](r,this._headerCache);if(n)return new Zt(r,n,this._streamInfo);this._codecParser[et]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(r=>!!r)),t}};var br=class e{static*[Z](t,r,n){let i={},o=yield*t[K](28,n);if(o[0]!==79||o[1]!==103||o[2]!==103||o[3]!==83||(i[Pa]=o[4],o[5]&248))return null;i[Fe]=!!(o[5]&4),i[Nt]=!!(o[5]&2),i[Bt]=!!(o[5]&1);let a=new $t(Se.from(o[H](0,28))[ot]);i[Je]=fd(a,6),i[ct]=a.getInt32(14,!0),i[le]=a.getInt32(18,!0),i[ur]=a.getInt32(22,!0);let d=o[26];i[M]=d+27,o=yield*t[K](i[M],n),i[Ce]=0,i[Gt]=[],i[on]=Se.from(o[H](27,i[M]));for(let l=0,c=0;l<d;l++){let h=i[on][l];i[Ce]+=h,c+=h,(h!==255||l===d-1)&&(i[Gt].push(c),c=0)}return new e(i)}constructor(t){ue.set(this,t),this[Je]=t[Je],this[Bt]=t[Bt],this[Nt]=t[Nt],this[Fe]=t[Fe],this[Gt]=t[Gt],this[le]=t[le],this[ur]=t[ur],this[ct]=t[ct]}};var Ai=class e extends pr{static*[Ke](t,r,n){let i=yield*br[Z](t,r,n);if(i){let o=ue.get(i)[Ce],s=ue.get(i)[M],a=s+o,d=(yield*t[K](a,0))[H](0,a),l=d[H](s,a);return new e(i,l,d)}else return null}constructor(t,r,n){super(t,r),pe.get(this)[M]=n[M],this[be]=[],this[ka]=n,this[Je]=t[Je],this[Zn]=t[ur],this[st]=0,this[Bt]=t[Bt],this[Nt]=t[Nt],this[Fe]=t[Fe],this[le]=t[le],this[W]=0,this[ct]=t[ct]}};var an=class extends Pe{constructor(t,r,n){super(r,t,n)}};var vd={0:Hn.slice(0,2),1:Hn},Ze="SILK-only",ge="CELT-only",rs="Hybrid",qt="narrowband",ns="medium-band",jt="wideband",ln="super-wideband",cn="fullband",im={0:{[B]:Ze,[N]:qt,[O]:10},8:{[B]:Ze,[N]:qt,[O]:20},16:{[B]:Ze,[N]:qt,[O]:40},24:{[B]:Ze,[N]:qt,[O]:60},32:{[B]:Ze,[N]:ns,[O]:10},40:{[B]:Ze,[N]:ns,[O]:20},48:{[B]:Ze,[N]:ns,[O]:40},56:{[B]:Ze,[N]:ns,[O]:60},64:{[B]:Ze,[N]:jt,[O]:10},72:{[B]:Ze,[N]:jt,[O]:20},80:{[B]:Ze,[N]:jt,[O]:40},88:{[B]:Ze,[N]:jt,[O]:60},96:{[B]:rs,[N]:ln,[O]:10},104:{[B]:rs,[N]:ln,[O]:20},112:{[B]:rs,[N]:cn,[O]:10},120:{[B]:rs,[N]:cn,[O]:20},128:{[B]:ge,[N]:qt,[O]:2.5},136:{[B]:ge,[N]:qt,[O]:5},144:{[B]:ge,[N]:qt,[O]:10},152:{[B]:ge,[N]:qt,[O]:20},160:{[B]:ge,[N]:jt,[O]:2.5},168:{[B]:ge,[N]:jt,[O]:5},176:{[B]:ge,[N]:jt,[O]:10},184:{[B]:ge,[N]:jt,[O]:20},192:{[B]:ge,[N]:ln,[O]:2.5},200:{[B]:ge,[N]:ln,[O]:5},208:{[B]:ge,[N]:ln,[O]:10},216:{[B]:ge,[N]:ln,[O]:20},224:{[B]:ge,[N]:cn,[O]:2.5},232:{[B]:ge,[N]:cn,[O]:5},240:{[B]:ge,[N]:cn,[O]:10},248:{[B]:ge,[N]:cn,[O]:20}},dn=class e extends Oe{static[$e](t,r,n){let i={};if(i[k]=t[9],i[St]=t[18],i[M]=i[St]!==0?21+i[k]:19,t[M]<i[M])throw new Error("Out of data while inside an Ogg Page");let o=r[0]&3,s=o===3?2:1,a=De(t[H](0,i[M]))+De(r[H](0,s)),d=n[Z](a);if(d)return new e(d);if(a.substr(0,8)!=="OpusHead"||t[8]!==1)return null;i[Q]=Se.from(t[H](0,i[M]));let l=new $t(i[Q][ot]);if(i[xe]=16,i[cr]=l.getUint16(10,!0),i[ci]=l.getUint32(12,!0),i[G]=Ot,i[ei]=l.getInt16(16,!0),i[St]in vd&&(i[ve]=vd[i[St]][i[k]-1],!i[ve]))return null;i[St]!==0&&(i[ui]=t[19],i[Kn]=t[20],i[oi]=[...t[H](21,i[k]+21)]);let c=im[248&r[0]];switch(i[B]=c[B],i[N]=c[N],i[O]=c[O],o){case 0:i[At]=1;break;case 1:case 2:i[At]=2;break;case 3:i[Qn]=!!(128&r[1]),i[Yn]=!!(64&r[1]),i[At]=63&r[1];break;default:return null}{let{length:h,data:u,channelMappingFamily:f,...m}=i;n[Xe](a,i,m)}return new e(i)}constructor(t){super(t),this[Q]=t[Q],this[N]=t[N],this[St]=t[St],this[oi]=t[oi],this[Kn]=t[Kn],this[At]=t[At],this[O]=t[O],this[Yn]=t[Yn],this[ci]=t[ci],this[Qn]=t[Qn],this[B]=t[B],this[ei]=t[ei],this[cr]=t[cr],this[ui]=t[ui]}};var Mi=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=an,this.Header=dn,n(this[ee]),this._identificationHeader=null,this._preSkipRemaining=null}get[ee](){return"opus"}[Kt](t){return t[le]===0?(this._headerCache[rt](),this._identificationHeader=t[Q]):t[le]===1||(t[be]=pe.get(t)[Ge].map(r=>{let n=dn[$e](this._identificationHeader,r,this._headerCache);if(n){this._preSkipRemaining===null&&(this._preSkipRemaining=n[cr]);let i=n[O]*n[At]/1e3*n[G];return this._preSkipRemaining>0&&(this._preSkipRemaining-=i,i=this._preSkipRemaining<0?-this._preSkipRemaining:0),new an(r,n,i)}this._codecParser[Go]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),t}};var un=class extends Pe{constructor(t,r,n){super(r,t,n)}};var Ka={};for(let e=0;e<8;e++)Ka[e+6]=2**(6+e);var Ei=class e extends Oe{static[$e](t,r,n,i){if(t[M]<30)throw new Error("Out of data while inside an Ogg Page");let o=De(t[H](0,30)),s=r[Z](o);if(s)return new e(s);let a={[M]:30};if(o.substr(0,7)!=="vorbis")return null;a[Q]=Se.from(t[H](0,30));let d=new $t(a[Q][ot]);if(a[Ut]=d.getUint32(7,!0),a[Ut]!==0||(a[k]=t[11],a[ve]=Hn[a[k]-1]||"application defined",a[G]=d.getUint32(12,!0),a[Vn]=d.getInt32(16,!0),a[Wn]=d.getInt32(20,!0),a[Gn]=d.getInt32(24,!0),a[Vt]=Ka[(t[28]&240)>>4],a[Ht]=Ka[t[28]&15],a[Ht]>a[Vt])||t[29]!==1)return null;a[xe]=32,a[nn]=i,a[ri]=n;{let{length:l,data:c,version:h,vorbisSetup:u,vorbisComments:f,...m}=a;r[Xe](o,a,m)}return new e(a)}constructor(t){super(t),this[Vn]=t[Vn],this[Gn]=t[Gn],this[Wn]=t[Wn],this[Ht]=t[Ht],this[Vt]=t[Vt],this[Q]=t[Q],this[ri]=t[ri],this[nn]=t[nn]}};var Li=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=un,n(this[ee]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[ee](){return dr}[Kt](t){t[be]=[];for(let r of pe.get(t)[Ge])if(r[0]===1)this._headerCache[rt](),this._identificationHeader=t[Q],this._setupComplete=!1;else if(r[0]===3)this._vorbisComments=r;else if(r[0]===5)this._vorbisSetup=r,this._mode=this._parseSetupHeader(r),this._setupComplete=!0;else if(this._setupComplete){let n=Ei[$e](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);n?t[be].push(new un(r,n,this._getSamples(r,n))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return t}_getSamples(t,r){let i=this._mode.blockFlags[t[0]>>1&this._mode.mask]?r[Vt]:r[Ht],o=this._prevBlockSize===null?0:(this._prevBlockSize+i)/4;return this._prevBlockSize=i,o}_parseSetupHeader(t){let r=new $o(t),n={count:0,blockFlags:[]};for(;(r.read(1)&1)!==1;);let i;for(;n.count<64&&r.position>0;){pi(r.read(8));let o=0;for(;r.read(8)===0&&o++<3;);if(o===4)i=r.read(7),n.blockFlags.unshift(i&1),r.position+=6,n.count++;else{((pi(i)&126)>>1)+1!==n.count&&this._codecParser[et]("vorbis derived mode count did not match actual mode count");break}}return n.mask=(1<<Math.log2(n.count))-1,n}};var $a=class{constructor(t,r,n){this._codecParser=t,this._headerCache=r,this._onCodec=n,this._continuedPacket=new Se,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[ee](){return this._codec||""}_updateCodec(t,r){this._codec!==t&&(this._headerCache[tt](),this._parser=new r(this._codecParser,this._headerCache,this._onCodec),this._codec=t)}_checkCodecSupport({data:t}){let r=De(t[H](0,8));switch(r){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",Mi),!0;case(/^\x7fFLAC/.test(r)&&r):return this._updateCodec("flac",_r),!0;case(/^\x01vorbis/.test(r)&&r):return this._updateCodec(dr,Li),!0;default:return!1}}_checkPageSequenceNumber(t){t[le]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&t[le]>1&&this._codecParser[et]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${t[le]}`),this._pageSequenceNumber=t[le]}_parsePage(t){this._isSupported===null&&(this._pageSequenceNumber=t[le],this._isSupported=this._checkCodecSupport(t)),this._checkPageSequenceNumber(t);let r=pe.get(t),n=ue.get(r[ke]),i=0;if(r[Ge]=n[Gt].map(o=>t[Q][H](i,i+=o)),this._continuedPacket[M]&&(r[Ge][0]=gi(this._continuedPacket,r[Ge][0]),this._continuedPacket=new Se),n[on][n[on][M]-1]===255&&(this._continuedPacket=gi(this._continuedPacket,r[Ge].pop())),this._previousAbsoluteGranulePosition!==null&&(t[W]=Number(t[Je]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=t[Je],this._isSupported){let o=this._parser[Kt](t);return this._codecParser[Wt](o),o}else return t}},Ti=class extends Ae{constructor(t,r,n){super(t,r),this._onCodec=n,this.Frame=Ai,this.Header=br,this._streams=new Map,this._currentSerialNumber=null}get[ee](){let t=this._streams.get(this._currentSerialNumber);return t?t.codec:""}*[dt](){let t=yield*this[Xt](!0);this._currentSerialNumber=t[ct];let r=this._streams.get(this._currentSerialNumber);return r||(r=new $a(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),t[Fe]&&this._streams.delete(this._currentSerialNumber),r._parsePage(t)}};var Za=()=>{},Ii=class{constructor(t,{onCodec:r,onCodecHeader:n,onCodecUpdate:i,enableLogging:o=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=t,this._onCodec=r||Za,this._onCodecHeader=n||Za,this._onCodecUpdate=i,this._enableLogging=o,this._crc32=s?ud:Za,this[tt]()}get[ee](){return this._parser?this._parser[ee]:""}[tt](){this._headerCache=new yi(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let t=this._generator.next();t.value;t=this._generator.next())yield t.value;this._flushing=!1,this[tt]()}*parseChunk(t){for(let r=this._generator.next(t);r.value;r=this._generator.next())yield r.value}parseAll(t){return[...this.parseChunk(t),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new wi(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new vi(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new _r(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new Ti(this,this._headerCache,this._onCodec);else throw new Error(`Unsupported Codec ${mimeType}`);for(this._frameNumber=0,this._currentReadPosition=0,this._totalBytesIn=0,this._totalBytesOut=0,this._totalSamples=0,this._sampleRate=void 0,this._rawData=new Uint8Array(0);;){let t=yield*this._parser[dt]();t&&(yield t)}}*[K](t=0,r=0){let n;for(;this._rawData[M]<=t+r;){if(n=yield,this._flushing)return this._rawData[H](r);n&&(this._totalBytesIn+=n[M],this._rawData=gi(this._rawData,n))}return this._rawData[H](r)}[We](t){this._currentReadPosition+=t,this._rawData=this._rawData[H](t)}[hi](t){this._sampleRate=t[ke][G],t[ke][_e]=t[st]>0?Math.round(t[Q][M]/t[st])*8:0,t[Mt]=this._frameNumber++,t[fr]=this._totalBytesOut,t[mr]=this._totalSamples,t[hr]=this._totalSamples/this._sampleRate*1e3,t[Zn]=this._crc32(t[Q]),this._headerCache[Wo](t[ke][_e],t[hr]),this._totalBytesOut+=t[Q][M],this._totalSamples+=t[W]}[Wt](t){if(t[be]){if(t[Fe]){let r=t[W];t[be].forEach(n=>{let i=n[W];r<i&&(n[W]=r>0?r:0,n[st]=n[W]/n[ke][G]*1e3),r-=i,this[hi](n)})}else t[W]=0,t[be].forEach(r=>{t[W]+=r[W],this[hi](r)});t[st]=t[W]/this._sampleRate*1e3||0,t[mr]=this._totalSamples,t[hr]=this._totalSamples/this._sampleRate*1e3||0,t[fr]=this._totalBytesOut}else this[hi](t)}_log(t,r){if(this._enableLogging){let n=[`${ee}: ${this[ee]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${fr}: ${this._totalBytesOut}`],i=Math.max(...n.map(o=>o[M]));r.push(`--stats--${"-".repeat(i-9)}`,...n,"-".repeat(i)),t("codec-parser",r.reduce((o,s)=>o+`
4
+ `+s,""))}}[et](...t){this._log(console.warn,t)}[Go](...t){this._log(console.error,t)}};var Sd=Ii;var is=be;var os=Q;var wd=ke;var Ad=Fe;var Md=nn;var Ed=mr;function Et(e){var t=t;function r(){}t={};function n(C){throw C}var i,o,s,a,d,l,c,h,u,f,m;function g(){var C=m.buffer;i=new Int8Array(C),o=new Int16Array(C),a=new Uint8Array(C),d=new Uint16Array(C),s=new Int32Array(C),l=new Uint32Array(C),c=new Float32Array(C),h=new Float64Array(C),u=new BigInt64Array(C),f=new BigUint64Array(C)}for(var p=C=>{for(var Ue,In,Dr=0,uo=0,fo=C.length,ho=new Uint8Array((fo*3>>2)-(C[fo-2]=="=")-(C[fo-1]=="="));Dr<fo;Dr+=4,uo+=3)Ue=$[C.charCodeAt(Dr+1)],In=$[C.charCodeAt(Dr+2)],ho[uo]=$[C.charCodeAt(Dr)]<<2|Ue>>4,ho[uo+1]=Ue<<4|In>>2,ho[uo+2]=In<<6|$[C.charCodeAt(Dr+3)];return ho},x=()=>n(""),S=()=>{},_={},y=C=>C(),b=()=>performance.now(),A=(C,Ue)=>{if(_[C]&&(clearTimeout(_[C].id),delete _[C]),!Ue)return 0;var In=setTimeout(()=>{delete _[C],y(()=>gc(C,b()))},Ue);return _[C]={id:In,timeout_ms:Ue},0},v=Math.atan,E=Math.cos,L=Math.exp,w=Math.log,T=Math.pow,R=Math.sin,U=C=>{var Ue=a.length;return C>>>=0,!1},z=C=>{throw`exit(${C})`},$=new Uint8Array(123),Te=25;Te>=0;--Te)$[48+Te]=52+Te,$[65+Te]=Te,$[97+Te]=26+Te;$[43]=62,$[47]=63;var ir={e:x,d:S,f:A,b:v,a:E,i:L,h:w,g:T,c:R,k:U,j:z};function co(C){Tn=C.n,dc=C.o,uc=C.p,fc=C.q,hc=C.r,mc=C.s,pc=C.t,gc=C.v}var Tn,dc,uc,fc,hc,mc,pc,gc;function Bu(C){C.m()}Et.wasm||Object.defineProperty(Et,"wasm",{get:()=>String.raw`dynEncode012091253f87dì%nä= 4&¿nÝØä‘ÂLÚªã9ÚØ[äº\ ¼¡³R=}L]ŸÈÿ2 ÿù¶J1jj¡é,zäV|i¸Qk¹‡= 
5
5
  ¨¨Ÿ%‰€ýv²†±»ŸoúâLa:ê±ÊäÌÓ.÷؇ý×>àW>z¯°8¯ñ€\Ñós 9ˆ\§ôÊ@Ü (tÂø4° ¢7fqÓg²Jè6x[zç®&4=} p.(°tÍޖ™ã¾>÷CõË"*k?¿~ 7‚~H2ÛÜâ.ÏQä;Œ6{ÜãFÑá'DœD¤±°HQ>MínÎϕÎöʵ’Ñӓ…™Þ“‰Ž‘š†Š‚œÌP¼P¨Þˆ*X²E=M¦qíxMà ±=M̚ë4/<šgNO‰™/¢ ¢>ˆa~Ï®”ììììì0”ìœa笡çëOÓÇM Q9tùµyuéµµÞϒ/Ÿ±Óõò}E{òÓJ¹Û|· ôfÒ c’¬”Wêaûÿlʽp¹|)‘ÖEL–†¦ }‰ypÕSϹI†]¢ˆºãæ°ÿo¶7ÛRqš¾ÔÅEߨ‘]æˉwÚ{óç‰Vwó1¾”E­Øpˆàe"Æùû–¡Áª ‡ Ààð´Lõ›€ÎxEÓ¢N¦‘…9Ÿëùši&€ Ò§Ø!ÇFçS=MbäO?ß·™縪‡7ùa}5ðšûÕtsUŒþ£Kïg‡ˆN™¾)ø§\V0uSIö:ÌU4ж¯´Õn9ÔƒèE£ZƼ{hµmى¾6ÆžÑ+xñ´«„þ¸=M‚ߤ·å®«ïÆGFÝì|H?äE"þ!9«Æïpæ'][¯ù·£W÷O§&#aŸ‡x$qf=}ø ô bϗŸ×W÷LôožÝWQÕӎ)u †÷½èV|¥Gà¨Ö¸˜@Œê| ÇK5ò €A·Â9’CS2š¸‹¼¿,ä›Ý ÑÝy™!ÑR„%ÆÝÎ0Âv§ qTcó±hØÉã‰=}Z=}Ælü­ën¯ð(-°ÜwVχï.th¥í­‡S~SÏ»Z”ZÔZ
6
6
  3–BÌÛ¬•<éæO)ÎyÚ¯O*®uìÛ$öI¥Ý9ôø³\¤ò³Ù¹ÇP¸J׎y@ÔyOÇm—’ô½üœš¾|S?2àú¤F?½ûoo3ôž;<àáûܘ8‚ì²7ïë¨RäY¹|ÓºÌF,ƒÐ™-¸*\P!FJÒ8= o6HwLrúº”¶Ð۞\Ù¬o¢–9Iq„Ý.ôf¶Îȏ{Ī×N|Mfs…•¤ „ÉݖàŸâ§‘*+ã§­’ô¯î¬7ç×§ä)€Š!Z¨ƒÉž,Äp~ý·wsSGó—äs„E€\ýï鞧Ö:Ò'“Cç(_X$\¦½eҒ8$’X˜F|e‚•œíٙә‚†¡¤Û<ØÞÛ¸9‰¿ðÃÎ#b~× ‚4éîÿÏq
7
7
  ˜ód‡|0•wU‰—&®è·vh6¨—{Ú珁Ú18ә(ÓY‚\ƒ0¦= çˆèíß)Ø=} ˜[xü-v˜?N(Kk‘gš0}âډ´ð“†¬”œÕQNÍ¢usѳ=}. ëg…û= Í M—Bp'²¨ œx’4è@9t“§eݵ¾âð½ z?†‹Z¹FH'‰Ì¯¿<ŒK,üµ<{˜ ¶JãývåàÆeù0Ð"F¥ÃÒÞŽþԛÉvC›zl}„ðN’£ Í^ƒP%²¸FX»WÎêô¶…ŠäÉJ^gƒ×SÃã.žÄt*'ªG‘«ÒB<ÜӅ¿ºp­\àuV¯£›Åݑ½á–Þ ùߞ=}ÎÚ^‹Ÿÿí>¥!¨ â=M·? */¤"å)â·ÿîÿî*(%*›2[½"üríÔ4š’l½»a}¯CwpCÓèìGc-ã6®=M32†k?Êg­…–!So-™x›>³G+ã@ò,™ Áïƒá„åN0þŠÙ‚è.~È÷¡vTr¶‰­‚Æ[üB±º»ávëw¹{pÜºû"Aæ’±9Æ^¹³òïRIAy5GÂwÉfœ4@Tù|qý7†ðªwBL|ÔqŽ‘v!ª°|]KiÐJVQ5‰¸åõ§‡‡åŒ"H¼0e¬<óBîÚS€ÏUìHPÙA+çÉ'se†ÌNf°@ÈM,ð½egÖ¬x©“„‹û½2~«ŠÒ1;ֈ«…¯°4&90èE»Ó׺ç‚ʧJ<Æ¿&~Nu¼ãÙµ¢.UÇä(qQô^ö–·“%!É
@@ -138,7 +138,7 @@ KÙ:KµºKí{K]ûK£[KÚKóšKÓ½R׿ÿ'P^j9TîçmóœþL¿_o©×hÙtÙ
138
138
  ÁiŸ;ª•äÀž‡%Ёn= =M+W= ÓÖc[aS
139
139
  FÁð]Nô‡Ý'= “qr(¶ù¤nŒü«òÿ¿d&ÿ ÈõT4Þ=}z|ö ¿OW×SMtdH.τãRX&§o3ؘÜXÍ^œÊM–í£W´iâ]NüOå£S£Å·ƒç÷­˜Ý§½GÑU y¹¦ß§/6P0(Cúýb"þ¥°VٌÄᣈ’ÓÙ@¾YýòDŽŒ{òÃv?’EP©”=MBé­\ĽYäýRò øfâëEEf¼D+gC×úDZGÅÿ±Ç?TzÙ¡±†Ï€ÁÕ¯¦ð‰vZ’mT}Œ3x˘z×cºrÑM=M„ c-ɩԈ™7½wæc§Î»cû¾yf‡ÙWòŒÆÝÔc¥³ôØfƒ«Äñ·9‰ø%­g:y”^+{U]¤þ‚…[&fӁÏY낫‡Gªõ‡¹¦ÖŒðþ¬m„oÛø‘?/ÛS’.[S›9ÛùœC›…/û2”²Y£ÎÑ%/sy¢×ÌùJ­W6Oí\g0^JùêßÏ0í[Ü“'ÏÔ>žÀ-¿[ÔW?Y]±ž ØÙÃî<~ÎëR~Ìf¾Z—/×¼_á¾Þê+îoÐñ{Þ\e3K%©¹§íB¹§(c=}ËÈ·SzÔnf§èx}o\9öf|%Ýå¥~©‚Iǀ ü€ñY8}FfŸú@Rú1éþ3‚÷˂‹ótQøvœû|³Îaá,Óé>BG6Òê}—ÄJ|¶=}°Žˆöf6žõk¶ÌºHgN’j‡Ò{柾M;9·é—§WèO±›Ä3қËÒyt™ ;ù´ˆà©aš|—Ó^!ÝøûšÄ
140
140
  (VV¸ ÇÙcÏ>yoçz ÃvòG{3Þ£½šŠcמôŒ íŚé;°OÛ‰GØ<wÜW> rU]Žq­{û'ùÝír{*øï?t-ígùWÿ…&§] m}×ût¥‚Ë~ß&>&Õv!b#ÅÌ‚q¢µ|jŽÍüùÉ^Æ&™ôžþŸ~sIµ"“]d)uâ´‘ºvk Å\<͉ÿ­öꍽƒÂ
141
- ïBçϧmÙIólÜoëVbƒ¦¯éWÇû3`});var Nu={a:ir};this.setModule=R=>{e.setModule(Et,R)},this.getModule=()=>e.getModule(Et),this.instantiate=()=>(this.getModule().then(R=>WebAssembly.instantiate(R,Nu)).then(R=>{let Ue=R.exports;co(Ue),m=Ue.l,g(),Bu(Ue),r()}),this.ready=new Promise(R=>{r=R}).then(()=>{this.HEAP=m.buffer,this.malloc=dc,this.free=pc,this.create_decoder=Tn,this.send_setup=uc,this.init_dsp=fc,this.decode_packets=hc,this.destroy_decoder=mc}),this)}function vr(){return this._init=()=>new this._WASMAudioDecoderCommon().instantiate(this._EmscriptenWASM,this._module).then(e=>{this._common=e,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._firstPage=!0,this._inputLen=this._common.allocateTypedArray(1,Uint32Array),this._outputBufferPtr=this._common.allocateTypedArray(1,Uint32Array),this._channels=this._common.allocateTypedArray(1,Uint32Array),this._sampleRate=this._common.allocateTypedArray(1,Uint32Array),this._samplesDecoded=this._common.allocateTypedArray(1,Uint32Array);let t=256;this._errors=this._common.allocateTypedArray(t,Uint32Array),this._errorsLength=this._common.allocateTypedArray(1,Int32Array),this._frameNumber=0,this._inputBytes=0,this._outputSamples=0,this._decoder=this._common.wasm.create_decoder(this._input.ptr,this._inputLen.ptr,this._outputBufferPtr.ptr,this._channels.ptr,this._sampleRate.ptr,this._samplesDecoded.ptr,this._errors.ptr,this._errorsLength.ptr,t)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.wasm.destroy_decoder(this._decoder),this._common.free()},this.sendSetupHeader=e=>{this._input.buf.set(e),this._inputLen.buf[0]=e.length,this._common.wasm.send_setup(this._decoder,this._firstPage),this._firstPage=!1},this.initDsp=()=>{this._common.wasm.init_dsp(this._decoder)},this.decodePackets=e=>{let t=[],r=0,n=[];for(let i=0;i<e.length;i++){let o=e[i];this._input.buf.set(o),this._inputLen.buf[0]=o.length,this._common.wasm.decode_packets(this._decoder);let s=this._samplesDecoded.buf[0],a=[],d=new Uint32Array(this._common.wasm.HEAP,this._outputBufferPtr.buf[0],this._channels.buf[0]);for(let l=0;l<this._channels.buf[0];l++){let c=new Float32Array(s);s&&c.set(new Float32Array(this._common.wasm.HEAP,d[l],s)),a.push(c)}t.push(a),r+=s,this._frameNumber++,this._inputBytes+=o.length,this._outputSamples+=s;for(let l=0;l<this._errorsLength.buf;l+=2){let c=this._common.codeToString(this._errors.buf[l]),h=this._common.codeToString(this._errors.buf[l+1]);n.push({message:c+" vorbis_synthesis"+h,frameLength:o.length,frameNumber:this._frameNumber,inputBytes:this._inputBytes,outputSamples:this._outputSamples})}this._errorsLength.buf[0]=0}return this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(n,t,this._channels.buf[0],r,this._sampleRate.buf[0],16)},this._isWebWorker=vr.isWebWorker,this._WASMAudioDecoderCommon=vr.WASMAudioDecoderCommon||te,this._EmscriptenWASM=vr.EmscriptenWASM||Et,this._module=vr.module,this._inputSize=128*1024,this._ready=this._init(),this}var ss=Symbol(),Lt=class{constructor(){this._onCodec=t=>{if(t!=="vorbis")throw new Error("@wasm-audio-decoders/ogg-vorbis does not support this codec "+t)},new te,this._init(),this._ready=this[ss](vr)}_init(){this._vorbisSetupInProgress=!0,this._totalSamplesDecoded=0,this._codecParser=new Sd("audio/ogg",{onCodec:this._onCodec,enableFrameCRC32:!1})}async[ss](t){if(this._decoder){let r=this._decoder;await r.ready.then(()=>r.free())}return this._decoder=new t,this._decoder.ready}get ready(){return this._ready}async reset(){return this._init(),this._decoder.reset()}free(){this._decoder.free()}async decodeOggPages(t){let r=[];for(let o=0;o<t.length;o++){let s=t[o];if(this._vorbisSetupInProgress&&(s[os][0]===1&&this._decoder.sendSetupHeader(s[os]),s[is].length)){let a=s[is][0][wd];this._decoder.sendSetupHeader(a[Md]),this._decoder.initDsp(),this._vorbisSetupInProgress=!1}r.push(...s[is].map(a=>a[os]))}let n=await this._decoder.decodePackets(r);this._totalSamplesDecoded+=n.samplesDecoded;let i=t[t.length-1];if(i&&i[Ad]){let o=this._totalSamplesDecoded-i[Ed];if(o>0){for(let s=0;s<n.channelData.length;s++)n.channelData[s]=n.channelData[s].subarray(0,n.samplesDecoded-o);n.samplesDecoded-=o,this._totalSamplesDecoded-=o}}return n}async decode(t){return this.decodeOggPages([...this._codecParser.parseChunk(t)])}async flush(){let t=await this.decodeOggPages([...this._codecParser.flush()]);return await this.reset(),t}async decodeFile(t){let r=await this.decodeOggPages([...this._codecParser.parseAll(t)]);return await this.reset(),r}};var Ya=class extends Zr{constructor(t){super(t,"ogg-vorbis-decoder",vr,Et)}async sendSetupHeader(t){return this.postToDecoder("sendSetupHeader",t)}async initDsp(){return this.postToDecoder("initDsp")}async decodePackets(t){return this.postToDecoder("decodePackets",t)}},Ri=class extends Lt{constructor(){super(),this._ready=super[ss](Ya)}async free(){await this._decoder.free()}terminate(){this._decoder.terminate()}};Co(Lt,"OggVorbisDecoder");Co(Ri,"OggVorbisDecoderWebWorker");var qa=class extends Error{constructor(t){super(t),this.name="OggDecodeError"}};async function as(e,t=new Lt){await t.ready;let r=await t.decode(new Uint8Array(e)),n=r.errors;if(n&&n.length>0)throw new qa(n.map(i=>i.message).join("; "));return{sampleRate:r.sampleRate,channels:r.channelData.length,bitDepth:r.bitDepth,channelData:r.channelData}}var Ci=class extends Error{constructor(t){super(t),this.name="AudioRegistryError"}},fn=class{constructor(t,r={}){this.vfs=t;this.refCounts=new Map;this.cache=new kt(r.cacheSize??64)}get size(){return this.cache.size}async load(t){let r=t.toLowerCase(),n=this.cache.get(r);if(n)return this.refCounts.set(r,(this.refCounts.get(r)??0)+1),n;let o=(await this.vfs.readFile(t)).slice().buffer,s=await this.decodeByExtension(t,o);return this.cache.set(r,s),this.refCounts.set(r,1),s}release(t){let r=t.toLowerCase(),n=this.refCounts.get(r)??0;n<=1?(this.cache.delete(r),this.refCounts.delete(r)):this.refCounts.set(r,n-1)}clearAll(){this.cache.clear(),this.refCounts.clear()}async decodeByExtension(t,r){let n=t.toLowerCase();if(n.endsWith(".wav")){let i=Ro(r),o=i.channels,s=Array.from({length:o},()=>new Float32Array(i.samples.length/o));for(let a=0;a<i.samples.length;a+=1)s[a%o][Math.floor(a/o)]=i.samples[a];return{sampleRate:i.sampleRate,channels:o,bitDepth:i.bitsPerSample,channelData:s}}if(n.endsWith(".ogg")||n.endsWith(".oga"))return as(r);throw new Ci(`Unsupported audio format: ${t}`)}};var om="quake2ts-pak-indexes",sm="pak-indexes";function Ld(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"&&"indexedDB"in window)return window.indexedDB;if(typeof globalThis<"u"&&"indexedDB"in globalThis)return globalThis.indexedDB}function zi(e,t){let r=Ld();return r?new Promise((n,i)=>{let o=r.open(e,1);o.onupgradeneeded=()=>{let{result:s}=o;s.objectStoreNames.contains(t)||s.createObjectStore(t,{keyPath:"key"})},o.onerror=()=>i(o.error??new Error("Unknown IndexedDB error")),o.onsuccess=()=>n(o.result)}):Promise.reject(new Error("IndexedDB is not available in this environment"))}function ki(e,t,r,n){return new Promise((i,o)=>{let a=e.transaction(t,r).objectStore(t),d=n(a);d.onsuccess=()=>i(d.result),d.onerror=()=>o(d.error??new Error("IndexedDB transaction error"))})}function ja(e,t){return`${ae(e)}:${t.toString(16)}`}function am(e){return e.map(t=>({...t}))}var ls=class{constructor(t=om,r=sm){this.dbName=t;this.storeName=r}get isSupported(){return!!Ld()}async persist(t){if(!this.isSupported)return;let r=t.validate(),n={...r,key:ja(t.name,r.checksum),name:t.name,size:t.size,persistedAt:Date.now(),entries:am(r.entries)},i=await zi(this.dbName,this.storeName);return await ki(i,this.storeName,"readwrite",o=>o.put(n)),i.close(),n}async find(t,r){if(!this.isSupported)return;let n=await zi(this.dbName,this.storeName),i=r!==void 0?ja(t,r):void 0,o=await ki(n,this.storeName,"readonly",s=>i?s.get(i):s.getAll());if(n.close(),!!o){if(Array.isArray(o)){let s=ae(t),a=o.filter(d=>ae(d.name)===s);return a.length===0?void 0:a.sort((d,l)=>l.persistedAt-d.persistedAt)[0]}return o}}async remove(t,r){if(!this.isSupported)return!1;let n=await zi(this.dbName,this.storeName),i=r!==void 0?ja(t,r):void 0,o=await ki(n,this.storeName,"readwrite",s=>{if(i)return s.delete(i);let a=`${ae(t)}:`;return s.delete(IDBKeyRange.bound(a,`${a}\uFFFF`,!1,!0))});return n.close(),typeof o=="number"?o>0:!0}async clear(){if(!this.isSupported)return;let t=await zi(this.dbName,this.storeName);await ki(t,this.storeName,"readwrite",r=>r.clear()),t.close()}async list(){if(!this.isSupported)return[];let t=await zi(this.dbName,this.storeName),r=await ki(t,this.storeName,"readonly",n=>n.getAll());return t.close(),r.sort((n,i)=>i.persistedAt-n.persistedAt)}};var Sr=class extends Error{constructor(r,n){super(n??`Missing dependencies: ${r.join(", ")}`);this.missing=r;this.name="AssetDependencyError"}},Fi=class{constructor(){this.nodes=new Map}register(t,r=[]){let n=this.nodes.get(t)??{dependencies:new Set,loaded:!1};r.forEach(i=>n.dependencies.add(i)),this.nodes.set(t,n),r.forEach(i=>{this.nodes.has(i)||this.nodes.set(i,{dependencies:new Set,loaded:!1})})}markLoaded(t){let r=this.nodes.get(t)??{dependencies:new Set,loaded:!1},n=this.getMissingDependencies(t,r);if(n.length>0)throw new Sr(n,`Asset ${t} is missing dependencies: ${n.join(", ")}`);r.loaded=!0,this.nodes.set(t,r)}markUnloaded(t){let r=this.nodes.get(t);r&&(r.loaded=!1)}isLoaded(t){return this.nodes.get(t)?.loaded??!1}missingDependencies(t){let r=this.nodes.get(t);return r?this.getMissingDependencies(t,r):[]}reset(){this.nodes.clear()}getMissingDependencies(t,r){let n=[];for(let i of r.dependencies)this.nodes.get(i)?.loaded||n.push(i);return n}},cs=class{constructor(t,r={}){this.vfs=t;this.maps=new Map;this.textures=new $r({capacity:r.textureCacheCapacity??128}),this.audio=new fn(t,{cacheSize:r.audioCacheSize??64}),this.dependencyTracker=r.dependencyTracker??new Fi,this.md2=new Wr(t),this.md3=new Xr(t),this.sprite=new Kr(t),this.bsp=new Gr(t),this.palette=new Uint8Array(768);for(let n=0;n<256;n++)this.palette[n*3]=n,this.palette[n*3+1]=n,this.palette[n*3+2]=n}async loadPalette(t="pics/colormap.pcx"){try{let r=await this.vfs.readFile(t),n=Nn(r);n.palette&&(this.palette=n.palette)}catch(r){console.warn(`Failed to load palette from ${t}:`,r)}}isAssetLoaded(t,r){return this.dependencyTracker.isLoaded(this.makeKey(t,r))}registerTexture(t,r){this.textures.set(t,r);let n=this.makeKey("texture",t);this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n)}async loadTexture(t){let r=this.textures.get(t);if(r)return r;let n=await this.vfs.readFile(t),i=t.split(".").pop()?.toLowerCase(),o;if(i==="wal")o=Io(n,this.palette);else if(i==="pcx")o=To(Nn(n));else if(i==="tga")o=jc(Ia(n));else throw new Error(`Unsupported texture format for loadTexture: ${i}`);return this.registerTexture(t,o),o}async loadSound(t){let r=await this.audio.load(t),n=this.makeKey("sound",t);return this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n),r}async loadMd2Model(t,r=[]){let n=this.makeKey("model",t),i=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,i);let o=this.dependencyTracker.missingDependencies(n);if(o.length>0)throw new Sr(o,`Asset ${n} is missing dependencies: ${o.join(", ")}`);let s=await this.md2.load(t);return this.dependencyTracker.markLoaded(n),s}getMd2Model(t){return this.md2.get(t)}async loadMd3Model(t,r=[]){let n=this.makeKey("model",t),i=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,i);let o=this.dependencyTracker.missingDependencies(n);if(o.length>0)throw new Sr(o,`Asset ${n} is missing dependencies: ${o.join(", ")}`);let s=await this.md3.load(t);return this.dependencyTracker.markLoaded(n),s}getMd3Model(t){return this.md3.get(t)}async loadSprite(t){let r=this.makeKey("sprite",t);this.dependencyTracker.register(r);let n=await this.sprite.load(t);return this.dependencyTracker.markLoaded(r),n}async loadMap(t){let r=this.makeKey("map",t);if(this.maps.has(t))return this.maps.get(t);this.dependencyTracker.register(r);let n=await this.bsp.load(t);return this.maps.set(t,n),this.dependencyTracker.markLoaded(r),n}getMap(t){return this.maps.get(t)}listFiles(t){return this.vfs.findByExtension(t)}resetForLevelChange(){this.textures.clear(),this.audio.clearAll(),this.dependencyTracker.reset(),this.maps.clear()}makeKey(t,r){return`${t}:${ae(r)}`}};var Qa=32,ds=(h=>(h[h.Auto=0]="Auto",h[h.Weapon=1]="Weapon",h[h.Voice=2]="Voice",h[h.Item=3]="Item",h[h.Body=4]="Body",h[h.Aux=5]="Aux",h[h.Footstep=6]="Footstep",h[h.Aux3=7]="Aux3",h[h.NoPhsAdd=8]="NoPhsAdd",h[h.Reliable=16]="Reliable",h[h.ForcePos=32]="ForcePos",h))(ds||{}),Td=-1,us=0,Id=1,Rd=2,Cd=3,hn=80,zd=.003;function wr(e){return e===3?e*.001:e*5e-4}function fs(e){let t=wr(e);return t<=0?Number.POSITIVE_INFINITY:80+1/t}var hs=class{constructor(t){this.factory=t}getContext(){return this.context||(this.context=this.factory()),this.context}async resume(){let t=this.getContext();t.state==="suspended"&&await t.resume()}getState(){return this.context?.state??"suspended"}};function ms(e){let t=e.getContext(),r=t.createGain();r.gain.value=1;let n=t.createDynamicsCompressor(),i=t.createBiquadFilter?.();return i?(i.type="lowpass",i.frequency.value=2e4,i.Q.value=.707,r.connect(i),i.connect(n)):r.connect(n),n.connect(t.destination),{context:t,master:r,compressor:n,filter:i}}var ps=class{constructor(t=new Ur){this.configStrings=t;this.buffers=new Map}registerName(t){return this.configStrings.soundIndex(t)}register(t,r){let n=this.registerName(t);return this.buffers.set(n,r),n}find(t){return this.configStrings.findSoundIndex(t)}get(t){return this.buffers.get(t)}has(t){return this.buffers.has(t)}getName(t){return this.configStrings.getName(t)}};var gs=class{constructor(t){this.vfs=t.vfs,this.registry=t.registry,this.contextController=t.context,this.soundRoot=t.soundRoot??"sound/",this.decodeAudio=t.decodeAudio??((r,n)=>{if(!r.decodeAudioData)throw new Error("decodeAudioData is not available on the provided audio context");return r.decodeAudioData(n)})}async precache(t){let r=[...new Set(t.map(o=>this.normalize(o)))],n={loaded:[],skipped:[],missing:[],errors:{}},i=this.contextController.getContext();for(let o of r)try{let s=this.registry.find(o);if(s!==void 0&&this.registry.has(s)){n.skipped.push(o);continue}if(!this.vfs.stat(o)){n.missing.push(o);continue}let l=(await this.vfs.readFile(o)).slice().buffer,c=await this.decodeAudio(i,l);this.registry.register(o,c),n.loaded.push(o)}catch(s){let a=s instanceof Error?s:new Error(String(s));n.errors[o]=a}return n}normalize(t){let r=ae(t.replace(/^\//,""));return r.startsWith(this.soundRoot)?r:ae(`${this.soundRoot}${r}`)}};var lm=7,Pi=e=>e&lm;function ys(e){return Array.from({length:32},()=>({entnum:0,entchannel:0,endTimeMs:0,isPlayer:!1,active:!1})).map(t=>({...t,isPlayer:t.entnum===e}))}function xs(e,t,r,n){if(r<0)throw new Error("pickChannel: entchannel must be non-negative");let i=Pi(r),o=-1,s=Number.POSITIVE_INFINITY;for(let a=0;a<e.length;a+=1){let d=e[a],l=Pi(d.entchannel);if(i!==0&&d.entnum===t&&l===i){o=a;break}if(d.active&&d.entnum===n.playerEntity&&t!==n.playerEntity)continue;let c=d.endTimeMs-n.nowMs;(o===-1||c<s)&&(s=c,o=a)}return o===-1?void 0:o}function _s(e,t,r,n,i){if(i)return{left:r,right:r,distanceComponent:0};let o=bc(e,t.origin),s=ma(o),a=Qe(o),d=s-80;d<0&&(d=0),d*=wr(n);let l=ha(t.right,a),c=t.mono??!1,h=c||n===0?1:.5*(1+l),u=c||n===0?1:.5*(1-l),f=Math.max(0,Math.floor(r*(1-d)*h));return{left:Math.max(0,Math.floor(r*(1-d)*u)),right:f,distanceComponent:d}}var bs=class{constructor(t){this.activeSources=new Map;this.contextController=t.context,this.registry=t.registry,this.playerEntity=t.playerEntity,this.channels=ys(t.playerEntity),this.listener=t.listener??{origin:_c,right:{x:1,y:0,z:0}},this.sfxVolume=t.sfxVolume??1,this.masterVolume=t.masterVolume??1,this.resolveOcclusion=t.resolveOcclusion,this.graph=ms(this.contextController),this.graph.master.gain.value=this.masterVolume}setListener(t){this.listener=t}setMasterVolume(t){this.masterVolume=t,this.graph.master.gain.value=t}setSfxVolume(t){this.sfxVolume=t}async ensureRunning(){await this.contextController.resume()}play(t){let r=this.registry.get(t.soundIndex);if(!r)return;let n=this.graph.context,i=n.currentTime*1e3,o=xs(this.channels,t.entity,t.channel,{nowMs:i,playerEntity:this.playerEntity});if(o===void 0)return;let s=this.activeSources.get(o);s&&(s.source.onended=null,s.source.stop(),this.activeSources.delete(o));let a=n.createBufferSource();a.buffer=r,a.loop=t.looping??!1;let d=t.origin??this.listener.origin,l=n.createGain(),c=this.createPanner(n,t.attenuation),h=this.resolveOcclusion?.(this.listener,d,t.attenuation),u=kd(h?.gainScale??1),f=this.resolveOcclusion?this.createOcclusionFilter(n,h?.lowpassHz??2e4):void 0;this.applyOriginToPanner(c,d);let m=t.entity===this.playerEntity,g=_s(d,this.listener,t.volume,t.attenuation,m),x=(t.volume===0?0:Math.max(g.left,g.right)/Math.max(1,t.volume))*(t.volume/255)*this.masterVolume*this.sfxVolume;l.gain.value=x*u;let S=n.currentTime+(t.timeOffsetMs??0)/1e3,_=(t.looping?Number.POSITIVE_INFINITY:r.duration*1e3)+S*1e3;a.connect(c),f?(c.connect(f),f.connect(l)):c.connect(l),l.connect(this.graph.master),a.start(S),a.onended=()=>{this.channels[o].active=!1,this.activeSources.delete(o)};let y={channelIndex:o,entnum:t.entity,entchannel:Pi(t.channel),endTimeMs:_,source:a,panner:c,gain:l,baseGain:x,origin:d,attenuation:t.attenuation,occlusion:f?{scale:u,lowpassHz:h?.lowpassHz,filter:f}:h?{scale:u,lowpassHz:h.lowpassHz}:void 0};return this.channels[o]={entnum:t.entity,entchannel:Pi(t.channel),endTimeMs:_,isPlayer:t.entity===this.playerEntity,active:!0},this.activeSources.set(o,y),y}stop(t){let r=this.activeSources.get(t);r&&(r.source.stop(),this.channels[t].active=!1,this.activeSources.delete(t))}stopEntitySounds(t){for(let[r,n]of[...this.activeSources.entries()])n.entnum===t&&(n.source.stop(),this.channels[r].active=!1,this.activeSources.delete(r))}updateEntityPosition(t,r){for(let n of this.activeSources.values())if(n.entnum===t&&(this.applyOriginToPanner(n.panner,r),n.origin=r,this.resolveOcclusion)){let i=this.resolveOcclusion(this.listener,r,n.attenuation);this.applyOcclusion(n,i)}}positionedSound(t,r,n,i){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:i,origin:t})}ambientSound(t,r,n){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:0,origin:t,looping:!0})}getChannelState(t){return this.channels[t]}getDiagnostics(){return{activeChannels:this.activeSources.size,masterVolume:this.masterVolume,sfxVolume:this.sfxVolume,channels:[...this.channels],activeSounds:[...this.activeSources.values()].map(t=>({entnum:t.entnum,entchannel:t.entchannel,channelIndex:t.channelIndex,origin:t.origin,gain:t.gain.gain.value,baseGain:t.baseGain,attenuation:t.attenuation,maxDistance:t.panner.maxDistance,distanceModel:t.panner.distanceModel,occlusion:t.occlusion?{scale:t.occlusion.scale,lowpassHz:t.occlusion.lowpassHz}:void 0}))}}setUnderwater(t,r=400){let n=this.graph.filter;n&&(n.type="lowpass",n.Q.value=.707,n.frequency.value=t?r:2e4)}createPanner(t,r){let n=t.createPanner?t.createPanner():Object.assign(t.createGain(),{positionX:{value:this.listener.origin.x},positionY:{value:this.listener.origin.y},positionZ:{value:this.listener.origin.z}});return this.configurePanner(n,r)}configurePanner(t,r){let n=wr(r);return t.refDistance=80,t.maxDistance=fs(r),t.rolloffFactor=n,t.distanceModel=r===0?"linear":"inverse",t.positionX.value=this.listener.origin.x,t.positionY.value=this.listener.origin.y,t.positionZ.value=this.listener.origin.z,t}applyOriginToPanner(t,r){t.positionX.value=r.x,t.positionY.value=r.y,t.positionZ.value=r.z}createOcclusionFilter(t,r){if(!t.createBiquadFilter)return;let n=t.createBiquadFilter();return n.type="lowpass",n.Q.value=.707,n.frequency.value=Ja(r,10,2e4),n}applyOcclusion(t,r){let n=kd(r?.gainScale??1);if(t.gain.gain.value=t.baseGain*n,t.occlusion?.filter){let i=r?.lowpassHz??2e4;t.occlusion.filter.frequency.value=Ja(i,10,2e4)}t.occlusion?(t.occlusion.scale=n,t.occlusion.lowpassHz=r?.lowpassHz):r&&(t.occlusion={scale:n,lowpassHz:r.lowpassHz})}},Ja=(e,t,r)=>Math.min(r,Math.max(t,e)),kd=e=>Ja(e,0,1);var vs=class{constructor(t){this.createElement=t.createElement,this.resolveSource=t.resolveSource??(async r=>r),this.volume=t.volume??1}async play(t,{loop:r=!0,restart:n=!1}={}){if(this.track===t&&this.element){this.element.loop=r,this.element.volume=this.volume,n&&(this.element.currentTime=0),(this.element.paused||n)&&await this.element.play();return}let i=await this.resolveSource(t),o=this.createElement();o.src=i,o.loop=r,o.volume=this.volume,o.currentTime=0,o.load(),await o.play(),this.element=o,this.track=t}pause(){!this.element||this.element.paused||this.element.pause()}async resume(){!this.element||!this.element.paused||await this.element.play()}stop(){this.element&&(this.element.pause(),this.element.currentTime=0,this.element=void 0,this.track=void 0)}setVolume(t){this.volume=t,this.element&&(this.element.volume=t)}getState(){let t=!!(this.element&&!this.element.paused&&!this.element.ended),r=!!this.element?.paused;return{track:this.track,paused:r,playing:t,volume:this.volume}}};function cm(e){e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}function dm(e,t,r,n){for(let i of t){let o=e.getExtension(i);if(!o)throw new Error(`Missing required WebGL extension: ${i}`);n.set(i,o)}for(let i of r){let o=e.getExtension(i);o&&n.set(i,o)}}function Fd(e,t={}){let{contextAttributes:r,requiredExtensions:n=[],optionalExtensions:i=[]}=t,o=e.getContext("webgl2",r??{antialias:!0});if(!o)throw new Error("WebGL2 not supported or failed to initialize");cm(o);let s=new Map;dm(o,n,i,s);let a=!1,d=new Set,l=new Set,c=u=>{a=!0,u.preventDefault();for(let f of d)f()},h=()=>{a=!1;for(let u of l)u()};return e.addEventListener("webglcontextlost",c),e.addEventListener("webglcontextrestored",h),{gl:o,extensions:s,isLost:()=>a,onLost(u){return d.add(u),()=>d.delete(u)},onRestored(u){return l.add(u),()=>l.delete(u)},dispose(){e.removeEventListener("webglcontextlost",c),e.removeEventListener("webglcontextrestored",h),d.clear(),l.clear(),s.clear()}}}function Pd(e,t,r){let n=e.createShader(t);if(!n)throw new Error("Failed to allocate shader");if(e.shaderSource(n,r),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){let o=e.getShaderInfoLog(n)??"Unknown shader compile failure";throw e.deleteShader(n),new Error(o)}return n}function um(e,t,r,n){let i=e.createProgram();if(!i)throw new Error("Failed to allocate shader program");if(e.attachShader(i,t),e.attachShader(i,r),n)for(let[s,a]of Object.entries(n))e.bindAttribLocation(i,a,s);if(e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)){let s=e.getProgramInfoLog(i)??"Unknown shader link failure";throw e.deleteProgram(i),new Error(s)}return i}var Me=class e{constructor(t,r){this.uniformLocations=new Map;this.attributeLocations=new Map;this.gl=t,this.program=r}static create(t,r,n){let i=Pd(t,t.VERTEX_SHADER,r.vertex),o=Pd(t,t.FRAGMENT_SHADER,r.fragment);try{let s=um(t,i,o,n);return new e(t,s)}finally{t.deleteShader(i),t.deleteShader(o)}}use(){this.gl.useProgram(this.program)}getUniformLocation(t){if(!this.uniformLocations.has(t)){let r=this.gl.getUniformLocation(this.program,t);this.uniformLocations.set(t,r)}return this.uniformLocations.get(t)??null}getAttributeLocation(t){if(!this.attributeLocations.has(t)){let r=this.gl.getAttribLocation(this.program,t);this.attributeLocations.set(t,r)}return this.attributeLocations.get(t)??-1}dispose(){this.gl.deleteProgram(this.program),this.uniformLocations.clear(),this.attributeLocations.clear()}};function Dd(e,t,r){return Me.create(e,t,r)}var Ee=class{constructor(t,r=t.STATIC_DRAW,n){this.gl=t,this.target=n??t.ARRAY_BUFFER;let i=t.createBuffer();if(!i)throw new Error("Failed to allocate buffer");this.buffer=i,t.bindBuffer(this.target,this.buffer),t.bufferData(this.target,0,r)}bind(){this.gl.bindBuffer(this.target,this.buffer)}upload(t,r=this.gl.STATIC_DRAW){this.bind(),this.gl.bufferData(this.target,t,r)}update(t,r=0){this.bind(),this.gl.bufferSubData(this.target,r,t)}dispose(){this.gl.deleteBuffer(this.buffer)}},ye=class extends Ee{constructor(t,r=t.STATIC_DRAW){super(t,r,t.ELEMENT_ARRAY_BUFFER)}},Ce=class{constructor(t){this.gl=t;let r=t.createVertexArray();if(!r)throw new Error("Failed to allocate vertex array object");this.vao=r}bind(){this.gl.bindVertexArray(this.vao)}configureAttributes(t,r){this.bind(),r&&r.bind();for(let n of t)this.gl.enableVertexAttribArray(n.index),this.gl.vertexAttribPointer(n.index,n.size,n.type,n.normalized??!1,n.stride??0,n.offset??0),n.divisor!==void 0&&this.gl.vertexAttribDivisor(n.index,n.divisor)}dispose(){this.gl.deleteVertexArray(this.vao)}},mn=class{constructor(t,r=t.TEXTURE_2D){this.width=0;this.height=0;this.gl=t,this.target=r;let n=t.createTexture();if(!n)throw new Error("Failed to allocate texture");this.texture=n}bind(t=0){this.gl.activeTexture(this.gl.TEXTURE0+t),this.gl.bindTexture(this.target,this.texture)}setParameters(t){this.bind(),t.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,t.wrapS),t.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,t.wrapT),t.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,t.minFilter),t.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,t.magFilter)}upload(t,r,n){this.width=t,this.height=r,this.uploadImage(0,this.gl.RGBA,t,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n)}uploadImage(t,r,n,i,o,s,a,d){this.bind(),this.gl.texImage2D(this.target,t,r,n,i,o,s,a,d)}dispose(){this.gl.deleteTexture(this.texture)}},pn=class{constructor(t){this.gl=t,this.target=t.TEXTURE_CUBE_MAP;let r=t.createTexture();if(!r)throw new Error("Failed to allocate cubemap texture");this.texture=r}bind(t=0){this.gl.activeTexture(this.gl.TEXTURE0+t),this.gl.bindTexture(this.target,this.texture)}setParameters(t){this.bind(),t.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,t.wrapS),t.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,t.wrapT),t.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,t.minFilter),t.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,t.magFilter)}uploadFace(t,r,n,i,o,s,a,d,l){this.bind(),this.gl.texImage2D(t,r,n,i,o,s,a,d,l)}dispose(){this.gl.deleteTexture(this.texture)}},Ss=class{constructor(t){this.gl=t;let r=t.createFramebuffer();if(!r)throw new Error("Failed to allocate framebuffer");this.framebuffer=r}bind(t=this.gl.FRAMEBUFFER){this.gl.bindFramebuffer(t,this.framebuffer)}attachTexture2D(t,r,n=0){this.bind(),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,t,r.target,r.texture,n)}dispose(){this.gl.deleteFramebuffer(this.framebuffer)}};var tl=4,el=7*tl,rl=[{index:0,size:3,type:5126,stride:el,offset:0},{index:1,size:2,type:5126,stride:el,offset:3*tl},{index:2,size:2,type:5126,stride:el,offset:5*tl}];function fm(e,t){return{width:e,height:e,padding:t,data:new Uint8Array(e*e*4),cursorX:0,cursorY:0,rowHeight:0}}function hm(e){let t=e.width*e.height;if(t===0)throw new Error("Invalid lightmap with zero area");let r=e.samples.byteLength/t;if(!Number.isInteger(r)||r<3||r>4)throw new Error("Unsupported lightmap channel count");return r}function mm(e,t,r){let n=hm(r),i=e.width*4,o=t.x+e.padding,s=t.y+e.padding,a=0;for(let d=0;d<r.height;d++){let l=(s+d)*i+o*4;for(let c=0;c<r.width;c++){let h=l+c*4;e.data[h]=r.samples[a],e.data[h+1]=r.samples[a+1],e.data[h+2]=r.samples[a+2],e.data[h+3]=n===4?r.samples[a+3]:255,a+=n}}}function pm(e,t,r){let n=t.width+r.lightmapPadding*2,i=t.height+r.lightmapPadding*2;if(n>r.atlasSize||i>r.atlasSize)throw new Error("Lightmap too large for atlas");for(let a of e){if(a.cursorX+n>a.width&&(a.cursorX=0,a.cursorY+=a.rowHeight+r.lightmapPadding,a.rowHeight=0),a.cursorY+i>a.height)continue;let d={atlasIndex:e.indexOf(a),x:a.cursorX,y:a.cursorY,width:t.width,height:t.height};return a.cursorX+=n+r.lightmapPadding,a.rowHeight=Math.max(a.rowHeight,i),{placement:d,atlas:a}}let o=fm(r.atlasSize,r.lightmapPadding);e.push(o);let s={atlasIndex:e.length-1,x:0,y:0,width:t.width,height:t.height};return o.cursorX=n+r.lightmapPadding,o.rowHeight=i,{placement:s,atlas:o}}function ws(e){return e instanceof Float32Array?e:new Float32Array(e)}function gm(e,t){if(!e){let n=new Uint16Array(t);for(let i=0;i<t;i++)n[i]=i;return n}return e instanceof Uint16Array?e:new Uint16Array(e)}function ym(e,t){let r=new Float32Array(e.length);for(let n=0;n<e.length;n+=2)r[n]=t.offset[0]+e[n]*t.scale[0],r[n+1]=t.offset[1]+e[n+1]*t.scale[1];return r}function xm(e,t){let r=ws(e.vertices),n=ws(e.textureCoords),i=t?ym(ws(e.lightmapCoords??e.textureCoords),t):ws(e.lightmapCoords??new Float32Array(n.length)),o=r.length/3;if(n.length/2!==o)throw new Error("Texture coordinates count mismatch");if(i.length/2!==o)throw new Error("Lightmap coordinates count mismatch");let s=new Float32Array(o*7);for(let a=0;a<o;a++){let d=a*3,l=a*2,c=a*7;s[c]=r[d],s[c+1]=r[d+1],s[c+2]=r[d+2],s[c+3]=n[l],s[c+4]=n[l+1],s[c+5]=i[l],s[c+6]=i[l+1]}return s}function Od(e){let t=[];for(let r=0;r<e.faces.length;r++){let n=e.faces[r];if(n.texInfo<0)continue;let i=e.texInfo[n.texInfo],o=[],s=[],a=[];for(let u=0;u<n.numEdges;u++){let f=e.surfEdges[n.firstEdge+u],m=e.edges[Math.abs(f)],g=f>=0?m.vertices[0]:m.vertices[1],p=e.vertices[g];o.push(p[0],p[1],p[2]);let x=p[0]*i.s[0]+p[1]*i.s[1]+p[2]*i.s[2]+i.sOffset,S=p[0]*i.t[0]+p[1]*i.t[1]+p[2]*i.t[2]+i.tOffset;s.push(x,S),a.push(x,S)}let d=[],l=o.length/3;for(let u=1;u<l-1;u++)d.push(0,u,u+1);let c,h=e.lightMapInfo[r];if(h){let u=1/0,f=-1/0,m=1/0,g=-1/0;for(let b=0;b<s.length;b+=2){let A=s[b],v=s[b+1];A<u&&(u=A),A>f&&(f=A),v<m&&(m=v),v>g&&(g=v)}let p=Math.floor(u/16),x=Math.floor(m/16),S=Math.ceil(f/16)-p+1,_=Math.ceil(g/16)-x+1,y=Ao(n,e.lightMaps,h);if(y&&y.length===S*_*3){c={width:S,height:_,samples:y};for(let b=0;b<a.length;b+=2)a[b]=s[b]/16-p+.5,a[b+1]=s[b+1]/16-x+.5}}t.push({vertices:new Float32Array(o),textureCoords:new Float32Array(s),lightmapCoords:new Float32Array(a),indices:new Uint16Array(d),texture:i.texture,surfaceFlags:i.flags,lightmap:c,faceIndex:r})}return t}function Bd(e,t,r,n={}){let i=t;if(r&&n.hiddenClassnames&&n.hiddenClassnames.size>0){let c=new Set;for(let h of r.entities.entities)if(h.classname&&n.hiddenClassnames.has(h.classname)){let u=h.properties.model;if(u&&u.startsWith("*")){let f=parseInt(u.substring(1),10);if(!isNaN(f)&&f>=0&&f<r.models.length){let m=r.models[f];for(let g=0;g<m.numFaces;g++)c.add(m.firstFace+g)}}}c.size>0&&(i=t.filter(h=>!c.has(h.faceIndex)))}let o={atlasSize:n.atlasSize??1024,lightmapPadding:n.lightmapPadding??1,hiddenClassnames:n.hiddenClassnames??new Set},s=[],a=new Map;i.forEach((c,h)=>{if(!c.lightmap)return;let{placement:u,atlas:f}=pm(s,c.lightmap,o);mm(f,u,c.lightmap),a.set(h,{atlasIndex:u.atlasIndex,offset:[(u.x+o.lightmapPadding)/o.atlasSize,(u.y+o.lightmapPadding)/o.atlasSize],scale:[u.width/o.atlasSize,u.height/o.atlasSize]})});let d=s.map(c=>{let h=new mn(e);return h.setParameters({wrapS:e.CLAMP_TO_EDGE,wrapT:e.CLAMP_TO_EDGE,minFilter:e.LINEAR,magFilter:e.LINEAR}),h.uploadImage(0,e.RGBA,c.width,c.height,0,e.RGBA,e.UNSIGNED_BYTE,c.data),{texture:h,width:c.width,height:c.height,pixels:c.data}});return{surfaces:i.map((c,h)=>{let u=a.get(h),f=xm(c,u),m=gm(c.indices,f.length/7),g=new Ee(e,e.STATIC_DRAW,e.ARRAY_BUFFER);g.upload(f);let p=new ye(e,e.STATIC_DRAW);p.upload(m);let x=new Ce(e);return x.configureAttributes(rl,g),{vao:x,vertexBuffer:g,indexBuffer:p,indexCount:m.length,vertexCount:f.length/7,texture:c.texture,surfaceFlags:c.surfaceFlags??zn,lightmap:u,vertexData:f,indexData:m}}),lightmaps:d}}function gn(e){let{normal:t,distance:r}=e,n=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);if(n===0)return e;let i=1/n;return{normal:{x:t.x*i,y:t.y*i,z:t.z*i},distance:r*i}}function Nd(e){if(e.length!==16)throw new Error("View-projection matrix must contain 16 elements");let t=e[0],r=e[4],n=e[8],i=e[12],o=e[1],s=e[5],a=e[9],d=e[13],l=e[2],c=e[6],h=e[10],u=e[14],f=e[3],m=e[7],g=e[11],p=e[15];return[gn({normal:{x:f+t,y:m+r,z:g+n},distance:p+i}),gn({normal:{x:f-t,y:m-r,z:g-n},distance:p-i}),gn({normal:{x:f+o,y:m+s,z:g+a},distance:p+d}),gn({normal:{x:f-o,y:m-s,z:g-a},distance:p-d}),gn({normal:{x:f+l,y:m+c,z:g+h},distance:p+u}),gn({normal:{x:f-l,y:m-c,z:g-h},distance:p-u})]}function _m(e,t){return e.normal.x*t.x+e.normal.y*t.y+e.normal.z*t.z+e.distance}function Di(e,t,r){for(let n of r){let i=n.normal.x>=0?t.x:e.x,o=n.normal.y>=0?t.y:e.y,s=n.normal.z>=0?t.z:e.z;if(_m(n,{x:i,y:o,z:s})<0)return!1}return!0}function Ud(e){return e<0}function Hd(e){return-e-1}function Vd(e,t){return e.normal[0]*t.x+e.normal[1]*t.y+e.normal[2]*t.z-e.dist}function bm(e,t,r){if(!e||t<0||r<0)return!0;let n=Math.ceil(e.numClusters/8),i=e.clusters[t].pvs,o=Math.floor(r/8),s=1<<r%8;return o<0||o>=n?!1:(i[o]&s)!==0}function vm(e,t){let r={x:e.mins[0],y:e.mins[1],z:e.mins[2]},n={x:e.maxs[0],y:e.maxs[1],z:e.maxs[2]};return Di(r,n,t)}function il(e,t){let r=0;for(;r>=0;){let n=e.nodes[r],i=e.planes[n.planeIndex],s=Vd(i,t)>=0?0:1,a=n.children[s];if(Ud(a))return Hd(a);r=a}return-1}function Sm(e,t){let r=e.leafs[t],n=[];for(let i=0;i<r.numLeafFaces;i+=1)n.push(e.leafLists.leafFaces[t][i]);return n}function nl(e,t,r,n,i,o,s){if(Ud(t)){let u=Hd(t),f=e.leafs[u];if(!bm(e.visibility,i,f.cluster)||!vm(f,n))return;let m={x:(f.mins[0]+f.maxs[0])*.5,y:(f.mins[1]+f.maxs[1])*.5,z:(f.mins[2]+f.maxs[2])*.5},g=m.x-r.x,p=m.y-r.y,x=m.z-r.z,S=-(g*g+p*p+x*x);for(let _ of Sm(e,u))s.has(_)||(s.add(_),o.push({faceIndex:_,leafIndex:u,sortKey:S}));return}let a=e.nodes[t],d=e.planes[a.planeIndex],l=Vd(d,r),c=l>=0?a.children[0]:a.children[1],h=l>=0?a.children[1]:a.children[0];Di({x:a.mins[0],y:a.mins[1],z:a.mins[2]},{x:a.maxs[0],y:a.maxs[1],z:a.maxs[2]},n)&&(nl(e,c,r,n,i,o,s),nl(e,h,r,n,i,o,s))}function Gd(e,t,r){let n=il(e,t),i=n>=0?e.leafs[n].cluster:-1,o=[];return nl(e,0,t,r,i,o,new Set),o}var Qt=32;function yn(e){let t=[];for(let r=0;r<e.length;r+=3){let n=e[r],i=e[r+1],o=e[r+2];t.push(n,i,i,o,o,n)}return e instanceof Uint32Array||Math.max(...t)>65535?new Uint32Array(t):new Uint16Array(t)}var ol=`#version 300 es
141
+ ïBçϧmÙIólÜoëVbƒ¦¯éWÇû3`});var Nu={a:ir};this.setModule=C=>{e.setModule(Et,C)},this.getModule=()=>e.getModule(Et),this.instantiate=()=>(this.getModule().then(C=>WebAssembly.instantiate(C,Nu)).then(C=>{let Ue=C.exports;co(Ue),m=Ue.l,g(),Bu(Ue),r()}),this.ready=new Promise(C=>{r=C}).then(()=>{this.HEAP=m.buffer,this.malloc=dc,this.free=pc,this.create_decoder=Tn,this.send_setup=uc,this.init_dsp=fc,this.decode_packets=hc,this.destroy_decoder=mc}),this)}function vr(){return this._init=()=>new this._WASMAudioDecoderCommon().instantiate(this._EmscriptenWASM,this._module).then(e=>{this._common=e,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._firstPage=!0,this._inputLen=this._common.allocateTypedArray(1,Uint32Array),this._outputBufferPtr=this._common.allocateTypedArray(1,Uint32Array),this._channels=this._common.allocateTypedArray(1,Uint32Array),this._sampleRate=this._common.allocateTypedArray(1,Uint32Array),this._samplesDecoded=this._common.allocateTypedArray(1,Uint32Array);let t=256;this._errors=this._common.allocateTypedArray(t,Uint32Array),this._errorsLength=this._common.allocateTypedArray(1,Int32Array),this._frameNumber=0,this._inputBytes=0,this._outputSamples=0,this._decoder=this._common.wasm.create_decoder(this._input.ptr,this._inputLen.ptr,this._outputBufferPtr.ptr,this._channels.ptr,this._sampleRate.ptr,this._samplesDecoded.ptr,this._errors.ptr,this._errorsLength.ptr,t)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.wasm.destroy_decoder(this._decoder),this._common.free()},this.sendSetupHeader=e=>{this._input.buf.set(e),this._inputLen.buf[0]=e.length,this._common.wasm.send_setup(this._decoder,this._firstPage),this._firstPage=!1},this.initDsp=()=>{this._common.wasm.init_dsp(this._decoder)},this.decodePackets=e=>{let t=[],r=0,n=[];for(let i=0;i<e.length;i++){let o=e[i];this._input.buf.set(o),this._inputLen.buf[0]=o.length,this._common.wasm.decode_packets(this._decoder);let s=this._samplesDecoded.buf[0],a=[],d=new Uint32Array(this._common.wasm.HEAP,this._outputBufferPtr.buf[0],this._channels.buf[0]);for(let l=0;l<this._channels.buf[0];l++){let c=new Float32Array(s);s&&c.set(new Float32Array(this._common.wasm.HEAP,d[l],s)),a.push(c)}t.push(a),r+=s,this._frameNumber++,this._inputBytes+=o.length,this._outputSamples+=s;for(let l=0;l<this._errorsLength.buf;l+=2){let c=this._common.codeToString(this._errors.buf[l]),h=this._common.codeToString(this._errors.buf[l+1]);n.push({message:c+" vorbis_synthesis"+h,frameLength:o.length,frameNumber:this._frameNumber,inputBytes:this._inputBytes,outputSamples:this._outputSamples})}this._errorsLength.buf[0]=0}return this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(n,t,this._channels.buf[0],r,this._sampleRate.buf[0],16)},this._isWebWorker=vr.isWebWorker,this._WASMAudioDecoderCommon=vr.WASMAudioDecoderCommon||te,this._EmscriptenWASM=vr.EmscriptenWASM||Et,this._module=vr.module,this._inputSize=128*1024,this._ready=this._init(),this}var ss=Symbol(),Lt=class{constructor(){this._onCodec=t=>{if(t!=="vorbis")throw new Error("@wasm-audio-decoders/ogg-vorbis does not support this codec "+t)},new te,this._init(),this._ready=this[ss](vr)}_init(){this._vorbisSetupInProgress=!0,this._totalSamplesDecoded=0,this._codecParser=new Sd("audio/ogg",{onCodec:this._onCodec,enableFrameCRC32:!1})}async[ss](t){if(this._decoder){let r=this._decoder;await r.ready.then(()=>r.free())}return this._decoder=new t,this._decoder.ready}get ready(){return this._ready}async reset(){return this._init(),this._decoder.reset()}free(){this._decoder.free()}async decodeOggPages(t){let r=[];for(let o=0;o<t.length;o++){let s=t[o];if(this._vorbisSetupInProgress&&(s[os][0]===1&&this._decoder.sendSetupHeader(s[os]),s[is].length)){let a=s[is][0][wd];this._decoder.sendSetupHeader(a[Md]),this._decoder.initDsp(),this._vorbisSetupInProgress=!1}r.push(...s[is].map(a=>a[os]))}let n=await this._decoder.decodePackets(r);this._totalSamplesDecoded+=n.samplesDecoded;let i=t[t.length-1];if(i&&i[Ad]){let o=this._totalSamplesDecoded-i[Ed];if(o>0){for(let s=0;s<n.channelData.length;s++)n.channelData[s]=n.channelData[s].subarray(0,n.samplesDecoded-o);n.samplesDecoded-=o,this._totalSamplesDecoded-=o}}return n}async decode(t){return this.decodeOggPages([...this._codecParser.parseChunk(t)])}async flush(){let t=await this.decodeOggPages([...this._codecParser.flush()]);return await this.reset(),t}async decodeFile(t){let r=await this.decodeOggPages([...this._codecParser.parseAll(t)]);return await this.reset(),r}};var Ya=class extends Zr{constructor(t){super(t,"ogg-vorbis-decoder",vr,Et)}async sendSetupHeader(t){return this.postToDecoder("sendSetupHeader",t)}async initDsp(){return this.postToDecoder("initDsp")}async decodePackets(t){return this.postToDecoder("decodePackets",t)}},Ci=class extends Lt{constructor(){super(),this._ready=super[ss](Ya)}async free(){await this._decoder.free()}terminate(){this._decoder.terminate()}};zo(Lt,"OggVorbisDecoder");zo(Ci,"OggVorbisDecoderWebWorker");var qa=class extends Error{constructor(t){super(t),this.name="OggDecodeError"}};async function as(e,t=new Lt){await t.ready;let r=await t.decode(new Uint8Array(e)),n=r.errors;if(n&&n.length>0)throw new qa(n.map(i=>i.message).join("; "));return{sampleRate:r.sampleRate,channels:r.channelData.length,bitDepth:r.bitDepth,channelData:r.channelData}}var zi=class extends Error{constructor(t){super(t),this.name="AudioRegistryError"}},fn=class{constructor(t,r={}){this.vfs=t;this.refCounts=new Map;this.cache=new kt(r.cacheSize??64)}get size(){return this.cache.size}async load(t){let r=t.toLowerCase(),n=this.cache.get(r);if(n)return this.refCounts.set(r,(this.refCounts.get(r)??0)+1),n;let o=(await this.vfs.readFile(t)).slice().buffer,s=await this.decodeByExtension(t,o);return this.cache.set(r,s),this.refCounts.set(r,1),s}release(t){let r=t.toLowerCase(),n=this.refCounts.get(r)??0;n<=1?(this.cache.delete(r),this.refCounts.delete(r)):this.refCounts.set(r,n-1)}clearAll(){this.cache.clear(),this.refCounts.clear()}async decodeByExtension(t,r){let n=t.toLowerCase();if(n.endsWith(".wav")){let i=Co(r),o=i.channels,s=Array.from({length:o},()=>new Float32Array(i.samples.length/o));for(let a=0;a<i.samples.length;a+=1)s[a%o][Math.floor(a/o)]=i.samples[a];return{sampleRate:i.sampleRate,channels:o,bitDepth:i.bitsPerSample,channelData:s}}if(n.endsWith(".ogg")||n.endsWith(".oga"))return as(r);throw new zi(`Unsupported audio format: ${t}`)}};var om="quake2ts-pak-indexes",sm="pak-indexes";function Ld(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"&&"indexedDB"in window)return window.indexedDB;if(typeof globalThis<"u"&&"indexedDB"in globalThis)return globalThis.indexedDB}function Ri(e,t){let r=Ld();return r?new Promise((n,i)=>{let o=r.open(e,1);o.onupgradeneeded=()=>{let{result:s}=o;s.objectStoreNames.contains(t)||s.createObjectStore(t,{keyPath:"key"})},o.onerror=()=>i(o.error??new Error("Unknown IndexedDB error")),o.onsuccess=()=>n(o.result)}):Promise.reject(new Error("IndexedDB is not available in this environment"))}function ki(e,t,r,n){return new Promise((i,o)=>{let a=e.transaction(t,r).objectStore(t),d=n(a);d.onsuccess=()=>i(d.result),d.onerror=()=>o(d.error??new Error("IndexedDB transaction error"))})}function ja(e,t){return`${ae(e)}:${t.toString(16)}`}function am(e){return e.map(t=>({...t}))}var ls=class{constructor(t=om,r=sm){this.dbName=t;this.storeName=r}get isSupported(){return!!Ld()}async persist(t){if(!this.isSupported)return;let r=t.validate(),n={...r,key:ja(t.name,r.checksum),name:t.name,size:t.size,persistedAt:Date.now(),entries:am(r.entries)},i=await Ri(this.dbName,this.storeName);return await ki(i,this.storeName,"readwrite",o=>o.put(n)),i.close(),n}async find(t,r){if(!this.isSupported)return;let n=await Ri(this.dbName,this.storeName),i=r!==void 0?ja(t,r):void 0,o=await ki(n,this.storeName,"readonly",s=>i?s.get(i):s.getAll());if(n.close(),!!o){if(Array.isArray(o)){let s=ae(t),a=o.filter(d=>ae(d.name)===s);return a.length===0?void 0:a.sort((d,l)=>l.persistedAt-d.persistedAt)[0]}return o}}async remove(t,r){if(!this.isSupported)return!1;let n=await Ri(this.dbName,this.storeName),i=r!==void 0?ja(t,r):void 0,o=await ki(n,this.storeName,"readwrite",s=>{if(i)return s.delete(i);let a=`${ae(t)}:`;return s.delete(IDBKeyRange.bound(a,`${a}\uFFFF`,!1,!0))});return n.close(),typeof o=="number"?o>0:!0}async clear(){if(!this.isSupported)return;let t=await Ri(this.dbName,this.storeName);await ki(t,this.storeName,"readwrite",r=>r.clear()),t.close()}async list(){if(!this.isSupported)return[];let t=await Ri(this.dbName,this.storeName),r=await ki(t,this.storeName,"readonly",n=>n.getAll());return t.close(),r.sort((n,i)=>i.persistedAt-n.persistedAt)}};var Sr=class extends Error{constructor(r,n){super(n??`Missing dependencies: ${r.join(", ")}`);this.missing=r;this.name="AssetDependencyError"}},Fi=class{constructor(){this.nodes=new Map}register(t,r=[]){let n=this.nodes.get(t)??{dependencies:new Set,loaded:!1};r.forEach(i=>n.dependencies.add(i)),this.nodes.set(t,n),r.forEach(i=>{this.nodes.has(i)||this.nodes.set(i,{dependencies:new Set,loaded:!1})})}markLoaded(t){let r=this.nodes.get(t)??{dependencies:new Set,loaded:!1},n=this.getMissingDependencies(t,r);if(n.length>0)throw new Sr(n,`Asset ${t} is missing dependencies: ${n.join(", ")}`);r.loaded=!0,this.nodes.set(t,r)}markUnloaded(t){let r=this.nodes.get(t);r&&(r.loaded=!1)}isLoaded(t){return this.nodes.get(t)?.loaded??!1}missingDependencies(t){let r=this.nodes.get(t);return r?this.getMissingDependencies(t,r):[]}reset(){this.nodes.clear()}getMissingDependencies(t,r){let n=[];for(let i of r.dependencies)this.nodes.get(i)?.loaded||n.push(i);return n}},cs=class{constructor(t,r={}){this.vfs=t;this.maps=new Map;this.textures=new $r({capacity:r.textureCacheCapacity??128}),this.audio=new fn(t,{cacheSize:r.audioCacheSize??64}),this.dependencyTracker=r.dependencyTracker??new Fi,this.md2=new Wr(t),this.md3=new Xr(t),this.sprite=new Kr(t),this.bsp=new Gr(t),this.palette=new Uint8Array(768);for(let n=0;n<256;n++)this.palette[n*3]=n,this.palette[n*3+1]=n,this.palette[n*3+2]=n}async loadPalette(t="pics/colormap.pcx"){try{let r=await this.vfs.readFile(t),n=Nn(r);n.palette&&(this.palette=n.palette)}catch(r){console.warn(`Failed to load palette from ${t}:`,r)}}isAssetLoaded(t,r){return this.dependencyTracker.isLoaded(this.makeKey(t,r))}registerTexture(t,r){this.textures.set(t,r);let n=this.makeKey("texture",t);this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n)}async loadTexture(t){let r=this.textures.get(t);if(r)return r;let n=await this.vfs.readFile(t),i=t.split(".").pop()?.toLowerCase(),o;if(i==="wal")o=Io(n,this.palette);else if(i==="pcx")o=To(Nn(n));else if(i==="tga")o=jc(Ia(n));else throw new Error(`Unsupported texture format for loadTexture: ${i}`);return this.registerTexture(t,o),o}async loadSound(t){let r=await this.audio.load(t),n=this.makeKey("sound",t);return this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n),r}async loadMd2Model(t,r=[]){let n=this.makeKey("model",t),i=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,i);let o=this.dependencyTracker.missingDependencies(n);if(o.length>0)throw new Sr(o,`Asset ${n} is missing dependencies: ${o.join(", ")}`);let s=await this.md2.load(t);return this.dependencyTracker.markLoaded(n),s}getMd2Model(t){return this.md2.get(t)}async loadMd3Model(t,r=[]){let n=this.makeKey("model",t),i=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,i);let o=this.dependencyTracker.missingDependencies(n);if(o.length>0)throw new Sr(o,`Asset ${n} is missing dependencies: ${o.join(", ")}`);let s=await this.md3.load(t);return this.dependencyTracker.markLoaded(n),s}getMd3Model(t){return this.md3.get(t)}async loadSprite(t){let r=this.makeKey("sprite",t);this.dependencyTracker.register(r);let n=await this.sprite.load(t);return this.dependencyTracker.markLoaded(r),n}async loadMap(t){let r=this.makeKey("map",t);if(this.maps.has(t))return this.maps.get(t);this.dependencyTracker.register(r);let n=await this.bsp.load(t);return this.maps.set(t,n),this.dependencyTracker.markLoaded(r),n}getMap(t){return this.maps.get(t)}listFiles(t){return this.vfs.findByExtension(t)}resetForLevelChange(){this.textures.clear(),this.audio.clearAll(),this.dependencyTracker.reset(),this.maps.clear()}makeKey(t,r){return`${t}:${ae(r)}`}};var Qa=32,ds=(h=>(h[h.Auto=0]="Auto",h[h.Weapon=1]="Weapon",h[h.Voice=2]="Voice",h[h.Item=3]="Item",h[h.Body=4]="Body",h[h.Aux=5]="Aux",h[h.Footstep=6]="Footstep",h[h.Aux3=7]="Aux3",h[h.NoPhsAdd=8]="NoPhsAdd",h[h.Reliable=16]="Reliable",h[h.ForcePos=32]="ForcePos",h))(ds||{}),Td=-1,us=0,Id=1,Cd=2,zd=3,hn=80,Rd=.003;function wr(e){return e===3?e*.001:e*5e-4}function fs(e){let t=wr(e);return t<=0?Number.POSITIVE_INFINITY:80+1/t}var hs=class{constructor(t){this.factory=t}getContext(){return this.context||(this.context=this.factory()),this.context}async resume(){let t=this.getContext();t.state==="suspended"&&await t.resume()}getState(){return this.context?.state??"suspended"}};function ms(e){let t=e.getContext(),r=t.createGain();r.gain.value=1;let n=t.createDynamicsCompressor(),i=t.createBiquadFilter?.();return i?(i.type="lowpass",i.frequency.value=2e4,i.Q.value=.707,r.connect(i),i.connect(n)):r.connect(n),n.connect(t.destination),{context:t,master:r,compressor:n,filter:i}}var ps=class{constructor(t=new Ur){this.configStrings=t;this.buffers=new Map}registerName(t){return this.configStrings.soundIndex(t)}register(t,r){let n=this.registerName(t);return this.buffers.set(n,r),n}find(t){return this.configStrings.findSoundIndex(t)}get(t){return this.buffers.get(t)}has(t){return this.buffers.has(t)}getName(t){return this.configStrings.getName(t)}};var gs=class{constructor(t){this.vfs=t.vfs,this.registry=t.registry,this.contextController=t.context,this.soundRoot=t.soundRoot??"sound/",this.decodeAudio=t.decodeAudio??((r,n)=>{if(!r.decodeAudioData)throw new Error("decodeAudioData is not available on the provided audio context");return r.decodeAudioData(n)})}async precache(t){let r=[...new Set(t.map(o=>this.normalize(o)))],n={loaded:[],skipped:[],missing:[],errors:{}},i=this.contextController.getContext();for(let o of r)try{let s=this.registry.find(o);if(s!==void 0&&this.registry.has(s)){n.skipped.push(o);continue}if(!this.vfs.stat(o)){n.missing.push(o);continue}let l=(await this.vfs.readFile(o)).slice().buffer,c=await this.decodeAudio(i,l);this.registry.register(o,c),n.loaded.push(o)}catch(s){let a=s instanceof Error?s:new Error(String(s));n.errors[o]=a}return n}normalize(t){let r=ae(t.replace(/^\//,""));return r.startsWith(this.soundRoot)?r:ae(`${this.soundRoot}${r}`)}};var lm=7,Di=e=>e&lm;function ys(e){return Array.from({length:32},()=>({entnum:0,entchannel:0,endTimeMs:0,isPlayer:!1,active:!1})).map(t=>({...t,isPlayer:t.entnum===e}))}function xs(e,t,r,n){if(r<0)throw new Error("pickChannel: entchannel must be non-negative");let i=Di(r),o=-1,s=Number.POSITIVE_INFINITY;for(let a=0;a<e.length;a+=1){let d=e[a],l=Di(d.entchannel);if(i!==0&&d.entnum===t&&l===i){o=a;break}if(d.active&&d.entnum===n.playerEntity&&t!==n.playerEntity)continue;let c=d.endTimeMs-n.nowMs;(o===-1||c<s)&&(s=c,o=a)}return o===-1?void 0:o}function _s(e,t,r,n,i){if(i)return{left:r,right:r,distanceComponent:0};let o=bc(e,t.origin),s=ma(o),a=Qe(o),d=s-80;d<0&&(d=0),d*=wr(n);let l=ha(t.right,a),c=t.mono??!1,h=c||n===0?1:.5*(1+l),u=c||n===0?1:.5*(1-l),f=Math.max(0,Math.floor(r*(1-d)*h));return{left:Math.max(0,Math.floor(r*(1-d)*u)),right:f,distanceComponent:d}}var bs=class{constructor(t){this.activeSources=new Map;this.contextController=t.context,this.registry=t.registry,this.playerEntity=t.playerEntity,this.channels=ys(t.playerEntity),this.listener=t.listener??{origin:_c,right:{x:1,y:0,z:0}},this.sfxVolume=t.sfxVolume??1,this.masterVolume=t.masterVolume??1,this.resolveOcclusion=t.resolveOcclusion,this.graph=ms(this.contextController),this.graph.master.gain.value=this.masterVolume}setListener(t){this.listener=t}setMasterVolume(t){this.masterVolume=t,this.graph.master.gain.value=t}setSfxVolume(t){this.sfxVolume=t}async ensureRunning(){await this.contextController.resume()}play(t){let r=this.registry.get(t.soundIndex);if(!r)return;let n=this.graph.context,i=n.currentTime*1e3,o=xs(this.channels,t.entity,t.channel,{nowMs:i,playerEntity:this.playerEntity});if(o===void 0)return;let s=this.activeSources.get(o);s&&(s.source.onended=null,s.source.stop(),this.activeSources.delete(o));let a=n.createBufferSource();a.buffer=r,a.loop=t.looping??!1;let d=t.origin??this.listener.origin,l=n.createGain(),c=this.createPanner(n,t.attenuation),h=this.resolveOcclusion?.(this.listener,d,t.attenuation),u=kd(h?.gainScale??1),f=this.resolveOcclusion?this.createOcclusionFilter(n,h?.lowpassHz??2e4):void 0;this.applyOriginToPanner(c,d);let m=t.entity===this.playerEntity,g=_s(d,this.listener,t.volume,t.attenuation,m),x=(t.volume===0?0:Math.max(g.left,g.right)/Math.max(1,t.volume))*(t.volume/255)*this.masterVolume*this.sfxVolume;l.gain.value=x*u;let S=n.currentTime+(t.timeOffsetMs??0)/1e3,_=(t.looping?Number.POSITIVE_INFINITY:r.duration*1e3)+S*1e3;a.connect(c),f?(c.connect(f),f.connect(l)):c.connect(l),l.connect(this.graph.master),a.start(S),a.onended=()=>{this.channels[o].active=!1,this.activeSources.delete(o)};let y={channelIndex:o,entnum:t.entity,entchannel:Di(t.channel),endTimeMs:_,source:a,panner:c,gain:l,baseGain:x,origin:d,attenuation:t.attenuation,occlusion:f?{scale:u,lowpassHz:h?.lowpassHz,filter:f}:h?{scale:u,lowpassHz:h.lowpassHz}:void 0};return this.channels[o]={entnum:t.entity,entchannel:Di(t.channel),endTimeMs:_,isPlayer:t.entity===this.playerEntity,active:!0},this.activeSources.set(o,y),y}stop(t){let r=this.activeSources.get(t);r&&(r.source.stop(),this.channels[t].active=!1,this.activeSources.delete(t))}stopEntitySounds(t){for(let[r,n]of[...this.activeSources.entries()])n.entnum===t&&(n.source.stop(),this.channels[r].active=!1,this.activeSources.delete(r))}updateEntityPosition(t,r){for(let n of this.activeSources.values())if(n.entnum===t&&(this.applyOriginToPanner(n.panner,r),n.origin=r,this.resolveOcclusion)){let i=this.resolveOcclusion(this.listener,r,n.attenuation);this.applyOcclusion(n,i)}}positionedSound(t,r,n,i){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:i,origin:t})}ambientSound(t,r,n){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:0,origin:t,looping:!0})}getChannelState(t){return this.channels[t]}getDiagnostics(){return{activeChannels:this.activeSources.size,masterVolume:this.masterVolume,sfxVolume:this.sfxVolume,channels:[...this.channels],activeSounds:[...this.activeSources.values()].map(t=>({entnum:t.entnum,entchannel:t.entchannel,channelIndex:t.channelIndex,origin:t.origin,gain:t.gain.gain.value,baseGain:t.baseGain,attenuation:t.attenuation,maxDistance:t.panner.maxDistance,distanceModel:t.panner.distanceModel,occlusion:t.occlusion?{scale:t.occlusion.scale,lowpassHz:t.occlusion.lowpassHz}:void 0}))}}setUnderwater(t,r=400){let n=this.graph.filter;n&&(n.type="lowpass",n.Q.value=.707,n.frequency.value=t?r:2e4)}createPanner(t,r){let n=t.createPanner?t.createPanner():Object.assign(t.createGain(),{positionX:{value:this.listener.origin.x},positionY:{value:this.listener.origin.y},positionZ:{value:this.listener.origin.z}});return this.configurePanner(n,r)}configurePanner(t,r){let n=wr(r);return t.refDistance=80,t.maxDistance=fs(r),t.rolloffFactor=n,t.distanceModel=r===0?"linear":"inverse",t.positionX.value=this.listener.origin.x,t.positionY.value=this.listener.origin.y,t.positionZ.value=this.listener.origin.z,t}applyOriginToPanner(t,r){t.positionX.value=r.x,t.positionY.value=r.y,t.positionZ.value=r.z}createOcclusionFilter(t,r){if(!t.createBiquadFilter)return;let n=t.createBiquadFilter();return n.type="lowpass",n.Q.value=.707,n.frequency.value=Ja(r,10,2e4),n}applyOcclusion(t,r){let n=kd(r?.gainScale??1);if(t.gain.gain.value=t.baseGain*n,t.occlusion?.filter){let i=r?.lowpassHz??2e4;t.occlusion.filter.frequency.value=Ja(i,10,2e4)}t.occlusion?(t.occlusion.scale=n,t.occlusion.lowpassHz=r?.lowpassHz):r&&(t.occlusion={scale:n,lowpassHz:r.lowpassHz})}},Ja=(e,t,r)=>Math.min(r,Math.max(t,e)),kd=e=>Ja(e,0,1);var vs=class{constructor(t){this.createElement=t.createElement,this.resolveSource=t.resolveSource??(async r=>r),this.volume=t.volume??1}async play(t,{loop:r=!0,restart:n=!1}={}){if(this.track===t&&this.element){this.element.loop=r,this.element.volume=this.volume,n&&(this.element.currentTime=0),(this.element.paused||n)&&await this.element.play();return}let i=await this.resolveSource(t),o=this.createElement();o.src=i,o.loop=r,o.volume=this.volume,o.currentTime=0,o.load(),await o.play(),this.element=o,this.track=t}pause(){!this.element||this.element.paused||this.element.pause()}async resume(){!this.element||!this.element.paused||await this.element.play()}stop(){this.element&&(this.element.pause(),this.element.currentTime=0,this.element=void 0,this.track=void 0)}setVolume(t){this.volume=t,this.element&&(this.element.volume=t)}getState(){let t=!!(this.element&&!this.element.paused&&!this.element.ended),r=!!this.element?.paused;return{track:this.track,paused:r,playing:t,volume:this.volume}}};function cm(e){e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}function dm(e,t,r,n){for(let i of t){let o=e.getExtension(i);if(!o)throw new Error(`Missing required WebGL extension: ${i}`);n.set(i,o)}for(let i of r){let o=e.getExtension(i);o&&n.set(i,o)}}function Fd(e,t={}){let{contextAttributes:r,requiredExtensions:n=[],optionalExtensions:i=[]}=t,o=e.getContext("webgl2",r??{antialias:!0});if(!o)throw new Error("WebGL2 not supported or failed to initialize");cm(o);let s=new Map;dm(o,n,i,s);let a=!1,d=new Set,l=new Set,c=u=>{a=!0,u.preventDefault();for(let f of d)f()},h=()=>{a=!1;for(let u of l)u()};return e.addEventListener("webglcontextlost",c),e.addEventListener("webglcontextrestored",h),{gl:o,extensions:s,isLost:()=>a,onLost(u){return d.add(u),()=>d.delete(u)},onRestored(u){return l.add(u),()=>l.delete(u)},dispose(){e.removeEventListener("webglcontextlost",c),e.removeEventListener("webglcontextrestored",h),d.clear(),l.clear(),s.clear()}}}function Dd(e,t,r){let n=e.createShader(t);if(!n)throw new Error("Failed to allocate shader");if(e.shaderSource(n,r),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){let o=e.getShaderInfoLog(n)??"Unknown shader compile failure";throw e.deleteShader(n),new Error(o)}return n}function um(e,t,r,n){let i=e.createProgram();if(!i)throw new Error("Failed to allocate shader program");if(e.attachShader(i,t),e.attachShader(i,r),n)for(let[s,a]of Object.entries(n))e.bindAttribLocation(i,a,s);if(e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)){let s=e.getProgramInfoLog(i)??"Unknown shader link failure";throw e.deleteProgram(i),new Error(s)}return i}var Me=class e{constructor(t,r){this.uniformLocations=new Map;this.attributeLocations=new Map;this.gl=t,this.program=r}static create(t,r,n){let i=Dd(t,t.VERTEX_SHADER,r.vertex),o=Dd(t,t.FRAGMENT_SHADER,r.fragment);try{let s=um(t,i,o,n);return new e(t,s)}finally{t.deleteShader(i),t.deleteShader(o)}}use(){this.gl.useProgram(this.program)}getUniformLocation(t){if(!this.uniformLocations.has(t)){let r=this.gl.getUniformLocation(this.program,t);this.uniformLocations.set(t,r)}return this.uniformLocations.get(t)??null}getAttributeLocation(t){if(!this.attributeLocations.has(t)){let r=this.gl.getAttribLocation(this.program,t);this.attributeLocations.set(t,r)}return this.attributeLocations.get(t)??-1}dispose(){this.gl.deleteProgram(this.program),this.uniformLocations.clear(),this.attributeLocations.clear()}};function Pd(e,t,r){return Me.create(e,t,r)}var Ee=class{constructor(t,r=t.STATIC_DRAW,n){this.gl=t,this.target=n??t.ARRAY_BUFFER;let i=t.createBuffer();if(!i)throw new Error("Failed to allocate buffer");this.buffer=i,t.bindBuffer(this.target,this.buffer),t.bufferData(this.target,0,r)}bind(){this.gl.bindBuffer(this.target,this.buffer)}upload(t,r=this.gl.STATIC_DRAW){this.bind(),this.gl.bufferData(this.target,t,r)}update(t,r=0){this.bind(),this.gl.bufferSubData(this.target,r,t)}dispose(){this.gl.deleteBuffer(this.buffer)}},ye=class extends Ee{constructor(t,r=t.STATIC_DRAW){super(t,r,t.ELEMENT_ARRAY_BUFFER)}},ze=class{constructor(t){this.gl=t;let r=t.createVertexArray();if(!r)throw new Error("Failed to allocate vertex array object");this.vao=r}bind(){this.gl.bindVertexArray(this.vao)}configureAttributes(t,r){this.bind(),r&&r.bind();for(let n of t)this.gl.enableVertexAttribArray(n.index),this.gl.vertexAttribPointer(n.index,n.size,n.type,n.normalized??!1,n.stride??0,n.offset??0),n.divisor!==void 0&&this.gl.vertexAttribDivisor(n.index,n.divisor)}dispose(){this.gl.deleteVertexArray(this.vao)}},mn=class{constructor(t,r=t.TEXTURE_2D){this.width=0;this.height=0;this.gl=t,this.target=r;let n=t.createTexture();if(!n)throw new Error("Failed to allocate texture");this.texture=n}bind(t=0){this.gl.activeTexture(this.gl.TEXTURE0+t),this.gl.bindTexture(this.target,this.texture)}setParameters(t){this.bind(),t.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,t.wrapS),t.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,t.wrapT),t.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,t.minFilter),t.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,t.magFilter)}upload(t,r,n){this.width=t,this.height=r,this.uploadImage(0,this.gl.RGBA,t,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n)}uploadImage(t,r,n,i,o,s,a,d){this.bind(),this.gl.texImage2D(this.target,t,r,n,i,o,s,a,d)}dispose(){this.gl.deleteTexture(this.texture)}},pn=class{constructor(t){this.gl=t,this.target=t.TEXTURE_CUBE_MAP;let r=t.createTexture();if(!r)throw new Error("Failed to allocate cubemap texture");this.texture=r}bind(t=0){this.gl.activeTexture(this.gl.TEXTURE0+t),this.gl.bindTexture(this.target,this.texture)}setParameters(t){this.bind(),t.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,t.wrapS),t.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,t.wrapT),t.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,t.minFilter),t.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,t.magFilter)}uploadFace(t,r,n,i,o,s,a,d,l){this.bind(),this.gl.texImage2D(t,r,n,i,o,s,a,d,l)}dispose(){this.gl.deleteTexture(this.texture)}},Ss=class{constructor(t){this.gl=t;let r=t.createFramebuffer();if(!r)throw new Error("Failed to allocate framebuffer");this.framebuffer=r}bind(t=this.gl.FRAMEBUFFER){this.gl.bindFramebuffer(t,this.framebuffer)}attachTexture2D(t,r,n=0){this.bind(),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,t,r.target,r.texture,n)}dispose(){this.gl.deleteFramebuffer(this.framebuffer)}};var tl=4,el=7*tl,rl=[{index:0,size:3,type:5126,stride:el,offset:0},{index:1,size:2,type:5126,stride:el,offset:3*tl},{index:2,size:2,type:5126,stride:el,offset:5*tl}];function fm(e,t){return{width:e,height:e,padding:t,data:new Uint8Array(e*e*4),cursorX:0,cursorY:0,rowHeight:0}}function hm(e){let t=e.width*e.height;if(t===0)throw new Error("Invalid lightmap with zero area");let r=e.samples.byteLength/t;if(!Number.isInteger(r)||r<3||r>4)throw new Error("Unsupported lightmap channel count");return r}function mm(e,t,r){let n=hm(r),i=e.width*4,o=t.x+e.padding,s=t.y+e.padding,a=0;for(let d=0;d<r.height;d++){let l=(s+d)*i+o*4;for(let c=0;c<r.width;c++){let h=l+c*4;e.data[h]=r.samples[a],e.data[h+1]=r.samples[a+1],e.data[h+2]=r.samples[a+2],e.data[h+3]=n===4?r.samples[a+3]:255,a+=n}}}function pm(e,t,r){let n=t.width+r.lightmapPadding*2,i=t.height+r.lightmapPadding*2;if(n>r.atlasSize||i>r.atlasSize)throw new Error("Lightmap too large for atlas");for(let a of e){if(a.cursorX+n>a.width&&(a.cursorX=0,a.cursorY+=a.rowHeight+r.lightmapPadding,a.rowHeight=0),a.cursorY+i>a.height)continue;let d={atlasIndex:e.indexOf(a),x:a.cursorX,y:a.cursorY,width:t.width,height:t.height};return a.cursorX+=n+r.lightmapPadding,a.rowHeight=Math.max(a.rowHeight,i),{placement:d,atlas:a}}let o=fm(r.atlasSize,r.lightmapPadding);e.push(o);let s={atlasIndex:e.length-1,x:0,y:0,width:t.width,height:t.height};return o.cursorX=n+r.lightmapPadding,o.rowHeight=i,{placement:s,atlas:o}}function ws(e){return e instanceof Float32Array?e:new Float32Array(e)}function gm(e,t){if(!e){let n=new Uint16Array(t);for(let i=0;i<t;i++)n[i]=i;return n}return e instanceof Uint16Array?e:new Uint16Array(e)}function ym(e,t){let r=new Float32Array(e.length);for(let n=0;n<e.length;n+=2)r[n]=t.offset[0]+e[n]*t.scale[0],r[n+1]=t.offset[1]+e[n+1]*t.scale[1];return r}function xm(e,t){let r=ws(e.vertices),n=ws(e.textureCoords),i=t?ym(ws(e.lightmapCoords??e.textureCoords),t):ws(e.lightmapCoords??new Float32Array(n.length)),o=r.length/3;if(n.length/2!==o)throw new Error("Texture coordinates count mismatch");if(i.length/2!==o)throw new Error("Lightmap coordinates count mismatch");let s=new Float32Array(o*7);for(let a=0;a<o;a++){let d=a*3,l=a*2,c=a*7;s[c]=r[d],s[c+1]=r[d+1],s[c+2]=r[d+2],s[c+3]=n[l],s[c+4]=n[l+1],s[c+5]=i[l],s[c+6]=i[l+1]}return s}function Od(e){let t=[];for(let r=0;r<e.faces.length;r++){let n=e.faces[r];if(n.texInfo<0)continue;let i=e.texInfo[n.texInfo],o=[],s=[],a=[];for(let u=0;u<n.numEdges;u++){let f=e.surfEdges[n.firstEdge+u],m=e.edges[Math.abs(f)],g=f>=0?m.vertices[0]:m.vertices[1],p=e.vertices[g];o.push(p[0],p[1],p[2]);let x=p[0]*i.s[0]+p[1]*i.s[1]+p[2]*i.s[2]+i.sOffset,S=p[0]*i.t[0]+p[1]*i.t[1]+p[2]*i.t[2]+i.tOffset;s.push(x,S),a.push(x,S)}let d=[],l=o.length/3;for(let u=1;u<l-1;u++)d.push(0,u,u+1);let c,h=e.lightMapInfo[r];if(h){let u=1/0,f=-1/0,m=1/0,g=-1/0;for(let b=0;b<s.length;b+=2){let A=s[b],v=s[b+1];A<u&&(u=A),A>f&&(f=A),v<m&&(m=v),v>g&&(g=v)}let p=Math.floor(u/16),x=Math.floor(m/16),S=Math.ceil(f/16)-p+1,_=Math.ceil(g/16)-x+1,y=Ao(n,e.lightMaps,h);if(y&&y.length===S*_*3){c={width:S,height:_,samples:y};for(let b=0;b<a.length;b+=2)a[b]=s[b]/16-p+.5,a[b+1]=s[b+1]/16-x+.5}}t.push({vertices:new Float32Array(o),textureCoords:new Float32Array(s),lightmapCoords:new Float32Array(a),indices:new Uint16Array(d),texture:i.texture,surfaceFlags:i.flags,lightmap:c,faceIndex:r})}return t}function Bd(e,t,r,n={}){let i=t;if(r&&n.hiddenClassnames&&n.hiddenClassnames.size>0){let c=new Set;for(let h of r.entities.entities)if(h.classname&&n.hiddenClassnames.has(h.classname)){let u=h.properties.model;if(u&&u.startsWith("*")){let f=parseInt(u.substring(1),10);if(!isNaN(f)&&f>=0&&f<r.models.length){let m=r.models[f];for(let g=0;g<m.numFaces;g++)c.add(m.firstFace+g)}}}c.size>0&&(i=t.filter(h=>!c.has(h.faceIndex)))}let o={atlasSize:n.atlasSize??1024,lightmapPadding:n.lightmapPadding??1,hiddenClassnames:n.hiddenClassnames??new Set},s=[],a=new Map;i.forEach((c,h)=>{if(!c.lightmap)return;let{placement:u,atlas:f}=pm(s,c.lightmap,o);mm(f,u,c.lightmap),a.set(h,{atlasIndex:u.atlasIndex,offset:[(u.x+o.lightmapPadding)/o.atlasSize,(u.y+o.lightmapPadding)/o.atlasSize],scale:[u.width/o.atlasSize,u.height/o.atlasSize]})});let d=s.map(c=>{let h=new mn(e);return h.setParameters({wrapS:e.CLAMP_TO_EDGE,wrapT:e.CLAMP_TO_EDGE,minFilter:e.LINEAR,magFilter:e.LINEAR}),h.uploadImage(0,e.RGBA,c.width,c.height,0,e.RGBA,e.UNSIGNED_BYTE,c.data),{texture:h,width:c.width,height:c.height,pixels:c.data}});return{surfaces:i.map((c,h)=>{let u=a.get(h),f=xm(c,u),m=gm(c.indices,f.length/7),g=new Ee(e,e.STATIC_DRAW,e.ARRAY_BUFFER);g.upload(f);let p=new ye(e,e.STATIC_DRAW);p.upload(m);let x=new ze(e);return x.configureAttributes(rl,g),{vao:x,vertexBuffer:g,indexBuffer:p,indexCount:m.length,vertexCount:f.length/7,texture:c.texture,surfaceFlags:c.surfaceFlags??Rn,lightmap:u,vertexData:f,indexData:m}}),lightmaps:d}}function gn(e){let{normal:t,distance:r}=e,n=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);if(n===0)return e;let i=1/n;return{normal:{x:t.x*i,y:t.y*i,z:t.z*i},distance:r*i}}function Nd(e){if(e.length!==16)throw new Error("View-projection matrix must contain 16 elements");let t=e[0],r=e[4],n=e[8],i=e[12],o=e[1],s=e[5],a=e[9],d=e[13],l=e[2],c=e[6],h=e[10],u=e[14],f=e[3],m=e[7],g=e[11],p=e[15];return[gn({normal:{x:f+t,y:m+r,z:g+n},distance:p+i}),gn({normal:{x:f-t,y:m-r,z:g-n},distance:p-i}),gn({normal:{x:f+o,y:m+s,z:g+a},distance:p+d}),gn({normal:{x:f-o,y:m-s,z:g-a},distance:p-d}),gn({normal:{x:f+l,y:m+c,z:g+h},distance:p+u}),gn({normal:{x:f-l,y:m-c,z:g-h},distance:p-u})]}function _m(e,t){return e.normal.x*t.x+e.normal.y*t.y+e.normal.z*t.z+e.distance}function Pi(e,t,r){for(let n of r){let i=n.normal.x>=0?t.x:e.x,o=n.normal.y>=0?t.y:e.y,s=n.normal.z>=0?t.z:e.z;if(_m(n,{x:i,y:o,z:s})<0)return!1}return!0}function Ud(e){return e<0}function Hd(e){return-e-1}function Vd(e,t){return e.normal[0]*t.x+e.normal[1]*t.y+e.normal[2]*t.z-e.dist}function bm(e,t,r){if(!e||t<0||r<0)return!0;let n=Math.ceil(e.numClusters/8),i=e.clusters[t].pvs,o=Math.floor(r/8),s=1<<r%8;return o<0||o>=n?!1:(i[o]&s)!==0}function vm(e,t){let r={x:e.mins[0],y:e.mins[1],z:e.mins[2]},n={x:e.maxs[0],y:e.maxs[1],z:e.maxs[2]};return Pi(r,n,t)}function il(e,t){let r=0;for(;r>=0;){let n=e.nodes[r],i=e.planes[n.planeIndex],s=Vd(i,t)>=0?0:1,a=n.children[s];if(Ud(a))return Hd(a);r=a}return-1}function Sm(e,t){let r=e.leafs[t],n=[];for(let i=0;i<r.numLeafFaces;i+=1)n.push(e.leafLists.leafFaces[t][i]);return n}function nl(e,t,r,n,i,o,s){if(Ud(t)){let u=Hd(t),f=e.leafs[u];if(!bm(e.visibility,i,f.cluster)||!vm(f,n))return;let m={x:(f.mins[0]+f.maxs[0])*.5,y:(f.mins[1]+f.maxs[1])*.5,z:(f.mins[2]+f.maxs[2])*.5},g=m.x-r.x,p=m.y-r.y,x=m.z-r.z,S=-(g*g+p*p+x*x);for(let _ of Sm(e,u))s.has(_)||(s.add(_),o.push({faceIndex:_,leafIndex:u,sortKey:S}));return}let a=e.nodes[t],d=e.planes[a.planeIndex],l=Vd(d,r),c=l>=0?a.children[0]:a.children[1],h=l>=0?a.children[1]:a.children[0];Pi({x:a.mins[0],y:a.mins[1],z:a.mins[2]},{x:a.maxs[0],y:a.maxs[1],z:a.maxs[2]},n)&&(nl(e,c,r,n,i,o,s),nl(e,h,r,n,i,o,s))}function Gd(e,t,r){let n=il(e,t),i=n>=0?e.leafs[n].cluster:-1,o=[];return nl(e,0,t,r,i,o,new Set),o}var Qt=32;function yn(e){let t=[];for(let r=0;r<e.length;r+=3){let n=e[r],i=e[r+1],o=e[r+2];t.push(n,i,i,o,o,n)}return e instanceof Uint32Array||Math.max(...t)>65535?new Uint32Array(t):new Uint16Array(t)}var ol=`#version 300 es
142
142
  precision highp float;
143
143
 
144
144
  layout(location = 0) in vec3 a_position;
@@ -281,7 +281,7 @@ void main() {
281
281
  }
282
282
 
283
283
  o_color = finalColor;
284
- }`,Wd=[0,255,255,255],wm=[0,-1,-1,-1];function al(e=Wd,t=[]){let r=new Float32Array(4);for(let n=0;n<4;n+=1){let i=e[n]??255;if(i===255){r[n]=0;continue}let o=t[i];r[n]=o!==void 0?o:1}return r}function Am(e){return[-(e*.25%1),0]}function ll(e=zn,t=0){let r=(e&Tc)!==0,n=(e&Mc)!==0,i=(e&Ac)!==0,o=(e&Ec)!==0,s=(e&Lc)!==0,a=o?.33:s?.66:1,d=o||s,l=!d&&!i,c=r?Am(t):[0,0];return{alpha:a,blend:d,depthWrite:l,warp:n,flowOffset:c,sky:i}}var As=class{constructor(t){this.uniformDlights=[];this.gl=t,this.program=Me.create(t,{vertex:ol,fragment:sl},{a_position:0,a_texCoord:1,a_lightmapCoord:2,a_lightmapStep:3}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformTexScroll=this.program.getUniformLocation("u_texScroll"),this.uniformLmScroll=this.program.getUniformLocation("u_lightmapScroll"),this.uniformLightStyles=this.program.getUniformLocation("u_lightStyleFactors"),this.uniformStyleLayerMapping=this.program.getUniformLocation("u_styleLayerMapping"),this.uniformAlpha=this.program.getUniformLocation("u_alpha"),this.uniformApplyLightmap=this.program.getUniformLocation("u_applyLightmap"),this.uniformWarp=this.program.getUniformLocation("u_warp"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformLightmap=this.program.getUniformLocation("u_lightmapAtlas"),this.uniformTime=this.program.getUniformLocation("u_time"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor"),this.uniformNumDlights=this.program.getUniformLocation("u_numDlights");for(let r=0;r<Qt;r++)this.uniformDlights.push({pos:this.program.getUniformLocation(`u_dlights[${r}].position`),color:this.program.getUniformLocation(`u_dlights[${r}].color`),intensity:this.program.getUniformLocation(`u_dlights[${r}].intensity`)})}bind(t){let{modelViewProjection:r,styleIndices:n=Wd,styleLayers:i=wm,styleValues:o=[],diffuseSampler:s=0,lightmapSampler:a,surfaceFlags:d=zn,timeSeconds:l=0,texScroll:c,alpha:h,warp:u,dlights:f=[],renderMode:m}=t,g=ll(d,l),p=al(n,o),x=c?c[0]:g.flowOffset[0],S=c?c[1]:g.flowOffset[1],_=h!==void 0?h:g.alpha,y=u!==void 0?u:g.warp;this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),this.gl.uniform2f(this.uniformTexScroll,x,S),this.gl.uniform2f(this.uniformLmScroll,g.flowOffset[0],g.flowOffset[1]),this.gl.uniform4fv(this.uniformLightStyles,p),this.gl.uniform4fv(this.uniformStyleLayerMapping,i),this.gl.uniform1f(this.uniformAlpha,_);let b=!g.sky&&a!==void 0;this.gl.uniform1i(this.uniformApplyLightmap,b?1:0),this.gl.uniform1i(this.uniformWarp,y?1:0),this.gl.uniform1f(this.uniformTime,l),this.gl.uniform1i(this.uniformDiffuse,s),this.gl.uniform1i(this.uniformLightmap,a??0);let A=0,v=[1,1,1,1];m&&(m.mode==="solid"||m.mode==="wireframe"?A=1:m.mode==="solid-faceted"&&(A=2),m.color?v=[...m.color]:m.generateRandomColor&&(v=[1,1,1,1])),this.gl.uniform1i(this.uniformRenderMode,A),this.gl.uniform4f(this.uniformSolidColor,v[0],v[1],v[2],v[3]);let E=Math.min(f.length,Qt);this.gl.uniform1i(this.uniformNumDlights,E);for(let L=0;L<E;L++){let w=f[L];this.gl.uniform3f(this.uniformDlights[L].pos,w.origin.x,w.origin.y,w.origin.z),this.gl.uniform3f(this.uniformDlights[L].color,w.color.x,w.color.y,w.color.z),this.gl.uniform1f(this.uniformDlights[L].intensity,w.intensity)}return g}draw(t,r){if(t.vao.bind(),r&&r.mode==="wireframe"){if(!t.wireframeIndexBuffer){let n=t;n.wireframeIndexBuffer=new ye(this.gl,this.gl.STATIC_DRAW);let i=yn(t.indexData);n.wireframeIndexBuffer.upload(i),n.wireframeIndexCount=i.length}t.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,t.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else t.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,t.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};function Xd(e,t){e.depthMask(t.depthWrite),t.blend?(e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)):e.disable(e.BLEND)}var Kd=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,1,1,1,-1,1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,-1,1,-1,-1,1]),cl=`#version 300 es
284
+ }`,Wd=[0,255,255,255],wm=[0,-1,-1,-1];function al(e=Wd,t=[]){let r=new Float32Array(4);for(let n=0;n<4;n+=1){let i=e[n]??255;if(i===255){r[n]=0;continue}let o=t[i];r[n]=o!==void 0?o:1}return r}function Am(e){return[-(e*.25%1),0]}function ll(e=Rn,t=0){let r=(e&Tc)!==0,n=(e&Mc)!==0,i=(e&Ac)!==0,o=(e&Ec)!==0,s=(e&Lc)!==0,a=o?.33:s?.66:1,d=o||s,l=!d&&!i,c=r?Am(t):[0,0];return{alpha:a,blend:d,depthWrite:l,warp:n,flowOffset:c,sky:i}}var As=class{constructor(t){this.uniformDlights=[];this.gl=t,this.program=Me.create(t,{vertex:ol,fragment:sl},{a_position:0,a_texCoord:1,a_lightmapCoord:2,a_lightmapStep:3}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformTexScroll=this.program.getUniformLocation("u_texScroll"),this.uniformLmScroll=this.program.getUniformLocation("u_lightmapScroll"),this.uniformLightStyles=this.program.getUniformLocation("u_lightStyleFactors"),this.uniformStyleLayerMapping=this.program.getUniformLocation("u_styleLayerMapping"),this.uniformAlpha=this.program.getUniformLocation("u_alpha"),this.uniformApplyLightmap=this.program.getUniformLocation("u_applyLightmap"),this.uniformWarp=this.program.getUniformLocation("u_warp"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformLightmap=this.program.getUniformLocation("u_lightmapAtlas"),this.uniformTime=this.program.getUniformLocation("u_time"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor"),this.uniformNumDlights=this.program.getUniformLocation("u_numDlights");for(let r=0;r<Qt;r++)this.uniformDlights.push({pos:this.program.getUniformLocation(`u_dlights[${r}].position`),color:this.program.getUniformLocation(`u_dlights[${r}].color`),intensity:this.program.getUniformLocation(`u_dlights[${r}].intensity`)})}bind(t){let{modelViewProjection:r,styleIndices:n=Wd,styleLayers:i=wm,styleValues:o=[],diffuseSampler:s=0,lightmapSampler:a,surfaceFlags:d=Rn,timeSeconds:l=0,texScroll:c,alpha:h,warp:u,dlights:f=[],renderMode:m}=t,g=ll(d,l),p=al(n,o),x=c?c[0]:g.flowOffset[0],S=c?c[1]:g.flowOffset[1],_=h!==void 0?h:g.alpha,y=u!==void 0?u:g.warp;this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),this.gl.uniform2f(this.uniformTexScroll,x,S),this.gl.uniform2f(this.uniformLmScroll,g.flowOffset[0],g.flowOffset[1]),this.gl.uniform4fv(this.uniformLightStyles,p),this.gl.uniform4fv(this.uniformStyleLayerMapping,i),this.gl.uniform1f(this.uniformAlpha,_);let b=!g.sky&&a!==void 0;this.gl.uniform1i(this.uniformApplyLightmap,b?1:0),this.gl.uniform1i(this.uniformWarp,y?1:0),this.gl.uniform1f(this.uniformTime,l),this.gl.uniform1i(this.uniformDiffuse,s),this.gl.uniform1i(this.uniformLightmap,a??0);let A=0,v=[1,1,1,1];m&&(m.mode==="solid"||m.mode==="wireframe"?A=1:m.mode==="solid-faceted"&&(A=2),m.color?v=[...m.color]:m.generateRandomColor&&(v=[1,1,1,1])),this.gl.uniform1i(this.uniformRenderMode,A),this.gl.uniform4f(this.uniformSolidColor,v[0],v[1],v[2],v[3]);let E=Math.min(f.length,Qt);this.gl.uniform1i(this.uniformNumDlights,E);for(let L=0;L<E;L++){let w=f[L];this.gl.uniform3f(this.uniformDlights[L].pos,w.origin.x,w.origin.y,w.origin.z),this.gl.uniform3f(this.uniformDlights[L].color,w.color.x,w.color.y,w.color.z),this.gl.uniform1f(this.uniformDlights[L].intensity,w.intensity)}return g}draw(t,r){if(t.vao.bind(),r&&r.mode==="wireframe"){if(!t.wireframeIndexBuffer){let n=t;n.wireframeIndexBuffer=new ye(this.gl,this.gl.STATIC_DRAW);let i=yn(t.indexData);n.wireframeIndexBuffer.upload(i),n.wireframeIndexCount=i.length}t.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,t.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else t.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,t.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};function Xd(e,t){e.depthMask(t.depthWrite),t.blend?(e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)):e.disable(e.BLEND)}var Kd=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,1,1,1,-1,1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,-1,1,-1,-1,1]),cl=`#version 300 es
285
285
  precision highp float;
286
286
 
287
287
  layout(location = 0) in vec3 a_position;
@@ -306,7 +306,7 @@ out vec4 o_color;
306
306
 
307
307
  void main() {
308
308
  o_color = texture(u_skybox, v_direction);
309
- }`,Ms=class{constructor(t){this.gl=t,this.program=Me.create(t,{vertex:cl,fragment:dl},{a_position:0}),this.vao=new Ce(t),this.vbo=new Ee(t,t.STATIC_DRAW),this.vbo.upload(Kd,t.STATIC_DRAW);let r=[{index:0,size:3,type:t.FLOAT,stride:12,offset:0}];this.vao.configureAttributes(r,this.vbo),this.uniformViewProj=this.program.getUniformLocation("u_viewProjectionNoTranslation"),this.uniformScroll=this.program.getUniformLocation("u_scroll"),this.uniformSampler=this.program.getUniformLocation("u_skybox"),this.cubemap=new pn(t),this.cubemap.setParameters({minFilter:t.LINEAR,magFilter:t.LINEAR,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE})}bind(t){let{viewProjection:r,scroll:n,textureUnit:i=0}=t;this.program.use(),this.gl.depthMask(!1),this.gl.uniformMatrix4fv(this.uniformViewProj,!1,r),this.gl.uniform2f(this.uniformScroll,n[0],n[1]),this.gl.uniform1i(this.uniformSampler,i),this.cubemap.bind(i),this.vao.bind()}draw(){this.gl.drawArrays(this.gl.TRIANGLES,0,Kd.length/3)}dispose(){this.vbo.dispose(),this.vao.dispose(),this.cubemap.dispose(),this.program.dispose()}};function $d(e){let t=new Float32Array(e);return t[12]=0,t[13]=0,t[14]=0,t}function Zd(e,t=[.01,.02]){let[r,n]=t;return[r*e,n*e]}var fl=`#version 300 es
309
+ }`,Ms=class{constructor(t){this.gl=t,this.program=Me.create(t,{vertex:cl,fragment:dl},{a_position:0}),this.vao=new ze(t),this.vbo=new Ee(t,t.STATIC_DRAW),this.vbo.upload(Kd,t.STATIC_DRAW);let r=[{index:0,size:3,type:t.FLOAT,stride:12,offset:0}];this.vao.configureAttributes(r,this.vbo),this.uniformViewProj=this.program.getUniformLocation("u_viewProjectionNoTranslation"),this.uniformScroll=this.program.getUniformLocation("u_scroll"),this.uniformSampler=this.program.getUniformLocation("u_skybox"),this.cubemap=new pn(t),this.cubemap.setParameters({minFilter:t.LINEAR,magFilter:t.LINEAR,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE})}bind(t){let{viewProjection:r,scroll:n,textureUnit:i=0}=t;this.program.use(),this.gl.depthMask(!1),this.gl.uniformMatrix4fv(this.uniformViewProj,!1,r),this.gl.uniform2f(this.uniformScroll,n[0],n[1]),this.gl.uniform1i(this.uniformSampler,i),this.cubemap.bind(i),this.vao.bind()}draw(){this.gl.drawArrays(this.gl.TRIANGLES,0,Kd.length/3)}dispose(){this.vbo.dispose(),this.vao.dispose(),this.cubemap.dispose(),this.program.dispose()}};function $d(e){let t=new Float32Array(e);return t[12]=0,t[13]=0,t[14]=0,t}function Zd(e,t=[.01,.02]){let[r,n]=t;return[r*e,n*e]}var fl=`#version 300 es
310
310
  precision highp float;
311
311
 
312
312
  layout(location = 0) in vec3 a_position;
@@ -394,7 +394,7 @@ void main() {
394
394
  }
395
395
 
396
396
  o_color = finalColor;
397
- }`;function Mm(e){let t=e.x*e.x+e.y*e.y+e.z*e.z;if(t<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(t);return{x:e.x*r,y:e.y*r,z:e.z*r}}function ul(e,t,r){return e+(t-e)*r}function Yd(e,t,r){return{x:ul(e.x,t.x,r),y:ul(e.y,t.y,r),z:ul(e.z,t.z,r)}}function Em(e,t,r){return[e/r.skinWidth,1-t/r.skinHeight]}function ml(e){if(e.glCommands.length===0){let n=[],i=[];return e.triangles.forEach(o=>{let s=n.length;for(let a=0;a<3;a+=1){let d=o.vertexIndices[a],l=o.texCoordIndices[a],c=e.texCoords[l];n.push({vertexIndex:d,texCoord:Em(c.s,c.t,e.header)})}i.push(s,s+1,s+2)}),{vertices:n,indices:new Uint16Array(i)}}let t=[],r=[];for(let n of e.glCommands){let i=t.length;if(t.push(...n.vertices.map(o=>({vertexIndex:o.vertexIndex,texCoord:[o.s,1-o.t]}))),n.mode==="strip")for(let o=0;o<n.vertices.length-2;o+=1){let s=o%2===0,a=i+o+(s?0:1),d=i+o+(s?1:0),l=i+o+2;r.push(a,d,l)}else for(let o=1;o<n.vertices.length-1;o+=1)r.push(i,i+o,i+o+1)}return{vertices:t,indices:new Uint16Array(r)}}function pl(e,t,r){let{frame0:n,frame1:i,lerp:o}=r,s=e.frames[n],a=e.frames[i];if(!s||!a)throw new Error("Requested MD2 frames are out of range");let d=new Float32Array(t.vertices.length*8);return t.vertices.forEach((l,c)=>{let h=s.vertices[l.vertexIndex],u=a.vertices[l.vertexIndex];if(!h||!u)throw new Error("MD2 vertex index out of range for frame");let f=Yd(h.position,u.position,o),m=Mm(Yd(h.normal,u.normal,o)),g=c*8;d[g]=f.x,d[g+1]=f.y,d[g+2]=f.z,d[g+3]=m.x,d[g+4]=m.y,d[g+5]=m.z,d[g+6]=l.texCoord[0],d[g+7]=l.texCoord[1]}),d}var Es=class{constructor(t,r,n){this.gl=t,this.geometry=ml(r),this.vertexBuffer=new Ee(t,t.STATIC_DRAW),this.indexBuffer=new ye(t,t.STATIC_DRAW),this.vertexArray=new Ce(t),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:t.FLOAT,stride:32,offset:0},{index:1,size:3,type:t.FLOAT,stride:32,offset:12},{index:2,size:2,type:t.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,t.STATIC_DRAW),this.update(r,n)}update(t,r){let n=pl(t,this.geometry,r);this.vertexBuffer.upload(n,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose(),this.wireframeIndexBuffer?.dispose()}},Ls=class{constructor(t){this.uniformDlights=[];this.gl=t,this.program=Me.create(t,{vertex:fl,fragment:hl},{a_position:0,a_normal:1,a_texCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformModelMatrix=this.program.getUniformLocation("u_modelMatrix"),this.uniformLightDir=this.program.getUniformLocation("u_lightDir"),this.uniformAmbient=this.program.getUniformLocation("u_ambient"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor"),this.uniformNumDlights=this.program.getUniformLocation("u_numDlights");for(let r=0;r<Qt;r++)this.uniformDlights.push({pos:this.program.getUniformLocation(`u_dlights[${r}].position`),color:this.program.getUniformLocation(`u_dlights[${r}].color`),intensity:this.program.getUniformLocation(`u_dlights[${r}].intensity`)})}bind(t){let{modelViewProjection:r,modelMatrix:n,lightDirection:i=[0,0,1],ambientLight:o=.2,tint:s=[1,1,1,1],diffuseSampler:a=0,dlights:d=[],renderMode:l}=t,c=new Float32Array(i),h=new Float32Array(s);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),n?this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,n):this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])),this.gl.uniform3fv(this.uniformLightDir,c),this.gl.uniform1f(this.uniformAmbient,o),this.gl.uniform4fv(this.uniformTint,h),this.gl.uniform1i(this.uniformDiffuse,a);let u=0,f=[1,1,1,1];l&&(l.mode==="solid"||l.mode==="wireframe"?u=1:l.mode==="solid-faceted"&&(u=2),l.color?f=[...l.color]:l.generateRandomColor),this.gl.uniform1i(this.uniformRenderMode,u),this.gl.uniform4f(this.uniformSolidColor,f[0],f[1],f[2],f[3]);let m=Math.min(d.length,Qt);this.gl.uniform1i(this.uniformNumDlights,m);for(let g=0;g<m;g++){let p=d[g];this.gl.uniform3f(this.uniformDlights[g].pos,p.origin.x,p.origin.y,p.origin.z),this.gl.uniform3f(this.uniformDlights[g].color,p.color.x,p.color.y,p.color.z),this.gl.uniform1f(this.uniformDlights[g].intensity,p.intensity)}}draw(t,r){if(t.vertexArray.bind(),r&&r.mode==="wireframe"){if(!t.wireframeIndexBuffer){t.wireframeIndexBuffer=new ye(this.gl,this.gl.STATIC_DRAW);let n=yn(t.geometry.indices);t.wireframeIndexBuffer.upload(n),t.wireframeIndexCount=n.length}t.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,t.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else t.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,t.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var J=1e-6,Ye=typeof Float32Array<"u"?Float32Array:Array,gl=Math.random;function Ts(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var IS=Math.PI/180,RS=180/Math.PI;var de={};ua(de,{add:()=>up,adjoint:()=>Fm,clone:()=>Tm,copy:()=>Im,create:()=>Lm,decompose:()=>jm,determinant:()=>Pm,equals:()=>pp,exactEquals:()=>mp,frob:()=>dp,fromQuat:()=>ep,fromQuat2:()=>Zm,fromRotation:()=>Wm,fromRotationTranslation:()=>Jd,fromRotationTranslationScale:()=>Qm,fromRotationTranslationScaleOrigin:()=>Jm,fromScaling:()=>Gm,fromTranslation:()=>Vm,fromValues:()=>Rm,fromXRotation:()=>Xm,fromYRotation:()=>Km,fromZRotation:()=>$m,frustum:()=>tp,getRotation:()=>qm,getScaling:()=>e0,getTranslation:()=>Ym,identity:()=>jd,invert:()=>km,lookAt:()=>ap,mul:()=>gp,multiply:()=>Qd,multiplyScalar:()=>fp,multiplyScalarAndAdd:()=>hp,ortho:()=>op,orthoNO:()=>r0,orthoZO:()=>sp,perspective:()=>rp,perspectiveFromFieldOfView:()=>ip,perspectiveNO:()=>t0,perspectiveZO:()=>np,rotate:()=>Bm,rotateX:()=>Nm,rotateY:()=>Um,rotateZ:()=>Hm,scale:()=>Om,set:()=>Cm,str:()=>cp,sub:()=>yp,subtract:()=>n0,targetTo:()=>lp,translate:()=>Dm,transpose:()=>zm});function Lm(){var e=new Ye(16);return Ye!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Tm(e){var t=new Ye(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Im(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Rm(e,t,r,n,i,o,s,a,d,l,c,h,u,f,m,g){var p=new Ye(16);return p[0]=e,p[1]=t,p[2]=r,p[3]=n,p[4]=i,p[5]=o,p[6]=s,p[7]=a,p[8]=d,p[9]=l,p[10]=c,p[11]=h,p[12]=u,p[13]=f,p[14]=m,p[15]=g,p}function Cm(e,t,r,n,i,o,s,a,d,l,c,h,u,f,m,g,p){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=o,e[5]=s,e[6]=a,e[7]=d,e[8]=l,e[9]=c,e[10]=h,e[11]=u,e[12]=f,e[13]=m,e[14]=g,e[15]=p,e}function jd(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function zm(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=i,e[13]=s,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function km(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],s=t[4],a=t[5],d=t[6],l=t[7],c=t[8],h=t[9],u=t[10],f=t[11],m=t[12],g=t[13],p=t[14],x=t[15],S=r*a-n*s,_=r*d-i*s,y=r*l-o*s,b=n*d-i*a,A=n*l-o*a,v=i*l-o*d,E=c*g-h*m,L=c*p-u*m,w=c*x-f*m,T=h*p-u*g,z=h*x-f*g,U=u*x-f*p,C=S*U-_*z+y*T+b*w-A*L+v*E;return C?(C=1/C,e[0]=(a*U-d*z+l*T)*C,e[1]=(i*z-n*U-o*T)*C,e[2]=(g*v-p*A+x*b)*C,e[3]=(u*A-h*v-f*b)*C,e[4]=(d*w-s*U-l*L)*C,e[5]=(r*U-i*w+o*L)*C,e[6]=(p*y-m*v-x*_)*C,e[7]=(c*v-u*y+f*_)*C,e[8]=(s*z-a*w+l*E)*C,e[9]=(n*w-r*z-o*E)*C,e[10]=(m*A-g*y+x*S)*C,e[11]=(h*y-c*A-f*S)*C,e[12]=(a*L-s*T-d*E)*C,e[13]=(r*T-n*L+i*E)*C,e[14]=(g*_-m*b-p*S)*C,e[15]=(c*b-h*_+u*S)*C,e):null}function Fm(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],s=t[4],a=t[5],d=t[6],l=t[7],c=t[8],h=t[9],u=t[10],f=t[11],m=t[12],g=t[13],p=t[14],x=t[15],S=r*a-n*s,_=r*d-i*s,y=r*l-o*s,b=n*d-i*a,A=n*l-o*a,v=i*l-o*d,E=c*g-h*m,L=c*p-u*m,w=c*x-f*m,T=h*p-u*g,z=h*x-f*g,U=u*x-f*p;return e[0]=a*U-d*z+l*T,e[1]=i*z-n*U-o*T,e[2]=g*v-p*A+x*b,e[3]=u*A-h*v-f*b,e[4]=d*w-s*U-l*L,e[5]=r*U-i*w+o*L,e[6]=p*y-m*v-x*_,e[7]=c*v-u*y+f*_,e[8]=s*z-a*w+l*E,e[9]=n*w-r*z-o*E,e[10]=m*A-g*y+x*S,e[11]=h*y-c*A-f*S,e[12]=a*L-s*T-d*E,e[13]=r*T-n*L+i*E,e[14]=g*_-m*b-p*S,e[15]=c*b-h*_+u*S,e}function Pm(e){var t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],s=e[5],a=e[6],d=e[7],l=e[8],c=e[9],h=e[10],u=e[11],f=e[12],m=e[13],g=e[14],p=e[15],x=t*s-r*o,S=t*a-n*o,_=r*a-n*s,y=l*m-c*f,b=l*g-h*f,A=c*g-h*m,v=t*A-r*b+n*y,E=o*A-s*b+a*y,L=l*_-c*S+h*x,w=f*_-m*S+g*x;return d*v-i*E+p*L-u*w}function Qd(e,t,r){var n=t[0],i=t[1],o=t[2],s=t[3],a=t[4],d=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],m=t[11],g=t[12],p=t[13],x=t[14],S=t[15],_=r[0],y=r[1],b=r[2],A=r[3];return e[0]=_*n+y*a+b*h+A*g,e[1]=_*i+y*d+b*u+A*p,e[2]=_*o+y*l+b*f+A*x,e[3]=_*s+y*c+b*m+A*S,_=r[4],y=r[5],b=r[6],A=r[7],e[4]=_*n+y*a+b*h+A*g,e[5]=_*i+y*d+b*u+A*p,e[6]=_*o+y*l+b*f+A*x,e[7]=_*s+y*c+b*m+A*S,_=r[8],y=r[9],b=r[10],A=r[11],e[8]=_*n+y*a+b*h+A*g,e[9]=_*i+y*d+b*u+A*p,e[10]=_*o+y*l+b*f+A*x,e[11]=_*s+y*c+b*m+A*S,_=r[12],y=r[13],b=r[14],A=r[15],e[12]=_*n+y*a+b*h+A*g,e[13]=_*i+y*d+b*u+A*p,e[14]=_*o+y*l+b*f+A*x,e[15]=_*s+y*c+b*m+A*S,e}function Dm(e,t,r){var n=r[0],i=r[1],o=r[2],s,a,d,l,c,h,u,f,m,g,p,x;return t===e?(e[12]=t[0]*n+t[4]*i+t[8]*o+t[12],e[13]=t[1]*n+t[5]*i+t[9]*o+t[13],e[14]=t[2]*n+t[6]*i+t[10]*o+t[14],e[15]=t[3]*n+t[7]*i+t[11]*o+t[15]):(s=t[0],a=t[1],d=t[2],l=t[3],c=t[4],h=t[5],u=t[6],f=t[7],m=t[8],g=t[9],p=t[10],x=t[11],e[0]=s,e[1]=a,e[2]=d,e[3]=l,e[4]=c,e[5]=h,e[6]=u,e[7]=f,e[8]=m,e[9]=g,e[10]=p,e[11]=x,e[12]=s*n+c*i+m*o+t[12],e[13]=a*n+h*i+g*o+t[13],e[14]=d*n+u*i+p*o+t[14],e[15]=l*n+f*i+x*o+t[15]),e}function Om(e,t,r){var n=r[0],i=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Bm(e,t,r,n){var i=n[0],o=n[1],s=n[2],a=Math.sqrt(i*i+o*o+s*s),d,l,c,h,u,f,m,g,p,x,S,_,y,b,A,v,E,L,w,T,z,U,C,$;return a<J?null:(a=1/a,i*=a,o*=a,s*=a,d=Math.sin(r),l=Math.cos(r),c=1-l,h=t[0],u=t[1],f=t[2],m=t[3],g=t[4],p=t[5],x=t[6],S=t[7],_=t[8],y=t[9],b=t[10],A=t[11],v=i*i*c+l,E=o*i*c+s*d,L=s*i*c-o*d,w=i*o*c-s*d,T=o*o*c+l,z=s*o*c+i*d,U=i*s*c+o*d,C=o*s*c-i*d,$=s*s*c+l,e[0]=h*v+g*E+_*L,e[1]=u*v+p*E+y*L,e[2]=f*v+x*E+b*L,e[3]=m*v+S*E+A*L,e[4]=h*w+g*T+_*z,e[5]=u*w+p*T+y*z,e[6]=f*w+x*T+b*z,e[7]=m*w+S*T+A*z,e[8]=h*U+g*C+_*$,e[9]=u*U+p*C+y*$,e[10]=f*U+x*C+b*$,e[11]=m*U+S*C+A*$,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Nm(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[4],s=t[5],a=t[6],d=t[7],l=t[8],c=t[9],h=t[10],u=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+l*n,e[5]=s*i+c*n,e[6]=a*i+h*n,e[7]=d*i+u*n,e[8]=l*i-o*n,e[9]=c*i-s*n,e[10]=h*i-a*n,e[11]=u*i-d*n,e}function Um(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],s=t[1],a=t[2],d=t[3],l=t[8],c=t[9],h=t[10],u=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-l*n,e[1]=s*i-c*n,e[2]=a*i-h*n,e[3]=d*i-u*n,e[8]=o*n+l*i,e[9]=s*n+c*i,e[10]=a*n+h*i,e[11]=d*n+u*i,e}function Hm(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],s=t[1],a=t[2],d=t[3],l=t[4],c=t[5],h=t[6],u=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i+l*n,e[1]=s*i+c*n,e[2]=a*i+h*n,e[3]=d*i+u*n,e[4]=l*i-o*n,e[5]=c*i-s*n,e[6]=h*i-a*n,e[7]=u*i-d*n,e}function Vm(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Gm(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Wm(e,t,r){var n=r[0],i=r[1],o=r[2],s=Math.sqrt(n*n+i*i+o*o),a,d,l;return s<J?null:(s=1/s,n*=s,i*=s,o*=s,a=Math.sin(t),d=Math.cos(t),l=1-d,e[0]=n*n*l+d,e[1]=i*n*l+o*a,e[2]=o*n*l-i*a,e[3]=0,e[4]=n*i*l-o*a,e[5]=i*i*l+d,e[6]=o*i*l+n*a,e[7]=0,e[8]=n*o*l+i*a,e[9]=i*o*l-n*a,e[10]=o*o*l+d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Xm(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Km(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function $m(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Jd(e,t,r){var n=t[0],i=t[1],o=t[2],s=t[3],a=n+n,d=i+i,l=o+o,c=n*a,h=n*d,u=n*l,f=i*d,m=i*l,g=o*l,p=s*a,x=s*d,S=s*l;return e[0]=1-(f+g),e[1]=h+S,e[2]=u-x,e[3]=0,e[4]=h-S,e[5]=1-(c+g),e[6]=m+p,e[7]=0,e[8]=u+x,e[9]=m-p,e[10]=1-(c+f),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Zm(e,t){var r=new Ye(3),n=-t[0],i=-t[1],o=-t[2],s=t[3],a=t[4],d=t[5],l=t[6],c=t[7],h=n*n+i*i+o*o+s*s;return h>0?(r[0]=(a*s+c*n+d*o-l*i)*2/h,r[1]=(d*s+c*i+l*n-a*o)*2/h,r[2]=(l*s+c*o+a*i-d*n)*2/h):(r[0]=(a*s+c*n+d*o-l*i)*2,r[1]=(d*s+c*i+l*n-a*o)*2,r[2]=(l*s+c*o+a*i-d*n)*2),Jd(e,t,r),e}function Ym(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function e0(e,t){var r=t[0],n=t[1],i=t[2],o=t[4],s=t[5],a=t[6],d=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(d*d+l*l+c*c),e}function qm(e,t){var r=new Ye(3);e0(r,t);var n=1/r[0],i=1/r[1],o=1/r[2],s=t[0]*n,a=t[1]*i,d=t[2]*o,l=t[4]*n,c=t[5]*i,h=t[6]*o,u=t[8]*n,f=t[9]*i,m=t[10]*o,g=s+c+m,p=0;return g>0?(p=Math.sqrt(g+1)*2,e[3]=.25*p,e[0]=(h-f)/p,e[1]=(u-d)/p,e[2]=(a-l)/p):s>c&&s>m?(p=Math.sqrt(1+s-c-m)*2,e[3]=(h-f)/p,e[0]=.25*p,e[1]=(a+l)/p,e[2]=(u+d)/p):c>m?(p=Math.sqrt(1+c-s-m)*2,e[3]=(u-d)/p,e[0]=(a+l)/p,e[1]=.25*p,e[2]=(h+f)/p):(p=Math.sqrt(1+m-s-c)*2,e[3]=(a-l)/p,e[0]=(u+d)/p,e[1]=(h+f)/p,e[2]=.25*p),e}function jm(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];var i=n[0],o=n[1],s=n[2],a=n[4],d=n[5],l=n[6],c=n[8],h=n[9],u=n[10];r[0]=Math.sqrt(i*i+o*o+s*s),r[1]=Math.sqrt(a*a+d*d+l*l),r[2]=Math.sqrt(c*c+h*h+u*u);var f=1/r[0],m=1/r[1],g=1/r[2],p=i*f,x=o*m,S=s*g,_=a*f,y=d*m,b=l*g,A=c*f,v=h*m,E=u*g,L=p+y+E,w=0;return L>0?(w=Math.sqrt(L+1)*2,e[3]=.25*w,e[0]=(b-v)/w,e[1]=(A-S)/w,e[2]=(x-_)/w):p>y&&p>E?(w=Math.sqrt(1+p-y-E)*2,e[3]=(b-v)/w,e[0]=.25*w,e[1]=(x+_)/w,e[2]=(A+S)/w):y>E?(w=Math.sqrt(1+y-p-E)*2,e[3]=(A-S)/w,e[0]=(x+_)/w,e[1]=.25*w,e[2]=(b+v)/w):(w=Math.sqrt(1+E-p-y)*2,e[3]=(x-_)/w,e[0]=(A+S)/w,e[1]=(b+v)/w,e[2]=.25*w),e}function Qm(e,t,r,n){var i=t[0],o=t[1],s=t[2],a=t[3],d=i+i,l=o+o,c=s+s,h=i*d,u=i*l,f=i*c,m=o*l,g=o*c,p=s*c,x=a*d,S=a*l,_=a*c,y=n[0],b=n[1],A=n[2];return e[0]=(1-(m+p))*y,e[1]=(u+_)*y,e[2]=(f-S)*y,e[3]=0,e[4]=(u-_)*b,e[5]=(1-(h+p))*b,e[6]=(g+x)*b,e[7]=0,e[8]=(f+S)*A,e[9]=(g-x)*A,e[10]=(1-(h+m))*A,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Jm(e,t,r,n,i){var o=t[0],s=t[1],a=t[2],d=t[3],l=o+o,c=s+s,h=a+a,u=o*l,f=o*c,m=o*h,g=s*c,p=s*h,x=a*h,S=d*l,_=d*c,y=d*h,b=n[0],A=n[1],v=n[2],E=i[0],L=i[1],w=i[2],T=(1-(g+x))*b,z=(f+y)*b,U=(m-_)*b,C=(f-y)*A,$=(1-(u+x))*A,Te=(p+S)*A,ir=(m+_)*v,co=(p-S)*v,Tn=(1-(u+g))*v;return e[0]=T,e[1]=z,e[2]=U,e[3]=0,e[4]=C,e[5]=$,e[6]=Te,e[7]=0,e[8]=ir,e[9]=co,e[10]=Tn,e[11]=0,e[12]=r[0]+E-(T*E+C*L+ir*w),e[13]=r[1]+L-(z*E+$*L+co*w),e[14]=r[2]+w-(U*E+Te*L+Tn*w),e[15]=1,e}function ep(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],s=r+r,a=n+n,d=i+i,l=r*s,c=n*s,h=n*a,u=i*s,f=i*a,m=i*d,g=o*s,p=o*a,x=o*d;return e[0]=1-h-m,e[1]=c+x,e[2]=u-p,e[3]=0,e[4]=c-x,e[5]=1-l-m,e[6]=f+g,e[7]=0,e[8]=u+p,e[9]=f-g,e[10]=1-l-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function tp(e,t,r,n,i,o,s){var a=1/(r-t),d=1/(i-n),l=1/(o-s);return e[0]=o*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*d,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(i+n)*d,e[10]=(s+o)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*l,e[15]=0,e}function t0(e,t,r,n,i){var o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var s=1/(n-i);e[10]=(i+n)*s,e[14]=2*i*n*s}else e[10]=-1,e[14]=-2*n;return e}var rp=t0;function np(e,t,r,n,i){var o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var s=1/(n-i);e[10]=i*s,e[14]=i*n*s}else e[10]=-1,e[14]=-n;return e}function ip(e,t,r,n){var i=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),d=2/(s+a),l=2/(i+o);return e[0]=d,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-((s-a)*d*.5),e[9]=(i-o)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function r0(e,t,r,n,i,o,s){var a=1/(t-r),d=1/(n-i),l=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*d,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*d,e[14]=(s+o)*l,e[15]=1,e}var op=r0;function sp(e,t,r,n,i,o,s){var a=1/(t-r),d=1/(n-i),l=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*d,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*d,e[14]=o*l,e[15]=1,e}function ap(e,t,r,n){var i,o,s,a,d,l,c,h,u,f,m=t[0],g=t[1],p=t[2],x=n[0],S=n[1],_=n[2],y=r[0],b=r[1],A=r[2];return Math.abs(m-y)<J&&Math.abs(g-b)<J&&Math.abs(p-A)<J?jd(e):(c=m-y,h=g-b,u=p-A,f=1/Math.sqrt(c*c+h*h+u*u),c*=f,h*=f,u*=f,i=S*u-_*h,o=_*c-x*u,s=x*h-S*c,f=Math.sqrt(i*i+o*o+s*s),f?(f=1/f,i*=f,o*=f,s*=f):(i=0,o=0,s=0),a=h*s-u*o,d=u*i-c*s,l=c*o-h*i,f=Math.sqrt(a*a+d*d+l*l),f?(f=1/f,a*=f,d*=f,l*=f):(a=0,d=0,l=0),e[0]=i,e[1]=a,e[2]=c,e[3]=0,e[4]=o,e[5]=d,e[6]=h,e[7]=0,e[8]=s,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*m+o*g+s*p),e[13]=-(a*m+d*g+l*p),e[14]=-(c*m+h*g+u*p),e[15]=1,e)}function lp(e,t,r,n){var i=t[0],o=t[1],s=t[2],a=n[0],d=n[1],l=n[2],c=i-r[0],h=o-r[1],u=s-r[2],f=c*c+h*h+u*u;f>0&&(f=1/Math.sqrt(f),c*=f,h*=f,u*=f);var m=d*u-l*h,g=l*c-a*u,p=a*h-d*c;return f=m*m+g*g+p*p,f>0&&(f=1/Math.sqrt(f),m*=f,g*=f,p*=f),e[0]=m,e[1]=g,e[2]=p,e[3]=0,e[4]=h*p-u*g,e[5]=u*m-c*p,e[6]=c*g-h*m,e[7]=0,e[8]=c,e[9]=h,e[10]=u,e[11]=0,e[12]=i,e[13]=o,e[14]=s,e[15]=1,e}function cp(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function dp(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function up(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function n0(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function fp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function hp(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function mp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function pp(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],d=e[6],l=e[7],c=e[8],h=e[9],u=e[10],f=e[11],m=e[12],g=e[13],p=e[14],x=e[15],S=t[0],_=t[1],y=t[2],b=t[3],A=t[4],v=t[5],E=t[6],L=t[7],w=t[8],T=t[9],z=t[10],U=t[11],C=t[12],$=t[13],Te=t[14],ir=t[15];return Math.abs(r-S)<=J*Math.max(1,Math.abs(r),Math.abs(S))&&Math.abs(n-_)<=J*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(i-y)<=J*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(o-b)<=J*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-A)<=J*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(a-v)<=J*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(d-E)<=J*Math.max(1,Math.abs(d),Math.abs(E))&&Math.abs(l-L)<=J*Math.max(1,Math.abs(l),Math.abs(L))&&Math.abs(c-w)<=J*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(h-T)<=J*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(u-z)<=J*Math.max(1,Math.abs(u),Math.abs(z))&&Math.abs(f-U)<=J*Math.max(1,Math.abs(f),Math.abs(U))&&Math.abs(m-C)<=J*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(g-$)<=J*Math.max(1,Math.abs(g),Math.abs($))&&Math.abs(p-Te)<=J*Math.max(1,Math.abs(p),Math.abs(Te))&&Math.abs(x-ir)<=J*Math.max(1,Math.abs(x),Math.abs(ir))}var gp=Qd,yp=n0;var ce={};ua(ce,{add:()=>Sp,angle:()=>Xp,bezier:()=>Op,ceil:()=>wp,clone:()=>xp,copy:()=>bp,create:()=>i0,cross:()=>kp,dist:()=>Jp,distance:()=>c0,div:()=>Qp,divide:()=>l0,dot:()=>yl,equals:()=>Yp,exactEquals:()=>Zp,floor:()=>Ap,forEach:()=>n1,fromValues:()=>_p,hermite:()=>Dp,inverse:()=>Cp,len:()=>t1,length:()=>o0,lerp:()=>Fp,max:()=>Ep,min:()=>Mp,mul:()=>jp,multiply:()=>a0,negate:()=>Rp,normalize:()=>zp,random:()=>Bp,rotateX:()=>Vp,rotateY:()=>Gp,rotateZ:()=>Wp,round:()=>Lp,scale:()=>Tp,scaleAndAdd:()=>Ip,set:()=>vp,slerp:()=>Pp,sqrDist:()=>e1,sqrLen:()=>r1,squaredDistance:()=>d0,squaredLength:()=>u0,str:()=>$p,sub:()=>qp,subtract:()=>s0,transformMat3:()=>Up,transformMat4:()=>Np,transformQuat:()=>Hp,zero:()=>Kp});function i0(){var e=new Ye(3);return Ye!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function xp(e){var t=new Ye(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o0(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function _p(e,t,r){var n=new Ye(3);return n[0]=e,n[1]=t,n[2]=r,n}function bp(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function vp(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function Sp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function s0(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function a0(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l0(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function wp(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Ap(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Mp(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Ep(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Lp(e,t){return e[0]=Ts(t[0]),e[1]=Ts(t[1]),e[2]=Ts(t[2]),e}function Tp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Ip(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function c0(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function d0(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function u0(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function Rp(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Cp(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function zp(e,t){var r=t[0],n=t[1],i=t[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function yl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function kp(e,t,r){var n=t[0],i=t[1],o=t[2],s=r[0],a=r[1],d=r[2];return e[0]=i*d-o*a,e[1]=o*s-n*d,e[2]=n*a-i*s,e}function Fp(e,t,r,n){var i=t[0],o=t[1],s=t[2];return e[0]=i+n*(r[0]-i),e[1]=o+n*(r[1]-o),e[2]=s+n*(r[2]-s),e}function Pp(e,t,r,n){var i=Math.acos(Math.min(Math.max(yl(t,r),-1),1)),o=Math.sin(i),s=Math.sin((1-n)*i)/o,a=Math.sin(n*i)/o;return e[0]=s*t[0]+a*r[0],e[1]=s*t[1]+a*r[1],e[2]=s*t[2]+a*r[2],e}function Dp(e,t,r,n,i,o){var s=o*o,a=s*(2*o-3)+1,d=s*(o-2)+o,l=s*(o-1),c=s*(3-2*o);return e[0]=t[0]*a+r[0]*d+n[0]*l+i[0]*c,e[1]=t[1]*a+r[1]*d+n[1]*l+i[1]*c,e[2]=t[2]*a+r[2]*d+n[2]*l+i[2]*c,e}function Op(e,t,r,n,i,o){var s=1-o,a=s*s,d=o*o,l=a*s,c=3*o*a,h=3*d*s,u=d*o;return e[0]=t[0]*l+r[0]*c+n[0]*h+i[0]*u,e[1]=t[1]*l+r[1]*c+n[1]*h+i[1]*u,e[2]=t[2]*l+r[2]*c+n[2]*h+i[2]*u,e}function Bp(e,t){t=t===void 0?1:t;var r=gl()*2*Math.PI,n=gl()*2-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e}function Np(e,t,r){var n=t[0],i=t[1],o=t[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return s=s||1,e[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/s,e[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,e[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,e}function Up(e,t,r){var n=t[0],i=t[1],o=t[2];return e[0]=n*r[0]+i*r[3]+o*r[6],e[1]=n*r[1]+i*r[4]+o*r[7],e[2]=n*r[2]+i*r[5]+o*r[8],e}function Hp(e,t,r){var n=r[0],i=r[1],o=r[2],s=r[3],a=t[0],d=t[1],l=t[2],c=i*l-o*d,h=o*a-n*l,u=n*d-i*a;return c=c+c,h=h+h,u=u+u,e[0]=a+s*c+i*u-o*h,e[1]=d+s*h+o*c-n*u,e[2]=l+s*u+n*h-i*c,e}function Vp(e,t,r,n){var i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Gp(e,t,r,n){var i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Wp(e,t,r,n){var i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Xp(e,t){var r=e[0],n=e[1],i=e[2],o=t[0],s=t[1],a=t[2],d=Math.sqrt((r*r+n*n+i*i)*(o*o+s*s+a*a)),l=d&&yl(e,t)/d;return Math.acos(Math.min(Math.max(l,-1),1))}function Kp(e){return e[0]=0,e[1]=0,e[2]=0,e}function $p(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Zp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Yp(e,t){var r=e[0],n=e[1],i=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(r-o)<=J*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=J*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=J*Math.max(1,Math.abs(i),Math.abs(a))}var qp=s0,jp=a0,Qp=l0,Jp=c0,e1=d0,t1=o0,r1=u0,n1=(function(){var e=i0();return function(t,r,n,i,o,s){var a,d;for(r||(r=3),n||(n=0),i?d=Math.min(i*r+n,t.length):d=t.length,a=n;a<d;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,s),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();var Is=class{constructor(){this._position=ce.create();this._angles=ce.create();this._bobAngles=ce.create();this._bobOffset=ce.create();this._kickAngles=ce.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=de.create();this._projectionMatrix=de.create();this._viewProjectionMatrix=de.create();this._dirty=!0}get position(){return this._position}set position(t){ce.copy(this._position,t),this._dirty=!0}get angles(){return this._angles}set angles(t){ce.copy(this._angles,t),this._dirty=!0}get bobAngles(){return this._bobAngles}set bobAngles(t){ce.copy(this._bobAngles,t),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(t){ce.copy(this._kickAngles,t),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(t){ce.copy(this._bobOffset,t),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(t){this._rollAngle=t,this._dirty=!0}get fov(){return this._fov}set fov(t){this._fov=t,this._dirty=!0}get aspect(){return this._aspect}set aspect(t){this._aspect=t,this._dirty=!0}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(t){let r=de.create();return de.perspective(r,t*Or,this._aspect,this._near,this._far),r}updateMatrices(){if(!this._dirty)return;de.perspective(this._projectionMatrix,this._fov*Or,this._aspect,this._near,this._far);let t=de.fromValues(0,-1,0,0,0,0,1,0,-1,0,0,0,0,0,0,1),r=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],n=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],i=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,o=r*Or,s=n*Or,a=i*Or,d=de.create();de.identity(d),de.rotateZ(d,d,-s),de.rotateY(d,d,-o),de.rotateX(d,d,-a);let l=de.create();de.multiply(l,t,d);let c=ce.add(ce.create(),this._position,this._bobOffset),h=ce.negate(ce.create(),c),u=ce.create();ce.transformMat4(u,h,d);let f=ce.fromValues(u[1]||0,u[2]||0,u[0]||0);de.copy(this._viewMatrix,l),this._viewMatrix[12]=f[0],this._viewMatrix[13]=f[1],this._viewMatrix[14]=f[2],de.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var i1=[.2,.2,.2],o1={x:0,y:0,z:1},s1=[.8,.8,.8];function xl(e,t,r){return e+(t-e)*r}function _n(e,t,r){return{x:xl(e.x,t.x,r),y:xl(e.y,t.y,r),z:xl(e.z,t.z,r)}}function xn(e){return e<0?0:e>1?1:e}function _l(e){let t=[],r=[];for(let n of e.triangles){let i=t.length,[o,s,a]=n.indices,d=e.texCoords[o],l=e.texCoords[s],c=e.texCoords[a];if(!d||!l||!c)throw new Error(`Missing texCoord for triangle in surface ${e.name}`);t.push({vertexIndex:o,texCoord:[d.s,1-d.t]},{vertexIndex:s,texCoord:[l.s,1-l.t]},{vertexIndex:a,texCoord:[c.s,1-c.t]}),r.push(i,i+1,i+2)}return{vertices:t,indices:new Uint16Array(r)}}function a1(e,t,r){let n=r?.ambient??i1,i=r?.directional??{direction:o1,color:s1},o=Qe(e),s=Qe(i.direction),a=xn(o.x*s.x+o.y*s.y+o.z*s.z),d=n[0]+i.color[0]*a,l=n[1]+i.color[1]*a,c=n[2]+i.color[2]*a;if(r?.dynamicLights){let h=r.modelMatrix?vc(r.modelMatrix,t):t;for(let u of r.dynamicLights){let f=h.x-u.origin.x,m=h.y-u.origin.y,g=h.z-u.origin.z,p=f*f+m*m+g*g,x=u.radius*u.radius;if(p<x&&x>0){let S=1-Math.sqrt(p)/u.radius,_=Math.sqrt(p),y=_>0?xn(-(f*o.x+m*o.y+g*o.z)/_):0,b=xn(S*y);d+=u.color[0]*b,l+=u.color[1]*b,c+=u.color[2]*b}}}return[xn(d),xn(l),xn(c)]}function bl(e,t,r,n){let i=e.vertices[r.frame0],o=e.vertices[r.frame1];if(!i||!o)throw new Error("Requested MD3 frames are out of range");let s=new Float32Array(t.vertices.length*12);return t.vertices.forEach((a,d)=>{let l=i[a.vertexIndex],c=o[a.vertexIndex];if(!l||!c)throw new Error(`Vertex index ${a.vertexIndex} missing for frame`);let h=_n(l.position,c.position,r.lerp),u=Qe(_n(l.normal,c.normal,r.lerp)),f=a1(u,h,n),m=d*12;s[m]=h.x,s[m+1]=h.y,s[m+2]=h.z,s[m+3]=u.x,s[m+4]=u.y,s[m+5]=u.z,s[m+6]=a.texCoord[0],s[m+7]=a.texCoord[1],s[m+8]=f[0],s[m+9]=f[1],s[m+10]=f[2],s[m+11]=1}),s}function f0(e,t,r){let n=e.tags[0];if(!n)return null;let i=n.findIndex(g=>g.name===r);if(i===-1)return null;let o=e.tags[t.frame0]?.[i],s=e.tags[t.frame1]?.[i];if(!o||!s)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let a=_n(o.origin,s.origin,t.lerp),d=Qe(_n(o.axis[0],s.axis[0],t.lerp)),l=Qe(_n(o.axis[1],s.axis[1],t.lerp)),c=Qe(_n(o.axis[2],s.axis[2],t.lerp)),h=d,u=Qe({x:l.x-h.x*(h.x*l.x+h.y*l.y+h.z*l.z),y:l.y-h.y*(h.x*l.x+h.y*l.y+h.z*l.z),z:l.z-h.z*(h.x*l.x+h.y*l.y+h.z*l.z)}),f=Qe({x:h.y*u.z-h.z*u.y,y:h.z*u.x-h.x*u.z,z:h.x*u.y-h.y*u.x}),m=[h,u,f];return{origin:a,axis:m,matrix:Sc(a,m)}}var vl=`#version 300 es
397
+ }`;function Mm(e){let t=e.x*e.x+e.y*e.y+e.z*e.z;if(t<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(t);return{x:e.x*r,y:e.y*r,z:e.z*r}}function ul(e,t,r){return e+(t-e)*r}function Yd(e,t,r){return{x:ul(e.x,t.x,r),y:ul(e.y,t.y,r),z:ul(e.z,t.z,r)}}function Em(e,t,r){return[e/r.skinWidth,1-t/r.skinHeight]}function ml(e){if(e.glCommands.length===0){let n=[],i=[];return e.triangles.forEach(o=>{let s=n.length;for(let a=0;a<3;a+=1){let d=o.vertexIndices[a],l=o.texCoordIndices[a],c=e.texCoords[l];n.push({vertexIndex:d,texCoord:Em(c.s,c.t,e.header)})}i.push(s,s+1,s+2)}),{vertices:n,indices:new Uint16Array(i)}}let t=[],r=[];for(let n of e.glCommands){let i=t.length;if(t.push(...n.vertices.map(o=>({vertexIndex:o.vertexIndex,texCoord:[o.s,1-o.t]}))),n.mode==="strip")for(let o=0;o<n.vertices.length-2;o+=1){let s=o%2===0,a=i+o+(s?0:1),d=i+o+(s?1:0),l=i+o+2;r.push(a,d,l)}else for(let o=1;o<n.vertices.length-1;o+=1)r.push(i,i+o,i+o+1)}return{vertices:t,indices:new Uint16Array(r)}}function pl(e,t,r){let{frame0:n,frame1:i,lerp:o}=r,s=e.frames[n],a=e.frames[i];if(!s||!a)throw new Error("Requested MD2 frames are out of range");let d=new Float32Array(t.vertices.length*8);return t.vertices.forEach((l,c)=>{let h=s.vertices[l.vertexIndex],u=a.vertices[l.vertexIndex];if(!h||!u)throw new Error("MD2 vertex index out of range for frame");let f=Yd(h.position,u.position,o),m=Mm(Yd(h.normal,u.normal,o)),g=c*8;d[g]=f.x,d[g+1]=f.y,d[g+2]=f.z,d[g+3]=m.x,d[g+4]=m.y,d[g+5]=m.z,d[g+6]=l.texCoord[0],d[g+7]=l.texCoord[1]}),d}var Es=class{constructor(t,r,n){this.gl=t,this.geometry=ml(r),this.vertexBuffer=new Ee(t,t.STATIC_DRAW),this.indexBuffer=new ye(t,t.STATIC_DRAW),this.vertexArray=new ze(t),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:t.FLOAT,stride:32,offset:0},{index:1,size:3,type:t.FLOAT,stride:32,offset:12},{index:2,size:2,type:t.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,t.STATIC_DRAW),this.update(r,n)}update(t,r){let n=pl(t,this.geometry,r);this.vertexBuffer.upload(n,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose(),this.wireframeIndexBuffer?.dispose()}},Ls=class{constructor(t){this.uniformDlights=[];this.gl=t,this.program=Me.create(t,{vertex:fl,fragment:hl},{a_position:0,a_normal:1,a_texCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformModelMatrix=this.program.getUniformLocation("u_modelMatrix"),this.uniformLightDir=this.program.getUniformLocation("u_lightDir"),this.uniformAmbient=this.program.getUniformLocation("u_ambient"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor"),this.uniformNumDlights=this.program.getUniformLocation("u_numDlights");for(let r=0;r<Qt;r++)this.uniformDlights.push({pos:this.program.getUniformLocation(`u_dlights[${r}].position`),color:this.program.getUniformLocation(`u_dlights[${r}].color`),intensity:this.program.getUniformLocation(`u_dlights[${r}].intensity`)})}bind(t){let{modelViewProjection:r,modelMatrix:n,lightDirection:i=[0,0,1],ambientLight:o=.2,tint:s=[1,1,1,1],diffuseSampler:a=0,dlights:d=[],renderMode:l}=t,c=new Float32Array(i),h=new Float32Array(s);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),n?this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,n):this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])),this.gl.uniform3fv(this.uniformLightDir,c),this.gl.uniform1f(this.uniformAmbient,o),this.gl.uniform4fv(this.uniformTint,h),this.gl.uniform1i(this.uniformDiffuse,a);let u=0,f=[1,1,1,1];l&&(l.mode==="solid"||l.mode==="wireframe"?u=1:l.mode==="solid-faceted"&&(u=2),l.color?f=[...l.color]:l.generateRandomColor),this.gl.uniform1i(this.uniformRenderMode,u),this.gl.uniform4f(this.uniformSolidColor,f[0],f[1],f[2],f[3]);let m=Math.min(d.length,Qt);this.gl.uniform1i(this.uniformNumDlights,m);for(let g=0;g<m;g++){let p=d[g];this.gl.uniform3f(this.uniformDlights[g].pos,p.origin.x,p.origin.y,p.origin.z),this.gl.uniform3f(this.uniformDlights[g].color,p.color.x,p.color.y,p.color.z),this.gl.uniform1f(this.uniformDlights[g].intensity,p.intensity)}}draw(t,r){if(t.vertexArray.bind(),r&&r.mode==="wireframe"){if(!t.wireframeIndexBuffer){t.wireframeIndexBuffer=new ye(this.gl,this.gl.STATIC_DRAW);let n=yn(t.geometry.indices);t.wireframeIndexBuffer.upload(n),t.wireframeIndexCount=n.length}t.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,t.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else t.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,t.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var J=1e-6,Ye=typeof Float32Array<"u"?Float32Array:Array,gl=Math.random;function Ts(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var IS=Math.PI/180,CS=180/Math.PI;var de={};ua(de,{add:()=>up,adjoint:()=>Fm,clone:()=>Tm,copy:()=>Im,create:()=>Lm,decompose:()=>jm,determinant:()=>Dm,equals:()=>pp,exactEquals:()=>mp,frob:()=>dp,fromQuat:()=>ep,fromQuat2:()=>Zm,fromRotation:()=>Wm,fromRotationTranslation:()=>Jd,fromRotationTranslationScale:()=>Qm,fromRotationTranslationScaleOrigin:()=>Jm,fromScaling:()=>Gm,fromTranslation:()=>Vm,fromValues:()=>Cm,fromXRotation:()=>Xm,fromYRotation:()=>Km,fromZRotation:()=>$m,frustum:()=>tp,getRotation:()=>qm,getScaling:()=>e0,getTranslation:()=>Ym,identity:()=>jd,invert:()=>km,lookAt:()=>ap,mul:()=>gp,multiply:()=>Qd,multiplyScalar:()=>fp,multiplyScalarAndAdd:()=>hp,ortho:()=>op,orthoNO:()=>r0,orthoZO:()=>sp,perspective:()=>rp,perspectiveFromFieldOfView:()=>ip,perspectiveNO:()=>t0,perspectiveZO:()=>np,rotate:()=>Bm,rotateX:()=>Nm,rotateY:()=>Um,rotateZ:()=>Hm,scale:()=>Om,set:()=>zm,str:()=>cp,sub:()=>yp,subtract:()=>n0,targetTo:()=>lp,translate:()=>Pm,transpose:()=>Rm});function Lm(){var e=new Ye(16);return Ye!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Tm(e){var t=new Ye(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Im(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Cm(e,t,r,n,i,o,s,a,d,l,c,h,u,f,m,g){var p=new Ye(16);return p[0]=e,p[1]=t,p[2]=r,p[3]=n,p[4]=i,p[5]=o,p[6]=s,p[7]=a,p[8]=d,p[9]=l,p[10]=c,p[11]=h,p[12]=u,p[13]=f,p[14]=m,p[15]=g,p}function zm(e,t,r,n,i,o,s,a,d,l,c,h,u,f,m,g,p){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=o,e[5]=s,e[6]=a,e[7]=d,e[8]=l,e[9]=c,e[10]=h,e[11]=u,e[12]=f,e[13]=m,e[14]=g,e[15]=p,e}function jd(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Rm(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=i,e[13]=s,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function km(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],s=t[4],a=t[5],d=t[6],l=t[7],c=t[8],h=t[9],u=t[10],f=t[11],m=t[12],g=t[13],p=t[14],x=t[15],S=r*a-n*s,_=r*d-i*s,y=r*l-o*s,b=n*d-i*a,A=n*l-o*a,v=i*l-o*d,E=c*g-h*m,L=c*p-u*m,w=c*x-f*m,T=h*p-u*g,R=h*x-f*g,U=u*x-f*p,z=S*U-_*R+y*T+b*w-A*L+v*E;return z?(z=1/z,e[0]=(a*U-d*R+l*T)*z,e[1]=(i*R-n*U-o*T)*z,e[2]=(g*v-p*A+x*b)*z,e[3]=(u*A-h*v-f*b)*z,e[4]=(d*w-s*U-l*L)*z,e[5]=(r*U-i*w+o*L)*z,e[6]=(p*y-m*v-x*_)*z,e[7]=(c*v-u*y+f*_)*z,e[8]=(s*R-a*w+l*E)*z,e[9]=(n*w-r*R-o*E)*z,e[10]=(m*A-g*y+x*S)*z,e[11]=(h*y-c*A-f*S)*z,e[12]=(a*L-s*T-d*E)*z,e[13]=(r*T-n*L+i*E)*z,e[14]=(g*_-m*b-p*S)*z,e[15]=(c*b-h*_+u*S)*z,e):null}function Fm(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],s=t[4],a=t[5],d=t[6],l=t[7],c=t[8],h=t[9],u=t[10],f=t[11],m=t[12],g=t[13],p=t[14],x=t[15],S=r*a-n*s,_=r*d-i*s,y=r*l-o*s,b=n*d-i*a,A=n*l-o*a,v=i*l-o*d,E=c*g-h*m,L=c*p-u*m,w=c*x-f*m,T=h*p-u*g,R=h*x-f*g,U=u*x-f*p;return e[0]=a*U-d*R+l*T,e[1]=i*R-n*U-o*T,e[2]=g*v-p*A+x*b,e[3]=u*A-h*v-f*b,e[4]=d*w-s*U-l*L,e[5]=r*U-i*w+o*L,e[6]=p*y-m*v-x*_,e[7]=c*v-u*y+f*_,e[8]=s*R-a*w+l*E,e[9]=n*w-r*R-o*E,e[10]=m*A-g*y+x*S,e[11]=h*y-c*A-f*S,e[12]=a*L-s*T-d*E,e[13]=r*T-n*L+i*E,e[14]=g*_-m*b-p*S,e[15]=c*b-h*_+u*S,e}function Dm(e){var t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],s=e[5],a=e[6],d=e[7],l=e[8],c=e[9],h=e[10],u=e[11],f=e[12],m=e[13],g=e[14],p=e[15],x=t*s-r*o,S=t*a-n*o,_=r*a-n*s,y=l*m-c*f,b=l*g-h*f,A=c*g-h*m,v=t*A-r*b+n*y,E=o*A-s*b+a*y,L=l*_-c*S+h*x,w=f*_-m*S+g*x;return d*v-i*E+p*L-u*w}function Qd(e,t,r){var n=t[0],i=t[1],o=t[2],s=t[3],a=t[4],d=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],m=t[11],g=t[12],p=t[13],x=t[14],S=t[15],_=r[0],y=r[1],b=r[2],A=r[3];return e[0]=_*n+y*a+b*h+A*g,e[1]=_*i+y*d+b*u+A*p,e[2]=_*o+y*l+b*f+A*x,e[3]=_*s+y*c+b*m+A*S,_=r[4],y=r[5],b=r[6],A=r[7],e[4]=_*n+y*a+b*h+A*g,e[5]=_*i+y*d+b*u+A*p,e[6]=_*o+y*l+b*f+A*x,e[7]=_*s+y*c+b*m+A*S,_=r[8],y=r[9],b=r[10],A=r[11],e[8]=_*n+y*a+b*h+A*g,e[9]=_*i+y*d+b*u+A*p,e[10]=_*o+y*l+b*f+A*x,e[11]=_*s+y*c+b*m+A*S,_=r[12],y=r[13],b=r[14],A=r[15],e[12]=_*n+y*a+b*h+A*g,e[13]=_*i+y*d+b*u+A*p,e[14]=_*o+y*l+b*f+A*x,e[15]=_*s+y*c+b*m+A*S,e}function Pm(e,t,r){var n=r[0],i=r[1],o=r[2],s,a,d,l,c,h,u,f,m,g,p,x;return t===e?(e[12]=t[0]*n+t[4]*i+t[8]*o+t[12],e[13]=t[1]*n+t[5]*i+t[9]*o+t[13],e[14]=t[2]*n+t[6]*i+t[10]*o+t[14],e[15]=t[3]*n+t[7]*i+t[11]*o+t[15]):(s=t[0],a=t[1],d=t[2],l=t[3],c=t[4],h=t[5],u=t[6],f=t[7],m=t[8],g=t[9],p=t[10],x=t[11],e[0]=s,e[1]=a,e[2]=d,e[3]=l,e[4]=c,e[5]=h,e[6]=u,e[7]=f,e[8]=m,e[9]=g,e[10]=p,e[11]=x,e[12]=s*n+c*i+m*o+t[12],e[13]=a*n+h*i+g*o+t[13],e[14]=d*n+u*i+p*o+t[14],e[15]=l*n+f*i+x*o+t[15]),e}function Om(e,t,r){var n=r[0],i=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Bm(e,t,r,n){var i=n[0],o=n[1],s=n[2],a=Math.sqrt(i*i+o*o+s*s),d,l,c,h,u,f,m,g,p,x,S,_,y,b,A,v,E,L,w,T,R,U,z,$;return a<J?null:(a=1/a,i*=a,o*=a,s*=a,d=Math.sin(r),l=Math.cos(r),c=1-l,h=t[0],u=t[1],f=t[2],m=t[3],g=t[4],p=t[5],x=t[6],S=t[7],_=t[8],y=t[9],b=t[10],A=t[11],v=i*i*c+l,E=o*i*c+s*d,L=s*i*c-o*d,w=i*o*c-s*d,T=o*o*c+l,R=s*o*c+i*d,U=i*s*c+o*d,z=o*s*c-i*d,$=s*s*c+l,e[0]=h*v+g*E+_*L,e[1]=u*v+p*E+y*L,e[2]=f*v+x*E+b*L,e[3]=m*v+S*E+A*L,e[4]=h*w+g*T+_*R,e[5]=u*w+p*T+y*R,e[6]=f*w+x*T+b*R,e[7]=m*w+S*T+A*R,e[8]=h*U+g*z+_*$,e[9]=u*U+p*z+y*$,e[10]=f*U+x*z+b*$,e[11]=m*U+S*z+A*$,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Nm(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[4],s=t[5],a=t[6],d=t[7],l=t[8],c=t[9],h=t[10],u=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+l*n,e[5]=s*i+c*n,e[6]=a*i+h*n,e[7]=d*i+u*n,e[8]=l*i-o*n,e[9]=c*i-s*n,e[10]=h*i-a*n,e[11]=u*i-d*n,e}function Um(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],s=t[1],a=t[2],d=t[3],l=t[8],c=t[9],h=t[10],u=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-l*n,e[1]=s*i-c*n,e[2]=a*i-h*n,e[3]=d*i-u*n,e[8]=o*n+l*i,e[9]=s*n+c*i,e[10]=a*n+h*i,e[11]=d*n+u*i,e}function Hm(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],s=t[1],a=t[2],d=t[3],l=t[4],c=t[5],h=t[6],u=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i+l*n,e[1]=s*i+c*n,e[2]=a*i+h*n,e[3]=d*i+u*n,e[4]=l*i-o*n,e[5]=c*i-s*n,e[6]=h*i-a*n,e[7]=u*i-d*n,e}function Vm(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Gm(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Wm(e,t,r){var n=r[0],i=r[1],o=r[2],s=Math.sqrt(n*n+i*i+o*o),a,d,l;return s<J?null:(s=1/s,n*=s,i*=s,o*=s,a=Math.sin(t),d=Math.cos(t),l=1-d,e[0]=n*n*l+d,e[1]=i*n*l+o*a,e[2]=o*n*l-i*a,e[3]=0,e[4]=n*i*l-o*a,e[5]=i*i*l+d,e[6]=o*i*l+n*a,e[7]=0,e[8]=n*o*l+i*a,e[9]=i*o*l-n*a,e[10]=o*o*l+d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Xm(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Km(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function $m(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Jd(e,t,r){var n=t[0],i=t[1],o=t[2],s=t[3],a=n+n,d=i+i,l=o+o,c=n*a,h=n*d,u=n*l,f=i*d,m=i*l,g=o*l,p=s*a,x=s*d,S=s*l;return e[0]=1-(f+g),e[1]=h+S,e[2]=u-x,e[3]=0,e[4]=h-S,e[5]=1-(c+g),e[6]=m+p,e[7]=0,e[8]=u+x,e[9]=m-p,e[10]=1-(c+f),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Zm(e,t){var r=new Ye(3),n=-t[0],i=-t[1],o=-t[2],s=t[3],a=t[4],d=t[5],l=t[6],c=t[7],h=n*n+i*i+o*o+s*s;return h>0?(r[0]=(a*s+c*n+d*o-l*i)*2/h,r[1]=(d*s+c*i+l*n-a*o)*2/h,r[2]=(l*s+c*o+a*i-d*n)*2/h):(r[0]=(a*s+c*n+d*o-l*i)*2,r[1]=(d*s+c*i+l*n-a*o)*2,r[2]=(l*s+c*o+a*i-d*n)*2),Jd(e,t,r),e}function Ym(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function e0(e,t){var r=t[0],n=t[1],i=t[2],o=t[4],s=t[5],a=t[6],d=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(d*d+l*l+c*c),e}function qm(e,t){var r=new Ye(3);e0(r,t);var n=1/r[0],i=1/r[1],o=1/r[2],s=t[0]*n,a=t[1]*i,d=t[2]*o,l=t[4]*n,c=t[5]*i,h=t[6]*o,u=t[8]*n,f=t[9]*i,m=t[10]*o,g=s+c+m,p=0;return g>0?(p=Math.sqrt(g+1)*2,e[3]=.25*p,e[0]=(h-f)/p,e[1]=(u-d)/p,e[2]=(a-l)/p):s>c&&s>m?(p=Math.sqrt(1+s-c-m)*2,e[3]=(h-f)/p,e[0]=.25*p,e[1]=(a+l)/p,e[2]=(u+d)/p):c>m?(p=Math.sqrt(1+c-s-m)*2,e[3]=(u-d)/p,e[0]=(a+l)/p,e[1]=.25*p,e[2]=(h+f)/p):(p=Math.sqrt(1+m-s-c)*2,e[3]=(a-l)/p,e[0]=(u+d)/p,e[1]=(h+f)/p,e[2]=.25*p),e}function jm(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];var i=n[0],o=n[1],s=n[2],a=n[4],d=n[5],l=n[6],c=n[8],h=n[9],u=n[10];r[0]=Math.sqrt(i*i+o*o+s*s),r[1]=Math.sqrt(a*a+d*d+l*l),r[2]=Math.sqrt(c*c+h*h+u*u);var f=1/r[0],m=1/r[1],g=1/r[2],p=i*f,x=o*m,S=s*g,_=a*f,y=d*m,b=l*g,A=c*f,v=h*m,E=u*g,L=p+y+E,w=0;return L>0?(w=Math.sqrt(L+1)*2,e[3]=.25*w,e[0]=(b-v)/w,e[1]=(A-S)/w,e[2]=(x-_)/w):p>y&&p>E?(w=Math.sqrt(1+p-y-E)*2,e[3]=(b-v)/w,e[0]=.25*w,e[1]=(x+_)/w,e[2]=(A+S)/w):y>E?(w=Math.sqrt(1+y-p-E)*2,e[3]=(A-S)/w,e[0]=(x+_)/w,e[1]=.25*w,e[2]=(b+v)/w):(w=Math.sqrt(1+E-p-y)*2,e[3]=(x-_)/w,e[0]=(A+S)/w,e[1]=(b+v)/w,e[2]=.25*w),e}function Qm(e,t,r,n){var i=t[0],o=t[1],s=t[2],a=t[3],d=i+i,l=o+o,c=s+s,h=i*d,u=i*l,f=i*c,m=o*l,g=o*c,p=s*c,x=a*d,S=a*l,_=a*c,y=n[0],b=n[1],A=n[2];return e[0]=(1-(m+p))*y,e[1]=(u+_)*y,e[2]=(f-S)*y,e[3]=0,e[4]=(u-_)*b,e[5]=(1-(h+p))*b,e[6]=(g+x)*b,e[7]=0,e[8]=(f+S)*A,e[9]=(g-x)*A,e[10]=(1-(h+m))*A,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Jm(e,t,r,n,i){var o=t[0],s=t[1],a=t[2],d=t[3],l=o+o,c=s+s,h=a+a,u=o*l,f=o*c,m=o*h,g=s*c,p=s*h,x=a*h,S=d*l,_=d*c,y=d*h,b=n[0],A=n[1],v=n[2],E=i[0],L=i[1],w=i[2],T=(1-(g+x))*b,R=(f+y)*b,U=(m-_)*b,z=(f-y)*A,$=(1-(u+x))*A,Te=(p+S)*A,ir=(m+_)*v,co=(p-S)*v,Tn=(1-(u+g))*v;return e[0]=T,e[1]=R,e[2]=U,e[3]=0,e[4]=z,e[5]=$,e[6]=Te,e[7]=0,e[8]=ir,e[9]=co,e[10]=Tn,e[11]=0,e[12]=r[0]+E-(T*E+z*L+ir*w),e[13]=r[1]+L-(R*E+$*L+co*w),e[14]=r[2]+w-(U*E+Te*L+Tn*w),e[15]=1,e}function ep(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],s=r+r,a=n+n,d=i+i,l=r*s,c=n*s,h=n*a,u=i*s,f=i*a,m=i*d,g=o*s,p=o*a,x=o*d;return e[0]=1-h-m,e[1]=c+x,e[2]=u-p,e[3]=0,e[4]=c-x,e[5]=1-l-m,e[6]=f+g,e[7]=0,e[8]=u+p,e[9]=f-g,e[10]=1-l-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function tp(e,t,r,n,i,o,s){var a=1/(r-t),d=1/(i-n),l=1/(o-s);return e[0]=o*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*d,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(i+n)*d,e[10]=(s+o)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*l,e[15]=0,e}function t0(e,t,r,n,i){var o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var s=1/(n-i);e[10]=(i+n)*s,e[14]=2*i*n*s}else e[10]=-1,e[14]=-2*n;return e}var rp=t0;function np(e,t,r,n,i){var o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var s=1/(n-i);e[10]=i*s,e[14]=i*n*s}else e[10]=-1,e[14]=-n;return e}function ip(e,t,r,n){var i=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),d=2/(s+a),l=2/(i+o);return e[0]=d,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-((s-a)*d*.5),e[9]=(i-o)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function r0(e,t,r,n,i,o,s){var a=1/(t-r),d=1/(n-i),l=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*d,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*d,e[14]=(s+o)*l,e[15]=1,e}var op=r0;function sp(e,t,r,n,i,o,s){var a=1/(t-r),d=1/(n-i),l=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*d,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*d,e[14]=o*l,e[15]=1,e}function ap(e,t,r,n){var i,o,s,a,d,l,c,h,u,f,m=t[0],g=t[1],p=t[2],x=n[0],S=n[1],_=n[2],y=r[0],b=r[1],A=r[2];return Math.abs(m-y)<J&&Math.abs(g-b)<J&&Math.abs(p-A)<J?jd(e):(c=m-y,h=g-b,u=p-A,f=1/Math.sqrt(c*c+h*h+u*u),c*=f,h*=f,u*=f,i=S*u-_*h,o=_*c-x*u,s=x*h-S*c,f=Math.sqrt(i*i+o*o+s*s),f?(f=1/f,i*=f,o*=f,s*=f):(i=0,o=0,s=0),a=h*s-u*o,d=u*i-c*s,l=c*o-h*i,f=Math.sqrt(a*a+d*d+l*l),f?(f=1/f,a*=f,d*=f,l*=f):(a=0,d=0,l=0),e[0]=i,e[1]=a,e[2]=c,e[3]=0,e[4]=o,e[5]=d,e[6]=h,e[7]=0,e[8]=s,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*m+o*g+s*p),e[13]=-(a*m+d*g+l*p),e[14]=-(c*m+h*g+u*p),e[15]=1,e)}function lp(e,t,r,n){var i=t[0],o=t[1],s=t[2],a=n[0],d=n[1],l=n[2],c=i-r[0],h=o-r[1],u=s-r[2],f=c*c+h*h+u*u;f>0&&(f=1/Math.sqrt(f),c*=f,h*=f,u*=f);var m=d*u-l*h,g=l*c-a*u,p=a*h-d*c;return f=m*m+g*g+p*p,f>0&&(f=1/Math.sqrt(f),m*=f,g*=f,p*=f),e[0]=m,e[1]=g,e[2]=p,e[3]=0,e[4]=h*p-u*g,e[5]=u*m-c*p,e[6]=c*g-h*m,e[7]=0,e[8]=c,e[9]=h,e[10]=u,e[11]=0,e[12]=i,e[13]=o,e[14]=s,e[15]=1,e}function cp(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function dp(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function up(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function n0(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function fp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function hp(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function mp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function pp(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],d=e[6],l=e[7],c=e[8],h=e[9],u=e[10],f=e[11],m=e[12],g=e[13],p=e[14],x=e[15],S=t[0],_=t[1],y=t[2],b=t[3],A=t[4],v=t[5],E=t[6],L=t[7],w=t[8],T=t[9],R=t[10],U=t[11],z=t[12],$=t[13],Te=t[14],ir=t[15];return Math.abs(r-S)<=J*Math.max(1,Math.abs(r),Math.abs(S))&&Math.abs(n-_)<=J*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(i-y)<=J*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(o-b)<=J*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-A)<=J*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(a-v)<=J*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(d-E)<=J*Math.max(1,Math.abs(d),Math.abs(E))&&Math.abs(l-L)<=J*Math.max(1,Math.abs(l),Math.abs(L))&&Math.abs(c-w)<=J*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(h-T)<=J*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(u-R)<=J*Math.max(1,Math.abs(u),Math.abs(R))&&Math.abs(f-U)<=J*Math.max(1,Math.abs(f),Math.abs(U))&&Math.abs(m-z)<=J*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(g-$)<=J*Math.max(1,Math.abs(g),Math.abs($))&&Math.abs(p-Te)<=J*Math.max(1,Math.abs(p),Math.abs(Te))&&Math.abs(x-ir)<=J*Math.max(1,Math.abs(x),Math.abs(ir))}var gp=Qd,yp=n0;var ce={};ua(ce,{add:()=>Sp,angle:()=>Xp,bezier:()=>Op,ceil:()=>wp,clone:()=>xp,copy:()=>bp,create:()=>i0,cross:()=>kp,dist:()=>Jp,distance:()=>c0,div:()=>Qp,divide:()=>l0,dot:()=>yl,equals:()=>Yp,exactEquals:()=>Zp,floor:()=>Ap,forEach:()=>n1,fromValues:()=>_p,hermite:()=>Pp,inverse:()=>zp,len:()=>t1,length:()=>o0,lerp:()=>Fp,max:()=>Ep,min:()=>Mp,mul:()=>jp,multiply:()=>a0,negate:()=>Cp,normalize:()=>Rp,random:()=>Bp,rotateX:()=>Vp,rotateY:()=>Gp,rotateZ:()=>Wp,round:()=>Lp,scale:()=>Tp,scaleAndAdd:()=>Ip,set:()=>vp,slerp:()=>Dp,sqrDist:()=>e1,sqrLen:()=>r1,squaredDistance:()=>d0,squaredLength:()=>u0,str:()=>$p,sub:()=>qp,subtract:()=>s0,transformMat3:()=>Up,transformMat4:()=>Np,transformQuat:()=>Hp,zero:()=>Kp});function i0(){var e=new Ye(3);return Ye!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function xp(e){var t=new Ye(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o0(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function _p(e,t,r){var n=new Ye(3);return n[0]=e,n[1]=t,n[2]=r,n}function bp(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function vp(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function Sp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function s0(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function a0(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l0(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function wp(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Ap(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Mp(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Ep(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Lp(e,t){return e[0]=Ts(t[0]),e[1]=Ts(t[1]),e[2]=Ts(t[2]),e}function Tp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Ip(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function c0(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function d0(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function u0(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function Cp(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function zp(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Rp(e,t){var r=t[0],n=t[1],i=t[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function yl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function kp(e,t,r){var n=t[0],i=t[1],o=t[2],s=r[0],a=r[1],d=r[2];return e[0]=i*d-o*a,e[1]=o*s-n*d,e[2]=n*a-i*s,e}function Fp(e,t,r,n){var i=t[0],o=t[1],s=t[2];return e[0]=i+n*(r[0]-i),e[1]=o+n*(r[1]-o),e[2]=s+n*(r[2]-s),e}function Dp(e,t,r,n){var i=Math.acos(Math.min(Math.max(yl(t,r),-1),1)),o=Math.sin(i),s=Math.sin((1-n)*i)/o,a=Math.sin(n*i)/o;return e[0]=s*t[0]+a*r[0],e[1]=s*t[1]+a*r[1],e[2]=s*t[2]+a*r[2],e}function Pp(e,t,r,n,i,o){var s=o*o,a=s*(2*o-3)+1,d=s*(o-2)+o,l=s*(o-1),c=s*(3-2*o);return e[0]=t[0]*a+r[0]*d+n[0]*l+i[0]*c,e[1]=t[1]*a+r[1]*d+n[1]*l+i[1]*c,e[2]=t[2]*a+r[2]*d+n[2]*l+i[2]*c,e}function Op(e,t,r,n,i,o){var s=1-o,a=s*s,d=o*o,l=a*s,c=3*o*a,h=3*d*s,u=d*o;return e[0]=t[0]*l+r[0]*c+n[0]*h+i[0]*u,e[1]=t[1]*l+r[1]*c+n[1]*h+i[1]*u,e[2]=t[2]*l+r[2]*c+n[2]*h+i[2]*u,e}function Bp(e,t){t=t===void 0?1:t;var r=gl()*2*Math.PI,n=gl()*2-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e}function Np(e,t,r){var n=t[0],i=t[1],o=t[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return s=s||1,e[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/s,e[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,e[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,e}function Up(e,t,r){var n=t[0],i=t[1],o=t[2];return e[0]=n*r[0]+i*r[3]+o*r[6],e[1]=n*r[1]+i*r[4]+o*r[7],e[2]=n*r[2]+i*r[5]+o*r[8],e}function Hp(e,t,r){var n=r[0],i=r[1],o=r[2],s=r[3],a=t[0],d=t[1],l=t[2],c=i*l-o*d,h=o*a-n*l,u=n*d-i*a;return c=c+c,h=h+h,u=u+u,e[0]=a+s*c+i*u-o*h,e[1]=d+s*h+o*c-n*u,e[2]=l+s*u+n*h-i*c,e}function Vp(e,t,r,n){var i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Gp(e,t,r,n){var i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Wp(e,t,r,n){var i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Xp(e,t){var r=e[0],n=e[1],i=e[2],o=t[0],s=t[1],a=t[2],d=Math.sqrt((r*r+n*n+i*i)*(o*o+s*s+a*a)),l=d&&yl(e,t)/d;return Math.acos(Math.min(Math.max(l,-1),1))}function Kp(e){return e[0]=0,e[1]=0,e[2]=0,e}function $p(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Zp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Yp(e,t){var r=e[0],n=e[1],i=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(r-o)<=J*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=J*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=J*Math.max(1,Math.abs(i),Math.abs(a))}var qp=s0,jp=a0,Qp=l0,Jp=c0,e1=d0,t1=o0,r1=u0,n1=(function(){var e=i0();return function(t,r,n,i,o,s){var a,d;for(r||(r=3),n||(n=0),i?d=Math.min(i*r+n,t.length):d=t.length,a=n;a<d;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,s),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();var Is=class{constructor(){this._position=ce.create();this._angles=ce.create();this._bobAngles=ce.create();this._bobOffset=ce.create();this._kickAngles=ce.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=de.create();this._projectionMatrix=de.create();this._viewProjectionMatrix=de.create();this._dirty=!0}get position(){return this._position}set position(t){ce.copy(this._position,t),this._dirty=!0}get angles(){return this._angles}set angles(t){ce.copy(this._angles,t),this._dirty=!0}get bobAngles(){return this._bobAngles}set bobAngles(t){ce.copy(this._bobAngles,t),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(t){ce.copy(this._kickAngles,t),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(t){ce.copy(this._bobOffset,t),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(t){this._rollAngle=t,this._dirty=!0}get fov(){return this._fov}set fov(t){this._fov=t,this._dirty=!0}get aspect(){return this._aspect}set aspect(t){this._aspect=t,this._dirty=!0}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(t){let r=de.create();return de.perspective(r,t*Or,this._aspect,this._near,this._far),r}updateMatrices(){if(!this._dirty)return;de.perspective(this._projectionMatrix,this._fov*Or,this._aspect,this._near,this._far);let t=de.fromValues(0,-1,0,0,0,0,1,0,-1,0,0,0,0,0,0,1),r=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],n=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],i=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,o=r*Or,s=n*Or,a=i*Or,d=de.create();de.identity(d),de.rotateZ(d,d,-s),de.rotateY(d,d,-o),de.rotateX(d,d,-a);let l=de.create();de.multiply(l,t,d);let c=ce.add(ce.create(),this._position,this._bobOffset),h=ce.negate(ce.create(),c),u=ce.create();ce.transformMat4(u,h,d);let f=ce.fromValues(u[1]||0,u[2]||0,u[0]||0);de.copy(this._viewMatrix,l),this._viewMatrix[12]=f[0],this._viewMatrix[13]=f[1],this._viewMatrix[14]=f[2],de.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var i1=[.2,.2,.2],o1={x:0,y:0,z:1},s1=[.8,.8,.8];function xl(e,t,r){return e+(t-e)*r}function _n(e,t,r){return{x:xl(e.x,t.x,r),y:xl(e.y,t.y,r),z:xl(e.z,t.z,r)}}function xn(e){return e<0?0:e>1?1:e}function _l(e){let t=[],r=[];for(let n of e.triangles){let i=t.length,[o,s,a]=n.indices,d=e.texCoords[o],l=e.texCoords[s],c=e.texCoords[a];if(!d||!l||!c)throw new Error(`Missing texCoord for triangle in surface ${e.name}`);t.push({vertexIndex:o,texCoord:[d.s,1-d.t]},{vertexIndex:s,texCoord:[l.s,1-l.t]},{vertexIndex:a,texCoord:[c.s,1-c.t]}),r.push(i,i+1,i+2)}return{vertices:t,indices:new Uint16Array(r)}}function a1(e,t,r){let n=r?.ambient??i1,i=r?.directional??{direction:o1,color:s1},o=Qe(e),s=Qe(i.direction),a=xn(o.x*s.x+o.y*s.y+o.z*s.z),d=n[0]+i.color[0]*a,l=n[1]+i.color[1]*a,c=n[2]+i.color[2]*a;if(r?.dynamicLights){let h=r.modelMatrix?vc(r.modelMatrix,t):t;for(let u of r.dynamicLights){let f=h.x-u.origin.x,m=h.y-u.origin.y,g=h.z-u.origin.z,p=f*f+m*m+g*g,x=u.radius*u.radius;if(p<x&&x>0){let S=1-Math.sqrt(p)/u.radius,_=Math.sqrt(p),y=_>0?xn(-(f*o.x+m*o.y+g*o.z)/_):0,b=xn(S*y);d+=u.color[0]*b,l+=u.color[1]*b,c+=u.color[2]*b}}}return[xn(d),xn(l),xn(c)]}function bl(e,t,r,n){let i=e.vertices[r.frame0],o=e.vertices[r.frame1];if(!i||!o)throw new Error("Requested MD3 frames are out of range");let s=new Float32Array(t.vertices.length*12);return t.vertices.forEach((a,d)=>{let l=i[a.vertexIndex],c=o[a.vertexIndex];if(!l||!c)throw new Error(`Vertex index ${a.vertexIndex} missing for frame`);let h=_n(l.position,c.position,r.lerp),u=Qe(_n(l.normal,c.normal,r.lerp)),f=a1(u,h,n),m=d*12;s[m]=h.x,s[m+1]=h.y,s[m+2]=h.z,s[m+3]=u.x,s[m+4]=u.y,s[m+5]=u.z,s[m+6]=a.texCoord[0],s[m+7]=a.texCoord[1],s[m+8]=f[0],s[m+9]=f[1],s[m+10]=f[2],s[m+11]=1}),s}function f0(e,t,r){let n=e.tags[0];if(!n)return null;let i=n.findIndex(g=>g.name===r);if(i===-1)return null;let o=e.tags[t.frame0]?.[i],s=e.tags[t.frame1]?.[i];if(!o||!s)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let a=_n(o.origin,s.origin,t.lerp),d=Qe(_n(o.axis[0],s.axis[0],t.lerp)),l=Qe(_n(o.axis[1],s.axis[1],t.lerp)),c=Qe(_n(o.axis[2],s.axis[2],t.lerp)),h=d,u=Qe({x:l.x-h.x*(h.x*l.x+h.y*l.y+h.z*l.z),y:l.y-h.y*(h.x*l.x+h.y*l.y+h.z*l.z),z:l.z-h.z*(h.x*l.x+h.y*l.y+h.z*l.z)}),f=Qe({x:h.y*u.z-h.z*u.y,y:h.z*u.x-h.x*u.z,z:h.x*u.y-h.y*u.x}),m=[h,u,f];return{origin:a,axis:m,matrix:Sc(a,m)}}var vl=`#version 300 es
398
398
  precision highp float;
399
399
 
400
400
  layout(location = 0) in vec3 a_position;
@@ -449,7 +449,7 @@ void main() {
449
449
  }
450
450
 
451
451
  o_color = finalColor;
452
- }`,Oi=class{constructor(t,r,n,i){this.gl=t,this.geometry=_l(r),this.vertexBuffer=new Ee(t,t.STATIC_DRAW),this.indexBuffer=new ye(t,t.STATIC_DRAW),this.vertexArray=new Ce(t),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:t.FLOAT,stride:48,offset:0},{index:1,size:3,type:t.FLOAT,stride:48,offset:12},{index:2,size:2,type:t.FLOAT,stride:48,offset:24},{index:3,size:4,type:t.FLOAT,stride:48,offset:32}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,t.STATIC_DRAW),this.update(r,n,i)}update(t,r,n){let i=bl(t,this.geometry,r,n);this.vertexBuffer.upload(i,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose(),this.wireframeIndexBuffer?.dispose()}},Rs=class{constructor(t,r,n,i){this.surfaces=new Map;this.gl=t,this.model=r,this.blend=n,this.lighting=i,r.surfaces.forEach(o=>{this.surfaces.set(o.name,new Oi(t,o,n,i))})}update(t,r){this.blend=t,this.lighting=r??this.lighting;for(let n of this.model.surfaces)this.surfaces.get(n.name)?.update(n,t,this.lighting)}dispose(){for(let t of this.surfaces.values())t.dispose();this.surfaces.clear()}},Cs=class{constructor(t){this.gl=t,this.program=Me.create(t,{vertex:vl,fragment:Sl},{a_position:0,a_normal:1,a_texCoord:2,a_color:3}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor")}bind(t,r=[1,1,1,1],n=0){this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,t),this.gl.uniform4fv(this.uniformTint,new Float32Array(r)),this.gl.uniform1i(this.uniformDiffuse,n),this.gl.uniform1i(this.uniformRenderMode,0),this.gl.uniform4f(this.uniformSolidColor,1,1,1,1)}drawSurface(t,r){let n=r?.diffuseSampler??0,i=r?.tint??[1,1,1,1],o=r?.renderMode;this.gl.uniform4fv(this.uniformTint,new Float32Array(i)),this.gl.uniform1i(this.uniformDiffuse,n);let s=0,a=[1,1,1,1];if(o&&(o.mode==="solid"||o.mode==="wireframe"?s=1:o.mode==="solid-faceted"&&(s=2),o.color&&(a=[...o.color])),this.gl.uniform1i(this.uniformRenderMode,s),this.gl.uniform4f(this.uniformSolidColor,a[0],a[1],a[2],a[3]),t.vertexArray.bind(),o&&o.mode==="wireframe"){if(!t.wireframeIndexBuffer){t.wireframeIndexBuffer=new ye(this.gl,this.gl.STATIC_DRAW);let d=yn(t.geometry.indices);t.wireframeIndexBuffer.upload(d),t.wireframeIndexCount=d.length}t.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,t.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else t.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,t.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var l1=[1,1,1,1],zs=class{constructor(t,r=Math.random){this.maxParticles=t,this.random=r,this.alive=new Uint8Array(t),this.positionX=new Float32Array(t),this.positionY=new Float32Array(t),this.positionZ=new Float32Array(t),this.velocityX=new Float32Array(t),this.velocityY=new Float32Array(t),this.velocityZ=new Float32Array(t),this.colorR=new Float32Array(t),this.colorG=new Float32Array(t),this.colorB=new Float32Array(t),this.colorA=new Float32Array(t),this.size=new Float32Array(t),this.lifetime=new Float32Array(t),this.remaining=new Float32Array(t),this.gravity=new Float32Array(t),this.damping=new Float32Array(t),this.bounce=new Float32Array(t),this.fade=new Uint8Array(t),this.blendMode=new Uint8Array(t)}spawn(t){let r=this.findFreeSlot();if(r===-1)return null;let n=t.color??l1,i=t.velocity??{x:0,y:0,z:0};return this.alive[r]=1,this.positionX[r]=t.position.x,this.positionY[r]=t.position.y,this.positionZ[r]=t.position.z,this.velocityX[r]=i.x,this.velocityY[r]=i.y,this.velocityZ[r]=i.z,this.colorR[r]=n[0],this.colorG[r]=n[1],this.colorB[r]=n[2],this.colorA[r]=n[3],this.size[r]=t.size??2.5,this.lifetime[r]=t.lifetime,this.remaining[r]=t.lifetime,this.gravity[r]=t.gravity??800,this.damping[r]=t.damping??0,this.bounce[r]=t.bounce??.25,this.fade[r]=t.fade?1:0,this.blendMode[r]=t.blendMode==="additive"?1:0,r}update(t,r={}){let n=r.floorZ??-1/0;for(let i=0;i<this.maxParticles;i+=1){if(!this.alive[i])continue;if(this.remaining[i]-=t,this.remaining[i]<=0){this.alive[i]=0;continue}let o=Math.max(0,1-this.damping[i]*t);this.velocityX[i]*=o,this.velocityY[i]*=o,this.velocityZ[i]=this.velocityZ[i]*o-this.gravity[i]*t,this.positionX[i]+=this.velocityX[i]*t,this.positionY[i]+=this.velocityY[i]*t,this.positionZ[i]+=this.velocityZ[i]*t,this.positionZ[i]<n&&(this.positionZ[i]=n,this.velocityZ[i]=-this.velocityZ[i]*this.bounce[i],this.velocityX[i]*=.7,this.velocityY[i]*=.7)}}killAll(){this.alive.fill(0)}aliveCount(){let t=0;for(let r=0;r<this.maxParticles;r+=1)this.alive[r]&&(t+=1);return t}getState(t){return{alive:this.alive[t]===1,position:{x:this.positionX[t],y:this.positionY[t],z:this.positionZ[t]},velocity:{x:this.velocityX[t],y:this.velocityY[t],z:this.velocityZ[t]},remaining:this.remaining[t],color:[this.colorR[t],this.colorG[t],this.colorB[t],this.colorA[t]],size:this.size[t],blendMode:this.blendMode[t]===1?"additive":"alpha"}}buildMesh(t,r){let n=[],i=[],o=[],s=a=>{let d=i.length,l=0;for(let c=0;c<this.maxParticles;c+=1){if(!this.alive[c]||(a==="additive"?1:0)!==this.blendMode[c])continue;l+=1;let h=n.length/9,u=this.size[c]*.5,f=this.fade[c]?Math.max(this.remaining[c]/this.lifetime[c],0):1,m=this.blendMode[c]===1?1.2:1,g=this.colorR[c]*m,p=this.colorG[c]*m,x=this.colorB[c]*m,S=this.colorA[c]*f,_=this.positionX[c],y=this.positionY[c],b=this.positionZ[c],A=t.x*u,v=t.y*u,E=t.z*u,L=r.x*u,w=r.y*u,T=r.z*u,z=[{x:_-A-L,y:y-v-w,z:b-E-T},{x:_+A-L,y:y+v-w,z:b+E-T},{x:_-A+L,y:y-v+w,z:b-E+T},{x:_+A+L,y:y+v+w,z:b+E+T}],U=[[0,1],[1,1],[0,0],[1,0]];z.forEach((C,$)=>{n.push(C.x,C.y,C.z,U[$]?.[0]??0,U[$]?.[1]??0,g,p,x,S)}),i.push(h,h+1,h+2,h+2,h+1,h+3)}l>0&&o.push({blendMode:a,start:d,count:i.length-d})};return s("alpha"),s("additive"),{vertices:new Float32Array(n),indices:new Uint16Array(i),batches:o}}findFreeSlot(){for(let t=0;t<this.maxParticles;t+=1)if(!this.alive[t])return t;return-1}},wl=`#version 300 es
452
+ }`,Oi=class{constructor(t,r,n,i){this.gl=t,this.geometry=_l(r),this.vertexBuffer=new Ee(t,t.STATIC_DRAW),this.indexBuffer=new ye(t,t.STATIC_DRAW),this.vertexArray=new ze(t),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:t.FLOAT,stride:48,offset:0},{index:1,size:3,type:t.FLOAT,stride:48,offset:12},{index:2,size:2,type:t.FLOAT,stride:48,offset:24},{index:3,size:4,type:t.FLOAT,stride:48,offset:32}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,t.STATIC_DRAW),this.update(r,n,i)}update(t,r,n){let i=bl(t,this.geometry,r,n);this.vertexBuffer.upload(i,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose(),this.wireframeIndexBuffer?.dispose()}},Cs=class{constructor(t,r,n,i){this.surfaces=new Map;this.gl=t,this.model=r,this.blend=n,this.lighting=i,r.surfaces.forEach(o=>{this.surfaces.set(o.name,new Oi(t,o,n,i))})}update(t,r){this.blend=t,this.lighting=r??this.lighting;for(let n of this.model.surfaces)this.surfaces.get(n.name)?.update(n,t,this.lighting)}dispose(){for(let t of this.surfaces.values())t.dispose();this.surfaces.clear()}},zs=class{constructor(t){this.gl=t,this.program=Me.create(t,{vertex:vl,fragment:Sl},{a_position:0,a_normal:1,a_texCoord:2,a_color:3}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor")}bind(t,r=[1,1,1,1],n=0){this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,t),this.gl.uniform4fv(this.uniformTint,new Float32Array(r)),this.gl.uniform1i(this.uniformDiffuse,n),this.gl.uniform1i(this.uniformRenderMode,0),this.gl.uniform4f(this.uniformSolidColor,1,1,1,1)}drawSurface(t,r){let n=r?.diffuseSampler??0,i=r?.tint??[1,1,1,1],o=r?.renderMode;this.gl.uniform4fv(this.uniformTint,new Float32Array(i)),this.gl.uniform1i(this.uniformDiffuse,n);let s=0,a=[1,1,1,1];if(o&&(o.mode==="solid"||o.mode==="wireframe"?s=1:o.mode==="solid-faceted"&&(s=2),o.color&&(a=[...o.color])),this.gl.uniform1i(this.uniformRenderMode,s),this.gl.uniform4f(this.uniformSolidColor,a[0],a[1],a[2],a[3]),t.vertexArray.bind(),o&&o.mode==="wireframe"){if(!t.wireframeIndexBuffer){t.wireframeIndexBuffer=new ye(this.gl,this.gl.STATIC_DRAW);let d=yn(t.geometry.indices);t.wireframeIndexBuffer.upload(d),t.wireframeIndexCount=d.length}t.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,t.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else t.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,t.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var l1=[1,1,1,1],Rs=class{constructor(t,r=Math.random){this.maxParticles=t,this.random=r,this.alive=new Uint8Array(t),this.positionX=new Float32Array(t),this.positionY=new Float32Array(t),this.positionZ=new Float32Array(t),this.velocityX=new Float32Array(t),this.velocityY=new Float32Array(t),this.velocityZ=new Float32Array(t),this.colorR=new Float32Array(t),this.colorG=new Float32Array(t),this.colorB=new Float32Array(t),this.colorA=new Float32Array(t),this.size=new Float32Array(t),this.lifetime=new Float32Array(t),this.remaining=new Float32Array(t),this.gravity=new Float32Array(t),this.damping=new Float32Array(t),this.bounce=new Float32Array(t),this.fade=new Uint8Array(t),this.blendMode=new Uint8Array(t)}spawn(t){let r=this.findFreeSlot();if(r===-1)return null;let n=t.color??l1,i=t.velocity??{x:0,y:0,z:0};return this.alive[r]=1,this.positionX[r]=t.position.x,this.positionY[r]=t.position.y,this.positionZ[r]=t.position.z,this.velocityX[r]=i.x,this.velocityY[r]=i.y,this.velocityZ[r]=i.z,this.colorR[r]=n[0],this.colorG[r]=n[1],this.colorB[r]=n[2],this.colorA[r]=n[3],this.size[r]=t.size??2.5,this.lifetime[r]=t.lifetime,this.remaining[r]=t.lifetime,this.gravity[r]=t.gravity??800,this.damping[r]=t.damping??0,this.bounce[r]=t.bounce??.25,this.fade[r]=t.fade?1:0,this.blendMode[r]=t.blendMode==="additive"?1:0,r}update(t,r={}){let n=r.floorZ??-1/0;for(let i=0;i<this.maxParticles;i+=1){if(!this.alive[i])continue;if(this.remaining[i]-=t,this.remaining[i]<=0){this.alive[i]=0;continue}let o=Math.max(0,1-this.damping[i]*t);this.velocityX[i]*=o,this.velocityY[i]*=o,this.velocityZ[i]=this.velocityZ[i]*o-this.gravity[i]*t,this.positionX[i]+=this.velocityX[i]*t,this.positionY[i]+=this.velocityY[i]*t,this.positionZ[i]+=this.velocityZ[i]*t,this.positionZ[i]<n&&(this.positionZ[i]=n,this.velocityZ[i]=-this.velocityZ[i]*this.bounce[i],this.velocityX[i]*=.7,this.velocityY[i]*=.7)}}killAll(){this.alive.fill(0)}aliveCount(){let t=0;for(let r=0;r<this.maxParticles;r+=1)this.alive[r]&&(t+=1);return t}getState(t){return{alive:this.alive[t]===1,position:{x:this.positionX[t],y:this.positionY[t],z:this.positionZ[t]},velocity:{x:this.velocityX[t],y:this.velocityY[t],z:this.velocityZ[t]},remaining:this.remaining[t],color:[this.colorR[t],this.colorG[t],this.colorB[t],this.colorA[t]],size:this.size[t],blendMode:this.blendMode[t]===1?"additive":"alpha"}}buildMesh(t,r){let n=[],i=[],o=[],s=a=>{let d=i.length,l=0;for(let c=0;c<this.maxParticles;c+=1){if(!this.alive[c]||(a==="additive"?1:0)!==this.blendMode[c])continue;l+=1;let h=n.length/9,u=this.size[c]*.5,f=this.fade[c]?Math.max(this.remaining[c]/this.lifetime[c],0):1,m=this.blendMode[c]===1?1.2:1,g=this.colorR[c]*m,p=this.colorG[c]*m,x=this.colorB[c]*m,S=this.colorA[c]*f,_=this.positionX[c],y=this.positionY[c],b=this.positionZ[c],A=t.x*u,v=t.y*u,E=t.z*u,L=r.x*u,w=r.y*u,T=r.z*u,R=[{x:_-A-L,y:y-v-w,z:b-E-T},{x:_+A-L,y:y+v-w,z:b+E-T},{x:_-A+L,y:y-v+w,z:b-E+T},{x:_+A+L,y:y+v+w,z:b+E+T}],U=[[0,1],[1,1],[0,0],[1,0]];R.forEach((z,$)=>{n.push(z.x,z.y,z.z,U[$]?.[0]??0,U[$]?.[1]??0,g,p,x,S)}),i.push(h,h+1,h+2,h+2,h+1,h+3)}l>0&&o.push({blendMode:a,start:d,count:i.length-d})};return s("alpha"),s("additive"),{vertices:new Float32Array(n),indices:new Uint16Array(i),batches:o}}findFreeSlot(){for(let t=0;t<this.maxParticles;t+=1)if(!this.alive[t])return t;return-1}},wl=`#version 300 es
453
453
  precision highp float;
454
454
 
455
455
  layout(location = 0) in vec3 a_position;
@@ -477,7 +477,7 @@ void main() {
477
477
  float dist = distance(v_uv, vec2(0.5));
478
478
  float alpha = v_color.a * (1.0 - smoothstep(0.35, 0.5, dist));
479
479
  o_color = vec4(v_color.rgb, alpha);
480
- }`,ks=class{constructor(t,r){this.vertexCapacity=0;this.indexCapacity=0;this.gl=t,this.system=r,this.program=Me.create(t,{vertex:wl,fragment:Al}),this.vertexBuffer=new Ee(t,t.DYNAMIC_DRAW),this.indexBuffer=new ye(t,t.DYNAMIC_DRAW),this.vertexArray=new Ce(t),this.vertexArray.configureAttributes([{index:0,size:3,type:t.FLOAT,stride:36,offset:0},{index:1,size:2,type:t.FLOAT,stride:36,offset:12},{index:2,size:4,type:t.FLOAT,stride:36,offset:20}],this.vertexBuffer)}render(t){let r=this.system.buildMesh(t.viewRight,t.viewUp);if(r.indices.length===0)return;let n=r.vertices;r.vertices.byteLength>this.vertexCapacity?(this.vertexCapacity=r.vertices.byteLength,this.vertexBuffer.upload(n,this.gl.DYNAMIC_DRAW)):this.vertexBuffer.update(n);let i=r.indices;r.indices.byteLength>this.indexCapacity?(this.indexCapacity=r.indices.byteLength,this.indexBuffer.upload(i,this.gl.DYNAMIC_DRAW)):this.indexBuffer.update(i),this.gl.depthMask(!1),this.program.use();let o=this.program.getUniformLocation("u_viewProjection");this.gl.uniformMatrix4fv(o,!1,t.viewProjection),this.vertexArray.bind();for(let s of r.batches)s.blendMode==="additive"?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFuncSeparate(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,s.count,this.gl.UNSIGNED_SHORT,s.start*2);this.gl.depthMask(!0)}dispose(){this.program.dispose(),this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}};function h0(e){let{system:t,origin:r,normal:n={x:0,y:0,z:1}}=e;for(let i=0;i<12;i+=1){let o=200+t.random()*180,s=t.random()*.35;t.spawn({position:r,velocity:{x:n.x*o+(t.random()-.5)*80,y:n.y*o+(t.random()-.5)*80,z:Math.max(n.z*o,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+t.random()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let i=0;i<8;i+=1)t.spawn({position:r,velocity:{x:(t.random()-.5)*40,y:(t.random()-.5)*40,z:80+t.random()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function m0(e){let{system:t,origin:r}=e;for(let n=0;n<40;n+=1){let i=t.random()*Math.PI*2,o=Math.acos(2*t.random()-1),s=220+t.random()*260,a={x:Math.sin(o)*Math.cos(i),y:Math.sin(o)*Math.sin(i),z:Math.cos(o)};t.spawn({position:r,velocity:{x:a.x*s,y:a.y*s,z:a.z*s},color:[1,.6,.2,1],size:5,lifetime:.9,gravity:700,damping:1,bounce:.35,blendMode:"additive",fade:!0})}for(let n=0;n<16;n+=1)t.spawn({position:r,velocity:{x:(t.random()-.5)*30,y:(t.random()-.5)*30,z:120+t.random()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function p0(e){let{system:t,origin:r,direction:n={x:0,y:0,z:1}}=e;for(let i=0;i<24;i+=1){let o=120+t.random()*180;t.spawn({position:r,velocity:{x:n.x*o+(t.random()-.5)*70,y:n.y*o+(t.random()-.5)*70,z:n.z*o+t.random()*80},color:[.6,0,0,.95],size:3,lifetime:.8,gravity:900,damping:1,bounce:.2,blendMode:"alpha",fade:!0})}}function g0(e){let{system:t,origin:r}=e;for(let n=0;n<30;n+=1){let i=t.random()*Math.PI*2,o=8+t.random()*8;t.spawn({position:r,velocity:{x:Math.cos(i)*o,y:Math.sin(i)*o,z:100+t.random()*80},color:[.4,.6,1,.9],size:4,lifetime:.5,gravity:300,damping:2,blendMode:"additive",fade:!0})}}function y0(e){let{system:t,origin:r,direction:n={x:1,y:0,z:0}}=e;for(let i=0;i<10;i+=1){let o=350+t.random()*100;t.spawn({position:r,velocity:{x:n.x*o+(t.random()-.5)*30,y:n.y*o+(t.random()-.5)*30,z:n.z*o+(t.random()-.5)*30},color:[1,.8,.3,1],size:3,lifetime:.25,gravity:200,damping:1,blendMode:"additive",fade:!0})}}function x0(e){let{system:t,origin:r,direction:n={x:0,y:0,z:0}}=e;for(let i=0;i<6;i+=1)t.spawn({position:{x:r.x+n.x*i*2,y:r.y+n.y*i*2,z:r.z+n.z*i*2},velocity:{x:(t.random()-.5)*15,y:(t.random()-.5)*15,z:20+t.random()*15},color:[.6,.6,.6,.8],size:2.2,lifetime:.6,gravity:200,damping:1.5,blendMode:"alpha",fade:!0})}var Ar=class{constructor(t){this.buffer=t,this.view=new DataView(t),this.offset=0}hasMore(){return this.offset<this.buffer.byteLength}readNextBlock(){if(this.offset+4>this.buffer.byteLength)return null;let t=this.view.getInt32(this.offset,!0);if(this.offset+=4,t<0||t>2097152)return console.warn(`DemoReader: Invalid block length ${t} at offset ${this.offset-4}`),null;if(this.offset+t>this.buffer.byteLength)return console.warn(`DemoReader: Incomplete block. Expected ${t} bytes, but only ${this.buffer.byteLength-this.offset} remain.`),null;let r=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,{length:t,data:new kn(r)}}reset(){this.offset=0}getOffset(){return this.offset}};function Mn(e){let t=e.length;for(;--t>=0;)e[t]=0}var c1=0,nu=1,d1=2,u1=3,f1=258,Zl=29,Qi=256,Wi=Qi+1+Zl,Sn=30,Yl=19,iu=2*Wi+1,Mr=15,Ml=16,h1=7,ql=256,ou=16,su=17,au=18,Nl=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ns=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),m1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),lu=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p1=512,It=new Array((Wi+2)*2);Mn(It);var Hi=new Array(Sn*2);Mn(Hi);var Xi=new Array(p1);Mn(Xi);var Ki=new Array(f1-u1+1);Mn(Ki);var jl=new Array(Zl);Mn(jl);var Us=new Array(Sn);Mn(Us);function El(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var cu,du,uu;function Ll(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var fu=e=>e<256?Xi[e]:Xi[256+(e>>>7)],$i=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},ze=(e,t,r)=>{e.bi_valid>Ml-r?(e.bi_buf|=t<<e.bi_valid&65535,$i(e,e.bi_buf),e.bi_buf=t>>Ml-e.bi_valid,e.bi_valid+=r-Ml):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},ft=(e,t,r)=>{ze(e,r[t*2],r[t*2+1])},hu=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},g1=e=>{e.bi_valid===16?($i(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},y1=(e,t)=>{let r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,d=t.stat_desc.max_length,l,c,h,u,f,m,g=0;for(u=0;u<=Mr;u++)e.bl_count[u]=0;for(r[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<iu;l++)c=e.heap[l],u=r[r[c*2+1]*2+1]+1,u>d&&(u=d,g++),r[c*2+1]=u,!(c>n)&&(e.bl_count[u]++,f=0,c>=a&&(f=s[c-a]),m=r[c*2],e.opt_len+=m*(u+f),o&&(e.static_len+=m*(i[c*2+1]+f)));if(g!==0){do{for(u=d-1;e.bl_count[u]===0;)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[d]--,g-=2}while(g>0);for(u=d;u!==0;u--)for(c=e.bl_count[u];c!==0;)h=e.heap[--l],!(h>n)&&(r[h*2+1]!==u&&(e.opt_len+=(u-r[h*2+1])*r[h*2],r[h*2+1]=u),c--)}},mu=(e,t,r)=>{let n=new Array(Mr+1),i=0,o,s;for(o=1;o<=Mr;o++)i=i+r[o-1]<<1,n[o]=i;for(s=0;s<=t;s++){let a=e[s*2+1];a!==0&&(e[s*2]=hu(n[a]++,a))}},x1=()=>{let e,t,r,n,i,o=new Array(Mr+1);for(r=0,n=0;n<Zl-1;n++)for(jl[n]=r,e=0;e<1<<Nl[n];e++)Ki[r++]=n;for(Ki[r-1]=n,i=0,n=0;n<16;n++)for(Us[n]=i,e=0;e<1<<Ns[n];e++)Xi[i++]=n;for(i>>=7;n<Sn;n++)for(Us[n]=i<<7,e=0;e<1<<Ns[n]-7;e++)Xi[256+i++]=n;for(t=0;t<=Mr;t++)o[t]=0;for(e=0;e<=143;)It[e*2+1]=8,e++,o[8]++;for(;e<=255;)It[e*2+1]=9,e++,o[9]++;for(;e<=279;)It[e*2+1]=7,e++,o[7]++;for(;e<=287;)It[e*2+1]=8,e++,o[8]++;for(mu(It,Wi+1,o),e=0;e<Sn;e++)Hi[e*2+1]=5,Hi[e*2]=hu(e,5);cu=new El(It,Nl,Qi+1,Wi,Mr),du=new El(Hi,Ns,0,Sn,Mr),uu=new El(new Array(0),m1,0,Yl,h1)},pu=e=>{let t;for(t=0;t<Wi;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Sn;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Yl;t++)e.bl_tree[t*2]=0;e.dyn_ltree[ql*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},gu=e=>{e.bi_valid>8?$i(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_0=(e,t,r,n)=>{let i=t*2,o=r*2;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]},Tl=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&_0(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!_0(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},b0=(e,t,r)=>{let n,i,o=0,s,a;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+o++]&255,n+=(e.pending_buf[e.sym_buf+o++]&255)<<8,i=e.pending_buf[e.sym_buf+o++],n===0?ft(e,i,t):(s=Ki[i],ft(e,s+Qi+1,t),a=Nl[s],a!==0&&(i-=jl[s],ze(e,i,a)),n--,s=fu(n),ft(e,s,r),a=Ns[s],a!==0&&(n-=Us[s],ze(e,n,a)));while(o<e.sym_next);ft(e,ql,t)},Ul=(e,t)=>{let r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems,s,a,d=-1,l;for(e.heap_len=0,e.heap_max=iu,s=0;s<o;s++)r[s*2]!==0?(e.heap[++e.heap_len]=d=s,e.depth[s]=0):r[s*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=d<2?++d:0,r[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=n[l*2+1]);for(t.max_code=d,s=e.heap_len>>1;s>=1;s--)Tl(e,r,s);l=o;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Tl(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,r[l*2]=r[s*2]+r[a*2],e.depth[l]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,r[s*2+1]=r[a*2+1]=l,e.heap[1]=l++,Tl(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],y1(e,t),mu(r,d,e.bl_count)},v0=(e,t,r)=>{let n,i=-1,o,s=t[1],a=0,d=7,l=4;for(s===0&&(d=138,l=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)o=s,s=t[(n+1)*2+1],!(++a<d&&o===s)&&(a<l?e.bl_tree[o*2]+=a:o!==0?(o!==i&&e.bl_tree[o*2]++,e.bl_tree[ou*2]++):a<=10?e.bl_tree[su*2]++:e.bl_tree[au*2]++,a=0,i=o,s===0?(d=138,l=3):o===s?(d=6,l=3):(d=7,l=4))},S0=(e,t,r)=>{let n,i=-1,o,s=t[1],a=0,d=7,l=4;for(s===0&&(d=138,l=3),n=0;n<=r;n++)if(o=s,s=t[(n+1)*2+1],!(++a<d&&o===s)){if(a<l)do ft(e,o,e.bl_tree);while(--a!==0);else o!==0?(o!==i&&(ft(e,o,e.bl_tree),a--),ft(e,ou,e.bl_tree),ze(e,a-3,2)):a<=10?(ft(e,su,e.bl_tree),ze(e,a-3,3)):(ft(e,au,e.bl_tree),ze(e,a-11,7));a=0,i=o,s===0?(d=138,l=3):o===s?(d=6,l=3):(d=7,l=4)}},_1=e=>{let t;for(v0(e,e.dyn_ltree,e.l_desc.max_code),v0(e,e.dyn_dtree,e.d_desc.max_code),Ul(e,e.bl_desc),t=Yl-1;t>=3&&e.bl_tree[lu[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},b1=(e,t,r,n)=>{let i;for(ze(e,t-257,5),ze(e,r-1,5),ze(e,n-4,4),i=0;i<n;i++)ze(e,e.bl_tree[lu[i]*2+1],3);S0(e,e.dyn_ltree,t-1),S0(e,e.dyn_dtree,r-1)},v1=e=>{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(r=32;r<Qi;r++)if(e.dyn_ltree[r*2]!==0)return 1;return 0},w0=!1,S1=e=>{w0||(x1(),w0=!0),e.l_desc=new Ll(e.dyn_ltree,cu),e.d_desc=new Ll(e.dyn_dtree,du),e.bl_desc=new Ll(e.bl_tree,uu),e.bi_buf=0,e.bi_valid=0,pu(e)},yu=(e,t,r,n)=>{ze(e,(c1<<1)+(n?1:0),3),gu(e),$i(e,r),$i(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},w1=e=>{ze(e,nu<<1,3),ft(e,ql,It),g1(e)},A1=(e,t,r,n)=>{let i,o,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=v1(e)),Ul(e,e.l_desc),Ul(e,e.d_desc),s=_1(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&t!==-1?yu(e,t,r,n):e.strategy===4||o===i?(ze(e,(nu<<1)+(n?1:0),3),b0(e,It,Hi)):(ze(e,(d1<<1)+(n?1:0),3),b1(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),b0(e,e.dyn_ltree,e.dyn_dtree)),pu(e),n&&gu(e)},M1=(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Ki[r]+Qi+1)*2]++,e.dyn_dtree[fu(t)*2]++),e.sym_next===e.sym_end),E1=S1,L1=yu,T1=A1,I1=M1,R1=w1,C1={_tr_init:E1,_tr_stored_block:L1,_tr_flush_block:T1,_tr_tally:I1,_tr_align:R1},z1=(e,t,r,n)=>{let i=e&65535|0,o=e>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+t[n++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0},Zi=z1,k1=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},F1=new Uint32Array(k1()),P1=(e,t,r,n)=>{let i=F1,o=n+r;e^=-1;for(let s=n;s<o;s++)e=e>>>8^i[(e^t[s])&255];return e^-1},fe=P1,Tr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Cr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:D1,_tr_stored_block:Hl,_tr_flush_block:O1,_tr_tally:tr,_tr_align:B1}=C1,{Z_NO_FLUSH:rr,Z_PARTIAL_FLUSH:N1,Z_FULL_FLUSH:U1,Z_FINISH:qe,Z_BLOCK:A0,Z_OK:he,Z_STREAM_END:M0,Z_STREAM_ERROR:ht,Z_DATA_ERROR:H1,Z_BUF_ERROR:Il,Z_DEFAULT_COMPRESSION:V1,Z_FILTERED:G1,Z_HUFFMAN_ONLY:Fs,Z_RLE:W1,Z_FIXED:X1,Z_DEFAULT_STRATEGY:K1,Z_UNKNOWN:$1,Z_DEFLATED:Gs}=Cr,Z1=9,Y1=15,q1=8,j1=29,Q1=256,Vl=Q1+1+j1,J1=30,eg=19,tg=2*Vl+1,rg=15,V=3,er=258,mt=er+V+1,ng=32,wn=42,Ql=57,Gl=69,Wl=73,Xl=91,Kl=103,Er=113,Ni=666,Le=1,En=2,Ir=3,Ln=4,ig=3,Lr=(e,t)=>(e.msg=Tr[t],t),E0=e=>e*2-(e>4?9:0),Jt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},og=e=>{let t,r,n,i=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=i?r-i:0;while(--t);t=i,n=t;do r=e.prev[--n],e.prev[n]=r>=i?r-i:0;while(--t)},sg=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,nr=sg,Be=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},Ne=(e,t)=>{O1(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Be(e.strm)},X=(e,t)=>{e.pending_buf[e.pending++]=t},Bi=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},$l=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),e.state.wrap===1?e.adler=Zi(e.adler,t,i,r):e.state.wrap===2&&(e.adler=fe(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},xu=(e,t)=>{let r=e.max_chain_length,n=e.strstart,i,o,s=e.prev_length,a=e.nice_match,d=e.strstart>e.w_size-mt?e.strstart-(e.w_size-mt):0,l=e.window,c=e.w_mask,h=e.prev,u=e.strstart+er,f=l[n+s-1],m=l[n+s];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do if(i=t,!(l[i+s]!==m||l[i+s-1]!==f||l[i]!==l[n]||l[++i]!==l[n+1])){n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<u);if(o=er-(u-n),n=u-er,o>s){if(e.match_start=t,s=o,o>=a)break;f=l[n+s-1],m=l[n+s]}}while((t=h[t&c])>d&&--r!==0);return s<=e.lookahead?s:e.lookahead},An=e=>{let t=e.w_size,r,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-mt)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),og(e),n+=t),e.strm.avail_in===0)break;if(r=$l(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.lookahead+e.insert>=V)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=nr(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=nr(e,e.ins_h,e.window[i+V-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<V)););}while(e.lookahead<mt&&e.strm.avail_in!==0)},_u=(e,t)=>{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,i,o,s=0,a=e.strm.avail_in;do{if(n=65535,o=e.bi_valid+42>>3,e.strm.avail_out<o||(o=e.strm.avail_out-o,i=e.strstart-e.block_start,n>i+e.strm.avail_in&&(n=i+e.strm.avail_in),n>o&&(n=o),n<r&&(n===0&&t!==qe||t===rr||n!==i+e.strm.avail_in)))break;s=t===qe&&n===i+e.strm.avail_in?1:0,Hl(e,0,0,s),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Be(e.strm),i&&(i>n&&(i=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,n-=i),n&&($l(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(s===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?Ln:t!==rr&&t!==qe&&e.strm.avail_in===0&&e.strstart===e.block_start?En:(o=e.window_size-e.strstart,e.strm.avail_in>o&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,o+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),o>e.strm.avail_in&&(o=e.strm.avail_in),o&&($l(e.strm,e.window,e.strstart,o),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.high_water<e.strstart&&(e.high_water=e.strstart),o=e.bi_valid+42>>3,o=e.pending_buf_size-o>65535?65535:e.pending_buf_size-o,r=o>e.w_size?e.w_size:o,i=e.strstart-e.block_start,(i>=r||(i||t===qe)&&t!==rr&&e.strm.avail_in===0&&i<=o)&&(n=i>o?o:i,s=t===qe&&e.strm.avail_in===0&&n===i?1:0,Hl(e,e.block_start,n,s),e.block_start+=n,Be(e.strm)),s?Ir:Le)},Rl=(e,t)=>{let r,n;for(;;){if(e.lookahead<mt){if(An(e),e.lookahead<mt&&t===rr)return Le;if(e.lookahead===0)break}if(r=0,e.lookahead>=V&&(e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-mt&&(e.match_length=xu(e,r)),e.match_length>=V)if(n=tr(e,e.strstart-e.match_start,e.match_length-V),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=V){e.match_length--;do e.strstart++,e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=nr(e,e.ins_h,e.window[e.strstart+1]);else n=tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Ne(e,!1),e.strm.avail_out===0))return Le}return e.insert=e.strstart<V-1?e.strstart:V-1,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En},bn=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<mt){if(An(e),e.lookahead<mt&&t===rr)return Le;if(e.lookahead===0)break}if(r=0,e.lookahead>=V&&(e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=V-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-mt&&(e.match_length=xu(e,r),e.match_length<=5&&(e.strategy===G1||e.match_length===V&&e.strstart-e.match_start>4096)&&(e.match_length=V-1)),e.prev_length>=V&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-V,n=tr(e,e.strstart-1-e.prev_match,e.prev_length-V),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=V-1,e.strstart++,n&&(Ne(e,!1),e.strm.avail_out===0))return Le}else if(e.match_available){if(n=tr(e,0,e.window[e.strstart-1]),n&&Ne(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Le}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=tr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<V-1?e.strstart:V-1,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En},ag=(e,t)=>{let r,n,i,o,s=e.window;for(;;){if(e.lookahead<=er){if(An(e),e.lookahead<=er&&t===rr)return Le;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=V&&e.strstart>0&&(i=e.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=e.strstart+er;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<o);e.match_length=er-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=V?(r=tr(e,1,e.match_length-V),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ne(e,!1),e.strm.avail_out===0))return Le}return e.insert=0,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En},lg=(e,t)=>{let r;for(;;){if(e.lookahead===0&&(An(e),e.lookahead===0)){if(t===rr)return Le;break}if(e.match_length=0,r=tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ne(e,!1),e.strm.avail_out===0))return Le}return e.insert=0,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En};function ut(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var Ui=[new ut(0,0,0,0,_u),new ut(4,4,8,4,Rl),new ut(4,5,16,8,Rl),new ut(4,6,32,32,Rl),new ut(4,4,16,16,bn),new ut(8,16,32,32,bn),new ut(8,16,128,128,bn),new ut(8,32,128,256,bn),new ut(32,128,258,1024,bn),new ut(32,258,258,4096,bn)],cg=e=>{e.window_size=2*e.w_size,Jt(e.head),e.max_lazy_match=Ui[e.level].max_lazy,e.good_match=Ui[e.level].good_length,e.nice_match=Ui[e.level].nice_length,e.max_chain_length=Ui[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=V-1,e.match_available=0,e.ins_h=0};function dg(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Gs,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(tg*2),this.dyn_dtree=new Uint16Array((2*J1+1)*2),this.bl_tree=new Uint16Array((2*eg+1)*2),Jt(this.dyn_ltree),Jt(this.dyn_dtree),Jt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(rg+1),this.heap=new Uint16Array(2*Vl+1),Jt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Vl+1),Jt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ji=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==wn&&t.status!==Ql&&t.status!==Gl&&t.status!==Wl&&t.status!==Xl&&t.status!==Kl&&t.status!==Er&&t.status!==Ni?1:0},bu=e=>{if(Ji(e))return Lr(e,ht);e.total_in=e.total_out=0,e.data_type=$1;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Ql:t.wrap?wn:Er,e.adler=t.wrap===2?0:1,t.last_flush=-2,D1(t),he},vu=e=>{let t=bu(e);return t===he&&cg(e.state),t},ug=(e,t)=>Ji(e)||e.state.wrap!==2?ht:(e.state.gzhead=t,he),Su=(e,t,r,n,i,o)=>{if(!e)return ht;let s=1;if(t===V1&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>Z1||r!==Gs||n<8||n>15||t<0||t>9||o<0||o>X1||n===8&&s!==1)return Lr(e,ht);n===8&&(n=9);let a=new dg;return e.state=a,a.strm=e,a.status=wn,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+V-1)/V),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=t,a.strategy=o,a.method=r,vu(e)},fg=(e,t)=>Su(e,t,Gs,Y1,q1,K1),hg=(e,t)=>{if(Ji(e)||t>A0||t<0)return e?Lr(e,ht):ht;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===Ni&&t!==qe)return Lr(e,e.avail_out===0?Il:ht);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(Be(e),e.avail_out===0)return r.last_flush=-1,he}else if(e.avail_in===0&&E0(t)<=E0(n)&&t!==qe)return Lr(e,Il);if(r.status===Ni&&e.avail_in!==0)return Lr(e,Il);if(r.status===wn&&r.wrap===0&&(r.status=Er),r.status===wn){let i=Gs+(r.w_bits-8<<4)<<8,o=-1;if(r.strategy>=Fs||r.level<2?o=0:r.level<6?o=1:r.level===6?o=2:o=3,i|=o<<6,r.strstart!==0&&(i|=ng),i+=31-i%31,Bi(r,i),r.strstart!==0&&(Bi(r,e.adler>>>16),Bi(r,e.adler&65535)),e.adler=1,r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(r.status===Ql){if(e.adler=0,X(r,31),X(r,139),X(r,8),r.gzhead)X(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),X(r,r.gzhead.time&255),X(r,r.gzhead.time>>8&255),X(r,r.gzhead.time>>16&255),X(r,r.gzhead.time>>24&255),X(r,r.level===9?2:r.strategy>=Fs||r.level<2?4:0),X(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(X(r,r.gzhead.extra.length&255),X(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=fe(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Gl;else if(X(r,0),X(r,0),X(r,0),X(r,0),X(r,0),X(r,r.level===9?2:r.strategy>=Fs||r.level<2?4:0),X(r,ig),r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(r.status===Gl){if(r.gzhead.extra){let i=r.pending,o=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+o>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex+=a,Be(e),r.pending!==0)return r.last_flush=-1,he;i=0,o-=a}let s=new Uint8Array(r.gzhead.extra);r.pending_buf.set(s.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Wl}if(r.status===Wl){if(r.gzhead.name){let i=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),Be(e),r.pending!==0)return r.last_flush=-1,he;i=0}r.gzindex<r.gzhead.name.length?o=r.gzhead.name.charCodeAt(r.gzindex++)&255:o=0,X(r,o)}while(o!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Xl}if(r.status===Xl){if(r.gzhead.comment){let i=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),Be(e),r.pending!==0)return r.last_flush=-1,he;i=0}r.gzindex<r.gzhead.comment.length?o=r.gzhead.comment.charCodeAt(r.gzindex++)&255:o=0,X(r,o)}while(o!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i))}r.status=Kl}if(r.status===Kl){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Be(e),r.pending!==0))return r.last_flush=-1,he;X(r,e.adler&255),X(r,e.adler>>8&255),e.adler=0}if(r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(e.avail_in!==0||r.lookahead!==0||t!==rr&&r.status!==Ni){let i=r.level===0?_u(r,t):r.strategy===Fs?lg(r,t):r.strategy===W1?ag(r,t):Ui[r.level].func(r,t);if((i===Ir||i===Ln)&&(r.status=Ni),i===Le||i===Ir)return e.avail_out===0&&(r.last_flush=-1),he;if(i===En&&(t===N1?B1(r):t!==A0&&(Hl(r,0,0,!1),t===U1&&(Jt(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Be(e),e.avail_out===0))return r.last_flush=-1,he}return t!==qe?he:r.wrap<=0?M0:(r.wrap===2?(X(r,e.adler&255),X(r,e.adler>>8&255),X(r,e.adler>>16&255),X(r,e.adler>>24&255),X(r,e.total_in&255),X(r,e.total_in>>8&255),X(r,e.total_in>>16&255),X(r,e.total_in>>24&255)):(Bi(r,e.adler>>>16),Bi(r,e.adler&65535)),Be(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?he:M0)},mg=e=>{if(Ji(e))return ht;let t=e.state.status;return e.state=null,t===Er?Lr(e,H1):he},pg=(e,t)=>{let r=t.length;if(Ji(e))return ht;let n=e.state,i=n.wrap;if(i===2||i===1&&n.status!==wn||n.lookahead)return ht;if(i===1&&(e.adler=Zi(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){i===0&&(Jt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let d=new Uint8Array(n.w_size);d.set(t.subarray(r-n.w_size,r),0),t=d,r=n.w_size}let o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,An(n);n.lookahead>=V;){let d=n.strstart,l=n.lookahead-(V-1);do n.ins_h=nr(n,n.ins_h,n.window[d+V-1]),n.prev[d&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=d,d++;while(--l);n.strstart=d,n.lookahead=V-1,An(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=V-1,n.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,n.wrap=i,he},gg=fg,yg=Su,xg=vu,_g=bu,bg=ug,vg=hg,Sg=mg,wg=pg,Ag="pako deflate (from Nodeca project)",Vi={deflateInit:gg,deflateInit2:yg,deflateReset:xg,deflateResetKeep:_g,deflateSetHeader:bg,deflate:vg,deflateEnd:Sg,deflateSetDictionary:wg,deflateInfo:Ag},Mg=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Eg=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)Mg(r,n)&&(e[n]=r[n])}}return e},Lg=e=>{let t=0;for(let n=0,i=e.length;n<i;n++)t+=e[n].length;let r=new Uint8Array(t);for(let n=0,i=0,o=e.length;n<o;n++){let s=e[n];r.set(s,i),i+=s.length}return r},Ws={assign:Eg,flattenChunks:Lg},wu=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{wu=!1}var Yi=new Uint8Array(256);for(let e=0;e<256;e++)Yi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Yi[254]=Yi[254]=1;var Tg=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,i,o,s=e.length,a=0;for(i=0;i<s;i++)r=e.charCodeAt(i),(r&64512)===55296&&i+1<s&&(n=e.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(a),o=0,i=0;o<a;i++)r=e.charCodeAt(i),(r&64512)===55296&&i+1<s&&(n=e.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|r&63):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|r&63):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|r&63);return t},Ig=(e,t)=>{if(t<65534&&e.subarray&&wu)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r},Rg=(e,t)=>{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,i,o=new Array(r*2);for(i=0,n=0;n<r;){let s=e[n++];if(s<128){o[i++]=s;continue}let a=Yi[s];if(a>4){o[i++]=65533,n+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&n<r;)s=s<<6|e[n++]&63,a--;if(a>1){o[i++]=65533;continue}s<65536?o[i++]=s:(s-=65536,o[i++]=55296|s>>10&1023,o[i++]=56320|s&1023)}return Ig(o,i)},Cg=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+Yi[e[r]]>t?r:t},qi={string2buf:Tg,buf2string:Rg,utf8border:Cg};function zg(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Au=zg,Mu=Object.prototype.toString,{Z_NO_FLUSH:kg,Z_SYNC_FLUSH:Fg,Z_FULL_FLUSH:Pg,Z_FINISH:Dg,Z_OK:Hs,Z_STREAM_END:Og,Z_DEFAULT_COMPRESSION:Bg,Z_DEFAULT_STRATEGY:Ng,Z_DEFLATED:Ug}=Cr;function eo(e){this.options=Ws.assign({level:Bg,method:Ug,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ng},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Au,this.strm.avail_out=0;let r=Vi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Hs)throw new Error(Tr[r]);if(t.header&&Vi.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=qi.string2buf(t.dictionary):Mu.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=Vi.deflateSetDictionary(this.strm,n),r!==Hs)throw new Error(Tr[r]);this._dict_set=!0}}eo.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i,o;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?Dg:kg,typeof e=="string"?r.input=qi.string2buf(e):Mu.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===Fg||o===Pg)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(i=Vi.deflate(r,o),i===Og)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Vi.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Hs;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};eo.prototype.onData=function(e){this.chunks.push(e)};eo.prototype.onEnd=function(e){e===Hs&&(this.result=Ws.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Jl(e,t){let r=new eo(t);if(r.push(e,!0),r.err)throw r.msg||Tr[r.err];return r.result}function Hg(e,t){return t=t||{},t.raw=!0,Jl(e,t)}function Vg(e,t){return t=t||{},t.gzip=!0,Jl(e,t)}var Gg=eo,Wg=Jl,Xg=Hg,Kg=Vg,$g=Cr,Zg={Deflate:Gg,deflate:Wg,deflateRaw:Xg,gzip:Kg,constants:$g},Ps=16209,Yg=16191,qg=function(t,r){let n,i,o,s,a,d,l,c,h,u,f,m,g,p,x,S,_,y,b,A,v,E,L,w,T=t.state;n=t.next_in,L=t.input,i=n+(t.avail_in-5),o=t.next_out,w=t.output,s=o-(r-t.avail_out),a=o+(t.avail_out-257),d=T.dmax,l=T.wsize,c=T.whave,h=T.wnext,u=T.window,f=T.hold,m=T.bits,g=T.lencode,p=T.distcode,x=(1<<T.lenbits)-1,S=(1<<T.distbits)-1;e:do{m<15&&(f+=L[n++]<<m,m+=8,f+=L[n++]<<m,m+=8),_=g[f&x];t:for(;;){if(y=_>>>24,f>>>=y,m-=y,y=_>>>16&255,y===0)w[o++]=_&65535;else if(y&16){b=_&65535,y&=15,y&&(m<y&&(f+=L[n++]<<m,m+=8),b+=f&(1<<y)-1,f>>>=y,m-=y),m<15&&(f+=L[n++]<<m,m+=8,f+=L[n++]<<m,m+=8),_=p[f&S];r:for(;;){if(y=_>>>24,f>>>=y,m-=y,y=_>>>16&255,y&16){if(A=_&65535,y&=15,m<y&&(f+=L[n++]<<m,m+=8,m<y&&(f+=L[n++]<<m,m+=8)),A+=f&(1<<y)-1,A>d){t.msg="invalid distance too far back",T.mode=Ps;break e}if(f>>>=y,m-=y,y=o-s,A>y){if(y=A-y,y>c&&T.sane){t.msg="invalid distance too far back",T.mode=Ps;break e}if(v=0,E=u,h===0){if(v+=l-y,y<b){b-=y;do w[o++]=u[v++];while(--y);v=o-A,E=w}}else if(h<y){if(v+=l+h-y,y-=h,y<b){b-=y;do w[o++]=u[v++];while(--y);if(v=0,h<b){y=h,b-=y;do w[o++]=u[v++];while(--y);v=o-A,E=w}}}else if(v+=h-y,y<b){b-=y;do w[o++]=u[v++];while(--y);v=o-A,E=w}for(;b>2;)w[o++]=E[v++],w[o++]=E[v++],w[o++]=E[v++],b-=3;b&&(w[o++]=E[v++],b>1&&(w[o++]=E[v++]))}else{v=o-A;do w[o++]=w[v++],w[o++]=w[v++],w[o++]=w[v++],b-=3;while(b>2);b&&(w[o++]=w[v++],b>1&&(w[o++]=w[v++]))}}else if((y&64)===0){_=p[(_&65535)+(f&(1<<y)-1)];continue r}else{t.msg="invalid distance code",T.mode=Ps;break e}break}}else if((y&64)===0){_=g[(_&65535)+(f&(1<<y)-1)];continue t}else if(y&32){T.mode=Yg;break e}else{t.msg="invalid literal/length code",T.mode=Ps;break e}break}}while(n<i&&o<a);b=m>>3,n-=b,m-=b<<3,f&=(1<<m)-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?5+(i-n):5-(n-i),t.avail_out=o<a?257+(a-o):257-(o-a),T.hold=f,T.bits=m},vn=15,L0=852,T0=592,I0=0,Cl=1,R0=2,jg=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Qg=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Jg=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ey=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),ty=(e,t,r,n,i,o,s,a)=>{let d=a.bits,l=0,c=0,h=0,u=0,f=0,m=0,g=0,p=0,x=0,S=0,_,y,b,A,v,E=null,L,w=new Uint16Array(vn+1),T=new Uint16Array(vn+1),z=null,U,C,$;for(l=0;l<=vn;l++)w[l]=0;for(c=0;c<n;c++)w[t[r+c]]++;for(f=d,u=vn;u>=1&&w[u]===0;u--);if(f>u&&(f=u),u===0)return i[o++]=1<<24|64<<16|0,i[o++]=1<<24|64<<16|0,a.bits=1,0;for(h=1;h<u&&w[h]===0;h++);for(f<h&&(f=h),p=1,l=1;l<=vn;l++)if(p<<=1,p-=w[l],p<0)return-1;if(p>0&&(e===I0||u!==1))return-1;for(T[1]=0,l=1;l<vn;l++)T[l+1]=T[l]+w[l];for(c=0;c<n;c++)t[r+c]!==0&&(s[T[t[r+c]]++]=c);if(e===I0?(E=z=s,L=20):e===Cl?(E=jg,z=Qg,L=257):(E=Jg,z=ey,L=0),S=0,c=0,l=h,v=o,m=f,g=0,b=-1,x=1<<f,A=x-1,e===Cl&&x>L0||e===R0&&x>T0)return 1;for(;;){U=l-g,s[c]+1<L?(C=0,$=s[c]):s[c]>=L?(C=z[s[c]-L],$=E[s[c]-L]):(C=96,$=0),_=1<<l-g,y=1<<m,h=y;do y-=_,i[v+(S>>g)+y]=U<<24|C<<16|$|0;while(y!==0);for(_=1<<l-1;S&_;)_>>=1;if(_!==0?(S&=_-1,S+=_):S=0,c++,--w[l]===0){if(l===u)break;l=t[r+s[c]]}if(l>f&&(S&A)!==b){for(g===0&&(g=f),v+=h,m=l-g,p=1<<m;m+g<u&&(p-=w[m+g],!(p<=0));)m++,p<<=1;if(x+=1<<m,e===Cl&&x>L0||e===R0&&x>T0)return 1;b=S&A,i[b]=f<<24|m<<16|v-o|0}}return S!==0&&(i[v+S]=l-g<<24|64<<16|0),a.bits=f,0},Gi=ty,ry=0,Eu=1,Lu=2,{Z_FINISH:C0,Z_BLOCK:ny,Z_TREES:Ds,Z_OK:Rr,Z_STREAM_END:iy,Z_NEED_DICT:oy,Z_STREAM_ERROR:je,Z_DATA_ERROR:Tu,Z_MEM_ERROR:Iu,Z_BUF_ERROR:sy,Z_DEFLATED:z0}=Cr,Xs=16180,k0=16181,F0=16182,P0=16183,D0=16184,O0=16185,B0=16186,N0=16187,U0=16188,H0=16189,Vs=16190,Tt=16191,zl=16192,V0=16193,kl=16194,G0=16195,W0=16196,X0=16197,K0=16198,Os=16199,Bs=16200,$0=16201,Z0=16202,Y0=16203,q0=16204,j0=16205,Fl=16206,Q0=16207,J0=16208,ne=16209,Ru=16210,Cu=16211,ay=852,ly=592,cy=15,dy=cy,eu=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function uy(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var zr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<Xs||t.mode>Cu?1:0},zu=e=>{if(zr(e))return je;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Xs,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(ay),t.distcode=t.distdyn=new Int32Array(ly),t.sane=1,t.back=-1,Rr},ku=e=>{if(zr(e))return je;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,zu(e)},Fu=(e,t)=>{let r;if(zr(e))return je;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?je:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ku(e))},Pu=(e,t)=>{if(!e)return je;let r=new uy;e.state=r,r.strm=e,r.window=null,r.mode=Xs;let n=Fu(e,t);return n!==Rr&&(e.state=null),n},fy=e=>Pu(e,dy),tu=!0,Pl,Dl,hy=e=>{if(tu){Pl=new Int32Array(512),Dl=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Gi(Eu,e.lens,0,288,Pl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Gi(Lu,e.lens,0,32,Dl,0,e.work,{bits:5}),tu=!1}e.lencode=Pl,e.lenbits=9,e.distcode=Dl,e.distbits=5},Du=(e,t,r,n)=>{let i,o=e.state;return o.window===null&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(t.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(t.subarray(r-n,r-n+i),o.wnext),n-=i,n?(o.window.set(t.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0},my=(e,t)=>{let r,n,i,o,s,a,d,l,c,h,u,f,m,g,p=0,x,S,_,y,b,A,v,E,L=new Uint8Array(4),w,T,z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(zr(e)||!e.output||!e.input&&e.avail_in!==0)return je;r=e.state,r.mode===Tt&&(r.mode=zl),s=e.next_out,i=e.output,d=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,l=r.hold,c=r.bits,h=a,u=d,E=Rr;e:for(;;)switch(r.mode){case Xs:if(r.wrap===0){r.mode=zl;break}for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.wrap&2&&l===35615){r.wbits===0&&(r.wbits=15),r.check=0,L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0),l=0,c=0,r.mode=k0;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=ne;break}if((l&15)!==z0){e.msg="unknown compression method",r.mode=ne;break}if(l>>>=4,c-=4,v=(l&15)+8,r.wbits===0&&(r.wbits=v),v>15||v>r.wbits){e.msg="invalid window size",r.mode=ne;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=l&512?H0:Tt,l=0,c=0;break;case k0:for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.flags=l,(r.flags&255)!==z0){e.msg="unknown compression method",r.mode=ne;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=ne;break}r.head&&(r.head.text=l>>8&1),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0)),l=0,c=0,r.mode=F0;case F0:for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.head&&(r.head.time=l),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,L[2]=l>>>16&255,L[3]=l>>>24&255,r.check=fe(r.check,L,4,0)),l=0,c=0,r.mode=P0;case P0:for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.head&&(r.head.xflags=l&255,r.head.os=l>>8),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0)),l=0,c=0,r.mode=D0;case D0:if(r.flags&1024){for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.length=l,r.head&&(r.head.extra_len=l),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=O0;case O0:if(r.flags&1024&&(f=r.length,f>a&&(f=a),f&&(r.head&&(v=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+f),v)),r.flags&512&&r.wrap&4&&(r.check=fe(r.check,n,f,o)),a-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=B0;case B0:if(r.flags&2048){if(a===0)break e;f=0;do v=n[o+f++],r.head&&v&&r.length<65536&&(r.head.name+=String.fromCharCode(v));while(v&&f<a);if(r.flags&512&&r.wrap&4&&(r.check=fe(r.check,n,f,o)),a-=f,o+=f,v)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=N0;case N0:if(r.flags&4096){if(a===0)break e;f=0;do v=n[o+f++],r.head&&v&&r.length<65536&&(r.head.comment+=String.fromCharCode(v));while(v&&f<a);if(r.flags&512&&r.wrap&4&&(r.check=fe(r.check,n,f,o)),a-=f,o+=f,v)break e}else r.head&&(r.head.comment=null);r.mode=U0;case U0:if(r.flags&512){for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.wrap&4&&l!==(r.check&65535)){e.msg="header crc mismatch",r.mode=ne;break}l=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Tt;break;case H0:for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}e.adler=r.check=eu(l),l=0,c=0,r.mode=Vs;case Vs:if(r.havedict===0)return e.next_out=s,e.avail_out=d,e.next_in=o,e.avail_in=a,r.hold=l,r.bits=c,oy;e.adler=r.check=1,r.mode=Tt;case Tt:if(t===ny||t===Ds)break e;case zl:if(r.last){l>>>=c&7,c-=c&7,r.mode=Fl;break}for(;c<3;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}switch(r.last=l&1,l>>>=1,c-=1,l&3){case 0:r.mode=V0;break;case 1:if(hy(r),r.mode=Os,t===Ds){l>>>=2,c-=2;break e}break;case 2:r.mode=W0;break;case 3:e.msg="invalid block type",r.mode=ne}l>>>=2,c-=2;break;case V0:for(l>>>=c&7,c-=c&7;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=ne;break}if(r.length=l&65535,l=0,c=0,r.mode=kl,t===Ds)break e;case kl:r.mode=G0;case G0:if(f=r.length,f){if(f>a&&(f=a),f>d&&(f=d),f===0)break e;i.set(n.subarray(o,o+f),s),a-=f,o+=f,d-=f,s+=f,r.length-=f;break}r.mode=Tt;break;case W0:for(;c<14;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.nlen=(l&31)+257,l>>>=5,c-=5,r.ndist=(l&31)+1,l>>>=5,c-=5,r.ncode=(l&15)+4,l>>>=4,c-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=ne;break}r.have=0,r.mode=X0;case X0:for(;r.have<r.ncode;){for(;c<3;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.lens[z[r.have++]]=l&7,l>>>=3,c-=3}for(;r.have<19;)r.lens[z[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,w={bits:r.lenbits},E=Gi(ry,r.lens,0,19,r.lencode,0,r.work,w),r.lenbits=w.bits,E){e.msg="invalid code lengths set",r.mode=ne;break}r.have=0,r.mode=K0;case K0:for(;r.have<r.nlen+r.ndist;){for(;p=r.lencode[l&(1<<r.lenbits)-1],x=p>>>24,S=p>>>16&255,_=p&65535,!(x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(_<16)l>>>=x,c-=x,r.lens[r.have++]=_;else{if(_===16){for(T=x+2;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(l>>>=x,c-=x,r.have===0){e.msg="invalid bit length repeat",r.mode=ne;break}v=r.lens[r.have-1],f=3+(l&3),l>>>=2,c-=2}else if(_===17){for(T=x+3;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=x,c-=x,v=0,f=3+(l&7),l>>>=3,c-=3}else{for(T=x+7;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=x,c-=x,v=0,f=11+(l&127),l>>>=7,c-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=ne;break}for(;f--;)r.lens[r.have++]=v}}if(r.mode===ne)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=ne;break}if(r.lenbits=9,w={bits:r.lenbits},E=Gi(Eu,r.lens,0,r.nlen,r.lencode,0,r.work,w),r.lenbits=w.bits,E){e.msg="invalid literal/lengths set",r.mode=ne;break}if(r.distbits=6,r.distcode=r.distdyn,w={bits:r.distbits},E=Gi(Lu,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,w),r.distbits=w.bits,E){e.msg="invalid distances set",r.mode=ne;break}if(r.mode=Os,t===Ds)break e;case Os:r.mode=Bs;case Bs:if(a>=6&&d>=258){e.next_out=s,e.avail_out=d,e.next_in=o,e.avail_in=a,r.hold=l,r.bits=c,qg(e,u),s=e.next_out,i=e.output,d=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,l=r.hold,c=r.bits,r.mode===Tt&&(r.back=-1);break}for(r.back=0;p=r.lencode[l&(1<<r.lenbits)-1],x=p>>>24,S=p>>>16&255,_=p&65535,!(x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(S&&(S&240)===0){for(y=x,b=S,A=_;p=r.lencode[A+((l&(1<<y+b)-1)>>y)],x=p>>>24,S=p>>>16&255,_=p&65535,!(y+x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=y,c-=y,r.back+=y}if(l>>>=x,c-=x,r.back+=x,r.length=_,S===0){r.mode=j0;break}if(S&32){r.back=-1,r.mode=Tt;break}if(S&64){e.msg="invalid literal/length code",r.mode=ne;break}r.extra=S&15,r.mode=$0;case $0:if(r.extra){for(T=r.extra;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Z0;case Z0:for(;p=r.distcode[l&(1<<r.distbits)-1],x=p>>>24,S=p>>>16&255,_=p&65535,!(x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if((S&240)===0){for(y=x,b=S,A=_;p=r.distcode[A+((l&(1<<y+b)-1)>>y)],x=p>>>24,S=p>>>16&255,_=p&65535,!(y+x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=y,c-=y,r.back+=y}if(l>>>=x,c-=x,r.back+=x,S&64){e.msg="invalid distance code",r.mode=ne;break}r.offset=_,r.extra=S&15,r.mode=Y0;case Y0:if(r.extra){for(T=r.extra;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=ne;break}r.mode=q0;case q0:if(d===0)break e;if(f=u-d,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=ne;break}f>r.wnext?(f-=r.wnext,m=r.wsize-f):m=r.wnext-f,f>r.length&&(f=r.length),g=r.window}else g=i,m=s-r.offset,f=r.length;f>d&&(f=d),d-=f,r.length-=f;do i[s++]=g[m++];while(--f);r.length===0&&(r.mode=Bs);break;case j0:if(d===0)break e;i[s++]=r.length,d--,r.mode=Bs;break;case Fl:if(r.wrap){for(;c<32;){if(a===0)break e;a--,l|=n[o++]<<c,c+=8}if(u-=d,e.total_out+=u,r.total+=u,r.wrap&4&&u&&(e.adler=r.check=r.flags?fe(r.check,i,u,s-u):Zi(r.check,i,u,s-u)),u=d,r.wrap&4&&(r.flags?l:eu(l))!==r.check){e.msg="incorrect data check",r.mode=ne;break}l=0,c=0}r.mode=Q0;case Q0:if(r.wrap&&r.flags){for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.wrap&4&&l!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=ne;break}l=0,c=0}r.mode=J0;case J0:E=iy;break e;case ne:E=Tu;break e;case Ru:return Iu;case Cu:default:return je}return e.next_out=s,e.avail_out=d,e.next_in=o,e.avail_in=a,r.hold=l,r.bits=c,(r.wsize||u!==e.avail_out&&r.mode<ne&&(r.mode<Fl||t!==C0))&&Du(e,e.output,e.next_out,u-e.avail_out),h-=e.avail_in,u-=e.avail_out,e.total_in+=h,e.total_out+=u,r.total+=u,r.wrap&4&&u&&(e.adler=r.check=r.flags?fe(r.check,i,u,e.next_out-u):Zi(r.check,i,u,e.next_out-u)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Tt?128:0)+(r.mode===Os||r.mode===kl?256:0),(h===0&&u===0||t===C0)&&E===Rr&&(E=sy),E},py=e=>{if(zr(e))return je;let t=e.state;return t.window&&(t.window=null),e.state=null,Rr},gy=(e,t)=>{if(zr(e))return je;let r=e.state;return(r.wrap&2)===0?je:(r.head=t,t.done=!1,Rr)},yy=(e,t)=>{let r=t.length,n,i,o;return zr(e)||(n=e.state,n.wrap!==0&&n.mode!==Vs)?je:n.mode===Vs&&(i=1,i=Zi(i,t,r,0),i!==n.check)?Tu:(o=Du(e,t,r,r),o?(n.mode=Ru,Iu):(n.havedict=1,Rr))},xy=ku,_y=Fu,by=zu,vy=fy,Sy=Pu,wy=my,Ay=py,My=gy,Ey=yy,Ly="pako inflate (from Nodeca project)",Rt={inflateReset:xy,inflateReset2:_y,inflateResetKeep:by,inflateInit:vy,inflateInit2:Sy,inflate:wy,inflateEnd:Ay,inflateGetHeader:My,inflateSetDictionary:Ey,inflateInfo:Ly};function Ty(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Iy=Ty,Ou=Object.prototype.toString,{Z_NO_FLUSH:Ry,Z_FINISH:Cy,Z_OK:ji,Z_STREAM_END:Ol,Z_NEED_DICT:Bl,Z_STREAM_ERROR:zy,Z_DATA_ERROR:ru,Z_MEM_ERROR:ky}=Cr;function to(e){this.options=Ws.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Au,this.strm.avail_out=0;let r=Rt.inflateInit2(this.strm,t.windowBits);if(r!==ji)throw new Error(Tr[r]);if(this.header=new Iy,Rt.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=qi.string2buf(t.dictionary):Ou.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Rt.inflateSetDictionary(this.strm,t.dictionary),r!==ji)))throw new Error(Tr[r])}to.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,o,s,a;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?Cy:Ry,Ou.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=Rt.inflate(r,s),o===Bl&&i&&(o=Rt.inflateSetDictionary(r,i),o===ji?o=Rt.inflate(r,s):o===ru&&(o=Bl));r.avail_in>0&&o===Ol&&r.state.wrap>0&&e[r.next_in]!==0;)Rt.inflateReset(r),o=Rt.inflate(r,s);switch(o){case zy:case ru:case Bl:case ky:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===Ol))if(this.options.to==="string"){let d=qi.utf8border(r.output,r.next_out),l=r.next_out-d,c=qi.buf2string(r.output,d);r.next_out=l,r.avail_out=n-l,l&&r.output.set(r.output.subarray(d,d+l),0),this.onData(c)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(o===ji&&a===0)){if(o===Ol)return o=Rt.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};to.prototype.onData=function(e){this.chunks.push(e)};to.prototype.onEnd=function(e){e===ji&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ws.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function ec(e,t){let r=new to(t);if(r.push(e),r.err)throw r.msg||Tr[r.err];return r.result}function Fy(e,t){return t=t||{},t.raw=!0,ec(e,t)}var Py=to,Dy=ec,Oy=Fy,By=ec,Ny=Cr,Uy={Inflate:Py,inflate:Dy,inflateRaw:Oy,ungzip:By,constants:Ny},{Deflate:Hy,deflate:Vy,deflateRaw:Gy,gzip:Wy}=Zg,{Inflate:Xy,inflate:Ky,inflateRaw:$y,ungzip:Zy}=Uy,Yy=Hy,qy=Vy,jy=Gy,Qy=Wy,Jy=Xy,ex=Ky,tx=$y,rx=Zy,nx=Cr,tc={Deflate:Yy,deflate:qy,deflateRaw:jy,gzip:Qy,Inflate:Jy,inflate:ex,inflateRaw:tx,ungzip:rx,constants:nx};var Ks=2023,Zs=1,Ys=2,qs=4,js=8,Qs=16,Js=32,rc=64,ix=128,ox=256,ea=512,ta=1024,ra=2048,ro=4096,nc=8192,no=16384,sx=32768,io=65536,na=1<<17,oo=1<<18,so=1<<19,ia=1<<20,oa=1<<21,sa=1<<22,ax=1<<23,aa=1<<24,ao=1<<25,la=1<<26,ca=1<<27,ic=1<<28,oc=1<<29,sc=1<<30,lx=-2147483648,ac=1,lc=2,cc=4;var cx=1,dx=2,ux=128,kr=()=>({number:0,modelindex:0,modelindex2:0,modelindex3:0,modelindex4:0,frame:0,skinnum:0,effects:0,renderfx:0,origin:{x:0,y:0,z:0},old_origin:{x:0,y:0,z:0},angles:{x:0,y:0,z:0},sound:0,event:0,solid:0,bits:0,bitsHigh:0,alpha:0,scale:0,instanceBits:0,loopVolume:0,loopAttenuation:0,owner:0,oldFrame:0}),$s=()=>({pm_type:0,origin:{x:0,y:0,z:0},velocity:{x:0,y:0,z:0},pm_time:0,pm_flags:0,gravity:0,delta_angles:{x:0,y:0,z:0},viewoffset:{x:0,y:0,z:0},viewangles:{x:0,y:0,z:0},kick_angles:{x:0,y:0,z:0},gun_index:0,gun_frame:0,gun_offset:{x:0,y:0,z:0},gun_angles:{x:0,y:0,z:0},blend:[0,0,0,0],fov:0,rdflags:0,stats:new Array(32).fill(0),gunskin:0,gunrate:0,damage_blend:[0,0,0,0],team_id:0}),Fr=class e{constructor(t,r){this.protocolVersion=0;this.isDemo=cx;this.stream=t,this.handler=r}setProtocolVersion(t){this.protocolVersion=t}getProtocolVersion(){return this.protocolVersion}translateCommand(t){if(this.protocolVersion===0){if(t===7)return P.serverdata;if(t===12)return P.serverdata}return this.protocolVersion===Ks?t:this.protocolVersion===34||this.protocolVersion===25?t<=P.frame?t:P.bad:(this.protocolVersion===0,t)}parseMessage(){for(;this.stream.hasMore();){let t=this.stream.readByte();if(t===-1)break;let r=t;t=this.translateCommand(t);try{switch(t){case P.bad:return;case P.nop:break;case P.disconnect:this.handler&&this.handler.onDisconnect&&this.handler.onDisconnect();break;case P.reconnect:this.handler&&this.handler.onReconnect&&this.handler.onReconnect();break;case P.print:this.parsePrint();break;case P.serverdata:this.parseServerData();break;case P.configstring:this.parseConfigString();break;case P.spawnbaseline:this.parseSpawnBaseline();break;case P.centerprint:this.parseCenterPrint();break;case P.download:this.parseDownload();break;case P.frame:this.parseFrame();break;case P.packetentities:this.parsePacketEntities(!1);break;case P.deltapacketentities:this.parsePacketEntities(!0);break;case P.playerinfo:this.parsePlayerState();break;case P.stufftext:this.parseStuffText();break;case P.layout:this.parseLayout();break;case P.inventory:this.parseInventory();break;case P.sound:this.parseSound();break;case P.muzzleflash:this.parseMuzzleFlash();break;case P.muzzleflash2:this.parseMuzzleFlash2();break;case P.temp_entity:this.parseTempEntity();break;case P.splitclient:this.parseSplitClient();break;case P.configblast:this.parseConfigBlast();break;case P.spawnbaselineblast:this.parseSpawnBaselineBlast();break;case P.level_restart:this.handler&&this.handler.onLevelRestart&&this.handler.onLevelRestart();break;case P.damage:this.parseDamage();break;case P.locprint:this.parseLocPrint();break;case P.fog:this.parseFog();break;case P.waitingforplayers:this.parseWaitingForPlayers();break;case P.bot_chat:this.parseBotChat();break;case P.poi:this.parsePoi();break;case P.help_path:this.parseHelpPath();break;case P.muzzleflash3:this.parseMuzzleFlash3();break;case P.achievement:this.parseAchievement();break;default:console.warn(`Unknown server command: ${r} (translated: ${t}) at offset ${this.stream.getPosition()-1}`);return}}catch(n){console.warn(`Error parsing command ${t}: ${n.message}`);return}}}parsePrint(){let t=this.stream.readByte(),r=this.stream.readString();this.handler&&this.handler.onPrint(t,r)}parseStuffText(){let t=this.stream.readString();this.handler&&this.handler.onStuffText(t)}parseLayout(){let t=this.stream.readString();this.handler&&this.handler.onLayout(t)}parseCenterPrint(){let t=this.stream.readString();this.handler&&this.handler.onCenterPrint(t)}parseServerData(){if(this.protocolVersion=this.stream.readLong(),this.protocolVersion===Ks){let t=this.stream.readLong(),r=this.stream.readByte();this.isDemo=r;let n=this.stream.readByte(),i=this.stream.readString(),o=this.stream.readShort();if(o===-2){let a=this.stream.readShort();for(let d=0;d<a;d++)this.stream.readShort();o=0}else o===-1&&(o=-1);let s=this.stream.readString();this.handler?this.handler.onServerData(this.protocolVersion,t,0,i,o,s,n,r):console.log(`Server Data (Rerelease): Protocol ${this.protocolVersion}, Level ${s}, Tick ${n}`)}else{let t=this.stream.readLong();this.isDemo=this.stream.readByte();let r=0,n=this.stream.readString(),i=this.stream.readShort(),o=this.stream.readString();this.handler?this.handler.onServerData(this.protocolVersion,t,r,n,i,o):console.log(`Server Data: Protocol ${this.protocolVersion}, Level ${o}, GameDir ${n}`)}}parseConfigString(){let t=this.stream.readShort(),r=this.stream.readString();this.handler&&this.handler.onConfigString(t,r)}parseSplitClient(){let t=this.stream.readByte();this.handler&&this.handler.onSplitClient&&this.handler.onSplitClient(t)}parseConfigBlast(){let t=this.stream.readShort(),r=this.stream.readShort(),n=this.stream.readData(t);try{let i=tc.inflate(n);i.byteLength!==r&&console.warn(`svc_configblast: Decompressed size mismatch. Expected ${r}, got ${i.byteLength}`);let o=new kn(i.buffer);for(;o.hasMore();){let s=o.readUShort(),a=o.readString();this.handler&&this.handler.onConfigString(s,a)}}catch(i){console.error("svc_configblast: Failed to decompress data",i)}}parseSpawnBaselineBlast(){let t=this.stream.readShort(),r=this.stream.readShort(),n=this.stream.readData(t);try{let i=tc.inflate(n);i.byteLength!==r&&console.warn(`svc_spawnbaselineblast: Decompressed size mismatch. Expected ${r}, got ${i.byteLength}`);let o=new kn(i.buffer),s=new e(o,this.handler);for(;o.hasMore();)s.parseSpawnBaseline()}catch(i){console.error("svc_spawnbaselineblast: Failed to decompress data",i)}}parseLocPrint(){let t=this.stream.readByte(),r=this.stream.readString(),n=this.stream.readByte(),i=[];for(let o=0;o<n;o++)i.push(this.stream.readString());this.handler&&this.handler.onLocPrint&&this.handler.onLocPrint(t,r,i)}parseWaitingForPlayers(){let t=this.stream.readByte();this.handler&&this.handler.onWaitingForPlayers&&this.handler.onWaitingForPlayers(t)}parseBotChat(){let t=this.stream.readString(),r=this.stream.readShort(),n=this.stream.readString();this.handler&&this.handler.onBotChat&&this.handler.onBotChat(n)}parsePoi(){let t=this.stream.readUShort(),r=this.stream.readUShort(),n={x:0,y:0,z:0};this.stream.readPos(n);let i=this.stream.readUShort(),o=this.stream.readByte(),s=this.stream.readByte();this.handler&&this.handler.onPoi&&this.handler.onPoi(s,n)}parseHelpPath(){let t=this.stream.readByte(),r={x:0,y:0,z:0};this.stream.readPos(r);let n={x:0,y:0,z:0};this.stream.readDir(n),this.handler&&this.handler.onHelpPath&&this.handler.onHelpPath(r)}parseAchievement(){let t=this.stream.readString();this.handler&&this.handler.onAchievement&&this.handler.onAchievement(t)}parseDownload(){let t=this.stream.readShort(),r=this.stream.readByte(),n;t>0&&(n=this.stream.readData(t)),this.handler&&this.handler.onDownload(t,r,n)}parseInventory(){let r=new Array(256);for(let n=0;n<256;n++)r[n]=this.stream.readShort();this.handler&&this.handler.onInventory(r)}parseSound(){let t=this.stream.readByte(),r=this.stream.readByte(),n,i,o,s,a;if(t&1&&(n=this.stream.readByte()),t&2&&(i=this.stream.readByte()),t&16&&(o=this.stream.readByte()),t&8&&(s=this.stream.readShort()),t&4){let d={x:0,y:0,z:0};this.stream.readPos(d),a=d}this.handler&&this.handler.onSound(t,r,n,i,o,s,a)}parseMuzzleFlash(){let t=this.stream.readShort(),r=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash(t,r)}parseMuzzleFlash2(){let t=this.stream.readShort(),r=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash2(t,r)}parseMuzzleFlash3(){let t=this.stream.readShort(),r=this.stream.readShort();this.handler&&this.handler.onMuzzleFlash3&&this.handler.onMuzzleFlash3(t,r)}parseFog(){let t=this.stream.readByte();if(t&128){let n=this.stream.readByte();t|=n<<8}let r={};t&1&&(r.density=this.stream.readFloat(),r.skyfactor=this.stream.readByte()),t&2&&(r.red=this.stream.readByte()),t&4&&(r.green=this.stream.readByte()),t&8&&(r.blue=this.stream.readByte()),t&16&&(r.time=this.stream.readShort()),t&32&&(r.hf_falloff=this.stream.readFloat()),t&64&&(r.hf_density=this.stream.readFloat()),t&256&&(r.hf_start_r=this.stream.readByte()),t&512&&(r.hf_start_g=this.stream.readByte()),t&1024&&(r.hf_start_b=this.stream.readByte()),t&2048&&(r.hf_start_dist=this.stream.readLong()),t&4096&&(r.hf_end_r=this.stream.readByte()),t&8192&&(r.hf_end_g=this.stream.readByte()),t&16384&&(r.hf_end_b=this.stream.readByte()),t&32768&&(r.hf_end_dist=this.stream.readLong()),this.handler&&this.handler.onFog&&this.handler.onFog(r)}parseDamage(){let t=this.stream.readByte(),r=[];for(let n=0;n<t;n++){let i=this.stream.readByte(),o={x:0,y:0,z:0};this.stream.readDir(o);let s=i&31,a=(i&32)!==0,d=(i&64)!==0,l=(i&128)!==0;r.push({damage:s,health:a,armor:d,power:l,dir:o})}this.handler&&this.handler.onDamage&&this.handler.onDamage(r)}parseTempEntity(){let t=this.stream.readByte(),r={x:0,y:0,z:0},n={x:0,y:0,z:0},i={x:0,y:0,z:0},o,s,a,d,l;switch(t){case I.EXPLOSION1:case I.EXPLOSION2:case I.ROCKET_EXPLOSION:case I.GRENADE_EXPLOSION:case I.ROCKET_EXPLOSION_WATER:case I.GRENADE_EXPLOSION_WATER:case I.BFG_EXPLOSION:case I.BFG_BIGEXPLOSION:case I.BOSSTPORT:case I.PLASMA_EXPLOSION:case I.PLAIN_EXPLOSION:case I.CHAINFIST_SMOKE:case I.TRACKER_EXPLOSION:case I.TELEPORT_EFFECT:case I.DBALL_GOAL:case I.NUKEBLAST:case I.WIDOWSPLASH:case I.EXPLOSION1_BIG:case I.EXPLOSION1_NP:this.stream.readPos(r);break;case I.GUNSHOT:case I.BLOOD:case I.BLASTER:case I.SHOTGUN:case I.SPARKS:case I.BULLET_SPARKS:case I.SCREEN_SPARKS:case I.SHIELD_SPARKS:case I.BLASTER2:case I.FLECHETTE:case I.MOREBLOOD:case I.ELECTRIC_SPARKS:case I.HEATBEAM_SPARKS:case I.HEATBEAM_STEAM:this.stream.readPos(r),this.stream.readDir(i);break;case I.SPLASH:case I.LASER_SPARKS:case I.WELDING_SPARKS:case I.TUNNEL_SPARKS:o=this.stream.readByte(),this.stream.readPos(r),this.stream.readDir(i),s=this.stream.readByte();break;case I.BLUEHYPERBLASTER:this.protocolVersion>=32?(this.stream.readPos(r),this.stream.readPos(n)):(this.stream.readPos(r),this.stream.readDir(i));break;case I.GREENBLOOD:this.protocolVersion>=32?(this.stream.readPos(r),this.stream.readDir(i)):(this.stream.readPos(r),this.stream.readPos(n));break;case I.RAILTRAIL:case I.BUBBLETRAIL:case I.BFG_LASER:case I.DEBUGTRAIL:case I.BUBBLETRAIL2:this.stream.readPos(r),this.stream.readPos(n);break;case I.PARASITE_ATTACK:case I.MEDIC_CABLE_ATTACK:this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n);break;case I.GRAPPLE_CABLE:a=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n),this.stream.readPos(i);break;case I.LIGHTNING:d=this.stream.readShort(),l=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n);break;case I.FLASHLIGHT:this.stream.readPos(r),a=this.stream.readShort();break;case I.FORCEWALL:this.stream.readPos(r),this.stream.readPos(n),s=this.stream.readByte();break;case I.STEAM:let c=this.stream.readShort();o=this.stream.readByte(),this.stream.readPos(r),this.stream.readDir(i),s=this.stream.readByte(),this.stream.readShort(),c!==-1&&this.stream.readLong();break;case I.WIDOWBEAMOUT:this.stream.readShort();case I.HEATBEAM:case I.MONSTER_HEATBEAM:a=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n),this.stream.readPos(i);break;default:break}this.handler&&this.handler.onTempEntity(t,r,n,i,o,s,a,d,l)}parseSpawnBaseline(){let t=this.parseEntityBits(),r=kr();this.parseDelta(kr(),r,t.number,t.bits,t.bitsHigh),this.handler&&this.handler.onSpawnBaseline(r)}parseFrame(){let t=this.stream.readLong(),r=this.stream.readLong(),n=this.stream.readByte(),i=this.stream.readByte(),o=this.stream.readData(i),s=this.stream.readByte();if(s=this.translateCommand(s),s!==P.playerinfo)throw new Error(`Expected svc_playerinfo after svc_frame, got ${s} (translated)`);let a=this.parsePlayerState();if(this.isDemo===ux){let d=this.stream.readByte();for(let l=0;l<d;l++)this.stream.readByte()}this.isDemo===dx&&this.stream.readLong(),this.handler&&this.handler.onFrame({serverFrame:t,deltaFrame:r,surpressCount:n,areaBytes:i,areaBits:o,playerState:a,packetEntities:{delta:!1,entities:[]}})}parsePlayerState(){let t=$s(),r=this.stream.readShort();r&1&&(t.pm_type=this.stream.readByte()),r&2&&(t.origin.x=this.stream.readShort()*.125,t.origin.y=this.stream.readShort()*.125,t.origin.z=this.stream.readShort()*.125),r&4&&(t.velocity.x=this.stream.readShort()*.125,t.velocity.y=this.stream.readShort()*.125,t.velocity.z=this.stream.readShort()*.125),r&8&&(t.pm_time=this.stream.readByte()),r&16&&(t.pm_flags=this.stream.readByte()),r&32&&(t.gravity=this.stream.readShort()),r&64&&(t.delta_angles.x=this.stream.readShort()*(180/32768),t.delta_angles.y=this.stream.readShort()*(180/32768),t.delta_angles.z=this.stream.readShort()*(180/32768)),r&128&&(t.viewoffset.x=this.stream.readChar()*.25,t.viewoffset.y=this.stream.readChar()*.25,t.viewoffset.z=this.stream.readChar()*.25),r&256&&(t.viewangles.x=this.stream.readAngle16(),t.viewangles.y=this.stream.readAngle16(),t.viewangles.z=this.stream.readAngle16()),r&512&&(t.kick_angles.x=this.stream.readChar()*.25,t.kick_angles.y=this.stream.readChar()*.25,t.kick_angles.z=this.stream.readChar()*.25),r&4096&&(t.gun_index=this.stream.readByte()),r&8192&&(t.gun_frame=this.stream.readByte(),t.gun_offset.x=this.stream.readChar()*.25,t.gun_offset.y=this.stream.readChar()*.25,t.gun_offset.z=this.stream.readChar()*.25,t.gun_angles.x=this.stream.readChar()*.25,t.gun_angles.y=this.stream.readChar()*.25,t.gun_angles.z=this.stream.readChar()*.25),r&1024&&(t.blend[0]=this.stream.readByte(),t.blend[1]=this.stream.readByte(),t.blend[2]=this.stream.readByte(),t.blend[3]=this.stream.readByte()),r&2048&&(t.fov=this.stream.readByte()),r&16384&&(t.rdflags=this.stream.readByte());let n=this.stream.readLong();for(let i=0;i<32;i++)n&1<<i&&(t.stats[i]=this.stream.readShort());return t}parsePacketEntities(t){let r=this.collectPacketEntities();this.handler&&this.handler.onFrame({serverFrame:0,deltaFrame:0,surpressCount:0,areaBytes:0,areaBits:new Uint8Array,playerState:$s(),packetEntities:{delta:t,entities:r}})}collectPacketEntities(){let t=[];for(;;){let r=this.parseEntityBits();if(r.number===0)break;let n=kr();this.parseDelta(kr(),n,r.number,r.bits,r.bitsHigh),t.push(n)}return t}parseEntityBits(){let t=this.stream.readByte();t&ix&&(t|=this.stream.readByte()<<8),t&sx&&(t|=this.stream.readByte()<<16),t&ax&&(t|=this.stream.readByte()<<24);let r=0;t&lx&&(r=this.stream.readByte());let n;return t&ox?n=this.stream.readShort():n=this.stream.readByte(),{number:n,bits:t,bitsHigh:r}}parseDelta(t,r,n,i,o=0){r.number=t.number,r.modelindex=t.modelindex,r.modelindex2=t.modelindex2,r.modelindex3=t.modelindex3,r.modelindex4=t.modelindex4,r.frame=t.frame,r.skinnum=t.skinnum,r.effects=t.effects,r.renderfx=t.renderfx,r.origin.x=t.origin.x,r.origin.y=t.origin.y,r.origin.z=t.origin.z,r.old_origin.x=t.origin.x,r.old_origin.y=t.origin.y,r.old_origin.z=t.origin.z,r.angles.x=t.angles.x,r.angles.y=t.angles.y,r.angles.z=t.angles.z,r.sound=t.sound,r.event=t.event,r.solid=t.solid,r.alpha=t.alpha,r.scale=t.scale,r.instanceBits=t.instanceBits,r.loopVolume=t.loopVolume,r.loopAttenuation=t.loopAttenuation,r.owner=t.owner,r.oldFrame=t.oldFrame,r.number=n,r.bits=i,r.bitsHigh=o,i&ra&&(r.modelindex=this.stream.readByte()),i&ia&&(r.modelindex2=this.stream.readByte()),i&oa&&(r.modelindex3=this.stream.readByte()),i&sa&&(r.modelindex4=this.stream.readByte()),i&Qs&&(r.frame=this.stream.readByte()),i&na&&(r.frame=this.stream.readShort()),i&io&&i&ao?r.skinnum=this.stream.readLong():i&io?r.skinnum=this.stream.readByte():i&ao&&(r.skinnum=this.stream.readShort()),i&no&&i&so?r.effects=this.stream.readLong():i&no?r.effects=this.stream.readByte():i&so&&(r.effects=this.stream.readShort()),i&ro&&i&oo?r.renderfx=this.stream.readLong():i&ro?r.renderfx=this.stream.readByte():i&oo&&(r.renderfx=this.stream.readShort()),i&Zs&&(r.origin.x=this.stream.readCoord()),i&Ys&&(r.origin.y=this.stream.readCoord()),i&ea&&(r.origin.z=this.stream.readCoord()),i&ta&&(r.angles.x=this.stream.readAngle()),i&qs&&(r.angles.y=this.stream.readAngle()),i&js&&(r.angles.z=this.stream.readAngle()),i&aa&&this.stream.readPos(r.old_origin),i&la&&(r.sound=this.stream.readByte()),i&Js?r.event=this.stream.readByte():r.event=0,i&ca&&(r.solid=this.stream.readShort()),i&nc&&(r.alpha=this.stream.readByte()/255),i&ic&&(r.scale=this.stream.readFloat()),i&oc&&(r.instanceBits=this.stream.readLong()),i&sc&&(r.loopVolume=this.stream.readByte()/255),o&ac&&(r.loopAttenuation=this.stream.readByte()/255),o&lc&&(r.owner=this.stream.readShort()),o&cc&&(r.oldFrame=this.stream.readShort())}};var da=(i=>(i[i.Stopped=0]="Stopped",i[i.Playing=1]="Playing",i[i.Paused=2]="Paused",i[i.Finished=3]="Finished",i))(da||{}),lo=class{constructor(){this.reader=null;this.state=0;this.playbackSpeed=1;this.currentProtocolVersion=0;this.accumulatedTime=0;this.frameDuration=100}setHandler(t){this.handler=t}loadDemo(t){this.reader=new Ar(t),this.state=0,this.accumulatedTime=0,this.currentProtocolVersion=0}play(){this.reader&&(this.state=1)}pause(){this.state===1&&(this.state=2)}stop(){this.state=0,this.reader&&this.reader.reset(),this.accumulatedTime=0,this.currentProtocolVersion=0}setFrameDuration(t){this.frameDuration=t}update(t){if(!(this.state!==1||!this.reader))for(this.accumulatedTime+=t*1e3*this.playbackSpeed;this.accumulatedTime>=this.frameDuration;){if(!this.reader.hasMore()){this.state=3;return}let r=this.reader.readNextBlock();if(!r){this.state=3;return}let n=new Fr(r.data,this.handler);n.setProtocolVersion(this.currentProtocolVersion),n.parseMessage(),this.currentProtocolVersion=n.getProtocolVersion(),this.accumulatedTime-=this.frameDuration}}getState(){return this.state}};function fx(e){return{init(){e.trace({x:0,y:0,z:0},{x:0,y:0,z:0})},shutdown(){},createMainLoop(t,r){return new or(t,r)}}}return $u(hx);})();
480
+ }`,ks=class{constructor(t,r){this.vertexCapacity=0;this.indexCapacity=0;this.gl=t,this.system=r,this.program=Me.create(t,{vertex:wl,fragment:Al}),this.vertexBuffer=new Ee(t,t.DYNAMIC_DRAW),this.indexBuffer=new ye(t,t.DYNAMIC_DRAW),this.vertexArray=new ze(t),this.vertexArray.configureAttributes([{index:0,size:3,type:t.FLOAT,stride:36,offset:0},{index:1,size:2,type:t.FLOAT,stride:36,offset:12},{index:2,size:4,type:t.FLOAT,stride:36,offset:20}],this.vertexBuffer)}render(t){let r=this.system.buildMesh(t.viewRight,t.viewUp);if(r.indices.length===0)return;let n=r.vertices;r.vertices.byteLength>this.vertexCapacity?(this.vertexCapacity=r.vertices.byteLength,this.vertexBuffer.upload(n,this.gl.DYNAMIC_DRAW)):this.vertexBuffer.update(n);let i=r.indices;r.indices.byteLength>this.indexCapacity?(this.indexCapacity=r.indices.byteLength,this.indexBuffer.upload(i,this.gl.DYNAMIC_DRAW)):this.indexBuffer.update(i),this.gl.depthMask(!1),this.program.use();let o=this.program.getUniformLocation("u_viewProjection");this.gl.uniformMatrix4fv(o,!1,t.viewProjection),this.vertexArray.bind();for(let s of r.batches)s.blendMode==="additive"?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFuncSeparate(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,s.count,this.gl.UNSIGNED_SHORT,s.start*2);this.gl.depthMask(!0)}dispose(){this.program.dispose(),this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}};function h0(e){let{system:t,origin:r,normal:n={x:0,y:0,z:1}}=e;for(let i=0;i<12;i+=1){let o=200+t.random()*180,s=t.random()*.35;t.spawn({position:r,velocity:{x:n.x*o+(t.random()-.5)*80,y:n.y*o+(t.random()-.5)*80,z:Math.max(n.z*o,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+t.random()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let i=0;i<8;i+=1)t.spawn({position:r,velocity:{x:(t.random()-.5)*40,y:(t.random()-.5)*40,z:80+t.random()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function m0(e){let{system:t,origin:r}=e;for(let n=0;n<40;n+=1){let i=t.random()*Math.PI*2,o=Math.acos(2*t.random()-1),s=220+t.random()*260,a={x:Math.sin(o)*Math.cos(i),y:Math.sin(o)*Math.sin(i),z:Math.cos(o)};t.spawn({position:r,velocity:{x:a.x*s,y:a.y*s,z:a.z*s},color:[1,.6,.2,1],size:5,lifetime:.9,gravity:700,damping:1,bounce:.35,blendMode:"additive",fade:!0})}for(let n=0;n<16;n+=1)t.spawn({position:r,velocity:{x:(t.random()-.5)*30,y:(t.random()-.5)*30,z:120+t.random()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function p0(e){let{system:t,origin:r,direction:n={x:0,y:0,z:1}}=e;for(let i=0;i<24;i+=1){let o=120+t.random()*180;t.spawn({position:r,velocity:{x:n.x*o+(t.random()-.5)*70,y:n.y*o+(t.random()-.5)*70,z:n.z*o+t.random()*80},color:[.6,0,0,.95],size:3,lifetime:.8,gravity:900,damping:1,bounce:.2,blendMode:"alpha",fade:!0})}}function g0(e){let{system:t,origin:r}=e;for(let n=0;n<30;n+=1){let i=t.random()*Math.PI*2,o=8+t.random()*8;t.spawn({position:r,velocity:{x:Math.cos(i)*o,y:Math.sin(i)*o,z:100+t.random()*80},color:[.4,.6,1,.9],size:4,lifetime:.5,gravity:300,damping:2,blendMode:"additive",fade:!0})}}function y0(e){let{system:t,origin:r,direction:n={x:1,y:0,z:0}}=e;for(let i=0;i<10;i+=1){let o=350+t.random()*100;t.spawn({position:r,velocity:{x:n.x*o+(t.random()-.5)*30,y:n.y*o+(t.random()-.5)*30,z:n.z*o+(t.random()-.5)*30},color:[1,.8,.3,1],size:3,lifetime:.25,gravity:200,damping:1,blendMode:"additive",fade:!0})}}function x0(e){let{system:t,origin:r,direction:n={x:0,y:0,z:0}}=e;for(let i=0;i<6;i+=1)t.spawn({position:{x:r.x+n.x*i*2,y:r.y+n.y*i*2,z:r.z+n.z*i*2},velocity:{x:(t.random()-.5)*15,y:(t.random()-.5)*15,z:20+t.random()*15},color:[.6,.6,.6,.8],size:2.2,lifetime:.6,gravity:200,damping:1.5,blendMode:"alpha",fade:!0})}var Ar=class{constructor(t){this.buffer=t,this.view=new DataView(t),this.offset=0}hasMore(){return this.offset<this.buffer.byteLength}readNextBlock(){if(this.offset+4>this.buffer.byteLength)return null;let t=this.view.getInt32(this.offset,!0);if(this.offset+=4,t<0||t>2097152)return console.warn(`DemoReader: Invalid block length ${t} at offset ${this.offset-4}`),null;if(this.offset+t>this.buffer.byteLength)return console.warn(`DemoReader: Incomplete block. Expected ${t} bytes, but only ${this.buffer.byteLength-this.offset} remain.`),null;let r=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,{length:t,data:new kn(r)}}reset(){this.offset=0}getOffset(){return this.offset}};function Mn(e){let t=e.length;for(;--t>=0;)e[t]=0}var c1=0,nu=1,d1=2,u1=3,f1=258,Zl=29,Qi=256,Wi=Qi+1+Zl,Sn=30,Yl=19,iu=2*Wi+1,Mr=15,Ml=16,h1=7,ql=256,ou=16,su=17,au=18,Nl=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ns=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),m1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),lu=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p1=512,It=new Array((Wi+2)*2);Mn(It);var Hi=new Array(Sn*2);Mn(Hi);var Xi=new Array(p1);Mn(Xi);var Ki=new Array(f1-u1+1);Mn(Ki);var jl=new Array(Zl);Mn(jl);var Us=new Array(Sn);Mn(Us);function El(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var cu,du,uu;function Ll(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var fu=e=>e<256?Xi[e]:Xi[256+(e>>>7)],$i=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Re=(e,t,r)=>{e.bi_valid>Ml-r?(e.bi_buf|=t<<e.bi_valid&65535,$i(e,e.bi_buf),e.bi_buf=t>>Ml-e.bi_valid,e.bi_valid+=r-Ml):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},ft=(e,t,r)=>{Re(e,r[t*2],r[t*2+1])},hu=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},g1=e=>{e.bi_valid===16?($i(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},y1=(e,t)=>{let r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,d=t.stat_desc.max_length,l,c,h,u,f,m,g=0;for(u=0;u<=Mr;u++)e.bl_count[u]=0;for(r[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<iu;l++)c=e.heap[l],u=r[r[c*2+1]*2+1]+1,u>d&&(u=d,g++),r[c*2+1]=u,!(c>n)&&(e.bl_count[u]++,f=0,c>=a&&(f=s[c-a]),m=r[c*2],e.opt_len+=m*(u+f),o&&(e.static_len+=m*(i[c*2+1]+f)));if(g!==0){do{for(u=d-1;e.bl_count[u]===0;)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[d]--,g-=2}while(g>0);for(u=d;u!==0;u--)for(c=e.bl_count[u];c!==0;)h=e.heap[--l],!(h>n)&&(r[h*2+1]!==u&&(e.opt_len+=(u-r[h*2+1])*r[h*2],r[h*2+1]=u),c--)}},mu=(e,t,r)=>{let n=new Array(Mr+1),i=0,o,s;for(o=1;o<=Mr;o++)i=i+r[o-1]<<1,n[o]=i;for(s=0;s<=t;s++){let a=e[s*2+1];a!==0&&(e[s*2]=hu(n[a]++,a))}},x1=()=>{let e,t,r,n,i,o=new Array(Mr+1);for(r=0,n=0;n<Zl-1;n++)for(jl[n]=r,e=0;e<1<<Nl[n];e++)Ki[r++]=n;for(Ki[r-1]=n,i=0,n=0;n<16;n++)for(Us[n]=i,e=0;e<1<<Ns[n];e++)Xi[i++]=n;for(i>>=7;n<Sn;n++)for(Us[n]=i<<7,e=0;e<1<<Ns[n]-7;e++)Xi[256+i++]=n;for(t=0;t<=Mr;t++)o[t]=0;for(e=0;e<=143;)It[e*2+1]=8,e++,o[8]++;for(;e<=255;)It[e*2+1]=9,e++,o[9]++;for(;e<=279;)It[e*2+1]=7,e++,o[7]++;for(;e<=287;)It[e*2+1]=8,e++,o[8]++;for(mu(It,Wi+1,o),e=0;e<Sn;e++)Hi[e*2+1]=5,Hi[e*2]=hu(e,5);cu=new El(It,Nl,Qi+1,Wi,Mr),du=new El(Hi,Ns,0,Sn,Mr),uu=new El(new Array(0),m1,0,Yl,h1)},pu=e=>{let t;for(t=0;t<Wi;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Sn;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Yl;t++)e.bl_tree[t*2]=0;e.dyn_ltree[ql*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},gu=e=>{e.bi_valid>8?$i(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_0=(e,t,r,n)=>{let i=t*2,o=r*2;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]},Tl=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&_0(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!_0(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},b0=(e,t,r)=>{let n,i,o=0,s,a;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+o++]&255,n+=(e.pending_buf[e.sym_buf+o++]&255)<<8,i=e.pending_buf[e.sym_buf+o++],n===0?ft(e,i,t):(s=Ki[i],ft(e,s+Qi+1,t),a=Nl[s],a!==0&&(i-=jl[s],Re(e,i,a)),n--,s=fu(n),ft(e,s,r),a=Ns[s],a!==0&&(n-=Us[s],Re(e,n,a)));while(o<e.sym_next);ft(e,ql,t)},Ul=(e,t)=>{let r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems,s,a,d=-1,l;for(e.heap_len=0,e.heap_max=iu,s=0;s<o;s++)r[s*2]!==0?(e.heap[++e.heap_len]=d=s,e.depth[s]=0):r[s*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=d<2?++d:0,r[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=n[l*2+1]);for(t.max_code=d,s=e.heap_len>>1;s>=1;s--)Tl(e,r,s);l=o;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Tl(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,r[l*2]=r[s*2]+r[a*2],e.depth[l]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,r[s*2+1]=r[a*2+1]=l,e.heap[1]=l++,Tl(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],y1(e,t),mu(r,d,e.bl_count)},v0=(e,t,r)=>{let n,i=-1,o,s=t[1],a=0,d=7,l=4;for(s===0&&(d=138,l=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)o=s,s=t[(n+1)*2+1],!(++a<d&&o===s)&&(a<l?e.bl_tree[o*2]+=a:o!==0?(o!==i&&e.bl_tree[o*2]++,e.bl_tree[ou*2]++):a<=10?e.bl_tree[su*2]++:e.bl_tree[au*2]++,a=0,i=o,s===0?(d=138,l=3):o===s?(d=6,l=3):(d=7,l=4))},S0=(e,t,r)=>{let n,i=-1,o,s=t[1],a=0,d=7,l=4;for(s===0&&(d=138,l=3),n=0;n<=r;n++)if(o=s,s=t[(n+1)*2+1],!(++a<d&&o===s)){if(a<l)do ft(e,o,e.bl_tree);while(--a!==0);else o!==0?(o!==i&&(ft(e,o,e.bl_tree),a--),ft(e,ou,e.bl_tree),Re(e,a-3,2)):a<=10?(ft(e,su,e.bl_tree),Re(e,a-3,3)):(ft(e,au,e.bl_tree),Re(e,a-11,7));a=0,i=o,s===0?(d=138,l=3):o===s?(d=6,l=3):(d=7,l=4)}},_1=e=>{let t;for(v0(e,e.dyn_ltree,e.l_desc.max_code),v0(e,e.dyn_dtree,e.d_desc.max_code),Ul(e,e.bl_desc),t=Yl-1;t>=3&&e.bl_tree[lu[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},b1=(e,t,r,n)=>{let i;for(Re(e,t-257,5),Re(e,r-1,5),Re(e,n-4,4),i=0;i<n;i++)Re(e,e.bl_tree[lu[i]*2+1],3);S0(e,e.dyn_ltree,t-1),S0(e,e.dyn_dtree,r-1)},v1=e=>{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(r=32;r<Qi;r++)if(e.dyn_ltree[r*2]!==0)return 1;return 0},w0=!1,S1=e=>{w0||(x1(),w0=!0),e.l_desc=new Ll(e.dyn_ltree,cu),e.d_desc=new Ll(e.dyn_dtree,du),e.bl_desc=new Ll(e.bl_tree,uu),e.bi_buf=0,e.bi_valid=0,pu(e)},yu=(e,t,r,n)=>{Re(e,(c1<<1)+(n?1:0),3),gu(e),$i(e,r),$i(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},w1=e=>{Re(e,nu<<1,3),ft(e,ql,It),g1(e)},A1=(e,t,r,n)=>{let i,o,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=v1(e)),Ul(e,e.l_desc),Ul(e,e.d_desc),s=_1(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&t!==-1?yu(e,t,r,n):e.strategy===4||o===i?(Re(e,(nu<<1)+(n?1:0),3),b0(e,It,Hi)):(Re(e,(d1<<1)+(n?1:0),3),b1(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),b0(e,e.dyn_ltree,e.dyn_dtree)),pu(e),n&&gu(e)},M1=(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Ki[r]+Qi+1)*2]++,e.dyn_dtree[fu(t)*2]++),e.sym_next===e.sym_end),E1=S1,L1=yu,T1=A1,I1=M1,C1=w1,z1={_tr_init:E1,_tr_stored_block:L1,_tr_flush_block:T1,_tr_tally:I1,_tr_align:C1},R1=(e,t,r,n)=>{let i=e&65535|0,o=e>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+t[n++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0},Zi=R1,k1=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},F1=new Uint32Array(k1()),D1=(e,t,r,n)=>{let i=F1,o=n+r;e^=-1;for(let s=n;s<o;s++)e=e>>>8^i[(e^t[s])&255];return e^-1},fe=D1,Tr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},zr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:P1,_tr_stored_block:Hl,_tr_flush_block:O1,_tr_tally:tr,_tr_align:B1}=z1,{Z_NO_FLUSH:rr,Z_PARTIAL_FLUSH:N1,Z_FULL_FLUSH:U1,Z_FINISH:qe,Z_BLOCK:A0,Z_OK:he,Z_STREAM_END:M0,Z_STREAM_ERROR:ht,Z_DATA_ERROR:H1,Z_BUF_ERROR:Il,Z_DEFAULT_COMPRESSION:V1,Z_FILTERED:G1,Z_HUFFMAN_ONLY:Fs,Z_RLE:W1,Z_FIXED:X1,Z_DEFAULT_STRATEGY:K1,Z_UNKNOWN:$1,Z_DEFLATED:Gs}=zr,Z1=9,Y1=15,q1=8,j1=29,Q1=256,Vl=Q1+1+j1,J1=30,eg=19,tg=2*Vl+1,rg=15,V=3,er=258,mt=er+V+1,ng=32,wn=42,Ql=57,Gl=69,Wl=73,Xl=91,Kl=103,Er=113,Ni=666,Le=1,En=2,Ir=3,Ln=4,ig=3,Lr=(e,t)=>(e.msg=Tr[t],t),E0=e=>e*2-(e>4?9:0),Jt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},og=e=>{let t,r,n,i=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=i?r-i:0;while(--t);t=i,n=t;do r=e.prev[--n],e.prev[n]=r>=i?r-i:0;while(--t)},sg=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,nr=sg,Be=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},Ne=(e,t)=>{O1(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Be(e.strm)},X=(e,t)=>{e.pending_buf[e.pending++]=t},Bi=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},$l=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),e.state.wrap===1?e.adler=Zi(e.adler,t,i,r):e.state.wrap===2&&(e.adler=fe(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},xu=(e,t)=>{let r=e.max_chain_length,n=e.strstart,i,o,s=e.prev_length,a=e.nice_match,d=e.strstart>e.w_size-mt?e.strstart-(e.w_size-mt):0,l=e.window,c=e.w_mask,h=e.prev,u=e.strstart+er,f=l[n+s-1],m=l[n+s];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do if(i=t,!(l[i+s]!==m||l[i+s-1]!==f||l[i]!==l[n]||l[++i]!==l[n+1])){n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<u);if(o=er-(u-n),n=u-er,o>s){if(e.match_start=t,s=o,o>=a)break;f=l[n+s-1],m=l[n+s]}}while((t=h[t&c])>d&&--r!==0);return s<=e.lookahead?s:e.lookahead},An=e=>{let t=e.w_size,r,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-mt)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),og(e),n+=t),e.strm.avail_in===0)break;if(r=$l(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.lookahead+e.insert>=V)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=nr(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=nr(e,e.ins_h,e.window[i+V-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<V)););}while(e.lookahead<mt&&e.strm.avail_in!==0)},_u=(e,t)=>{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,i,o,s=0,a=e.strm.avail_in;do{if(n=65535,o=e.bi_valid+42>>3,e.strm.avail_out<o||(o=e.strm.avail_out-o,i=e.strstart-e.block_start,n>i+e.strm.avail_in&&(n=i+e.strm.avail_in),n>o&&(n=o),n<r&&(n===0&&t!==qe||t===rr||n!==i+e.strm.avail_in)))break;s=t===qe&&n===i+e.strm.avail_in?1:0,Hl(e,0,0,s),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Be(e.strm),i&&(i>n&&(i=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,n-=i),n&&($l(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(s===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?Ln:t!==rr&&t!==qe&&e.strm.avail_in===0&&e.strstart===e.block_start?En:(o=e.window_size-e.strstart,e.strm.avail_in>o&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,o+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),o>e.strm.avail_in&&(o=e.strm.avail_in),o&&($l(e.strm,e.window,e.strstart,o),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.high_water<e.strstart&&(e.high_water=e.strstart),o=e.bi_valid+42>>3,o=e.pending_buf_size-o>65535?65535:e.pending_buf_size-o,r=o>e.w_size?e.w_size:o,i=e.strstart-e.block_start,(i>=r||(i||t===qe)&&t!==rr&&e.strm.avail_in===0&&i<=o)&&(n=i>o?o:i,s=t===qe&&e.strm.avail_in===0&&n===i?1:0,Hl(e,e.block_start,n,s),e.block_start+=n,Be(e.strm)),s?Ir:Le)},Cl=(e,t)=>{let r,n;for(;;){if(e.lookahead<mt){if(An(e),e.lookahead<mt&&t===rr)return Le;if(e.lookahead===0)break}if(r=0,e.lookahead>=V&&(e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-mt&&(e.match_length=xu(e,r)),e.match_length>=V)if(n=tr(e,e.strstart-e.match_start,e.match_length-V),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=V){e.match_length--;do e.strstart++,e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=nr(e,e.ins_h,e.window[e.strstart+1]);else n=tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Ne(e,!1),e.strm.avail_out===0))return Le}return e.insert=e.strstart<V-1?e.strstart:V-1,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En},bn=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<mt){if(An(e),e.lookahead<mt&&t===rr)return Le;if(e.lookahead===0)break}if(r=0,e.lookahead>=V&&(e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=V-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-mt&&(e.match_length=xu(e,r),e.match_length<=5&&(e.strategy===G1||e.match_length===V&&e.strstart-e.match_start>4096)&&(e.match_length=V-1)),e.prev_length>=V&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-V,n=tr(e,e.strstart-1-e.prev_match,e.prev_length-V),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=nr(e,e.ins_h,e.window[e.strstart+V-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=V-1,e.strstart++,n&&(Ne(e,!1),e.strm.avail_out===0))return Le}else if(e.match_available){if(n=tr(e,0,e.window[e.strstart-1]),n&&Ne(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Le}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=tr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<V-1?e.strstart:V-1,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En},ag=(e,t)=>{let r,n,i,o,s=e.window;for(;;){if(e.lookahead<=er){if(An(e),e.lookahead<=er&&t===rr)return Le;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=V&&e.strstart>0&&(i=e.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=e.strstart+er;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<o);e.match_length=er-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=V?(r=tr(e,1,e.match_length-V),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ne(e,!1),e.strm.avail_out===0))return Le}return e.insert=0,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En},lg=(e,t)=>{let r;for(;;){if(e.lookahead===0&&(An(e),e.lookahead===0)){if(t===rr)return Le;break}if(e.match_length=0,r=tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ne(e,!1),e.strm.avail_out===0))return Le}return e.insert=0,t===qe?(Ne(e,!0),e.strm.avail_out===0?Ir:Ln):e.sym_next&&(Ne(e,!1),e.strm.avail_out===0)?Le:En};function ut(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var Ui=[new ut(0,0,0,0,_u),new ut(4,4,8,4,Cl),new ut(4,5,16,8,Cl),new ut(4,6,32,32,Cl),new ut(4,4,16,16,bn),new ut(8,16,32,32,bn),new ut(8,16,128,128,bn),new ut(8,32,128,256,bn),new ut(32,128,258,1024,bn),new ut(32,258,258,4096,bn)],cg=e=>{e.window_size=2*e.w_size,Jt(e.head),e.max_lazy_match=Ui[e.level].max_lazy,e.good_match=Ui[e.level].good_length,e.nice_match=Ui[e.level].nice_length,e.max_chain_length=Ui[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=V-1,e.match_available=0,e.ins_h=0};function dg(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Gs,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(tg*2),this.dyn_dtree=new Uint16Array((2*J1+1)*2),this.bl_tree=new Uint16Array((2*eg+1)*2),Jt(this.dyn_ltree),Jt(this.dyn_dtree),Jt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(rg+1),this.heap=new Uint16Array(2*Vl+1),Jt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Vl+1),Jt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ji=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==wn&&t.status!==Ql&&t.status!==Gl&&t.status!==Wl&&t.status!==Xl&&t.status!==Kl&&t.status!==Er&&t.status!==Ni?1:0},bu=e=>{if(Ji(e))return Lr(e,ht);e.total_in=e.total_out=0,e.data_type=$1;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Ql:t.wrap?wn:Er,e.adler=t.wrap===2?0:1,t.last_flush=-2,P1(t),he},vu=e=>{let t=bu(e);return t===he&&cg(e.state),t},ug=(e,t)=>Ji(e)||e.state.wrap!==2?ht:(e.state.gzhead=t,he),Su=(e,t,r,n,i,o)=>{if(!e)return ht;let s=1;if(t===V1&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>Z1||r!==Gs||n<8||n>15||t<0||t>9||o<0||o>X1||n===8&&s!==1)return Lr(e,ht);n===8&&(n=9);let a=new dg;return e.state=a,a.strm=e,a.status=wn,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+V-1)/V),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=t,a.strategy=o,a.method=r,vu(e)},fg=(e,t)=>Su(e,t,Gs,Y1,q1,K1),hg=(e,t)=>{if(Ji(e)||t>A0||t<0)return e?Lr(e,ht):ht;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===Ni&&t!==qe)return Lr(e,e.avail_out===0?Il:ht);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(Be(e),e.avail_out===0)return r.last_flush=-1,he}else if(e.avail_in===0&&E0(t)<=E0(n)&&t!==qe)return Lr(e,Il);if(r.status===Ni&&e.avail_in!==0)return Lr(e,Il);if(r.status===wn&&r.wrap===0&&(r.status=Er),r.status===wn){let i=Gs+(r.w_bits-8<<4)<<8,o=-1;if(r.strategy>=Fs||r.level<2?o=0:r.level<6?o=1:r.level===6?o=2:o=3,i|=o<<6,r.strstart!==0&&(i|=ng),i+=31-i%31,Bi(r,i),r.strstart!==0&&(Bi(r,e.adler>>>16),Bi(r,e.adler&65535)),e.adler=1,r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(r.status===Ql){if(e.adler=0,X(r,31),X(r,139),X(r,8),r.gzhead)X(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),X(r,r.gzhead.time&255),X(r,r.gzhead.time>>8&255),X(r,r.gzhead.time>>16&255),X(r,r.gzhead.time>>24&255),X(r,r.level===9?2:r.strategy>=Fs||r.level<2?4:0),X(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(X(r,r.gzhead.extra.length&255),X(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=fe(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Gl;else if(X(r,0),X(r,0),X(r,0),X(r,0),X(r,0),X(r,r.level===9?2:r.strategy>=Fs||r.level<2?4:0),X(r,ig),r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(r.status===Gl){if(r.gzhead.extra){let i=r.pending,o=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+o>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex+=a,Be(e),r.pending!==0)return r.last_flush=-1,he;i=0,o-=a}let s=new Uint8Array(r.gzhead.extra);r.pending_buf.set(s.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Wl}if(r.status===Wl){if(r.gzhead.name){let i=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),Be(e),r.pending!==0)return r.last_flush=-1,he;i=0}r.gzindex<r.gzhead.name.length?o=r.gzhead.name.charCodeAt(r.gzindex++)&255:o=0,X(r,o)}while(o!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Xl}if(r.status===Xl){if(r.gzhead.comment){let i=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i)),Be(e),r.pending!==0)return r.last_flush=-1,he;i=0}r.gzindex<r.gzhead.comment.length?o=r.gzhead.comment.charCodeAt(r.gzindex++)&255:o=0,X(r,o)}while(o!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=fe(e.adler,r.pending_buf,r.pending-i,i))}r.status=Kl}if(r.status===Kl){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Be(e),r.pending!==0))return r.last_flush=-1,he;X(r,e.adler&255),X(r,e.adler>>8&255),e.adler=0}if(r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(e.avail_in!==0||r.lookahead!==0||t!==rr&&r.status!==Ni){let i=r.level===0?_u(r,t):r.strategy===Fs?lg(r,t):r.strategy===W1?ag(r,t):Ui[r.level].func(r,t);if((i===Ir||i===Ln)&&(r.status=Ni),i===Le||i===Ir)return e.avail_out===0&&(r.last_flush=-1),he;if(i===En&&(t===N1?B1(r):t!==A0&&(Hl(r,0,0,!1),t===U1&&(Jt(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Be(e),e.avail_out===0))return r.last_flush=-1,he}return t!==qe?he:r.wrap<=0?M0:(r.wrap===2?(X(r,e.adler&255),X(r,e.adler>>8&255),X(r,e.adler>>16&255),X(r,e.adler>>24&255),X(r,e.total_in&255),X(r,e.total_in>>8&255),X(r,e.total_in>>16&255),X(r,e.total_in>>24&255)):(Bi(r,e.adler>>>16),Bi(r,e.adler&65535)),Be(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?he:M0)},mg=e=>{if(Ji(e))return ht;let t=e.state.status;return e.state=null,t===Er?Lr(e,H1):he},pg=(e,t)=>{let r=t.length;if(Ji(e))return ht;let n=e.state,i=n.wrap;if(i===2||i===1&&n.status!==wn||n.lookahead)return ht;if(i===1&&(e.adler=Zi(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){i===0&&(Jt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let d=new Uint8Array(n.w_size);d.set(t.subarray(r-n.w_size,r),0),t=d,r=n.w_size}let o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,An(n);n.lookahead>=V;){let d=n.strstart,l=n.lookahead-(V-1);do n.ins_h=nr(n,n.ins_h,n.window[d+V-1]),n.prev[d&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=d,d++;while(--l);n.strstart=d,n.lookahead=V-1,An(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=V-1,n.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,n.wrap=i,he},gg=fg,yg=Su,xg=vu,_g=bu,bg=ug,vg=hg,Sg=mg,wg=pg,Ag="pako deflate (from Nodeca project)",Vi={deflateInit:gg,deflateInit2:yg,deflateReset:xg,deflateResetKeep:_g,deflateSetHeader:bg,deflate:vg,deflateEnd:Sg,deflateSetDictionary:wg,deflateInfo:Ag},Mg=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Eg=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)Mg(r,n)&&(e[n]=r[n])}}return e},Lg=e=>{let t=0;for(let n=0,i=e.length;n<i;n++)t+=e[n].length;let r=new Uint8Array(t);for(let n=0,i=0,o=e.length;n<o;n++){let s=e[n];r.set(s,i),i+=s.length}return r},Ws={assign:Eg,flattenChunks:Lg},wu=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{wu=!1}var Yi=new Uint8Array(256);for(let e=0;e<256;e++)Yi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Yi[254]=Yi[254]=1;var Tg=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,i,o,s=e.length,a=0;for(i=0;i<s;i++)r=e.charCodeAt(i),(r&64512)===55296&&i+1<s&&(n=e.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(a),o=0,i=0;o<a;i++)r=e.charCodeAt(i),(r&64512)===55296&&i+1<s&&(n=e.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|r&63):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|r&63):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|r&63);return t},Ig=(e,t)=>{if(t<65534&&e.subarray&&wu)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r},Cg=(e,t)=>{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,i,o=new Array(r*2);for(i=0,n=0;n<r;){let s=e[n++];if(s<128){o[i++]=s;continue}let a=Yi[s];if(a>4){o[i++]=65533,n+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&n<r;)s=s<<6|e[n++]&63,a--;if(a>1){o[i++]=65533;continue}s<65536?o[i++]=s:(s-=65536,o[i++]=55296|s>>10&1023,o[i++]=56320|s&1023)}return Ig(o,i)},zg=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+Yi[e[r]]>t?r:t},qi={string2buf:Tg,buf2string:Cg,utf8border:zg};function Rg(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Au=Rg,Mu=Object.prototype.toString,{Z_NO_FLUSH:kg,Z_SYNC_FLUSH:Fg,Z_FULL_FLUSH:Dg,Z_FINISH:Pg,Z_OK:Hs,Z_STREAM_END:Og,Z_DEFAULT_COMPRESSION:Bg,Z_DEFAULT_STRATEGY:Ng,Z_DEFLATED:Ug}=zr;function eo(e){this.options=Ws.assign({level:Bg,method:Ug,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ng},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Au,this.strm.avail_out=0;let r=Vi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Hs)throw new Error(Tr[r]);if(t.header&&Vi.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=qi.string2buf(t.dictionary):Mu.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=Vi.deflateSetDictionary(this.strm,n),r!==Hs)throw new Error(Tr[r]);this._dict_set=!0}}eo.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i,o;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?Pg:kg,typeof e=="string"?r.input=qi.string2buf(e):Mu.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===Fg||o===Dg)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(i=Vi.deflate(r,o),i===Og)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Vi.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Hs;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};eo.prototype.onData=function(e){this.chunks.push(e)};eo.prototype.onEnd=function(e){e===Hs&&(this.result=Ws.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Jl(e,t){let r=new eo(t);if(r.push(e,!0),r.err)throw r.msg||Tr[r.err];return r.result}function Hg(e,t){return t=t||{},t.raw=!0,Jl(e,t)}function Vg(e,t){return t=t||{},t.gzip=!0,Jl(e,t)}var Gg=eo,Wg=Jl,Xg=Hg,Kg=Vg,$g=zr,Zg={Deflate:Gg,deflate:Wg,deflateRaw:Xg,gzip:Kg,constants:$g},Ds=16209,Yg=16191,qg=function(t,r){let n,i,o,s,a,d,l,c,h,u,f,m,g,p,x,S,_,y,b,A,v,E,L,w,T=t.state;n=t.next_in,L=t.input,i=n+(t.avail_in-5),o=t.next_out,w=t.output,s=o-(r-t.avail_out),a=o+(t.avail_out-257),d=T.dmax,l=T.wsize,c=T.whave,h=T.wnext,u=T.window,f=T.hold,m=T.bits,g=T.lencode,p=T.distcode,x=(1<<T.lenbits)-1,S=(1<<T.distbits)-1;e:do{m<15&&(f+=L[n++]<<m,m+=8,f+=L[n++]<<m,m+=8),_=g[f&x];t:for(;;){if(y=_>>>24,f>>>=y,m-=y,y=_>>>16&255,y===0)w[o++]=_&65535;else if(y&16){b=_&65535,y&=15,y&&(m<y&&(f+=L[n++]<<m,m+=8),b+=f&(1<<y)-1,f>>>=y,m-=y),m<15&&(f+=L[n++]<<m,m+=8,f+=L[n++]<<m,m+=8),_=p[f&S];r:for(;;){if(y=_>>>24,f>>>=y,m-=y,y=_>>>16&255,y&16){if(A=_&65535,y&=15,m<y&&(f+=L[n++]<<m,m+=8,m<y&&(f+=L[n++]<<m,m+=8)),A+=f&(1<<y)-1,A>d){t.msg="invalid distance too far back",T.mode=Ds;break e}if(f>>>=y,m-=y,y=o-s,A>y){if(y=A-y,y>c&&T.sane){t.msg="invalid distance too far back",T.mode=Ds;break e}if(v=0,E=u,h===0){if(v+=l-y,y<b){b-=y;do w[o++]=u[v++];while(--y);v=o-A,E=w}}else if(h<y){if(v+=l+h-y,y-=h,y<b){b-=y;do w[o++]=u[v++];while(--y);if(v=0,h<b){y=h,b-=y;do w[o++]=u[v++];while(--y);v=o-A,E=w}}}else if(v+=h-y,y<b){b-=y;do w[o++]=u[v++];while(--y);v=o-A,E=w}for(;b>2;)w[o++]=E[v++],w[o++]=E[v++],w[o++]=E[v++],b-=3;b&&(w[o++]=E[v++],b>1&&(w[o++]=E[v++]))}else{v=o-A;do w[o++]=w[v++],w[o++]=w[v++],w[o++]=w[v++],b-=3;while(b>2);b&&(w[o++]=w[v++],b>1&&(w[o++]=w[v++]))}}else if((y&64)===0){_=p[(_&65535)+(f&(1<<y)-1)];continue r}else{t.msg="invalid distance code",T.mode=Ds;break e}break}}else if((y&64)===0){_=g[(_&65535)+(f&(1<<y)-1)];continue t}else if(y&32){T.mode=Yg;break e}else{t.msg="invalid literal/length code",T.mode=Ds;break e}break}}while(n<i&&o<a);b=m>>3,n-=b,m-=b<<3,f&=(1<<m)-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?5+(i-n):5-(n-i),t.avail_out=o<a?257+(a-o):257-(o-a),T.hold=f,T.bits=m},vn=15,L0=852,T0=592,I0=0,zl=1,C0=2,jg=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Qg=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Jg=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ey=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),ty=(e,t,r,n,i,o,s,a)=>{let d=a.bits,l=0,c=0,h=0,u=0,f=0,m=0,g=0,p=0,x=0,S=0,_,y,b,A,v,E=null,L,w=new Uint16Array(vn+1),T=new Uint16Array(vn+1),R=null,U,z,$;for(l=0;l<=vn;l++)w[l]=0;for(c=0;c<n;c++)w[t[r+c]]++;for(f=d,u=vn;u>=1&&w[u]===0;u--);if(f>u&&(f=u),u===0)return i[o++]=1<<24|64<<16|0,i[o++]=1<<24|64<<16|0,a.bits=1,0;for(h=1;h<u&&w[h]===0;h++);for(f<h&&(f=h),p=1,l=1;l<=vn;l++)if(p<<=1,p-=w[l],p<0)return-1;if(p>0&&(e===I0||u!==1))return-1;for(T[1]=0,l=1;l<vn;l++)T[l+1]=T[l]+w[l];for(c=0;c<n;c++)t[r+c]!==0&&(s[T[t[r+c]]++]=c);if(e===I0?(E=R=s,L=20):e===zl?(E=jg,R=Qg,L=257):(E=Jg,R=ey,L=0),S=0,c=0,l=h,v=o,m=f,g=0,b=-1,x=1<<f,A=x-1,e===zl&&x>L0||e===C0&&x>T0)return 1;for(;;){U=l-g,s[c]+1<L?(z=0,$=s[c]):s[c]>=L?(z=R[s[c]-L],$=E[s[c]-L]):(z=96,$=0),_=1<<l-g,y=1<<m,h=y;do y-=_,i[v+(S>>g)+y]=U<<24|z<<16|$|0;while(y!==0);for(_=1<<l-1;S&_;)_>>=1;if(_!==0?(S&=_-1,S+=_):S=0,c++,--w[l]===0){if(l===u)break;l=t[r+s[c]]}if(l>f&&(S&A)!==b){for(g===0&&(g=f),v+=h,m=l-g,p=1<<m;m+g<u&&(p-=w[m+g],!(p<=0));)m++,p<<=1;if(x+=1<<m,e===zl&&x>L0||e===C0&&x>T0)return 1;b=S&A,i[b]=f<<24|m<<16|v-o|0}}return S!==0&&(i[v+S]=l-g<<24|64<<16|0),a.bits=f,0},Gi=ty,ry=0,Eu=1,Lu=2,{Z_FINISH:z0,Z_BLOCK:ny,Z_TREES:Ps,Z_OK:Cr,Z_STREAM_END:iy,Z_NEED_DICT:oy,Z_STREAM_ERROR:je,Z_DATA_ERROR:Tu,Z_MEM_ERROR:Iu,Z_BUF_ERROR:sy,Z_DEFLATED:R0}=zr,Xs=16180,k0=16181,F0=16182,D0=16183,P0=16184,O0=16185,B0=16186,N0=16187,U0=16188,H0=16189,Vs=16190,Tt=16191,Rl=16192,V0=16193,kl=16194,G0=16195,W0=16196,X0=16197,K0=16198,Os=16199,Bs=16200,$0=16201,Z0=16202,Y0=16203,q0=16204,j0=16205,Fl=16206,Q0=16207,J0=16208,ne=16209,Cu=16210,zu=16211,ay=852,ly=592,cy=15,dy=cy,eu=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function uy(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Rr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<Xs||t.mode>zu?1:0},Ru=e=>{if(Rr(e))return je;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Xs,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(ay),t.distcode=t.distdyn=new Int32Array(ly),t.sane=1,t.back=-1,Cr},ku=e=>{if(Rr(e))return je;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ru(e)},Fu=(e,t)=>{let r;if(Rr(e))return je;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?je:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ku(e))},Du=(e,t)=>{if(!e)return je;let r=new uy;e.state=r,r.strm=e,r.window=null,r.mode=Xs;let n=Fu(e,t);return n!==Cr&&(e.state=null),n},fy=e=>Du(e,dy),tu=!0,Dl,Pl,hy=e=>{if(tu){Dl=new Int32Array(512),Pl=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Gi(Eu,e.lens,0,288,Dl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Gi(Lu,e.lens,0,32,Pl,0,e.work,{bits:5}),tu=!1}e.lencode=Dl,e.lenbits=9,e.distcode=Pl,e.distbits=5},Pu=(e,t,r,n)=>{let i,o=e.state;return o.window===null&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(t.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(t.subarray(r-n,r-n+i),o.wnext),n-=i,n?(o.window.set(t.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0},my=(e,t)=>{let r,n,i,o,s,a,d,l,c,h,u,f,m,g,p=0,x,S,_,y,b,A,v,E,L=new Uint8Array(4),w,T,R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Rr(e)||!e.output||!e.input&&e.avail_in!==0)return je;r=e.state,r.mode===Tt&&(r.mode=Rl),s=e.next_out,i=e.output,d=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,l=r.hold,c=r.bits,h=a,u=d,E=Cr;e:for(;;)switch(r.mode){case Xs:if(r.wrap===0){r.mode=Rl;break}for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.wrap&2&&l===35615){r.wbits===0&&(r.wbits=15),r.check=0,L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0),l=0,c=0,r.mode=k0;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=ne;break}if((l&15)!==R0){e.msg="unknown compression method",r.mode=ne;break}if(l>>>=4,c-=4,v=(l&15)+8,r.wbits===0&&(r.wbits=v),v>15||v>r.wbits){e.msg="invalid window size",r.mode=ne;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=l&512?H0:Tt,l=0,c=0;break;case k0:for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.flags=l,(r.flags&255)!==R0){e.msg="unknown compression method",r.mode=ne;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=ne;break}r.head&&(r.head.text=l>>8&1),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0)),l=0,c=0,r.mode=F0;case F0:for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.head&&(r.head.time=l),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,L[2]=l>>>16&255,L[3]=l>>>24&255,r.check=fe(r.check,L,4,0)),l=0,c=0,r.mode=D0;case D0:for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.head&&(r.head.xflags=l&255,r.head.os=l>>8),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0)),l=0,c=0,r.mode=P0;case P0:if(r.flags&1024){for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.length=l,r.head&&(r.head.extra_len=l),r.flags&512&&r.wrap&4&&(L[0]=l&255,L[1]=l>>>8&255,r.check=fe(r.check,L,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=O0;case O0:if(r.flags&1024&&(f=r.length,f>a&&(f=a),f&&(r.head&&(v=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+f),v)),r.flags&512&&r.wrap&4&&(r.check=fe(r.check,n,f,o)),a-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=B0;case B0:if(r.flags&2048){if(a===0)break e;f=0;do v=n[o+f++],r.head&&v&&r.length<65536&&(r.head.name+=String.fromCharCode(v));while(v&&f<a);if(r.flags&512&&r.wrap&4&&(r.check=fe(r.check,n,f,o)),a-=f,o+=f,v)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=N0;case N0:if(r.flags&4096){if(a===0)break e;f=0;do v=n[o+f++],r.head&&v&&r.length<65536&&(r.head.comment+=String.fromCharCode(v));while(v&&f<a);if(r.flags&512&&r.wrap&4&&(r.check=fe(r.check,n,f,o)),a-=f,o+=f,v)break e}else r.head&&(r.head.comment=null);r.mode=U0;case U0:if(r.flags&512){for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.wrap&4&&l!==(r.check&65535)){e.msg="header crc mismatch",r.mode=ne;break}l=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Tt;break;case H0:for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}e.adler=r.check=eu(l),l=0,c=0,r.mode=Vs;case Vs:if(r.havedict===0)return e.next_out=s,e.avail_out=d,e.next_in=o,e.avail_in=a,r.hold=l,r.bits=c,oy;e.adler=r.check=1,r.mode=Tt;case Tt:if(t===ny||t===Ps)break e;case Rl:if(r.last){l>>>=c&7,c-=c&7,r.mode=Fl;break}for(;c<3;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}switch(r.last=l&1,l>>>=1,c-=1,l&3){case 0:r.mode=V0;break;case 1:if(hy(r),r.mode=Os,t===Ps){l>>>=2,c-=2;break e}break;case 2:r.mode=W0;break;case 3:e.msg="invalid block type",r.mode=ne}l>>>=2,c-=2;break;case V0:for(l>>>=c&7,c-=c&7;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=ne;break}if(r.length=l&65535,l=0,c=0,r.mode=kl,t===Ps)break e;case kl:r.mode=G0;case G0:if(f=r.length,f){if(f>a&&(f=a),f>d&&(f=d),f===0)break e;i.set(n.subarray(o,o+f),s),a-=f,o+=f,d-=f,s+=f,r.length-=f;break}r.mode=Tt;break;case W0:for(;c<14;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.nlen=(l&31)+257,l>>>=5,c-=5,r.ndist=(l&31)+1,l>>>=5,c-=5,r.ncode=(l&15)+4,l>>>=4,c-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=ne;break}r.have=0,r.mode=X0;case X0:for(;r.have<r.ncode;){for(;c<3;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.lens[R[r.have++]]=l&7,l>>>=3,c-=3}for(;r.have<19;)r.lens[R[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,w={bits:r.lenbits},E=Gi(ry,r.lens,0,19,r.lencode,0,r.work,w),r.lenbits=w.bits,E){e.msg="invalid code lengths set",r.mode=ne;break}r.have=0,r.mode=K0;case K0:for(;r.have<r.nlen+r.ndist;){for(;p=r.lencode[l&(1<<r.lenbits)-1],x=p>>>24,S=p>>>16&255,_=p&65535,!(x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(_<16)l>>>=x,c-=x,r.lens[r.have++]=_;else{if(_===16){for(T=x+2;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(l>>>=x,c-=x,r.have===0){e.msg="invalid bit length repeat",r.mode=ne;break}v=r.lens[r.have-1],f=3+(l&3),l>>>=2,c-=2}else if(_===17){for(T=x+3;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=x,c-=x,v=0,f=3+(l&7),l>>>=3,c-=3}else{for(T=x+7;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=x,c-=x,v=0,f=11+(l&127),l>>>=7,c-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=ne;break}for(;f--;)r.lens[r.have++]=v}}if(r.mode===ne)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=ne;break}if(r.lenbits=9,w={bits:r.lenbits},E=Gi(Eu,r.lens,0,r.nlen,r.lencode,0,r.work,w),r.lenbits=w.bits,E){e.msg="invalid literal/lengths set",r.mode=ne;break}if(r.distbits=6,r.distcode=r.distdyn,w={bits:r.distbits},E=Gi(Lu,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,w),r.distbits=w.bits,E){e.msg="invalid distances set",r.mode=ne;break}if(r.mode=Os,t===Ps)break e;case Os:r.mode=Bs;case Bs:if(a>=6&&d>=258){e.next_out=s,e.avail_out=d,e.next_in=o,e.avail_in=a,r.hold=l,r.bits=c,qg(e,u),s=e.next_out,i=e.output,d=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,l=r.hold,c=r.bits,r.mode===Tt&&(r.back=-1);break}for(r.back=0;p=r.lencode[l&(1<<r.lenbits)-1],x=p>>>24,S=p>>>16&255,_=p&65535,!(x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(S&&(S&240)===0){for(y=x,b=S,A=_;p=r.lencode[A+((l&(1<<y+b)-1)>>y)],x=p>>>24,S=p>>>16&255,_=p&65535,!(y+x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=y,c-=y,r.back+=y}if(l>>>=x,c-=x,r.back+=x,r.length=_,S===0){r.mode=j0;break}if(S&32){r.back=-1,r.mode=Tt;break}if(S&64){e.msg="invalid literal/length code",r.mode=ne;break}r.extra=S&15,r.mode=$0;case $0:if(r.extra){for(T=r.extra;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Z0;case Z0:for(;p=r.distcode[l&(1<<r.distbits)-1],x=p>>>24,S=p>>>16&255,_=p&65535,!(x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if((S&240)===0){for(y=x,b=S,A=_;p=r.distcode[A+((l&(1<<y+b)-1)>>y)],x=p>>>24,S=p>>>16&255,_=p&65535,!(y+x<=c);){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}l>>>=y,c-=y,r.back+=y}if(l>>>=x,c-=x,r.back+=x,S&64){e.msg="invalid distance code",r.mode=ne;break}r.offset=_,r.extra=S&15,r.mode=Y0;case Y0:if(r.extra){for(T=r.extra;c<T;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=ne;break}r.mode=q0;case q0:if(d===0)break e;if(f=u-d,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=ne;break}f>r.wnext?(f-=r.wnext,m=r.wsize-f):m=r.wnext-f,f>r.length&&(f=r.length),g=r.window}else g=i,m=s-r.offset,f=r.length;f>d&&(f=d),d-=f,r.length-=f;do i[s++]=g[m++];while(--f);r.length===0&&(r.mode=Bs);break;case j0:if(d===0)break e;i[s++]=r.length,d--,r.mode=Bs;break;case Fl:if(r.wrap){for(;c<32;){if(a===0)break e;a--,l|=n[o++]<<c,c+=8}if(u-=d,e.total_out+=u,r.total+=u,r.wrap&4&&u&&(e.adler=r.check=r.flags?fe(r.check,i,u,s-u):Zi(r.check,i,u,s-u)),u=d,r.wrap&4&&(r.flags?l:eu(l))!==r.check){e.msg="incorrect data check",r.mode=ne;break}l=0,c=0}r.mode=Q0;case Q0:if(r.wrap&&r.flags){for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.wrap&4&&l!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=ne;break}l=0,c=0}r.mode=J0;case J0:E=iy;break e;case ne:E=Tu;break e;case Cu:return Iu;case zu:default:return je}return e.next_out=s,e.avail_out=d,e.next_in=o,e.avail_in=a,r.hold=l,r.bits=c,(r.wsize||u!==e.avail_out&&r.mode<ne&&(r.mode<Fl||t!==z0))&&Pu(e,e.output,e.next_out,u-e.avail_out),h-=e.avail_in,u-=e.avail_out,e.total_in+=h,e.total_out+=u,r.total+=u,r.wrap&4&&u&&(e.adler=r.check=r.flags?fe(r.check,i,u,e.next_out-u):Zi(r.check,i,u,e.next_out-u)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Tt?128:0)+(r.mode===Os||r.mode===kl?256:0),(h===0&&u===0||t===z0)&&E===Cr&&(E=sy),E},py=e=>{if(Rr(e))return je;let t=e.state;return t.window&&(t.window=null),e.state=null,Cr},gy=(e,t)=>{if(Rr(e))return je;let r=e.state;return(r.wrap&2)===0?je:(r.head=t,t.done=!1,Cr)},yy=(e,t)=>{let r=t.length,n,i,o;return Rr(e)||(n=e.state,n.wrap!==0&&n.mode!==Vs)?je:n.mode===Vs&&(i=1,i=Zi(i,t,r,0),i!==n.check)?Tu:(o=Pu(e,t,r,r),o?(n.mode=Cu,Iu):(n.havedict=1,Cr))},xy=ku,_y=Fu,by=Ru,vy=fy,Sy=Du,wy=my,Ay=py,My=gy,Ey=yy,Ly="pako inflate (from Nodeca project)",Ct={inflateReset:xy,inflateReset2:_y,inflateResetKeep:by,inflateInit:vy,inflateInit2:Sy,inflate:wy,inflateEnd:Ay,inflateGetHeader:My,inflateSetDictionary:Ey,inflateInfo:Ly};function Ty(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Iy=Ty,Ou=Object.prototype.toString,{Z_NO_FLUSH:Cy,Z_FINISH:zy,Z_OK:ji,Z_STREAM_END:Ol,Z_NEED_DICT:Bl,Z_STREAM_ERROR:Ry,Z_DATA_ERROR:ru,Z_MEM_ERROR:ky}=zr;function to(e){this.options=Ws.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Au,this.strm.avail_out=0;let r=Ct.inflateInit2(this.strm,t.windowBits);if(r!==ji)throw new Error(Tr[r]);if(this.header=new Iy,Ct.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=qi.string2buf(t.dictionary):Ou.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Ct.inflateSetDictionary(this.strm,t.dictionary),r!==ji)))throw new Error(Tr[r])}to.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,o,s,a;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?zy:Cy,Ou.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=Ct.inflate(r,s),o===Bl&&i&&(o=Ct.inflateSetDictionary(r,i),o===ji?o=Ct.inflate(r,s):o===ru&&(o=Bl));r.avail_in>0&&o===Ol&&r.state.wrap>0&&e[r.next_in]!==0;)Ct.inflateReset(r),o=Ct.inflate(r,s);switch(o){case Ry:case ru:case Bl:case ky:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===Ol))if(this.options.to==="string"){let d=qi.utf8border(r.output,r.next_out),l=r.next_out-d,c=qi.buf2string(r.output,d);r.next_out=l,r.avail_out=n-l,l&&r.output.set(r.output.subarray(d,d+l),0),this.onData(c)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(o===ji&&a===0)){if(o===Ol)return o=Ct.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};to.prototype.onData=function(e){this.chunks.push(e)};to.prototype.onEnd=function(e){e===ji&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ws.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function ec(e,t){let r=new to(t);if(r.push(e),r.err)throw r.msg||Tr[r.err];return r.result}function Fy(e,t){return t=t||{},t.raw=!0,ec(e,t)}var Dy=to,Py=ec,Oy=Fy,By=ec,Ny=zr,Uy={Inflate:Dy,inflate:Py,inflateRaw:Oy,ungzip:By,constants:Ny},{Deflate:Hy,deflate:Vy,deflateRaw:Gy,gzip:Wy}=Zg,{Inflate:Xy,inflate:Ky,inflateRaw:$y,ungzip:Zy}=Uy,Yy=Hy,qy=Vy,jy=Gy,Qy=Wy,Jy=Xy,ex=Ky,tx=$y,rx=Zy,nx=zr,tc={Deflate:Yy,deflate:qy,deflateRaw:jy,gzip:Qy,Inflate:Jy,inflate:ex,inflateRaw:tx,ungzip:rx,constants:nx};var Ks=2023,Zs=1,Ys=2,qs=4,js=8,Qs=16,Js=32,rc=64,ix=128,ox=256,ea=512,ta=1024,ra=2048,ro=4096,nc=8192,no=16384,sx=32768,io=65536,na=1<<17,oo=1<<18,so=1<<19,ia=1<<20,oa=1<<21,sa=1<<22,ax=1<<23,aa=1<<24,ao=1<<25,la=1<<26,ca=1<<27,ic=1<<28,oc=1<<29,sc=1<<30,lx=-2147483648,ac=1,lc=2,cc=4;var cx=1,dx=2,ux=128,kr=()=>({number:0,modelindex:0,modelindex2:0,modelindex3:0,modelindex4:0,frame:0,skinnum:0,effects:0,renderfx:0,origin:{x:0,y:0,z:0},old_origin:{x:0,y:0,z:0},angles:{x:0,y:0,z:0},sound:0,event:0,solid:0,bits:0,bitsHigh:0,alpha:0,scale:0,instanceBits:0,loopVolume:0,loopAttenuation:0,owner:0,oldFrame:0}),$s=()=>({pm_type:0,origin:{x:0,y:0,z:0},velocity:{x:0,y:0,z:0},pm_time:0,pm_flags:0,gravity:0,delta_angles:{x:0,y:0,z:0},viewoffset:{x:0,y:0,z:0},viewangles:{x:0,y:0,z:0},kick_angles:{x:0,y:0,z:0},gun_index:0,gun_frame:0,gun_offset:{x:0,y:0,z:0},gun_angles:{x:0,y:0,z:0},blend:[0,0,0,0],fov:0,rdflags:0,stats:new Array(32).fill(0),gunskin:0,gunrate:0,damage_blend:[0,0,0,0],team_id:0}),Fr=class e{constructor(t,r){this.protocolVersion=0;this.isDemo=cx;this.stream=t,this.handler=r}setProtocolVersion(t){this.protocolVersion=t}getProtocolVersion(){return this.protocolVersion}translateCommand(t){if(this.protocolVersion===0){if(t===7)return D.serverdata;if(t===12)return D.serverdata}return this.protocolVersion===Ks?t:this.protocolVersion===34||this.protocolVersion===25?t<=D.frame?t:D.bad:(this.protocolVersion===0,t)}parseMessage(){for(;this.stream.hasMore();){let t=this.stream.readByte();if(t===-1)break;let r=t;t=this.translateCommand(t);try{switch(t){case D.bad:return;case D.nop:break;case D.disconnect:this.handler&&this.handler.onDisconnect&&this.handler.onDisconnect();break;case D.reconnect:this.handler&&this.handler.onReconnect&&this.handler.onReconnect();break;case D.print:this.parsePrint();break;case D.serverdata:this.parseServerData();break;case D.configstring:this.parseConfigString();break;case D.spawnbaseline:this.parseSpawnBaseline();break;case D.centerprint:this.parseCenterPrint();break;case D.download:this.parseDownload();break;case D.frame:this.parseFrame();break;case D.packetentities:this.parsePacketEntities(!1);break;case D.deltapacketentities:this.parsePacketEntities(!0);break;case D.playerinfo:this.parsePlayerState();break;case D.stufftext:this.parseStuffText();break;case D.layout:this.parseLayout();break;case D.inventory:this.parseInventory();break;case D.sound:this.parseSound();break;case D.muzzleflash:this.parseMuzzleFlash();break;case D.muzzleflash2:this.parseMuzzleFlash2();break;case D.temp_entity:this.parseTempEntity();break;case D.splitclient:this.parseSplitClient();break;case D.configblast:this.parseConfigBlast();break;case D.spawnbaselineblast:this.parseSpawnBaselineBlast();break;case D.level_restart:this.handler&&this.handler.onLevelRestart&&this.handler.onLevelRestart();break;case D.damage:this.parseDamage();break;case D.locprint:this.parseLocPrint();break;case D.fog:this.parseFog();break;case D.waitingforplayers:this.parseWaitingForPlayers();break;case D.bot_chat:this.parseBotChat();break;case D.poi:this.parsePoi();break;case D.help_path:this.parseHelpPath();break;case D.muzzleflash3:this.parseMuzzleFlash3();break;case D.achievement:this.parseAchievement();break;default:console.warn(`Unknown server command: ${r} (translated: ${t}) at offset ${this.stream.getPosition()-1}`);return}}catch(n){console.warn(`Error parsing command ${t}: ${n.message}`);return}}}parsePrint(){let t=this.stream.readByte(),r=this.stream.readString();this.handler&&this.handler.onPrint(t,r)}parseStuffText(){let t=this.stream.readString();this.handler&&this.handler.onStuffText(t)}parseLayout(){let t=this.stream.readString();this.handler&&this.handler.onLayout(t)}parseCenterPrint(){let t=this.stream.readString();this.handler&&this.handler.onCenterPrint(t)}parseServerData(){if(this.protocolVersion=this.stream.readLong(),this.protocolVersion===Ks){let t=this.stream.readLong(),r=this.stream.readByte();this.isDemo=r;let n=this.stream.readByte(),i=this.stream.readString(),o=this.stream.readShort();if(o===-2){let a=this.stream.readShort();for(let d=0;d<a;d++)this.stream.readShort();o=0}else o===-1&&(o=-1);let s=this.stream.readString();this.handler?this.handler.onServerData(this.protocolVersion,t,0,i,o,s,n,r):console.log(`Server Data (Rerelease): Protocol ${this.protocolVersion}, Level ${s}, Tick ${n}`)}else{let t=this.stream.readLong();this.isDemo=this.stream.readByte();let r=0,n=this.stream.readString(),i=this.stream.readShort(),o=this.stream.readString();this.handler?this.handler.onServerData(this.protocolVersion,t,r,n,i,o):console.log(`Server Data: Protocol ${this.protocolVersion}, Level ${o}, GameDir ${n}`)}}parseConfigString(){let t=this.stream.readShort(),r=this.stream.readString();this.handler&&this.handler.onConfigString(t,r)}parseSplitClient(){let t=this.stream.readByte();this.handler&&this.handler.onSplitClient&&this.handler.onSplitClient(t)}parseConfigBlast(){let t=this.stream.readShort(),r=this.stream.readShort(),n=this.stream.readData(t);try{let i=tc.inflate(n);i.byteLength!==r&&console.warn(`svc_configblast: Decompressed size mismatch. Expected ${r}, got ${i.byteLength}`);let o=new kn(i.buffer);for(;o.hasMore();){let s=o.readUShort(),a=o.readString();this.handler&&this.handler.onConfigString(s,a)}}catch(i){console.error("svc_configblast: Failed to decompress data",i)}}parseSpawnBaselineBlast(){let t=this.stream.readShort(),r=this.stream.readShort(),n=this.stream.readData(t);try{let i=tc.inflate(n);i.byteLength!==r&&console.warn(`svc_spawnbaselineblast: Decompressed size mismatch. Expected ${r}, got ${i.byteLength}`);let o=new kn(i.buffer),s=new e(o,this.handler);for(;o.hasMore();)s.parseSpawnBaseline()}catch(i){console.error("svc_spawnbaselineblast: Failed to decompress data",i)}}parseLocPrint(){let t=this.stream.readByte(),r=this.stream.readString(),n=this.stream.readByte(),i=[];for(let o=0;o<n;o++)i.push(this.stream.readString());this.handler&&this.handler.onLocPrint&&this.handler.onLocPrint(t,r,i)}parseWaitingForPlayers(){let t=this.stream.readByte();this.handler&&this.handler.onWaitingForPlayers&&this.handler.onWaitingForPlayers(t)}parseBotChat(){let t=this.stream.readString(),r=this.stream.readShort(),n=this.stream.readString();this.handler&&this.handler.onBotChat&&this.handler.onBotChat(n)}parsePoi(){let t=this.stream.readUShort(),r=this.stream.readUShort(),n={x:0,y:0,z:0};this.stream.readPos(n);let i=this.stream.readUShort(),o=this.stream.readByte(),s=this.stream.readByte();this.handler&&this.handler.onPoi&&this.handler.onPoi(s,n)}parseHelpPath(){let t=this.stream.readByte(),r={x:0,y:0,z:0};this.stream.readPos(r);let n={x:0,y:0,z:0};this.stream.readDir(n),this.handler&&this.handler.onHelpPath&&this.handler.onHelpPath(r)}parseAchievement(){let t=this.stream.readString();this.handler&&this.handler.onAchievement&&this.handler.onAchievement(t)}parseDownload(){let t=this.stream.readShort(),r=this.stream.readByte(),n;t>0&&(n=this.stream.readData(t)),this.handler&&this.handler.onDownload(t,r,n)}parseInventory(){let r=new Array(256);for(let n=0;n<256;n++)r[n]=this.stream.readShort();this.handler&&this.handler.onInventory(r)}parseSound(){let t=this.stream.readByte(),r=this.stream.readByte(),n,i,o,s,a;if(t&1&&(n=this.stream.readByte()),t&2&&(i=this.stream.readByte()),t&16&&(o=this.stream.readByte()),t&8&&(s=this.stream.readShort()),t&4){let d={x:0,y:0,z:0};this.stream.readPos(d),a=d}this.handler&&this.handler.onSound(t,r,n,i,o,s,a)}parseMuzzleFlash(){let t=this.stream.readShort(),r=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash(t,r)}parseMuzzleFlash2(){let t=this.stream.readShort(),r=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash2(t,r)}parseMuzzleFlash3(){let t=this.stream.readShort(),r=this.stream.readShort();this.handler&&this.handler.onMuzzleFlash3&&this.handler.onMuzzleFlash3(t,r)}parseFog(){let t=this.stream.readByte();if(t&128){let n=this.stream.readByte();t|=n<<8}let r={};t&1&&(r.density=this.stream.readFloat(),r.skyfactor=this.stream.readByte()),t&2&&(r.red=this.stream.readByte()),t&4&&(r.green=this.stream.readByte()),t&8&&(r.blue=this.stream.readByte()),t&16&&(r.time=this.stream.readShort()),t&32&&(r.hf_falloff=this.stream.readFloat()),t&64&&(r.hf_density=this.stream.readFloat()),t&256&&(r.hf_start_r=this.stream.readByte()),t&512&&(r.hf_start_g=this.stream.readByte()),t&1024&&(r.hf_start_b=this.stream.readByte()),t&2048&&(r.hf_start_dist=this.stream.readLong()),t&4096&&(r.hf_end_r=this.stream.readByte()),t&8192&&(r.hf_end_g=this.stream.readByte()),t&16384&&(r.hf_end_b=this.stream.readByte()),t&32768&&(r.hf_end_dist=this.stream.readLong()),this.handler&&this.handler.onFog&&this.handler.onFog(r)}parseDamage(){let t=this.stream.readByte(),r=[];for(let n=0;n<t;n++){let i=this.stream.readByte(),o={x:0,y:0,z:0};this.stream.readDir(o);let s=i&31,a=(i&32)!==0,d=(i&64)!==0,l=(i&128)!==0;r.push({damage:s,health:a,armor:d,power:l,dir:o})}this.handler&&this.handler.onDamage&&this.handler.onDamage(r)}parseTempEntity(){let t=this.stream.readByte(),r={x:0,y:0,z:0},n={x:0,y:0,z:0},i={x:0,y:0,z:0},o,s,a,d,l;switch(t){case I.EXPLOSION1:case I.EXPLOSION2:case I.ROCKET_EXPLOSION:case I.GRENADE_EXPLOSION:case I.ROCKET_EXPLOSION_WATER:case I.GRENADE_EXPLOSION_WATER:case I.BFG_EXPLOSION:case I.BFG_BIGEXPLOSION:case I.BOSSTPORT:case I.PLASMA_EXPLOSION:case I.PLAIN_EXPLOSION:case I.CHAINFIST_SMOKE:case I.TRACKER_EXPLOSION:case I.TELEPORT_EFFECT:case I.DBALL_GOAL:case I.NUKEBLAST:case I.WIDOWSPLASH:case I.EXPLOSION1_BIG:case I.EXPLOSION1_NP:this.stream.readPos(r);break;case I.GUNSHOT:case I.BLOOD:case I.BLASTER:case I.SHOTGUN:case I.SPARKS:case I.BULLET_SPARKS:case I.SCREEN_SPARKS:case I.SHIELD_SPARKS:case I.BLASTER2:case I.FLECHETTE:case I.MOREBLOOD:case I.ELECTRIC_SPARKS:case I.HEATBEAM_SPARKS:case I.HEATBEAM_STEAM:this.stream.readPos(r),this.stream.readDir(i);break;case I.SPLASH:case I.LASER_SPARKS:case I.WELDING_SPARKS:case I.TUNNEL_SPARKS:o=this.stream.readByte(),this.stream.readPos(r),this.stream.readDir(i),s=this.stream.readByte();break;case I.BLUEHYPERBLASTER:this.protocolVersion>=32?(this.stream.readPos(r),this.stream.readPos(n)):(this.stream.readPos(r),this.stream.readDir(i));break;case I.GREENBLOOD:this.protocolVersion>=32?(this.stream.readPos(r),this.stream.readDir(i)):(this.stream.readPos(r),this.stream.readPos(n));break;case I.RAILTRAIL:case I.BUBBLETRAIL:case I.BFG_LASER:case I.DEBUGTRAIL:case I.BUBBLETRAIL2:this.stream.readPos(r),this.stream.readPos(n);break;case I.PARASITE_ATTACK:case I.MEDIC_CABLE_ATTACK:this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n);break;case I.GRAPPLE_CABLE:a=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n),this.stream.readPos(i);break;case I.LIGHTNING:d=this.stream.readShort(),l=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n);break;case I.FLASHLIGHT:this.stream.readPos(r),a=this.stream.readShort();break;case I.FORCEWALL:this.stream.readPos(r),this.stream.readPos(n),s=this.stream.readByte();break;case I.STEAM:let c=this.stream.readShort();o=this.stream.readByte(),this.stream.readPos(r),this.stream.readDir(i),s=this.stream.readByte(),this.stream.readShort(),c!==-1&&this.stream.readLong();break;case I.WIDOWBEAMOUT:this.stream.readShort();case I.HEATBEAM:case I.MONSTER_HEATBEAM:a=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n),this.stream.readPos(i);break;default:break}this.handler&&this.handler.onTempEntity(t,r,n,i,o,s,a,d,l)}parseSpawnBaseline(){let t=this.parseEntityBits(),r=kr();this.parseDelta(kr(),r,t.number,t.bits,t.bitsHigh),this.handler&&this.handler.onSpawnBaseline(r)}parseFrame(){let t=this.stream.readLong(),r=this.stream.readLong(),n=this.stream.readByte(),i=this.stream.readByte(),o=this.stream.readData(i),s=this.stream.readByte();if(s=this.translateCommand(s),s!==D.playerinfo)throw new Error(`Expected svc_playerinfo after svc_frame, got ${s} (translated)`);let a=this.parsePlayerState();if(this.isDemo===ux){let d=this.stream.readByte();for(let l=0;l<d;l++)this.stream.readByte()}this.isDemo===dx&&this.stream.readLong(),this.handler&&this.handler.onFrame({serverFrame:t,deltaFrame:r,surpressCount:n,areaBytes:i,areaBits:o,playerState:a,packetEntities:{delta:!1,entities:[]}})}parsePlayerState(){let t=$s(),r=this.stream.readShort();r&1&&(t.pm_type=this.stream.readByte()),r&2&&(t.origin.x=this.stream.readShort()*.125,t.origin.y=this.stream.readShort()*.125,t.origin.z=this.stream.readShort()*.125),r&4&&(t.velocity.x=this.stream.readShort()*.125,t.velocity.y=this.stream.readShort()*.125,t.velocity.z=this.stream.readShort()*.125),r&8&&(t.pm_time=this.stream.readByte()),r&16&&(t.pm_flags=this.stream.readByte()),r&32&&(t.gravity=this.stream.readShort()),r&64&&(t.delta_angles.x=this.stream.readShort()*(180/32768),t.delta_angles.y=this.stream.readShort()*(180/32768),t.delta_angles.z=this.stream.readShort()*(180/32768)),r&128&&(t.viewoffset.x=this.stream.readChar()*.25,t.viewoffset.y=this.stream.readChar()*.25,t.viewoffset.z=this.stream.readChar()*.25),r&256&&(t.viewangles.x=this.stream.readAngle16(),t.viewangles.y=this.stream.readAngle16(),t.viewangles.z=this.stream.readAngle16()),r&512&&(t.kick_angles.x=this.stream.readChar()*.25,t.kick_angles.y=this.stream.readChar()*.25,t.kick_angles.z=this.stream.readChar()*.25),r&4096&&(t.gun_index=this.stream.readByte()),r&8192&&(t.gun_frame=this.stream.readByte(),t.gun_offset.x=this.stream.readChar()*.25,t.gun_offset.y=this.stream.readChar()*.25,t.gun_offset.z=this.stream.readChar()*.25,t.gun_angles.x=this.stream.readChar()*.25,t.gun_angles.y=this.stream.readChar()*.25,t.gun_angles.z=this.stream.readChar()*.25),r&1024&&(t.blend[0]=this.stream.readByte(),t.blend[1]=this.stream.readByte(),t.blend[2]=this.stream.readByte(),t.blend[3]=this.stream.readByte()),r&2048&&(t.fov=this.stream.readByte()),r&16384&&(t.rdflags=this.stream.readByte());let n=this.stream.readLong();for(let i=0;i<32;i++)n&1<<i&&(t.stats[i]=this.stream.readShort());return t}parsePacketEntities(t){let r=this.collectPacketEntities();this.handler&&this.handler.onFrame({serverFrame:0,deltaFrame:0,surpressCount:0,areaBytes:0,areaBits:new Uint8Array,playerState:$s(),packetEntities:{delta:t,entities:r}})}collectPacketEntities(){let t=[];for(;;){let r=this.parseEntityBits();if(r.number===0)break;let n=kr();this.parseDelta(kr(),n,r.number,r.bits,r.bitsHigh),t.push(n)}return t}parseEntityBits(){let t=this.stream.readByte();t&ix&&(t|=this.stream.readByte()<<8),t&sx&&(t|=this.stream.readByte()<<16),t&ax&&(t|=this.stream.readByte()<<24);let r=0;t&lx&&(r=this.stream.readByte());let n;return t&ox?n=this.stream.readShort():n=this.stream.readByte(),{number:n,bits:t,bitsHigh:r}}parseDelta(t,r,n,i,o=0){r.number=t.number,r.modelindex=t.modelindex,r.modelindex2=t.modelindex2,r.modelindex3=t.modelindex3,r.modelindex4=t.modelindex4,r.frame=t.frame,r.skinnum=t.skinnum,r.effects=t.effects,r.renderfx=t.renderfx,r.origin.x=t.origin.x,r.origin.y=t.origin.y,r.origin.z=t.origin.z,r.old_origin.x=t.origin.x,r.old_origin.y=t.origin.y,r.old_origin.z=t.origin.z,r.angles.x=t.angles.x,r.angles.y=t.angles.y,r.angles.z=t.angles.z,r.sound=t.sound,r.event=t.event,r.solid=t.solid,r.alpha=t.alpha,r.scale=t.scale,r.instanceBits=t.instanceBits,r.loopVolume=t.loopVolume,r.loopAttenuation=t.loopAttenuation,r.owner=t.owner,r.oldFrame=t.oldFrame,r.number=n,r.bits=i,r.bitsHigh=o,i&ra&&(r.modelindex=this.stream.readByte()),i&ia&&(r.modelindex2=this.stream.readByte()),i&oa&&(r.modelindex3=this.stream.readByte()),i&sa&&(r.modelindex4=this.stream.readByte()),i&Qs&&(r.frame=this.stream.readByte()),i&na&&(r.frame=this.stream.readShort()),i&io&&i&ao?r.skinnum=this.stream.readLong():i&io?r.skinnum=this.stream.readByte():i&ao&&(r.skinnum=this.stream.readShort()),i&no&&i&so?r.effects=this.stream.readLong():i&no?r.effects=this.stream.readByte():i&so&&(r.effects=this.stream.readShort()),i&ro&&i&oo?r.renderfx=this.stream.readLong():i&ro?r.renderfx=this.stream.readByte():i&oo&&(r.renderfx=this.stream.readShort()),i&Zs&&(r.origin.x=this.stream.readCoord()),i&Ys&&(r.origin.y=this.stream.readCoord()),i&ea&&(r.origin.z=this.stream.readCoord()),i&ta&&(r.angles.x=this.stream.readAngle()),i&qs&&(r.angles.y=this.stream.readAngle()),i&js&&(r.angles.z=this.stream.readAngle()),i&aa&&this.stream.readPos(r.old_origin),i&la&&(r.sound=this.stream.readByte()),i&Js?r.event=this.stream.readByte():r.event=0,i&ca&&(r.solid=this.stream.readShort()),i&nc&&(r.alpha=this.stream.readByte()/255),i&ic&&(r.scale=this.stream.readFloat()),i&oc&&(r.instanceBits=this.stream.readLong()),i&sc&&(r.loopVolume=this.stream.readByte()/255),o&ac&&(r.loopAttenuation=this.stream.readByte()/255),o&lc&&(r.owner=this.stream.readShort()),o&cc&&(r.oldFrame=this.stream.readShort())}};var da=(i=>(i[i.Stopped=0]="Stopped",i[i.Playing=1]="Playing",i[i.Paused=2]="Paused",i[i.Finished=3]="Finished",i))(da||{}),lo=class{constructor(){this.reader=null;this.state=0;this.playbackSpeed=1;this.currentProtocolVersion=0;this.accumulatedTime=0;this.frameDuration=100}setHandler(t){this.handler=t}loadDemo(t){this.reader=new Ar(t),this.state=0,this.accumulatedTime=0,this.currentProtocolVersion=0}play(){this.reader&&(this.state=1)}pause(){this.state===1&&(this.state=2)}stop(){this.state=0,this.reader&&this.reader.reset(),this.accumulatedTime=0,this.currentProtocolVersion=0}setFrameDuration(t){this.frameDuration=t}update(t){if(!(this.state!==1||!this.reader))for(this.accumulatedTime+=t*1e3*this.playbackSpeed;this.accumulatedTime>=this.frameDuration;){if(!this.reader.hasMore()){this.state=3;return}let r=this.reader.readNextBlock();if(!r){this.state=3;return}let n=new Fr(r.data,this.handler);n.setProtocolVersion(this.currentProtocolVersion),n.parseMessage(),this.currentProtocolVersion=n.getProtocolVersion(),this.accumulatedTime-=this.frameDuration}}getState(){return this.state}getCurrentTime(){return this.accumulatedTime}};function fx(e){return{init(){e.trace({x:0,y:0,z:0},{x:0,y:0,z:0})},shutdown(){},createMainLoop(t,r){return new or(t,r)}}}return $u(hx);})();
481
481
  /*! Bundled license information:
482
482
 
483
483
  pako/dist/pako.esm.mjs: