quake2ts 0.0.233 → 0.0.235
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.
- package/package.json +4 -2
- package/packages/client/dist/browser/index.global.js +49 -16
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +4469 -131
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +4469 -131
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +56 -20
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +4584 -237
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +4584 -237
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/demo/parser.d.ts +12 -3
- package/packages/engine/dist/types/demo/parser.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bsp/geometry.d.ts +1 -0
- package/packages/engine/dist/types/render/bsp/geometry.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bsp/renderer.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bsp/surface.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bspPipeline.d.ts +4 -2
- package/packages/engine/dist/types/render/bspPipeline.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/browser/index.global.js +1 -1
- package/packages/shared/dist/browser/index.global.js.map +1 -1
- package/packages/shared/dist/cjs/index.cjs +10 -0
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +10 -0
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/io/binaryStream.d.ts +2 -0
- package/packages/shared/dist/types/io/binaryStream.d.ts.map +1 -1
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var Quake2Engine=(()=>{var Sl=Object.create;var li=Object.defineProperty;var Al=Object.getOwnPropertyDescriptor;var Ml=Object.getOwnPropertyNames;var wl=Object.getPrototypeOf,Ll=Object.prototype.hasOwnProperty;var El=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),qo=(t,e)=>{for(var r in e)li(t,r,{get:e[r],enumerable:!0})},ya=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ml(e))!Ll.call(t,i)&&i!==r&&li(t,i,{get:()=>e[i],enumerable:!(n=Al(e,i))||n.enumerable});return t};var Tl=(t,e,r)=>(r=t!=null?Sl(wl(t)):{},ya(e||!t||!t.__esModule?li(r,"default",{value:t,enumerable:!0}):r,t)),Il=t=>ya(li({},"__esModule",{value:!0}),t);var Za=El((wm,Qa)=>{"use strict";Qa.exports=Worker});var Zf={};qo(Zf,{ATTN_IDLE:()=>Cc,ATTN_LOOP_NONE:()=>Tc,ATTN_NONE:()=>so,ATTN_NORM:()=>Ic,ATTN_STATIC:()=>Rc,AssetDependencyError:()=>Zt,AssetDependencyTracker:()=>qn,AssetManager:()=>io,AudioApi:()=>dr,AudioContextController:()=>co,AudioRegistry:()=>Pr,AudioRegistryError:()=>Xn,AudioSystem:()=>yo,BSP_SURFACE_FRAGMENT_SOURCE:()=>Gs,BSP_SURFACE_VERTEX_SOURCE:()=>Vs,BSP_VERTEX_LAYOUT:()=>ks,BspLoader:()=>fr,BspParseError:()=>q,BspSurfacePipeline:()=>vo,Camera:()=>wo,Command:()=>Wr,CommandRegistry:()=>or,ConfigStringRegistry:()=>lr,Cvar:()=>Yr,CvarRegistry:()=>ar,DemoPlaybackController:()=>ii,DemoReader:()=>tr,EngineHost:()=>cr,EngineRuntime:()=>qr,FixedTimestepLoop:()=>Ot,Framebuffer:()=>xo,IndexBuffer:()=>fe,LruCache:()=>pt,MAX_SOUND_CHANNELS:()=>Bs,MD2_FRAGMENT_SHADER:()=>js,MD2_VERTEX_SHADER:()=>$s,MD3_FRAGMENT_SHADER:()=>oa,MD3_VERTEX_SHADER:()=>ia,Md2Loader:()=>hr,Md2MeshBuffers:()=>So,Md2ParseError:()=>le,Md2Pipeline:()=>Ao,Md3Loader:()=>mr,Md3ModelMesh:()=>Lo,Md3ParseError:()=>Fe,Md3Pipeline:()=>Eo,Md3SurfaceMesh:()=>Jn,MusicSystem:()=>go,NetworkMessageParser:()=>nr,PARTICLE_FRAGMENT_SHADER:()=>aa,PARTICLE_VERTEX_SHADER:()=>sa,PakArchive:()=>ur,PakIndexStore:()=>no,PakIngestionError:()=>mt,PakParseError:()=>ze,PakValidationError:()=>Dt,PakValidator:()=>gi,ParticleRenderer:()=>Io,ParticleSystem:()=>To,PlaybackState:()=>Yo,RERELEASE_KNOWN_PAKS:()=>ss,SKYBOX_FRAGMENT_SHADER:()=>Ys,SKYBOX_VERTEX_SHADER:()=>Ks,SOUND_FULLVOLUME:()=>Br,SOUND_LOOP_ATTENUATE:()=>zc,ShaderProgram:()=>ve,SkyboxPipeline:()=>_o,SoundChannel:()=>oo,SoundPrecache:()=>fo,SoundRegistry:()=>uo,SpriteLoader:()=>pr,SpriteParseError:()=>yt,Texture2D:()=>Or,TextureCache:()=>yr,TextureCubeMap:()=>Dr,TgaParseError:()=>et,U_ALPHA:()=>bl,U_ANGLE1:()=>No,U_ANGLE2:()=>Fo,U_ANGLE3:()=>Po,U_EFFECTS16:()=>ri,U_EFFECTS8:()=>Zn,U_EVENT:()=>Oo,U_FRAME16:()=>Uo,U_FRAME8:()=>Bo,U_MODEL:()=>ko,U_MODEL2:()=>Ho,U_MODEL3:()=>Vo,U_MODEL4:()=>Go,U_OLDORIGIN:()=>Wo,U_ORIGIN1:()=>Ro,U_ORIGIN2:()=>zo,U_ORIGIN3:()=>Do,U_REMOVE:()=>ca,U_RENDERFX16:()=>ti,U_RENDERFX8:()=>Qn,U_SKIN16:()=>ni,U_SKIN8:()=>ei,U_SOLID:()=>Ko,U_SOUND:()=>Xo,VertexArray:()=>we,VertexBuffer:()=>_e,VirtualFileSystem:()=>yi,advanceAnimation:()=>Ya,applySurfaceState:()=>Xc,attenuationToDistanceMultiplier:()=>er,boxIntersectsFrustum:()=>jn,buildBspGeometry:()=>Nc,buildMd2Geometry:()=>Js,buildMd2VertexData:()=>Qs,buildMd3SurfaceGeometry:()=>ra,buildMd3VertexData:()=>na,calculateMaxAudibleDistance:()=>ao,calculatePakChecksum:()=>Ba,computeFrameBlend:()=>qa,computeSkyScroll:()=>qc,createAnimationState:()=>$a,createAudioGraph:()=>lo,createBspSurfaces:()=>Dc,createEmptyEntityState:()=>rr,createEmptyProtocolPlayerState:()=>Co,createEngine:()=>Qf,createEngineRuntime:()=>Fa,createFaceLightmap:()=>bi,createInitialChannels:()=>ho,createProgramFromSources:()=>Oc,createWebGLContext:()=>Pc,decodeOgg:()=>ro,deriveSurfaceRenderState:()=>Xs,extractFrustumPlanes:()=>kc,filesToPakSources:()=>as,findLeafForPoint:()=>Hs,gatherVisibleFaces:()=>Gc,groupMd2Animations:()=>Ga,ingestPakFiles:()=>Oa,ingestPaks:()=>xi,interpolateMd3Tag:()=>fl,interpolateVec3:()=>ja,parseBsp:()=>cs,parseMd2:()=>ls,parseMd3:()=>ds,parsePcx:()=>Qr,parseSprite:()=>us,parseTga:()=>fs,parseWal:()=>_i,parseWalTexture:()=>Mi,parseWav:()=>wi,pcxToRgba:()=>Si,pickChannel:()=>mo,preparePcxTexture:()=>Ai,removeViewTranslation:()=>Yc,resolveLightStyles:()=>Ws,spatializeOrigin:()=>po,spawnBlood:()=>pl,spawnBulletImpact:()=>hl,spawnExplosion:()=>ml,spawnMuzzleFlash:()=>gl,spawnTeleportFlash:()=>yl,spawnTrail:()=>xl,walToRgba:()=>hs,wireDropTarget:()=>Da,wireFileInput:()=>Na});var Cl=()=>typeof performance<"u"?performance.now():Date.now(),Rl=t=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>t()):setTimeout(t,25)},Ot=class{constructor(e,r={}){this.callbacks=e;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let e=this.options.now(),r=this.lastTimeMs===void 0?0:e-this.lastTimeMs;this.lastTimeMs=e,this.advance(r,e),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??Cl,schedule:r.schedule??Rl}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(e){let r=(this.lastTimeMs??0)+e;this.lastTimeMs=r,this.advance(e,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(e,r){let n=Math.min(Math.max(e,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 Wr=class{constructor(e,r,n){this.name=e,this.callback=r,this.description=n}execute(e){this.callback(e)}},or=class{constructor(){this.commands=new Map}register(e,r,n){let i=new Wr(e,r,n);return this.commands.set(e,i),i}get(e){return this.commands.get(e)}execute(e){let r=this.tokenize(e);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(e){return e.trim().split(/\s+/)}list(){return[...this.commands.values()].sort((e,r)=>e.name.localeCompare(r.name))}};var zl=Object.defineProperty,ga=(t,e)=>{for(var r in e)zl(t,r,{get:e[r],enumerable:!0})},xa={x:0,y:0,z:0};var nh=Math.PI/180;function ba(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function Fl(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}function jo(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function Pl(t){return jo(t,t)}function Jo(t){return Math.sqrt(Pl(t))}function He(t){let e=Jo(t);return e===0?t:Fl(t,1/e)}var Bl=Math.PI/180,ih=180/Math.PI,sr=Bl;var Ol=[[-.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 Dl(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function va(t,e){let r=e.x,n=e.y,i=e.z;return{x:t[0]*r+t[4]*n+t[8]*i+t[12],y:t[1]*r+t[5]*n+t[9]*i+t[13],z:t[2]*r+t[6]*n+t[10]*i+t[14]}}function _a(t,e){let r=Dl();return r[0]=e[0].x,r[1]=e[0].y,r[2]=e[0].z,r[4]=e[1].x,r[5]=e[1].y,r[6]=e[1].z,r[8]=e[2].x,r[9]=e[2].y,r[10]=e[2].z,r[12]=t.x,r[13]=t.y,r[14]=t.z,r}var Ke=1,ht=2;var Qo=8,Zo=16,Nl=32;var kl=16384;var di=65536,Sa=1<<17,Ul=1<<18,Hl=1<<19,Vl=1<<20,Gl=1<<21,Wl=1<<22,Xl=1<<23,oh=1<<24,ui=1<<25,Kl=1<<26,sh=1<<27,ah=1<<28,ch=1<<29,fi=1<<30,lh=1<<31;var Kr=0;var Aa=4,Ma=8,wa=16,La=32,Ea=64;var dh=1<<25,uh=1<<28,fh=1<<29,hh=1<<30,mh=1<<31;var ph=Ke|ht,yh=Ke|di|ht|ui|fi,gh=Ke|di|ht,xh=Ke|Sa|ht|ui|fi,bh=Nl|Qo|Zo,vh=Ke|Zo|Qo,Yl=Ke|ui|fi|ht|Kl,_h=Ul|Hl|Vl|Gl|Wl|Xl,Sh=Ke|Qo|Zo|ui|fi,Ah=Ke|di|ht,Mh=Ke|ht,wh=Ke|di|ht|Sa,Lh=Yl|kl;var Eh=Number.MAX_SAFE_INTEGER-1;var hi=(t=>(t[t.None=0]="None",t[t.Archive=1]="Archive",t[t.UserInfo=2]="UserInfo",t[t.ServerInfo=4]="ServerInfo",t[t.Latch=8]="Latch",t[t.Cheat=16]="Cheat",t))(hi||{});var mi=256;var es=256,ts=8192,pi=2048,rs=512,ns=256,is=mi*2,os=256,$o=32,Xr=96;var Y=(t=>(t[t.Name=0]="Name",t[t.CdTrack=1]="CdTrack",t[t.Sky=2]="Sky",t[t.SkyAxis=3]="SkyAxis",t[t.SkyRotate=4]="SkyRotate",t[t.StatusBar=5]="StatusBar",t[t.CONFIG_N64_PHYSICS=56]="CONFIG_N64_PHYSICS",t[t.CONFIG_CTF_TEAMS=57]="CONFIG_CTF_TEAMS",t[t.CONFIG_COOP_RESPAWN_STRING=58]="CONFIG_COOP_RESPAWN_STRING",t[t.AirAccel=59]="AirAccel",t[t.MaxClients=60]="MaxClients",t[t.MapChecksum=61]="MapChecksum",t[t.Models=62]="Models",t[t.Sounds=62+ts]="Sounds",t[t.Images=t.Sounds+pi]="Images",t[t.Lights=t.Images+rs]="Lights",t[t.ShadowLights=t.Lights+es]="ShadowLights",t[t.Items=t.ShadowLights+os]="Items",t[t.PlayerSkins=t.Items+ns]="PlayerSkins",t[t.General=t.PlayerSkins+mi]="General",t[t.WheelWeapons=t.General+is]="WheelWeapons",t[t.WheelAmmo=t.WheelWeapons+$o]="WheelAmmo",t[t.WheelPowerups=t.WheelAmmo+$o]="WheelPowerups",t[t.CdLoopCount=t.WheelPowerups+$o]="CdLoopCount",t[t.GameStyle=t.CdLoopCount+1]="GameStyle",t[t.MaxConfigStrings=t.GameStyle+1]="MaxConfigStrings",t))(Y||{}),Ta=Y.MaxConfigStrings;function Ia(t){return t>=5&&t<59?Xr*(59-t):t>=Y.General&&t<Y.WheelWeapons?Xr*(Y.MaxConfigStrings-t):Xr}var ql={};ga(ql,{addReplayFrame:()=>Ql,createReplaySession:()=>Jl,deserializeReplay:()=>jl,serializeReplay:()=>$l});function $l(t){return JSON.stringify(t,null,2)}function jl(t){let e=JSON.parse(t);if(!e.metadata||!Array.isArray(e.frames))throw new Error("Invalid replay format: missing metadata or frames");return e}function Jl(t,e){return{metadata:{map:t,date:new Date().toISOString(),version:"1.0",seed:e},frames:[]}}function Ql(t,e,r,n){t.frames.push({serverFrame:r,cmd:e,timestamp:Date.now()-n})}var R=(t=>(t[t.bad=0]="bad",t[t.muzzleflash=1]="muzzleflash",t[t.muzzleflash2=2]="muzzleflash2",t[t.temp_entity=3]="temp_entity",t[t.layout=4]="layout",t[t.inventory=5]="inventory",t[t.nop=6]="nop",t[t.disconnect=7]="disconnect",t[t.reconnect=8]="reconnect",t[t.sound=9]="sound",t[t.print=10]="print",t[t.stufftext=11]="stufftext",t[t.serverdata=12]="serverdata",t[t.configstring=13]="configstring",t[t.spawnbaseline=14]="spawnbaseline",t[t.centerprint=15]="centerprint",t[t.download=16]="download",t[t.playerinfo=17]="playerinfo",t[t.packetentities=18]="packetentities",t[t.deltapacketentities=19]="deltapacketentities",t[t.frame=20]="frame",t[t.splitclient=21]="splitclient",t[t.configblast=22]="configblast",t[t.spawnbaselineblast=23]="spawnbaselineblast",t[t.level_restart=24]="level_restart",t[t.damage=25]="damage",t[t.locprint=26]="locprint",t[t.fog=27]="fog",t[t.waitingforplayers=28]="waitingforplayers",t[t.bot_chat=29]="bot_chat",t[t.poi=30]="poi",t[t.help_path=31]="help_path",t[t.muzzleflash3=32]="muzzleflash3",t[t.achievement=33]="achievement",t))(R||{});var T=(t=>(t[t.GUNSHOT=0]="GUNSHOT",t[t.BLOOD=1]="BLOOD",t[t.BLASTER=2]="BLASTER",t[t.RAILTRAIL=3]="RAILTRAIL",t[t.SHOTGUN=4]="SHOTGUN",t[t.EXPLOSION1=5]="EXPLOSION1",t[t.EXPLOSION2=6]="EXPLOSION2",t[t.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",t[t.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",t[t.SPARKS=9]="SPARKS",t[t.SPLASH=10]="SPLASH",t[t.BUBBLETRAIL=11]="BUBBLETRAIL",t[t.SCREEN_SPARKS=12]="SCREEN_SPARKS",t[t.SHIELD_SPARKS=13]="SHIELD_SPARKS",t[t.BULLET_SPARKS=14]="BULLET_SPARKS",t[t.LASER_SPARKS=15]="LASER_SPARKS",t[t.PARASITE_ATTACK=16]="PARASITE_ATTACK",t[t.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",t[t.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",t[t.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",t[t.BFG_EXPLOSION=20]="BFG_EXPLOSION",t[t.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",t[t.BOSSTPORT=22]="BOSSTPORT",t[t.BFG_LASER=23]="BFG_LASER",t[t.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",t[t.WELDING_SPARKS=25]="WELDING_SPARKS",t[t.GREENBLOOD=26]="GREENBLOOD",t[t.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",t[t.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",t[t.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",t[t.BLASTER2=30]="BLASTER2",t[t.RAILTRAIL2=31]="RAILTRAIL2",t[t.FLAME=32]="FLAME",t[t.LIGHTNING=33]="LIGHTNING",t[t.DEBUGTRAIL=34]="DEBUGTRAIL",t[t.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",t[t.FLASHLIGHT=36]="FLASHLIGHT",t[t.FORCEWALL=37]="FORCEWALL",t[t.HEATBEAM=38]="HEATBEAM",t[t.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",t[t.STEAM=40]="STEAM",t[t.BUBBLETRAIL2=41]="BUBBLETRAIL2",t[t.MOREBLOOD=42]="MOREBLOOD",t[t.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",t[t.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",t[t.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",t[t.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",t[t.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",t[t.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",t[t.DBALL_GOAL=49]="DBALL_GOAL",t[t.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",t[t.NUKEBLAST=51]="NUKEBLAST",t[t.WIDOWSPLASH=52]="WIDOWSPLASH",t[t.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",t[t.EXPLOSION1_NP=54]="EXPLOSION1_NP",t[t.FLECHETTE=55]="FLECHETTE",t[t.BLUEHYPERBLASTER_KEX=56]="BLUEHYPERBLASTER_KEX",t[t.BFG_ZAP=57]="BFG_ZAP",t[t.BERSERK_SLAM=58]="BERSERK_SLAM",t[t.GRAPPLE_CABLE_2=59]="GRAPPLE_CABLE_2",t[t.POWER_SPLASH=60]="POWER_SPLASH",t[t.LIGHTNING_BEAM=61]="LIGHTNING_BEAM",t[t.EXPLOSION1_NL=62]="EXPLOSION1_NL",t[t.EXPLOSION2_NL=63]="EXPLOSION2_NL",t))(T||{});var Zl=12,ed=9,Th=Math.ceil(Zl*ed/16),td=23,rd=2,Ih=Math.ceil(td*rd/16);var nd={};ga(nd,{U_ANGLE1:()=>dd,U_ANGLE2:()=>ud,U_ANGLE3:()=>fd,U_EFFECTS:()=>pd,U_EVENT:()=>xd,U_FRAME:()=>hd,U_MODEL:()=>od,U_MODEL2:()=>vd,U_MODEL3:()=>_d,U_MODEL4:()=>Sd,U_MOREBITS:()=>bd,U_NUMBER:()=>id,U_ORIGIN1:()=>ad,U_ORIGIN2:()=>cd,U_ORIGIN3:()=>ld,U_REMOVE:()=>Ad,U_RENDERFX:()=>yd,U_SKIN:()=>md,U_SOLID:()=>gd,U_SOUND:()=>sd});var id=1,od=2,sd=4,ad=8,cd=16,ld=32,dd=64,ud=128,fd=256,hd=512,md=1024,pd=2048,yd=4096,gd=8192,xd=16384,bd=32768,vd=1,_d=2,Sd=4,Ad=32768;var Ca=class{constructor(t){t instanceof Uint8Array?this.view=new DataView(t.buffer,t.byteOffset,t.byteLength):this.view=new DataView(t),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(t){if(t<0||t>this.length)throw new Error(`Seek out of bounds: ${t} (length: ${this.length})`);this.offset=t}hasMore(){return this.offset<this.length}readChar(){let t=this.view.getInt8(this.offset);return this.offset+=1,t}readByte(){let t=this.view.getUint8(this.offset);return this.offset+=1,t}readShort(){let t=this.view.getInt16(this.offset,!0);return this.offset+=2,t}readLong(){let t=this.view.getInt32(this.offset,!0);return this.offset+=4,t}readFloat(){let t=this.view.getFloat32(this.offset,!0);return this.offset+=4,t}readString(){let t="";for(;this.offset<this.length;){let e=this.readChar();if(e===-1||e===0)break;t+=String.fromCharCode(e)}return t}readStringLine(){let t="";for(;this.offset<this.length;){let e=this.readChar();if(e===-1||e===0||e===10)break;t+=String.fromCharCode(e)}return t}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(t){if(this.offset+t>this.length)throw new Error(`Read out of bounds: ${this.offset+t} (length: ${this.length})`);let e=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,t);return this.offset+=t,new Uint8Array(e)}readPos(t){t.x=this.readCoord(),t.y=this.readCoord(),t.z=this.readCoord()}readDir(t){let e=this.readByte();if(e>=162){t.x=0,t.y=0,t.z=0;return}let r=Ol[e];t.x=r[0],t.y=r[1],t.z=r[2]}};var Ra=(t=>(t[t.Bullets=0]="Bullets",t[t.Shells=1]="Shells",t[t.Rockets=2]="Rockets",t[t.Grenades=3]="Grenades",t[t.Cells=4]="Cells",t[t.Slugs=5]="Slugs",t[t.MagSlugs=6]="MagSlugs",t[t.Trap=7]="Trap",t[t.Flechettes=8]="Flechettes",t[t.Tesla=9]="Tesla",t[t.Disruptor=10]="Disruptor",t[t.Prox=11]="Prox",t[t.Nuke=12]="Nuke",t[t.Rounds=13]="Rounds",t))(Ra||{}),Ch=Object.keys(Ra).length/2;var Yr=class{constructor({name:e,defaultValue:r,description:n,flags:i=hi.None,onChange:o}){this.modifiedCount=0;this.name=e,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(e){if(this.flags&hi.Latch){if(e===this._value){this.latched=void 0;return}if(this.latched===e)return;this.latched!==e&&(this.latched=e);return}this.apply(e)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let e=this.latched;return this.latched=void 0,e===this._value?!1:(this.apply(e),!0)}apply(e){if(this._value===e)return;let r=this._value;this._value=e,this.modifiedCount+=1,this.onChange?.(this,r)}},ar=class{constructor(){this.cvars=new Map}register(e){let r=this.cvars.get(e.name);if(r)return r;let n=new Yr(e);return this.cvars.set(e.name,n),n}get(e){return this.cvars.get(e)}setValue(e,r){let n=this.get(e);if(!n)throw new Error(`Unknown cvar: ${e}`);return n.set(r),n}resetAll(){for(let e of this.cvars.values())e.reset()}applyLatched(){let e=!1;for(let r of this.cvars.values())e=r.applyLatched()||e;return e}list(){return[...this.cvars.values()].sort((e,r)=>e.name.localeCompare(r.name))}};var cr=class{constructor(e,r,n={}){this.game=e;this.client=r;this.started=!1;this.commands=new or;this.cvars=new ar;this.stepSimulation=e=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(e,this.latestCommand)};this.renderClient=e=>{this.client&&(this.latestCommand=this.client.render({...e,previous:this.previousFrame,latest:this.latestFrame}))};let i=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??i,this.loop=new Ot({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(e){throw this.game.shutdown(),this.client?.shutdown(),e}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(e){this.loop.pump(e)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};function Md(t){if(t<0||t>=Y.MaxConfigStrings)throw new RangeError(`Configstring index ${t} is out of range (0-${Y.MaxConfigStrings-1})`)}function za(t,e){let r=Ia(t);if(e.length>r)throw new RangeError(`Configstring ${t} exceeds maximum length (${e.length} > ${r}); limit is ${Xr} chars per slot`)}var lr=class{constructor(){this.values=new Map;this.modelCursor=Y.Models;this.soundCursor=Y.Sounds;this.imageCursor=Y.Images;this.lightCursor=Y.Lights;this.shadowLightCursor=Y.ShadowLights;this.itemCursor=Y.Items;this.playerSkinCursor=Y.PlayerSkins;this.generalCursor=Y.General}set(e,r){return Md(e),za(e,r),this.values.set(e,r),e}get(e){return this.values.get(e)}getName(e){return this.get(e)}getAll(){let e=new Array(Ta).fill("");for(let[r,n]of this.values.entries())e[r]=n;return e}modelIndex(e){return this.register(e,Y.Models,ts,"modelCursor")}soundIndex(e){return this.register(e,Y.Sounds,pi,"soundCursor")}findSoundIndex(e){for(let r=Y.Sounds;r<Y.Sounds+pi;r+=1)if(this.values.get(r)===e)return r}imageIndex(e){return this.register(e,Y.Images,rs,"imageCursor")}lightIndex(e){return this.register(e,Y.Lights,es,"lightCursor")}shadowLightIndex(e){return this.register(e,Y.ShadowLights,os,"shadowLightCursor")}itemIndex(e){return this.register(e,Y.Items,ns,"itemCursor")}playerSkinIndex(e){return this.register(e,Y.PlayerSkins,mi,"playerSkinCursor")}generalIndex(e){return this.register(e,Y.General,is,"generalCursor")}register(e,r,n,i){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===e)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 za(o,e),this.values.set(o,e),this[i]=o+1,o}};var dr=class{constructor(e){this.registry=e.registry,this.system=e.system,this.music=e.music,this.client=e.client}soundindex(e){return this.registry.registerName(e)}sound(e,r,n,i,o,s){this.system.play({entity:e,channel:r,soundIndex:n,volume:i,attenuation:o,timeOffsetMs:s}),this.triggerSubtitle(n)}positioned_sound(e,r,n,i){this.system.positionedSound(e,r,n,i),this.triggerSubtitle(r)}loop_sound(e,r,n,i,o){this.system.play({entity:e,channel:r,soundIndex:n,volume:i,attenuation:o,looping:!0}),this.triggerSubtitle(n)}stop_entity_sounds(e){this.system.stopEntitySounds(e)}set_listener(e){this.system.setListener(e)}play_music(e,r=!0){return this.music?this.music.play(e,{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(e){this.music?.setVolume(e)}play_ambient(e,r,n){this.system.ambientSound(e,r,n),this.triggerSubtitle(r)}play_channel(e){this.system.play({...e}),this.triggerSubtitle(e.soundIndex)}triggerSubtitle(e){if(!this.client)return;let r=this.registry.getName(e);if(!r)return;let n=r.match(/\[(.*?)\]/);n&&this.client.showSubtitle(n[1],r)}};var qr=class{constructor(e,r){this.engine=e;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(e){this.host.pump(e)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function Fa(t,e,r,n,i){let o=new dr({...n,client:r}),s=new cr(e,r,i);return{runtime:new qr(t,s),audio:o}}var wd="PACK";function Ld(t,e,r){let n=[];for(let i=0;i<r;i+=1){let o=t.getUint8(e+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function ie(t){return t.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function Ed(){let t=new Uint32Array(256);for(let e=0;e<256;e+=1){let r=e;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;t[e]=r>>>0}return t}var Td=Ed();function Pa(t){let e=4294967295;for(let r=0;r<t.length;r+=1){let n=t[r];e=Td[(e^n)&255]^e>>>8}return(e^4294967295)>>>0}var ze=class extends Error{},ur=class t{constructor(e,r,n,i){this.name=e;this.buffer=r;this.entries=new Map(n.map(o=>[o.name,o])),this.checksum=i,this.size=r.byteLength}static fromArrayBuffer(e,r){let n=new DataView(r);if(r.byteLength<12)throw new ze("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!==wd)throw new ze(`Invalid PAK header magic: ${i}`);let o=n.getInt32(4,!0),s=n.getInt32(8,!0);if(o<12)throw new ze(`Invalid directory offset: ${o}`);if(s<=0||s%64!==0)throw new ze(`Invalid directory length: ${s}`);if(o+s>r.byteLength)throw new ze("Directory exceeds buffer length");let c=s/64,l=[],d=new Map;for(let u=0;u<c;u+=1){let f=o+u*64,h=Ld(n,f,56),m=ie(h),y=n.getInt32(f+56,!0),p=n.getInt32(f+60,!0);if(y<0||p<0||y+p>r.byteLength)throw new ze(`Invalid entry bounds for ${h||"<unnamed>"} (offset=${y}, length=${p})`);if(!m)throw new ze(`Entry ${u} has an empty name`);let g={name:m,offset:y,length:p};d.set(m,g)}return l.push(...d.values()),new t(e,r,l,Pa(new Uint8Array(r)))}getEntry(e){return this.entries.get(ie(e))}listEntries(){return Array.from(this.entries.values())}readFile(e){let r=this.getEntry(e);if(!r)throw new ze(`File not found in PAK: ${e}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function Ba(t){return Pa(new Uint8Array(t))}var yi=class{constructor(e=[]){this.mounts=[];this.files=new Map;e.forEach(r=>this.mountPak(r))}mountPak(e){this.mounts.push(e);for(let r of e.listEntries()){let n=ie(r.name);this.files.set(n,{archive:e,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(e){return this.files.has(ie(e))}stat(e){let r=this.files.get(ie(e));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(e){let r=this.files.get(ie(e));if(!r)throw new Error(`File not found in VFS: ${e}`);return r.archive.readFile(e)}list(e=""){let r=ie(e).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,c=a.indexOf("/");c===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):i.add(a.slice(0,c))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...i].sort()}}findByExtension(e){let r=e.startsWith(".")?e.toLowerCase():`.${e.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 ss=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"}]),Dt=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"}},gi=class{constructor(e=ss){this.known=new Map;e.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(e,r){let n=this.normalizePakName(r??("name"in e?e.name:"unknown")),i=e.checksum,o="size"in e?e.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(e,r){let n=this.validateArchive(e,r);if(n.status==="mismatch")throw new Dt(n);return n}normalizePakName(e){let r=ie(e),n=r.split("/"),i=n.pop()??r,o=n.pop();return o?`${i}@${o}`:i}};var mt=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 Id(t,e){if(typeof t.arrayBuffer=="function"){let r=await t.arrayBuffer();return e?.({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=>{e?.({file:"blob",loadedBytes:o.loaded,totalBytes:o.total||t.size,state:"reading"})},i.onload=()=>{let o=i.result;o instanceof ArrayBuffer?r(o):n(new Error("Unexpected FileReader result"))},i.readAsArrayBuffer(t)});if(typeof Response<"u"){let r=await new Response(t).arrayBuffer();return e?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof t.stream=="function"){let r=t.stream().getReader(),n=[],i=0;for(;;){let{done:a,value:c}=await r.read();if(a)break;if(!c)continue;let l=c;n.push(l),i+=l.byteLength,e?.({file:"blob",loadedBytes:i,totalBytes:t.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 mt("blob",new Error("Unsupported Blob type"))}async function Cd(t,e){if(t.data instanceof ArrayBuffer)return e?.({file:t.name,loadedBytes:t.data.byteLength,totalBytes:t.data.byteLength,state:"reading"}),t.data;if(t.data instanceof Blob){let n=t.data.size;return Id(t.data,i=>e?.({...i,file:t.name,totalBytes:n}))}let r=t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength);return e?.({file:t.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function xi(t,e,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,c=[];for(let l of e)try{let d=await Cd(l,n.onProgress),u=ur.fromArrayBuffer(l.name,d),f=n.validator?.validateArchive(u);if(f){n.onValidationResult?.(f);let h=f.status==="mismatch",m=f.status==="unknown";if(h&&o||m&&!s){let y=new Dt(f);if(n.onError?.(l.name,y),a)throw new mt(l.name,y);c.push({archive:u,mounted:!1,validation:f});continue}}if(t.mountPak(u),i&&n.pakIndexStore)try{await n.pakIndexStore.persist(u)}catch(h){if(n.onError?.(l.name,h),a)throw new mt(l.name,h)}n.onProgress?.({file:l.name,loadedBytes:d.byteLength,totalBytes:d.byteLength,state:"parsed"}),c.push({archive:u,mounted:!0,validation:f})}catch(d){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,d),a)throw new mt(l.name,d)}return c}var pt=class{constructor(e){this.capacity=e;this.map=new Map;if(e<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(e){return this.map.has(e)}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}set(e,r){if(this.map.has(e)&&this.map.delete(e),this.map.set(e,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(e){return this.map.delete(e)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([e,r])=>({key:e,value:r}))}};function Rd(t){return Array.isArray(t)?t:Array.from(t)}function as(t){return Rd(t).map(e=>({name:e.name,data:e}))}async function Oa(t,e,r){let n=as(e);return xi(t,n,r??{})}function Da(t,e){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&&e(Array.from(o))};return t.addEventListener("dragover",r),t.addEventListener("drop",n),()=>{t.removeEventListener("dragover",r),t.removeEventListener("drop",n)}}function Na(t,e){let r=n=>{let i=n.target;!i||!i.files||i.files.length===0||(e(i.files),i.value="")};return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}var zd="IBSP",Fd=38,Ua=19,Pd=8+Ua*8;var q=class extends Error{},fr=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),cs(n.buffer)}};function cs(t){if(t.byteLength<Pd)throw new q("BSP too small to contain header");let e=new DataView(t),r=String.fromCharCode(e.getUint8(0),e.getUint8(1),e.getUint8(2),e.getUint8(3));if(r!==zd)throw new q(`Invalid BSP magic ${r}`);let n=e.getInt32(4,!0);if(n!==Fd)throw new q(`Unsupported BSP version ${n}`);let i=new Map;for(let M=0;M<Ua;M+=1){let w=e.getInt32(8+M*8,!0),E=e.getInt32(12+M*8,!0);if(w<0||E<0||w+E>t.byteLength)throw new q(`Invalid lump bounds for index ${M}`);i.set(M,{offset:w,length:E})}let o={version:n,lumps:i},s=Od(t,i.get(0)),a=Nd(t,i.get(1)),c=kd(t,i.get(2)),l=Ud(t,i.get(4)),d=Hd(t,i.get(5)),u=Vd(t,i.get(6)),f=new Uint8Array(t,i.get(7).offset,i.get(7).length),h=Jd(u,i.get(7)),m=Gd(t,i.get(8)),y=Wd(t,i.get(11)),p=Xd(t,i.get(12)),g=Kd(t,i.get(13)),_=Yd(t,i.get(14)),x=qd(t,i.get(15)),v=$d(t,i.get(9),i.get(10),m),b=jd(t,i.get(3));return{header:o,entities:s,planes:a,vertices:c,nodes:l,texInfo:d,faces:u,lightMaps:f,lightMapInfo:h,leafs:m,leafLists:v,edges:y,surfEdges:p,models:g,brushes:_,brushSides:x,visibility:b,pickEntity(M){let w=null,E=1/0;for(let L of s.entities){let O=L.properties.model;if(!O||!O.startsWith("*"))continue;let N=parseInt(O.substring(1),10);if(isNaN(N)||N<0||N>=g.length)continue;let H=g[N],C=Bd(M.origin,M.direction,H.mins,H.maxs);C!==null&&C<E&&(E=C,w={entity:L,model:H,distance:C})}return w}}}function Bd(t,e,r,n){let i=0,o=1/0;for(let s=0;s<3;s++)if(Math.abs(e[s])<1e-8){if(t[s]<r[s]||t[s]>n[s])return null}else{let a=1/e[s],c=(r[s]-t[s])*a,l=(n[s]-t[s])*a;if(c>l){let d=c;c=l,l=d}if(i=Math.max(i,c),o=Math.min(o,l),i>o)return null}return i}function Od(t,e){let r=new TextDecoder().decode(new Uint8Array(t,e.offset,e.length)),n=Dd(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 Dd(t){let e=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(t))!==null;){let i=n[1],o={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(i))!==null;)o[a[1]]=a[2];e.push({classname:o.classname,properties:o})}return e}function Nd(t,e){let r=new DataView(t,e.offset,e.length),n=e.length/20;if(n%1!==0)throw new q("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),c=r.getInt32(o*20+16,!0);i.push({normal:s,dist:a,type:c})}return i}function kd(t,e){let r=new DataView(t,e.offset,e.length),n=e.length/12;if(n%1!==0)throw new q("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 Ud(t,e){let r=new DataView(t,e.offset,e.length),n=28,i=e.length/n;if(i%1!==0)throw new q("Node lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,c=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],d=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],u=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],f=r.getUint16(a+24,!0),h=r.getUint16(a+26,!0);o.push({planeIndex:c,children:l,mins:d,maxs:u,firstFace:f,numFaces:h})}return o}function Hd(t,e){let r=new DataView(t,e.offset,e.length),n=76,i=e.length/n;if(i%1!==0)throw new q("TexInfo lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,c=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),d=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],u=r.getFloat32(a+28,!0),f=r.getInt32(a+32,!0),h=r.getInt32(a+36,!0),m=new Uint8Array(t,e.offset+a+40,32),y=new TextDecoder("utf-8").decode(m).replace(/\0.*$/,""),p=r.getInt32(a+72,!0);o.push({s:c,sOffset:l,t:d,tOffset:u,flags:f,value:h,texture:y,nextTexInfo:p})}return o}function Vd(t,e){let r=new DataView(t,e.offset,e.length),n=20,i=e.length/n;if(i%1!==0)throw new q("Face lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,c=r.getUint16(a,!0),l=r.getInt16(a+2,!0),d=r.getInt32(a+4,!0),u=r.getInt16(a+8,!0),f=r.getInt16(a+10,!0),h=[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:c,side:l,firstEdge:d,numEdges:u,texInfo:f,styles:h,lightOffset:m})}return o}function Gd(t,e){let r=new DataView(t,e.offset,e.length),n=28,i=e.length/n;if(i%1!==0)throw new q("Leaf lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,c=r.getInt32(a,!0),l=r.getInt16(a+4,!0),d=r.getInt16(a+6,!0),u=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],f=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],h=r.getUint16(a+20,!0),m=r.getUint16(a+22,!0),y=r.getUint16(a+24,!0),p=r.getUint16(a+26,!0);o.push({contents:c,cluster:l,area:d,mins:u,maxs:f,firstLeafFace:h,numLeafFaces:m,firstLeafBrush:y,numLeafBrushes:p})}return o}function Wd(t,e){let r=new DataView(t,e.offset,e.length),n=4,i=e.length/n;if(i%1!==0)throw new q("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 Xd(t,e){let r=e.length/4;if(r%1!==0)throw new q("SurfEdge lump has invalid length");let n=new DataView(t,e.offset,e.length),i=new Int32Array(r);for(let o=0;o<r;o+=1)i[o]=n.getInt32(o*4,!0);return i}function Kd(t,e){let r=new DataView(t,e.offset,e.length),n=48;if(e.length%n!==0)throw new q("Model lump has invalid length");let i=e.length/n,o=[];for(let s=0;s<i;s+=1){let a=s*n,c=[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)],d=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],u=r.getInt32(a+36,!0),f=r.getInt32(a+40,!0),h=r.getInt32(a+44,!0);o.push({mins:c,maxs:l,origin:d,headNode:u,firstFace:f,numFaces:h})}return o}function Yd(t,e){let r=new DataView(t,e.offset,e.length),n=12,i=e.length/n;if(i%1!==0)throw new q("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 qd(t,e){let r=new DataView(t,e.offset,e.length),n=4,i=e.length/n;if(i%1!==0)throw new q("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 $d(t,e,r,n){let i=[],o=[],s=e.length/2,a=r.length/2,c=new DataView(t,e.offset,e.length),l=new DataView(t,r.offset,r.length);for(let d of n){if(d.firstLeafFace+d.numLeafFaces>s)throw new q("Leaf faces reference data past lump bounds");if(d.firstLeafBrush+d.numLeafBrushes>a)throw new q("Leaf brushes reference data past lump bounds");let u=[];for(let h=0;h<d.numLeafFaces;h+=1)u.push(c.getUint16((d.firstLeafFace+h)*2,!0));let f=[];for(let h=0;h<d.numLeafBrushes;h+=1)f.push(l.getUint16((d.firstLeafBrush+h)*2,!0));i.push(u),o.push(f)}return{leafFaces:i,leafBrushes:o}}function jd(t,e){if(e.length===0)return;if(e.length<4)throw new q("Visibility lump too small");let r=new DataView(t,e.offset,e.length),n=r.getInt32(0,!0),i=4+n*8;if(n<0||i>e.length)throw new q("Visibility lump truncated");let o=4,s=[];for(let a=0;a<n;a+=1){let c=r.getInt32(o,!0),l=r.getInt32(o+4,!0);o+=8;let d=e.offset+c,u=e.offset+l,f=e.offset+e.length;if(c<0||l<0||d>=f||u>=f)throw new q("Visibility offsets out of range");s.push({pvs:ka(t,d,n,e),phs:ka(t,u,n,e)})}return{numClusters:n,clusters:s}}function ka(t,e,r,n){let i=Math.ceil(r/8),o=new Uint8Array(i),s=new Uint8Array(t),a=e,c=0,l=n.offset+n.length;for(;c<i;){if(a>=l)throw new q("Visibility data truncated");let d=s[a++];if(d!==0){o[c++]=d;continue}if(a>=l)throw new q("Visibility run exceeds lump bounds");let u=s[a++];for(let f=0;f<u&&c<i;f+=1)o[c++]=0}return o}function Jd(t,e){return t.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,e.length-r.lightOffset)}})}function bi(t,e,r){if(t.lightOffset<0||t.lightOffset>=e.byteLength)return;let n=e.byteLength-t.lightOffset,i=Math.min(r?.length??n,n);if(!(i<=0))return e.subarray(t.lightOffset,t.lightOffset+i)}var Qd=844121161,Zd=8,Ha=68,e0=[{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}],le=class extends Error{},hr=class{constructor(e){this.vfs=e;this.cache=new Map}async load(e){if(this.cache.has(e))return this.cache.get(e);let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);n.set(r);let i=ls(n.buffer);return this.cache.set(e,i),i}get(e){return this.cache.get(e)}};function Va(t,e,r){let n=[];for(let i=0;i<r;i+=1){let o=t.getUint8(e+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function $r(t,e,r,n){if(r!==0&&(e<Ha||e+r>t.byteLength))throw new le(`${n} section is out of bounds`)}function t0(t){if(t.byteLength<Ha)throw new le("MD2 buffer too small to contain header");let e=new DataView(t),r=e.getInt32(0,!0),n=e.getInt32(4,!0);if(r!==Qd)throw new le(`Invalid MD2 ident: ${r}`);if(n!==Zd)throw new le(`Unsupported MD2 version: ${n}`);let i={ident:r,version:n,skinWidth:e.getInt32(8,!0),skinHeight:e.getInt32(12,!0),frameSize:e.getInt32(16,!0),numSkins:e.getInt32(20,!0),numVertices:e.getInt32(24,!0),numTexCoords:e.getInt32(28,!0),numTriangles:e.getInt32(32,!0),numGlCommands:e.getInt32(36,!0),numFrames:e.getInt32(40,!0),offsetSkins:e.getInt32(44,!0),offsetTexCoords:e.getInt32(48,!0),offsetTriangles:e.getInt32(52,!0),offsetFrames:e.getInt32(56,!0),offsetGlCommands:e.getInt32(60,!0),offsetEnd:e.getInt32(64,!0),magic:r},o=40+i.numVertices*4;if(i.frameSize!==o)throw new le(`Unexpected frame size ${i.frameSize}, expected ${o}`);if(i.offsetEnd>t.byteLength)throw new le("MD2 offset_end exceeds buffer length");return i}function r0(t,e){let r=e.numSkins*64;$r(t,e.offsetSkins,r,"skins");let n=new DataView(t,e.offsetSkins,r),i=[];for(let o=0;o<e.numSkins;o+=1)i.push({name:Va(n,o*64,64)});return i}function n0(t,e){let r=e.numTexCoords*4;$r(t,e.offsetTexCoords,r,"texcoords");let n=new DataView(t,e.offsetTexCoords,r),i=[];for(let o=0;o<e.numTexCoords;o+=1){let s=o*4;i.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return i}function i0(t,e){let r=e.numTriangles*12;$r(t,e.offsetTriangles,r,"triangles");let n=new DataView(t,e.offsetTriangles,r),i=[];for(let o=0;o<e.numTriangles;o+=1){let s=o*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],c=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=e.numVertices)||c.some(l=>l>=e.numTexCoords))throw new le("Triangle references out of range vertex or texcoord");i.push({vertexIndices:a,texCoordIndices:c})}return i}function o0(t,e){let r=e.numFrames*e.frameSize;$r(t,e.offsetFrames,r,"frames");let n=[];for(let i=0;i<e.numFrames;i+=1){let o=e.offsetFrames+i*e.frameSize,s=new DataView(t,o,e.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},c={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=Va(s,24,16),d=[],u=1/0,f=1/0,h=1/0,m=-1/0,y=-1/0,p=-1/0;for(let g=0;g<e.numVertices;g+=1){let _=40+g*4,x=s.getUint8(_)*a.x+c.x,v=s.getUint8(_+1)*a.y+c.y,b=s.getUint8(_+2)*a.z+c.z;x<u&&(u=x),v<f&&(f=v),b<h&&(h=b),x>m&&(m=x),v>y&&(y=v),b>p&&(p=b);let A={x,y:v,z:b},M=s.getUint8(_+3),w=e0[M];if(!w)throw new le(`Invalid normal index ${M} in frame ${l}`);d.push({position:A,normalIndex:M,normal:w})}n.push({name:l,vertices:d,minBounds:{x:u,y:f,z:h},maxBounds:{x:m,y,z:p}})}return n}function s0(t,e){let r=e.numGlCommands*4;if($r(t,e.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(t,e.offsetGlCommands,r),i=[],o=0;for(;;){if(o+4>r)throw new le("GL command list ended unexpectedly");let s=n.getInt32(o,!0);if(o+=4,s===0)break;let a=Math.abs(s),c=[],l=a*12;if(o+l>r)throw new le("GL command vertex block exceeds buffer");for(let d=0;d<a;d+=1){let u=n.getFloat32(o,!0),f=n.getFloat32(o+4,!0),h=n.getInt32(o+8,!0);if(o+=12,h<0||h>=e.numVertices)throw new le("GL command references invalid vertex index");c.push({s:u,t:f,vertexIndex:h})}i.push({mode:s>0?"strip":"fan",vertices:c})}if(o!==r)throw new le("GL command list did not consume expected data");return i}function ls(t){let e=t0(t),r=r0(t,e),n=n0(t,e),i=i0(t,e),o=o0(t,e),s=s0(t,e);return{header:e,skins:r,texCoords:n,triangles:i,frames:o,glCommands:s}}function Ga(t){let e=[],r=0;for(;r<t.length;){let n=t[r].name,i=n.replace(/\d+$/,"")||n,o=r;for(;o+1<t.length&&(t[o+1].name.replace(/\d+$/,"")||t[o+1].name)===i;)o+=1;e.push({name:i,firstFrame:r,lastFrame:o}),r=o+1}return e}var Wa=860898377,a0=15,Fe=class extends Error{constructor(e){super(e),this.name="Md3ParseError"}};function jr(t,e,r){let n=new Uint8Array(t.buffer,t.byteOffset+e,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function c0(t){let e=(t>>8&255)*(2*Math.PI/255),r=(t&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(e)*n,y:Math.sin(e)*n,z:Math.cos(r)}}function vi(t,e,r,n){if(e<0||e+r>n)throw new Fe(`${t} exceeds buffer bounds`)}function l0(t){let e=t.getInt32(0,!0);if(e!==Wa)throw new Fe(`Invalid MD3 ident: ${e}`);let r=t.getInt32(4,!0);if(r!==a0)throw new Fe(`Unsupported MD3 version: ${r}`);let n=jr(t,8,64),i=t.getInt32(72,!0),o=t.getInt32(76,!0),s=t.getInt32(80,!0),a=t.getInt32(84,!0),c=t.getInt32(88,!0),l=t.getInt32(92,!0),d=t.getInt32(96,!0),u=t.getInt32(100,!0),f=t.getInt32(104,!0);if(o<=0||a<0||s<0)throw new Fe("Invalid MD3 counts");return{ident:e,version:r,name:n,flags:i,numFrames:o,numTags:s,numSurfaces:a,numSkins:c,ofsFrames:l,ofsTags:d,ofsSurfaces:u,ofsEnd:f,magic:e}}function d0(t,e){let r=[];vi("Frames",e.ofsFrames,e.numFrames*56,t.byteLength);for(let i=0;i<e.numFrames;i+=1){let o=e.ofsFrames+i*56;r.push({minBounds:{x:t.getFloat32(o,!0),y:t.getFloat32(o+4,!0),z:t.getFloat32(o+8,!0)},maxBounds:{x:t.getFloat32(o+12,!0),y:t.getFloat32(o+16,!0),z:t.getFloat32(o+20,!0)},localOrigin:{x:t.getFloat32(o+24,!0),y:t.getFloat32(o+28,!0),z:t.getFloat32(o+32,!0)},radius:t.getFloat32(o+36,!0),name:jr(t,o+40,16)})}return r}function u0(t,e){let r=[],i=e.numFrames*e.numTags*112;vi("Tags",e.ofsTags,i,t.byteLength);for(let o=0;o<e.numFrames;o+=1){let s=[];for(let a=0;a<e.numTags;a+=1){let c=e.ofsTags+(o*e.numTags+a)*112,l=c+64,d=l+12;s.push({name:jr(t,c,64),origin:{x:t.getFloat32(l,!0),y:t.getFloat32(l+4,!0),z:t.getFloat32(l+8,!0)},axis:[{x:t.getFloat32(d,!0),y:t.getFloat32(d+4,!0),z:t.getFloat32(d+8,!0)},{x:t.getFloat32(d+12,!0),y:t.getFloat32(d+16,!0),z:t.getFloat32(d+20,!0)},{x:t.getFloat32(d+24,!0),y:t.getFloat32(d+28,!0),z:t.getFloat32(d+32,!0)}]})}r.push(s)}return r}function f0(t,e){let r=t.getInt32(e,!0);if(r!==Wa)throw new Fe(`Invalid surface ident at ${e}: ${r}`);let n=jr(t,e+4,64),i=t.getInt32(e+68,!0),o=t.getInt32(e+72,!0),s=t.getInt32(e+76,!0),a=t.getInt32(e+80,!0),c=t.getInt32(e+84,!0),l=t.getInt32(e+88,!0),d=t.getInt32(e+92,!0),u=t.getInt32(e+96,!0),f=t.getInt32(e+100,!0),h=t.getInt32(e+104,!0);if(o<=0||a<=0||c<=0)throw new Fe(`Invalid surface counts for ${n}`);let m=h;vi(`Surface ${n}`,e,m,t.byteLength);let y=[],p=e+l;for(let M=0;M<c;M+=1){let w=p+M*12;y.push({indices:[t.getInt32(w,!0),t.getInt32(w+4,!0),t.getInt32(w+8,!0)]})}let g=[],_=e+d;for(let M=0;M<s;M+=1){let w=_+M*68;g.push({name:jr(t,w,64),shaderIndex:t.getInt32(w+64,!0)})}let x=[],v=e+u;for(let M=0;M<a;M+=1){let w=v+M*8;x.push({s:t.getFloat32(w,!0),t:t.getFloat32(w+4,!0)})}let b=[],A=e+f;for(let M=0;M<o;M+=1){let w=[];for(let E=0;E<a;E+=1){let L=A+(M*a+E)*8,O=t.getInt16(L,!0)/64,N=t.getInt16(L+2,!0)/64,H=t.getInt16(L+4,!0)/64,C=t.getUint16(L+6,!0);w.push({position:{x:O,y:N,z:H},latLng:C,normal:c0(C)})}b.push(w)}return{surface:{name:n,flags:i,numFrames:o,shaders:g,triangles:y,texCoords:x,vertices:b},nextOffset:e+h}}function ds(t){if(t.byteLength<108)throw new Fe("MD3 buffer too small for header");let e=new DataView(t),r=l0(e);vi("MD3 end",r.ofsEnd,0,t.byteLength);let n=d0(e,r),i=u0(e,r),o=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:c,nextOffset:l}=f0(e,s);o.push(c),s=l}if(s!==r.ofsEnd)throw new Fe("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:i,surfaces:o}}var mr=class{constructor(e){this.vfs=e;this.cache=new Map}async load(e){if(this.cache.has(e))return this.cache.get(e);let r=await this.vfs.readFile(e),n=ds(r.slice().buffer);return this.cache.set(e,n),n}get(e){return this.cache.get(e)}};var h0=844317769,m0=2,Xa=64,Ka=12,yt=class extends Error{};function p0(t,e,r){let n=[];for(let i=0;i<r;i+=1){let o=t.getUint8(e+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function us(t){if(t.byteLength<Ka)throw new yt("Sprite buffer too small to contain header");let e=new DataView(t),r=e.getInt32(0,!0),n=e.getInt32(4,!0),i=e.getInt32(8,!0);if(r!==h0)throw new yt(`Invalid Sprite ident: ${r}`);if(n!==m0)throw new yt(`Unsupported Sprite version: ${n}`);let o=[],s=16+Xa,a=Ka;for(let c=0;c<i;c+=1){if(a+s>t.byteLength)throw new yt("Sprite frame data exceeds buffer length");let l=e.getInt32(a,!0),d=e.getInt32(a+4,!0),u=e.getInt32(a+8,!0),f=e.getInt32(a+12,!0),h=p0(e,a+16,Xa);o.push({width:l,height:d,originX:u,originY:f,name:h}),a+=s}return{ident:r,version:n,numFrames:i,frames:o}}var pr=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),us(n.buffer)}};function Ya(t,e){let r=(t.sequence.end-t.sequence.start+1)/t.sequence.fps,n=t.sequence.loop!==!1,i=t.time+e;return n?i=(i%r+r)%r:i>r&&(i=r),{...t,time:Math.max(0,Math.min(i,r))}}function qa(t){let e=t.sequence.end-t.sequence.start+1,r=1/t.sequence.fps,n=t.sequence.loop!==!1,i=t.time/r;if(!n&&i>=e)return{frame0:t.sequence.end,frame1:t.sequence.end,lerp:0};let o=n?i%e:Math.min(i,e-1),s=Math.floor(o),a=t.sequence.start+s,c=s+1>=e?n?t.sequence.start:t.sequence.end:a+1,l=!n&&s>=e-1?0:o-s;return{frame0:a,frame1:c,lerp:l}}function $a(t){return{sequence:t,time:0}}function ja(t,e,r){return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r,z:t.z+(e.z-t.z)*r}}var Jr=class extends Error{constructor(e){super(e),this.name="WalParseError"}};function _i(t){if(t.byteLength<100)throw new Jr("WAL buffer too small");let e=new DataView(t),r=new Uint8Array(t,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),i=e.getInt32(32,!0),o=e.getInt32(36,!0),s=[e.getInt32(40,!0),e.getInt32(44,!0),e.getInt32(48,!0),e.getInt32(52,!0)],a=new Uint8Array(t,56,32),c=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=e.getInt32(88,!0),d=e.getInt32(92,!0),u=e.getInt32(96,!0);if(i<=0||o<=0)throw new Jr("Invalid WAL dimensions");let f=[],h=i,m=o;for(let y=0;y<s.length;y+=1){let p=s[y],g=Math.max(1,h*m|0);if(p<=0||p+g>t.byteLength)throw new Jr(`Invalid WAL mip offset for level ${y}`);let _=new Uint8Array(t,p,g);f.push({level:y,width:h,height:m,data:_}),h=Math.max(1,h>>1),m=Math.max(1,m>>1)}return{name:n,width:i,height:o,mipmaps:f,animName:c,flags:l,contents:d,value:u}}var Nt=class extends Error{constructor(e){super(e),this.name="PcxParseError"}};function Qr(t){if(t.byteLength<128)throw new Nt("PCX buffer too small for header");let e=new DataView(t),r=e.getUint8(0),n=e.getUint8(2),i=e.getUint8(3),o=e.getUint16(4,!0),s=e.getUint16(6,!0),a=e.getUint16(8,!0),c=e.getUint16(10,!0);if(r!==10||n!==1)throw new Nt("Unsupported PCX encoding");if(i!==8)throw new Nt("Only 8bpp PCX files are supported");let l=a-o+1,d=c-s+1,u=e.getUint16(66,!0),f=t.byteLength-769;if(f<128||new DataView(t,f,1).getUint8(0)!==12)throw new Nt("Missing PCX palette");let h=new Uint8Array(t,f+1,768),m=new Uint8Array(t,128,f-128),y=new Uint8Array(l*d),p=0,g=0;for(let _=0;_<d;_+=1){let x=0;for(;x<u&&p<m.length;){let v=1,b=m[p++];if((b&192)===192){if(v=b&63,p>=m.length)throw new Nt("Unexpected end of PCX RLE data");b=m[p++]}for(let A=0;A<v&&x<u;A+=1)x<l&&(y[g++]=b),x+=1}}return{width:l,height:d,bitsPerPixel:i,pixels:y,palette:h}}function Si(t){let e=new Uint8Array(t.width*t.height*4);for(let r=0;r<t.pixels.length;r+=1){let n=t.pixels[r],i=n*3,o=r*4;e[o]=t.palette[i],e[o+1]=t.palette[i+1],e[o+2]=t.palette[i+2],e[o+3]=n===255?0:255}return e}var et=class extends Error{constructor(e){super(e),this.name="TgaParseError"}};function fs(t){let e=new DataView(t);if(t.byteLength<18)throw new et("Buffer too small for TGA header");let r=e.getUint8(0),n=e.getUint8(1),i=e.getUint8(2),o=e.getUint16(12,!0),s=e.getUint16(14,!0),a=e.getUint8(16),c=e.getUint8(17);if(i!==2&&i!==10&&i!==3&&i!==11)throw new et(`Unsupported TGA image type: ${i} (only RGB/Grayscale supported)`);if(a!==24&&a!==32&&a!==8)throw new et(`Unsupported pixel depth: ${a} (only 8, 24, 32 bpp supported)`);let l=i>=9,d=i===3||i===11,u=a/8,f=18+r;if(n===1){let x=e.getUint16(5,!0),v=e.getUint8(7);f+=x*(v/8)}let h=o*s,m=new Uint8Array(h*4),y=(c&32)!==0,p=0,g=new Uint8Array(t),_=x=>{if(d){let v=g[f++];m[x]=v,m[x+1]=v,m[x+2]=v,m[x+3]=255}else{let v=g[f++],b=g[f++],A=g[f++],M=a===32?g[f++]:255;m[x]=A,m[x+1]=b,m[x+2]=v,m[x+3]=M}};if(l){let x=0;for(;x<h;){if(f>=t.byteLength)throw new et("Unexpected end of TGA RLE data");let v=g[f++],b=(v&127)+1,A=(v&128)!==0;if(x+b>h)throw new et("TGA RLE packet exceeds image bounds");if(A){let M=d?g[f]:g[f+2],w=d?g[f]:g[f+1],E=g[f],L=d?255:a===32?g[f+3]:255;f+=u;for(let O=0;O<b;O++){let N=(x+O)*4;m[N]=M,m[N+1]=w,m[N+2]=E,m[N+3]=L}}else for(let M=0;M<b;M++)_((x+M)*4);x+=b}}else for(let x=0;x<h;x++){if(f>=t.byteLength)throw new et("Unexpected end of TGA data");_(x*4)}if(!y){let x=o*4,v=new Uint8Array(x);for(let b=0;b<s/2;b++){let A=b*x,M=(s-1-b)*x;v.set(m.subarray(A,A+x)),m.set(m.subarray(M,M+x),A),m.set(v,M)}}return{width:o,height:s,bitsPerPixel:32,pixels:m}}var yr=class{constructor(e={}){this.cache=new pt(e.capacity??128)}get size(){return this.cache.size}get(e){return this.cache.get(e.toLowerCase())}set(e,r){this.cache.set(e.toLowerCase(),r)}clear(){this.cache.clear()}};function hs(t,e){let r=[];for(let n of t.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,c=o*4;i[c]=e[a],i[c+1]=e[a+1],i[c+2]=e[a+2],i[c+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:i})}return{width:t.width,height:t.height,levels:r,source:"wal"}}function Ai(t){let e=Si(t),r={level:0,width:t.width,height:t.height,rgba:e};return{width:t.width,height:t.height,levels:[r],source:"pcx"}}function Ja(t){let e={level:0,width:t.width,height:t.height,rgba:t.pixels};return{width:t.width,height:t.height,levels:[e],source:"tga"}}function Mi(t,e){return hs(_i(t),e)}var kt=class extends Error{constructor(e){super(e),this.name="WavParseError"}};function ms(t,e,r){return new TextDecoder("ascii").decode(new Uint8Array(t.buffer,t.byteOffset+e,r))}function wi(t){if(t.byteLength<44)throw new kt("WAV buffer too small");let e=new DataView(t);if(ms(e,0,4)!=="RIFF"||ms(e,8,4)!=="WAVE")throw new kt("Invalid WAV header");let r=12,n=-1,i=-1,o=0,s=0;for(;r+8<=t.byteLength;){let m=ms(e,r,4),y=e.getUint32(r+4,!0),p=r+8;m==="fmt "?(n=p,o=y):m==="data"&&(i=p,s=y),r=p+y}if(n===-1||i===-1)throw new kt("Missing fmt or data chunk");let a=e.getUint16(n,!0),c=e.getUint16(n+2,!0),l=e.getUint32(n+4,!0),d=e.getUint16(n+14,!0);if(a!==1)throw new kt("Only PCM WAV is supported");let u=d/8,f=s/(u*c),h=new Float32Array(f*c);for(let m=0;m<f;m+=1)for(let y=0;y<c;y+=1){let p=m*c+y,g=i+p*u,_=0;if(d===8)_=e.getUint8(g),h[p]=(_-128)/128;else if(d===16)_=e.getInt16(g,!0),h[p]=_/32768;else if(d===24){let x=e.getUint8(g),v=e.getUint8(g+1),b=e.getInt8(g+2);_=x|v<<8|b<<16,h[p]=_/8388608}else throw new kt(`Unsupported bitsPerSample: ${d}`)}return{sampleRate:l,channels:c,bitsPerSample:d,samples:h}}var y0=(t,e=4294967295,r=79764919)=>{let n=new Int32Array(256),i,o,s,a=e;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<t.length;i++)a=a<<8^n[255&(a>>24^t[i])];return a};var ps=(t,e=y0)=>{let r=p=>new Uint8Array(p.length/2).map(((g,_)=>parseInt(p.substring(2*_,2*(_+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,g)=>i.set(p,g)));let o=new Uint8Array(t.length),s,a,c,l=!1,d=0,u=42,f=t.length>13&&t.substring(0,9)==="dynEncode",h=0;f&&(h=11,a=n(t.substring(9,h)),a<=1&&(h+=2,u=n(t.substring(11,h))),a===1&&(h+=8,c=(p=>new DataView(r(p).buffer).getInt32(0,!0))(t.substring(13,h))));let m=256-u;for(let p=h;p<t.length;p++)if(s=t.charCodeAt(p),s!==61||l){if(s===92&&p<t.length-5&&f){let g=t.charCodeAt(p+1);g!==117&&g!==85||(s=parseInt(t.substring(p+2,p+6),16),p+=5)}if(s>255){let g=i.get(s);g&&(s=g+127)}l&&(l=!1,s-=64),o[d++]=s<u&&s>0?s+m:s-u}else l=!0;let y=o.subarray(0,d);if(f&&a===1){let p=e(y);if(p!==c){let g="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",g+`
|
|
2
|
-
`,"Expected: "+
|
|
3
|
-
`,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(g)}}return y};function Z(){let t=Uint8Array,e=Float32Array;Z.modules||Object.defineProperties(Z,{modules:{value:new WeakMap},setModule:{value(r,n){Z.modules.set(r,Promise.resolve(n))}},getModule:{value(r,n){let i=Z.modules.get(r);return i||(n?i=WebAssembly.compile(ps(n)):(n=r.wasm,i=Z.inflateDynEncodeString(n).then(o=>WebAssembly.compile(o))),Z.modules.set(r,i)),i}},concatFloat32:{value(r,n){let i=new e(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 c=[],l,d;for(l=0;l<i;l++){let u=[];for(d=0;d<n.length;)u.push(n[d++][l]||[]);c.push(Z.concatFloat32(u,o))}return Z.getDecodedAudio(r,c,o,s,a)}},inflateDynEncodeString:{value(r){return r=ps(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*4U((I-H(H*i0J,^*DH+H-H*I+H,I*4)33H(H*H)^*DH(H+H)^*@H+i§H)i§3æ*).§K(iHI/+§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,hi73H,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ô7H,c)(i)H+i´8W)(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,hi73H-i)J+V)&+I,H(H+V)æ,8(I.H(H*8*J-i(p51H-i)J+i¸7V)(H(H+iø7V)(8(J/H(P*0J+s,hi73H+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(i2J,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*4J1J.U(*H.U((J2i')o5/H.U()I.H,H(^*<H0H1U((H.i0J.i§i0i')o5/H/H.H2J*H(J.q50H,P*0J/H*I-H,P*(J0,hH,P*,H-q,hi)I-423+hH*m5+H/H0H(H1U((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-iEr5)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¨1I/+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+H0H1I2i(I-+hH-H2p,hH,H,iP8*J*i(p5-H*i7u,hH,i-H-i)H*c)(H-i)I-4*3i(I/i+I.i+I(*h*h*hH*i86*(*)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,hiI*4,3H,iø-H,i¸)H,i-H18)J(,hi¡I*H(i(p5,H1H,V)ú-H,V)ø-o5,3H,i(H,iXH,i-H1i)H08)J(,hi I*H(i(p5,H0H,V)H,V)o5,3H,H,iPH,iH8+I*4+3(3(3H,i$6i¬78+I*3H*H3m5(3i)I-H*i(r5)3H)H,P*0^*(H+H,P*<^*(H*I-3H,i2L(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*S7US0U `;Z.getModule(Z,i).then(o=>WebAssembly.instantiate(o,{})).then(({exports:o})=>{let s=new Map(Object.entries(o)),a=s.get("puff"),c=s.get("memory").buffer,l=new t(c),d=new DataView(c),u=s.get("__heap_base"),f=r.length,h=u;u+=4,d.setInt32(h,f,!0);let m=u;u+=f,l.set(r,m);let y=u;u+=4,d.setInt32(y,l.byteLength-u,!0),a(u,y,m,h),n(l.slice(u,u+d.getInt32(y,!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&&Z.setModule(r,n),this._wasm=new r(Z).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var ec=Tl(Za(),1);var g0=()=>globalThis.Worker||ec.default,gr=class extends g0(){constructor(e,r,n,i){Z.modules||new Z;let o=Z.modules.get(n);if(!o){let s="text/javascript",a,c=`'use strict';(${((l,d,u)=>{let f,h,m=new Promise(y=>{h=y});self.onmessage=({data:{id:y,command:p,data:g}})=>{let _=m,x={id:y},v;p==="init"?(Object.defineProperties(l,{WASMAudioDecoderCommon:{value:d},EmscriptenWASM:{value:u},module:{value:g.module},isWebWorker:{value:!0}}),f=new l(g.options),h()):p==="free"?f.free():p==="ready"?_=_.then(()=>f.ready):p==="reset"?_=_.then(()=>f.reset()):(Object.assign(x,f[p](Array.isArray(g)?g.map(b=>new Uint8Array(b)):new Uint8Array(g))),v=x.channelData?x.channelData.map(b=>b.buffer):[]),_.then(()=>self.postMessage(x,v))}}).toString()})(${n}, ${Z}, ${i})`;try{a=typeof process.versions.node<"u"}catch{}o=a?`data:${s};base64,${Buffer.from(c).toString("base64")}`:URL.createObjectURL(new Blob([c],{type:s})),Z.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,...c}=s;this._enqueuedOperations.get(a)(c),this._enqueuedOperations.delete(a)},new i(Z).getModule().then(s=>{this.postToDecoder("init",{module:s,options:e})})}async postToDecoder(e,r){return new Promise(n=>{this.postMessage({command:e,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 Li=(t,e)=>{Object.defineProperty(t,"name",{value:e})};var ee=Symbol,tc=", ",P=(()=>{let t="front",e="side",r="rear",n="left",i="center",o="right";return["",t+" ",e+" ",r+" "].map(s=>[[n,o],[n,o,i],[n,i,o],[i,n,o],[i]].flatMap(a=>a.map(c=>s+c).join(tc)))})(),Ye="LFE",gt="monophonic (mono)",xt="stereo",Zr="surround",te=(t,...e)=>`${[gt,xt,`linear ${Zr}`,"quadraphonic",`5.0 ${Zr}`,`5.1 ${Zr}`,`6.1 ${Zr}`,`7.1 ${Zr}`][t-1]} (${e.join(tc)})`,en=[gt,te(2,P[0][0]),te(3,P[0][2]),te(4,P[1][0],P[3][0]),te(5,P[1][2],P[3][0]),te(6,P[1][2],P[3][0],Ye),te(7,P[1][2],P[2][0],P[3][4],Ye),te(8,P[1][2],P[2][0],P[3][0],Ye)],rc=192e3,nc=176400,Ei=96e3,Ti=88200,ic=64e3,bt=48e3,xr=44100,br=32e3,vr=24e3,_r=22050,Sr=16e3,Ii=12e3,Ci=11025,Ar=8e3,oc=7350,Ve="absoluteGranulePosition",k="bandwidth",he="bitDepth",me="bitrate",tn=me+"Maximum",rn=me+"Minimum",nn=me+"Nominal",qe="buffer",on=qe+"Fullness",J="codec",pe=J+"Frames",sn="coupledStreamCount",Mr="crc",an=Mr+"16",cn=Mr+"32",$="data",F="description",$e="duration",wr="emphasis",ln="hasOpusPadding",Le="header",vt="isContinuedPacket",dn="isCopyrighted",_t="isFirstPage",un="isHome",Ee="isLastPage",tt="isOriginal",rt="isPrivate",fn="isVbr",Ae="layer",S="length",D="mode",nt=D+"Extension",Ri="mpeg",it=Ri+"Version",hn="numberAACFrames",mn="outputGain",Ut="preSkip",pn="profile",zi=ee(),ot="protection",ys="rawData",Pe="segments",U="subarray",St="version",Ht="vorbis",yn=Ht+"Comments",Lr=Ht+"Setup",Fi="block",gn=Fi+"ingStrategy",Pi=ee(),st=Fi+"Size",At=Fi+"size0",Mt=Fi+"size1",xn=ee(),Bi="channel",at=Bi+"MappingFamily",bn=Bi+"MappingTable",ye=Bi+"Mode",vn=ee(),z=Bi+"s",sc="copyright",_n=sc+"Id",Sn=sc+"IdStart",ct="frame",lt=ct+"Count",Me=ct+"Length",Oi="Number",dt=ct+Oi,je=ct+"Padding",B=ct+"Size",ac="Rate",An="inputSample"+ac,gs="page",Vt=gs+"Checksum",Er=ee(),wt=gs+"SegmentTable",oe=gs+"Sequence"+Oi,xs="sample",Mn=xs+Oi,V=xs+ac,Je=ee(),G=xs+"s",Di="stream",wn=Di+"Count",Ln=Di+"Info",Qe=Di+"Serial"+Oi,bs=Di+"StructureVersion",vs="total",Gt=vs+"BytesOut",Wt=vs+"Duration",Xt=vs+"Samples",W=ee(),Be=ee(),En=ee(),Lt=ee(),Ge=ee(),Ni=ee(),_s=ee(),Et=ee(),X=ee(),Oe=ee(),De=ee(),Ze=ee(),Tt=ee(),ki=ee(),We=ee(),Xe=ee(),Ne=ee(),Ui=ee(),ge=Uint8Array,It=DataView,K="reserved",xe="bad",Tr="free",Tn="none",Hi="16bit CRC";var Ss=(t,e,r)=>{for(let n=0;n<t[S];n++){let i=e(n);for(let o=8;o>0;o--)i=r(i);t[n]=i}return t},b0=Ss(new ge(256),t=>t,t=>t&128?7^t<<1:t<<1),re=[Ss(new Uint16Array(256),t=>t<<8,t=>t<<1^(t&32768?32773:0))],ne=[Ss(new Uint32Array(256),t=>t,t=>t>>>1^(t&1)*3988292384)];for(let t=0;t<15;t++){re.push(new Uint16Array(256)),ne.push(new Uint32Array(256));for(let e=0;e<=255;e++)re[t+1][e]=re[0][re[t][e]>>>8]^re[t][e]<<8,ne[t+1][e]=ne[t][e]>>>8^ne[0][ne[t][e]&255]}var lc=t=>{let e=0,r=t[S];for(let n=0;n!==r;n++)e=b0[e^t[n]];return e},dc=t=>{let e=t[S],r=e-16,n=0,i=0;for(;i<=r;)n^=t[i++]<<8|t[i++],n=re[15][n>>8]^re[14][n&255]^re[13][t[i++]]^re[12][t[i++]]^re[11][t[i++]]^re[10][t[i++]]^re[9][t[i++]]^re[8][t[i++]]^re[7][t[i++]]^re[6][t[i++]]^re[5][t[i++]]^re[4][t[i++]]^re[3][t[i++]]^re[2][t[i++]]^re[1][t[i++]]^re[0][t[i++]];for(;i!==e;)n=(n&255)<<8^re[0][n>>8^t[i++]];return n},uc=t=>{let e=t[S],r=e-16,n=0,i=0;for(;i<=r;)n=ne[15][(t[i++]^n)&255]^ne[14][(t[i++]^n>>>8)&255]^ne[13][(t[i++]^n>>>16)&255]^ne[12][t[i++]^n>>>24]^ne[11][t[i++]]^ne[10][t[i++]]^ne[9][t[i++]]^ne[8][t[i++]]^ne[7][t[i++]]^ne[6][t[i++]]^ne[5][t[i++]]^ne[4][t[i++]]^ne[3][t[i++]]^ne[2][t[i++]]^ne[1][t[i++]]^ne[0][t[i++]];for(;i!==e;)n=ne[0][(n^t[i++])&255]^n>>>8;return n^-1},Cn=(...t)=>{let e=new ge(t.reduce((r,n)=>r+n[S],0));return t.reduce((r,n)=>(e.set(n,r),r+n[S]),0),e},Te=t=>String.fromCharCode(...t),cc=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],In=t=>cc[t&15]<<4|cc[t>>4],Vi=class{constructor(e){this._data=e,this._pos=e[S]*8}set position(e){this._pos=e}get position(){return this._pos}read(e){let r=Math.floor(this._pos/8),n=this._pos%8;return this._pos-=e,(In(this._data[r-1])<<8)+In(this._data[r])>>7-n&255}},fc=(t,e)=>{try{return t.getBigInt64(e,!0)}catch{let r=t.getUint8(e+7)&128?-1:1,n=t.getUint32(e,!0),i=t.getUint32(e+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 Rn=class{constructor(e,r){this._onCodecHeader=e,this._onCodecUpdate=r,this[We]()}[Xe](){this._isEnabled=!0}[We](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[ki](e,r){if(this._onCodecUpdate){this._bitrate!==e&&(this._bitrate=e,this._codecShouldUpdate=!0);let n=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&n&&this._onCodecUpdate({bitrate:e,...n},r),this._codecShouldUpdate=!1}}[X](e){let r=this._headerCache.get(e);return r&&this._updateCurrentHeader(e),r}[Oe](e,r,n){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...r}),this._codecHeaderSent=!0),this._updateCurrentHeader(e),this._headerCache.set(e,r),this._codecUpdateData.set(r,n))}_updateCurrentHeader(e){this._onCodecUpdate&&e!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=e)}};var ce=new WeakMap,de=new WeakMap;var be=class{constructor(e,r){this._codecParser=e,this._headerCache=r}*[_s](){let e;do{if(e=yield*this.Frame[De](this._codecParser,this._headerCache,0),e)return e;this._codecParser[Be](1)}while(!0)}*[Et](e){let r=yield*this[_s](),n=de.get(r)[S];if(e||this._codecParser._flushing||(yield*this.Header[X](this._codecParser,this._headerCache,n)))return this._headerCache[Xe](),this._codecParser[Be](n),this._codecParser[Lt](r),r;this._codecParser[Ge](`Missing ${ct} at ${n} bytes from current position.`,`Dropping current ${ct} and trying again.`),this._headerCache[We](),this._codecParser[Be](1)}};var Kt=class{constructor(e,r){de.set(this,{[Le]:e}),this[$]=r}};var Ie=class extends Kt{static*[De](e,r,n,i,o){let s=yield*e[X](n,i,o);if(s){let a=ce.get(s)[Me],c=ce.get(s)[G],l=(yield*n[W](a,o))[U](0,a);return new r(s,l,c)}else return null}constructor(e,r,n){super(e,r),this[Le]=e,this[G]=n,this[$e]=n/e[V]*1e3,this[dt]=null,this[Gt]=null,this[Xt]=null,this[Wt]=null,de.get(this)[S]=r[S]}};var As="unsynchronizationFlag",Ms="extendedHeaderFlag",ws="experimentalFlag",Ls="footerPresent",zn=class t{static*getID3v2Header(e,r,n){let o={},s=yield*e[W](3,n);if(s[0]!==73||s[1]!==68||s[2]!==51||(s=yield*e[W](10,n),o[St]=`id3v2.${s[3]}.${s[4]}`,s[5]&15)||(o[As]=!!(s[5]&128),o[Ms]=!!(s[5]&64),o[ws]=!!(s[5]&32),o[Ls]=!!(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[S]=10+a,new t(o)}constructor(e){this[St]=e[St],this[As]=e[As],this[Ms]=e[Ms],this[ws]=e[ws],this[Ls]=e[Ls],this[S]=e[S]}};var Ce=class{constructor(e){ce.set(this,e),this[he]=e[he],this[me]=null,this[z]=e[z],this[ye]=e[ye],this[V]=e[V]}};var gc={0:[Tr,Tr,Tr,Tr,Tr],16:[32,32,32,32,8],240:[xe,xe,xe,xe,xe]},Gi=(t,e,r)=>8*((t+r)%e+e)*(1<<(t+r)/e)-8*e*(e/8|0);for(let t=2;t<15;t++)gc[t<<4]=[t*32,Gi(t,4,0),Gi(t,4,-1),Gi(t,8,4),Gi(t,8,0)];var v0=0,_0=1,S0=2,A0=3,hc=4,Wi="bands ",Xi=" to 31",mc={0:Wi+4+Xi,16:Wi+8+Xi,32:Wi+12+Xi,48:Wi+16+Xi},Yt="bitrateIndex",Fn="v2",ji="v1",Ki="Intensity stereo ",Yi=", MS stereo ",qi="on",$i="off",M0={0:Ki+$i+Yi+$i,16:Ki+qi+Yi+$i,32:Ki+$i+Yi+qi,48:Ki+qi+Yi+qi},Es={0:{[F]:K},2:{[F]:"Layer III",[je]:1,[nt]:M0,[ji]:{[Yt]:S0,[G]:1152},[Fn]:{[Yt]:hc,[G]:576}},4:{[F]:"Layer II",[je]:1,[nt]:mc,[G]:1152,[ji]:{[Yt]:_0},[Fn]:{[Yt]:hc}},6:{[F]:"Layer I",[je]:4,[nt]:mc,[G]:384,[ji]:{[Yt]:v0},[Fn]:{[Yt]:A0}}},Ts="MPEG Version ",pc="ISO/IEC ",w0={0:{[F]:`${Ts}2.5 (later extension of MPEG 2)`,[Ae]:Fn,[V]:{0:Ci,4:Ii,8:Ar,12:K}},8:{[F]:K},16:{[F]:`${Ts}2 (${pc}13818-3)`,[Ae]:Fn,[V]:{0:_r,4:vr,8:Sr,12:K}},24:{[F]:`${Ts}1 (${pc}11172-3)`,[Ae]:ji,[V]:{0:xr,4:bt,8:br,12:K}},length:S},L0={0:Hi,1:Tn},E0={0:Tn,1:"50/15 ms",2:K,3:"CCIT J.17"},yc={0:{[z]:2,[F]:xt},64:{[z]:2,[F]:"joint "+xt},128:{[z]:2,[F]:"dual channel"},192:{[z]:1,[F]:gt}},qt=class t extends Ce{static*[X](e,r,n){let i={},o=yield*zn.getID3v2Header(e,r,n);o&&(yield*e[W](o[S],n),e[Be](o[S]));let s=yield*e[W](4,n),a=Te(s[U](0,4)),c=r[X](a);if(c)return new t(c);if(s[0]!==255||s[1]<224)return null;let l=w0[s[1]&24];if(l[F]===K)return null;let d=s[1]&6;if(Es[d][F]===K)return null;let u={...Es[d],...Es[d][l[Ae]]};if(i[it]=l[F],i[Ae]=u[F],i[G]=u[G],i[ot]=L0[s[1]&1],i[S]=4,i[me]=gc[s[2]&240][u[Yt]],i[me]===xe||(i[V]=l[V][s[2]&12],i[V]===K)||(i[je]=s[2]&2&&u[je],i[rt]=!!(s[2]&1),i[Me]=Math.floor(125*i[me]*i[G]/i[V]+i[je]),!i[Me]))return null;let f=s[3]&192;if(i[ye]=yc[f][F],i[z]=yc[f][z],i[nt]=u[nt][s[3]&48],i[dn]=!!(s[3]&8),i[tt]=!!(s[3]&4),i[wr]=E0[s[3]&3],i[wr]===K)return null;i[he]=16;{let{length:h,frameLength:m,samples:y,...p}=i;r[Oe](a,i,p)}return new t(i)}constructor(e){super(e),this[me]=e[me],this[wr]=e[wr],this[je]=e[je],this[dn]=e[dn],this[tt]=e[tt],this[rt]=e[rt],this[Ae]=e[Ae],this[nt]=e[nt],this[it]=e[it],this[ot]=e[ot]}};var Pn=class t extends Ie{static*[De](e,r,n){return yield*super[De](qt,t,e,r,n)}constructor(e,r,n){super(e,r,n)}};var Bn=class extends be{constructor(e,r,n){super(e,r),this.Frame=Pn,this.Header=qt,n(this[J])}get[J](){return Ri}*[Ze](){return yield*this[Et]()}};var T0={0:"MPEG-4",8:"MPEG-2"},I0={0:"valid",2:xe,4:xe,6:xe},C0={0:Hi,1:Tn},R0={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},z0={0:Ei,4:Ti,8:ic,12:bt,16:xr,20:br,24:vr,28:_r,32:Sr,36:Ii,40:Ci,44:Ar,48:oc,52:K,56:K,60:"frequency is written explicitly"},xc={0:{[z]:0,[F]:"Defined in AOT Specific Config"},64:{[z]:1,[F]:gt},128:{[z]:2,[F]:te(2,P[0][0])},192:{[z]:3,[F]:te(3,P[1][3])},256:{[z]:4,[F]:te(4,P[1][3],P[3][4])},320:{[z]:5,[F]:te(5,P[1][3],P[3][0])},384:{[z]:6,[F]:te(6,P[1][3],P[3][0],Ye)},448:{[z]:8,[F]:te(8,P[1][3],P[2][0],P[3][0],Ye)}},$t=class t extends Ce{static*[X](e,r,n){let i={},o=yield*e[W](7,n),s=Te([o[0],o[1],o[2],o[3]&252|o[6]&3]),a=r[X](s);if(a)Object.assign(i,a);else{if(o[0]!==255||o[1]<240||(i[it]=T0[o[1]&8],i[Ae]=I0[o[1]&6],i[Ae]===xe))return null;let l=o[1]&1;i[ot]=C0[l],i[S]=l?7:9,i[zi]=o[2]&192,i[Je]=o[2]&60;let d=o[2]&2;if(i[pn]=R0[i[zi]],i[V]=z0[i[Je]],i[V]===K)return null;i[rt]=!!d,i[vn]=(o[2]<<8|o[3])&448,i[ye]=xc[i[vn]][F],i[z]=xc[i[vn]][z],i[tt]=!!(o[3]&32),i[un]=!!(o[3]&8),i[_n]=!!(o[3]&8),i[Sn]=!!(o[3]&4),i[he]=16,i[G]=1024,i[hn]=o[6]&3;{let{length:u,channelModeBits:f,profileBits:h,sampleRateBits:m,frameLength:y,samples:p,numberAACFrames:g,..._}=i;r[Oe](s,i,_)}}if(i[Me]=(o[3]<<11|o[4]<<3|o[5]>>5)&8191,!i[Me])return null;let c=(o[5]<<6|o[6]>>2)&2047;return i[on]=c===2047?"VBR":c,new t(i)}constructor(e){super(e),this[_n]=e[_n],this[Sn]=e[Sn],this[on]=e[on],this[un]=e[un],this[tt]=e[tt],this[rt]=e[rt],this[Ae]=e[Ae],this[S]=e[S],this[it]=e[it],this[hn]=e[hn],this[pn]=e[pn],this[ot]=e[ot]}get audioSpecificConfig(){let e=ce.get(this),r=e[zi]+64<<5|e[Je]<<5|e[vn]>>3,n=new ge(2);return new It(n[qe]).setUint16(0,r,!1),n}};var On=class t extends Ie{static*[De](e,r,n){return yield*super[De]($t,t,e,r,n)}constructor(e,r,n){super(e,r,n)}};var Dn=class extends be{constructor(e,r,n){super(e,r),this.Frame=On,this.Header=$t,n(this[J])}get[J](){return"aac"}*[Ze](){return yield*this[Et]()}};var Ct=class t extends Ie{static _getFrameFooterCrc16(e){return(e[e[S]-2]<<8)+e[e[S]-1]}static[Ui](e){let r=t._getFrameFooterCrc16(e),n=dc(e[U](0,-2));return r===n}constructor(e,r,n){r[Ln]=n,r[an]=t._getFrameFooterCrc16(e),super(r,e,ce.get(r)[G])}};var bc="get from STREAMINFO metadata block",F0={0:"Fixed",1:"Variable"},vc={0:K,16:192};for(let t=2;t<16;t++)vc[t<<4]=t<6?576*2**(t-2):2**t;var P0={0:bc,1:Ti,2:nc,3:rc,4:Ar,5:Sr,6:_r,7:vr,8:br,9:xr,10:bt,11:Ei,15:xe},B0={0:{[z]:1,[F]:gt},16:{[z]:2,[F]:te(2,P[0][0])},32:{[z]:3,[F]:te(3,P[0][1])},48:{[z]:4,[F]:te(4,P[1][0],P[3][0])},64:{[z]:5,[F]:te(5,P[1][1],P[3][0])},80:{[z]:6,[F]:te(6,P[1][1],Ye,P[3][0])},96:{[z]:7,[F]:te(7,P[1][1],Ye,P[3][4],P[2][0])},112:{[z]:8,[F]:te(8,P[1][1],Ye,P[3][0],P[2][0])},128:{[z]:2,[F]:`${xt} (left, diff)`},144:{[z]:2,[F]:`${xt} (diff, right)`},160:{[z]:2,[F]:`${xt} (avg, diff)`},176:K,192:K,208:K,224:K,240:K},O0={0:bc,2:8,4:12,6:K,8:16,10:20,12:24,14:K},Rt=class t extends Ce{static _decodeUTF8Int(e){if(e[0]>254)return null;if(e[0]<128)return{value:e[0],length:1};let r=1;for(let s=64;s&e[0];s>>=1)r++;let n=r-1,i=0,o=0;for(;n>0;o+=6,n--){if((e[n]&192)!==128)return null;i|=(e[n]&63)<<o}return i|=(e[n]&127>>r)<<o,{value:i,length:r}}static[Ne](e,r){let n={[W]:function*(){return e}};return t[X](n,r,0).next().value}static*[X](e,r,n){let i=yield*e[W](6,n);if(i[0]!==255||!(i[1]===248||i[1]===249))return null;let o={},s=Te(i[U](0,4)),a=r[X](s);if(a)Object.assign(o,a);else{if(o[Pi]=i[1]&1,o[gn]=F0[o[Pi]],o[xn]=i[2]&240,o[Je]=i[2]&15,o[st]=vc[o[xn]],o[st]===K||(o[V]=P0[o[Je]],o[V]===xe)||i[3]&1)return null;let l=B0[i[3]&240];if(l===K||(o[z]=l[z],o[ye]=l[F],o[he]=O0[i[3]&14],o[he]===K))return null}o[S]=5,i=yield*e[W](o[S]+8,n);let c=t._decodeUTF8Int(i[U](4));if(!c||(o[Pi]?o[Mn]=c.value:o[dt]=c.value,o[S]+=c[S],o[xn]===96?(i[S]<o[S]&&(i=yield*e[W](o[S],n)),o[st]=i[o[S]-1]+1,o[S]+=1):o[xn]===112&&(i[S]<o[S]&&(i=yield*e[W](o[S],n)),o[st]=(i[o[S]-1]<<8)+i[o[S]]+1,o[S]+=2),o[G]=o[st],o[Je]===12?(i[S]<o[S]&&(i=yield*e[W](o[S],n)),o[V]=i[o[S]-1]*1e3,o[S]+=1):o[Je]===13?(i[S]<o[S]&&(i=yield*e[W](o[S],n)),o[V]=(i[o[S]-1]<<8)+i[o[S]],o[S]+=2):o[Je]===14&&(i[S]<o[S]&&(i=yield*e[W](o[S],n)),o[V]=((i[o[S]-1]<<8)+i[o[S]])*10,o[S]+=2),i[S]<o[S]&&(i=yield*e[W](o[S],n)),o[Mr]=i[o[S]-1],o[Mr]!==lc(i[U](0,o[S]-1))))return null;if(!a){let{blockingStrategyBits:l,frameNumber:d,sampleNumber:u,samples:f,sampleRateBits:h,blockSizeBits:m,crc:y,length:p,...g}=o;r[Oe](s,o,g)}return new t(o)}constructor(e){super(e),this[an]=null,this[gn]=e[gn],this[st]=e[st],this[dt]=e[dt],this[Mn]=e[Mn],this[Ln]=null}};var D0=2,N0=512*1024,jt=class extends be{constructor(e,r,n){super(e,r),this.Frame=Ct,this.Header=Rt,n(this[J])}get[J](){return"flac"}*_getNextFrameSyncOffset(e){let r=yield*this._codecParser[W](2,0),n=r[S]-2;for(;e<n;){if(r[e]===255){let o=r[e+1];if(o===248||o===249)break;o!==255&&e++}e++}return e}*[Ze](){do{let e=yield*Rt[X](this._codecParser,this._headerCache,0);if(e){let r=ce.get(e)[S]+D0;for(;r<=N0;){if(this._codecParser._flushing||(yield*Rt[X](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[W](r);if(this._codecParser._flushing||(n=n[U](0,r)),Ct[Ui](n)){let i=new Ct(n,e);return this._headerCache[Xe](),this._codecParser[Be](r),this._codecParser[Lt](i),i}}r=yield*this._getNextFrameSyncOffset(r+1)}this._codecParser[Ge](`Unable to sync FLAC frame after searching ${r} bytes.`),this._codecParser[Be](r)}else this._codecParser[Be](yield*this._getNextFrameSyncOffset(1))}while(!0)}[Tt](e){return e[oe]===0?(this._headerCache[Xe](),this._streamInfo=e[$][U](13)):e[oe]===1||(e[pe]=de.get(e)[Pe].map(r=>{let n=Rt[Ne](r,this._headerCache);if(n)return new Ct(r,n,this._streamInfo);this._codecParser[Ge]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(r=>!!r)),e}};var Jt=class t{static*[X](e,r,n){let i={},o=yield*e[W](28,n);if(o[0]!==79||o[1]!==103||o[2]!==103||o[3]!==83||(i[bs]=o[4],o[5]&248))return null;i[Ee]=!!(o[5]&4),i[_t]=!!(o[5]&2),i[vt]=!!(o[5]&1);let a=new It(ge.from(o[U](0,28))[qe]);i[Ve]=fc(a,6),i[Qe]=a.getInt32(14,!0),i[oe]=a.getInt32(18,!0),i[Vt]=a.getInt32(22,!0);let c=o[26];i[S]=c+27,o=yield*e[W](i[S],n),i[Me]=0,i[wt]=[],i[Er]=ge.from(o[U](27,i[S]));for(let l=0,d=0;l<c;l++){let u=i[Er][l];i[Me]+=u,d+=u,(u!==255||l===c-1)&&(i[wt].push(d),d=0)}return new t(i)}constructor(e){ce.set(this,e),this[Ve]=e[Ve],this[vt]=e[vt],this[_t]=e[_t],this[Ee]=e[Ee],this[wt]=e[wt],this[oe]=e[oe],this[Vt]=e[Vt],this[Qe]=e[Qe]}};var Nn=class t extends Kt{static*[De](e,r,n){let i=yield*Jt[X](e,r,n);if(i){let o=ce.get(i)[Me],s=ce.get(i)[S],a=s+o,c=(yield*e[W](a,0))[U](0,a),l=c[U](s,a);return new t(i,l,c)}else return null}constructor(e,r,n){super(e,r),de.get(this)[S]=n[S],this[pe]=[],this[ys]=n,this[Ve]=e[Ve],this[cn]=e[Vt],this[$e]=0,this[vt]=e[vt],this[_t]=e[_t],this[Ee]=e[Ee],this[oe]=e[oe],this[G]=0,this[Qe]=e[Qe]}};var Ir=class extends Ie{constructor(e,r,n){super(r,e,n)}};var _c={0:en.slice(0,2),1:en},ke="SILK-only",ue="CELT-only",Ji="Hybrid",zt="narrowband",Qi="medium-band",Ft="wideband",Cr="super-wideband",Rr="fullband",k0={0:{[D]:ke,[k]:zt,[B]:10},8:{[D]:ke,[k]:zt,[B]:20},16:{[D]:ke,[k]:zt,[B]:40},24:{[D]:ke,[k]:zt,[B]:60},32:{[D]:ke,[k]:Qi,[B]:10},40:{[D]:ke,[k]:Qi,[B]:20},48:{[D]:ke,[k]:Qi,[B]:40},56:{[D]:ke,[k]:Qi,[B]:60},64:{[D]:ke,[k]:Ft,[B]:10},72:{[D]:ke,[k]:Ft,[B]:20},80:{[D]:ke,[k]:Ft,[B]:40},88:{[D]:ke,[k]:Ft,[B]:60},96:{[D]:Ji,[k]:Cr,[B]:10},104:{[D]:Ji,[k]:Cr,[B]:20},112:{[D]:Ji,[k]:Rr,[B]:10},120:{[D]:Ji,[k]:Rr,[B]:20},128:{[D]:ue,[k]:zt,[B]:2.5},136:{[D]:ue,[k]:zt,[B]:5},144:{[D]:ue,[k]:zt,[B]:10},152:{[D]:ue,[k]:zt,[B]:20},160:{[D]:ue,[k]:Ft,[B]:2.5},168:{[D]:ue,[k]:Ft,[B]:5},176:{[D]:ue,[k]:Ft,[B]:10},184:{[D]:ue,[k]:Ft,[B]:20},192:{[D]:ue,[k]:Cr,[B]:2.5},200:{[D]:ue,[k]:Cr,[B]:5},208:{[D]:ue,[k]:Cr,[B]:10},216:{[D]:ue,[k]:Cr,[B]:20},224:{[D]:ue,[k]:Rr,[B]:2.5},232:{[D]:ue,[k]:Rr,[B]:5},240:{[D]:ue,[k]:Rr,[B]:10},248:{[D]:ue,[k]:Rr,[B]:20}},zr=class t extends Ce{static[Ne](e,r,n){let i={};if(i[z]=e[9],i[at]=e[18],i[S]=i[at]!==0?21+i[z]:19,e[S]<i[S])throw new Error("Out of data while inside an Ogg Page");let o=r[0]&3,s=o===3?2:1,a=Te(e[U](0,i[S]))+Te(r[U](0,s)),c=n[X](a);if(c)return new t(c);if(a.substr(0,8)!=="OpusHead"||e[8]!==1)return null;i[$]=ge.from(e[U](0,i[S]));let l=new It(i[$][qe]);if(i[he]=16,i[Ut]=l.getUint16(10,!0),i[An]=l.getUint32(12,!0),i[V]=bt,i[mn]=l.getInt16(16,!0),i[at]in _c&&(i[ye]=_c[i[at]][i[z]-1],!i[ye]))return null;i[at]!==0&&(i[wn]=e[19],i[sn]=e[20],i[bn]=[...e[U](21,i[z]+21)]);let d=k0[248&r[0]];switch(i[D]=d[D],i[k]=d[k],i[B]=d[B],o){case 0:i[lt]=1;break;case 1:case 2:i[lt]=2;break;case 3:i[fn]=!!(128&r[1]),i[ln]=!!(64&r[1]),i[lt]=63&r[1];break;default:return null}{let{length:u,data:f,channelMappingFamily:h,...m}=i;n[Oe](a,i,m)}return new t(i)}constructor(e){super(e),this[$]=e[$],this[k]=e[k],this[at]=e[at],this[bn]=e[bn],this[sn]=e[sn],this[lt]=e[lt],this[B]=e[B],this[ln]=e[ln],this[An]=e[An],this[fn]=e[fn],this[D]=e[D],this[mn]=e[mn],this[Ut]=e[Ut],this[wn]=e[wn]}};var kn=class extends be{constructor(e,r,n){super(e,r),this.Frame=Ir,this.Header=zr,n(this[J]),this._identificationHeader=null,this._preSkipRemaining=null}get[J](){return"opus"}[Tt](e){return e[oe]===0?(this._headerCache[Xe](),this._identificationHeader=e[$]):e[oe]===1||(e[pe]=de.get(e)[Pe].map(r=>{let n=zr[Ne](this._identificationHeader,r,this._headerCache);if(n){this._preSkipRemaining===null&&(this._preSkipRemaining=n[Ut]);let i=n[B]*n[lt]/1e3*n[V];return this._preSkipRemaining>0&&(this._preSkipRemaining-=i,i=this._preSkipRemaining<0?-this._preSkipRemaining:0),new Ir(r,n,i)}this._codecParser[Ni]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),e}};var Fr=class extends Ie{constructor(e,r,n){super(r,e,n)}};var Is={};for(let t=0;t<8;t++)Is[t+6]=2**(6+t);var Un=class t extends Ce{static[Ne](e,r,n,i){if(e[S]<30)throw new Error("Out of data while inside an Ogg Page");let o=Te(e[U](0,30)),s=r[X](o);if(s)return new t(s);let a={[S]:30};if(o.substr(0,7)!=="vorbis")return null;a[$]=ge.from(e[U](0,30));let c=new It(a[$][qe]);if(a[St]=c.getUint32(7,!0),a[St]!==0||(a[z]=e[11],a[ye]=en[a[z]-1]||"application defined",a[V]=c.getUint32(12,!0),a[tn]=c.getInt32(16,!0),a[nn]=c.getInt32(20,!0),a[rn]=c.getInt32(24,!0),a[Mt]=Is[(e[28]&240)>>4],a[At]=Is[e[28]&15],a[At]>a[Mt])||e[29]!==1)return null;a[he]=32,a[Lr]=i,a[yn]=n;{let{length:l,data:d,version:u,vorbisSetup:f,vorbisComments:h,...m}=a;r[Oe](o,a,m)}return new t(a)}constructor(e){super(e),this[tn]=e[tn],this[rn]=e[rn],this[nn]=e[nn],this[At]=e[At],this[Mt]=e[Mt],this[$]=e[$],this[yn]=e[yn],this[Lr]=e[Lr]}};var Hn=class extends be{constructor(e,r,n){super(e,r),this.Frame=Fr,n(this[J]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[J](){return Ht}[Tt](e){e[pe]=[];for(let r of de.get(e)[Pe])if(r[0]===1)this._headerCache[Xe](),this._identificationHeader=e[$],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=Un[Ne](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);n?e[pe].push(new Fr(r,n,this._getSamples(r,n))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return e}_getSamples(e,r){let i=this._mode.blockFlags[e[0]>>1&this._mode.mask]?r[Mt]:r[At],o=this._prevBlockSize===null?0:(this._prevBlockSize+i)/4;return this._prevBlockSize=i,o}_parseSetupHeader(e){let r=new Vi(e),n={count:0,blockFlags:[]};for(;(r.read(1)&1)!==1;);let i;for(;n.count<64&&r.position>0;){In(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{((In(i)&126)>>1)+1!==n.count&&this._codecParser[Ge]("vorbis derived mode count did not match actual mode count");break}}return n.mask=(1<<Math.log2(n.count))-1,n}};var Cs=class{constructor(e,r,n){this._codecParser=e,this._headerCache=r,this._onCodec=n,this._continuedPacket=new ge,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[J](){return this._codec||""}_updateCodec(e,r){this._codec!==e&&(this._headerCache[We](),this._parser=new r(this._codecParser,this._headerCache,this._onCodec),this._codec=e)}_checkCodecSupport({data:e}){let r=Te(e[U](0,8));switch(r){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",kn),!0;case(/^\x7fFLAC/.test(r)&&r):return this._updateCodec("flac",jt),!0;case(/^\x01vorbis/.test(r)&&r):return this._updateCodec(Ht,Hn),!0;default:return!1}}_checkPageSequenceNumber(e){e[oe]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&e[oe]>1&&this._codecParser[Ge]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${e[oe]}`),this._pageSequenceNumber=e[oe]}_parsePage(e){this._isSupported===null&&(this._pageSequenceNumber=e[oe],this._isSupported=this._checkCodecSupport(e)),this._checkPageSequenceNumber(e);let r=de.get(e),n=ce.get(r[Le]),i=0;if(r[Pe]=n[wt].map(o=>e[$][U](i,i+=o)),this._continuedPacket[S]&&(r[Pe][0]=Cn(this._continuedPacket,r[Pe][0]),this._continuedPacket=new ge),n[Er][n[Er][S]-1]===255&&(this._continuedPacket=Cn(this._continuedPacket,r[Pe].pop())),this._previousAbsoluteGranulePosition!==null&&(e[G]=Number(e[Ve]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=e[Ve],this._isSupported){let o=this._parser[Tt](e);return this._codecParser[Lt](o),o}else return e}},Vn=class extends be{constructor(e,r,n){super(e,r),this._onCodec=n,this.Frame=Nn,this.Header=Jt,this._streams=new Map,this._currentSerialNumber=null}get[J](){let e=this._streams.get(this._currentSerialNumber);return e?e.codec:""}*[Ze](){let e=yield*this[Et](!0);this._currentSerialNumber=e[Qe];let r=this._streams.get(this._currentSerialNumber);return r||(r=new Cs(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),e[Ee]&&this._streams.delete(this._currentSerialNumber),r._parsePage(e)}};var Rs=()=>{},Gn=class{constructor(e,{onCodec:r,onCodecHeader:n,onCodecUpdate:i,enableLogging:o=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=e,this._onCodec=r||Rs,this._onCodecHeader=n||Rs,this._onCodecUpdate=i,this._enableLogging=o,this._crc32=s?uc:Rs,this[We]()}get[J](){return this._parser?this._parser[J]:""}[We](){this._headerCache=new Rn(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let e=this._generator.next();e.value;e=this._generator.next())yield e.value;this._flushing=!1,this[We]()}*parseChunk(e){for(let r=this._generator.next(e);r.value;r=this._generator.next())yield r.value}parseAll(e){return[...this.parseChunk(e),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new Dn(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new Bn(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new jt(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new Vn(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 e=yield*this._parser[Ze]();e&&(yield e)}}*[W](e=0,r=0){let n;for(;this._rawData[S]<=e+r;){if(n=yield,this._flushing)return this._rawData[U](r);n&&(this._totalBytesIn+=n[S],this._rawData=Cn(this._rawData,n))}return this._rawData[U](r)}[Be](e){this._currentReadPosition+=e,this._rawData=this._rawData[U](e)}[En](e){this._sampleRate=e[Le][V],e[Le][me]=e[$e]>0?Math.round(e[$][S]/e[$e])*8:0,e[dt]=this._frameNumber++,e[Gt]=this._totalBytesOut,e[Xt]=this._totalSamples,e[Wt]=this._totalSamples/this._sampleRate*1e3,e[cn]=this._crc32(e[$]),this._headerCache[ki](e[Le][me],e[Wt]),this._totalBytesOut+=e[$][S],this._totalSamples+=e[G]}[Lt](e){if(e[pe]){if(e[Ee]){let r=e[G];e[pe].forEach(n=>{let i=n[G];r<i&&(n[G]=r>0?r:0,n[$e]=n[G]/n[Le][V]*1e3),r-=i,this[En](n)})}else e[G]=0,e[pe].forEach(r=>{e[G]+=r[G],this[En](r)});e[$e]=e[G]/this._sampleRate*1e3||0,e[Xt]=this._totalSamples,e[Wt]=this._totalSamples/this._sampleRate*1e3||0,e[Gt]=this._totalBytesOut}else this[En](e)}_log(e,r){if(this._enableLogging){let n=[`${J}: ${this[J]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${Gt}: ${this._totalBytesOut}`],i=Math.max(...n.map(o=>o[S]));r.push(`--stats--${"-".repeat(i-9)}`,...n,"-".repeat(i)),e("codec-parser",r.reduce((o,s)=>o+`
|
|
4
|
-
`+s,""))}}[
|
|
1
|
+
"use strict";var Quake2Engine=(()=>{var ku=Object.create;var mo=Object.defineProperty;var Fu=Object.getOwnPropertyDescriptor;var Du=Object.getOwnPropertyNames;var Pu=Object.getPrototypeOf,Ou=Object.prototype.hasOwnProperty;var Bu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),da=(e,t)=>{for(var r in t)mo(e,r,{get:t[r],enumerable:!0})},cc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Du(t))!Ou.call(e,i)&&i!==r&&mo(e,i,{get:()=>t[i],enumerable:!(n=Fu(t,i))||n.enumerable});return e};var Nu=(e,t,r)=>(r=e!=null?ku(Pu(e)):{},cc(t||!e||!e.__esModule?mo(r,"default",{value:e,enumerable:!0}):r,e)),Uu=e=>cc(mo({},"__esModule",{value:!0}),e);var Xc=Bu((C_,Wc)=>{"use strict";Wc.exports=Worker});var sx={};da(sx,{ATTN_IDLE:()=>Sd,ATTN_LOOP_NONE:()=>bd,ATTN_NONE:()=>us,ATTN_NORM:()=>vd,ATTN_STATIC:()=>wd,AssetDependencyError:()=>Sr,AssetDependencyTracker:()=>Fi,AssetManager:()=>cs,AudioApi:()=>Hr,AudioContextController:()=>hs,AudioRegistry:()=>fn,AudioRegistryError:()=>zi,AudioSystem:()=>bs,BSP_SURFACE_FRAGMENT_SOURCE:()=>ol,BSP_SURFACE_VERTEX_SOURCE:()=>il,BSP_VERTEX_LAYOUT:()=>tl,BspLoader:()=>Gr,BspParseError:()=>j,BspSurfacePipeline:()=>As,Camera:()=>Is,Command:()=>Rn,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:()=>ja,MD2_FRAGMENT_SHADER:()=>fl,MD2_VERTEX_SHADER:()=>ul,MD3_FRAGMENT_SHADER:()=>vl,MD3_VERTEX_SHADER:()=>bl,Md2Loader:()=>Wr,Md2MeshBuffers:()=>Es,Md2ParseError:()=>me,Md2Pipeline:()=>Ls,Md3Loader:()=>Xr,Md3ModelMesh:()=>Rs,Md3ParseError:()=>Ve,Md3Pipeline:()=>zs,Md3SurfaceMesh:()=>Oi,MusicSystem:()=>vs,NetworkMessageParser:()=>Fr,PARTICLE_FRAGMENT_SHADER:()=>wl,PARTICLE_VERTEX_SHADER:()=>Sl,PakArchive:()=>Vr,PakIndexStore:()=>ls,PakIngestionError:()=>Ct,PakParseError:()=>He,PakValidationError:()=>sr,PakValidator:()=>So,ParticleRenderer:()=>ks,ParticleSystem:()=>Cs,PlaybackState:()=>ca,RERELEASE_KNOWN_PAKS:()=>Sa,SKYBOX_FRAGMENT_SHADER:()=>cl,SKYBOX_VERTEX_SHADER:()=>ll,SOUND_FULLVOLUME:()=>hn,SOUND_LOOP_ATTENUATE:()=>Ad,ShaderProgram:()=>Me,SkyboxPipeline:()=>Ms,SoundChannel:()=>ds,SoundPrecache:()=>gs,SoundRegistry:()=>ps,SpriteLoader:()=>Kr,SpriteParseError:()=>Ft,Texture2D:()=>mn,TextureCache:()=>$r,TextureCubeMap:()=>pn,TgaParseError:()=>pt,U_ALPHA:()=>Ru,U_ANGLE1:()=>ea,U_ANGLE2:()=>Zs,U_ANGLE3:()=>qs,U_EFFECTS16:()=>so,U_EFFECTS8:()=>no,U_EVENT:()=>Qs,U_FRAME16:()=>ra,U_FRAME8:()=>js,U_MODEL:()=>ta,U_MODEL2:()=>na,U_MODEL3:()=>ia,U_MODEL4:()=>oa,U_OLDORIGIN:()=>sa,U_ORIGIN1:()=>$s,U_ORIGIN2:()=>Ys,U_ORIGIN3:()=>Js,U_REMOVE:()=>tc,U_RENDERFX16:()=>oo,U_RENDERFX8:()=>ro,U_SKIN16:()=>ao,U_SKIN8:()=>io,U_SOLID:()=>la,U_SOUND:()=>aa,VertexArray:()=>ze,VertexBuffer:()=>Ee,VirtualFileSystem:()=>vo,advanceAnimation:()=>Nc,applySurfaceState:()=>Od,attenuationToDistanceMultiplier:()=>wr,boxIntersectsFrustum:()=>Pi,buildBspGeometry:()=>Rd,buildMd2Geometry:()=>hl,buildMd2VertexData:()=>ml,buildMd3SurfaceGeometry:()=>xl,buildMd3VertexData:()=>_l,calculateMaxAudibleDistance:()=>fs,calculatePakChecksum:()=>Lc,computeFrameBlend:()=>Uc,computeSkyScroll:()=>Ud,createAnimationState:()=>Hc,createAudioGraph:()=>ms,createBspSurfaces:()=>Id,createEmptyEntityState:()=>kr,createEmptyProtocolPlayerState:()=>Ks,createEngine:()=>ox,createEngineRuntime:()=>Mc,createFaceLightmap:()=>Ao,createInitialChannels:()=>ys,createProgramFromSources:()=>Td,createWebGLContext:()=>Ed,decodeOgg:()=>as,deriveSurfaceRenderState:()=>al,extractFrustumPlanes:()=>zd,filesToPakSources:()=>wa,findLeafForPoint:()=>nl,gatherVisibleFaces:()=>Dd,groupMd2Animations:()=>Dc,ingestPakFiles:()=>Tc,ingestPaks:()=>wo,interpolateMd3Tag:()=>i0,interpolateVec3:()=>Vc,parseBsp:()=>Aa,parseMd2:()=>Ma,parseMd3:()=>Ea,parsePcx:()=>Nn,parseSprite:()=>La,parseTga:()=>Ta,parseWal:()=>Eo,parseWalTexture:()=>Io,parseWav:()=>Ro,pcxToRgba:()=>Lo,pickChannel:()=>xs,preparePcxTexture:()=>To,removeViewTranslation:()=>Nd,resolveLightStyles:()=>sl,spatializeOrigin:()=>_s,spawnBlood:()=>a0,spawnBulletImpact:()=>o0,spawnExplosion:()=>s0,spawnMuzzleFlash:()=>c0,spawnTeleportFlash:()=>l0,spawnTrail:()=>d0,walToRgba:()=>Ia,wireDropTarget:()=>Ic,wireFileInput:()=>Rc});var Hu=()=>typeof performance<"u"?performance.now():Date.now(),Vu=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??Hu,schedule:r.schedule??Vu}}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)}},Pr=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 Gu=Object.defineProperty,dc=(e,t)=>{for(var r in t)Gu(e,r,{get:t[r],enumerable:!0})},uc={x:0,y:0,z:0};var dx=Math.PI/180;function fc(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function Wu(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function fa(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Xu(e){return fa(e,e)}function ha(e){return Math.sqrt(Xu(e))}function Qe(e){let t=ha(e);return t===0?e:Wu(e,1/t)}var Ku=Math.PI/180,ux=180/Math.PI,Or=Ku;var $u=[[-.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 Yu(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function hc(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 mc(e,t){let r=Yu();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 ma=8,pa=16,Zu=32;var qu=16384;var po=65536,pc=1<<17,ju=1<<18,Qu=1<<19,Ju=1<<20,ef=1<<21,tf=1<<22,rf=1<<23,fx=1<<24,go=1<<25,nf=1<<26,hx=1<<27,mx=1<<28,px=1<<29,yo=1<<30,gx=1<<31;var Cn=0;var gc=4,yc=8,xc=16,_c=32,bc=64;var yx=1<<25,xx=1<<28,_x=1<<29,bx=1<<30,vx=1<<31;var Sx=nt|zt,wx=nt|po|zt|go|yo,Ax=nt|po|zt,Mx=nt|pc|zt|go|yo,Ex=Zu|ma|pa,Lx=nt|pa|ma,of=nt|go|yo|zt|nf,Tx=ju|Qu|Ju|ef|tf|rf,Ix=nt|ma|pa|go|yo,Rx=nt|po|zt,zx=nt|zt,Cx=nt|po|zt|pc,kx=of|qu;var Fx=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 ga=256,ya=8192,bo=2048,xa=512,_a=256,ba=_o*2,va=256,ua=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+ya]="Sounds",e[e.Images=e.Sounds+bo]="Images",e[e.Lights=e.Images+xa]="Lights",e[e.ShadowLights=e.Lights+ga]="ShadowLights",e[e.Items=e.ShadowLights+va]="Items",e[e.PlayerSkins=e.Items+_a]="PlayerSkins",e[e.General=e.PlayerSkins+_o]="General",e[e.WheelWeapons=e.General+ba]="WheelWeapons",e[e.WheelAmmo=e.WheelWeapons+ua]="WheelAmmo",e[e.WheelPowerups=e.WheelAmmo+ua]="WheelPowerups",e[e.CdLoopCount=e.WheelPowerups+ua]="CdLoopCount",e[e.GameStyle=e.CdLoopCount+1]="GameStyle",e[e.MaxConfigStrings=e.GameStyle+1]="MaxConfigStrings",e))(q||{}),vc=q.MaxConfigStrings;function Sc(e){return e>=5&&e<59?zn*(59-e):e>=q.General&&e<q.WheelWeapons?zn*(q.MaxConfigStrings-e):zn}var sf={};dc(sf,{addReplayFrame:()=>df,createReplaySession:()=>cf,deserializeReplay:()=>lf,serializeReplay:()=>af});function af(e){return JSON.stringify(e,null,2)}function lf(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 cf(e,t){return{metadata:{map:e,date:new Date().toISOString(),version:"1.0",seed:t},frames:[]}}function df(e,t,r,n){e.frames.push({serverFrame:r,cmd:t,timestamp:Date.now()-n})}var k=(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))(k||{});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 uf=12,ff=9,Dx=Math.ceil(uf*ff/16),hf=23,mf=2,Px=Math.ceil(hf*mf/16);var pf={};dc(pf,{U_ANGLE1:()=>Sf,U_ANGLE2:()=>wf,U_ANGLE3:()=>Af,U_EFFECTS:()=>Lf,U_EVENT:()=>Rf,U_FRAME:()=>Mf,U_MODEL:()=>yf,U_MODEL2:()=>Cf,U_MODEL3:()=>kf,U_MODEL4:()=>Ff,U_MOREBITS:()=>zf,U_NUMBER:()=>gf,U_ORIGIN1:()=>_f,U_ORIGIN2:()=>bf,U_ORIGIN3:()=>vf,U_REMOVE:()=>Df,U_RENDERFX:()=>Tf,U_SKIN:()=>Ef,U_SOLID:()=>If,U_SOUND:()=>xf});var gf=1,yf=2,xf=4,_f=8,bf=16,vf=32,Sf=64,wf=128,Af=256,Mf=512,Ef=1024,Lf=2048,Tf=4096,If=8192,Rf=16384,zf=32768,Cf=1,kf=2,Ff=4,Df=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=$u[t];e.x=r[0],e.y=r[1],e.z=r[2]}};var wc=(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))(wc||{}),Ox=Object.keys(wc).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 Pf(e){if(e<0||e>=q.MaxConfigStrings)throw new RangeError(`Configstring index ${e} is out of range (0-${q.MaxConfigStrings-1})`)}function Ac(e,t){let r=Sc(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 Pf(t),Ac(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(vc).fill("");for(let[r,n]of this.values.entries())t[r]=n;return t}modelIndex(t){return this.register(t,q.Models,ya,"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,xa,"imageCursor")}lightIndex(t){return this.register(t,q.Lights,ga,"lightCursor")}shadowLightIndex(t){return this.register(t,q.ShadowLights,va,"shadowLightCursor")}itemIndex(t){return this.register(t,q.Items,_a,"itemCursor")}playerSkinIndex(t){return this.register(t,q.PlayerSkins,_o,"playerSkinCursor")}generalIndex(t){return this.register(t,q.General,ba,"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 Ac(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 Mc(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 Of="PACK";function Bf(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 Nf(){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 Uf=Nf();function Ec(e){let t=4294967295;for(let r=0;r<e.length;r+=1){let n=e[r];t=Uf[(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!==Of)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=Bf(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,Ec(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 Lc(e){return Ec(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 Sa=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=Sa){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 Ct=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 Hf(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 Ct("blob",new Error("Unsupported Blob type"))}async function Vf(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 Hf(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 Vf(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 Ct(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 Ct(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 Ct(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 Gf(e){return Array.isArray(e)?e:Array.from(e)}function wa(e){return Gf(e).map(t=>({name:t.name,data:t}))}async function Tc(e,t,r){let n=wa(t);return wo(e,n,r??{})}function Ic(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 Rc(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 Wf="IBSP",Xf=38,Cc=19,Kf=8+Cc*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),Aa(n.buffer)}};function Aa(e){if(e.byteLength<Kf)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!==Wf)throw new j(`Invalid BSP magic ${r}`);let n=t.getInt32(4,!0);if(n!==Xf)throw new j(`Unsupported BSP version ${n}`);let i=new Map;for(let v=0;v<Cc;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=Yf(e,i.get(0)),a=qf(e,i.get(1)),d=jf(e,i.get(2)),l=Qf(e,i.get(4)),c=Jf(e,i.get(5)),h=eh(e,i.get(6)),u=new Uint8Array(e,i.get(7).offset,i.get(7).length),f=ch(h,i.get(7)),m=th(e,i.get(8)),g=rh(e,i.get(11)),p=nh(e,i.get(12)),x=ih(e,i.get(13)),S=oh(e,i.get(14)),_=sh(e,i.get(15)),y=ah(e,i.get(9),i.get(10),m),b=lh(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 C=parseInt(T.substring(1),10);if(isNaN(C)||C<0||C>=x.length)continue;let U=x[C],z=$f(v.origin,v.direction,U.mins,U.maxs);z!==null&&z<L&&(L=z,E={entity:w,model:U,distance:z})}return E}}}function $f(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 Yf(e,t){let r=new TextDecoder().decode(new Uint8Array(e,t.offset,t.length)),n=Zf(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 Zf(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 qf(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 jf(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 Qf(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 Jf(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 eh(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 th(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 rh(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 nh(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 ih(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 oh(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 sh(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 ah(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 lh(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:zc(e,c,n,t),phs:zc(e,h,n,t)})}return{numClusters:n,clusters:s}}function zc(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 ch(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 dh=844121161,uh=8,kc=68,fh=[{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=Ma(n.buffer);return this.cache.set(t,i),i}get(t){return this.cache.get(t)}};function Fc(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<kc||t+r>e.byteLength))throw new me(`${n} section is out of bounds`)}function hh(e){if(e.byteLength<kc)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!==dh)throw new me(`Invalid MD2 ident: ${r}`);if(n!==uh)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 mh(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:Fc(n,o*64,64)});return i}function ph(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 gh(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 yh(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=Fc(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=fh[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 xh(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 Ma(e){let t=hh(e),r=mh(e,t),n=ph(e,t),i=gh(e,t),o=yh(e,t),s=xh(e,t);return{header:t,skins:r,texCoords:n,triangles:i,frames:o,glCommands:s}}function Dc(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 Pc=860898377,_h=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 bh(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 vh(e){let t=e.getInt32(0,!0);if(t!==Pc)throw new Ve(`Invalid MD3 ident: ${t}`);let r=e.getInt32(4,!0);if(r!==_h)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 Sh(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 wh(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 Ah(e,t){let r=e.getInt32(t,!0);if(r!==Pc)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,C=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:C,z:U},latLng:z,normal:bh(z)})}b.push(E)}return{surface:{name:n,flags:i,numFrames:o,shaders:x,triangles:g,texCoords:_,vertices:b},nextOffset:t+f}}function Ea(e){if(e.byteLength<108)throw new Ve("MD3 buffer too small for header");let t=new DataView(e),r=vh(t);Mo("MD3 end",r.ofsEnd,0,e.byteLength);let n=Sh(t,r),i=wh(t,r),o=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:d,nextOffset:l}=Ah(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=Ea(r.slice().buffer);return this.cache.set(t,n),n}get(t){return this.cache.get(t)}};var Mh=844317769,Eh=2,Oc=64,Bc=12,Ft=class extends Error{};function Lh(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 La(e){if(e.byteLength<Bc)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!==Mh)throw new Ft(`Invalid Sprite ident: ${r}`);if(n!==Eh)throw new Ft(`Unsupported Sprite version: ${n}`);let o=[],s=16+Oc,a=Bc;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=Lh(t,a+16,Oc);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),La(n.buffer)}};function Nc(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 Uc(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 Hc(e){return{sequence:e,time:0}}function Vc(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 Ta(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 C=(_+T)*4;m[C]=v,m[C+1]=E,m[C+2]=L,m[C+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 Ia(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 Gc(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 Ia(Eo(e),t)}var lr=class extends Error{constructor(t){super(t),this.name="WavParseError"}};function Ra(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(Ra(t,0,4)!=="RIFF"||Ra(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=Ra(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 Th=(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=Th)=>{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
|
+
`,"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*4U((I-H(H*i0J,^*DH+H-H*I+H,I*4)33H(H*H)^*DH(H+H)^*@H+i§H)i§3æ*).§K(iHI/+§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,hi73H,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ô7H,c)(i)H+i´8W)(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,hi73H-i)J+V)&+I,H(H+V)æ,8(I.H(H*8*J-i(p51H-i)J+i¸7V)(H(H+iø7V)(8(J/H(P*0J+s,hi73H+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(i2J,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*4J1J.U(*H.U((J2i')o5/H.U()I.H,H(^*<H0H1U((H.i0J.i§i0i')o5/H/H.H2J*H(J.q50H,P*0J/H*I-H,P*(J0,hH,P*,H-q,hi)I-423+hH*m5+H/H0H(H1U((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-iEr5)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¨1I/+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+H0H1I2i(I-+hH-H2p,hH,H,iP8*J*i(p5-H*i7u,hH,i-H-i)H*c)(H-i)I-4*3i(I/i+I.i+I(*h*h*hH*i86*(*)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,hiI*4,3H,iø-H,i¸)H,i-H18)J(,hi¡I*H(i(p5,H1H,V)ú-H,V)ø-o5,3H,i(H,iXH,i-H1i)H08)J(,hi I*H(i(p5,H0H,V)H,V)o5,3H,H,iPH,iH8+I*4+3(3(3H,i$6i¬78+I*3H*H3m5(3i)I-H*i(r5)3H)H,P*0^*(H+H,P*<^*(H*I-3H,i2L(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*S7US0U `;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 Kc=Nu(Xc(),1);var Ih=()=>globalThis.Worker||Kc.default,Yr=class extends Ih(){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,$c=", ",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($c)))})(),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($c)})`,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)],Yc=192e3,Zc=176400,Co=96e3,ko=88200,qc=64e3,Ot=48e3,Zr=44100,qr=32e3,jr=24e3,Qr=22050,Jr=16e3,Fo=12e3,Do=11025,en=8e3,jc=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",Yn=tn+"32",Q="data",D="description",st="duration",rn="emphasis",Zn="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",Ca="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(),F=Uo+"s",Qc="copyright",ai=Qc+"Id",li=Qc+"IdStart",wt="frame",At=wt+"Count",Re=wt+"Length",Ho="Number",Mt=wt+Ho,at=wt+"Padding",O=wt+"Size",Jc="Rate",ci="inputSample"+Jc,ka="page",ur=ka+"Checksum",on=re(),Gt=ka+"SegmentTable",le=ka+"Sequence"+Ho,Fa="sample",di=Fa+Ho,G=Fa+Jc,lt=re(),W=Fa+"s",Vo="stream",ui=Vo+"Count",fi=Vo+"Info",ct=Vo+"Serial"+Ho,Da=Vo+"StructureVersion",Pa="total",fr=Pa+"BytesOut",hr=Pa+"Duration",mr=Pa+"Samples",K=re(),We=re(),hi=re(),Wt=re(),et=re(),Go=re(),Oa=re(),Xt=re(),Y=re(),Xe=re(),Ke=re(),dt=re(),Kt=re(),Wo=re(),tt=re(),rt=re(),$e=re(),Xo=re(),Se=Uint8Array,$t=DataView,Z="reserved",we="bad",sn="free",mi="none",Ko="16bit CRC";var Ba=(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},zh=Ba(new Se(256),e=>e,e=>e&128?7^e<<1:e<<1),oe=[Ba(new Uint16Array(256),e=>e<<8,e=>e<<1^(e&32768?32773:0))],se=[Ba(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 td=e=>{let t=0,r=e[M];for(let n=0;n!==r;n++)t=zh[t^e[n]];return t},rd=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},nd=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),ed=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],pi=e=>ed[e&15]<<4|ed[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}},id=(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}}[Y](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}*[Oa](){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[Oa](),n=pe.get(r)[M];if(t||this._codecParser._flushing||(yield*this.Header[Y](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[Y](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 Na="unsynchronizationFlag",Ua="extendedHeaderFlag",Ha="experimentalFlag",Va="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[Na]=!!(s[5]&128),o[Ua]=!!(s[5]&64),o[Ha]=!!(s[5]&32),o[Va]=!!(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[Na]=t[Na],this[Ua]=t[Ua],this[Ha]=t[Ha],this[Va]=t[Va],this[M]=t[M]}};var Oe=class{constructor(t){ue.set(this,t),this[xe]=t[xe],this[_e]=null,this[F]=t[F],this[ve]=t[ve],this[G]=t[G]}};var cd={0:[sn,sn,sn,sn,sn],16:[32,32,32,32,8],240:[we,we,we,we,we]},Yo=(e,t,r)=>8*((e+r)%t+t)*(1<<(e+r)/t)-8*t*(t/8|0);for(let e=2;e<15;e++)cd[e<<4]=[e*32,Yo(e,4,0),Yo(e,4,-1),Yo(e,8,4),Yo(e,8,0)];var Ch=0,kh=1,Fh=2,Dh=3,od=4,Zo="bands ",qo=" to 31",sd={0:Zo+4+qo,16:Zo+8+qo,32:Zo+12+qo,48:Zo+16+qo},gr="bitrateIndex",_i="v2",ts="v1",jo="Intensity stereo ",Qo=", MS stereo ",Jo="on",es="off",Ph={0:jo+es+Qo+es,16:jo+Jo+Qo+es,32:jo+es+Qo+Jo,48:jo+Jo+Qo+Jo},Ga={0:{[D]:Z},2:{[D]:"Layer III",[at]:1,[xt]:Ph,[ts]:{[gr]:Fh,[W]:1152},[_i]:{[gr]:od,[W]:576}},4:{[D]:"Layer II",[at]:1,[xt]:sd,[W]:1152,[ts]:{[gr]:kh},[_i]:{[gr]:od}},6:{[D]:"Layer I",[at]:4,[xt]:sd,[W]:384,[ts]:{[gr]:Ch},[_i]:{[gr]:Dh}}},Wa="MPEG Version ",ad="ISO/IEC ",Oh={0:{[D]:`${Wa}2.5 (later extension of MPEG 2)`,[Ie]:_i,[G]:{0:Do,4:Fo,8:en,12:Z}},8:{[D]:Z},16:{[D]:`${Wa}2 (${ad}13818-3)`,[Ie]:_i,[G]:{0:Qr,4:jr,8:Jr,12:Z}},24:{[D]:`${Wa}1 (${ad}11172-3)`,[Ie]:ts,[G]:{0:Zr,4:Ot,8:qr,12:Z}},length:M},Bh={0:Ko,1:mi},Nh={0:mi,1:"50/15 ms",2:Z,3:"CCIT J.17"},ld={0:{[F]:2,[D]:Pt},64:{[F]:2,[D]:"joint "+Pt},128:{[F]:2,[D]:"dual channel"},192:{[F]:1,[D]:Dt}},yr=class e extends Oe{static*[Y](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[Y](a);if(d)return new e(d);if(s[0]!==255||s[1]<224)return null;let l=Oh[s[1]&24];if(l[D]===Z)return null;let c=s[1]&6;if(Ga[c][D]===Z)return null;let h={...Ga[c],...Ga[c][l[Ie]]};if(i[_t]=l[D],i[Ie]=h[D],i[W]=h[W],i[bt]=Bh[s[1]&1],i[M]=4,i[_e]=cd[s[2]&240][h[gr]],i[_e]===we||(i[G]=l[G][s[2]&12],i[G]===Z)||(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]=ld[u][D],i[F]=ld[u][F],i[xt]=h[xt][s[3]&48],i[qn]=!!(s[3]&8),i[gt]=!!(s[3]&4),i[rn]=Nh[s[3]&3],i[rn]===Z)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 Uh={0:"MPEG-4",8:"MPEG-2"},Hh={0:"valid",2:we,4:we,6:we},Vh={0:Ko,1:mi},Gh={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},Wh={0:Co,4:ko,8:qc,12:Ot,16:Zr,20:qr,24:jr,28:Qr,32:Jr,36:Fo,40:Do,44:en,48:jc,52:Z,56:Z,60:"frequency is written explicitly"},dd={0:{[F]:0,[D]:"Defined in AOT Specific Config"},64:{[F]:1,[D]:Dt},128:{[F]:2,[D]:ie(2,P[0][0])},192:{[F]:3,[D]:ie(3,P[1][3])},256:{[F]:4,[D]:ie(4,P[1][3],P[3][4])},320:{[F]:5,[D]:ie(5,P[1][3],P[3][0])},384:{[F]:6,[D]:ie(6,P[1][3],P[3][0],it)},448:{[F]:8,[D]:ie(8,P[1][3],P[2][0],P[3][0],it)}},xr=class e extends Oe{static*[Y](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[Y](s);if(a)Object.assign(i,a);else{if(o[0]!==255||o[1]<240||(i[_t]=Uh[o[1]&8],i[Ie]=Hh[o[1]&6],i[Ie]===we))return null;let l=o[1]&1;i[bt]=Vh[l],i[M]=l?7:9,i[Oo]=o[2]&192,i[lt]=o[2]&60;let c=o[2]&2;if(i[ti]=Gh[i[Oo]],i[G]=Wh[i[lt]],i[G]===Z)return null;i[yt]=!!c,i[si]=(o[2]<<8|o[3])&448,i[ve]=dd[i[si]][D],i[F]=dd[i[si]][F],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 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 Yt=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=rd(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 ud="get from STREAMINFO metadata block",Xh={0:"Fixed",1:"Variable"},fd={0:Z,16:192};for(let e=2;e<16;e++)fd[e<<4]=e<6?576*2**(e-2):2**e;var Kh={0:ud,1:ko,2:Zc,3:Yc,4:en,5:Jr,6:Qr,7:jr,8:qr,9:Zr,10:Ot,11:Co,15:we},$h={0:{[F]:1,[D]:Dt},16:{[F]:2,[D]:ie(2,P[0][0])},32:{[F]:3,[D]:ie(3,P[0][1])},48:{[F]:4,[D]:ie(4,P[1][0],P[3][0])},64:{[F]:5,[D]:ie(5,P[1][1],P[3][0])},80:{[F]:6,[D]:ie(6,P[1][1],it,P[3][0])},96:{[F]:7,[D]:ie(7,P[1][1],it,P[3][4],P[2][0])},112:{[F]:8,[D]:ie(8,P[1][1],it,P[3][0],P[2][0])},128:{[F]:2,[D]:`${Pt} (left, diff)`},144:{[F]:2,[D]:`${Pt} (diff, right)`},160:{[F]:2,[D]:`${Pt} (avg, diff)`},176:Z,192:Z,208:Z,224:Z,240:Z},Yh={0:ud,2:8,4:12,6:Z,8:16,10:20,12:24,14:Z},Zt=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[Y](n,r,0).next().value}static*[Y](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[Y](s);if(a)Object.assign(o,a);else{if(o[No]=i[1]&1,o[ni]=Xh[o[No]],o[ii]=i[2]&240,o[lt]=i[2]&15,o[vt]=fd[o[ii]],o[vt]===Z||(o[G]=Kh[o[lt]],o[G]===we)||i[3]&1)return null;let l=$h[i[3]&240];if(l===Z||(o[F]=l[F],o[ve]=l[D],o[xe]=Yh[i[3]&14],o[xe]===Z))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]!==td(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 Zh=2,qh=512*1024,_r=class extends Ae{constructor(t,r,n){super(t,r),this.Frame=Yt,this.Header=Zt,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*Zt[Y](this._codecParser,this._headerCache,0);if(t){let r=ue.get(t)[M]+Zh;for(;r<=qh;){if(this._codecParser._flushing||(yield*Zt[Y](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[K](r);if(this._codecParser._flushing||(n=n[H](0,r)),Yt[Xo](n)){let i=new Yt(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=Zt[$e](r,this._headerCache);if(n)return new Yt(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*[Y](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]=id(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[Y](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[Ca]=n,this[Je]=t[Je],this[Yn]=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 hd={0:Hn.slice(0,2),1:Hn},Ye="SILK-only",ge="CELT-only",rs="Hybrid",qt="narrowband",ns="medium-band",jt="wideband",ln="super-wideband",cn="fullband",jh={0:{[B]:Ye,[N]:qt,[O]:10},8:{[B]:Ye,[N]:qt,[O]:20},16:{[B]:Ye,[N]:qt,[O]:40},24:{[B]:Ye,[N]:qt,[O]:60},32:{[B]:Ye,[N]:ns,[O]:10},40:{[B]:Ye,[N]:ns,[O]:20},48:{[B]:Ye,[N]:ns,[O]:40},56:{[B]:Ye,[N]:ns,[O]:60},64:{[B]:Ye,[N]:jt,[O]:10},72:{[B]:Ye,[N]:jt,[O]:20},80:{[B]:Ye,[N]:jt,[O]:40},88:{[B]:Ye,[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[F]=t[9],i[St]=t[18],i[M]=i[St]!==0?21+i[F]: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[Y](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 hd&&(i[ve]=hd[i[St]][i[F]-1],!i[ve]))return null;i[St]!==0&&(i[ui]=t[19],i[Kn]=t[20],i[oi]=[...t[H](21,i[F]+21)]);let c=jh[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[Zn]=!!(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[Zn]=t[Zn],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 Xa={};for(let e=0;e<8;e++)Xa[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[Y](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[F]=t[11],a[ve]=Hn[a[F]-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]=Xa[(t[28]&240)>>4],a[Ht]=Xa[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 Ka=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 Ka(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),t[Fe]&&this._streams.delete(this._currentSerialNumber),r._parsePage(t)}};var $a=()=>{},Ii=class{constructor(t,{onCodec:r,onCodecHeader:n,onCodecUpdate:i,enableLogging:o=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=t,this._onCodec=r||$a,this._onCodecHeader=n||$a,this._onCodecUpdate=i,this._enableLogging=o,this._crc32=s?nd:$a,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[Yn]=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 md=Ii;var is=be;var os=Q;var pd=ke;var gd=Fe;var yd=nn;var xd=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,Dr=0,uo=0,fo=R.length,ho=new Uint8Array((fo*3>>2)-(R[fo-2]=="=")-(R[fo-1]=="="));Dr<fo;Dr+=4,uo+=3)Ue=$[R.charCodeAt(Dr+1)],In=$[R.charCodeAt(Dr+2)],ho[uo]=$[R.charCodeAt(Dr)]<<2|Ue>>4,ho[uo+1]=Ue<<4|In>>2,ho[uo+2]=In<<6|$[R.charCodeAt(Dr+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(()=>lc(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,C=Math.sin,U=R=>{var Ue=a.length;return R>>>=0,!1},z=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:C,k:U,j:z};function co(R){Tn=R.n,rc=R.o,nc=R.p,ic=R.q,oc=R.r,sc=R.s,ac=R.t,lc=R.v}var Tn,rc,nc,ic,oc,sc,ac,lc;function zu(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¹=
|
|
5
5
|
¨¨%ýv²±»oúâLa:ê±ÊäÌÓ.÷Øý×>àW>z¯°8¯ñ\Ñós9\§ôÊ@Ü (tÃø4° ¢7fqÓg²Jè6x[zç®&4=} p.(°tÍÞã¾>÷CõË"*k?¿~7~H2ÛÜâ.ÏQä;6{ÜãFÑá'DD¤±°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ïgN¾)ø§\V0uSIö:ÌU4ж¯´Õn9ÔèE£ZƼ{hµmÙ¾6ÆÑ+xñ´«þ¸=Mߤ·å®«ïÆGFÝì|H?äE"þ!9«Æïpæ'][¯ù·£W÷O§&#ax$qf=}ø ô bÏ×W÷LôoÝWQÕÓ)u÷½èV|¥Gà¨Ö¸@ê|ÇK5ò A·Â9CS2¸¼¿,äÝÑÝy!ÑR%ÆÝÎ0Âv§ qTcó±hØÉã=}Z=}Ælüën¯ð(-°ÜwVÏï.th¥íS~SÏ»ZZÔZ
|
|
6
6
|
3BÌÛ¬<éæ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óäsE\ýïé§Ö:Ò'Cç(_X$\¦½eÒ8$XF|eíÙÓ¡¤Û<ØÞÛ¸9¿ðÃÎ#b~× 4éîÿÏq
|
|
7
7
|
ód|0wU&®è·vh6¨{ÚçÚ18Ó(ÓY\0¦= çèíß)Ø=}[xü-v?N(Kkg0}âÚ´ð¬ÕQNÍ¢usѳ=}. ëg
û= ÍMBp'²¨ x4è@9t§eݵ¾âð½ z?Z¹FH'̯¿<K,üµ<{ ¶JãývåàÆeù0Ð"F¥ÃÒÞþÔÉvCzl}ðN£ Í^P%²¸FX»WÎêô¶
äÉJ^g×SÃã.Ät*'ªG«ÒB<ÜÓ
¿ºp\àuV¯£ÅݽáÞ ùß=}ÎÚ^ÿí>¥!¨ â=M·?*/¤"å)â·ÿîÿî*(%*2[½"üríÔ4l½»a}¯CwpCÓèìGc-ã6®=M32k?Êg
!So-x>³G+ã@ò, ÁïáåN0þÙè.~È÷¡vTr¶Ã[üB±º»ávëw¹{pܺû"Aæ±9Æ^¹³òïRIAy5GÂwÉf4@Tù|qý7ðªwBL|Ôqv!ª°|]KiÐJVQ5¸åõ§å"H¼0e¬<óBîÚSÏUìHPÙA+çÉ'seÌNf°@ÈM,ð½egÖ¬x©û½2~«Ò1;Ö«
¯°4&90èE»Ó׺çʧJ<Æ¿&~Nu¼ãÙµ¢.UÇä(qQô^ö·%!É
|
|
@@ -138,12 +138,13 @@ 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ÑUy¹¦ß§/6P0(Cúýb"þ¥°VÙÄá£ÓÙ@¾YýòD{òÃv?EP©=MBé\ĽYäýRò øfâëEEf¼D+gC×úDZGÅÿ±Ç?TzÙ¡±ÏÁÕ¯¦ðvZmT}3xËz×cºrÑM=Mc-É©Ô7½wæc§Î»cû¾yfÙWòÆÝÔc¥³ôØf«Äñ·9ø%g:y^+{U]¤þ
[&fÓÏYë«Gªõ¹¦Öðþ¬moÛø?/ÛS.[S9ÛùC
/û2²Y£ÎÑ%/sy¢×ÌùJW6Oí\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¶ÌºHgNjÒ{æ¾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 _l={a:Bt};this.setModule=I=>{t.setModule(ut,I)},this.getModule=()=>t.getModule(ut),this.instantiate=()=>(this.getModule().then(I=>WebAssembly.instantiate(I,_l)).then(I=>{let Re=I.exports;oi(Re),m=Re.l,y(),vl(Re),r()}),this.ready=new Promise(I=>{r=I}).then(()=>{this.HEAP=m.buffer,this.malloc=la,this.free=ma,this.create_decoder=Vr,this.send_setup=da,this.init_dsp=ua,this.decode_packets=fa,this.destroy_decoder=ha}),this)}function Qt(){return this._init=()=>new this._WASMAudioDecoderCommon().instantiate(this._EmscriptenWASM,this._module).then(t=>{this._common=t,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 e=256;this._errors=this._common.allocateTypedArray(e,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,e)}),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=t=>{this._input.buf.set(t),this._inputLen.buf[0]=t.length,this._common.wasm.send_setup(this._decoder,this._firstPage),this._firstPage=!1},this.initDsp=()=>{this._common.wasm.init_dsp(this._decoder)},this.decodePackets=t=>{let e=[],r=0,n=[];for(let i=0;i<t.length;i++){let o=t[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=[],c=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 d=new Float32Array(s);s&&d.set(new Float32Array(this._common.wasm.HEAP,c[l],s)),a.push(d)}e.push(a),r+=s,this._frameNumber++,this._inputBytes+=o.length,this._outputSamples+=s;for(let l=0;l<this._errorsLength.buf;l+=2){let d=this._common.codeToString(this._errors.buf[l]),u=this._common.codeToString(this._errors.buf[l+1]);n.push({message:d+" vorbis_synthesis"+u,frameLength:o.length,frameNumber:this._frameNumber,inputBytes:this._inputBytes,outputSamples:this._outputSamples})}this._errorsLength.buf[0]=0}return this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(n,e,this._channels.buf[0],r,this._sampleRate.buf[0],16)},this._isWebWorker=Qt.isWebWorker,this._WASMAudioDecoderCommon=Qt.WASMAudioDecoderCommon||Z,this._EmscriptenWASM=Qt.EmscriptenWASM||ut,this._module=Qt.module,this._inputSize=128*1024,this._ready=this._init(),this}var to=Symbol(),ft=class{constructor(){this._onCodec=e=>{if(e!=="vorbis")throw new Error("@wasm-audio-decoders/ogg-vorbis does not support this codec "+e)},new Z,this._init(),this._ready=this[to](Qt)}_init(){this._vorbisSetupInProgress=!0,this._totalSamplesDecoded=0,this._codecParser=new Sc("audio/ogg",{onCodec:this._onCodec,enableFrameCRC32:!1})}async[to](e){if(this._decoder){let r=this._decoder;await r.ready.then(()=>r.free())}return this._decoder=new e,this._decoder.ready}get ready(){return this._ready}async reset(){return this._init(),this._decoder.reset()}free(){this._decoder.free()}async decodeOggPages(e){let r=[];for(let o=0;o<e.length;o++){let s=e[o];if(this._vorbisSetupInProgress&&(s[eo][0]===1&&this._decoder.sendSetupHeader(s[eo]),s[Zi].length)){let a=s[Zi][0][Ac];this._decoder.sendSetupHeader(a[wc]),this._decoder.initDsp(),this._vorbisSetupInProgress=!1}r.push(...s[Zi].map(a=>a[eo]))}let n=await this._decoder.decodePackets(r);this._totalSamplesDecoded+=n.samplesDecoded;let i=e[e.length-1];if(i&&i[Mc]){let o=this._totalSamplesDecoded-i[Lc];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(e){return this.decodeOggPages([...this._codecParser.parseChunk(e)])}async flush(){let e=await this.decodeOggPages([...this._codecParser.flush()]);return await this.reset(),e}async decodeFile(e){let r=await this.decodeOggPages([...this._codecParser.parseAll(e)]);return await this.reset(),r}};var zs=class extends gr{constructor(e){super(e,"ogg-vorbis-decoder",Qt,ut)}async sendSetupHeader(e){return this.postToDecoder("sendSetupHeader",e)}async initDsp(){return this.postToDecoder("initDsp")}async decodePackets(e){return this.postToDecoder("decodePackets",e)}},Wn=class extends ft{constructor(){super(),this._ready=super[to](zs)}async free(){await this._decoder.free()}terminate(){this._decoder.terminate()}};Li(ft,"OggVorbisDecoder");Li(Wn,"OggVorbisDecoderWebWorker");var Fs=class extends Error{constructor(e){super(e),this.name="OggDecodeError"}};async function ro(t,e=new ft){await e.ready;let r=await e.decode(new Uint8Array(t)),n=r.errors;if(n&&n.length>0)throw new Fs(n.map(i=>i.message).join("; "));return{sampleRate:r.sampleRate,channels:r.channelData.length,bitDepth:r.bitDepth,channelData:r.channelData}}var Xn=class extends Error{constructor(e){super(e),this.name="AudioRegistryError"}},Pr=class{constructor(e,r={}){this.vfs=e;this.refCounts=new Map;this.cache=new pt(r.cacheSize??64)}get size(){return this.cache.size}async load(e){let r=e.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(e)).slice().buffer,s=await this.decodeByExtension(e,o);return this.cache.set(r,s),this.refCounts.set(r,1),s}release(e){let r=e.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(e,r){let n=e.toLowerCase();if(n.endsWith(".wav")){let i=wi(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 ro(r);throw new Xn(`Unsupported audio format: ${e}`)}};var U0="quake2ts-pak-indexes",H0="pak-indexes";function Ec(){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 Kn(t,e){let r=Ec();return r?new Promise((n,i)=>{let o=r.open(t,1);o.onupgradeneeded=()=>{let{result:s}=o;s.objectStoreNames.contains(e)||s.createObjectStore(e,{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 Yn(t,e,r,n){return new Promise((i,o)=>{let a=t.transaction(e,r).objectStore(e),c=n(a);c.onsuccess=()=>i(c.result),c.onerror=()=>o(c.error??new Error("IndexedDB transaction error"))})}function Ps(t,e){return`${ie(t)}:${e.toString(16)}`}function V0(t){return t.map(e=>({...e}))}var no=class{constructor(e=U0,r=H0){this.dbName=e;this.storeName=r}get isSupported(){return!!Ec()}async persist(e){if(!this.isSupported)return;let r=e.validate(),n={...r,key:Ps(e.name,r.checksum),name:e.name,size:e.size,persistedAt:Date.now(),entries:V0(r.entries)},i=await Kn(this.dbName,this.storeName);return await Yn(i,this.storeName,"readwrite",o=>o.put(n)),i.close(),n}async find(e,r){if(!this.isSupported)return;let n=await Kn(this.dbName,this.storeName),i=r!==void 0?Ps(e,r):void 0,o=await Yn(n,this.storeName,"readonly",s=>i?s.get(i):s.getAll());if(n.close(),!!o){if(Array.isArray(o)){let s=ie(e),a=o.filter(c=>ie(c.name)===s);return a.length===0?void 0:a.sort((c,l)=>l.persistedAt-c.persistedAt)[0]}return o}}async remove(e,r){if(!this.isSupported)return!1;let n=await Kn(this.dbName,this.storeName),i=r!==void 0?Ps(e,r):void 0,o=await Yn(n,this.storeName,"readwrite",s=>{if(i)return s.delete(i);let a=`${ie(e)}:`;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 e=await Kn(this.dbName,this.storeName);await Yn(e,this.storeName,"readwrite",r=>r.clear()),e.close()}async list(){if(!this.isSupported)return[];let e=await Kn(this.dbName,this.storeName),r=await Yn(e,this.storeName,"readonly",n=>n.getAll());return e.close(),r.sort((n,i)=>i.persistedAt-n.persistedAt)}};var Zt=class extends Error{constructor(r,n){super(n??`Missing dependencies: ${r.join(", ")}`);this.missing=r;this.name="AssetDependencyError"}},qn=class{constructor(){this.nodes=new Map}register(e,r=[]){let n=this.nodes.get(e)??{dependencies:new Set,loaded:!1};r.forEach(i=>n.dependencies.add(i)),this.nodes.set(e,n),r.forEach(i=>{this.nodes.has(i)||this.nodes.set(i,{dependencies:new Set,loaded:!1})})}markLoaded(e){let r=this.nodes.get(e)??{dependencies:new Set,loaded:!1},n=this.getMissingDependencies(e,r);if(n.length>0)throw new Zt(n,`Asset ${e} is missing dependencies: ${n.join(", ")}`);r.loaded=!0,this.nodes.set(e,r)}markUnloaded(e){let r=this.nodes.get(e);r&&(r.loaded=!1)}isLoaded(e){return this.nodes.get(e)?.loaded??!1}missingDependencies(e){let r=this.nodes.get(e);return r?this.getMissingDependencies(e,r):[]}reset(){this.nodes.clear()}getMissingDependencies(e,r){let n=[];for(let i of r.dependencies)this.nodes.get(i)?.loaded||n.push(i);return n}},io=class{constructor(e,r={}){this.vfs=e;this.maps=new Map;this.textures=new yr({capacity:r.textureCacheCapacity??128}),this.audio=new Pr(e,{cacheSize:r.audioCacheSize??64}),this.dependencyTracker=r.dependencyTracker??new qn,this.md2=new hr(e),this.md3=new mr(e),this.sprite=new pr(e),this.bsp=new fr(e),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(e="pics/colormap.pcx"){try{let r=await this.vfs.readFile(e),n=Qr(r);n.palette&&(this.palette=n.palette)}catch(r){console.warn(`Failed to load palette from ${e}:`,r)}}isAssetLoaded(e,r){return this.dependencyTracker.isLoaded(this.makeKey(e,r))}registerTexture(e,r){this.textures.set(e,r);let n=this.makeKey("texture",e);this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n)}async loadTexture(e){let r=this.textures.get(e);if(r)return r;let n=await this.vfs.readFile(e),i=e.split(".").pop()?.toLowerCase(),o;if(i==="wal")o=Mi(n,this.palette);else if(i==="pcx")o=Ai(Qr(n));else if(i==="tga")o=Ja(fs(n));else throw new Error(`Unsupported texture format for loadTexture: ${i}`);return this.registerTexture(e,o),o}async loadSound(e){let r=await this.audio.load(e),n=this.makeKey("sound",e);return this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n),r}async loadMd2Model(e,r=[]){let n=this.makeKey("model",e),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 Zt(o,`Asset ${n} is missing dependencies: ${o.join(", ")}`);let s=await this.md2.load(e);return this.dependencyTracker.markLoaded(n),s}getMd2Model(e){return this.md2.get(e)}async loadMd3Model(e,r=[]){let n=this.makeKey("model",e),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 Zt(o,`Asset ${n} is missing dependencies: ${o.join(", ")}`);let s=await this.md3.load(e);return this.dependencyTracker.markLoaded(n),s}getMd3Model(e){return this.md3.get(e)}async loadSprite(e){let r=this.makeKey("sprite",e);this.dependencyTracker.register(r);let n=await this.sprite.load(e);return this.dependencyTracker.markLoaded(r),n}async loadMap(e){let r=this.makeKey("map",e);if(this.maps.has(e))return this.maps.get(e);this.dependencyTracker.register(r);let n=await this.bsp.load(e);return this.maps.set(e,n),this.dependencyTracker.markLoaded(r),n}getMap(e){return this.maps.get(e)}listFiles(e){return this.vfs.findByExtension(e)}resetForLevelChange(){this.textures.clear(),this.audio.clearAll(),this.dependencyTracker.reset(),this.maps.clear()}makeKey(e,r){return`${e}:${ie(r)}`}};var Bs=32,oo=(u=>(u[u.Auto=0]="Auto",u[u.Weapon=1]="Weapon",u[u.Voice=2]="Voice",u[u.Item=3]="Item",u[u.Body=4]="Body",u[u.Aux=5]="Aux",u[u.Footstep=6]="Footstep",u[u.Aux3=7]="Aux3",u[u.NoPhsAdd=8]="NoPhsAdd",u[u.Reliable=16]="Reliable",u[u.ForcePos=32]="ForcePos",u))(oo||{}),Tc=-1,so=0,Ic=1,Cc=2,Rc=3,Br=80,zc=.003;function er(t){return t===3?t*.001:t*5e-4}function ao(t){let e=er(t);return e<=0?Number.POSITIVE_INFINITY:80+1/e}var co=class{constructor(e){this.factory=e}getContext(){return this.context||(this.context=this.factory()),this.context}async resume(){let e=this.getContext();e.state==="suspended"&&await e.resume()}getState(){return this.context?.state??"suspended"}};function lo(t){let e=t.getContext(),r=e.createGain();r.gain.value=1;let n=e.createDynamicsCompressor(),i=e.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(e.destination),{context:e,master:r,compressor:n,filter:i}}var uo=class{constructor(e=new lr){this.configStrings=e;this.buffers=new Map}registerName(e){return this.configStrings.soundIndex(e)}register(e,r){let n=this.registerName(e);return this.buffers.set(n,r),n}find(e){return this.configStrings.findSoundIndex(e)}get(e){return this.buffers.get(e)}has(e){return this.buffers.has(e)}getName(e){return this.configStrings.getName(e)}};var fo=class{constructor(e){this.vfs=e.vfs,this.registry=e.registry,this.contextController=e.context,this.soundRoot=e.soundRoot??"sound/",this.decodeAudio=e.decodeAudio??((r,n)=>{if(!r.decodeAudioData)throw new Error("decodeAudioData is not available on the provided audio context");return r.decodeAudioData(n)})}async precache(e){let r=[...new Set(e.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,d=await this.decodeAudio(i,l);this.registry.register(o,d),n.loaded.push(o)}catch(s){let a=s instanceof Error?s:new Error(String(s));n.errors[o]=a}return n}normalize(e){let r=ie(e.replace(/^\//,""));return r.startsWith(this.soundRoot)?r:ie(`${this.soundRoot}${r}`)}};var G0=7,$n=t=>t&G0;function ho(t){return Array.from({length:32},()=>({entnum:0,entchannel:0,endTimeMs:0,isPlayer:!1,active:!1})).map(e=>({...e,isPlayer:e.entnum===t}))}function mo(t,e,r,n){if(r<0)throw new Error("pickChannel: entchannel must be non-negative");let i=$n(r),o=-1,s=Number.POSITIVE_INFINITY;for(let a=0;a<t.length;a+=1){let c=t[a],l=$n(c.entchannel);if(i!==0&&c.entnum===e&&l===i){o=a;break}if(c.active&&c.entnum===n.playerEntity&&e!==n.playerEntity)continue;let d=c.endTimeMs-n.nowMs;(o===-1||d<s)&&(s=d,o=a)}return o===-1?void 0:o}function po(t,e,r,n,i){if(i)return{left:r,right:r,distanceComponent:0};let o=ba(t,e.origin),s=Jo(o),a=He(o),c=s-80;c<0&&(c=0),c*=er(n);let l=jo(e.right,a),d=e.mono??!1,u=d||n===0?1:.5*(1+l),f=d||n===0?1:.5*(1-l),h=Math.max(0,Math.floor(r*(1-c)*u));return{left:Math.max(0,Math.floor(r*(1-c)*f)),right:h,distanceComponent:c}}var yo=class{constructor(e){this.activeSources=new Map;this.contextController=e.context,this.registry=e.registry,this.playerEntity=e.playerEntity,this.channels=ho(e.playerEntity),this.listener=e.listener??{origin:xa,right:{x:1,y:0,z:0}},this.sfxVolume=e.sfxVolume??1,this.masterVolume=e.masterVolume??1,this.resolveOcclusion=e.resolveOcclusion,this.graph=lo(this.contextController),this.graph.master.gain.value=this.masterVolume}setListener(e){this.listener=e}setMasterVolume(e){this.masterVolume=e,this.graph.master.gain.value=e}setSfxVolume(e){this.sfxVolume=e}async ensureRunning(){await this.contextController.resume()}play(e){let r=this.registry.get(e.soundIndex);if(!r)return;let n=this.graph.context,i=n.currentTime*1e3,o=mo(this.channels,e.entity,e.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=e.looping??!1;let c=e.origin??this.listener.origin,l=n.createGain(),d=this.createPanner(n,e.attenuation),u=this.resolveOcclusion?.(this.listener,c,e.attenuation),f=Fc(u?.gainScale??1),h=this.resolveOcclusion?this.createOcclusionFilter(n,u?.lowpassHz??2e4):void 0;this.applyOriginToPanner(d,c);let m=e.entity===this.playerEntity,y=po(c,this.listener,e.volume,e.attenuation,m),g=(e.volume===0?0:Math.max(y.left,y.right)/Math.max(1,e.volume))*(e.volume/255)*this.masterVolume*this.sfxVolume;l.gain.value=g*f;let _=n.currentTime+(e.timeOffsetMs??0)/1e3,x=(e.looping?Number.POSITIVE_INFINITY:r.duration*1e3)+_*1e3;a.connect(d),h?(d.connect(h),h.connect(l)):d.connect(l),l.connect(this.graph.master),a.start(_),a.onended=()=>{this.channels[o].active=!1,this.activeSources.delete(o)};let v={channelIndex:o,entnum:e.entity,entchannel:$n(e.channel),endTimeMs:x,source:a,panner:d,gain:l,baseGain:g,origin:c,attenuation:e.attenuation,occlusion:h?{scale:f,lowpassHz:u?.lowpassHz,filter:h}:u?{scale:f,lowpassHz:u.lowpassHz}:void 0};return this.channels[o]={entnum:e.entity,entchannel:$n(e.channel),endTimeMs:x,isPlayer:e.entity===this.playerEntity,active:!0},this.activeSources.set(o,v),v}stop(e){let r=this.activeSources.get(e);r&&(r.source.stop(),this.channels[e].active=!1,this.activeSources.delete(e))}stopEntitySounds(e){for(let[r,n]of[...this.activeSources.entries()])n.entnum===e&&(n.source.stop(),this.channels[r].active=!1,this.activeSources.delete(r))}updateEntityPosition(e,r){for(let n of this.activeSources.values())if(n.entnum===e&&(this.applyOriginToPanner(n.panner,r),n.origin=r,this.resolveOcclusion)){let i=this.resolveOcclusion(this.listener,r,n.attenuation);this.applyOcclusion(n,i)}}positionedSound(e,r,n,i){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:i,origin:e})}ambientSound(e,r,n){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:0,origin:e,looping:!0})}getChannelState(e){return this.channels[e]}getDiagnostics(){return{activeChannels:this.activeSources.size,masterVolume:this.masterVolume,sfxVolume:this.sfxVolume,channels:[...this.channels],activeSounds:[...this.activeSources.values()].map(e=>({entnum:e.entnum,entchannel:e.entchannel,channelIndex:e.channelIndex,origin:e.origin,gain:e.gain.gain.value,baseGain:e.baseGain,attenuation:e.attenuation,maxDistance:e.panner.maxDistance,distanceModel:e.panner.distanceModel,occlusion:e.occlusion?{scale:e.occlusion.scale,lowpassHz:e.occlusion.lowpassHz}:void 0}))}}setUnderwater(e,r=400){let n=this.graph.filter;n&&(n.type="lowpass",n.Q.value=.707,n.frequency.value=e?r:2e4)}createPanner(e,r){let n=e.createPanner?e.createPanner():Object.assign(e.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(e,r){let n=er(r);return e.refDistance=80,e.maxDistance=ao(r),e.rolloffFactor=n,e.distanceModel=r===0?"linear":"inverse",e.positionX.value=this.listener.origin.x,e.positionY.value=this.listener.origin.y,e.positionZ.value=this.listener.origin.z,e}applyOriginToPanner(e,r){e.positionX.value=r.x,e.positionY.value=r.y,e.positionZ.value=r.z}createOcclusionFilter(e,r){if(!e.createBiquadFilter)return;let n=e.createBiquadFilter();return n.type="lowpass",n.Q.value=.707,n.frequency.value=Os(r,10,2e4),n}applyOcclusion(e,r){let n=Fc(r?.gainScale??1);if(e.gain.gain.value=e.baseGain*n,e.occlusion?.filter){let i=r?.lowpassHz??2e4;e.occlusion.filter.frequency.value=Os(i,10,2e4)}e.occlusion?(e.occlusion.scale=n,e.occlusion.lowpassHz=r?.lowpassHz):r&&(e.occlusion={scale:n,lowpassHz:r.lowpassHz})}},Os=(t,e,r)=>Math.min(r,Math.max(e,t)),Fc=t=>Os(t,0,1);var go=class{constructor(e){this.createElement=e.createElement,this.resolveSource=e.resolveSource??(async r=>r),this.volume=e.volume??1}async play(e,{loop:r=!0,restart:n=!1}={}){if(this.track===e&&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(e),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=e}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(e){this.volume=e,this.element&&(this.element.volume=e)}getState(){let e=!!(this.element&&!this.element.paused&&!this.element.ended),r=!!this.element?.paused;return{track:this.track,paused:r,playing:e,volume:this.volume}}};function W0(t){t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)}function X0(t,e,r,n){for(let i of e){let o=t.getExtension(i);if(!o)throw new Error(`Missing required WebGL extension: ${i}`);n.set(i,o)}for(let i of r){let o=t.getExtension(i);o&&n.set(i,o)}}function Pc(t,e={}){let{contextAttributes:r,requiredExtensions:n=[],optionalExtensions:i=[]}=e,o=t.getContext("webgl2",r??{antialias:!0});if(!o)throw new Error("WebGL2 not supported or failed to initialize");W0(o);let s=new Map;X0(o,n,i,s);let a=!1,c=new Set,l=new Set,d=f=>{a=!0,f.preventDefault();for(let h of c)h()},u=()=>{a=!1;for(let f of l)f()};return t.addEventListener("webglcontextlost",d),t.addEventListener("webglcontextrestored",u),{gl:o,extensions:s,isLost:()=>a,onLost(f){return c.add(f),()=>c.delete(f)},onRestored(f){return l.add(f),()=>l.delete(f)},dispose(){t.removeEventListener("webglcontextlost",d),t.removeEventListener("webglcontextrestored",u),c.clear(),l.clear(),s.clear()}}}function Bc(t,e,r){let n=t.createShader(e);if(!n)throw new Error("Failed to allocate shader");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){let o=t.getShaderInfoLog(n)??"Unknown shader compile failure";throw t.deleteShader(n),new Error(o)}return n}function K0(t,e,r,n){let i=t.createProgram();if(!i)throw new Error("Failed to allocate shader program");if(t.attachShader(i,e),t.attachShader(i,r),n)for(let[s,a]of Object.entries(n))t.bindAttribLocation(i,a,s);if(t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){let s=t.getProgramInfoLog(i)??"Unknown shader link failure";throw t.deleteProgram(i),new Error(s)}return i}var ve=class t{constructor(e,r){this.uniformLocations=new Map;this.attributeLocations=new Map;this.gl=e,this.program=r}static create(e,r,n){let i=Bc(e,e.VERTEX_SHADER,r.vertex),o=Bc(e,e.FRAGMENT_SHADER,r.fragment);try{let s=K0(e,i,o,n);return new t(e,s)}finally{e.deleteShader(i),e.deleteShader(o)}}use(){this.gl.useProgram(this.program)}getUniformLocation(e){if(!this.uniformLocations.has(e)){let r=this.gl.getUniformLocation(this.program,e);this.uniformLocations.set(e,r)}return this.uniformLocations.get(e)??null}getAttributeLocation(e){if(!this.attributeLocations.has(e)){let r=this.gl.getAttribLocation(this.program,e);this.attributeLocations.set(e,r)}return this.attributeLocations.get(e)??-1}dispose(){this.gl.deleteProgram(this.program),this.uniformLocations.clear(),this.attributeLocations.clear()}};function Oc(t,e,r){return ve.create(t,e,r)}var _e=class{constructor(e,r=e.STATIC_DRAW,n){this.gl=e,this.target=n??e.ARRAY_BUFFER;let i=e.createBuffer();if(!i)throw new Error("Failed to allocate buffer");this.buffer=i,e.bindBuffer(this.target,this.buffer),e.bufferData(this.target,0,r)}bind(){this.gl.bindBuffer(this.target,this.buffer)}upload(e,r=this.gl.STATIC_DRAW){this.bind(),this.gl.bufferData(this.target,e,r)}update(e,r=0){this.bind(),this.gl.bufferSubData(this.target,r,e)}dispose(){this.gl.deleteBuffer(this.buffer)}},fe=class extends _e{constructor(e,r=e.STATIC_DRAW){super(e,r,e.ELEMENT_ARRAY_BUFFER)}},we=class{constructor(e){this.gl=e;let r=e.createVertexArray();if(!r)throw new Error("Failed to allocate vertex array object");this.vao=r}bind(){this.gl.bindVertexArray(this.vao)}configureAttributes(e,r){this.bind(),r&&r.bind();for(let n of e)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)}},Or=class{constructor(e,r=e.TEXTURE_2D){this.width=0;this.height=0;this.gl=e,this.target=r;let n=e.createTexture();if(!n)throw new Error("Failed to allocate texture");this.texture=n}bind(e=0){this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.target,this.texture)}setParameters(e){this.bind(),e.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,e.wrapS),e.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,e.wrapT),e.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,e.minFilter),e.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,e.magFilter)}upload(e,r,n){this.width=e,this.height=r,this.uploadImage(0,this.gl.RGBA,e,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n)}uploadImage(e,r,n,i,o,s,a,c){this.bind(),this.gl.texImage2D(this.target,e,r,n,i,o,s,a,c)}dispose(){this.gl.deleteTexture(this.texture)}},Dr=class{constructor(e){this.gl=e,this.target=e.TEXTURE_CUBE_MAP;let r=e.createTexture();if(!r)throw new Error("Failed to allocate cubemap texture");this.texture=r}bind(e=0){this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.target,this.texture)}setParameters(e){this.bind(),e.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,e.wrapS),e.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,e.wrapT),e.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,e.minFilter),e.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,e.magFilter)}uploadFace(e,r,n,i,o,s,a,c,l){this.bind(),this.gl.texImage2D(e,r,n,i,o,s,a,c,l)}dispose(){this.gl.deleteTexture(this.texture)}},xo=class{constructor(e){this.gl=e;let r=e.createFramebuffer();if(!r)throw new Error("Failed to allocate framebuffer");this.framebuffer=r}bind(e=this.gl.FRAMEBUFFER){this.gl.bindFramebuffer(e,this.framebuffer)}attachTexture2D(e,r,n=0){this.bind(),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,e,r.target,r.texture,n)}dispose(){this.gl.deleteFramebuffer(this.framebuffer)}};var Ns=4,Ds=7*Ns,ks=[{index:0,size:3,type:5126,stride:Ds,offset:0},{index:1,size:2,type:5126,stride:Ds,offset:3*Ns},{index:2,size:2,type:5126,stride:Ds,offset:5*Ns}];function Y0(t,e){return{width:t,height:t,padding:e,data:new Uint8Array(t*t*4),cursorX:0,cursorY:0,rowHeight:0}}function q0(t){let e=t.width*t.height;if(e===0)throw new Error("Invalid lightmap with zero area");let r=t.samples.byteLength/e;if(!Number.isInteger(r)||r<3||r>4)throw new Error("Unsupported lightmap channel count");return r}function $0(t,e,r){let n=q0(r),i=t.width*4,o=e.x+t.padding,s=e.y+t.padding,a=0;for(let c=0;c<r.height;c++){let l=(s+c)*i+o*4;for(let d=0;d<r.width;d++){let u=l+d*4;t.data[u]=r.samples[a],t.data[u+1]=r.samples[a+1],t.data[u+2]=r.samples[a+2],t.data[u+3]=n===4?r.samples[a+3]:255,a+=n}}}function j0(t,e,r){let n=e.width+r.lightmapPadding*2,i=e.height+r.lightmapPadding*2;if(n>r.atlasSize||i>r.atlasSize)throw new Error("Lightmap too large for atlas");for(let a of t){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 c={atlasIndex:t.indexOf(a),x:a.cursorX,y:a.cursorY,width:e.width,height:e.height};return a.cursorX+=n+r.lightmapPadding,a.rowHeight=Math.max(a.rowHeight,i),{placement:c,atlas:a}}let o=Y0(r.atlasSize,r.lightmapPadding);t.push(o);let s={atlasIndex:t.length-1,x:0,y:0,width:e.width,height:e.height};return o.cursorX=n+r.lightmapPadding,o.rowHeight=i,{placement:s,atlas:o}}function bo(t){return t instanceof Float32Array?t:new Float32Array(t)}function J0(t,e){if(!t){let n=new Uint16Array(e);for(let i=0;i<e;i++)n[i]=i;return n}return t instanceof Uint16Array?t:new Uint16Array(t)}function Q0(t,e){let r=new Float32Array(t.length);for(let n=0;n<t.length;n+=2)r[n]=e.offset[0]+t[n]*e.scale[0],r[n+1]=e.offset[1]+t[n+1]*e.scale[1];return r}function Z0(t,e){let r=bo(t.vertices),n=bo(t.textureCoords),i=e?Q0(bo(t.lightmapCoords??t.textureCoords),e):bo(t.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 c=a*3,l=a*2,d=a*7;s[d]=r[c],s[d+1]=r[c+1],s[d+2]=r[c+2],s[d+3]=n[l],s[d+4]=n[l+1],s[d+5]=i[l],s[d+6]=i[l+1]}return s}function Dc(t){let e=[];for(let r=0;r<t.faces.length;r++){let n=t.faces[r];if(n.texInfo<0)continue;let i=t.texInfo[n.texInfo],o=[],s=[],a=[];for(let f=0;f<n.numEdges;f++){let h=t.surfEdges[n.firstEdge+f],m=t.edges[Math.abs(h)],y=h>=0?m.vertices[0]:m.vertices[1],p=t.vertices[y];o.push(p[0],p[1],p[2]);let g=p[0]*i.s[0]+p[1]*i.s[1]+p[2]*i.s[2]+i.sOffset,_=p[0]*i.t[0]+p[1]*i.t[1]+p[2]*i.t[2]+i.tOffset;s.push(g,_),a.push(g,_)}let c=[],l=o.length/3;for(let f=1;f<l-1;f++)c.push(0,f,f+1);let d,u=t.lightMapInfo[r];if(u){let f=1/0,h=-1/0,m=1/0,y=-1/0;for(let b=0;b<s.length;b+=2){let A=s[b],M=s[b+1];A<f&&(f=A),A>h&&(h=A),M<m&&(m=M),M>y&&(y=M)}let p=Math.floor(f/16),g=Math.floor(m/16),_=Math.ceil(h/16)-p+1,x=Math.ceil(y/16)-g+1,v=bi(n,t.lightMaps,u);if(v&&v.length===_*x*3){d={width:_,height:x,samples:v};for(let b=0;b<a.length;b+=2)a[b]=s[b]/16-p+.5,a[b+1]=s[b+1]/16-g+.5}}e.push({vertices:new Float32Array(o),textureCoords:new Float32Array(s),lightmapCoords:new Float32Array(a),indices:new Uint16Array(c),texture:i.texture,surfaceFlags:i.flags,lightmap:d,faceIndex:r})}return e}function Nc(t,e,r,n={}){let i=e;if(r&&n.hiddenClassnames&&n.hiddenClassnames.size>0){let d=new Set;for(let u of r.entities.entities)if(u.classname&&n.hiddenClassnames.has(u.classname)){let f=u.properties.model;if(f&&f.startsWith("*")){let h=parseInt(f.substring(1),10);if(!isNaN(h)&&h>=0&&h<r.models.length){let m=r.models[h];for(let y=0;y<m.numFaces;y++)d.add(m.firstFace+y)}}}d.size>0&&(i=e.filter(u=>!d.has(u.faceIndex)))}let o={atlasSize:n.atlasSize??1024,lightmapPadding:n.lightmapPadding??1,hiddenClassnames:n.hiddenClassnames??new Set},s=[],a=new Map;i.forEach((d,u)=>{if(!d.lightmap)return;let{placement:f,atlas:h}=j0(s,d.lightmap,o);$0(h,f,d.lightmap),a.set(u,{atlasIndex:f.atlasIndex,offset:[(f.x+o.lightmapPadding)/o.atlasSize,(f.y+o.lightmapPadding)/o.atlasSize],scale:[f.width/o.atlasSize,f.height/o.atlasSize]})});let c=s.map(d=>{let u=new Or(t);return u.setParameters({wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,minFilter:t.LINEAR,magFilter:t.LINEAR}),u.uploadImage(0,t.RGBA,d.width,d.height,0,t.RGBA,t.UNSIGNED_BYTE,d.data),{texture:u,width:d.width,height:d.height,pixels:d.data}});return{surfaces:i.map((d,u)=>{let f=a.get(u),h=Z0(d,f),m=J0(d.indices,h.length/7),y=new _e(t,t.STATIC_DRAW,t.ARRAY_BUFFER);y.upload(h);let p=new fe(t,t.STATIC_DRAW);p.upload(m);let g=new we(t);return g.configureAttributes(ks,y),{vao:g,vertexBuffer:y,indexBuffer:p,indexCount:m.length,vertexCount:h.length/7,texture:d.texture,surfaceFlags:d.surfaceFlags??Kr,lightmap:f,vertexData:h,indexData:m}}),lightmaps:c}}function Nr(t){let{normal:e,distance:r}=t,n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(n===0)return t;let i=1/n;return{normal:{x:e.x*i,y:e.y*i,z:e.z*i},distance:r*i}}function kc(t){if(t.length!==16)throw new Error("View-projection matrix must contain 16 elements");let e=t[0],r=t[4],n=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],l=t[2],d=t[6],u=t[10],f=t[14],h=t[3],m=t[7],y=t[11],p=t[15];return[Nr({normal:{x:h+e,y:m+r,z:y+n},distance:p+i}),Nr({normal:{x:h-e,y:m-r,z:y-n},distance:p-i}),Nr({normal:{x:h+o,y:m+s,z:y+a},distance:p+c}),Nr({normal:{x:h-o,y:m-s,z:y-a},distance:p-c}),Nr({normal:{x:h+l,y:m+d,z:y+u},distance:p+f}),Nr({normal:{x:h-l,y:m-d,z:y-u},distance:p-f})]}function eu(t,e){return t.normal.x*e.x+t.normal.y*e.y+t.normal.z*e.z+t.distance}function jn(t,e,r){for(let n of r){let i=n.normal.x>=0?e.x:t.x,o=n.normal.y>=0?e.y:t.y,s=n.normal.z>=0?e.z:t.z;if(eu(n,{x:i,y:o,z:s})<0)return!1}return!0}function Uc(t){return t<0}function Hc(t){return-t-1}function Vc(t,e){return t.normal[0]*e.x+t.normal[1]*e.y+t.normal[2]*e.z-t.dist}function tu(t,e,r){if(!t||e<0||r<0)return!0;let n=Math.ceil(t.numClusters/8),i=t.clusters[e].pvs,o=Math.floor(r/8),s=1<<r%8;return o<0||o>=n?!1:(i[o]&s)!==0}function ru(t,e){let r={x:t.mins[0],y:t.mins[1],z:t.mins[2]},n={x:t.maxs[0],y:t.maxs[1],z:t.maxs[2]};return jn(r,n,e)}function Hs(t,e){let r=0;for(;r>=0;){let n=t.nodes[r],i=t.planes[n.planeIndex],s=Vc(i,e)>=0?0:1,a=n.children[s];if(Uc(a))return Hc(a);r=a}return-1}function nu(t,e){let r=t.leafs[e],n=[];for(let i=0;i<r.numLeafFaces;i+=1)n.push(t.leafLists.leafFaces[e][i]);return n}function Us(t,e,r,n,i,o,s){if(Uc(e)){let f=Hc(e),h=t.leafs[f];if(!tu(t.visibility,i,h.cluster)||!ru(h,n))return;let m={x:(h.mins[0]+h.maxs[0])*.5,y:(h.mins[1]+h.maxs[1])*.5,z:(h.mins[2]+h.maxs[2])*.5},y=m.x-r.x,p=m.y-r.y,g=m.z-r.z,_=-(y*y+p*p+g*g);for(let x of nu(t,f))s.has(x)||(s.add(x),o.push({faceIndex:x,leafIndex:f,sortKey:_}));return}let a=t.nodes[e],c=t.planes[a.planeIndex],l=Vc(c,r),d=l>=0?a.children[0]:a.children[1],u=l>=0?a.children[1]:a.children[0];jn({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)&&(Us(t,d,r,n,i,o,s),Us(t,u,r,n,i,o,s))}function Gc(t,e,r){let n=Hs(t,e),i=n>=0?t.leafs[n].cluster:-1,o=[];return Us(t,0,e,r,i,o,new Set),o}var Pt=32;function kr(t){let e=[];for(let r=0;r<t.length;r+=3){let n=t[r],i=t[r+1],o=t[r+2];e.push(n,i,i,o,o,n)}return t instanceof Uint32Array||Math.max(...e)>65535?new Uint32Array(e):new Uint16Array(e)}var Vs=`#version 300 es
|
|
141
|
+
ïBçϧmÙIólÜoëVb¦¯éWÇû3`});var Cu={a:ir};this.setModule=R=>{e.setModule(Et,R)},this.getModule=()=>e.getModule(Et),this.instantiate=()=>(this.getModule().then(R=>WebAssembly.instantiate(R,Cu)).then(R=>{let Ue=R.exports;co(Ue),m=Ue.l,g(),zu(Ue),r()}),this.ready=new Promise(R=>{r=R}).then(()=>{this.HEAP=m.buffer,this.malloc=rc,this.free=ac,this.create_decoder=Tn,this.send_setup=nc,this.init_dsp=ic,this.decode_packets=oc,this.destroy_decoder=sc}),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 md("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][pd];this._decoder.sendSetupHeader(a[yd]),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[gd]){let o=this._totalSamplesDecoded-i[xd];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 Yr{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()}};zo(Lt,"OggVorbisDecoder");zo(Ri,"OggVorbisDecoderWebWorker");var Za=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 Za(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=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 zi(`Unsupported audio format: ${t}`)}};var Qh="quake2ts-pak-indexes",Jh="pak-indexes";function _d(){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 Ci(e,t){let r=_d();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 qa(e,t){return`${ae(e)}:${t.toString(16)}`}function em(e){return e.map(t=>({...t}))}var ls=class{constructor(t=Qh,r=Jh){this.dbName=t;this.storeName=r}get isSupported(){return!!_d()}async persist(t){if(!this.isSupported)return;let r=t.validate(),n={...r,key:qa(t.name,r.checksum),name:t.name,size:t.size,persistedAt:Date.now(),entries:em(r.entries)},i=await Ci(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 Ci(this.dbName,this.storeName),i=r!==void 0?qa(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 Ci(this.dbName,this.storeName),i=r!==void 0?qa(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 Ci(this.dbName,this.storeName);await ki(t,this.storeName,"readwrite",r=>r.clear()),t.close()}async list(){if(!this.isSupported)return[];let t=await Ci(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=Gc(Ta(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 ja=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||{}),bd=-1,us=0,vd=1,Sd=2,wd=3,hn=80,Ad=.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 tm=7,Di=e=>e&tm;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=fc(e,t.origin),s=ha(o),a=Qe(o),d=s-80;d<0&&(d=0),d*=wr(n);let l=fa(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:uc,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=Md(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=Qa(r,10,2e4),n}applyOcclusion(t,r){let n=Md(r?.gainScale??1);if(t.gain.gain.value=t.baseGain*n,t.occlusion?.filter){let i=r?.lowpassHz??2e4;t.occlusion.filter.frequency.value=Qa(i,10,2e4)}t.occlusion?(t.occlusion.scale=n,t.occlusion.lowpassHz=r?.lowpassHz):r&&(t.occlusion={scale:n,lowpassHz:r.lowpassHz})}},Qa=(e,t,r)=>Math.min(r,Math.max(t,e)),Md=e=>Qa(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 rm(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 nm(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 Ed(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");rm(o);let s=new Map;nm(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 Ld(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 im(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=Ld(t,t.VERTEX_SHADER,r.vertex),o=Ld(t,t.FRAGMENT_SHADER,r.fragment);try{let s=im(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 Td(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 el=4,Ja=7*el,tl=[{index:0,size:3,type:5126,stride:Ja,offset:0},{index:1,size:2,type:5126,stride:Ja,offset:3*el},{index:2,size:2,type:5126,stride:Ja,offset:5*el}];function om(e,t){return{width:e,height:e,padding:t,data:new Uint8Array(e*e*4),cursorX:0,cursorY:0,rowHeight:0}}function sm(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 am(e,t,r){let n=sm(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 lm(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=om(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 cm(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 dm(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 um(e,t){let r=ws(e.vertices),n=ws(e.textureCoords),i=t?dm(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 Id(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 Rd(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}=lm(s,c.lightmap,o);am(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=um(c,u),m=cm(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(tl,g),{vao:x,vertexBuffer:g,indexBuffer:p,indexCount:m.length,vertexCount:f.length/7,texture:c.texture,surfaceFlags:c.surfaceFlags??Cn,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 zd(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 fm(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(fm(n,{x:i,y:o,z:s})<0)return!1}return!0}function Cd(e){return e<0}function kd(e){return-e-1}function Fd(e,t){return e.normal[0]*t.x+e.normal[1]*t.y+e.normal[2]*t.z-e.dist}function hm(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 mm(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 nl(e,t){let r=0;for(;r>=0;){let n=e.nodes[r],i=e.planes[n.planeIndex],s=Fd(i,t)>=0?0:1,a=n.children[s];if(Cd(a))return kd(a);r=a}return-1}function pm(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 rl(e,t,r,n,i,o,s){if(Cd(t)){let u=kd(t),f=e.leafs[u];if(!hm(e.visibility,i,f.cluster)||!mm(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 pm(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=Fd(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)&&(rl(e,c,r,n,i,o,s),rl(e,h,r,n,i,o,s))}function Dd(e,t,r){let n=nl(e,t),i=n>=0?e.leafs[n].cluster:-1,o=[];return rl(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 il=`#version 300 es
|
|
142
142
|
precision highp float;
|
|
143
143
|
|
|
144
144
|
layout(location = 0) in vec3 a_position;
|
|
145
145
|
layout(location = 1) in vec2 a_texCoord;
|
|
146
146
|
layout(location = 2) in vec2 a_lightmapCoord;
|
|
147
|
+
layout(location = 3) in float a_lightmapStep;
|
|
147
148
|
|
|
148
149
|
uniform mat4 u_modelViewProjection;
|
|
149
150
|
uniform vec2 u_texScroll;
|
|
@@ -151,6 +152,7 @@ uniform vec2 u_lightmapScroll;
|
|
|
151
152
|
|
|
152
153
|
out vec2 v_texCoord;
|
|
153
154
|
out vec2 v_lightmapCoord;
|
|
155
|
+
out float v_lightmapStep;
|
|
154
156
|
out vec3 v_position;
|
|
155
157
|
|
|
156
158
|
vec2 applyScroll(vec2 uv, vec2 scroll) {
|
|
@@ -160,9 +162,10 @@ vec2 applyScroll(vec2 uv, vec2 scroll) {
|
|
|
160
162
|
void main() {
|
|
161
163
|
v_texCoord = applyScroll(a_texCoord, u_texScroll);
|
|
162
164
|
v_lightmapCoord = applyScroll(a_lightmapCoord, u_lightmapScroll);
|
|
165
|
+
v_lightmapStep = a_lightmapStep;
|
|
163
166
|
v_position = a_position;
|
|
164
167
|
gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
|
|
165
|
-
}`,
|
|
168
|
+
}`,ol=`#version 300 es
|
|
166
169
|
precision highp float;
|
|
167
170
|
|
|
168
171
|
struct DLight {
|
|
@@ -171,15 +174,17 @@ struct DLight {
|
|
|
171
174
|
float intensity;
|
|
172
175
|
};
|
|
173
176
|
|
|
174
|
-
const int MAX_DLIGHTS = ${
|
|
177
|
+
const int MAX_DLIGHTS = ${Qt};
|
|
175
178
|
|
|
176
179
|
in vec2 v_texCoord;
|
|
177
180
|
in vec2 v_lightmapCoord;
|
|
181
|
+
in float v_lightmapStep;
|
|
178
182
|
in vec3 v_position;
|
|
179
183
|
|
|
180
184
|
uniform sampler2D u_diffuseMap;
|
|
181
185
|
uniform sampler2D u_lightmapAtlas;
|
|
182
186
|
uniform vec4 u_lightStyleFactors;
|
|
187
|
+
uniform vec4 u_styleLayerMapping; // 0, 1, 2... or -1 if invalid
|
|
183
188
|
uniform float u_alpha;
|
|
184
189
|
uniform bool u_applyLightmap;
|
|
185
190
|
uniform bool u_warp;
|
|
@@ -213,9 +218,35 @@ void main() {
|
|
|
213
218
|
vec3 totalLight = vec3(1.0);
|
|
214
219
|
|
|
215
220
|
if (u_applyLightmap) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
// Multi-style lightmap accumulation
|
|
222
|
+
vec3 light = vec3(0.0);
|
|
223
|
+
bool hasLight = false;
|
|
224
|
+
|
|
225
|
+
vec2 lmBase = warpCoords(v_lightmapCoord);
|
|
226
|
+
|
|
227
|
+
// Loop unrolled-ish
|
|
228
|
+
for (int i = 0; i < 4; i++) {
|
|
229
|
+
// We can access vec4 components by index in newer GLSL ES, or use direct access
|
|
230
|
+
float layer = u_styleLayerMapping[i];
|
|
231
|
+
float factor = u_lightStyleFactors[i];
|
|
232
|
+
|
|
233
|
+
if (layer >= -0.5) { // Valid layer (check >= 0 approx)
|
|
234
|
+
// Offset V by layer * step
|
|
235
|
+
// Since we packed vertically
|
|
236
|
+
vec2 offset = vec2(0.0, layer * v_lightmapStep);
|
|
237
|
+
light += texture(u_lightmapAtlas, lmBase + offset).rgb * factor;
|
|
238
|
+
hasLight = true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// If no valid lightmaps found (e.g. unlit surface?), default to full bright?
|
|
243
|
+
// Or if u_applyLightmap is true, there should be at least one style.
|
|
244
|
+
// Fallback to 1.0 if accumulator is empty?
|
|
245
|
+
// In Q2, unlit surfs are fullbright (or use minlight).
|
|
246
|
+
// If hasLight is false, it means no styles are active.
|
|
247
|
+
if (!hasLight) light = vec3(1.0);
|
|
248
|
+
|
|
249
|
+
totalLight = light; // Dynamic lights add on top or multiply? Q2 adds.
|
|
219
250
|
|
|
220
251
|
// Add dynamic lights
|
|
221
252
|
for (int i = 0; i < MAX_DLIGHTS; i++) {
|
|
@@ -250,7 +281,7 @@ void main() {
|
|
|
250
281
|
}
|
|
251
282
|
|
|
252
283
|
o_color = finalColor;
|
|
253
|
-
}`,
|
|
284
|
+
}`,Pd=[0,255,255,255],gm=[0,-1,-1,-1];function sl(e=Pd,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 ym(e){return[-(e*.25%1),0]}function al(e=Cn,t=0){let r=(e&bc)!==0,n=(e&yc)!==0,i=(e&gc)!==0,o=(e&xc)!==0,s=(e&_c)!==0,a=o?.33:s?.66:1,d=o||s,l=!d&&!i,c=r?ym(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:il,fragment:ol},{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=Pd,styleLayers:i=gm,styleValues:o=[],diffuseSampler:s=0,lightmapSampler:a,surfaceFlags:d=Cn,timeSeconds:l=0,texScroll:c,alpha:h,warp:u,dlights:f=[],renderMode:m}=t,g=al(d,l),p=sl(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 Od(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 Bd=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]),ll=`#version 300 es
|
|
254
285
|
precision highp float;
|
|
255
286
|
|
|
256
287
|
layout(location = 0) in vec3 a_position;
|
|
@@ -265,7 +296,7 @@ void main() {
|
|
|
265
296
|
dir.xy += u_scroll;
|
|
266
297
|
v_direction = dir;
|
|
267
298
|
gl_Position = u_viewProjectionNoTranslation * vec4(a_position, 1.0);
|
|
268
|
-
}`,
|
|
299
|
+
}`,cl=`#version 300 es
|
|
269
300
|
precision highp float;
|
|
270
301
|
|
|
271
302
|
in vec3 v_direction;
|
|
@@ -275,7 +306,7 @@ out vec4 o_color;
|
|
|
275
306
|
|
|
276
307
|
void main() {
|
|
277
308
|
o_color = texture(u_skybox, v_direction);
|
|
278
|
-
}`,
|
|
309
|
+
}`,Ms=class{constructor(t){this.gl=t,this.program=Me.create(t,{vertex:ll,fragment:cl},{a_position:0}),this.vao=new ze(t),this.vbo=new Ee(t,t.STATIC_DRAW),this.vbo.upload(Bd,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,Bd.length/3)}dispose(){this.vbo.dispose(),this.vao.dispose(),this.cubemap.dispose(),this.program.dispose()}};function Nd(e){let t=new Float32Array(e);return t[12]=0,t[13]=0,t[14]=0,t}function Ud(e,t=[.01,.02]){let[r,n]=t;return[r*e,n*e]}var ul=`#version 300 es
|
|
279
310
|
precision highp float;
|
|
280
311
|
|
|
281
312
|
layout(location = 0) in vec3 a_position;
|
|
@@ -288,7 +319,7 @@ struct DLight {
|
|
|
288
319
|
float intensity;
|
|
289
320
|
};
|
|
290
321
|
|
|
291
|
-
const int MAX_DLIGHTS = ${
|
|
322
|
+
const int MAX_DLIGHTS = ${Qt};
|
|
292
323
|
|
|
293
324
|
uniform mat4 u_modelViewProjection;
|
|
294
325
|
uniform mat4 u_modelMatrix;
|
|
@@ -327,7 +358,7 @@ void main() {
|
|
|
327
358
|
v_texCoord = a_texCoord;
|
|
328
359
|
v_position = worldPos.xyz;
|
|
329
360
|
gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
|
|
330
|
-
}`,
|
|
361
|
+
}`,fl=`#version 300 es
|
|
331
362
|
precision highp float;
|
|
332
363
|
|
|
333
364
|
in vec2 v_texCoord;
|
|
@@ -363,7 +394,7 @@ void main() {
|
|
|
363
394
|
}
|
|
364
395
|
|
|
365
396
|
o_color = finalColor;
|
|
366
|
-
}`;function ou(t){let e=t.x*t.x+t.y*t.y+t.z*t.z;if(e<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(e);return{x:t.x*r,y:t.y*r,z:t.z*r}}function qs(t,e,r){return t+(e-t)*r}function $c(t,e,r){return{x:qs(t.x,e.x,r),y:qs(t.y,e.y,r),z:qs(t.z,e.z,r)}}function su(t,e,r){return[t/r.skinWidth,1-e/r.skinHeight]}function Js(t){if(t.glCommands.length===0){let n=[],i=[];return t.triangles.forEach(o=>{let s=n.length;for(let a=0;a<3;a+=1){let c=o.vertexIndices[a],l=o.texCoordIndices[a],d=t.texCoords[l];n.push({vertexIndex:c,texCoord:su(d.s,d.t,t.header)})}i.push(s,s+1,s+2)}),{vertices:n,indices:new Uint16Array(i)}}let e=[],r=[];for(let n of t.glCommands){let i=e.length;if(e.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),c=i+o+(s?1:0),l=i+o+2;r.push(a,c,l)}else for(let o=1;o<n.vertices.length-1;o+=1)r.push(i,i+o,i+o+1)}return{vertices:e,indices:new Uint16Array(r)}}function Qs(t,e,r){let{frame0:n,frame1:i,lerp:o}=r,s=t.frames[n],a=t.frames[i];if(!s||!a)throw new Error("Requested MD2 frames are out of range");let c=new Float32Array(e.vertices.length*8);return e.vertices.forEach((l,d)=>{let u=s.vertices[l.vertexIndex],f=a.vertices[l.vertexIndex];if(!u||!f)throw new Error("MD2 vertex index out of range for frame");let h=$c(u.position,f.position,o),m=ou($c(u.normal,f.normal,o)),y=d*8;c[y]=h.x,c[y+1]=h.y,c[y+2]=h.z,c[y+3]=m.x,c[y+4]=m.y,c[y+5]=m.z,c[y+6]=l.texCoord[0],c[y+7]=l.texCoord[1]}),c}var So=class{constructor(e,r,n){this.gl=e,this.geometry=Js(r),this.vertexBuffer=new _e(e,e.STATIC_DRAW),this.indexBuffer=new fe(e,e.STATIC_DRAW),this.vertexArray=new we(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:32,offset:0},{index:1,size:3,type:e.FLOAT,stride:32,offset:12},{index:2,size:2,type:e.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n)}update(e,r){let n=Qs(e,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()}},Ao=class{constructor(e){this.uniformDlights=[];this.gl=e,this.program=ve.create(e,{vertex:$s,fragment:js},{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<Pt;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(e){let{modelViewProjection:r,modelMatrix:n,lightDirection:i=[0,0,1],ambientLight:o=.2,tint:s=[1,1,1,1],diffuseSampler:a=0,dlights:c=[],renderMode:l}=e,d=new Float32Array(i),u=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,d),this.gl.uniform1f(this.uniformAmbient,o),this.gl.uniform4fv(this.uniformTint,u),this.gl.uniform1i(this.uniformDiffuse,a);let f=0,h=[1,1,1,1];l&&(l.mode==="solid"||l.mode==="wireframe"?f=1:l.mode==="solid-faceted"&&(f=2),l.color?h=[...l.color]:l.generateRandomColor),this.gl.uniform1i(this.uniformRenderMode,f),this.gl.uniform4f(this.uniformSolidColor,h[0],h[1],h[2],h[3]);let m=Math.min(c.length,Pt);this.gl.uniform1i(this.uniformNumDlights,m);for(let y=0;y<m;y++){let p=c[y];this.gl.uniform3f(this.uniformDlights[y].pos,p.origin.x,p.origin.y,p.origin.z),this.gl.uniform3f(this.uniformDlights[y].color,p.color.x,p.color.y,p.color.z),this.gl.uniform1f(this.uniformDlights[y].intensity,p.intensity)}}draw(e,r){if(e.vertexArray.bind(),r&&r.mode==="wireframe"){if(!e.wireframeIndexBuffer){e.wireframeIndexBuffer=new fe(this.gl,this.gl.STATIC_DRAW);let n=kr(e.geometry.indices);e.wireframeIndexBuffer.upload(n),e.wireframeIndexCount=n.length}e.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,e.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else e.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,e.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var j=1e-6,Ue=typeof Float32Array<"u"?Float32Array:Array,Zs=Math.random;function Mo(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var pg=Math.PI/180,yg=180/Math.PI;var ae={};qo(ae,{add:()=>Xu,adjoint:()=>mu,clone:()=>cu,copy:()=>lu,create:()=>au,decompose:()=>Ru,determinant:()=>pu,equals:()=>$u,exactEquals:()=>qu,frob:()=>Wu,fromQuat:()=>Pu,fromQuat2:()=>Tu,fromRotation:()=>Mu,fromRotationTranslation:()=>Zc,fromRotationTranslationScale:()=>zu,fromRotationTranslationScaleOrigin:()=>Fu,fromScaling:()=>Au,fromTranslation:()=>Su,fromValues:()=>du,fromXRotation:()=>wu,fromYRotation:()=>Lu,fromZRotation:()=>Eu,frustum:()=>Bu,getRotation:()=>Cu,getScaling:()=>el,getTranslation:()=>Iu,identity:()=>Jc,invert:()=>hu,lookAt:()=>Hu,mul:()=>ju,multiply:()=>Qc,multiplyScalar:()=>Ku,multiplyScalarAndAdd:()=>Yu,ortho:()=>ku,orthoNO:()=>rl,orthoZO:()=>Uu,perspective:()=>Ou,perspectiveFromFieldOfView:()=>Nu,perspectiveNO:()=>tl,perspectiveZO:()=>Du,rotate:()=>xu,rotateX:()=>bu,rotateY:()=>vu,rotateZ:()=>_u,scale:()=>gu,set:()=>uu,str:()=>Gu,sub:()=>Ju,subtract:()=>nl,targetTo:()=>Vu,translate:()=>yu,transpose:()=>fu});function au(){var t=new Ue(16);return Ue!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function cu(t){var e=new Ue(16);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 lu(t,e){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 du(t,e,r,n,i,o,s,a,c,l,d,u,f,h,m,y){var p=new Ue(16);return p[0]=t,p[1]=e,p[2]=r,p[3]=n,p[4]=i,p[5]=o,p[6]=s,p[7]=a,p[8]=c,p[9]=l,p[10]=d,p[11]=u,p[12]=f,p[13]=h,p[14]=m,p[15]=y,p}function uu(t,e,r,n,i,o,s,a,c,l,d,u,f,h,m,y,p){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=f,t[12]=h,t[13]=m,t[14]=y,t[15]=p,t}function Jc(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fu(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],o=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function hu(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],f=e[10],h=e[11],m=e[12],y=e[13],p=e[14],g=e[15],_=r*a-n*s,x=r*c-i*s,v=r*l-o*s,b=n*c-i*a,A=n*l-o*a,M=i*l-o*c,w=d*y-u*m,E=d*p-f*m,L=d*g-h*m,O=u*p-f*y,N=u*g-h*y,H=f*g-h*p,C=_*H-x*N+v*O+b*L-A*E+M*w;return C?(C=1/C,t[0]=(a*H-c*N+l*O)*C,t[1]=(i*N-n*H-o*O)*C,t[2]=(y*M-p*A+g*b)*C,t[3]=(f*A-u*M-h*b)*C,t[4]=(c*L-s*H-l*E)*C,t[5]=(r*H-i*L+o*E)*C,t[6]=(p*v-m*M-g*x)*C,t[7]=(d*M-f*v+h*x)*C,t[8]=(s*N-a*L+l*w)*C,t[9]=(n*L-r*N-o*w)*C,t[10]=(m*A-y*v+g*_)*C,t[11]=(u*v-d*A-h*_)*C,t[12]=(a*E-s*O-c*w)*C,t[13]=(r*O-n*E+i*w)*C,t[14]=(y*x-m*b-p*_)*C,t[15]=(d*b-u*x+f*_)*C,t):null}function mu(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],f=e[10],h=e[11],m=e[12],y=e[13],p=e[14],g=e[15],_=r*a-n*s,x=r*c-i*s,v=r*l-o*s,b=n*c-i*a,A=n*l-o*a,M=i*l-o*c,w=d*y-u*m,E=d*p-f*m,L=d*g-h*m,O=u*p-f*y,N=u*g-h*y,H=f*g-h*p;return t[0]=a*H-c*N+l*O,t[1]=i*N-n*H-o*O,t[2]=y*M-p*A+g*b,t[3]=f*A-u*M-h*b,t[4]=c*L-s*H-l*E,t[5]=r*H-i*L+o*E,t[6]=p*v-m*M-g*x,t[7]=d*M-f*v+h*x,t[8]=s*N-a*L+l*w,t[9]=n*L-r*N-o*w,t[10]=m*A-y*v+g*_,t[11]=u*v-d*A-h*_,t[12]=a*E-s*O-c*w,t[13]=r*O-n*E+i*w,t[14]=y*x-m*b-p*_,t[15]=d*b-u*x+f*_,t}function pu(t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],l=t[8],d=t[9],u=t[10],f=t[11],h=t[12],m=t[13],y=t[14],p=t[15],g=e*s-r*o,_=e*a-n*o,x=r*a-n*s,v=l*m-d*h,b=l*y-u*h,A=d*y-u*m,M=e*A-r*b+n*v,w=o*A-s*b+a*v,E=l*x-d*_+u*g,L=h*x-m*_+y*g;return c*M-i*w+p*E-f*L}function Qc(t,e,r){var n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],d=e[7],u=e[8],f=e[9],h=e[10],m=e[11],y=e[12],p=e[13],g=e[14],_=e[15],x=r[0],v=r[1],b=r[2],A=r[3];return t[0]=x*n+v*a+b*u+A*y,t[1]=x*i+v*c+b*f+A*p,t[2]=x*o+v*l+b*h+A*g,t[3]=x*s+v*d+b*m+A*_,x=r[4],v=r[5],b=r[6],A=r[7],t[4]=x*n+v*a+b*u+A*y,t[5]=x*i+v*c+b*f+A*p,t[6]=x*o+v*l+b*h+A*g,t[7]=x*s+v*d+b*m+A*_,x=r[8],v=r[9],b=r[10],A=r[11],t[8]=x*n+v*a+b*u+A*y,t[9]=x*i+v*c+b*f+A*p,t[10]=x*o+v*l+b*h+A*g,t[11]=x*s+v*d+b*m+A*_,x=r[12],v=r[13],b=r[14],A=r[15],t[12]=x*n+v*a+b*u+A*y,t[13]=x*i+v*c+b*f+A*p,t[14]=x*o+v*l+b*h+A*g,t[15]=x*s+v*d+b*m+A*_,t}function yu(t,e,r){var n=r[0],i=r[1],o=r[2],s,a,c,l,d,u,f,h,m,y,p,g;return e===t?(t[12]=e[0]*n+e[4]*i+e[8]*o+e[12],t[13]=e[1]*n+e[5]*i+e[9]*o+e[13],t[14]=e[2]*n+e[6]*i+e[10]*o+e[14],t[15]=e[3]*n+e[7]*i+e[11]*o+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],d=e[4],u=e[5],f=e[6],h=e[7],m=e[8],y=e[9],p=e[10],g=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=d,t[5]=u,t[6]=f,t[7]=h,t[8]=m,t[9]=y,t[10]=p,t[11]=g,t[12]=s*n+d*i+m*o+e[12],t[13]=a*n+u*i+y*o+e[13],t[14]=c*n+f*i+p*o+e[14],t[15]=l*n+h*i+g*o+e[15]),t}function gu(t,e,r){var n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function xu(t,e,r,n){var i=n[0],o=n[1],s=n[2],a=Math.sqrt(i*i+o*o+s*s),c,l,d,u,f,h,m,y,p,g,_,x,v,b,A,M,w,E,L,O,N,H,C,Q;return a<j?null:(a=1/a,i*=a,o*=a,s*=a,c=Math.sin(r),l=Math.cos(r),d=1-l,u=e[0],f=e[1],h=e[2],m=e[3],y=e[4],p=e[5],g=e[6],_=e[7],x=e[8],v=e[9],b=e[10],A=e[11],M=i*i*d+l,w=o*i*d+s*c,E=s*i*d-o*c,L=i*o*d-s*c,O=o*o*d+l,N=s*o*d+i*c,H=i*s*d+o*c,C=o*s*d-i*c,Q=s*s*d+l,t[0]=u*M+y*w+x*E,t[1]=f*M+p*w+v*E,t[2]=h*M+g*w+b*E,t[3]=m*M+_*w+A*E,t[4]=u*L+y*O+x*N,t[5]=f*L+p*O+v*N,t[6]=h*L+g*O+b*N,t[7]=m*L+_*O+A*N,t[8]=u*H+y*C+x*Q,t[9]=f*H+p*C+v*Q,t[10]=h*H+g*C+b*Q,t[11]=m*H+_*C+A*Q,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function bu(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[4],s=e[5],a=e[6],c=e[7],l=e[8],d=e[9],u=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+l*n,t[5]=s*i+d*n,t[6]=a*i+u*n,t[7]=c*i+f*n,t[8]=l*i-o*n,t[9]=d*i-s*n,t[10]=u*i-a*n,t[11]=f*i-c*n,t}function vu(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],c=e[3],l=e[8],d=e[9],u=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-l*n,t[1]=s*i-d*n,t[2]=a*i-u*n,t[3]=c*i-f*n,t[8]=o*n+l*i,t[9]=s*n+d*i,t[10]=a*n+u*i,t[11]=c*n+f*i,t}function _u(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],c=e[3],l=e[4],d=e[5],u=e[6],f=e[7];return e!==t&&(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[0]=o*i+l*n,t[1]=s*i+d*n,t[2]=a*i+u*n,t[3]=c*i+f*n,t[4]=l*i-o*n,t[5]=d*i-s*n,t[6]=u*i-a*n,t[7]=f*i-c*n,t}function Su(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function Au(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Mu(t,e,r){var n=r[0],i=r[1],o=r[2],s=Math.sqrt(n*n+i*i+o*o),a,c,l;return s<j?null:(s=1/s,n*=s,i*=s,o*=s,a=Math.sin(e),c=Math.cos(e),l=1-c,t[0]=n*n*l+c,t[1]=i*n*l+o*a,t[2]=o*n*l-i*a,t[3]=0,t[4]=n*i*l-o*a,t[5]=i*i*l+c,t[6]=o*i*l+n*a,t[7]=0,t[8]=n*o*l+i*a,t[9]=i*o*l-n*a,t[10]=o*o*l+c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function wu(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Lu(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Eu(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Zc(t,e,r){var n=e[0],i=e[1],o=e[2],s=e[3],a=n+n,c=i+i,l=o+o,d=n*a,u=n*c,f=n*l,h=i*c,m=i*l,y=o*l,p=s*a,g=s*c,_=s*l;return t[0]=1-(h+y),t[1]=u+_,t[2]=f-g,t[3]=0,t[4]=u-_,t[5]=1-(d+y),t[6]=m+p,t[7]=0,t[8]=f+g,t[9]=m-p,t[10]=1-(d+h),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Tu(t,e){var r=new Ue(3),n=-e[0],i=-e[1],o=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],d=e[7],u=n*n+i*i+o*o+s*s;return u>0?(r[0]=(a*s+d*n+c*o-l*i)*2/u,r[1]=(c*s+d*i+l*n-a*o)*2/u,r[2]=(l*s+d*o+a*i-c*n)*2/u):(r[0]=(a*s+d*n+c*o-l*i)*2,r[1]=(c*s+d*i+l*n-a*o)*2,r[2]=(l*s+d*o+a*i-c*n)*2),Zc(t,e,r),t}function Iu(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function el(t,e){var r=e[0],n=e[1],i=e[2],o=e[4],s=e[5],a=e[6],c=e[8],l=e[9],d=e[10];return t[0]=Math.sqrt(r*r+n*n+i*i),t[1]=Math.sqrt(o*o+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+d*d),t}function Cu(t,e){var r=new Ue(3);el(r,e);var n=1/r[0],i=1/r[1],o=1/r[2],s=e[0]*n,a=e[1]*i,c=e[2]*o,l=e[4]*n,d=e[5]*i,u=e[6]*o,f=e[8]*n,h=e[9]*i,m=e[10]*o,y=s+d+m,p=0;return y>0?(p=Math.sqrt(y+1)*2,t[3]=.25*p,t[0]=(u-h)/p,t[1]=(f-c)/p,t[2]=(a-l)/p):s>d&&s>m?(p=Math.sqrt(1+s-d-m)*2,t[3]=(u-h)/p,t[0]=.25*p,t[1]=(a+l)/p,t[2]=(f+c)/p):d>m?(p=Math.sqrt(1+d-s-m)*2,t[3]=(f-c)/p,t[0]=(a+l)/p,t[1]=.25*p,t[2]=(u+h)/p):(p=Math.sqrt(1+m-s-d)*2,t[3]=(a-l)/p,t[0]=(f+c)/p,t[1]=(u+h)/p,t[2]=.25*p),t}function Ru(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];var i=n[0],o=n[1],s=n[2],a=n[4],c=n[5],l=n[6],d=n[8],u=n[9],f=n[10];r[0]=Math.sqrt(i*i+o*o+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(d*d+u*u+f*f);var h=1/r[0],m=1/r[1],y=1/r[2],p=i*h,g=o*m,_=s*y,x=a*h,v=c*m,b=l*y,A=d*h,M=u*m,w=f*y,E=p+v+w,L=0;return E>0?(L=Math.sqrt(E+1)*2,t[3]=.25*L,t[0]=(b-M)/L,t[1]=(A-_)/L,t[2]=(g-x)/L):p>v&&p>w?(L=Math.sqrt(1+p-v-w)*2,t[3]=(b-M)/L,t[0]=.25*L,t[1]=(g+x)/L,t[2]=(A+_)/L):v>w?(L=Math.sqrt(1+v-p-w)*2,t[3]=(A-_)/L,t[0]=(g+x)/L,t[1]=.25*L,t[2]=(b+M)/L):(L=Math.sqrt(1+w-p-v)*2,t[3]=(g-x)/L,t[0]=(A+_)/L,t[1]=(b+M)/L,t[2]=.25*L),t}function zu(t,e,r,n){var i=e[0],o=e[1],s=e[2],a=e[3],c=i+i,l=o+o,d=s+s,u=i*c,f=i*l,h=i*d,m=o*l,y=o*d,p=s*d,g=a*c,_=a*l,x=a*d,v=n[0],b=n[1],A=n[2];return t[0]=(1-(m+p))*v,t[1]=(f+x)*v,t[2]=(h-_)*v,t[3]=0,t[4]=(f-x)*b,t[5]=(1-(u+p))*b,t[6]=(y+g)*b,t[7]=0,t[8]=(h+_)*A,t[9]=(y-g)*A,t[10]=(1-(u+m))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Fu(t,e,r,n,i){var o=e[0],s=e[1],a=e[2],c=e[3],l=o+o,d=s+s,u=a+a,f=o*l,h=o*d,m=o*u,y=s*d,p=s*u,g=a*u,_=c*l,x=c*d,v=c*u,b=n[0],A=n[1],M=n[2],w=i[0],E=i[1],L=i[2],O=(1-(y+g))*b,N=(h+v)*b,H=(m-x)*b,C=(h-v)*A,Q=(1-(f+g))*A,Se=(p+_)*A,Bt=(m+x)*M,oi=(p-_)*M,Vr=(1-(f+y))*M;return t[0]=O,t[1]=N,t[2]=H,t[3]=0,t[4]=C,t[5]=Q,t[6]=Se,t[7]=0,t[8]=Bt,t[9]=oi,t[10]=Vr,t[11]=0,t[12]=r[0]+w-(O*w+C*E+Bt*L),t[13]=r[1]+E-(N*w+Q*E+oi*L),t[14]=r[2]+L-(H*w+Se*E+Vr*L),t[15]=1,t}function Pu(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=r+r,a=n+n,c=i+i,l=r*s,d=n*s,u=n*a,f=i*s,h=i*a,m=i*c,y=o*s,p=o*a,g=o*c;return t[0]=1-u-m,t[1]=d+g,t[2]=f-p,t[3]=0,t[4]=d-g,t[5]=1-l-m,t[6]=h+y,t[7]=0,t[8]=f+p,t[9]=h-y,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Bu(t,e,r,n,i,o,s){var a=1/(r-e),c=1/(i-n),l=1/(o-s);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(i+n)*c,t[10]=(s+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*l,t[15]=0,t}function tl(t,e,r,n,i){var o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){var s=1/(n-i);t[10]=(i+n)*s,t[14]=2*i*n*s}else t[10]=-1,t[14]=-2*n;return t}var Ou=tl;function Du(t,e,r,n,i){var o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){var s=1/(n-i);t[10]=i*s,t[14]=i*n*s}else t[10]=-1,t[14]=-n;return t}function Nu(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(i+o);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(i-o)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function rl(t,e,r,n,i,o,s){var a=1/(e-r),c=1/(n-i),l=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(i+n)*c,t[14]=(s+o)*l,t[15]=1,t}var ku=rl;function Uu(t,e,r,n,i,o,s){var a=1/(e-r),c=1/(n-i),l=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(i+n)*c,t[14]=o*l,t[15]=1,t}function Hu(t,e,r,n){var i,o,s,a,c,l,d,u,f,h,m=e[0],y=e[1],p=e[2],g=n[0],_=n[1],x=n[2],v=r[0],b=r[1],A=r[2];return Math.abs(m-v)<j&&Math.abs(y-b)<j&&Math.abs(p-A)<j?Jc(t):(d=m-v,u=y-b,f=p-A,h=1/Math.sqrt(d*d+u*u+f*f),d*=h,u*=h,f*=h,i=_*f-x*u,o=x*d-g*f,s=g*u-_*d,h=Math.sqrt(i*i+o*o+s*s),h?(h=1/h,i*=h,o*=h,s*=h):(i=0,o=0,s=0),a=u*s-f*o,c=f*i-d*s,l=d*o-u*i,h=Math.sqrt(a*a+c*c+l*l),h?(h=1/h,a*=h,c*=h,l*=h):(a=0,c=0,l=0),t[0]=i,t[1]=a,t[2]=d,t[3]=0,t[4]=o,t[5]=c,t[6]=u,t[7]=0,t[8]=s,t[9]=l,t[10]=f,t[11]=0,t[12]=-(i*m+o*y+s*p),t[13]=-(a*m+c*y+l*p),t[14]=-(d*m+u*y+f*p),t[15]=1,t)}function Vu(t,e,r,n){var i=e[0],o=e[1],s=e[2],a=n[0],c=n[1],l=n[2],d=i-r[0],u=o-r[1],f=s-r[2],h=d*d+u*u+f*f;h>0&&(h=1/Math.sqrt(h),d*=h,u*=h,f*=h);var m=c*f-l*u,y=l*d-a*f,p=a*u-c*d;return h=m*m+y*y+p*p,h>0&&(h=1/Math.sqrt(h),m*=h,y*=h,p*=h),t[0]=m,t[1]=y,t[2]=p,t[3]=0,t[4]=u*p-f*y,t[5]=f*m-d*p,t[6]=d*y-u*m,t[7]=0,t[8]=d,t[9]=u,t[10]=f,t[11]=0,t[12]=i,t[13]=o,t[14]=s,t[15]=1,t}function Gu(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function Wu(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function Xu(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function nl(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function Ku(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Yu(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function qu(t,e){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]}function $u(t,e){var r=t[0],n=t[1],i=t[2],o=t[3],s=t[4],a=t[5],c=t[6],l=t[7],d=t[8],u=t[9],f=t[10],h=t[11],m=t[12],y=t[13],p=t[14],g=t[15],_=e[0],x=e[1],v=e[2],b=e[3],A=e[4],M=e[5],w=e[6],E=e[7],L=e[8],O=e[9],N=e[10],H=e[11],C=e[12],Q=e[13],Se=e[14],Bt=e[15];return Math.abs(r-_)<=j*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(n-x)<=j*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(i-v)<=j*Math.max(1,Math.abs(i),Math.abs(v))&&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-M)<=j*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(c-w)<=j*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(l-E)<=j*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(d-L)<=j*Math.max(1,Math.abs(d),Math.abs(L))&&Math.abs(u-O)<=j*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(f-N)<=j*Math.max(1,Math.abs(f),Math.abs(N))&&Math.abs(h-H)<=j*Math.max(1,Math.abs(h),Math.abs(H))&&Math.abs(m-C)<=j*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-Q)<=j*Math.max(1,Math.abs(y),Math.abs(Q))&&Math.abs(p-Se)<=j*Math.max(1,Math.abs(p),Math.abs(Se))&&Math.abs(g-Bt)<=j*Math.max(1,Math.abs(g),Math.abs(Bt))}var ju=Qc,Ju=nl;var se={};qo(se,{add:()=>rf,angle:()=>Lf,bezier:()=>xf,ceil:()=>nf,clone:()=>Qu,copy:()=>ef,create:()=>il,cross:()=>mf,dist:()=>Pf,distance:()=>ll,div:()=>Ff,divide:()=>cl,dot:()=>ea,equals:()=>Cf,exactEquals:()=>If,floor:()=>of,forEach:()=>Nf,fromValues:()=>Zu,hermite:()=>gf,inverse:()=>ff,len:()=>Of,length:()=>ol,lerp:()=>pf,max:()=>af,min:()=>sf,mul:()=>zf,multiply:()=>al,negate:()=>uf,normalize:()=>hf,random:()=>bf,rotateX:()=>Af,rotateY:()=>Mf,rotateZ:()=>wf,round:()=>cf,scale:()=>lf,scaleAndAdd:()=>df,set:()=>tf,slerp:()=>yf,sqrDist:()=>Bf,sqrLen:()=>Df,squaredDistance:()=>dl,squaredLength:()=>ul,str:()=>Tf,sub:()=>Rf,subtract:()=>sl,transformMat3:()=>_f,transformMat4:()=>vf,transformQuat:()=>Sf,zero:()=>Ef});function il(){var t=new Ue(3);return Ue!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Qu(t){var e=new Ue(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ol(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function Zu(t,e,r){var n=new Ue(3);return n[0]=t,n[1]=e,n[2]=r,n}function ef(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function tf(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function rf(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function sl(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function al(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function cl(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function nf(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function of(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function sf(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function af(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function cf(t,e){return t[0]=Mo(e[0]),t[1]=Mo(e[1]),t[2]=Mo(e[2]),t}function lf(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function df(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function ll(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function dl(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function ul(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function uf(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function ff(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function hf(t,e){var r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function ea(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function mf(t,e,r){var n=e[0],i=e[1],o=e[2],s=r[0],a=r[1],c=r[2];return t[0]=i*c-o*a,t[1]=o*s-n*c,t[2]=n*a-i*s,t}function pf(t,e,r,n){var i=e[0],o=e[1],s=e[2];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=s+n*(r[2]-s),t}function yf(t,e,r,n){var i=Math.acos(Math.min(Math.max(ea(e,r),-1),1)),o=Math.sin(i),s=Math.sin((1-n)*i)/o,a=Math.sin(n*i)/o;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function gf(t,e,r,n,i,o){var s=o*o,a=s*(2*o-3)+1,c=s*(o-2)+o,l=s*(o-1),d=s*(3-2*o);return t[0]=e[0]*a+r[0]*c+n[0]*l+i[0]*d,t[1]=e[1]*a+r[1]*c+n[1]*l+i[1]*d,t[2]=e[2]*a+r[2]*c+n[2]*l+i[2]*d,t}function xf(t,e,r,n,i,o){var s=1-o,a=s*s,c=o*o,l=a*s,d=3*o*a,u=3*c*s,f=c*o;return t[0]=e[0]*l+r[0]*d+n[0]*u+i[0]*f,t[1]=e[1]*l+r[1]*d+n[1]*u+i[1]*f,t[2]=e[2]*l+r[2]*d+n[2]*u+i[2]*f,t}function bf(t,e){e=e===void 0?1:e;var r=Zs()*2*Math.PI,n=Zs()*2-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}function vf(t,e,r){var n=e[0],i=e[1],o=e[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/s,t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,t}function _f(t,e,r){var n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t}function Sf(t,e,r){var n=r[0],i=r[1],o=r[2],s=r[3],a=e[0],c=e[1],l=e[2],d=i*l-o*c,u=o*a-n*l,f=n*c-i*a;return d=d+d,u=u+u,f=f+f,t[0]=a+s*d+i*f-o*u,t[1]=c+s*u+o*d-n*f,t[2]=l+s*f+n*u-i*d,t}function Af(t,e,r,n){var i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[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),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Mf(t,e,r,n){var i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[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),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function wf(t,e,r,n){var i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[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],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Lf(t,e){var r=t[0],n=t[1],i=t[2],o=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+n*n+i*i)*(o*o+s*s+a*a)),l=c&&ea(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function Ef(t){return t[0]=0,t[1]=0,t[2]=0,t}function Tf(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function If(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Cf(t,e){var r=t[0],n=t[1],i=t[2],o=e[0],s=e[1],a=e[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 Rf=sl,zf=al,Ff=cl,Pf=ll,Bf=dl,Of=ol,Df=ul,Nf=(function(){var t=il();return function(e,r,n,i,o,s){var a,c;for(r||(r=3),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();var wo=class{constructor(){this._position=se.create();this._angles=se.create();this._bobAngles=se.create();this._bobOffset=se.create();this._kickAngles=se.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=ae.create();this._projectionMatrix=ae.create();this._viewProjectionMatrix=ae.create();this._dirty=!0}get position(){return this._position}set position(e){se.copy(this._position,e),this._dirty=!0}get angles(){return this._angles}set angles(e){se.copy(this._angles,e),this._dirty=!0}get bobAngles(){return this._bobAngles}set bobAngles(e){se.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){se.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){se.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let r=ae.create();return ae.perspective(r,e*sr,this._aspect,this._near,this._far),r}updateMatrices(){if(!this._dirty)return;ae.perspective(this._projectionMatrix,this._fov*sr,this._aspect,this._near,this._far);let e=ae.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*sr,s=n*sr,a=i*sr,c=ae.create();ae.identity(c),ae.rotateZ(c,c,-s),ae.rotateY(c,c,-o),ae.rotateX(c,c,-a);let l=ae.create();ae.multiply(l,e,c);let d=se.add(se.create(),this._position,this._bobOffset),u=se.negate(se.create(),d),f=se.create();se.transformMat4(f,u,c);let h=se.fromValues(f[1]||0,f[2]||0,f[0]||0);ae.copy(this._viewMatrix,l),this._viewMatrix[12]=h[0],this._viewMatrix[13]=h[1],this._viewMatrix[14]=h[2],ae.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var kf=[.2,.2,.2],Uf={x:0,y:0,z:1},Hf=[.8,.8,.8];function ta(t,e,r){return t+(e-t)*r}function Hr(t,e,r){return{x:ta(t.x,e.x,r),y:ta(t.y,e.y,r),z:ta(t.z,e.z,r)}}function Ur(t){return t<0?0:t>1?1:t}function ra(t){let e=[],r=[];for(let n of t.triangles){let i=e.length,[o,s,a]=n.indices,c=t.texCoords[o],l=t.texCoords[s],d=t.texCoords[a];if(!c||!l||!d)throw new Error(`Missing texCoord for triangle in surface ${t.name}`);e.push({vertexIndex:o,texCoord:[c.s,1-c.t]},{vertexIndex:s,texCoord:[l.s,1-l.t]},{vertexIndex:a,texCoord:[d.s,1-d.t]}),r.push(i,i+1,i+2)}return{vertices:e,indices:new Uint16Array(r)}}function Vf(t,e,r){let n=r?.ambient??kf,i=r?.directional??{direction:Uf,color:Hf},o=He(t),s=He(i.direction),a=Ur(o.x*s.x+o.y*s.y+o.z*s.z),c=n[0]+i.color[0]*a,l=n[1]+i.color[1]*a,d=n[2]+i.color[2]*a;if(r?.dynamicLights){let u=r.modelMatrix?va(r.modelMatrix,e):e;for(let f of r.dynamicLights){let h=u.x-f.origin.x,m=u.y-f.origin.y,y=u.z-f.origin.z,p=h*h+m*m+y*y,g=f.radius*f.radius;if(p<g&&g>0){let _=1-Math.sqrt(p)/f.radius,x=Math.sqrt(p),v=x>0?Ur(-(h*o.x+m*o.y+y*o.z)/x):0,b=Ur(_*v);c+=f.color[0]*b,l+=f.color[1]*b,d+=f.color[2]*b}}}return[Ur(c),Ur(l),Ur(d)]}function na(t,e,r,n){let i=t.vertices[r.frame0],o=t.vertices[r.frame1];if(!i||!o)throw new Error("Requested MD3 frames are out of range");let s=new Float32Array(e.vertices.length*12);return e.vertices.forEach((a,c)=>{let l=i[a.vertexIndex],d=o[a.vertexIndex];if(!l||!d)throw new Error(`Vertex index ${a.vertexIndex} missing for frame`);let u=Hr(l.position,d.position,r.lerp),f=He(Hr(l.normal,d.normal,r.lerp)),h=Vf(f,u,n),m=c*12;s[m]=u.x,s[m+1]=u.y,s[m+2]=u.z,s[m+3]=f.x,s[m+4]=f.y,s[m+5]=f.z,s[m+6]=a.texCoord[0],s[m+7]=a.texCoord[1],s[m+8]=h[0],s[m+9]=h[1],s[m+10]=h[2],s[m+11]=1}),s}function fl(t,e,r){let n=t.tags[0];if(!n)return null;let i=n.findIndex(y=>y.name===r);if(i===-1)return null;let o=t.tags[e.frame0]?.[i],s=t.tags[e.frame1]?.[i];if(!o||!s)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let a=Hr(o.origin,s.origin,e.lerp),c=He(Hr(o.axis[0],s.axis[0],e.lerp)),l=He(Hr(o.axis[1],s.axis[1],e.lerp)),d=He(Hr(o.axis[2],s.axis[2],e.lerp)),u=c,f=He({x:l.x-u.x*(u.x*l.x+u.y*l.y+u.z*l.z),y:l.y-u.y*(u.x*l.x+u.y*l.y+u.z*l.z),z:l.z-u.z*(u.x*l.x+u.y*l.y+u.z*l.z)}),h=He({x:u.y*f.z-u.z*f.y,y:u.z*f.x-u.x*f.z,z:u.x*f.y-u.y*f.x}),m=[u,f,h];return{origin:a,axis:m,matrix:_a(a,m)}}var ia=`#version 300 es
|
|
397
|
+
}`;function xm(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 dl(e,t,r){return e+(t-e)*r}function Hd(e,t,r){return{x:dl(e.x,t.x,r),y:dl(e.y,t.y,r),z:dl(e.z,t.z,r)}}function _m(e,t,r){return[e/r.skinWidth,1-t/r.skinHeight]}function hl(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:_m(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 ml(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=Hd(h.position,u.position,o),m=xm(Hd(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=hl(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=ml(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:ul,fragment:fl},{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,Ze=typeof Float32Array<"u"?Float32Array:Array,pl=Math.random;function Ts(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var SS=Math.PI/180,wS=180/Math.PI;var de={};da(de,{add:()=>ip,adjoint:()=>Lm,clone:()=>vm,copy:()=>Sm,create:()=>bm,decompose:()=>Wm,determinant:()=>Tm,equals:()=>lp,exactEquals:()=>ap,frob:()=>np,fromQuat:()=>$m,fromQuat2:()=>Hm,fromRotation:()=>Om,fromRotationTranslation:()=>Xd,fromRotationTranslationScale:()=>Xm,fromRotationTranslationScaleOrigin:()=>Km,fromScaling:()=>Pm,fromTranslation:()=>Dm,fromValues:()=>wm,fromXRotation:()=>Bm,fromYRotation:()=>Nm,fromZRotation:()=>Um,frustum:()=>Ym,getRotation:()=>Gm,getScaling:()=>Kd,getTranslation:()=>Vm,identity:()=>Gd,invert:()=>Em,lookAt:()=>ep,mul:()=>cp,multiply:()=>Wd,multiplyScalar:()=>op,multiplyScalarAndAdd:()=>sp,ortho:()=>Qm,orthoNO:()=>Yd,orthoZO:()=>Jm,perspective:()=>Zm,perspectiveFromFieldOfView:()=>jm,perspectiveNO:()=>$d,perspectiveZO:()=>qm,rotate:()=>zm,rotateX:()=>Cm,rotateY:()=>km,rotateZ:()=>Fm,scale:()=>Rm,set:()=>Am,str:()=>rp,sub:()=>dp,subtract:()=>Zd,targetTo:()=>tp,translate:()=>Im,transpose:()=>Mm});function bm(){var e=new Ze(16);return Ze!=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 vm(e){var t=new Ze(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 Sm(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 wm(e,t,r,n,i,o,s,a,d,l,c,h,u,f,m,g){var p=new Ze(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 Am(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 Gd(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 Mm(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 Em(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,C=h*x-f*g,U=u*x-f*p,z=S*U-_*C+y*T+b*w-A*L+v*E;return z?(z=1/z,e[0]=(a*U-d*C+l*T)*z,e[1]=(i*C-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*C-a*w+l*E)*z,e[9]=(n*w-r*C-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 Lm(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,C=h*x-f*g,U=u*x-f*p;return e[0]=a*U-d*C+l*T,e[1]=i*C-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*C-a*w+l*E,e[9]=n*w-r*C-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 Tm(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 Wd(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 Im(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 Rm(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 zm(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,C,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,C=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+_*C,e[5]=u*w+p*T+y*C,e[6]=f*w+x*T+b*C,e[7]=m*w+S*T+A*C,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 Cm(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 km(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 Fm(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 Dm(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 Pm(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 Om(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 Bm(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 Nm(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 Um(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 Xd(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 Hm(e,t){var r=new Ze(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),Xd(e,t,r),e}function Vm(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Kd(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 Gm(e,t){var r=new Ze(3);Kd(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 Wm(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 Xm(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 Km(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,C=(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]=C,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-(C*E+$*L+co*w),e[14]=r[2]+w-(U*E+Te*L+Tn*w),e[15]=1,e}function $m(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 Ym(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 $d(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 Zm=$d;function qm(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 jm(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 Yd(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 Qm=Yd;function Jm(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 ep(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?Gd(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 tp(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 rp(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 np(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 ip(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 Zd(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 op(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 sp(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 ap(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 lp(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],C=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-C)<=J*Math.max(1,Math.abs(u),Math.abs(C))&&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 cp=Wd,dp=Zd;var ce={};da(ce,{add:()=>pp,angle:()=>Bp,bezier:()=>Rp,ceil:()=>gp,clone:()=>up,copy:()=>hp,create:()=>qd,cross:()=>Ep,dist:()=>Kp,distance:()=>t0,div:()=>Xp,divide:()=>e0,dot:()=>gl,equals:()=>Vp,exactEquals:()=>Hp,floor:()=>yp,forEach:()=>qp,fromValues:()=>fp,hermite:()=>Ip,inverse:()=>Ap,len:()=>Yp,length:()=>jd,lerp:()=>Lp,max:()=>_p,min:()=>xp,mul:()=>Wp,multiply:()=>Jd,negate:()=>wp,normalize:()=>Mp,random:()=>zp,rotateX:()=>Dp,rotateY:()=>Pp,rotateZ:()=>Op,round:()=>bp,scale:()=>vp,scaleAndAdd:()=>Sp,set:()=>mp,slerp:()=>Tp,sqrDist:()=>$p,sqrLen:()=>Zp,squaredDistance:()=>r0,squaredLength:()=>n0,str:()=>Up,sub:()=>Gp,subtract:()=>Qd,transformMat3:()=>kp,transformMat4:()=>Cp,transformQuat:()=>Fp,zero:()=>Np});function qd(){var e=new Ze(3);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function up(e){var t=new Ze(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function jd(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function fp(e,t,r){var n=new Ze(3);return n[0]=e,n[1]=t,n[2]=r,n}function hp(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function mp(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function pp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Qd(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function Jd(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function e0(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function gp(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function yp(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function xp(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 _p(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 bp(e,t){return e[0]=Ts(t[0]),e[1]=Ts(t[1]),e[2]=Ts(t[2]),e}function vp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Sp(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 t0(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 r0(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 n0(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function wp(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Ap(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Mp(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 gl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ep(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 Lp(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 Tp(e,t,r,n){var i=Math.acos(Math.min(Math.max(gl(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 Ip(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 Rp(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 zp(e,t){t=t===void 0?1:t;var r=pl()*2*Math.PI,n=pl()*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 Cp(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 kp(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 Fp(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 Dp(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 Pp(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 Op(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 Bp(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&&gl(e,t)/d;return Math.acos(Math.min(Math.max(l,-1),1))}function Np(e){return e[0]=0,e[1]=0,e[2]=0,e}function Up(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Hp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Vp(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 Gp=Qd,Wp=Jd,Xp=e0,Kp=t0,$p=r0,Yp=jd,Zp=n0,qp=(function(){var e=qd();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 jp=[.2,.2,.2],Qp={x:0,y:0,z:1},Jp=[.8,.8,.8];function yl(e,t,r){return e+(t-e)*r}function _n(e,t,r){return{x:yl(e.x,t.x,r),y:yl(e.y,t.y,r),z:yl(e.z,t.z,r)}}function xn(e){return e<0?0:e>1?1:e}function xl(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 e1(e,t,r){let n=r?.ambient??jp,i=r?.directional??{direction:Qp,color:Jp},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?hc(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 _l(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=e1(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 i0(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:mc(a,m)}}var bl=`#version 300 es
|
|
367
398
|
precision highp float;
|
|
368
399
|
|
|
369
400
|
layout(location = 0) in vec3 a_position;
|
|
@@ -382,7 +413,7 @@ void main() {
|
|
|
382
413
|
v_color = a_color;
|
|
383
414
|
v_position = a_position; // Model space, assuming single mesh pass
|
|
384
415
|
gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
|
|
385
|
-
}`,
|
|
416
|
+
}`,vl=`#version 300 es
|
|
386
417
|
precision highp float;
|
|
387
418
|
|
|
388
419
|
in vec2 v_texCoord;
|
|
@@ -418,7 +449,7 @@ void main() {
|
|
|
418
449
|
}
|
|
419
450
|
|
|
420
451
|
o_color = finalColor;
|
|
421
|
-
}`,
|
|
452
|
+
}`,Oi=class{constructor(t,r,n,i){this.gl=t,this.geometry=xl(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=_l(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()}},zs=class{constructor(t){this.gl=t,this.program=Me.create(t,{vertex:bl,fragment:vl},{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 t1=[1,1,1,1],Cs=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??t1,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,C=[{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]];C.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}},Sl=`#version 300 es
|
|
422
453
|
precision highp float;
|
|
423
454
|
|
|
424
455
|
layout(location = 0) in vec3 a_position;
|
|
@@ -434,7 +465,7 @@ void main() {
|
|
|
434
465
|
v_uv = a_uv;
|
|
435
466
|
v_color = a_color;
|
|
436
467
|
gl_Position = u_viewProjection * vec4(a_position, 1.0);
|
|
437
|
-
}`,
|
|
468
|
+
}`,wl=`#version 300 es
|
|
438
469
|
precision highp float;
|
|
439
470
|
|
|
440
471
|
in vec2 v_uv;
|
|
@@ -446,5 +477,10 @@ void main() {
|
|
|
446
477
|
float dist = distance(v_uv, vec2(0.5));
|
|
447
478
|
float alpha = v_color.a * (1.0 - smoothstep(0.35, 0.5, dist));
|
|
448
479
|
o_color = vec4(v_color.rgb, alpha);
|
|
449
|
-
}`,Io=class{constructor(e,r){this.vertexCapacity=0;this.indexCapacity=0;this.gl=e,this.system=r,this.program=ve.create(e,{vertex:sa,fragment:aa}),this.vertexBuffer=new _e(e,e.DYNAMIC_DRAW),this.indexBuffer=new fe(e,e.DYNAMIC_DRAW),this.vertexArray=new we(e),this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:36,offset:0},{index:1,size:2,type:e.FLOAT,stride:36,offset:12},{index:2,size:4,type:e.FLOAT,stride:36,offset:20}],this.vertexBuffer)}render(e){let r=this.system.buildMesh(e.viewRight,e.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,e.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 hl(t){let{system:e,origin:r,normal:n={x:0,y:0,z:1}}=t;for(let i=0;i<12;i+=1){let o=200+e.random()*180,s=e.random()*.35;e.spawn({position:r,velocity:{x:n.x*o+(e.random()-.5)*80,y:n.y*o+(e.random()-.5)*80,z:Math.max(n.z*o,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+e.random()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let i=0;i<8;i+=1)e.spawn({position:r,velocity:{x:(e.random()-.5)*40,y:(e.random()-.5)*40,z:80+e.random()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function ml(t){let{system:e,origin:r}=t;for(let n=0;n<40;n+=1){let i=e.random()*Math.PI*2,o=Math.acos(2*e.random()-1),s=220+e.random()*260,a={x:Math.sin(o)*Math.cos(i),y:Math.sin(o)*Math.sin(i),z:Math.cos(o)};e.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)e.spawn({position:r,velocity:{x:(e.random()-.5)*30,y:(e.random()-.5)*30,z:120+e.random()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function pl(t){let{system:e,origin:r,direction:n={x:0,y:0,z:1}}=t;for(let i=0;i<24;i+=1){let o=120+e.random()*180;e.spawn({position:r,velocity:{x:n.x*o+(e.random()-.5)*70,y:n.y*o+(e.random()-.5)*70,z:n.z*o+e.random()*80},color:[.6,0,0,.95],size:3,lifetime:.8,gravity:900,damping:1,bounce:.2,blendMode:"alpha",fade:!0})}}function yl(t){let{system:e,origin:r}=t;for(let n=0;n<30;n+=1){let i=e.random()*Math.PI*2,o=8+e.random()*8;e.spawn({position:r,velocity:{x:Math.cos(i)*o,y:Math.sin(i)*o,z:100+e.random()*80},color:[.4,.6,1,.9],size:4,lifetime:.5,gravity:300,damping:2,blendMode:"additive",fade:!0})}}function gl(t){let{system:e,origin:r,direction:n={x:1,y:0,z:0}}=t;for(let i=0;i<10;i+=1){let o=350+e.random()*100;e.spawn({position:r,velocity:{x:n.x*o+(e.random()-.5)*30,y:n.y*o+(e.random()-.5)*30,z:n.z*o+(e.random()-.5)*30},color:[1,.8,.3,1],size:3,lifetime:.25,gravity:200,damping:1,blendMode:"additive",fade:!0})}}function xl(t){let{system:e,origin:r,direction:n={x:0,y:0,z:0}}=t;for(let i=0;i<6;i+=1)e.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:(e.random()-.5)*15,y:(e.random()-.5)*15,z:20+e.random()*15},color:[.6,.6,.6,.8],size:2.2,lifetime:.6,gravity:200,damping:1.5,blendMode:"alpha",fade:!0})}var tr=class{constructor(e){this.buffer=e,this.view=new DataView(e),this.offset=0}hasMore(){return this.offset<this.buffer.byteLength}readNextBlock(){if(this.offset+4>this.buffer.byteLength)return null;let e=this.view.getInt32(this.offset,!0);if(this.offset+=4,e<0||e>262144)return console.warn(`DemoReader: Invalid block length ${e} at offset ${this.offset-4}`),null;if(this.offset+e>this.buffer.byteLength)return console.warn(`DemoReader: Incomplete block. Expected ${e} bytes, but only ${this.buffer.byteLength-this.offset} remain.`),null;let r=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,{length:e,data:new Ca(r)}}reset(){this.offset=0}getOffset(){return this.offset}};var Wf=2023,Ro=1,zo=2,Fo=4,Po=8,Bo=16,Oo=32,ca=64,Xf=128,Kf=256,Do=512,No=1024,ko=2048,Qn=4096,Zn=16384,Yf=32768,ei=65536,Uo=1<<17,ti=1<<18,ri=1<<19,Ho=1<<20,Vo=1<<21,Go=1<<22,qf=1<<23,Wo=1<<24,ni=1<<25,Xo=1<<26,Ko=1<<27,bl=8192;var $f=1,jf=2,Jf=128,rr=()=>({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,alpha:0,scale:0,instanceBits:0,loopVolume:0,loopAttenuation:0,owner:0,oldFrame:0}),Co=()=>({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}),nr=class{constructor(e,r){this.protocolVersion=0;this.isDemo=$f;this.stream=e,this.handler=r}translateCommand(e){if(this.protocolVersion===0){if(e===7)return R.serverdata;if(e===12)return R.serverdata}if(this.protocolVersion===25){if(e>=7&&e<=15)return e+5;if(e===1)return R.print;if(e===2)return R.stufftext;if(e===3)return R.sound;if(e===4)return R.nop;if(e===5)return R.disconnect;if(e===6)return R.reconnect;if(e===16)return R.temp_entity}return this.protocolVersion===Wf,e}parseMessage(){for(;this.stream.hasMore();){let e=this.stream.readByte();if(e===-1)break;let r=e;e=this.translateCommand(e);try{switch(e){case R.nop:break;case R.disconnect:this.handler&&this.handler.onDisconnect&&this.handler.onDisconnect();break;case R.reconnect:this.handler&&this.handler.onReconnect&&this.handler.onReconnect();break;case R.print:this.parsePrint();break;case R.serverdata:this.parseServerData();break;case R.configstring:this.parseConfigString();break;case R.spawnbaseline:this.parseSpawnBaseline();break;case R.centerprint:this.parseCenterPrint();break;case R.download:this.parseDownload();break;case R.frame:this.parseFrame();break;case R.packetentities:this.parsePacketEntities(!1);break;case R.deltapacketentities:this.parsePacketEntities(!0);break;case R.playerinfo:this.parsePlayerState();break;case R.stufftext:this.parseStuffText();break;case R.layout:this.parseLayout();break;case R.inventory:this.parseInventory();break;case R.sound:this.parseSound();break;case R.muzzleflash:this.parseMuzzleFlash();break;case R.muzzleflash2:this.parseMuzzleFlash2();break;case R.temp_entity:this.parseTempEntity();break;case R.splitclient:break;case R.configblast:break;case R.spawnbaselineblast:break;case R.level_restart:this.handler&&this.handler.onLevelRestart&&this.handler.onLevelRestart();break;case R.damage:this.parseDamage();break;case R.locprint:break;case R.fog:this.parseFog();break;case R.waitingforplayers:this.handler&&this.handler.onWaitingForPlayers&&this.handler.onWaitingForPlayers();break;case R.bot_chat:break;case R.poi:break;case R.help_path:break;case R.muzzleflash3:this.parseMuzzleFlash3();break;case R.achievement:break;default:console.warn(`Unknown server command: ${r} (translated: ${e}) at offset ${this.stream.getPosition()-1}`);return}}catch(n){console.warn(`Error parsing command ${e}: ${n.message}`);return}}}parsePrint(){let e=this.stream.readByte(),r=this.stream.readString();this.handler&&this.handler.onPrint(e,r)}parseStuffText(){let e=this.stream.readString();this.handler&&this.handler.onStuffText(e)}parseLayout(){let e=this.stream.readString();this.handler&&this.handler.onLayout(e)}parseCenterPrint(){let e=this.stream.readString();this.handler&&this.handler.onCenterPrint(e)}parseServerData(){this.protocolVersion=this.stream.readLong();let e=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,e,r,n,i,o):console.log(`Server Data: Protocol ${this.protocolVersion}, Level ${o}, GameDir ${n}`)}parseConfigString(){let e=this.stream.readShort(),r=this.stream.readString();this.handler&&this.handler.onConfigString(e,r)}parseDownload(){let e=this.stream.readShort(),r=this.stream.readByte(),n;e>0&&(n=this.stream.readData(e)),this.handler&&this.handler.onDownload(e,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 e=this.stream.readByte(),r=this.stream.readByte(),n,i,o,s,a;if(e&1&&(n=this.stream.readByte()),e&2&&(i=this.stream.readByte()),e&16&&(o=this.stream.readByte()),e&8&&(s=this.stream.readShort()),e&4){let c={x:0,y:0,z:0};this.stream.readPos(c),a=c}this.handler&&this.handler.onSound(e,r,n,i,o,s,a)}parseMuzzleFlash(){let e=this.stream.readShort(),r=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash(e,r)}parseMuzzleFlash2(){let e=this.stream.readShort(),r=this.stream.readByte();this.handler&&this.handler.onMuzzleFlash2(e,r)}parseMuzzleFlash3(){let e=this.stream.readShort(),r=this.stream.readShort();this.handler&&this.handler.onMuzzleFlash3&&this.handler.onMuzzleFlash3(e,r)}parseFog(){let e=this.stream.readByte();if(e&128){let n=this.stream.readByte();e|=n<<8}let r={};e&1&&(r.density=this.stream.readFloat(),r.skyfactor=this.stream.readByte()),e&2&&(r.red=this.stream.readByte()),e&4&&(r.green=this.stream.readByte()),e&8&&(r.blue=this.stream.readByte()),e&16&&(r.time=this.stream.readShort()),e&32&&(r.hf_falloff=this.stream.readFloat()),e&64&&(r.hf_density=this.stream.readFloat()),e&256&&(r.hf_start_r=this.stream.readByte()),e&512&&(r.hf_start_g=this.stream.readByte()),e&1024&&(r.hf_start_b=this.stream.readByte()),e&2048&&(r.hf_start_dist=this.stream.readLong()),e&4096&&(r.hf_end_r=this.stream.readByte()),e&8192&&(r.hf_end_g=this.stream.readByte()),e&16384&&(r.hf_end_b=this.stream.readByte()),e&32768&&(r.hf_end_dist=this.stream.readLong()),this.handler&&this.handler.onFog&&this.handler.onFog(r)}parseDamage(){let e=this.stream.readByte(),r=[];for(let n=0;n<e;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,c=(i&64)!==0,l=(i&128)!==0;r.push({damage:s,health:a,armor:c,power:l,dir:o})}this.handler&&this.handler.onDamage&&this.handler.onDamage(r)}parseTempEntity(){let e=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,c,l;switch(e){case T.EXPLOSION1:case T.EXPLOSION2:case T.ROCKET_EXPLOSION:case T.GRENADE_EXPLOSION:case T.ROCKET_EXPLOSION_WATER:case T.GRENADE_EXPLOSION_WATER:case T.BFG_EXPLOSION:case T.BFG_BIGEXPLOSION:case T.BOSSTPORT:case T.PLASMA_EXPLOSION:case T.PLAIN_EXPLOSION:case T.CHAINFIST_SMOKE:case T.TRACKER_EXPLOSION:case T.TELEPORT_EFFECT:case T.DBALL_GOAL:case T.NUKEBLAST:case T.WIDOWSPLASH:case T.EXPLOSION1_BIG:case T.EXPLOSION1_NP:this.stream.readPos(r);break;case T.GUNSHOT:case T.BLOOD:case T.BLASTER:case T.SHOTGUN:case T.SPARKS:case T.BULLET_SPARKS:case T.SCREEN_SPARKS:case T.SHIELD_SPARKS:case T.BLASTER2:case T.FLECHETTE:case T.MOREBLOOD:case T.ELECTRIC_SPARKS:case T.HEATBEAM_SPARKS:case T.HEATBEAM_STEAM:this.stream.readPos(r),this.stream.readDir(i);break;case T.SPLASH:case T.LASER_SPARKS:case T.WELDING_SPARKS:case T.TUNNEL_SPARKS:o=this.stream.readByte(),this.stream.readPos(r),this.stream.readDir(i),s=this.stream.readByte();break;case T.BLUEHYPERBLASTER:this.protocolVersion>=32?(this.stream.readPos(r),this.stream.readPos(n)):(this.stream.readPos(r),this.stream.readDir(i));break;case T.GREENBLOOD:this.protocolVersion>=32?(this.stream.readPos(r),this.stream.readDir(i)):(this.stream.readPos(r),this.stream.readPos(n));break;case T.RAILTRAIL:case T.BUBBLETRAIL:case T.BFG_LASER:case T.DEBUGTRAIL:case T.BUBBLETRAIL2:this.stream.readPos(r),this.stream.readPos(n);break;case T.PARASITE_ATTACK:case T.MEDIC_CABLE_ATTACK:this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n);break;case T.GRAPPLE_CABLE:a=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n),this.stream.readPos(i);break;case T.LIGHTNING:c=this.stream.readShort(),l=this.stream.readShort(),this.stream.readPos(r),this.stream.readPos(n);break;case T.FLASHLIGHT:this.stream.readPos(r),a=this.stream.readShort();break;case T.FORCEWALL:this.stream.readPos(r),this.stream.readPos(n),s=this.stream.readByte();break;case T.STEAM:let d=this.stream.readShort();o=this.stream.readByte(),this.stream.readPos(r),this.stream.readDir(i),s=this.stream.readByte(),this.stream.readShort(),d!==-1&&this.stream.readLong();break;case T.WIDOWBEAMOUT:this.stream.readShort();case T.HEATBEAM:case T.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(e,r,n,i,o,s,a,c,l)}parseSpawnBaseline(){let e=this.parseEntityBits(),r=rr();this.parseDelta(rr(),r,e.number,e.bits),this.handler&&this.handler.onSpawnBaseline(r)}parseFrame(){let e=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!==R.playerinfo)throw new Error(`Expected svc_playerinfo after svc_frame, got ${s}`);let a=this.parsePlayerState();if(this.isDemo===Jf){let c=this.stream.readByte();for(let l=0;l<c;l++)this.stream.readByte()}this.isDemo===jf&&this.stream.readLong(),this.handler&&this.handler.onFrame({serverFrame:e,deltaFrame:r,surpressCount:n,areaBytes:i,areaBits:o,playerState:a,packetEntities:{delta:!1,entities:[]}})}parsePlayerState(){let e=Co(),r=this.stream.readShort();r&1&&(e.pm_type=this.stream.readByte()),r&2&&(e.origin.x=this.stream.readShort()*.125,e.origin.y=this.stream.readShort()*.125,e.origin.z=this.stream.readShort()*.125),r&4&&(e.velocity.x=this.stream.readShort()*.125,e.velocity.y=this.stream.readShort()*.125,e.velocity.z=this.stream.readShort()*.125),r&8&&(e.pm_time=this.stream.readByte()),r&16&&(e.pm_flags=this.stream.readByte()),r&32&&(e.gravity=this.stream.readShort()),r&64&&(e.delta_angles.x=this.stream.readShort()*(180/32768),e.delta_angles.y=this.stream.readShort()*(180/32768),e.delta_angles.z=this.stream.readShort()*(180/32768)),r&128&&(e.viewoffset.x=this.stream.readChar()*.25,e.viewoffset.y=this.stream.readChar()*.25,e.viewoffset.z=this.stream.readChar()*.25),r&256&&(e.viewangles.x=this.stream.readAngle16(),e.viewangles.y=this.stream.readAngle16(),e.viewangles.z=this.stream.readAngle16()),r&512&&(e.kick_angles.x=this.stream.readChar()*.25,e.kick_angles.y=this.stream.readChar()*.25,e.kick_angles.z=this.stream.readChar()*.25),r&4096&&(e.gun_index=this.stream.readByte()),r&8192&&(e.gun_frame=this.stream.readByte(),e.gun_offset.x=this.stream.readChar()*.25,e.gun_offset.y=this.stream.readChar()*.25,e.gun_offset.z=this.stream.readChar()*.25,e.gun_angles.x=this.stream.readChar()*.25,e.gun_angles.y=this.stream.readChar()*.25,e.gun_angles.z=this.stream.readChar()*.25),r&1024&&(e.blend[0]=this.stream.readByte(),e.blend[1]=this.stream.readByte(),e.blend[2]=this.stream.readByte(),e.blend[3]=this.stream.readByte()),r&2048&&(e.fov=this.stream.readByte()),r&16384&&(e.rdflags=this.stream.readByte());let n=this.stream.readLong();for(let i=0;i<32;i++)n&1<<i&&(e.stats[i]=this.stream.readShort());return e}parsePacketEntities(e){let r=this.collectPacketEntities();this.handler&&this.handler.onFrame({serverFrame:0,deltaFrame:0,surpressCount:0,areaBytes:0,areaBits:new Uint8Array,playerState:Co(),packetEntities:{delta:e,entities:r}})}collectPacketEntities(){let e=[];for(;;){let r=this.parseEntityBits();if(r.number===0)break;let n=rr();this.parseDelta(rr(),n,r.number,r.bits),e.push(n)}return e}parseEntityBits(){let e=this.stream.readByte();e&Xf&&(e|=this.stream.readByte()<<8),e&Yf&&(e|=this.stream.readByte()<<16),e&qf&&(e|=this.stream.readByte()<<24);let r;return e&Kf?r=this.stream.readShort():r=this.stream.readByte(),{number:r,bits:e}}parseDelta(e,r,n,i){r.number=e.number,r.modelindex=e.modelindex,r.modelindex2=e.modelindex2,r.modelindex3=e.modelindex3,r.modelindex4=e.modelindex4,r.frame=e.frame,r.skinnum=e.skinnum,r.effects=e.effects,r.renderfx=e.renderfx,r.origin.x=e.origin.x,r.origin.y=e.origin.y,r.origin.z=e.origin.z,r.old_origin.x=e.origin.x,r.old_origin.y=e.origin.y,r.old_origin.z=e.origin.z,r.angles.x=e.angles.x,r.angles.y=e.angles.y,r.angles.z=e.angles.z,r.sound=e.sound,r.event=e.event,r.solid=e.solid,r.number=n,r.bits=i,i&ko&&(r.modelindex=this.stream.readByte()),i&Ho&&(r.modelindex2=this.stream.readByte()),i&Vo&&(r.modelindex3=this.stream.readByte()),i&Go&&(r.modelindex4=this.stream.readByte()),i&Bo&&(r.frame=this.stream.readByte()),i&Uo&&(r.frame=this.stream.readShort()),i&ei&&i&ni?r.skinnum=this.stream.readLong():i&ei?r.skinnum=this.stream.readByte():i&ni&&(r.skinnum=this.stream.readShort()),i&Zn&&i&ri?r.effects=this.stream.readLong():i&Zn?r.effects=this.stream.readByte():i&ri&&(r.effects=this.stream.readShort()),i&Qn&&i&ti?r.renderfx=this.stream.readLong():i&Qn?r.renderfx=this.stream.readByte():i&ti&&(r.renderfx=this.stream.readShort()),i&Ro&&(r.origin.x=this.stream.readCoord()),i&zo&&(r.origin.y=this.stream.readCoord()),i&Do&&(r.origin.z=this.stream.readCoord()),i&No&&(r.angles.x=this.stream.readAngle()),i&Fo&&(r.angles.y=this.stream.readAngle()),i&Po&&(r.angles.z=this.stream.readAngle()),i&Wo&&this.stream.readPos(r.old_origin),i&Xo&&(r.sound=this.stream.readByte()),i&Oo?r.event=this.stream.readByte():r.event=0,i&Ko&&(r.solid=this.stream.readShort())}};var Yo=(i=>(i[i.Stopped=0]="Stopped",i[i.Playing=1]="Playing",i[i.Paused=2]="Paused",i[i.Finished=3]="Finished",i))(Yo||{}),ii=class{constructor(){this.reader=null;this.state=0;this.playbackSpeed=1;this.accumulatedTime=0;this.frameDuration=100}setHandler(e){this.handler=e}loadDemo(e){this.reader=new tr(e),this.state=0,this.accumulatedTime=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}update(e){if(!(this.state!==1||!this.reader))for(this.accumulatedTime+=e*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}new nr(r.data,this.handler).parseMessage(),this.accumulatedTime-=this.frameDuration}}getState(){return this.state}};function Qf(t){return{init(){t.trace({x:0,y:0,z:0},{x:0,y:0,z:0})},shutdown(){},createMainLoop(e,r){return new Ot(e,r)}}}return Il(Zf);})();
|
|
480
|
+
}`,ks=class{constructor(t,r){this.vertexCapacity=0;this.indexCapacity=0;this.gl=t,this.system=r,this.program=Me.create(t,{vertex:Sl,fragment:wl}),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 o0(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 s0(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 a0(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 l0(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 c0(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 d0(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>262144)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 r1=0,Z0=1,n1=2,i1=3,o1=258,$l=29,Qi=256,Wi=Qi+1+$l,Sn=30,Yl=19,q0=2*Wi+1,Mr=15,Al=16,s1=7,Zl=256,j0=16,Q0=17,J0=18,Bl=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]),a1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),eu=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l1=512,It=new Array((Wi+2)*2);Mn(It);var Hi=new Array(Sn*2);Mn(Hi);var Xi=new Array(l1);Mn(Xi);var Ki=new Array(o1-i1+1);Mn(Ki);var ql=new Array($l);Mn(ql);var Us=new Array(Sn);Mn(Us);function Ml(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 tu,ru,nu;function El(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var iu=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},Ce=(e,t,r)=>{e.bi_valid>Al-r?(e.bi_buf|=t<<e.bi_valid&65535,$i(e,e.bi_buf),e.bi_buf=t>>Al-e.bi_valid,e.bi_valid+=r-Al):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},ft=(e,t,r)=>{Ce(e,r[t*2],r[t*2+1])},ou=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},c1=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)},d1=(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<q0;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--)}},su=(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]=ou(n[a]++,a))}},u1=()=>{let e,t,r,n,i,o=new Array(Mr+1);for(r=0,n=0;n<$l-1;n++)for(ql[n]=r,e=0;e<1<<Bl[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(su(It,Wi+1,o),e=0;e<Sn;e++)Hi[e*2+1]=5,Hi[e*2]=ou(e,5);tu=new Ml(It,Bl,Qi+1,Wi,Mr),ru=new Ml(Hi,Ns,0,Sn,Mr),nu=new Ml(new Array(0),a1,0,Yl,s1)},au=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[Zl*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},lu=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},u0=(e,t,r,n)=>{let i=t*2,o=r*2;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]},Ll=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&u0(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!u0(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},f0=(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=Bl[s],a!==0&&(i-=ql[s],Ce(e,i,a)),n--,s=iu(n),ft(e,s,r),a=Ns[s],a!==0&&(n-=Us[s],Ce(e,n,a)));while(o<e.sym_next);ft(e,Zl,t)},Nl=(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=q0,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--)Ll(e,r,s);l=o;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ll(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++,Ll(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],d1(e,t),su(r,d,e.bl_count)},h0=(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[j0*2]++):a<=10?e.bl_tree[Q0*2]++:e.bl_tree[J0*2]++,a=0,i=o,s===0?(d=138,l=3):o===s?(d=6,l=3):(d=7,l=4))},m0=(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,j0,e.bl_tree),Ce(e,a-3,2)):a<=10?(ft(e,Q0,e.bl_tree),Ce(e,a-3,3)):(ft(e,J0,e.bl_tree),Ce(e,a-11,7));a=0,i=o,s===0?(d=138,l=3):o===s?(d=6,l=3):(d=7,l=4)}},f1=e=>{let t;for(h0(e,e.dyn_ltree,e.l_desc.max_code),h0(e,e.dyn_dtree,e.d_desc.max_code),Nl(e,e.bl_desc),t=Yl-1;t>=3&&e.bl_tree[eu[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},h1=(e,t,r,n)=>{let i;for(Ce(e,t-257,5),Ce(e,r-1,5),Ce(e,n-4,4),i=0;i<n;i++)Ce(e,e.bl_tree[eu[i]*2+1],3);m0(e,e.dyn_ltree,t-1),m0(e,e.dyn_dtree,r-1)},m1=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},p0=!1,p1=e=>{p0||(u1(),p0=!0),e.l_desc=new El(e.dyn_ltree,tu),e.d_desc=new El(e.dyn_dtree,ru),e.bl_desc=new El(e.bl_tree,nu),e.bi_buf=0,e.bi_valid=0,au(e)},cu=(e,t,r,n)=>{Ce(e,(r1<<1)+(n?1:0),3),lu(e),$i(e,r),$i(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},g1=e=>{Ce(e,Z0<<1,3),ft(e,Zl,It),c1(e)},y1=(e,t,r,n)=>{let i,o,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=m1(e)),Nl(e,e.l_desc),Nl(e,e.d_desc),s=f1(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?cu(e,t,r,n):e.strategy===4||o===i?(Ce(e,(Z0<<1)+(n?1:0),3),f0(e,It,Hi)):(Ce(e,(n1<<1)+(n?1:0),3),h1(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),f0(e,e.dyn_ltree,e.dyn_dtree)),au(e),n&&lu(e)},x1=(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[iu(t)*2]++),e.sym_next===e.sym_end),_1=p1,b1=cu,v1=y1,S1=x1,w1=g1,A1={_tr_init:_1,_tr_stored_block:b1,_tr_flush_block:v1,_tr_tally:S1,_tr_align:w1},M1=(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},Yi=M1,E1=()=>{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},L1=new Uint32Array(E1()),T1=(e,t,r,n)=>{let i=L1,o=n+r;e^=-1;for(let s=n;s<o;s++)e=e>>>8^i[(e^t[s])&255];return e^-1},fe=T1,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:I1,_tr_stored_block:Ul,_tr_flush_block:R1,_tr_tally:tr,_tr_align:z1}=A1,{Z_NO_FLUSH:rr,Z_PARTIAL_FLUSH:C1,Z_FULL_FLUSH:k1,Z_FINISH:qe,Z_BLOCK:g0,Z_OK:he,Z_STREAM_END:y0,Z_STREAM_ERROR:ht,Z_DATA_ERROR:F1,Z_BUF_ERROR:Tl,Z_DEFAULT_COMPRESSION:D1,Z_FILTERED:P1,Z_HUFFMAN_ONLY:Fs,Z_RLE:O1,Z_FIXED:B1,Z_DEFAULT_STRATEGY:N1,Z_UNKNOWN:U1,Z_DEFLATED:Gs}=zr,H1=9,V1=15,G1=8,W1=29,X1=256,Hl=X1+1+W1,K1=30,$1=19,Y1=2*Hl+1,Z1=15,V=3,er=258,mt=er+V+1,q1=32,wn=42,jl=57,Vl=69,Gl=73,Wl=91,Xl=103,Er=113,Ni=666,Le=1,En=2,Ir=3,Ln=4,j1=3,Lr=(e,t)=>(e.msg=Tr[t],t),x0=e=>e*2-(e>4?9:0),Jt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Q1=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)},J1=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,nr=J1,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)=>{R1(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},Kl=(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=Yi(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)},du=(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),Q1(e),n+=t),e.strm.avail_in===0)break;if(r=Kl(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)},uu=(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,Ul(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&&(Kl(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&&(Kl(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,Ul(e,e.block_start,n,s),e.block_start+=n,Be(e.strm)),s?Ir:Le)},Il=(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=du(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=du(e,r),e.match_length<=5&&(e.strategy===P1||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},eg=(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},tg=(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,uu),new ut(4,4,8,4,Il),new ut(4,5,16,8,Il),new ut(4,6,32,32,Il),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)],rg=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 ng(){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(Y1*2),this.dyn_dtree=new Uint16Array((2*K1+1)*2),this.bl_tree=new Uint16Array((2*$1+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(Z1+1),this.heap=new Uint16Array(2*Hl+1),Jt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Hl+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!==jl&&t.status!==Vl&&t.status!==Gl&&t.status!==Wl&&t.status!==Xl&&t.status!==Er&&t.status!==Ni?1:0},fu=e=>{if(Ji(e))return Lr(e,ht);e.total_in=e.total_out=0,e.data_type=U1;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?jl:t.wrap?wn:Er,e.adler=t.wrap===2?0:1,t.last_flush=-2,I1(t),he},hu=e=>{let t=fu(e);return t===he&&rg(e.state),t},ig=(e,t)=>Ji(e)||e.state.wrap!==2?ht:(e.state.gzhead=t,he),mu=(e,t,r,n,i,o)=>{if(!e)return ht;let s=1;if(t===D1&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>H1||r!==Gs||n<8||n>15||t<0||t>9||o<0||o>B1||n===8&&s!==1)return Lr(e,ht);n===8&&(n=9);let a=new ng;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,hu(e)},og=(e,t)=>mu(e,t,Gs,V1,G1,N1),sg=(e,t)=>{if(Ji(e)||t>g0||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?Tl: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&&x0(t)<=x0(n)&&t!==qe)return Lr(e,Tl);if(r.status===Ni&&e.avail_in!==0)return Lr(e,Tl);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|=q1),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===jl){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=Vl;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,j1),r.status=Er,Be(e),r.pending!==0)return r.last_flush=-1,he}if(r.status===Vl){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=Gl}if(r.status===Gl){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=Wl}if(r.status===Wl){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=Xl}if(r.status===Xl){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?uu(r,t):r.strategy===Fs?tg(r,t):r.strategy===O1?eg(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===C1?z1(r):t!==g0&&(Ul(r,0,0,!1),t===k1&&(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?y0:(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:y0)},ag=e=>{if(Ji(e))return ht;let t=e.state.status;return e.state=null,t===Er?Lr(e,F1):he},lg=(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=Yi(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},cg=og,dg=mu,ug=hu,fg=fu,hg=ig,mg=sg,pg=ag,gg=lg,yg="pako deflate (from Nodeca project)",Vi={deflateInit:cg,deflateInit2:dg,deflateReset:ug,deflateResetKeep:fg,deflateSetHeader:hg,deflate:mg,deflateEnd:pg,deflateSetDictionary:gg,deflateInfo:yg},xg=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_g=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)xg(r,n)&&(e[n]=r[n])}}return e},bg=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:_g,flattenChunks:bg},pu=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{pu=!1}var Zi=new Uint8Array(256);for(let e=0;e<256;e++)Zi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Zi[254]=Zi[254]=1;var vg=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},Sg=(e,t)=>{if(t<65534&&e.subarray&&pu)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},wg=(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=Zi[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 Sg(o,i)},Ag=(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+Zi[e[r]]>t?r:t},qi={string2buf:vg,buf2string:wg,utf8border:Ag};function Mg(){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 gu=Mg,yu=Object.prototype.toString,{Z_NO_FLUSH:Eg,Z_SYNC_FLUSH:Lg,Z_FULL_FLUSH:Tg,Z_FINISH:Ig,Z_OK:Hs,Z_STREAM_END:Rg,Z_DEFAULT_COMPRESSION:zg,Z_DEFAULT_STRATEGY:Cg,Z_DEFLATED:kg}=zr;function eo(e){this.options=Ws.assign({level:zg,method:kg,chunkSize:16384,windowBits:15,memLevel:8,strategy:Cg},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 gu,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):yu.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?Ig:Eg,typeof e=="string"?r.input=qi.string2buf(e):yu.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===Lg||o===Tg)&&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===Rg)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 Ql(e,t){let r=new eo(t);if(r.push(e,!0),r.err)throw r.msg||Tr[r.err];return r.result}function Fg(e,t){return t=t||{},t.raw=!0,Ql(e,t)}function Dg(e,t){return t=t||{},t.gzip=!0,Ql(e,t)}var Pg=eo,Og=Ql,Bg=Fg,Ng=Dg,Ug=zr,Hg={Deflate:Pg,deflate:Og,deflateRaw:Bg,gzip:Ng,constants:Ug},Ds=16209,Vg=16191,Gg=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=Vg;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,_0=852,b0=592,v0=0,Rl=1,S0=2,Wg=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]),Xg=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]),Kg=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]),$g=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]),Yg=(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),C=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===v0||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===v0?(E=C=s,L=20):e===Rl?(E=Wg,C=Xg,L=257):(E=Kg,C=$g,L=0),S=0,c=0,l=h,v=o,m=f,g=0,b=-1,x=1<<f,A=x-1,e===Rl&&x>_0||e===S0&&x>b0)return 1;for(;;){U=l-g,s[c]+1<L?(z=0,$=s[c]):s[c]>=L?(z=C[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===Rl&&x>_0||e===S0&&x>b0)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=Yg,Zg=0,xu=1,_u=2,{Z_FINISH:w0,Z_BLOCK:qg,Z_TREES:Ps,Z_OK:Rr,Z_STREAM_END:jg,Z_NEED_DICT:Qg,Z_STREAM_ERROR:je,Z_DATA_ERROR:bu,Z_MEM_ERROR:vu,Z_BUF_ERROR:Jg,Z_DEFLATED:A0}=zr,Xs=16180,M0=16181,E0=16182,L0=16183,T0=16184,I0=16185,R0=16186,z0=16187,C0=16188,k0=16189,Vs=16190,Tt=16191,zl=16192,F0=16193,Cl=16194,D0=16195,P0=16196,O0=16197,B0=16198,Os=16199,Bs=16200,N0=16201,U0=16202,H0=16203,V0=16204,G0=16205,kl=16206,W0=16207,X0=16208,ne=16209,Su=16210,wu=16211,ey=852,ty=592,ry=15,ny=ry,K0=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function iy(){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 Cr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<Xs||t.mode>wu?1:0},Au=e=>{if(Cr(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(ey),t.distcode=t.distdyn=new Int32Array(ty),t.sane=1,t.back=-1,Rr},Mu=e=>{if(Cr(e))return je;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Au(e)},Eu=(e,t)=>{let r;if(Cr(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,Mu(e))},Lu=(e,t)=>{if(!e)return je;let r=new iy;e.state=r,r.strm=e,r.window=null,r.mode=Xs;let n=Eu(e,t);return n!==Rr&&(e.state=null),n},oy=e=>Lu(e,ny),$0=!0,Fl,Dl,sy=e=>{if($0){Fl=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(xu,e.lens,0,288,Fl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Gi(_u,e.lens,0,32,Dl,0,e.work,{bits:5}),$0=!1}e.lencode=Fl,e.lenbits=9,e.distcode=Dl,e.distbits=5},Tu=(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},ay=(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,C=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Cr(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=M0;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)!==A0){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?k0:Tt,l=0,c=0;break;case M0:for(;c<16;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}if(r.flags=l,(r.flags&255)!==A0){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=E0;case E0: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=L0;case L0: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=T0;case T0: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=I0;case I0: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=R0;case R0: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=z0;case z0: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=C0;case C0: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 k0:for(;c<32;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}e.adler=r.check=K0(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,Qg;e.adler=r.check=1,r.mode=Tt;case Tt:if(t===qg||t===Ps)break e;case zl:if(r.last){l>>>=c&7,c-=c&7,r.mode=kl;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=F0;break;case 1:if(sy(r),r.mode=Os,t===Ps){l>>>=2,c-=2;break e}break;case 2:r.mode=P0;break;case 3:e.msg="invalid block type",r.mode=ne}l>>>=2,c-=2;break;case F0: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=Cl,t===Ps)break e;case Cl:r.mode=D0;case D0: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 P0: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=O0;case O0:for(;r.have<r.ncode;){for(;c<3;){if(a===0)break e;a--,l+=n[o++]<<c,c+=8}r.lens[C[r.have++]]=l&7,l>>>=3,c-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,w={bits:r.lenbits},E=Gi(Zg,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=B0;case B0: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(xu,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(_u,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,Gg(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=G0;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=N0;case N0: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=U0;case U0: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=H0;case H0: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=V0;case V0: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 G0:if(d===0)break e;i[s++]=r.length,d--,r.mode=Bs;break;case kl: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):Yi(r.check,i,u,s-u)),u=d,r.wrap&4&&(r.flags?l:K0(l))!==r.check){e.msg="incorrect data check",r.mode=ne;break}l=0,c=0}r.mode=W0;case W0: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=X0;case X0:E=jg;break e;case ne:E=bu;break e;case Su:return vu;case wu: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<kl||t!==w0))&&Tu(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):Yi(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===Cl?256:0),(h===0&&u===0||t===w0)&&E===Rr&&(E=Jg),E},ly=e=>{if(Cr(e))return je;let t=e.state;return t.window&&(t.window=null),e.state=null,Rr},cy=(e,t)=>{if(Cr(e))return je;let r=e.state;return(r.wrap&2)===0?je:(r.head=t,t.done=!1,Rr)},dy=(e,t)=>{let r=t.length,n,i,o;return Cr(e)||(n=e.state,n.wrap!==0&&n.mode!==Vs)?je:n.mode===Vs&&(i=1,i=Yi(i,t,r,0),i!==n.check)?bu:(o=Tu(e,t,r,r),o?(n.mode=Su,vu):(n.havedict=1,Rr))},uy=Mu,fy=Eu,hy=Au,my=oy,py=Lu,gy=ay,yy=ly,xy=cy,_y=dy,by="pako inflate (from Nodeca project)",Rt={inflateReset:uy,inflateReset2:fy,inflateResetKeep:hy,inflateInit:my,inflateInit2:py,inflate:gy,inflateEnd:yy,inflateGetHeader:xy,inflateSetDictionary:_y,inflateInfo:by};function vy(){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 Sy=vy,Iu=Object.prototype.toString,{Z_NO_FLUSH:wy,Z_FINISH:Ay,Z_OK:ji,Z_STREAM_END:Pl,Z_NEED_DICT:Ol,Z_STREAM_ERROR:My,Z_DATA_ERROR:Y0,Z_MEM_ERROR:Ey}=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 gu,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 Sy,Rt.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=qi.string2buf(t.dictionary):Iu.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?Ay:wy,Iu.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===Ol&&i&&(o=Rt.inflateSetDictionary(r,i),o===ji?o=Rt.inflate(r,s):o===Y0&&(o=Ol));r.avail_in>0&&o===Pl&&r.state.wrap>0&&e[r.next_in]!==0;)Rt.inflateReset(r),o=Rt.inflate(r,s);switch(o){case My:case Y0:case Ol:case Ey:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===Pl))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===Pl)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 Jl(e,t){let r=new to(t);if(r.push(e),r.err)throw r.msg||Tr[r.err];return r.result}function Ly(e,t){return t=t||{},t.raw=!0,Jl(e,t)}var Ty=to,Iy=Jl,Ry=Ly,zy=Jl,Cy=zr,ky={Inflate:Ty,inflate:Iy,inflateRaw:Ry,ungzip:zy,constants:Cy},{Deflate:Fy,deflate:Dy,deflateRaw:Py,gzip:Oy}=Hg,{Inflate:By,inflate:Ny,inflateRaw:Uy,ungzip:Hy}=ky,Vy=Fy,Gy=Dy,Wy=Py,Xy=Oy,Ky=By,$y=Ny,Yy=Uy,Zy=Hy,qy=zr,ec={Deflate:Vy,deflate:Gy,deflateRaw:Wy,gzip:Xy,Inflate:Ky,inflate:$y,inflateRaw:Yy,ungzip:Zy,constants:qy};var jy=2023,$s=1,Ys=2,Zs=4,qs=8,js=16,Qs=32,tc=64,Qy=128,Jy=256,Js=512,ea=1024,ta=2048,ro=4096,no=16384,ex=32768,io=65536,ra=1<<17,oo=1<<18,so=1<<19,na=1<<20,ia=1<<21,oa=1<<22,tx=1<<23,sa=1<<24,ao=1<<25,aa=1<<26,la=1<<27,Ru=8192;var rx=1,nx=2,ix=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,alpha:0,scale:0,instanceBits:0,loopVolume:0,loopAttenuation:0,owner:0,oldFrame:0}),Ks=()=>({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=rx;this.stream=t,this.handler=r}translateCommand(t){if(this.protocolVersion===0){if(t===7)return k.serverdata;if(t===12)return k.serverdata}if(this.protocolVersion===25){if(t>=7&&t<=15)return t+5;if(t===1)return k.print;if(t===2)return k.stufftext;if(t===3)return k.sound;if(t===4)return k.nop;if(t===5)return k.disconnect;if(t===6)return k.reconnect;if(t===16)return k.temp_entity}return this.protocolVersion===jy,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 k.nop:break;case k.disconnect:this.handler&&this.handler.onDisconnect&&this.handler.onDisconnect();break;case k.reconnect:this.handler&&this.handler.onReconnect&&this.handler.onReconnect();break;case k.print:this.parsePrint();break;case k.serverdata:this.parseServerData();break;case k.configstring:this.parseConfigString();break;case k.spawnbaseline:this.parseSpawnBaseline();break;case k.centerprint:this.parseCenterPrint();break;case k.download:this.parseDownload();break;case k.frame:this.parseFrame();break;case k.packetentities:this.parsePacketEntities(!1);break;case k.deltapacketentities:this.parsePacketEntities(!0);break;case k.playerinfo:this.parsePlayerState();break;case k.stufftext:this.parseStuffText();break;case k.layout:this.parseLayout();break;case k.inventory:this.parseInventory();break;case k.sound:this.parseSound();break;case k.muzzleflash:this.parseMuzzleFlash();break;case k.muzzleflash2:this.parseMuzzleFlash2();break;case k.temp_entity:this.parseTempEntity();break;case k.splitclient:this.parseSplitClient();break;case k.configblast:this.parseConfigBlast();break;case k.spawnbaselineblast:this.parseSpawnBaselineBlast();break;case k.level_restart:this.handler&&this.handler.onLevelRestart&&this.handler.onLevelRestart();break;case k.damage:this.parseDamage();break;case k.locprint:this.parseLocPrint();break;case k.fog:this.parseFog();break;case k.waitingforplayers:this.parseWaitingForPlayers();break;case k.bot_chat:this.parseBotChat();break;case k.poi:this.parsePoi();break;case k.help_path:this.parseHelpPath();break;case k.muzzleflash3:this.parseMuzzleFlash3();break;case k.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(){this.protocolVersion=this.stream.readLong();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=ec.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=ec.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)}parseWaitingForPlayers(){let t=this.stream.readByte();this.handler&&this.handler.onWaitingForPlayers&&this.handler.onWaitingForPlayers()}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()}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),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!==k.playerinfo)throw new Error(`Expected svc_playerinfo after svc_frame, got ${s}`);let a=this.parsePlayerState();if(this.isDemo===ix){let d=this.stream.readByte();for(let l=0;l<d;l++)this.stream.readByte()}this.isDemo===nx&&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=Ks(),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:Ks(),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),t.push(n)}return t}parseEntityBits(){let t=this.stream.readByte();t&Qy&&(t|=this.stream.readByte()<<8),t&ex&&(t|=this.stream.readByte()<<16),t&tx&&(t|=this.stream.readByte()<<24);let r;return t&Jy?r=this.stream.readShort():r=this.stream.readByte(),{number:r,bits:t}}parseDelta(t,r,n,i){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.number=n,r.bits=i,i&ta&&(r.modelindex=this.stream.readByte()),i&na&&(r.modelindex2=this.stream.readByte()),i&ia&&(r.modelindex3=this.stream.readByte()),i&oa&&(r.modelindex4=this.stream.readByte()),i&js&&(r.frame=this.stream.readByte()),i&ra&&(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&$s&&(r.origin.x=this.stream.readCoord()),i&Ys&&(r.origin.y=this.stream.readCoord()),i&Js&&(r.origin.z=this.stream.readCoord()),i&ea&&(r.angles.x=this.stream.readAngle()),i&Zs&&(r.angles.y=this.stream.readAngle()),i&qs&&(r.angles.z=this.stream.readAngle()),i&sa&&this.stream.readPos(r.old_origin),i&aa&&(r.sound=this.stream.readByte()),i&Qs?r.event=this.stream.readByte():r.event=0,i&la&&(r.solid=this.stream.readShort())}};var ca=(i=>(i[i.Stopped=0]="Stopped",i[i.Playing=1]="Playing",i[i.Paused=2]="Paused",i[i.Finished=3]="Finished",i))(ca||{}),lo=class{constructor(){this.reader=null;this.state=0;this.playbackSpeed=1;this.accumulatedTime=0;this.frameDuration=100}setHandler(t){this.handler=t}loadDemo(t){this.reader=new Ar(t),this.state=0,this.accumulatedTime=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}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}new Fr(r.data,this.handler).parseMessage(),this.accumulatedTime-=this.frameDuration}}getState(){return this.state}};function ox(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 Uu(sx);})();
|
|
481
|
+
/*! Bundled license information:
|
|
482
|
+
|
|
483
|
+
pako/dist/pako.esm.mjs:
|
|
484
|
+
(*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
|
|
485
|
+
*/
|
|
450
486
|
//# sourceMappingURL=index.global.js.map
|