yolkbot 1.4.0 → 1.4.2

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.
@@ -1 +1 @@
1
- var Ue=Object.defineProperty;var it=(t,e)=>{for(var s in e)Ue(t,s,{get:e[s],enumerable:!0,configurable:!0,set:(i)=>e[s]=()=>i})};var We=globalThis.fetch,Rt=We;console.error("wwws does not support the browser.");var Gt=null;var W={},Z=typeof window<"u"&&typeof HTMLElement<"u",ot=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",Ot=typeof process<"u"&&process.moduleLoadList?.length>0,_t=typeof process<"u"&&!!process.versions?.deno,vt=typeof process<"u"&&!!process.versions?.bun;if(!Z&&!ot&&!Ot&&!_t&&!vt)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");W.isBrowser=Z;W.isIsolated=!Ot&&!_t&&!vt;W.fetch=Z||ot?globalThis.fetch:Rt;W.WebSocket=Z||ot?globalThis.WebSocket:Gt;var w=W;var kt={};it(kt,{findItemById:()=>l,UserAgent:()=>$,URLRewards:()=>He,Team:()=>Ke,StateBufferSize:()=>j,SocialReward:()=>Je,SocialMedia:()=>wt,ShellStreak:()=>g,PlayType:()=>I,Movement:()=>S,ItemType:()=>P,GunList:()=>_,GunEquipTime:()=>xt,GameOptionFlag:()=>gt,GameMode:()=>M,GameAction:()=>L,FramesBetweenSyncs:()=>C,FirebaseKey:()=>O,CoopState:()=>X,CollectType:()=>Q,ChiknWinnerDailyLimit:()=>lt,ChatFlag:()=>Be,ChallengeType:()=>$e,ChallengeSubType:()=>je,BanDuration:()=>dt});var pt={};it(pt,{SMG:()=>ut,RPEGG:()=>at,M24:()=>ft,Eggk47:()=>nt,DozenGauge:()=>rt,Cluck9mm:()=>ht,CSG1:()=>ct,AUG:()=>mt});var R=class{constructor(){this.adsMod=0.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},nt=class extends R{constructor(){super();this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.05,this.accuracyRecover=0.025,this.tracer=1}},rt=class extends R{constructor(){super();this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=0.16,this.accuracyMax=0.13,this.accuracyLoss=0.17,this.accuracyRecover=0.02,this.adsMod=0.6,this.movementAccuracyMod=0.2,this.tracer=0}},ct=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=0.3,this.accuracyMax=0.004,this.accuracyLoss=0.3,this.accuracyRecover=0.025,this.tracer=0}},ht=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=0.15,this.accuracyMax=0.035,this.accuracyLoss=0.09,this.accuracyRecover=0.08,this.adsMod=0.8,this.movementAccuracyMod=0.6,this.tracer=0}},at=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=0.4,this.accuracyMin=0.3,this.accuracyMax=0.015,this.accuracyLoss=0.3,this.accuracyRecover=0.02,this.radius=2.75}},ut=class extends R{constructor(){super();this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=0.19,this.accuracyMax=0.06,this.accuracyLoss=0.045,this.accuracyRecover=0.05,this.adsMod=0.6,this.movementAccuracyMod=0.7,this.tracer=2}},ft=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=0.35,this.accuracyMax=0,this.accuracyLoss=0.1,this.accuracyRecover=0.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=0.8,this.tracer=0}},mt=class extends R{constructor(){super();this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.037,this.accuracyRecover=0.03,this.adsMod=0.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=0.8,this.movementInstability=2,this.tracer=0}};var l=()=>null;var dt={FiveMinutes:0,FifteenMinutes:1,OneHour:2},je={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},$e={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},Be={None:0,Pinned:2,Team:4,Mod:254,Server:255},lt=3,Q={Ammo:0,Grenade:1},X={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},O="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",C=3,L={Reset:1,Pause:2},M={FFA:0,Team:1,Spatula:2,KOTC:3},gt={Locked:1,NoTeamChange:2,NoTeamShuffle:4},xt=13,_=[nt,rt,ct,at,ut,ft,mt],P={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},S={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},I={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},g={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},wt={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},Je={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},j=256,Ke={Blue:1,Red:2},He=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],$=w.isBrowser?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";class At{url="";proxy="";binaryType="";maxRetries=5;connectionTimeout=5000;constructor(t,e){if(w.isBrowser&&e)throw Error("You cannot pass a proxy to a WebSocket in a browser.");this.url=t,this.proxy=e}async tryConnect(t=1){let e=new URL(this.url),s=async()=>{if(t===5)return!1;return await this.tryConnect(t+1)};try{if(this.socket=w.isBrowser?new w.WebSocket(this.url):new w.WebSocket(this.url,{proxy:this.proxy||null,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",origin:e.origin.replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":$}}),this.binaryType)this.socket.binaryType=this.binaryType}catch(i){return console.error(`Failed to connect on try ${t}, trying again...`,i),await s()}if(this.onBeforeConnect)this.onBeforeConnect();return new Promise((i)=>{let n=setTimeout(async()=>{this.socket.close(),i(await s())},this.connectionTimeout),r=async(c)=>{clearTimeout(n),console.error("WebSocket error",c),i(await s())};this.socket.addEventListener("open",async()=>{clearTimeout(n),this.socket.removeEventListener("error",r),i(!0)}),this.socket.addEventListener("error",r)})}get onmessage(){return this.socket?.onmessage}set onmessage(t){if(this.socket)this.socket.onmessage=t;else console.error("set onmessage before socket existed")}get onclose(){return this.socket?.onclose}set onclose(t){if(this.socket)this.socket.onclose=t;else console.error("set onclose before socket existed")}get onerror(){return this.socket?.onerror}set onerror(t){if(this.socket)this.socket.onerror=t;else console.error("set onclose before socket existed")}send(t){return this.socket?.send(t)}close(t){return this.socket?.close(t)}}var F=At;var B={origin:"https://shellshock.io","user-agent":$,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class D{constructor(t={}){this.proxy=t.proxy,this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.maxRetries=t.maxRetries||5,this.suppressErrors=t.suppressErrors||!1,this.connectionTimeout=t.connectionTimeout||5000}queryServices=async(t)=>{let e=new F(`${this.protocol}://${this.instance}/services/`,this.proxy);if(e.connectionTimeout=this.connectionTimeout,!await e.tryConnect(-2)||e.socket.readyState!==1)return"websocket_connect_fail";return new Promise((i)=>{let n=!1;e.onmessage=(r)=>{n=!0;try{let c=JSON.parse(r.data);i(c)}catch{if(!this.suppressErrors)console.error("queryServices: Bad API JSON response with call:",t.cmd,"and data:",JSON.stringify(t)),console.error("queryServices: Full data sent:",JSON.stringify(t));i("bad_json")}e.close()},e.onerror=()=>!n&&i("unknown_socket_error"),e.onclose=()=>!n&&i("services_closed_early"),e.send(JSON.stringify(t))})};#t=async(t,e,s)=>{if(!t||!e)return"firebase_no_credentials";let i,n;try{i=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${s}?key=${O}`,{method:"POST",body:JSON.stringify({email:t,password:e,returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),n=i.idToken}catch(c){if(c.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(c.code==="auth/missing-email")return"firebase_no_credentials";else if(c.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",i||c);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e,c);return"firebase_unknown_error"}if(!n){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",i);return"firebase_no_token"}this.idToken=n;let r=await this.queryServices({cmd:"auth",firebaseToken:n});return typeof r==="object"?{firebase:i,...r}:r};createAccount=async(t,e)=>await this.#t(t,e,"signUp");loginWithCredentials=async(t,e)=>await this.#t(t,e,"signInWithPassword");loginWithRefreshToken=async(t)=>{if(!t)return"firebase_no_credentials";let e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",t);let s,i;try{s=await(await w.fetch(`https://securetoken.googleapis.com/v1/token?key=${O}`,{method:"POST",body:e,headers:{...B,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),i=s.id_token}catch(r){if(r.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(r.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",r,t);return"firebase_unknown_error"}if(!i){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",s);return"firebase_no_token"}this.idToken=i;let n=await this.queryServices({cmd:"auth",firebaseToken:i});return typeof n==="object"?{firebase:s,...n}:n};loginAnonymously=async()=>{let e=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${O}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),s=e.idToken;if(!s){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",e);return"firebase_no_token"}this.idToken=s;let i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:e,...i}:i};sendEmailVerification=async(t=this.idToken)=>{if(!t)return"no_idtoken_passed";let s=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${O}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:t}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json();if(s.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",s);return"firebase_invalid_response"}return{email:s.email}};verifyOobCode=async(t)=>{if(!t)return"no_oob_code_passed";let s=await(await w.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${O}`,{method:"POST",body:JSON.stringify({oobCode:t}),headers:{...B,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!s.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",s);return"firebase_invalid_response"}return s.email}}var V=D;class Ct{static buffer;static idx;static init(t){this.buffer=new Uint8Array(t),this.idx=0}static isMoreDataAvailable(){return Math.max(0,this.buffer.length-this.idx)}static unPackInt8U(){let t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){let t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){let t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){let t=this.idx;return this.idx+=4,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536+this.buffer[t+3]*16777216}static unPackInt16(){return(this.unPackInt16U()+32768)%65536-32768}static unPackInt32(){return(this.unPackInt32U()+2147483648)%4294967296-2147483648}static unPackRadU(){return this.unPackInt24U()/2097152}static unPackRad(){return this.unPackInt16U()/8192-Math.PI}static unPackFloat(){return this.unPackInt16()/256}static unPackDouble(){return this.unPackInt32()/1048576}static unPackString(t){t=t||255;let e=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(e)}static unPackLongString(t){t=t||16383;let e=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(e)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let s="";for(let i=0;i<t;i++){let n=this.unPackInt16U();if(n>0)s+=String.fromCodePoint(n)}return s}}var o=Ct;class Lt{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){let e=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(e)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){if(typeof t!=="string")t="";this.packInt8(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}packLongString(t){if(typeof t!=="string")t="";this.packInt16(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}}var p=Lt;var Ye={gameNotFound:4000,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023},b=Ye;var Ze={},a=Ze;var Qe=Object.fromEntries(Object.entries(wt).map(([t,e])=>[e,t.toLowerCase()]));class tt{constructor(t,e=null){if(this.id=t.id,this.uniqueId=t.uniqueId,this.name=t.name,this.safeName=t.safeName,this.team=t.team,this.playing=t.playing,this.socials=t.social&&JSON.parse(t.social),this.socials)this.socials.forEach((s)=>s.type=Qe[s.id]);if(this.isVip=t.upgradeProductId>0,this.showBadge=!t.hideBadge||!1,this.streak=t.score,this.streakRewards=Object.values(g).filter((s)=>t.activeShellStreaks&s),this.scale=this.streakRewards.includes(g.MiniEgg)?0.5:1,this.position={x:t.x,y:t.y,z:t.z},this.jumping=t.$controlKeys&S.Jump,this.scoping=t.$controlKeys&S.Scope,this.climbing=!1,this.view={yaw:t.yaw,pitch:t.pitch},this.updateKotcZone(e),this.character={eggColor:t.shellColor,primaryGun:t.primaryWeaponItem,secondaryGun:t.secondaryWeaponItem,stamp:t.stampItem,hat:t.hatItem,grenade:t.grenadeItem,melee:t.meleeItem,stampPos:{x:t.stampPosX,y:t.stampPosY}},this.stats={totalKills:t.totalKills,totalDeaths:t.totalDeaths,bestStreak:t.bestStreak},this.activeGun=t.weaponIdx,this.selectedGun=t.charClass,this.weapons=[],this.character.primaryGun)this.weapons[0]=new _[this.selectedGun],this.weapons[1]=new ht;this.grenades=1,this.hp=t.hp,this.hpShield=0,this.spawnShield=t.shield,this.randomSeed=0}updateKotcZone(t){if(!t)return this.inKotcZone=!1;let e=Math.floor(this.position.x),s=Math.floor(this.position.y),i=Math.floor(this.position.z);this.inKotcZone=t.some((n)=>n.x===e&&n.y===s&&n.z===i)&&this.playing}}var et=tt;var Xe=(t)=>new Uint8Array(t.match(/.{2}/g).map((e)=>parseInt(e,16))),Ie=new TextEncoder,Ft=async(t)=>{if(typeof process<"u"&&typeof process.getBuiltinModule==="function"){let n=process.getBuiltinModule("node:crypto"),r=Buffer.from("3496afa51f2a553ea1fc5211400c000b","hex");return n.createHmac("sha256",r).update(t).digest("hex")}let e=Xe("3496afa51f2a553ea1fc5211400c000b"),s=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await crypto.subtle.sign("HMAC",s,Ie.encode(t));return Array.from(new Uint8Array(i)).map((n)=>n.toString(16).padStart(2,"0")).join("")},G=(t)=>{return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t-1050359)},qt=(t,e)=>{let s=Math.round(t/(Math.PI*2)*65535),i=0,n=Math.round((e+1.5)/3*32767),r=s<0?0:s;s=r>65535?65535:r;let c=Math.trunc(s);if(c<0)c=0;if(c>4294967295)c=4294967295;c=s>=0?c:0,c=s>65535?0:c;let h=c;i^=h;let m=n<0?0:n;s=m,m=s>32767?32767:s,s=m;let f=Math.trunc(s);if(f<0)f=0;if(f>4294967295)f=4294967295;f=s>=0?f:0,f=s>65535?0:f;let u=f,d=u,k=i^d,E=k&255,N=i<<8,v=(i&65280)>>>8;u=(N|v)>>>0;let Y=E^u;k=k<<8|(k&65280)>>>8,h^=d,d=k^h&255,h=h<<8|(h&65280)>>>8,i=h^i&255;let z=[];return z[3]=G(1050359+(d&63)),z[7]=G(1050359+(u>>>8&63)),z[4]=G(1050359+(k>>>10&63)),z[0]=G(1050359+((i&252)>>>2)),z[5]=G(1050359+(k>>>4&48|Y>>>4&15)),z[2]=G(1050359+(h>>>6&60|d>>>6&3)),z[6]=G(1050359+((u>>>14&3|Y<<2)&63)),z[1]=G(1050359+((h>>>12&15|i<<4)&63)),String.fromCharCode(...z)};class st{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;#e=!1;constructor(t={}){if(this.#t=t.noExitOnError||!1,!t.instance)t.instance="shellshock.io";if(!t.protocol)t.protocol="wss";if(t.api)this.api=t.api;else this.api=new V({proxy:t.proxy,protocol:t.protocol,instance:t.instance,connectionTimeout:t.connectionTimeout});if(t.sessionId||t.noLogin)this.sessionId=t.sessionId;else this.#s();if(t.proxy&&w.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(t.proxy)this.proxy=t.proxy;this.#n(t.instance,t.protocol,t.noLogin,t.connectionTimeout)}async#n(t,e,s,i){if(this.ws=new F(`${e}://${t}/matchmaker/`,this.proxy),this.ws.connectionTimeout=i||5000,!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");if(this.ws.onmessage=(r)=>{let c=JSON.parse(r.data);if(c.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:Ft(c.uuid)}));this.#o("msg",c)},this.ws.onclose=()=>{if(this.connected=!1,!this.#e)this.#n(t,e,s,i)},this.connected=!0,this.sessionId||s)this.onceConnected.forEach((r)=>r())}async#s(){let t=await this.api.loginAnonymously();if(!t||typeof t==="string")this.#o("authFail",t);if(this.sessionId=t.sessionId,this.connected)this.onceConnected.forEach((e)=>e())}send(t){this.ws.send(JSON.stringify(t))}async waitForConnect(){return new Promise((t)=>{if(this.connected)t();else this.onceConnected.push(t)})}async getRegions(){await this.waitForConnect();let t=this;return new Promise((e)=>{let s=(i)=>{if(i.command==="regionList")this.regionList=i.regionList,this.off("msg",s),e(i.regionList)};this.on("msg",s),this.ws.onerror=(i)=>t.#i("failed to get regions",i),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#e=!0,this.connected=!1,this.ws.close()}on(t,e){if(!this.onListeners.has(t))this.onListeners.set(t,[]);this.onListeners.get(t).push(e)}once(t,e){if(!this.onceListeners.has(t))this.onceListeners.set(t,[]);this.onceListeners.get(t).push(e)}off(t,e){if(this.onListeners.has(t))this.onListeners.set(t,this.onListeners.get(t).filter((s)=>s!==e));if(this.onceListeners.has(t))this.onceListeners.set(t,this.onceListeners.get(t).filter((s)=>s!==e))}#o(t,...e){if(this.onListeners.has(t))this.onListeners.get(t).forEach((s)=>s(...e));if(this.onceListeners.has(t))this.onceListeners.get(t).forEach((s)=>s(...e)),this.onceListeners.delete(t)}#i(t){if(this.onListeners.has("error"))this.#o("error",t);else if(this.#t)console.error(t);else throw Error(t)}}var Ut=st;var De=(t,e)=>(t%e+e)%e,Ve=Math.PI*2,Wt=(t)=>Math.round(t*8192)/8192,be=(t)=>Wt(De(Math.atan2(-t.x,-t.z),Ve)),ts=(t)=>Wt(Math.atan2(t.y,Math.hypot(t.x,t.z)));class jt{constructor(t){this.pos=t}validate(){return this.pos&&this.pos.x&&this.pos.y&&this.pos.z}check(t){return t.me.playing}execute(t){let e={x:this.pos.x-t.me.position.x,y:this.pos.y-t.me.position.y,z:this.pos.z-t.me.position.z},s=be(e),i=ts(e);t.state.yaw=s,t.state.pitch=i}}var J=jt;class $t{constructor(t){if(typeof t==="number")this.inputKeys=t;else if(typeof t==="object")this.inputKeys=t.reduce((e,s)=>e|s,0)}validate(){if(typeof this.inputKeys!=="number")return!1;if(this.inputKeys&S.Forward&&this.inputKeys&S.Backward)return!1;if(this.inputKeys&S.Left&&this.inputKeys&S.Right)return!1;return!0}check(t){return t.me.playing}execute(t){t.state.controlKeys=this.inputKeys}}var K=$t;class Mt{constructor(t,e){if(this.x=e.x,this.y=e.y,this.z=e.z,this.positionStr=`${this.x},${this.y},${this.z}`,this.position={x:this.x,y:this.y,z:this.z},this.meshType=t.split(".").pop(),this.f=0,this.g=0,this.h=0,this.visited=null,this.parent=null,this.closed=null,this.links=[],this.isStair())if(e.ry)this.ry=e.ry;else this.ry=0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}canLink(t,e){let s=this.x-t.x,i=this.z-t.z,n=this.y-t.y,r=Math.abs(s),c=Math.abs(n),h=Math.abs(i);if(r+c+h===0||r+h>1||this.isFull()||t.isFull())return!1;let m=e.at(this.x,this.y-1,this.z),f=e.at(t.x,t.y-1,t.z);if(!m||!f)return!1;let u={0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}};switch(this.meshType){case"none":if(n===1&&t.canWalkThrough())return!0;if(m.canWalkOn()||m.isLadder()){if(t.meshType==="none"||t.meshType==="ladder"&&c===0||t.meshType==="wedge"&&n===0&&s===-u[t.ry].x&&i===-u[t.ry].z)return!0}return!1;case"ladder":if(c===1&&t.canWalkThrough())return!0;if(c===0&&m.canWalkOn())return!0;if(t.meshType==="ladder"&&(c===1||m.canWalkOn()&&f.canWalkOn()))return!0;return!1;case"wedge":if(this.x+u[this.ry].x===t.x&&this.z+u[this.ry].z===t.z&&this.y+1===t.y)return!0;if(this.x-u[this.ry].x===t.x&&this.z-u[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y))return!0;return!1;default:return!1}}flatCenter(){return{x:this.x+0.5,y:this.y+0,z:this.z+0.5}}flatRadialDistance(t){let e=this.flatCenter();return Math.hypot(e.x-t.x,e.z-t.z)}}class St{list=[];constructor(t){let e={};for(let i of Object.keys(t.data))for(let n of t.data[i])e[n.x<<16|n.y<<8|n.z]=!0,this.list.push(new Mt(i,n));for(let i=0;i<t.width;i++)for(let n=0;n<t.height;n++)for(let r=0;r<t.depth;r++)if(!e[i<<16|n<<8|r])this.list.push(new Mt("SPECIAL.air.none",{x:i,y:n,z:r}));let s=new Map;for(let i of this.list)s.set(i.positionStr,i);for(let i of this.list){let n=[{x:i.x+1,y:i.y,z:i.z},{x:i.x-1,y:i.y,z:i.z},{x:i.x,y:i.y+1,z:i.z},{x:i.x,y:i.y-1,z:i.z},{x:i.x,y:i.y,z:i.z+1},{x:i.x,y:i.y,z:i.z-1}];for(let r of n){let c=`${r.x},${r.y},${r.z}`,h=s.get(c);if(h&&i.canLink(h,this))i.links.push(h)}}}at(t,e,s){if(!this.nodeMap){this.nodeMap=new Map;for(let n of this.list){let r=`${n.x},${n.y},${n.z}`;this.nodeMap.set(r,n)}}let i=`${t},${e},${s}`;return this.nodeMap.get(i)}clean(){for(let t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,e){let s=e.x-t.x,i=e.y-t.y,n=e.z-t.z,r=Math.max(Math.abs(s),Math.abs(i),Math.abs(n)),c=s/r,h=i/r,m=n/r,f=t.x,u=t.y,d=t.z;for(let k=0;k<=r;k++){let E=this.at(Math.round(f),Math.round(u),Math.round(d));if(E&&E.isFull())return!1;f+=c,u+=h,d+=m}return!0}}var Bt=async(t,e)=>{if(!w.isIsolated&&typeof process<"u"){let{existsSync:i,mkdirSync:n,readFileSync:r,writeFileSync:c}=process.getBuiltinModule("node:fs"),{join:h}=process.getBuiltinModule("node:path"),{homedir:m}=process.getBuiltinModule("node:os"),f=h(m(),".yolkbot");if(!i(f))n(f);let u=h(f,"maps");if(!i(u))n(u);let d=h(u,`${t}-${e}.json`);if(i(d))return JSON.parse(r(d,"utf-8"));let k=await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json();return c(d,JSON.stringify(k,null,4),{flag:"w+"}),k}return await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json()},Jt=(t)=>{let e=0,s={},i=[];for(let c of t){if(!s[c.x])s[c.x]={};if(!s[c.x][c.y])s[c.x][c.y]={};s[c.x][c.y][c.z]={zone:null}}let n=[{x:-1,z:0},{x:1,z:0},{x:0,z:-1},{x:0,z:1}],r=(c,h,m)=>s[c]&&s[c][h]&&s[c][h][m]?s[c][h][m]:null;for(let c of t)if(!s[c.x][c.y][c.z].zone){c.zone=++e,s[c.x][c.y][c.z].zone=c.zone;let h=[c],m;do{m=0;for(let f of t)if(!s[f.x][f.y][f.z].zone)for(let u of n){let d=r(f.x+u.x,f.y,f.z+u.z);if(d&&d.zone===c.zone){m++,f.zone=c.zone,s[f.x][f.y][f.z].zone=c.zone,h.push(f);break}}}while(m>0);i.push(h)}return i};var Kt=[];var H=[];var yt=[];var Ht=Object.fromEntries(Object.entries(M).map(([t,e])=>[e,t])),Yt=Object.fromEntries(Object.entries(gt).map(([t,e])=>[t[0].toLowerCase()+t.slice(1),e])),Zt={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},zt=(t,e)=>(t%e+e)%e;class Tt{static Intents=Zt;Intents=Zt;#t=[];#e={};#n=[];#s;#o;constructor(t={}){if(t.proxy&&w.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)){if(!l(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}if(this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.connectionTimeout=t.connectionTimeout||5000,this.state={name:"yolkbot",weaponIdx:0,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new et({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:Ht[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:X.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#o=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:[,,,,,,,].fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{let e=new Date().getUTCDay(),s=new Date().getUTCHours();return e>=5&&s>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new V({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:t?.apiMaxRetries,connectionTimeout:this.connectionTimeout}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(t){if(t.validate(this)){if(t.check(this))t.execute(this);else this.#t.push(t);return!0}return!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.createAccount(t,e);return this.processLoginData(s)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.loginWithCredentials(t,e);return this.processLoginData(s)}async loginWithRefreshToken(t){this.account=this.#s;let e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;let t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){if(typeof t!=="object")return this.emit("authFail",t),t;if(t.banRemaining)return this.emit("banned",t.banRemaining),"account_banned";if(!t.playerOutput)return this.emit("authFail",t),t;if(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<1714546800000,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#i(t.challenges);if(this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#i(t){this.account.challenges=[];for(let e of t){let s=Kt.find((i)=>i.id===e.challengeId);if(!s)continue;delete e.playerId,this.account.challenges.push({raw:{challengeInfo:s,challengeData:e},id:e.challengeId,name:s.loc.title,desc:s.loc.desc,rewardEggs:s.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:s.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){let t=await this.loginAnonymously();if(typeof t!=="object")return t}if(!this.matchmaker){if(this.matchmaker=new Ut({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(e)=>this.emit("authFail",e)),this.matchmaker.on("error",(e)=>this.processError(e))}return!0}async findPublicGame(t,e){if(typeof t!=="string")return"no_region_passed";if(!yt.find((i)=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((i)=>{let n=(r)=>{if(r.command==="notice")return;if(this.matchmaker.off("msg",n),r.command==="gameFound")return i(r);if(r.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(r))};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t,playType:I.JoinPublic,gameType:e,sessionId:this.account.sessionId})})}async createPrivateGame(t,e,s){if(typeof t!=="string")return"no_region_passed";if(!yt.find((r)=>r.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(typeof s!=="string")return"no_map_passed";let i=H.findIndex((r)=>r.name.toLowerCase()===s.toLowerCase());if(i===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((r)=>{let c=(h)=>{if(h.command==="notice")return;if(this.matchmaker.off("msg",c),h.command==="gameFound")return r(h);if(h.error==="sessionNotFound")return r("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(h))};this.matchmaker.on("msg",c),this.matchmaker.send({command:"findGame",region:t,playType:I.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})})}async join(t,e){if(this.state.name=t||"yolkbot",typeof e==="string"){if(e.includes("#"))e=e.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((r)=>{let c=(h)=>{if(h.command==="gameFound")this.matchmaker.off("msg",c),this.game.raw=h,this.game.code=h.id,r(h.id);if(h.error&&h.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",c),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e==="object"){if(this.account.id===0)await this.loginAnonymously();if(this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}let s=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);if(this.game.socket=new F(`${this.protocol}://${s}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.connectionTimeout=this.connectionTimeout,this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(n)=>this.processPacket(n.data),this.game.socket.onclose=(n)=>{if(this.state.left)this.state.left=!1;else this.emit("close",n.code),this.leave(-1)}},!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#r(){if(Object.entries(this.me.position).map((e)=>Math.floor(e[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new K(0));else{let e;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1)e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new J(e));else e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new J(e));for(let s of this.pathing.activePath)if(s.flatRadialDistance(this.me.position)<0.1&&s.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(s)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(s)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&S.Forward))this.dispatch(new K(S.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#r();for(let e=0;e<this.#t.length;e++){let s=this.#t[e];if(s.check(this))s.execute(this),this.#t.splice(e,1)}if(this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333),this.me.playing){let e=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("setting buffer for idx",e),console.log("checking...shotsFired",this.state.shotsFired);if(this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[e]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");let s=new p;s.packInt8(a.syncMe),s.packInt8(this.state.stateIdx),s.packInt8(this.state.serverStateIdx);let i=zt(this.state.stateIdx-C+1,j);for(let n=0;n<C;n++){let r=zt(i+n,j),c=this.state.buffer[r]||{},h=c.controlKeys||0,m=c.shotsFired||0,f=c.yaw??this.state.yaw,u=c.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,i,r,c);s.packInt8(h),s.packInt8(m),s.packString(qt(f,u)),s.packInt8(100)}s.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=zt(this.state.stateIdx+1,j)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;let t=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(let e of Object.values(this.players)){if(e.playing&&e.hp>0){let s=e.streakRewards.includes(g.OverHeal);e.hp+=s?-t:t,e.hp=s?Math.max(100,e.hp):Math.min(100,e.hp)}if(e.spawnShield>0)e.spawnShield-=6}}on(t,e){if(Object.keys(this.#e).includes(t))this.#e[t].push(e);else this.#e[t]=[e]}once(t,e){let s=(...i)=>{e(...i),this.off(t,s)};this.on(t,s)}onAny(t){this.#n.push(t)}off(t,e){if(e)this.#e[t]=this.#e[t].filter((s)=>s!==e);else this.#e[t]=[]}emit(t,...e){if(this.hasQuit)return;if(this.#e[t])for(let s of this.#e[t])s(...e);for(let s of this.#n)s(t,...e)}#c(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,s,e)}#h(){let t=o.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),s={id:t,uniqueId:o.unPackString(),name:o.unPackString(),safeName:o.unPackString(),charClass:o.unPackInt8U(),team:o.unPackInt8U(),primaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),secondaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),shellColor:o.unPackInt8U(),hatItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampPosX:o.unPackInt8(),stampPosY:o.unPackInt8(),grenadeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),meleeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat(),$dx:o.unPackFloat(),$dy:o.unPackFloat(),$dz:o.unPackFloat(),yaw:o.unPackRadU(),pitch:o.unPackRad(),score:o.unPackInt32U(),$kills:o.unPackInt16U(),$deaths:o.unPackInt16U(),$streak:o.unPackInt16U(),totalKills:o.unPackInt32U(),totalDeaths:o.unPackInt32U(),bestStreak:o.unPackInt16U(),$bestOverallStreak:o.unPackInt16U(),shield:o.unPackInt8U(),hp:o.unPackInt8U(),playing:o.unPackInt8U(),weaponIdx:o.unPackInt8U(),$controlKeys:o.unPackInt8U(),upgradeProductId:o.unPackInt8U(),activeShellStreaks:o.unPackInt8U(),social:o.unPackLongString(),hideBadge:o.unPackInt8U()};this.game.mapIdx=o.unPackInt8U(),this.game.isPrivate=o.unPackInt8U()===1,this.game.gameModeId=o.unPackInt8U();let i=new et(s,this.game.gameMode===M.KOTC?this.game.activeZone:null);if(!this.players[s.id])this.players[s.id]=i;if(this.emit("playerJoin",i),this.me.id===s.id)this.me=i,this.emit("botJoin",this.me)}#a(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackInt8U(),h=o.unPackInt8U(),m=o.unPackInt8U(),f=o.unPackInt8U(),u=this.players[t];if(u){if(u.playing=!0,u.randomSeed=e,u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.rounds=r;if(u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.store=c;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.rounds=h;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.store=m;u.grenades=f,u.position={x:s,y:i,z:n},u.spawnShield=120,this.emit("playerRespawn",u)}}#u(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackInt8U(),r=this.players[t];if(!r||r.id===this.me.id){for(let N=0;N<C;N++)o.unPackInt8U(),o.unPackRadU(),o.unPackRad(),o.unPackInt8U();return}for(let N=0;N<C;N++){let v=o.unPackInt8U();if(v&S.Jump)r.jumping=!0;else r.jumping=!1;if(v&S.Scope)r.scoping=!0;else r.scoping=!1;let A={...r.view};if(r.view.yaw=o.unPackRadU(),r.view.pitch=o.unPackRad(),r.view.yaw!==A.yaw||r.view.pitch!==A.pitch)this.emit("playerRotate",r,A,r.view);r.scale=o.unPackInt8U()}let c=r.position,h=c.x!==e||c.y!==s||c.z!==i,m=r.climbing!==n,f=h||m,u=f?{...c}:null;if(c.x!==e)c.x=e;if(c.z!==i)c.z=i;if(!r.jumping||Math.abs(c.y-s)>0.5)c.y=s;if(m)r.climbing=n;if(!f)return;if(this.emit("playerMove",r,u,c),this.game.gameModeId!==M.KOTC)return;let d=this.game.activeZone,k=!!r.inKotcZone;if(!d&&k){r.inKotcZone=!1,this.emit("playerLeaveZone",r);return}r.updateKotcZone(d);let E=!!r.inKotcZone;if(k!==E)r.inKotcZone=E,this.emit(E?"playerEnterZone":"playerLeaveZone",r)}#f(){let t=o.unPackInt8U(),e=this.players[t];if(e){if(e.playing=!1,e.streakRewards)e.streakRewards=[];if(this.emit("playerPause",e),e.inKotcZone)e.inKotcZone=!1,this.emit("playerLeaveZone",e)}}#m(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(s)s.activeGun=e,this.emit("playerSwapWeapon",s,e)}#p(){let t=o.unPackInt8U(),e=o.unPackInt8U();o.unPackInt8U(),o.unPackInt8U();let s=o.unPackInt8U(),i=this.players[t],n=this.players[e],r=i?{...i}:null;if(i){if(i.id===this.me.id)this.lastDeathTime=Date.now();i.playing=!1,i.streak=0,i.hp=100,i.spawnShield=0,i.stats.totalDeaths++,i.inKotcZone=!1,this.emit("playerLeaveZone",i)}if(n){if(n.streak++,n.stats.totalKills++,n.streak>n.stats.bestStreak)n.stats.bestStreak=n.streak}this.emit("playerDeath",i,n,r,s)}#d(){let t=o.unPackInt8U(),e={posX:o.unPackFloat(),posY:o.unPackFloat(),posZ:o.unPackFloat(),dirX:o.unPackFloat(),dirY:o.unPackFloat(),dirZ:o.unPackFloat()},s=this.players[t];if(!s)return;let i=s.weapons[s.activeGun];if(i&&i.ammo)i.ammo.rounds--,this.emit("playerFire",s,i,e)}#l(){let t=o.unPackInt16U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat();this.game.collectables[e].push({id:t,x:s,y:i,z:n}),this.emit("spawnItem",e,{x:s,y:i,z:n},t)}#g(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt16U(),n=this.players[t];if(!n)return;if(this.game.collectables[e]=this.game.collectables[e].filter((r)=>r.id!==i),e===Q.Ammo){let r=n.weapons[s];if(r&&r.ammo)r.ammo.store=Math.min(r.ammo.storeMax,r.ammo.store+r.ammo.pickup),this.emit("playerCollectAmmo",n,r,i)}if(e===Q.Grenade){if(n.grenades++,n.grenades>3)n.grenades=3;this.emit("playerCollectGrenade",n,i)}}#x(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.hp;s.hp=e,this.emit("playerDamage",s,i,s.hp)}#w(){let t=o.unPackInt8U();o.unPackFloat(),o.unPackFloat();let e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#k(){let t=o.unPackInt8U(),e=this.players[t];o.unPackInt8U();let s=o.unPackInt8U(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat();if(this.me.climbing=!!o.unPackInt8U(),o.unPackInt8U(),o.unPackInt8U(),!e)return;this.state.serverStateIdx=s;let c=e.position.x,h=e.position.y,m=e.position.z;if(e.position.x=i,e.position.y=n,e.position.z=r,c!==i||h!==n||m!==r)this.emit("playerMove",e,{x:c,y:h,z:m},{x:i,y:n,z:r})}#M(){let t=new p;t.packInt8(a.eventModifier),t.send(this.game.socket)}#S(){let t=o.unPackInt8U(),e={...this.players[t]};delete this.players[t],this.emit("playerLeave",e)}#y(){if(this.game.gameModeId===M.Spatula){let t={...this.game};this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();let e={x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat()},s=o.unPackInt8U(),i=o.unPackInt8U();this.game.spatula={coords:e,controlledBy:s,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===M.KOTC){let t={...this.game};this.game.stage=o.unPackInt8U(),this.game.zoneNumber=o.unPackInt8U(),this.game.capturing=o.unPackInt8U(),this.game.captureProgress=o.unPackInt16U(),this.game.numCapturing=o.unPackInt8U(),this.game.teamScore[1]=o.unPackInt8U(),this.game.teamScore[2]=o.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1000,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;let e=Object.values(this.players).filter((s)=>s.inKotcZone&&s.playing);if(this.game.activeZone)Object.values(this.players).forEach((s)=>s.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((s)=>{s.inKotcZone=!1,this.emit("playerLeaveZone",s)});this.emit("gameStateChange",t,this.game,e)}else if(this.game.gameModeId===M.Team)this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();if(this.game.gameModeId!==M.Spatula)delete this.game.spatula;if(this.game.gameModeId!==M.KOTC)delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.numCapturing,delete this.game.activeZone;if(this.game.gameModeId===M.FFA)delete this.game.teamScore}#z(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;switch(e){case g.HardBoiled:if(t===this.me.id)this.me.shieldHp=100;s.streakRewards.push(g.HardBoiled);break;case g.EggBreaker:s.streakRewards.push(g.EggBreaker);break;case g.Restock:{if(s.grenades=3,s.weapons[0]&&s.weapons[0].ammo)s.weapons[0].ammo.rounds=s.weapons[0].ammo.capacity,s.weapons[0].ammo.store=s.weapons[0].ammo.storeMax;if(s.weapons[1]&&s.weapons[1].ammo)s.weapons[1].ammo.rounds=s.weapons[1].ammo.capacity,s.weapons[1].ammo.store=s.weapons[1].ammo.storeMax;break}case g.OverHeal:s.hp=Math.min(200,s.hp+100),s.streakRewards.push(g.OverHeal);break;case g.DoubleEggs:s.streakRewards.push(g.DoubleEggs);break;case g.MiniEgg:s.scale=0.5,s.streakRewards.push(g.MiniEgg);break}this.emit("playerBeginStreak",s,e)}#T(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if([g.EggBreaker,g.OverHeal,g.DoubleEggs,g.MiniEgg].includes(e)&&s.streakRewards.includes(e))s.streakRewards=s.streakRewards.filter((n)=>n!==e);if(e===g.MiniEgg)s.scale=1;this.emit("playerEndStreak",s,e)}#E(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat();if(!this.me)return;if(this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0)this.me.streakRewards=this.me.streakRewards.filter((n)=>n!==g.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:s,dz:i});else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:s,dz:i})}#P(){let t={...this.game.options},e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt8U();if(e<1||e>4)e=4;if(s<0||s>8)s=4;if(i>16)i=4;this.game.options.gravity=e/4,this.game.options.damage=s/4,this.game.options.healthRegen=i/4;let n=o.unPackInt8U();Object.keys(Yt).forEach((r)=>{let c=n&Yt[r]?1:0;this.game.options[r]=c}),this.game.options.weaponsDisabled=Array.from({length:7},()=>o.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((r)=>r),this.emit("gameOptionsChange",t,this.game.options)}#N(){let t=o.unPackInt8U();if(t===L.Pause)this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3000);if(t===L.Reset){if(Object.values(this.players).forEach((e)=>e.streak=0),this.game.gameModeId!==M.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===M.Spatula)this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0};if(this.game.gameModeId===M.KOTC)this.game.stage=X.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.capturePercent=0;this.emit("gameReset")}}#R(){if(!this.intents.includes(this.Intents.PING))return;let t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{let e=new p;e.packInt8(a.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1000)}#G(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.team;s.team=e,s.streak=0,this.emit("playerSwitchTeam",s,i,e)}#O(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt16U(),i=o.unPackInt16U(),n=o.unPackInt8U(),r=o.unPackInt16U(),c=o.unPackInt16U(),h=o.unPackInt16U(),m=o.unPackInt16U(),f=o.unPackInt8(),u=o.unPackInt8(),d=this.intents.includes(this.Intents.COSMETIC_DATA),k=d?l(s):s,E=d?l(i):i,N=d?l(r):r,v=d?l(c):c,A=d?l(h):h,Y=d?l(m):m,x=this.players[t];if(x){let z={...x.character},Nt=x.selectedGun;if(x.character.eggColor=n,x.character.primaryGun=k,x.character.secondaryGun=E,x.character.stamp=v,x.character.hat=N,x.character.grenade=A,x.character.melee=Y,x.character.stampPos.x=f,x.character.stampPos.y=u,x.selectedGun=e,x.weapons[0]=new _[e],Nt!==x.selectedGun)this.emit("playerChangeGun",x,Nt,x.selectedGun);if(z!==x.character)this.emit("playerChangeCharacter",x,z,x.character)}}#_(){let t=o.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#v(){this.me.playing=!1,this.emit("respawnDenied")}#A(){let t=o.unPackInt8U(),e=this.players[t];if(e)this.emit("playerMelee",e)}#C(){let t=o.unPackInt8U(),e=this.players[t];if(!e)return;let s=e.weapons[e.activeGun];if(s.ammo){let i=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=i,s.ammo.store-=i}this.emit("playerReload",e,s)}updateGameOptions(){let t=new p;t.packInt8(a.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);let e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach((s)=>{t.packInt8(s?1:0)}),t.send(this.game.socket)}#L(){this.game.isPrivate=!0,this.updateGameOptions()}#F(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))e=l(e);if(t===P.Grenade)this.emit("grenadeExplode",e,{x:s,y:i,z:n},r,c);else this.emit("rocketHit",{x:s,y:i,z:n},r,c)}#q(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat(),c=o.unPackFloat(),h=this.players[t];if(h)h.grenades--,this.emit("playerThrowGrenade",h,{x:e,y:s,z:i},{x:n,y:r,z:c})}#U(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",s,e);let i=this.account.challenges.find((n)=>n.id===e);if(this.emit("challengeComplete",s,i),s.id===this.me.id)this.refreshChallenges()}#W(){let t=new p;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?a.observeGame:a.joinGame),t.packString(this.game.raw.uuid),t.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE)),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packString(this.state.name),t.packInt32(this.account.session),t.packString(this.account.sessionId),t.packString(this.account.firebaseId),t.send(this.game.socket)}async#j(){if(this.me.id=o.unPackInt8U(),this.me.team=o.unPackInt8U(),this.game.gameModeId=o.unPackInt8U(),this.game.gameMode=Ht[this.game.gameModeId],this.game.mapIdx=o.unPackInt8U(),this.game.map=H[this.game.mapIdx],this.game.playerLimit=o.unPackInt8U(),this.game.isGameOwner=o.unPackInt8U()===1,this.game.isPrivate=o.unPackInt8U()===1||this.game.isGameOwner,o.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await Bt(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===M.KOTC){let e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(e){if(this.game.map.zones=Jt(e),!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new St(this.game.map.raw)}this.state.inGame=!0,this.lastDeathTime=Date.now();let t=new p;if(t.packInt8(a.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();let e=new p;e.packInt8(a.ping),e.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){let e=new p;e.packInt8(a.keepAlive),e.send(this.game.socket)}},15000);this.emit("gameReady")}#$(){let t=o.unPackInt8U(),e=o.unPackString(128),s=o.unPackString(32),i=this.players[t];if(!i)return;i.admin={ip:s,dbId:e},this.emit("playerInfo",i,s,e)}packetHandlers={[a.syncThem]:()=>this.#u(),[a.fire]:()=>this.#d(),[a.hitThem]:()=>this.#x(),[a.syncMe]:()=>this.#k(),[a.hitMe]:()=>this.#w(),[a.swapWeapon]:()=>this.#m(),[a.collectItem]:()=>this.#g(),[a.respawn]:()=>this.#a(),[a.die]:()=>this.#p(),[a.pause]:()=>this.#f(),[a.chat]:()=>this.#c(),[a.addPlayer]:()=>this.#h(),[a.removePlayer]:()=>this.#S(),[a.eventModifier]:()=>this.#M(),[a.metaGameState]:()=>this.#y(),[a.beginShellStreak]:()=>this.#z(),[a.endShellStreak]:()=>this.#T(),[a.hitMeHardBoiled]:()=>this.#E(),[a.gameOptions]:()=>this.#P(),[a.ping]:()=>this.#R(),[a.switchTeam]:()=>this.#G(),[a.changeCharacter]:()=>this.#O(),[a.reload]:()=>this.#C(),[a.explode]:()=>this.#F(),[a.throwGrenade]:()=>this.#q(),[a.spawnItem]:()=>this.#l(),[a.melee]:()=>this.#A(),[a.updateBalance]:()=>this.#_(),[a.challengeCompleted]:()=>this.#U(),[a.socketReady]:()=>this.#W(),[a.gameJoined]:()=>this.#j(),[a.gameAction]:()=>this.#N(),[a.requestGameOptions]:()=>this.#L(),[a.respawnDenied]:()=>this.#v(),[a.playerInfo]:()=>this.#$(),[a.expireUpgrade]:()=>{},[a.clientReady]:()=>{},[a.musicInfo]:()=>o.unPackLongString()};processPacket(t){if(o.init(t),this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",t);let e=0,s=0,i=!1;while(o.isMoreDataAvailable()&&!i){let n=o.unPackInt8U(),r=this.packetHandlers[n];if(r)r();else{if(console.error(`processPacket: I got but couldn't identify a: ${Object.keys(a).find((c)=>a[c]===n)} ${n}`),e)console.error(`processPacket: It may be a result of the ${e} command (${s}).`);i=!0;break}if(e=Object.keys(a).find((c)=>a[c]===n),s=n,this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${e}: ${s}`)}}async checkChiknWinner(){let t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000,this.account.cw}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>lt)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";let e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof e==="string")return e;if(e.error){if(e.error==="RATELIMITED"||e.error==="RATELMITED")return await this.checkChiknWinner(),"on_cooldown";else if(e.error==="SESSION_EXPIRED")return this.emit("sessionExpired"),"session_expired";return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}if(e.reward)return this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach((s)=>this.account.ownedItemIds.push(s)),await this.checkChiknWinner(),e.reward;return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";let t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof t==="string")return t;if(t.result!=="SUCCESS")return console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error";return this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}async refreshChallenges(){let t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof t==="string")return t;return this.#i(t),this.account.challenges}async rerollChallenge(t){let e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;return this.#i(e),this.account.challenges}async claimChallenge(t){let e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;if(this.#i(e.challenges),e.reward>0)this.account.eggBalance+=e.reward;return{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){let t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){let e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")return this.account.eggBalance=e.eggs_given,e.item_ids.forEach((s)=>this.account.ownedItemIds.push(s)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids};return e}async claimURLReward(t){let e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async claimSocialReward(t){let e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async buyItem(t){let e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId);return e}processError(...t){let e=t.join(" ");if(this.#e.error&&this.#e.error.length)this.emit("error",e);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(e);else throw Error(e)}leave(t=b.mainMenu){if(this.hasQuit)return;if(t>-1)this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t);clearInterval(this.updateIntervalId),this.#t=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new et({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){if(this.account=this.#s,this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(t=!1){if(this.hasQuit)return;if(this.leave(),this.matchmaker){if(this.matchmaker.close(),!t)delete this.matchmaker}if(!t)delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#o={},this.#e={},this.#n=[],this.#t=[];if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}class Qt{constructor(t,e,s=""){this.uniqueId=t,this.duration=e,this.reason=s}validate(t){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return!1;if(typeof this.duration!=="number"||!Object.values(dt).some((e)=>this.duration===e))return!1;if(!(t.account.adminRoles&4))return!1;return!0}check(){return!0}execute(t){let e=new p;e.packInt8(a.banPlayer),e.packString(this.uniqueId),e.packString(this.reason),e.packInt8(this.duration),e.send(t.game.socket)}}var Xt=Qt;class It{constructor(t){this.uniqueId=t}validate(t){return typeof this.uniqueId==="string"&&t.game.isGameOwner&&Object.values(t.players).find((e)=>e.uniqueId===this.uniqueId)}check(){return!0}execute(t){let e=new p;e.packInt8(a.bootPlayer),e.packString(this.uniqueId),e.send(t.game.socket)}}var Dt=It;class Vt{constructor(t){this.msg=t}validate(){if(typeof this.msg!=="string")return!1;if(this.msg.length<1||this.msg.length>64)return!1;return!0}check(t){if(!t.state?.inGame)return!1;if(!t.game.isPrivate&&!t.account.adminRoles&&t.state.chatLines>=2)return!1;if(!t.game.isPrivate&&!t.account.emailVerified&&!t.account.isAged)return!1;return!0}execute(t){t.state.chatLines++;let e=new p;e.packInt8(a.chat),e.packString(this.msg),e.send(t.game.socket)}}var bt=Vt;class te{constructor(t){this.amount=t||1}validate(){return this.amount>=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee&&t.me.weapons[t.me.activeGun].ammo.rounds>=this.amount}execute(t){t.state.shotsFired+=this.amount||1}}var ee=te;var es=Array.from({length:4},(t,e)=>(e+1)*0.25),ss=Array.from({length:9},(t,e)=>e*0.25),is=Array.from({length:17},(t,e)=>e*0.25),y=(t,e)=>typeof t>"u"?e:t;class se{constructor(t){this.changes=t}#t(t){let e={};if(e.gravity=y(this.changes.gravity,t.game.options.gravity),e.damage=y(this.changes.damage,t.game.options.damage),e.healthRegen=y(this.changes.healthRegen,t.game.options.healthRegen),e.locked=y(this.changes.locked,t.game.options.locked),e.noTeamChange=y(this.changes.noTeamChange,t.game.options.noTeamChange),e.noTeamShuffle=y(this.changes.noTeamShuffle,t.game.options.noTeamShuffle),e.weaponsDisabled=[y(this.changes.disableEggk,t.game.options.weaponsDisabled[0]),y(this.changes.disableScrambler,t.game.options.weaponsDisabled[1]),y(this.changes.disableFreeRanger,t.game.options.weaponsDisabled[2]),y(this.changes.disableRPG,t.game.options.weaponsDisabled[3]),y(this.changes.disableWhipper,t.game.options.weaponsDisabled[4]),y(this.changes.disableCrackshot,t.game.options.weaponsDisabled[5]),y(this.changes.disableTriHard,t.game.options.weaponsDisabled[6])],this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((s)=>e.weaponsDisabled[s]=!0);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((s)=>e.weaponsDisabled[s]=!1);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)e.weaponsDisabled=this.changes.rawWeaponsDisabled.map((s)=>!!s);return e.mustUseSecondary=e.weaponsDisabled.every((s)=>s),e}validate(t){let e=this.#t(t);if(!es.includes(e.gravity))return!1;if(!ss.includes(e.damage))return!1;if(!is.includes(e.healthRegen))return!1;if(typeof e.locked!=="boolean")return!1;if(typeof e.noTeamChange!=="boolean")return!1;if(typeof e.noTeamShuffle!=="boolean")return!1;if(!Array.isArray(e.weaponsDisabled))return!1;if(e.weaponsDisabled.length!==7)return!1;if(e.weaponsDisabled.some((s)=>typeof s!=="boolean"))return!1;return!0}check(t){return t.game.isGameOwner}execute(t){t.game.options=this.#t(t),t.updateGameOptions()}}var ie=se;class Et{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}pop(){let t=this.content[0],e=this.content.pop();if(this.content.length>0)this.content[0]=e,this.sinkDown(0);return t}remove(t){let e=this.content.length;for(let s=0;s<e;s++){if(this.content[s]!==t)continue;let i=this.content.pop();if(s===e-1)break;this.content[s]=i,this.bubbleUp(s),this.sinkDown(s);break}}size(){return this.content.length}bubbleUp(t){let e=this.content[t],s=this.scoreFunction(e);while(t>0){let i=Math.floor((t+1)/2)-1,n=this.content[i];if(s>=this.scoreFunction(n))break;this.content[i]=e,this.content[t]=n,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){let e=this.content.length,s=this.content[t],i=this.scoreFunction(s);while(!0){let n=(t+1)*2,r=n-1,c=null,h;if(r<e){let m=this.content[r];if(h=this.scoreFunction(m),h<i)c=r}if(n<e){let m=this.content[n];if(this.scoreFunction(m)<(c===null?i:h))c=n}if(c===null)break;this.content[t]=this.content[c],this.content[c]=s,t=c}}}class T{constructor(t){this.list=t}heuristic(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)+Math.abs(t.z-e.z)}reversePath(t){let e=[];while(t.parent)e.push(t),t=t.parent;return e.reverse(),e}path(t,e){this.list.clean();let s=new Et((n)=>n.f),i=[];t.h=this.heuristic(t,e),t.g=0,t.f=t.g+t.h,s.push(t);while(s.size()!==0){let n=s.pop();if(n===e)return this.reversePath(n);i.push(n);let r=n.links;for(let c=0;c<r.length;c++){let h=r[c];if(i.includes(h))continue;let m=n.g+1,f=h.visited;if(!f||m<h.g)if(h.visited=!0,h.parent=n,h.g=m,h.h=this.heuristic(h.position,e.position),h.f=h.g+h.h,f)s.rescoreElement(h);else s.push(h)}}return null}}class oe{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[0].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[0]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ne=oe;class re{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.activeZone){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ce=re;class he{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[1].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[1]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ae=he;class ue{idOrName;constructor(t){this.idOrName=t}validate(t){if(!t.intents.includes(t.Intents.PATHFINDING))return!1;if(!this.idOrName)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=t.players[this.idOrName.toString()]||t.players.find((c)=>c.name===this.idOrName),s=Object.entries(t.me.position).map((c)=>Math.floor(c[1])),i=Object.entries(e.position).map((c)=>Math.floor(c[1])),n=t.pathing.nodeList.at(...s),r=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(n,r),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var fe=ue;class me{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=Object.entries(t.me.position).map((r)=>Math.floor(r[1])),s=Object.entries(t.game.spatula.coords).map((r)=>Math.floor(r[1])),i=t.pathing.nodeList.at(...e),n=t.pathing.nodeList.at(...s);if(t.pathing.activePath=this.pather.path(i,n),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var pe=me;var os=(t,e)=>(t%e+e)%e,ns=Math.PI*2,de=(t)=>Math.round(t*8192)/8192,rs=(t)=>de(os(Math.atan2(-t.x,-t.z),ns)),cs=(t)=>de(Math.atan2(t.y,Math.hypot(t.x,t.z)));class le{idOrName;constructor(t){this.idOrName=t}validate(t){return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((r)=>r.name===this.idOrName),s={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-0.05,z:e.position.z-t.me.position.z},i=rs(s),n=cs(s);t.state.yaw=i,t.state.pitch=n}}var ge=le;class xe{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.melee),e.send(t.game.socket),t.usingMelee=!0,setTimeout(()=>{t.usingMelee=!1,t.swappingGun=!0,setTimeout(()=>{t.swappingGun=!1},0.5*xt)},566.6666666666667)}}var we=xe;class ke{validate(){return!0}check(t){return t.me.playing}execute(t){let e=new p;e.packInt8(a.pause),e.send(t.game.socket),setTimeout(()=>t.me.playing=!1,3000)}}var Me=ke;class Se{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.reload),e.send(t.game.socket);let s=t.me.weapons[t.me.activeGun];if(s.ammo){let r=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=r,s.ammo.store-=r}t.emit("playerReload",t.me,s);let i=t.me.weapons[t.me.activeGun],n=i.ammo.rounds<1;t.state.reloading=!0,setTimeout(()=>t.state.reloading=!1,n?i.longReloadTime:i.shortReloadTime)}}var ye=Se;class ze{constructor(t,e={}){if(this.idOrName=t,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],!this.reasons.includes(!0))this.reasons[3]=!0;for(let s=0;s<this.reasons.length;s++)if(this.reasons[s]===!0)this.reasonInt|=1<<s}validate(t){if(this.reasons.every((s)=>s===!1))return!1;if(!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName)))return!1;return!0}check(t){if(!t.state.inGame)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((i)=>i.name===this.idOrName),s=new p;s.packInt8(a.reportPlayer),s.packString(e.uniqueId),s.packInt8(this.reasonInt),s.send(t.game.socket)}}var Te=ze;class Ee{validate(){return!0}check(t){return t.game.isGameOwner}execute(t){let e=new p;e.packInt8(a.gameAction),e.packInt8(L.Reset),e.send(t.game.socket)}}var Pe=Ee;var q=(t)=>l(t)&&l(t).unlock==="default",U=(t,e)=>l(t)&&l(t).item_type_id===e;class Ne{constructor(t){this.changes={classIdx:t.gunId,hatId:t.hatId,stampId:t.stampId,grenadeId:t.grenadeId,meleeId:t.meleeId,colorIdx:t.eggColor,primaryId:t.primaryIds,secondaryId:t.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,e])=>!!e))}validate(t){let e=this.changes;if(e.colorIdx&&e.colorIdx>=7&&!t.account.vip)return!1;if(e.colorIdx&&e.colorIdx>=14)return!1;if(U(e.hatId,P.Hat)&&!q(e.hatId)&&!t.account.ownedItemIds.includes(e.hatId))return!1;if(U(e.stampId,P.Stamp)&&!q(e.stampId)&&!t.account.ownedItemIds.includes(e.stampId))return!1;if(U(e.grenadeId,P.Grenade)&&!q(e.grenadeId)&&!t.account.ownedItemIds.includes(e.grenadeId))return!1;if(U(e.meleeId,P.Melee)&&!q(e.meleeId)&&!t.account.ownedItemIds.includes(e.meleeId))return!1;if(typeof e.classIdx==="number"&&e.classIdx>6||e.classIdx<0)return!1;if(this.changes.primaryId)for(let s=0;s<7;s++){let i=this.changes.primaryId[s];if(!U(i,P.Primary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}if(this.changes.secondaryId)for(let s=0;s<7;s++){let i=this.changes.secondaryId[s];if(!U(i,P.Secondary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}return!0}check(t){return!t.me.playing}execute(t){if(t.me&&this.changes.classIdx&&this.changes.classIdx!==t.me.selectedGun)t.me.weapons[0]=new _[this.changes.classIdx];t.state.weaponIdx=this.changes.classIdx||t.state.weaponIdx;let e={...t.account.loadout,...this.changes},s=t.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:t.account.firebaseId,sessionId:t.account.sessionId,loadout:e});if(t.account.loadout=e,t.me)s.then(()=>{if(t.state.inGame){let n=new p;n.packInt8(a.changeCharacter),n.packInt8(this.changes?.classIdx||t.me.selectedGun),n.send(t.game.socket)}let i=t.intents.includes(t.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([n,r])=>{if(n==="classIdx")t.me.selectedGun=r;else if(n==="hatId")t.me.character.hat=i?l(r):r;else if(n==="stampId")t.me.character.stamp=i?l(r):r;else if(n==="grenadeId")t.me.character.grenade=i?l(r):r;else if(n==="meleeId")t.me.character.melee=i?l(r):r;else if(n==="colorIdx")t.me.character.eggColor=r;else if(n==="primaryId")t.me.character.primaryGun=i?l(r[t.me.selectedGun]):r;else if(n==="secondaryId")t.me.character.secondaryGun=i?l(r[t.me.selectedGun]):r})})}}var Re=Ne;class Ge{validate(){return!0}check(t){if(t.me.playing)return!1;if(t.lastDeathTime+6000<Date.now())return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;return!0}execute(t){let e=new p;e.packInt8(a.requestRespawn),e.send(t.game.socket),t.state.buffer=[]}}var Oe=Ge;class _e{constructor(t){this.manualWeapon=t}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=+!t.me.activeGun;if(typeof this.manualWeapon==="number")e=this.manualWeapon;t.me.activeGun=e;let s=new p;s.packInt8(a.swapWeapon),s.packInt8(t.me.activeGun),s.send(t.game.socket)}}var ve=_e;class Ae{validate(){return!0}check(t){if(!t.state.inGame||t.me.playing)return!1;if(t.game.gameModeId===0)return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;if(t.game.isPrivate)return!t.game.options.noTeamChange;let e=t.players,s=t.me.team,i=e.filter((r)=>r.team===s).length,n=e.filter((r)=>r.team!==s).length;if(n>i)return!1;if(i===n)return!1;return!0}execute(t){let e=new p;e.packInt8(a.switchTeam),e.send(t.game.socket)}}var Ce=Ae;class Le{constructor(t=1){this.power=t}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.throwGrenade),e.packFloat(this.power),e.send(t.game.socket)}}var Fe=Le;var qe={BanPlayerDispatch:Xt,BootPlayerDispatch:Dt,ChatDispatch:bt,FireDispatch:ee,GameOptionsDispatch:ie,GoToAmmoDispatch:ne,GoToCoopDispatch:ce,GoToGrenadeDispatch:ae,GoToPlayerDispatch:fe,GoToSpatulaDispatch:pe,LookAtDispatch:ge,LookAtPosDispatch:J,MeleeDispatch:we,MovementDispatch:K,PauseDispatch:Me,ReloadDispatch:ye,ReportPlayerDispatch:Te,ResetGameDispatch:Pe,SaveLoadoutDispatch:Re,SpawnDispatch:Oe,SwapWeaponDispatch:ve,SwitchTeamDispatch:Ce,ThrowGrenadeDispatch:Fe};var Pt={};it(Pt,{CommOut:()=>p,CommIn:()=>o,CommCode:()=>a,CloseCode:()=>b});var hs={API:D,Bot:Tt,GamePlayer:tt,Matchmaker:st,Dispatches:qe,Comm:Pt,Constants:kt,Guns:pt,Maps:H};window.yolkbot=hs;if(window.onYolkReady&&typeof window.onYolkReady==="function")console.warn("window.onYolkReady is no longer required as of yolkbot 1.3.0. You don't have to put your code inside it anymore."),window.onYolkReady();
1
+ var Ue=Object.defineProperty;var it=(t,e)=>{for(var s in e)Ue(t,s,{get:e[s],enumerable:!0,configurable:!0,set:(i)=>e[s]=()=>i})};var We=globalThis.fetch,Rt=We;console.error("wwws does not support the browser.");var Gt=null;var W={},Z=typeof window<"u"&&typeof HTMLElement<"u",ot=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",Ot=typeof process<"u"&&process.moduleLoadList?.length>0,_t=typeof Deno<"u",vt=typeof process<"u"&&!!process.versions?.bun;if(!Z&&!ot&&!Ot&&!_t&&!vt)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");W.isBrowser=Z;W.isIsolated=!Ot&&!_t&&!vt;W.fetch=Z||ot?globalThis.fetch:Rt;W.WebSocket=Z||ot?globalThis.WebSocket:Gt;var w=W;var kt={};it(kt,{findItemById:()=>l,UserAgent:()=>$,URLRewards:()=>He,Team:()=>Ke,StateBufferSize:()=>j,SocialReward:()=>Je,SocialMedia:()=>wt,ShellStreak:()=>g,PlayType:()=>I,Movement:()=>S,ItemType:()=>P,GunList:()=>_,GunEquipTime:()=>xt,GameOptionFlag:()=>gt,GameMode:()=>M,GameAction:()=>L,FramesBetweenSyncs:()=>C,FirebaseKey:()=>O,CoopState:()=>X,CollectType:()=>Q,ChiknWinnerDailyLimit:()=>lt,ChatFlag:()=>Be,ChallengeType:()=>$e,ChallengeSubType:()=>je,BanDuration:()=>dt});var pt={};it(pt,{SMG:()=>ut,RPEGG:()=>at,M24:()=>ft,Eggk47:()=>nt,DozenGauge:()=>rt,Cluck9mm:()=>ht,CSG1:()=>ct,AUG:()=>mt});var R=class{constructor(){this.adsMod=0.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},nt=class extends R{constructor(){super();this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.05,this.accuracyRecover=0.025,this.tracer=1}},rt=class extends R{constructor(){super();this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=0.16,this.accuracyMax=0.13,this.accuracyLoss=0.17,this.accuracyRecover=0.02,this.adsMod=0.6,this.movementAccuracyMod=0.2,this.tracer=0}},ct=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=0.3,this.accuracyMax=0.004,this.accuracyLoss=0.3,this.accuracyRecover=0.025,this.tracer=0}},ht=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=0.15,this.accuracyMax=0.035,this.accuracyLoss=0.09,this.accuracyRecover=0.08,this.adsMod=0.8,this.movementAccuracyMod=0.6,this.tracer=0}},at=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=0.4,this.accuracyMin=0.3,this.accuracyMax=0.015,this.accuracyLoss=0.3,this.accuracyRecover=0.02,this.radius=2.75}},ut=class extends R{constructor(){super();this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=0.19,this.accuracyMax=0.06,this.accuracyLoss=0.045,this.accuracyRecover=0.05,this.adsMod=0.6,this.movementAccuracyMod=0.7,this.tracer=2}},ft=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=0.35,this.accuracyMax=0,this.accuracyLoss=0.1,this.accuracyRecover=0.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=0.8,this.tracer=0}},mt=class extends R{constructor(){super();this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.037,this.accuracyRecover=0.03,this.adsMod=0.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=0.8,this.movementInstability=2,this.tracer=0}};var l=()=>null;var dt={FiveMinutes:0,FifteenMinutes:1,OneHour:2},je={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},$e={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},Be={None:0,Pinned:2,Team:4,Mod:254,Server:255},lt=3,Q={Ammo:0,Grenade:1},X={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},O="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",C=3,L={Reset:1,Pause:2},M={FFA:0,Team:1,Spatula:2,KOTC:3},gt={Locked:1,NoTeamChange:2,NoTeamShuffle:4},xt=13,_=[nt,rt,ct,at,ut,ft,mt],P={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},S={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},I={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},g={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},wt={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},Je={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},j=256,Ke={Blue:1,Red:2},He=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],$=w.isBrowser?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";class At{url="";proxy="";binaryType="";maxRetries=5;connectionTimeout=5000;constructor(t,e){if(w.isBrowser&&e)throw Error("You cannot pass a proxy to a WebSocket in a browser.");this.url=t,this.proxy=e}async tryConnect(t=1){let e=new URL(this.url),s=async()=>{if(t===5)return!1;return await this.tryConnect(t+1)};try{if(this.socket=w.isBrowser?new w.WebSocket(this.url):new w.WebSocket(this.url,{proxy:this.proxy||null,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",origin:e.origin.replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":$}}),this.binaryType)this.socket.binaryType=this.binaryType}catch(i){return console.error(`Failed to connect on try ${t}, trying again...`,i),await s()}if(this.onBeforeConnect)this.onBeforeConnect();return new Promise((i)=>{let n=setTimeout(async()=>{this.socket.close(),i(await s())},this.connectionTimeout),r=async(c)=>{clearTimeout(n),console.error("WebSocket error",c),i(await s())};this.socket.addEventListener("open",async()=>{clearTimeout(n),this.socket.removeEventListener("error",r),i(!0)}),this.socket.addEventListener("error",r)})}get onmessage(){return this.socket?.onmessage}set onmessage(t){if(this.socket)this.socket.onmessage=t;else console.error("set onmessage before socket existed")}get onclose(){return this.socket?.onclose}set onclose(t){if(this.socket)this.socket.onclose=t;else console.error("set onclose before socket existed")}get onerror(){return this.socket?.onerror}set onerror(t){if(this.socket)this.socket.onerror=t;else console.error("set onclose before socket existed")}send(t){return this.socket?.send(t)}close(t){return this.socket?.close(t)}}var F=At;var B={origin:"https://shellshock.io","user-agent":$,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class D{constructor(t={}){this.proxy=t.proxy,this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.maxRetries=t.maxRetries||5,this.suppressErrors=t.suppressErrors||!1,this.connectionTimeout=t.connectionTimeout||5000}queryServices=async(t)=>{let e=new F(`${this.protocol}://${this.instance}/services/`,this.proxy);if(e.connectionTimeout=this.connectionTimeout,!await e.tryConnect(-2)||e.socket.readyState!==1)return"websocket_connect_fail";return new Promise((i)=>{let n=!1;e.onmessage=(r)=>{n=!0;try{let c=JSON.parse(r.data);i(c)}catch{if(!this.suppressErrors)console.error("queryServices: Bad API JSON response with call:",t.cmd,"and data:",JSON.stringify(t)),console.error("queryServices: Full data sent:",JSON.stringify(t));i("bad_json")}e.close()},e.onerror=()=>!n&&i("unknown_socket_error"),e.onclose=()=>!n&&i("services_closed_early"),e.send(JSON.stringify(t))})};#t=async(t,e,s)=>{if(!t||!e)return"firebase_no_credentials";let i,n;try{i=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${s}?key=${O}`,{method:"POST",body:JSON.stringify({email:t,password:e,returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),n=i.idToken}catch(c){if(c.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(c.code==="auth/missing-email")return"firebase_no_credentials";else if(c.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",i||c);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e,c);return"firebase_unknown_error"}if(!n){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",i);return"firebase_no_token"}this.idToken=n;let r=await this.queryServices({cmd:"auth",firebaseToken:n});return typeof r==="object"?{firebase:i,...r}:r};createAccount=async(t,e)=>await this.#t(t,e,"signUp");loginWithCredentials=async(t,e)=>await this.#t(t,e,"signInWithPassword");loginWithRefreshToken=async(t)=>{if(!t)return"firebase_no_credentials";let e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",t);let s,i;try{s=await(await w.fetch(`https://securetoken.googleapis.com/v1/token?key=${O}`,{method:"POST",body:e,headers:{...B,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),i=s.id_token}catch(r){if(r.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(r.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",r,t);return"firebase_unknown_error"}if(!i){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",s);return"firebase_no_token"}this.idToken=i;let n=await this.queryServices({cmd:"auth",firebaseToken:i});return typeof n==="object"?{firebase:s,...n}:n};loginAnonymously=async()=>{let e=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${O}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),s=e.idToken;if(!s){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",e);return"firebase_no_token"}this.idToken=s;let i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:e,...i}:i};sendEmailVerification=async(t=this.idToken)=>{if(!t)return"no_idtoken_passed";let s=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${O}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:t}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json();if(s.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",s);return"firebase_invalid_response"}return{email:s.email}};verifyOobCode=async(t)=>{if(!t)return"no_oob_code_passed";let s=await(await w.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${O}`,{method:"POST",body:JSON.stringify({oobCode:t}),headers:{...B,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!s.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",s);return"firebase_invalid_response"}return s.email}}var V=D;class Ct{static buffer;static idx;static init(t){this.buffer=new Uint8Array(t),this.idx=0}static isMoreDataAvailable(){return Math.max(0,this.buffer.length-this.idx)}static unPackInt8U(){let t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){let t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){let t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){let t=this.idx;return this.idx+=4,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536+this.buffer[t+3]*16777216}static unPackInt16(){return(this.unPackInt16U()+32768)%65536-32768}static unPackInt32(){return(this.unPackInt32U()+2147483648)%4294967296-2147483648}static unPackRadU(){return this.unPackInt24U()/2097152}static unPackRad(){return this.unPackInt16U()/8192-Math.PI}static unPackFloat(){return this.unPackInt16()/256}static unPackDouble(){return this.unPackInt32()/1048576}static unPackString(t){t=t||255;let e=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(e)}static unPackLongString(t){t=t||16383;let e=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(e)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let s="";for(let i=0;i<t;i++){let n=this.unPackInt16U();if(n>0)s+=String.fromCodePoint(n)}return s}}var o=Ct;class Lt{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){let e=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(e)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){if(typeof t!=="string")t="";this.packInt8(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}packLongString(t){if(typeof t!=="string")t="";this.packInt16(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}}var p=Lt;var Ye={gameNotFound:4000,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023},b=Ye;var Ze={},a=Ze;var Qe=Object.fromEntries(Object.entries(wt).map(([t,e])=>[e,t.toLowerCase()]));class tt{constructor(t,e=null){if(this.id=t.id,this.uniqueId=t.uniqueId,this.name=t.name,this.safeName=t.safeName,this.team=t.team,this.playing=t.playing,this.socials=t.social&&JSON.parse(t.social),this.socials)this.socials.forEach((s)=>s.type=Qe[s.id]);if(this.isVip=t.upgradeProductId>0,this.showBadge=!t.hideBadge||!1,this.streak=t.score,this.streakRewards=Object.values(g).filter((s)=>t.activeShellStreaks&s),this.scale=this.streakRewards.includes(g.MiniEgg)?0.5:1,this.position={x:t.x,y:t.y,z:t.z},this.jumping=t.$controlKeys&S.Jump,this.scoping=t.$controlKeys&S.Scope,this.climbing=!1,this.view={yaw:t.yaw,pitch:t.pitch},this.updateKotcZone(e),this.character={eggColor:t.shellColor,primaryGun:t.primaryWeaponItem,secondaryGun:t.secondaryWeaponItem,stamp:t.stampItem,hat:t.hatItem,grenade:t.grenadeItem,melee:t.meleeItem,stampPos:{x:t.stampPosX,y:t.stampPosY}},this.stats={totalKills:t.totalKills,totalDeaths:t.totalDeaths,bestStreak:t.bestStreak},this.activeGun=t.weaponIdx,this.selectedGun=t.charClass,this.weapons=[],this.character.primaryGun)this.weapons[0]=new _[this.selectedGun],this.weapons[1]=new ht;this.grenades=1,this.hp=t.hp,this.hpShield=0,this.spawnShield=t.shield,this.randomSeed=0}updateKotcZone(t){if(!t)return this.inKotcZone=!1;let e=Math.floor(this.position.x),s=Math.floor(this.position.y),i=Math.floor(this.position.z);this.inKotcZone=t.some((n)=>n.x===e&&n.y===s&&n.z===i)&&this.playing}}var et=tt;var Xe=(t)=>new Uint8Array(t.match(/.{2}/g).map((e)=>parseInt(e,16))),Ie=new TextEncoder,Ft=async(t)=>{if(typeof process<"u"&&typeof process.getBuiltinModule==="function"){let n=process.getBuiltinModule("node:crypto"),r=Buffer.from("3496afb51f42553e31635211400c000b","hex");return n.createHmac("sha256",r).update(t).digest("hex")}let e=Xe("3496afb51f42553e31635211400c000b"),s=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await crypto.subtle.sign("HMAC",s,Ie.encode(t));return Array.from(new Uint8Array(i)).map((n)=>n.toString(16).padStart(2,"0")).join("")},G=(t)=>{return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t-1050359)},qt=(t,e)=>{let s=Math.round(t/(Math.PI*2)*65535),i=0,n=Math.round((e+1.5)/3*32767),r=s<0?0:s;s=r>65535?65535:r;let c=Math.trunc(s);if(c<0)c=0;if(c>4294967295)c=4294967295;c=s>=0?c:0,c=s>65535?0:c;let h=c;i^=h;let m=n<0?0:n;s=m,m=s>32767?32767:s,s=m;let f=Math.trunc(s);if(f<0)f=0;if(f>4294967295)f=4294967295;f=s>=0?f:0,f=s>65535?0:f;let u=f,d=u,k=i^d,E=k&255,N=i<<8,v=(i&65280)>>>8;u=(N|v)>>>0;let Y=E^u;k=k<<8|(k&65280)>>>8,h^=d,d=k^h&255,h=h<<8|(h&65280)>>>8,i=h^i&255;let z=[];return z[3]=G(1050359+(d&63)),z[7]=G(1050359+(u>>>8&63)),z[4]=G(1050359+(k>>>10&63)),z[0]=G(1050359+((i&252)>>>2)),z[5]=G(1050359+(k>>>4&48|Y>>>4&15)),z[2]=G(1050359+(h>>>6&60|d>>>6&3)),z[6]=G(1050359+((u>>>14&3|Y<<2)&63)),z[1]=G(1050359+((h>>>12&15|i<<4)&63)),String.fromCharCode(...z)};class st{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;#e=!1;constructor(t={}){if(this.#t=t.noExitOnError||!1,!t.instance)t.instance="shellshock.io";if(!t.protocol)t.protocol="wss";if(t.api)this.api=t.api;else this.api=new V({proxy:t.proxy,protocol:t.protocol,instance:t.instance,connectionTimeout:t.connectionTimeout});if(t.sessionId||t.noLogin)this.sessionId=t.sessionId;else this.#s();if(t.proxy&&w.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(t.proxy)this.proxy=t.proxy;this.#n(t.instance,t.protocol,t.noLogin,t.connectionTimeout)}async#n(t,e,s,i){if(this.ws=new F(`${e}://${t}/matchmaker/`,this.proxy),this.ws.connectionTimeout=i||5000,!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");if(this.ws.onmessage=async(r)=>{let c=JSON.parse(r.data);if(c.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:await Ft(c.uuid)}));this.#o("msg",c)},this.ws.onclose=()=>{if(this.connected=!1,!this.#e)this.#n(t,e,s,i)},this.connected=!0,this.sessionId||s)this.onceConnected.forEach((r)=>r())}async#s(){let t=await this.api.loginAnonymously();if(!t||typeof t==="string")this.#o("authFail",t);if(this.sessionId=t.sessionId,this.connected)this.onceConnected.forEach((e)=>e())}send(t){this.ws.send(JSON.stringify(t))}async waitForConnect(){return new Promise((t)=>{if(this.connected)t();else this.onceConnected.push(t)})}async getRegions(){await this.waitForConnect();let t=this;return new Promise((e)=>{let s=(i)=>{if(i.command==="regionList")this.regionList=i.regionList,this.off("msg",s),e(i.regionList)};this.on("msg",s),this.ws.onerror=(i)=>t.#i("failed to get regions",i),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#e=!0,this.connected=!1,this.ws.close()}on(t,e){if(!this.onListeners.has(t))this.onListeners.set(t,[]);this.onListeners.get(t).push(e)}once(t,e){if(!this.onceListeners.has(t))this.onceListeners.set(t,[]);this.onceListeners.get(t).push(e)}off(t,e){if(this.onListeners.has(t))this.onListeners.set(t,this.onListeners.get(t).filter((s)=>s!==e));if(this.onceListeners.has(t))this.onceListeners.set(t,this.onceListeners.get(t).filter((s)=>s!==e))}#o(t,...e){if(this.onListeners.has(t))this.onListeners.get(t).forEach((s)=>s(...e));if(this.onceListeners.has(t))this.onceListeners.get(t).forEach((s)=>s(...e)),this.onceListeners.delete(t)}#i(t){if(this.onListeners.has("error"))this.#o("error",t);else if(this.#t)console.error(t);else throw Error(t)}}var Ut=st;var De=(t,e)=>(t%e+e)%e,Ve=Math.PI*2,Wt=(t)=>Math.round(t*8192)/8192,be=(t)=>Wt(De(Math.atan2(-t.x,-t.z),Ve)),ts=(t)=>Wt(Math.atan2(t.y,Math.hypot(t.x,t.z)));class jt{constructor(t){this.pos=t}validate(){return this.pos&&this.pos.x&&this.pos.y&&this.pos.z}check(t){return t.me.playing}execute(t){let e={x:this.pos.x-t.me.position.x,y:this.pos.y-t.me.position.y,z:this.pos.z-t.me.position.z},s=be(e),i=ts(e);t.state.yaw=s,t.state.pitch=i}}var J=jt;class $t{constructor(t){if(typeof t==="number")this.inputKeys=t;else if(typeof t==="object")this.inputKeys=t.reduce((e,s)=>e|s,0)}validate(){if(typeof this.inputKeys!=="number")return!1;if(this.inputKeys&S.Forward&&this.inputKeys&S.Backward)return!1;if(this.inputKeys&S.Left&&this.inputKeys&S.Right)return!1;return!0}check(t){return t.me.playing}execute(t){t.state.controlKeys=this.inputKeys}}var K=$t;class Mt{constructor(t,e){if(this.x=e.x,this.y=e.y,this.z=e.z,this.positionStr=`${this.x},${this.y},${this.z}`,this.position={x:this.x,y:this.y,z:this.z},this.meshType=t.split(".").pop(),this.f=0,this.g=0,this.h=0,this.visited=null,this.parent=null,this.closed=null,this.links=[],this.isStair())if(e.ry)this.ry=e.ry;else this.ry=0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}canLink(t,e){let s=this.x-t.x,i=this.z-t.z,n=this.y-t.y,r=Math.abs(s),c=Math.abs(n),h=Math.abs(i);if(r+c+h===0||r+h>1||this.isFull()||t.isFull())return!1;let m=e.at(this.x,this.y-1,this.z),f=e.at(t.x,t.y-1,t.z);if(!m||!f)return!1;let u={0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}};switch(this.meshType){case"none":if(n===1&&t.canWalkThrough())return!0;if(m.canWalkOn()||m.isLadder()){if(t.meshType==="none"||t.meshType==="ladder"&&c===0||t.meshType==="wedge"&&n===0&&s===-u[t.ry].x&&i===-u[t.ry].z)return!0}return!1;case"ladder":if(c===1&&t.canWalkThrough())return!0;if(c===0&&m.canWalkOn())return!0;if(t.meshType==="ladder"&&(c===1||m.canWalkOn()&&f.canWalkOn()))return!0;return!1;case"wedge":if(this.x+u[this.ry].x===t.x&&this.z+u[this.ry].z===t.z&&this.y+1===t.y)return!0;if(this.x-u[this.ry].x===t.x&&this.z-u[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y))return!0;return!1;default:return!1}}flatCenter(){return{x:this.x+0.5,y:this.y+0,z:this.z+0.5}}flatRadialDistance(t){let e=this.flatCenter();return Math.hypot(e.x-t.x,e.z-t.z)}}class St{list=[];constructor(t){let e={};for(let i of Object.keys(t.data))for(let n of t.data[i])e[n.x<<16|n.y<<8|n.z]=!0,this.list.push(new Mt(i,n));for(let i=0;i<t.width;i++)for(let n=0;n<t.height;n++)for(let r=0;r<t.depth;r++)if(!e[i<<16|n<<8|r])this.list.push(new Mt("SPECIAL.air.none",{x:i,y:n,z:r}));let s=new Map;for(let i of this.list)s.set(i.positionStr,i);for(let i of this.list){let n=[{x:i.x+1,y:i.y,z:i.z},{x:i.x-1,y:i.y,z:i.z},{x:i.x,y:i.y+1,z:i.z},{x:i.x,y:i.y-1,z:i.z},{x:i.x,y:i.y,z:i.z+1},{x:i.x,y:i.y,z:i.z-1}];for(let r of n){let c=`${r.x},${r.y},${r.z}`,h=s.get(c);if(h&&i.canLink(h,this))i.links.push(h)}}}at(t,e,s){if(!this.nodeMap){this.nodeMap=new Map;for(let n of this.list){let r=`${n.x},${n.y},${n.z}`;this.nodeMap.set(r,n)}}let i=`${t},${e},${s}`;return this.nodeMap.get(i)}clean(){for(let t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,e){let s=e.x-t.x,i=e.y-t.y,n=e.z-t.z,r=Math.max(Math.abs(s),Math.abs(i),Math.abs(n)),c=s/r,h=i/r,m=n/r,f=t.x,u=t.y,d=t.z;for(let k=0;k<=r;k++){let E=this.at(Math.round(f),Math.round(u),Math.round(d));if(E&&E.isFull())return!1;f+=c,u+=h,d+=m}return!0}}var Bt=async(t,e)=>{if(!w.isIsolated&&typeof process<"u"){let{existsSync:i,mkdirSync:n,readFileSync:r,writeFileSync:c}=process.getBuiltinModule("node:fs"),{join:h}=process.getBuiltinModule("node:path"),{homedir:m}=process.getBuiltinModule("node:os"),f=h(m(),".yolkbot");if(!i(f))n(f);let u=h(f,"maps");if(!i(u))n(u);let d=h(u,`${t}-${e}.json`);if(i(d))return JSON.parse(r(d,"utf-8"));let k=await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json();return c(d,JSON.stringify(k,null,4),{flag:"w+"}),k}return await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json()},Jt=(t)=>{let e=0,s={},i=[];for(let c of t){if(!s[c.x])s[c.x]={};if(!s[c.x][c.y])s[c.x][c.y]={};s[c.x][c.y][c.z]={zone:null}}let n=[{x:-1,z:0},{x:1,z:0},{x:0,z:-1},{x:0,z:1}],r=(c,h,m)=>s[c]&&s[c][h]&&s[c][h][m]?s[c][h][m]:null;for(let c of t)if(!s[c.x][c.y][c.z].zone){c.zone=++e,s[c.x][c.y][c.z].zone=c.zone;let h=[c],m;do{m=0;for(let f of t)if(!s[f.x][f.y][f.z].zone)for(let u of n){let d=r(f.x+u.x,f.y,f.z+u.z);if(d&&d.zone===c.zone){m++,f.zone=c.zone,s[f.x][f.y][f.z].zone=c.zone,h.push(f);break}}}while(m>0);i.push(h)}return i};var Kt=[];var H=[];var yt=[];var Ht=Object.fromEntries(Object.entries(M).map(([t,e])=>[e,t])),Yt=Object.fromEntries(Object.entries(gt).map(([t,e])=>[t[0].toLowerCase()+t.slice(1),e])),Zt={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},zt=(t,e)=>(t%e+e)%e;class Tt{static Intents=Zt;Intents=Zt;#t=[];#e={};#n=[];#s;#o;constructor(t={}){if(t.proxy&&w.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)){if(!l(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}if(this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.connectionTimeout=t.connectionTimeout||5000,this.state={name:"yolkbot",weaponIdx:0,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new et({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:Ht[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:X.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#o=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:[,,,,,,,].fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{let e=new Date().getUTCDay(),s=new Date().getUTCHours();return e>=5&&s>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new V({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:t?.apiMaxRetries,connectionTimeout:this.connectionTimeout}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(t){if(t.validate(this)){if(t.check(this))t.execute(this);else this.#t.push(t);return!0}return!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.createAccount(t,e);return this.processLoginData(s)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.loginWithCredentials(t,e);return this.processLoginData(s)}async loginWithRefreshToken(t){this.account=this.#s;let e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;let t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){if(typeof t!=="object")return this.emit("authFail",t),t;if(t.banRemaining)return this.emit("banned",t.banRemaining),"account_banned";if(!t.playerOutput)return this.emit("authFail",t),t;if(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<1714546800000,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#i(t.challenges);if(this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#i(t){this.account.challenges=[];for(let e of t){let s=Kt.find((i)=>i.id===e.challengeId);if(!s)continue;delete e.playerId,this.account.challenges.push({raw:{challengeInfo:s,challengeData:e},id:e.challengeId,name:s.loc.title,desc:s.loc.desc,rewardEggs:s.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:s.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){let t=await this.loginAnonymously();if(typeof t!=="object")return t}if(!this.matchmaker){if(this.matchmaker=new Ut({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(e)=>this.emit("authFail",e)),this.matchmaker.on("error",(e)=>this.processError(e))}return!0}async findPublicGame(t,e){if(typeof t!=="string")return"no_region_passed";if(!yt.find((i)=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((i)=>{let n=(r)=>{if(r.command==="notice")return;if(this.matchmaker.off("msg",n),r.command==="gameFound")return i(r);if(r.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(r))};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t,playType:I.JoinPublic,gameType:e,sessionId:this.account.sessionId})})}async createPrivateGame(t,e,s){if(typeof t!=="string")return"no_region_passed";if(!yt.find((r)=>r.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(typeof s!=="string")return"no_map_passed";let i=H.findIndex((r)=>r.name.toLowerCase()===s.toLowerCase());if(i===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((r)=>{let c=(h)=>{if(h.command==="notice")return;if(this.matchmaker.off("msg",c),h.command==="gameFound")return r(h);if(h.error==="sessionNotFound")return r("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(h))};this.matchmaker.on("msg",c),this.matchmaker.send({command:"findGame",region:t,playType:I.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})})}async join(t,e){if(this.state.name=t||"yolkbot",typeof e==="string"){if(e.includes("#"))e=e.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((r)=>{let c=(h)=>{if(h.command==="gameFound")this.matchmaker.off("msg",c),this.game.raw=h,this.game.code=h.id,r(h.id);if(h.error&&h.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",c),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e==="object"){if(this.account.id===0)await this.loginAnonymously();if(this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}let s=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);if(this.game.socket=new F(`${this.protocol}://${s}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.connectionTimeout=this.connectionTimeout,this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(n)=>this.processPacket(n.data),this.game.socket.onclose=(n)=>{if(this.state.left)this.state.left=!1;else this.emit("close",n.code),this.leave(-1)}},!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#r(){if(Object.entries(this.me.position).map((e)=>Math.floor(e[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new K(0));else{let e;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1)e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new J(e));else e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new J(e));for(let s of this.pathing.activePath)if(s.flatRadialDistance(this.me.position)<0.1&&s.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(s)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(s)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&S.Forward))this.dispatch(new K(S.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#r();for(let e=0;e<this.#t.length;e++){let s=this.#t[e];if(s.check(this))s.execute(this),this.#t.splice(e,1)}if(this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333),this.me.playing){let e=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("setting buffer for idx",e),console.log("checking...shotsFired",this.state.shotsFired);if(this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[e]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");let s=new p;s.packInt8(a.syncMe),s.packInt8(this.state.stateIdx),s.packInt8(this.state.serverStateIdx);let i=zt(this.state.stateIdx-C+1,j);for(let n=0;n<C;n++){let r=zt(i+n,j),c=this.state.buffer[r]||{},h=c.controlKeys||0,m=c.shotsFired||0,f=c.yaw??this.state.yaw,u=c.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,i,r,c);s.packInt8(h),s.packInt8(m),s.packString(qt(f,u)),s.packInt8(100)}s.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=zt(this.state.stateIdx+1,j)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;let t=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(let e of Object.values(this.players)){if(e.playing&&e.hp>0){let s=e.streakRewards.includes(g.OverHeal);e.hp+=s?-t:t,e.hp=s?Math.max(100,e.hp):Math.min(100,e.hp)}if(e.spawnShield>0)e.spawnShield-=6}}on(t,e){if(Object.keys(this.#e).includes(t))this.#e[t].push(e);else this.#e[t]=[e]}once(t,e){let s=(...i)=>{e(...i),this.off(t,s)};this.on(t,s)}onAny(t){this.#n.push(t)}off(t,e){if(e)this.#e[t]=this.#e[t].filter((s)=>s!==e);else this.#e[t]=[]}emit(t,...e){if(this.hasQuit)return;if(this.#e[t])for(let s of this.#e[t])s(...e);for(let s of this.#n)s(t,...e)}#c(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,s,e)}#h(){let t=o.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),s={id:t,uniqueId:o.unPackString(),name:o.unPackString(),safeName:o.unPackString(),charClass:o.unPackInt8U(),team:o.unPackInt8U(),primaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),secondaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),shellColor:o.unPackInt8U(),hatItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampPosX:o.unPackInt8(),stampPosY:o.unPackInt8(),grenadeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),meleeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat(),$dx:o.unPackFloat(),$dy:o.unPackFloat(),$dz:o.unPackFloat(),yaw:o.unPackRadU(),pitch:o.unPackRad(),score:o.unPackInt32U(),$kills:o.unPackInt16U(),$deaths:o.unPackInt16U(),$streak:o.unPackInt16U(),totalKills:o.unPackInt32U(),totalDeaths:o.unPackInt32U(),bestStreak:o.unPackInt16U(),$bestOverallStreak:o.unPackInt16U(),shield:o.unPackInt8U(),hp:o.unPackInt8U(),playing:o.unPackInt8U(),weaponIdx:o.unPackInt8U(),$controlKeys:o.unPackInt8U(),upgradeProductId:o.unPackInt8U(),activeShellStreaks:o.unPackInt8U(),social:o.unPackLongString(),hideBadge:o.unPackInt8U()};this.game.mapIdx=o.unPackInt8U(),this.game.isPrivate=o.unPackInt8U()===1,this.game.gameModeId=o.unPackInt8U();let i=new et(s,this.game.gameMode===M.KOTC?this.game.activeZone:null);if(!this.players[s.id])this.players[s.id]=i;if(this.emit("playerJoin",i),this.me.id===s.id)this.me=i,this.emit("botJoin",this.me)}#a(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackInt8U(),h=o.unPackInt8U(),m=o.unPackInt8U(),f=o.unPackInt8U(),u=this.players[t];if(u){if(u.playing=!0,u.randomSeed=e,u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.rounds=r;if(u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.store=c;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.rounds=h;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.store=m;u.grenades=f,u.position={x:s,y:i,z:n},u.spawnShield=120,this.emit("playerRespawn",u)}}#u(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackInt8U(),r=this.players[t];if(!r||r.id===this.me.id){for(let N=0;N<C;N++)o.unPackInt8U(),o.unPackRadU(),o.unPackRad(),o.unPackInt8U();return}for(let N=0;N<C;N++){let v=o.unPackInt8U();if(v&S.Jump)r.jumping=!0;else r.jumping=!1;if(v&S.Scope)r.scoping=!0;else r.scoping=!1;let A={...r.view};if(r.view.yaw=o.unPackRadU(),r.view.pitch=o.unPackRad(),r.view.yaw!==A.yaw||r.view.pitch!==A.pitch)this.emit("playerRotate",r,A,r.view);r.scale=o.unPackInt8U()}let c=r.position,h=c.x!==e||c.y!==s||c.z!==i,m=r.climbing!==n,f=h||m,u=f?{...c}:null;if(c.x!==e)c.x=e;if(c.z!==i)c.z=i;if(!r.jumping||Math.abs(c.y-s)>0.5)c.y=s;if(m)r.climbing=n;if(!f)return;if(this.emit("playerMove",r,u,c),this.game.gameModeId!==M.KOTC)return;let d=this.game.activeZone,k=!!r.inKotcZone;if(!d&&k){r.inKotcZone=!1,this.emit("playerLeaveZone",r);return}r.updateKotcZone(d);let E=!!r.inKotcZone;if(k!==E)r.inKotcZone=E,this.emit(E?"playerEnterZone":"playerLeaveZone",r)}#f(){let t=o.unPackInt8U(),e=this.players[t];if(e){if(e.playing=!1,e.streakRewards)e.streakRewards=[];if(this.emit("playerPause",e),e.inKotcZone)e.inKotcZone=!1,this.emit("playerLeaveZone",e)}}#m(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(s)s.activeGun=e,this.emit("playerSwapWeapon",s,e)}#p(){let t=o.unPackInt8U(),e=o.unPackInt8U();o.unPackInt8U(),o.unPackInt8U();let s=o.unPackInt8U(),i=this.players[t],n=this.players[e],r=i?{...i}:null;if(i){if(i.id===this.me.id)this.lastDeathTime=Date.now();i.playing=!1,i.streak=0,i.hp=100,i.spawnShield=0,i.stats.totalDeaths++,i.inKotcZone=!1,this.emit("playerLeaveZone",i)}if(n){if(n.streak++,n.stats.totalKills++,n.streak>n.stats.bestStreak)n.stats.bestStreak=n.streak}this.emit("playerDeath",i,n,r,s)}#d(){let t=o.unPackInt8U(),e={posX:o.unPackFloat(),posY:o.unPackFloat(),posZ:o.unPackFloat(),dirX:o.unPackFloat(),dirY:o.unPackFloat(),dirZ:o.unPackFloat()},s=this.players[t];if(!s)return;let i=s.weapons[s.activeGun];if(i&&i.ammo)i.ammo.rounds--,this.emit("playerFire",s,i,e)}#l(){let t=o.unPackInt16U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat();this.game.collectables[e].push({id:t,x:s,y:i,z:n}),this.emit("spawnItem",e,{x:s,y:i,z:n},t)}#g(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt16U(),n=this.players[t];if(!n)return;if(this.game.collectables[e]=this.game.collectables[e].filter((r)=>r.id!==i),e===Q.Ammo){let r=n.weapons[s];if(r&&r.ammo)r.ammo.store=Math.min(r.ammo.storeMax,r.ammo.store+r.ammo.pickup),this.emit("playerCollectAmmo",n,r,i)}if(e===Q.Grenade){if(n.grenades++,n.grenades>3)n.grenades=3;this.emit("playerCollectGrenade",n,i)}}#x(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.hp;s.hp=e,this.emit("playerDamage",s,i,s.hp)}#w(){let t=o.unPackInt8U();o.unPackFloat(),o.unPackFloat();let e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#k(){let t=o.unPackInt8U(),e=this.players[t];o.unPackInt8U();let s=o.unPackInt8U(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat();if(this.me.climbing=!!o.unPackInt8U(),o.unPackInt8U(),o.unPackInt8U(),!e)return;this.state.serverStateIdx=s;let c=e.position.x,h=e.position.y,m=e.position.z;if(e.position.x=i,e.position.y=n,e.position.z=r,c!==i||h!==n||m!==r)this.emit("playerMove",e,{x:c,y:h,z:m},{x:i,y:n,z:r})}#M(){let t=new p;t.packInt8(a.eventModifier),t.send(this.game.socket)}#S(){let t=o.unPackInt8U(),e={...this.players[t]};delete this.players[t],this.emit("playerLeave",e)}#y(){if(this.game.gameModeId===M.Spatula){let t={...this.game};this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();let e={x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat()},s=o.unPackInt8U(),i=o.unPackInt8U();this.game.spatula={coords:e,controlledBy:s,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===M.KOTC){let t={...this.game};this.game.stage=o.unPackInt8U(),this.game.zoneNumber=o.unPackInt8U(),this.game.capturing=o.unPackInt8U(),this.game.captureProgress=o.unPackInt16U(),this.game.numCapturing=o.unPackInt8U(),this.game.teamScore[1]=o.unPackInt8U(),this.game.teamScore[2]=o.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1000,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;let e=Object.values(this.players).filter((s)=>s.inKotcZone&&s.playing);if(this.game.activeZone)Object.values(this.players).forEach((s)=>s.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((s)=>{s.inKotcZone=!1,this.emit("playerLeaveZone",s)});this.emit("gameStateChange",t,this.game,e)}else if(this.game.gameModeId===M.Team)this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();if(this.game.gameModeId!==M.Spatula)delete this.game.spatula;if(this.game.gameModeId!==M.KOTC)delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.numCapturing,delete this.game.activeZone;if(this.game.gameModeId===M.FFA)delete this.game.teamScore}#z(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;switch(e){case g.HardBoiled:if(t===this.me.id)this.me.shieldHp=100;s.streakRewards.push(g.HardBoiled);break;case g.EggBreaker:s.streakRewards.push(g.EggBreaker);break;case g.Restock:{if(s.grenades=3,s.weapons[0]&&s.weapons[0].ammo)s.weapons[0].ammo.rounds=s.weapons[0].ammo.capacity,s.weapons[0].ammo.store=s.weapons[0].ammo.storeMax;if(s.weapons[1]&&s.weapons[1].ammo)s.weapons[1].ammo.rounds=s.weapons[1].ammo.capacity,s.weapons[1].ammo.store=s.weapons[1].ammo.storeMax;break}case g.OverHeal:s.hp=Math.min(200,s.hp+100),s.streakRewards.push(g.OverHeal);break;case g.DoubleEggs:s.streakRewards.push(g.DoubleEggs);break;case g.MiniEgg:s.scale=0.5,s.streakRewards.push(g.MiniEgg);break}this.emit("playerBeginStreak",s,e)}#T(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if([g.EggBreaker,g.OverHeal,g.DoubleEggs,g.MiniEgg].includes(e)&&s.streakRewards.includes(e))s.streakRewards=s.streakRewards.filter((n)=>n!==e);if(e===g.MiniEgg)s.scale=1;this.emit("playerEndStreak",s,e)}#E(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat();if(!this.me)return;if(this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0)this.me.streakRewards=this.me.streakRewards.filter((n)=>n!==g.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:s,dz:i});else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:s,dz:i})}#P(){let t={...this.game.options},e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt8U();if(e<1||e>4)e=4;if(s<0||s>8)s=4;if(i>16)i=4;this.game.options.gravity=e/4,this.game.options.damage=s/4,this.game.options.healthRegen=i/4;let n=o.unPackInt8U();Object.keys(Yt).forEach((r)=>{let c=n&Yt[r]?1:0;this.game.options[r]=c}),this.game.options.weaponsDisabled=Array.from({length:7},()=>o.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((r)=>r),this.emit("gameOptionsChange",t,this.game.options)}#N(){let t=o.unPackInt8U();if(t===L.Pause)this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3000);if(t===L.Reset){if(Object.values(this.players).forEach((e)=>e.streak=0),this.game.gameModeId!==M.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===M.Spatula)this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0};if(this.game.gameModeId===M.KOTC)this.game.stage=X.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.capturePercent=0;this.emit("gameReset")}}#R(){if(!this.intents.includes(this.Intents.PING))return;let t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{let e=new p;e.packInt8(a.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1000)}#G(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.team;s.team=e,s.streak=0,this.emit("playerSwitchTeam",s,i,e)}#O(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt16U(),i=o.unPackInt16U(),n=o.unPackInt8U(),r=o.unPackInt16U(),c=o.unPackInt16U(),h=o.unPackInt16U(),m=o.unPackInt16U(),f=o.unPackInt8(),u=o.unPackInt8(),d=this.intents.includes(this.Intents.COSMETIC_DATA),k=d?l(s):s,E=d?l(i):i,N=d?l(r):r,v=d?l(c):c,A=d?l(h):h,Y=d?l(m):m,x=this.players[t];if(x){let z={...x.character},Nt=x.selectedGun;if(x.character.eggColor=n,x.character.primaryGun=k,x.character.secondaryGun=E,x.character.stamp=v,x.character.hat=N,x.character.grenade=A,x.character.melee=Y,x.character.stampPos.x=f,x.character.stampPos.y=u,x.selectedGun=e,x.weapons[0]=new _[e],Nt!==x.selectedGun)this.emit("playerChangeGun",x,Nt,x.selectedGun);if(z!==x.character)this.emit("playerChangeCharacter",x,z,x.character)}}#_(){let t=o.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#v(){this.me.playing=!1,this.emit("respawnDenied")}#A(){let t=o.unPackInt8U(),e=this.players[t];if(e)this.emit("playerMelee",e)}#C(){let t=o.unPackInt8U(),e=this.players[t];if(!e)return;let s=e.weapons[e.activeGun];if(s.ammo){let i=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=i,s.ammo.store-=i}this.emit("playerReload",e,s)}updateGameOptions(){let t=new p;t.packInt8(a.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);let e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach((s)=>{t.packInt8(s?1:0)}),t.send(this.game.socket)}#L(){this.game.isPrivate=!0,this.updateGameOptions()}#F(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))e=l(e);if(t===P.Grenade)this.emit("grenadeExplode",e,{x:s,y:i,z:n},r,c);else this.emit("rocketHit",{x:s,y:i,z:n},r,c)}#q(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat(),c=o.unPackFloat(),h=this.players[t];if(h)h.grenades--,this.emit("playerThrowGrenade",h,{x:e,y:s,z:i},{x:n,y:r,z:c})}#U(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",s,e);let i=this.account.challenges.find((n)=>n.id===e);if(this.emit("challengeComplete",s,i),s.id===this.me.id)this.refreshChallenges()}#W(){let t=new p;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?a.observeGame:a.joinGame),t.packString(this.game.raw.uuid),t.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE)),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packString(this.state.name),t.packInt32(this.account.session),t.packString(this.account.sessionId),t.packString(this.account.firebaseId),t.send(this.game.socket)}async#j(){if(this.me.id=o.unPackInt8U(),this.me.team=o.unPackInt8U(),this.game.gameModeId=o.unPackInt8U(),this.game.gameMode=Ht[this.game.gameModeId],this.game.mapIdx=o.unPackInt8U(),this.game.map=H[this.game.mapIdx],this.game.playerLimit=o.unPackInt8U(),this.game.isGameOwner=o.unPackInt8U()===1,this.game.isPrivate=o.unPackInt8U()===1||this.game.isGameOwner,o.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await Bt(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===M.KOTC){let e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(e){if(this.game.map.zones=Jt(e),!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new St(this.game.map.raw)}this.state.inGame=!0,this.lastDeathTime=Date.now();let t=new p;if(t.packInt8(a.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();let e=new p;e.packInt8(a.ping),e.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){let e=new p;e.packInt8(a.keepAlive),e.send(this.game.socket)}},15000);this.emit("gameReady")}#$(){let t=o.unPackInt8U(),e=o.unPackString(128),s=o.unPackString(32),i=this.players[t];if(!i)return;i.admin={ip:s,dbId:e},this.emit("playerInfo",i,s,e)}packetHandlers={[a.syncThem]:()=>this.#u(),[a.fire]:()=>this.#d(),[a.hitThem]:()=>this.#x(),[a.syncMe]:()=>this.#k(),[a.hitMe]:()=>this.#w(),[a.swapWeapon]:()=>this.#m(),[a.collectItem]:()=>this.#g(),[a.respawn]:()=>this.#a(),[a.die]:()=>this.#p(),[a.pause]:()=>this.#f(),[a.chat]:()=>this.#c(),[a.addPlayer]:()=>this.#h(),[a.removePlayer]:()=>this.#S(),[a.eventModifier]:()=>this.#M(),[a.metaGameState]:()=>this.#y(),[a.beginShellStreak]:()=>this.#z(),[a.endShellStreak]:()=>this.#T(),[a.hitMeHardBoiled]:()=>this.#E(),[a.gameOptions]:()=>this.#P(),[a.ping]:()=>this.#R(),[a.switchTeam]:()=>this.#G(),[a.changeCharacter]:()=>this.#O(),[a.reload]:()=>this.#C(),[a.explode]:()=>this.#F(),[a.throwGrenade]:()=>this.#q(),[a.spawnItem]:()=>this.#l(),[a.melee]:()=>this.#A(),[a.updateBalance]:()=>this.#_(),[a.challengeCompleted]:()=>this.#U(),[a.socketReady]:()=>this.#W(),[a.gameJoined]:()=>this.#j(),[a.gameAction]:()=>this.#N(),[a.requestGameOptions]:()=>this.#L(),[a.respawnDenied]:()=>this.#v(),[a.playerInfo]:()=>this.#$(),[a.expireUpgrade]:()=>{},[a.clientReady]:()=>{},[a.musicInfo]:()=>o.unPackLongString()};processPacket(t){if(o.init(t),this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",t);let e=0,s=0,i=!1;while(o.isMoreDataAvailable()&&!i){let n=o.unPackInt8U(),r=this.packetHandlers[n];if(r)r();else{if(console.error(`processPacket: I got but couldn't identify a: ${Object.keys(a).find((c)=>a[c]===n)} ${n}`),e)console.error(`processPacket: It may be a result of the ${e} command (${s}).`);i=!0;break}if(e=Object.keys(a).find((c)=>a[c]===n),s=n,this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${e}: ${s}`)}}async checkChiknWinner(){let t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000,this.account.cw}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>lt)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";let e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof e==="string")return e;if(e.error){if(e.error==="RATELIMITED"||e.error==="RATELMITED")return await this.checkChiknWinner(),"on_cooldown";else if(e.error==="SESSION_EXPIRED")return this.emit("sessionExpired"),"session_expired";return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}if(e.reward)return this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach((s)=>this.account.ownedItemIds.push(s)),await this.checkChiknWinner(),e.reward;return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";let t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof t==="string")return t;if(t.result!=="SUCCESS")return console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error";return this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}async refreshChallenges(){let t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof t==="string")return t;return this.#i(t),this.account.challenges}async rerollChallenge(t){let e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;return this.#i(e),this.account.challenges}async claimChallenge(t){let e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;if(this.#i(e.challenges),e.reward>0)this.account.eggBalance+=e.reward;return{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){let t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){let e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")return this.account.eggBalance=e.eggs_given,e.item_ids.forEach((s)=>this.account.ownedItemIds.push(s)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids};return e}async claimURLReward(t){let e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async claimSocialReward(t){let e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async buyItem(t){let e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId);return e}processError(...t){let e=t.join(" ");if(this.#e.error&&this.#e.error.length)this.emit("error",e);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(e);else throw Error(e)}leave(t=b.mainMenu){if(this.hasQuit)return;if(t>-1)this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t);clearInterval(this.updateIntervalId),this.#t=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new et({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){if(this.account=this.#s,this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(t=!1){if(this.hasQuit)return;if(this.leave(),this.matchmaker){if(this.matchmaker.close(),!t)delete this.matchmaker}if(!t)delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#o={},this.#e={},this.#n=[],this.#t=[];if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}class Qt{constructor(t,e,s=""){this.uniqueId=t,this.duration=e,this.reason=s}validate(t){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return!1;if(typeof this.duration!=="number"||!Object.values(dt).some((e)=>this.duration===e))return!1;if(!(t.account.adminRoles&4))return!1;return!0}check(){return!0}execute(t){let e=new p;e.packInt8(a.banPlayer),e.packString(this.uniqueId),e.packString(this.reason),e.packInt8(this.duration),e.send(t.game.socket)}}var Xt=Qt;class It{constructor(t){this.uniqueId=t}validate(t){return typeof this.uniqueId==="string"&&t.game.isGameOwner&&Object.values(t.players).find((e)=>e.uniqueId===this.uniqueId)}check(){return!0}execute(t){let e=new p;e.packInt8(a.bootPlayer),e.packString(this.uniqueId),e.send(t.game.socket)}}var Dt=It;class Vt{constructor(t){this.msg=t}validate(){if(typeof this.msg!=="string")return!1;if(this.msg.length<1||this.msg.length>64)return!1;return!0}check(t){if(!t.state?.inGame)return!1;if(!t.game.isPrivate&&!t.account.adminRoles&&t.state.chatLines>=2)return!1;if(!t.game.isPrivate&&!t.account.emailVerified&&!t.account.isAged)return!1;return!0}execute(t){t.state.chatLines++;let e=new p;e.packInt8(a.chat),e.packString(this.msg),e.send(t.game.socket)}}var bt=Vt;class te{constructor(t){this.amount=t||1}validate(){return this.amount>=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee&&t.me.weapons[t.me.activeGun].ammo.rounds>=this.amount}execute(t){t.state.shotsFired+=this.amount||1}}var ee=te;var es=Array.from({length:4},(t,e)=>(e+1)*0.25),ss=Array.from({length:9},(t,e)=>e*0.25),is=Array.from({length:17},(t,e)=>e*0.25),y=(t,e)=>typeof t>"u"?e:t;class se{constructor(t){this.changes=t}#t(t){let e={};if(e.gravity=y(this.changes.gravity,t.game.options.gravity),e.damage=y(this.changes.damage,t.game.options.damage),e.healthRegen=y(this.changes.healthRegen,t.game.options.healthRegen),e.locked=y(this.changes.locked,t.game.options.locked),e.noTeamChange=y(this.changes.noTeamChange,t.game.options.noTeamChange),e.noTeamShuffle=y(this.changes.noTeamShuffle,t.game.options.noTeamShuffle),e.weaponsDisabled=[y(this.changes.disableEggk,t.game.options.weaponsDisabled[0]),y(this.changes.disableScrambler,t.game.options.weaponsDisabled[1]),y(this.changes.disableFreeRanger,t.game.options.weaponsDisabled[2]),y(this.changes.disableRPG,t.game.options.weaponsDisabled[3]),y(this.changes.disableWhipper,t.game.options.weaponsDisabled[4]),y(this.changes.disableCrackshot,t.game.options.weaponsDisabled[5]),y(this.changes.disableTriHard,t.game.options.weaponsDisabled[6])],this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((s)=>e.weaponsDisabled[s]=!0);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((s)=>e.weaponsDisabled[s]=!1);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)e.weaponsDisabled=this.changes.rawWeaponsDisabled.map((s)=>!!s);return e.mustUseSecondary=e.weaponsDisabled.every((s)=>s),e}validate(t){let e=this.#t(t);if(!es.includes(e.gravity))return!1;if(!ss.includes(e.damage))return!1;if(!is.includes(e.healthRegen))return!1;if(typeof e.locked!=="boolean")return!1;if(typeof e.noTeamChange!=="boolean")return!1;if(typeof e.noTeamShuffle!=="boolean")return!1;if(!Array.isArray(e.weaponsDisabled))return!1;if(e.weaponsDisabled.length!==7)return!1;if(e.weaponsDisabled.some((s)=>typeof s!=="boolean"))return!1;return!0}check(t){return t.game.isGameOwner}execute(t){t.game.options=this.#t(t),t.updateGameOptions()}}var ie=se;class Et{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}pop(){let t=this.content[0],e=this.content.pop();if(this.content.length>0)this.content[0]=e,this.sinkDown(0);return t}remove(t){let e=this.content.length;for(let s=0;s<e;s++){if(this.content[s]!==t)continue;let i=this.content.pop();if(s===e-1)break;this.content[s]=i,this.bubbleUp(s),this.sinkDown(s);break}}size(){return this.content.length}bubbleUp(t){let e=this.content[t],s=this.scoreFunction(e);while(t>0){let i=Math.floor((t+1)/2)-1,n=this.content[i];if(s>=this.scoreFunction(n))break;this.content[i]=e,this.content[t]=n,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){let e=this.content.length,s=this.content[t],i=this.scoreFunction(s);while(!0){let n=(t+1)*2,r=n-1,c=null,h;if(r<e){let m=this.content[r];if(h=this.scoreFunction(m),h<i)c=r}if(n<e){let m=this.content[n];if(this.scoreFunction(m)<(c===null?i:h))c=n}if(c===null)break;this.content[t]=this.content[c],this.content[c]=s,t=c}}}class T{constructor(t){this.list=t}heuristic(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)+Math.abs(t.z-e.z)}reversePath(t){let e=[];while(t.parent)e.push(t),t=t.parent;return e.reverse(),e}path(t,e){this.list.clean();let s=new Et((n)=>n.f),i=[];t.h=this.heuristic(t,e),t.g=0,t.f=t.g+t.h,s.push(t);while(s.size()!==0){let n=s.pop();if(n===e)return this.reversePath(n);i.push(n);let r=n.links;for(let c=0;c<r.length;c++){let h=r[c];if(i.includes(h))continue;let m=n.g+1,f=h.visited;if(!f||m<h.g)if(h.visited=!0,h.parent=n,h.g=m,h.h=this.heuristic(h.position,e.position),h.f=h.g+h.h,f)s.rescoreElement(h);else s.push(h)}}return null}}class oe{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[0].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[0]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ne=oe;class re{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.activeZone){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ce=re;class he{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[1].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[1]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ae=he;class ue{idOrName;constructor(t){this.idOrName=t}validate(t){if(!t.intents.includes(t.Intents.PATHFINDING))return!1;if(!this.idOrName)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=t.players[this.idOrName.toString()]||t.players.find((c)=>c.name===this.idOrName),s=Object.entries(t.me.position).map((c)=>Math.floor(c[1])),i=Object.entries(e.position).map((c)=>Math.floor(c[1])),n=t.pathing.nodeList.at(...s),r=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(n,r),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var fe=ue;class me{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=Object.entries(t.me.position).map((r)=>Math.floor(r[1])),s=Object.entries(t.game.spatula.coords).map((r)=>Math.floor(r[1])),i=t.pathing.nodeList.at(...e),n=t.pathing.nodeList.at(...s);if(t.pathing.activePath=this.pather.path(i,n),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var pe=me;var os=(t,e)=>(t%e+e)%e,ns=Math.PI*2,de=(t)=>Math.round(t*8192)/8192,rs=(t)=>de(os(Math.atan2(-t.x,-t.z),ns)),cs=(t)=>de(Math.atan2(t.y,Math.hypot(t.x,t.z)));class le{idOrName;constructor(t){this.idOrName=t}validate(t){return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((r)=>r.name===this.idOrName),s={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-0.05,z:e.position.z-t.me.position.z},i=rs(s),n=cs(s);t.state.yaw=i,t.state.pitch=n}}var ge=le;class xe{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.melee),e.send(t.game.socket),t.usingMelee=!0,setTimeout(()=>{t.usingMelee=!1,t.swappingGun=!0,setTimeout(()=>{t.swappingGun=!1},0.5*xt)},566.6666666666667)}}var we=xe;class ke{validate(){return!0}check(t){return t.me.playing}execute(t){let e=new p;e.packInt8(a.pause),e.send(t.game.socket),setTimeout(()=>t.me.playing=!1,3000)}}var Me=ke;class Se{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.reload),e.send(t.game.socket);let s=t.me.weapons[t.me.activeGun];if(s.ammo){let r=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=r,s.ammo.store-=r}t.emit("playerReload",t.me,s);let i=t.me.weapons[t.me.activeGun],n=i.ammo.rounds<1;t.state.reloading=!0,setTimeout(()=>t.state.reloading=!1,n?i.longReloadTime:i.shortReloadTime)}}var ye=Se;class ze{constructor(t,e={}){if(this.idOrName=t,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],!this.reasons.includes(!0))this.reasons[3]=!0;for(let s=0;s<this.reasons.length;s++)if(this.reasons[s]===!0)this.reasonInt|=1<<s}validate(t){if(this.reasons.every((s)=>s===!1))return!1;if(!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName)))return!1;return!0}check(t){if(!t.state.inGame)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((i)=>i.name===this.idOrName),s=new p;s.packInt8(a.reportPlayer),s.packString(e.uniqueId),s.packInt8(this.reasonInt),s.send(t.game.socket)}}var Te=ze;class Ee{validate(){return!0}check(t){return t.game.isGameOwner}execute(t){let e=new p;e.packInt8(a.gameAction),e.packInt8(L.Reset),e.send(t.game.socket)}}var Pe=Ee;var q=(t)=>l(t)&&l(t).unlock==="default",U=(t,e)=>l(t)&&l(t).item_type_id===e;class Ne{constructor(t){this.changes={classIdx:t.gunId,hatId:t.hatId,stampId:t.stampId,grenadeId:t.grenadeId,meleeId:t.meleeId,colorIdx:t.eggColor,primaryId:t.primaryIds,secondaryId:t.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,e])=>!!e))}validate(t){let e=this.changes;if(e.colorIdx&&e.colorIdx>=7&&!t.account.vip)return!1;if(e.colorIdx&&e.colorIdx>=14)return!1;if(U(e.hatId,P.Hat)&&!q(e.hatId)&&!t.account.ownedItemIds.includes(e.hatId))return!1;if(U(e.stampId,P.Stamp)&&!q(e.stampId)&&!t.account.ownedItemIds.includes(e.stampId))return!1;if(U(e.grenadeId,P.Grenade)&&!q(e.grenadeId)&&!t.account.ownedItemIds.includes(e.grenadeId))return!1;if(U(e.meleeId,P.Melee)&&!q(e.meleeId)&&!t.account.ownedItemIds.includes(e.meleeId))return!1;if(typeof e.classIdx==="number"&&e.classIdx>6||e.classIdx<0)return!1;if(this.changes.primaryId)for(let s=0;s<7;s++){let i=this.changes.primaryId[s];if(!U(i,P.Primary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}if(this.changes.secondaryId)for(let s=0;s<7;s++){let i=this.changes.secondaryId[s];if(!U(i,P.Secondary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}return!0}check(t){return!t.me.playing}execute(t){if(t.me&&this.changes.classIdx&&this.changes.classIdx!==t.me.selectedGun)t.me.weapons[0]=new _[this.changes.classIdx];t.state.weaponIdx=this.changes.classIdx||t.state.weaponIdx;let e={...t.account.loadout,...this.changes},s=t.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:t.account.firebaseId,sessionId:t.account.sessionId,loadout:e});if(t.account.loadout=e,t.me)s.then(()=>{if(t.state.inGame){let n=new p;n.packInt8(a.changeCharacter),n.packInt8(this.changes?.classIdx||t.me.selectedGun),n.send(t.game.socket)}let i=t.intents.includes(t.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([n,r])=>{if(n==="classIdx")t.me.selectedGun=r;else if(n==="hatId")t.me.character.hat=i?l(r):r;else if(n==="stampId")t.me.character.stamp=i?l(r):r;else if(n==="grenadeId")t.me.character.grenade=i?l(r):r;else if(n==="meleeId")t.me.character.melee=i?l(r):r;else if(n==="colorIdx")t.me.character.eggColor=r;else if(n==="primaryId")t.me.character.primaryGun=i?l(r[t.me.selectedGun]):r;else if(n==="secondaryId")t.me.character.secondaryGun=i?l(r[t.me.selectedGun]):r})})}}var Re=Ne;class Ge{validate(){return!0}check(t){if(t.me.playing)return!1;if(t.lastDeathTime+6000<Date.now())return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;return!0}execute(t){let e=new p;e.packInt8(a.requestRespawn),e.send(t.game.socket),t.state.buffer=[]}}var Oe=Ge;class _e{constructor(t){this.manualWeapon=t}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=+!t.me.activeGun;if(typeof this.manualWeapon==="number")e=this.manualWeapon;t.me.activeGun=e;let s=new p;s.packInt8(a.swapWeapon),s.packInt8(t.me.activeGun),s.send(t.game.socket)}}var ve=_e;class Ae{validate(){return!0}check(t){if(!t.state.inGame||t.me.playing)return!1;if(t.game.gameModeId===0)return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;if(t.game.isPrivate)return!t.game.options.noTeamChange;let e=t.players,s=t.me.team,i=e.filter((r)=>r.team===s).length,n=e.filter((r)=>r.team!==s).length;if(n>i)return!1;if(i===n)return!1;return!0}execute(t){let e=new p;e.packInt8(a.switchTeam),e.send(t.game.socket)}}var Ce=Ae;class Le{constructor(t=1){this.power=t}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.throwGrenade),e.packFloat(this.power),e.send(t.game.socket)}}var Fe=Le;var qe={BanPlayerDispatch:Xt,BootPlayerDispatch:Dt,ChatDispatch:bt,FireDispatch:ee,GameOptionsDispatch:ie,GoToAmmoDispatch:ne,GoToCoopDispatch:ce,GoToGrenadeDispatch:ae,GoToPlayerDispatch:fe,GoToSpatulaDispatch:pe,LookAtDispatch:ge,LookAtPosDispatch:J,MeleeDispatch:we,MovementDispatch:K,PauseDispatch:Me,ReloadDispatch:ye,ReportPlayerDispatch:Te,ResetGameDispatch:Pe,SaveLoadoutDispatch:Re,SpawnDispatch:Oe,SwapWeaponDispatch:ve,SwitchTeamDispatch:Ce,ThrowGrenadeDispatch:Fe};var Pt={};it(Pt,{CommOut:()=>p,CommIn:()=>o,CommCode:()=>a,CloseCode:()=>b});var hs={API:D,Bot:Tt,GamePlayer:tt,Matchmaker:st,Dispatches:qe,Comm:Pt,Constants:kt,Guns:pt,Maps:H};window.yolkbot=hs;if(window.onYolkReady&&typeof window.onYolkReady==="function")console.warn("window.onYolkReady is no longer required as of yolkbot 1.3.0. You don't have to put your code inside it anymore."),window.onYolkReady();