hytopia 0.10.11 โ†’ 0.10.12-prerelease-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.
package/bin/scripts.js CHANGED
@@ -79,7 +79,7 @@ async function build() {
79
79
  mainFields: ['module', 'main'],
80
80
  conditions: ['import', 'node'],
81
81
  banner: {
82
- js: 'import { createRequire as __cr } from "module"; import { fileURLToPath } from "url"; import { dirname } from "path"; const require = __cr(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);'
82
+ js: 'import { createRequire as __cr } from "module"; import { fileURLToPath } from "url"; import { dirname as __bundlerDirname } from "path"; const require = __cr(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = __bundlerDirname(__filename);'
83
83
  }
84
84
  });
85
85
  }
@@ -433,55 +433,30 @@ async function packageProject() {
433
433
  return;
434
434
  }
435
435
 
436
- // Make sure assets exist and the model optimizer has been ran
437
- const assetsDir = path.join(sourceDir, 'assets');
438
- let hasOptimizedDir = false;
436
+ // Build the project
437
+ await build();
438
+
439
+ // Test server startup & make sure optimizer has ran
440
+ console.log('๐Ÿงช Testing server startup and making sure optimizer has ran...');
441
+ logDivider();
439
442
 
440
- if (fs.existsSync(assetsDir)) {
441
- // Function to recursively check for .optimized directories
442
- const checkForOptimizedDir = (dir) => {
443
- const items = fs.readdirSync(dir);
444
-
445
- for (const item of items) {
446
- const itemPath = path.join(dir, item);
447
- const stats = fs.statSync(itemPath);
448
-
449
- if (stats.isDirectory()) {
450
- if (item === '.optimized') {
451
- hasOptimizedDir = true;
452
- return true;
453
- }
454
-
455
- // Check subdirectories
456
- if (checkForOptimizedDir(itemPath)) {
457
- return true;
458
- }
459
- }
443
+ const child = spawn(process.execPath, ['--enable-source-maps', 'index.mjs'], { stdio: 'pipe' });
444
+
445
+ await new Promise(resolve => {
446
+ child.stdout.on('data', data => {
447
+ process.stdout.write(data);
448
+
449
+ if (data.toString().includes('Server running')) {
450
+ child.kill();
451
+ resolve();
460
452
  }
461
-
462
- return false;
463
- };
464
-
465
- checkForOptimizedDir(assetsDir);
466
-
467
- if (!hasOptimizedDir) {
468
- console.warn('โŒ Error: No .optimized directories found in the assets folder.');
469
- console.warn(' Make sure your server has ran the optimizer for your models.');
470
- console.warn(' This can be done by running your server with the command `hytopia dev`');
471
- return;
472
- }
473
- } else {
474
- console.warn('โŒ Error: No assets directory found in the project.');
475
- return;
476
- }
477
-
453
+ });
454
+ });
455
+
478
456
  // Prepare to package
479
457
  const outputFile = path.join(sourceDir, `${projectName}.zip`);
480
458
 
481
459
  console.log(`๐Ÿ“ฆ Packaging project "${projectName}"...`);
482
-
483
- // Build the project
484
- await build();
485
460
 
486
461
  // Create a file to stream archive data to
487
462
  const output = fs.createWriteStream(outputFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.10.11",
3
+ "version": "0.10.12-prerelease-2",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./server.mjs",
package/server.mjs CHANGED
@@ -402,7 +402,7 @@ globstar while`,Z,H,J,V,q),this.matchOne(Z.slice(H),J.slice(V),X))return this.de
402
402
  characterSettings { skinTone hairColor eyeColor hairStyle }
403
403
  equippedItems { slot item { slots { flags type modelUrl textureUrl } } }
404
404
  }
405
- }`});try{let $=(await J.next()).value?.data?.userById;if(!$)return p.warning(`PlatformGateway.getPlayerCosmetics(): No cosmetic data returned for user id "${Z}".`);let Y=$.equippedItems.map((W)=>({slot:W.slot,item:W.item.slots.find((G)=>G.type===W.slot)})).filter((W)=>!!W.item),Q=Number($.characterSettings?.hairStyle?.split("_")[1]||1),K=`https://d3qkovarww0lj1.cloudfront.net/?skin_tone=${$.characterSettings?.skinTone||"SKIN_COLOR_1"}&clothing=${$.characterSettings?.clothing||"CLOTHING_1"}&hair_style=${$.characterSettings?.hairStyle||"HAIR_STYLE_1"}&hair_color=${$.characterSettings?.hairColor||"HAIR_COLOR_1"}&eye_color=${$.characterSettings?.eyeColor||"00FF00"}`;return{equippedItems:Y,hairStyle:Q,skinTextureUri:K}}finally{await J.return?.()}}async getPlayerSession(Z){if(!this._creativeGateway)return;return await this._creativeGateway.getSession(Z)}async setData(Z,J){if(J.error)return p.warning("PlatformGateway.setData(): Cannot set data with an error property.");if(!this._creativeGateway&&process.env.NODE_ENV==="production")return p.warning("PlatformGateway.setData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be set.");return this._creativeGateway?await this._creativeGateway.kv.set(Z,J):this._writeDevDataLocally(Z,J)}_readDevDataLocally(Z){try{if(!e$.existsSync(kz))return;let J=D80.join(kz,`${Z}.json`);return JSON.parse(e$.readFileSync(J,"utf8"))}catch(J){p.warning(`PlatformGateway._readDevDataLocally(): Failed to read data for key "${Z}": ${J}`)}}_writeDevDataLocally(Z,J){try{if(!e$.existsSync(kz))e$.mkdirSync(kz,{recursive:!0});let X=D80.join(kz,`${Z}.json`),$={};if(e$.existsSync(X))$=JSON.parse(e$.readFileSync(X,"utf8"));let Y={...$,...J};e$.writeFileSync(X,JSON.stringify(Y,null,2),"utf8")}catch(X){p.warning(`PlatformGateway._writeDevDataLocally(): Failed to write data for key "${Z}": ${X}`)}}}class ZY{static instance=new ZY;constructor(){}async getGlobalData(Z){let J=await O4.instance.getData(Z);if(!J||J.error){if(J?.error)p.warning(`PersistenceManager.getGlobalData(): ${J.error.message}`);return}return J}async getPlayerData(Z){let J=await O4.instance.getData(this._getPlayerKey(Z));if(!J||J.error){if(J?.error)p.warning(`PersistenceManager.getPlayerData(): ${J.error.message}`);return}return J}async setGlobalData(Z,J){let X=await O4.instance.setData(Z,J);if(!X||X.error){if(X?.error)p.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(Z,J){let X=await O4.instance.setData(this._getPlayerKey(Z),J);if(!X||X.error){if(X?.error)p.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(Z){return`player-${Z.id}`}}var R80;(($)=>{$[$.FIRST_PERSON=0]="FIRST_PERSON";$[$.THIRD_PERSON=1]="THIRD_PERSON";$[$.SPECTATOR=2]="SPECTATOR"})(R80||={});var pP;((x)=>{x.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";x.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";x.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";x.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";x.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";x.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";x.SET_FOV="PLAYER_CAMERA.SET_FOV";x.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";x.SET_MODEL_SHOWN_NODES="PLAYER_CAMERA.SET_MODEL_SHOWN_NODES";x.SET_MODE="PLAYER_CAMERA.SET_MODE";x.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";x.SET_SHOULDER_ANGLE="PLAYER_CAMERA.SET_SHOULDER_ANGLE";x.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";x.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";x.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(pP||={});class Ez extends B0{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_modelShownNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_shoulderAngle=0;_trackedEntity;_trackedPosition;_zoom=1;constructor(Z){super();this.player=Z}get attachedToEntity(){return this._attachedToEntity}get attachedToPosition(){return this._attachedToPosition}get facingDirection(){return{x:-Math.sin(this._orientation.yaw)*Math.cos(this._orientation.pitch),y:Math.sin(this._orientation.pitch),z:-Math.cos(this._orientation.yaw)*Math.cos(this._orientation.pitch)}}get facingQuaternion(){let Z=this._orientation.pitch*0.5,J=this._orientation.yaw*0.5,X=Math.cos(Z),$=Math.sin(Z),Y=Math.cos(J),Q=Math.sin(J);return{x:$*Y,y:X*Q,z:-$*Q,w:X*Y}}get filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get modelShownNodes(){return this._modelShownNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get shoulderAngle(){return this._shoulderAngle}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(Z){if(!this._requirePlayerWorld("lookAtEntity"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:Z})}lookAtPosition(Z){if(!this._requirePlayerWorld("lookAtPosition"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:Z})}reset(){this._attachedToEntity=void 0,this._attachedToPosition=void 0,this._orientation={pitch:0,yaw:0},this._trackedEntity=void 0,this._trackedPosition=void 0}setAttachedToEntity(Z){if(!this._requirePlayerWorld("setAttachedToEntity"))return;if(!Z.isSpawned)return p.error(`PlayerCamera.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);this._attachedToEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:Z})}setAttachedToPosition(Z){if(!this._requirePlayerWorld("setAttachedToPosition"))return;this._attachedToPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:Z})}setFilmOffset(Z){if(!this._requirePlayerWorld("setFilmOffset"))return;this._filmOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:Z})}setForwardOffset(Z){if(!this._requirePlayerWorld("setForwardOffset"))return;this._forwardOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:Z})}setFov(Z){if(!this._requirePlayerWorld("setFov"))return;this._fov=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:Z})}setModelHiddenNodes(Z){if(!this._requirePlayerWorld("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setModelShownNodes(Z){if(!this._requirePlayerWorld("setModelShownNodes"))return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_SHOWN_NODES",{playerCamera:this,modelShownNodes:this._modelShownNodes})}setMode(Z){if(!this._requirePlayerWorld("setMode"))return;this._mode=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:Z})}setOffset(Z){if(!this._requirePlayerWorld("setOffset"))return;this._offset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:Z})}setOrientationPitch(Z){this._orientation.pitch=Z}setOrientationYaw(Z){this._orientation.yaw=Z}setShoulderAngle(Z){if(!this._requirePlayerWorld("setShoulderAngle"))return;this._shoulderAngle=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_SHOULDER_ANGLE",{playerCamera:this,shoulderAngle:Z})}setTrackedEntity(Z){if(!this._requirePlayerWorld("setTrackedEntity"))return;this._trackedEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:Z})}setTrackedPosition(Z){if(!this._requirePlayerWorld("setTrackedPosition"))return;this._trackedPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:Z})}setZoom(Z){if(!this._requirePlayerWorld("setZoom"))return;this._zoom=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:Z})}serialize(){return T0.serializePlayerCamera(this)}_requirePlayerWorld(Z){if(!this.player.world)p.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world, invoked method: ${Z}()`);return!!this.player.world}}var nw;((Y)=>{Y.DATA="PLAYER_UI.DATA";Y.LOAD="PLAYER_UI.LOAD";Y.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";Y.SEND_DATA="PLAYER_UI.SEND_DATA"})(nw||={});class Iz extends B0{player;constructor(Z){super();this.player=Z}load(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:Z})}lockPointer(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:Z})}sendData(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:Z})}}var N80=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","u","i","o","j","k","l","n","m","1","2","3","4","5","6","7","8","9","0"],_z;((Q)=>{Q.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";Q.JOINED_WORLD="PLAYER.JOINED_WORLD";Q.LEFT_WORLD="PLAYER.LEFT_WORLD";Q.RECONNECTED_WORLD="PLAYER.RECONNECTED_WORLD";Q.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(_z||={});class gK extends B0{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;cosmetics;ui;_input={};_lastUnreliableInputSequenceNumber=0;_persistedData;_world;_worldSwitched=!1;constructor(Z,J){super();this.id=J?.user.id??`player-${gK._devNextPlayerId++}`,this.username=J?.user.username??this.id,this.profilePictureUrl=J?.user.profilePictureURL??void 0,this.camera=new Ez(this),this.connection=Z,this.cosmetics=O4.instance.getPlayerCosmetics(this.id),this.ui=new Iz(this),Z.onPacket(Y0.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),Z.onPacket(Y0.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),Z.onPacket(Y0.PacketId.INPUT,this._onInputPacket),Z.onPacket(Y0.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),Z.onPacket(Y0.PacketId.UI_DATA_SEND,this._onUIDataSendPacket)}get input(){return this._input}get world(){return this._world}disconnect(){this._leaveWorld(),this.connection.disconnect()}getPersistedData(){return this._persistedData}joinWorld(Z){if(this._world===Z)return;if(!this._world)this._world=Z,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world});else{for(let J of this._world.entityManager.getPlayerEntitiesByPlayer(this))if(J.isSpawned)J.despawn();this.disconnect(),this._world=Z,this._worldSwitched=!0}}async loadInitialPersistedData(){if(this._persistedData)return;this._persistedData=await ZY.instance.getPlayerData(this)??void 0}reconnected(){if(!this._world)return;if(this._lastUnreliableInputSequenceNumber=0,!this._worldSwitched)this.emitWithWorld(this._world,"PLAYER.RECONNECTED_WORLD",{player:this,world:this._world});else this._worldSwitched=!1,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}resetInputs(){this._input={}}setPersistedData(Z){return this._persistedData={...this._persistedData,...Z},ZY.instance.setPlayerData(this,Z).catch((J)=>{}),this._persistedData}serialize(){return T0.serializePlayer(this)}_leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}_onChatMessageSendPacket=(Z)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:Z[1].m})};_onDebugConfigPacket=(Z)=>{console.log(Z)};_onInputPacket=(Z)=>{let J=Z[1];if(J.sq!==void 0){if(J.sq<this._lastUnreliableInputSequenceNumber)return;this._lastUnreliableInputSequenceNumber=J.sq}if(N80.forEach((X)=>{let $=X;if(J[$]!==void 0)this._input[$]=Boolean(J[$])}),J.cp!==void 0)this.camera.setOrientationPitch(J.cp);if(J.cy!==void 0)this.camera.setOrientationYaw(J.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(Z)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:Z[1]})}}var iP;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(iP||={});class bz extends B0{_commandCallbacks={};_world;constructor(Z){super();this._world=Z,this._subscribeToPlayerEvents()}registerCommand(Z,J){this._commandCallbacks[Z]=J}unregisterCommand(Z){delete this._commandCallbacks[Z]}sendBroadcastMessage(Z,J){this._sendBroadcastMessage(void 0,Z,J)}sendPlayerMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:Z,message:J,color:X})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(Z)=>{let{player:J,message:X}=Z,[$,...Y]=X.split(" "),Q=this._commandCallbacks[$];if(Q){Q(J,Y,X);return}this._sendBroadcastMessage(J,X)})}_sendBroadcastMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:Z,message:J,color:X})}}var y5=16,gP=y5-1,aI1=y5**3;class p5{_blocks;_originCoordinate;constructor(Z){this._blocks=new Uint8Array(aI1),this._originCoordinate=Z}get blocks(){return this._blocks}get originCoordinate(){return this._originCoordinate}static blockIndexToLocalCoordinate(Z){return{x:Z%y5,y:(Z/y5|0)%y5,z:Z/(y5*y5)|0}}static globalCoordinateToLocalCoordinate(Z){return{x:Z.x&y5-1,y:Z.y&y5-1,z:Z.z&y5-1}}static globalCoordinateToOriginCoordinate(Z){return{x:Z.x&~(y5-1),y:Z.y&~(y5-1),z:Z.z&~(y5-1)}}getBlockId(Z){return this._blocks[this._getIndex(Z)]}hasBlock(Z){return this._blocks[this._getIndex(Z)]!==0}setBlock(Z,J){if(!this._isValidLocalCoordinate(Z))return p.error("Chunk.setBlock(): Block local coordinate is out of bounds");let X=this._getIndex(Z);this._blocks[X]=J}serialize(){return T0.serializeChunk(this)}_getIndex(Z){return Z.x+(Z.y<<4)+(Z.z<<8)}_isValidLocalCoordinate(Z){return Z.x>=0&&Z.x<=gP&&Z.y>=0&&Z.y<=gP&&Z.z>=0&&Z.z<=gP}}var dP;(($)=>{$.ADD_CHUNK="CHUNK_LATTICE.ADD_CHUNK";$.REMOVE_CHUNK="CHUNK_LATTICE.REMOVE_CHUNK";$.SET_BLOCK="CHUNK_LATTICE.SET_BLOCK"})(dP||={});class hz extends B0{_blockTypeColliders=new Map;_blockTypeCounts=new Map;_chunks=new Map;_rigidBody;_world;constructor(Z){super();this._world=Z}get chunkCount(){return this._chunks.size}clear(){for(let Z of this._blockTypeColliders.values())this._world.simulation.colliderMap.removeColliderBlockType(Z),Z.removeFromSimulation();this._chunks.forEach((Z)=>{this.emitWithWorld(this._world,"CHUNK_LATTICE.REMOVE_CHUNK",{chunkLattice:this,chunk:Z})}),this._blockTypeColliders.clear(),this._blockTypeCounts.clear(),this._chunks.clear()}getBlockId(Z){let J=this.getChunk(p5.globalCoordinateToOriginCoordinate(Z));if(!J)return 0;return J.getBlockId(p5.globalCoordinateToLocalCoordinate(Z))}getBlockTypeCollider(Z){return this._blockTypeColliders.get(Z)}getBlockType(Z){let J=this.getBlockId(Z);return J?this._world.blockTypeRegistry.getBlockType(J):null}getBlockTypeCount(Z){return this._blockTypeCounts.get(Z)??0}getChunk(Z){return this._chunks.get(this._getChunkKey(p5.globalCoordinateToOriginCoordinate(Z)))}getOrCreateBlockTypeCollider(Z,J){let X=this._blockTypeColliders.get(Z);if(X)return X;let Y=this._world.blockTypeRegistry.getBlockType(Z).createCollider(J);return this._blockTypeColliders.set(Z,Y),Y}getOrCreateChunk(Z){let J=p5.globalCoordinateToOriginCoordinate(Z),X=this._chunks.get(this._getChunkKey(J));if(X)return X;return X=new p5(J),this._chunks.set(this._getChunkKey(J),X),this.emitWithWorld(this._world,"CHUNK_LATTICE.ADD_CHUNK",{chunkLattice:this,chunk:X}),X}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(Z){let J=this.getChunk(p5.globalCoordinateToOriginCoordinate(Z));if(!J)return!1;return J.hasBlock(p5.globalCoordinateToLocalCoordinate(Z))}hasChunk(Z){let J=p5.globalCoordinateToOriginCoordinate(Z);return this._chunks.has(this._getChunkKey(J))}setBlock(Z,J){let X=p5.globalCoordinateToLocalCoordinate(Z),$=this.getOrCreateChunk(Z),Y=$.getBlockId(X);if(Y===J)return;if($.setBlock(X,J),!this._rigidBody)this._rigidBody=new l$({type:"fixed"}),this._rigidBody.addToSimulation(this._world.simulation);if(Y!==0){let Q=Math.max(0,(this._blockTypeCounts.get(Y)??0)-1),K=this.getBlockTypeCollider(Y);if(K)if(Q===0)this._world.simulation.colliderMap.removeColliderBlockType(K),K.removeFromSimulation(),this._blockTypeColliders.delete(Y);else K.setVoxel(Z,!1),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set(Y,Q)}if(J!==0){let Q=(this._blockTypeCounts.get(J)??0)+1,K=this.getOrCreateBlockTypeCollider(J,[Z]);if(Q===1){let W=this._world.blockTypeRegistry.getBlockType(J);K.addToSimulation(this._world.simulation,this._rigidBody),this._world.simulation.colliderMap.setColliderBlockType(K,W),this._combineVoxelStates(K)}else K.setVoxel(Z,!0),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set(J,Q)}this.emitWithWorld(this._world,"CHUNK_LATTICE.SET_BLOCK",{chunkLattice:this,chunk:$,globalCoordinate:Z,localCoordinate:X,blockTypeId:J})}_combineVoxelStates(Z){if(Z.isSensor)return;for(let J of this._blockTypeColliders.values()){if(J===Z||J.isSensor)continue;Z.combineVoxelStates(J)}}_getChunkKey(Z){return`${Z.x},${Z.y},${Z.z}`}_propagateVoxelChange(Z,J){if(Z.isSensor)return;for(let X of this._blockTypeColliders.values()){if(X===Z||X.isSensor)continue;Z.propagateVoxelChange(X,J)}}}class Sz{_colliderHandleBlockTypeMap=new Map;_colliderHandleCollisionCallbackMap=new Map;_colliderHandleEntityMap=new Map;_cleanupBlockTypeColliderHandles=new Set;_pendingCleanupBlockTypeColliderHandles=new Set;_cleanupCollisionCallbackColliderHandles=new Set;_pendingCleanupCollisionCallbackColliderHandles=new Set;_cleanupEntityColliderHandles=new Set;_pendingCleanupEntityColliderHandles=new Set;getColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleBlockTypeMap.get(Z.rawCollider.handle)}getColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleCollisionCallbackMap.get(Z.rawCollider.handle)}getColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleEntityMap.get(Z.rawCollider.handle)}getColliderHandleBlockType(Z){return this._colliderHandleBlockTypeMap.get(Z)}getColliderHandleCollisionCallback(Z){return this._colliderHandleCollisionCallbackMap.get(Z)}getColliderHandleEntity(Z){return this._colliderHandleEntityMap.get(Z)}removeColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleBlockType(Z.rawCollider.handle)}removeColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleCollisionCallback(Z.rawCollider.handle)}removeColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleEntity(Z.rawCollider.handle)}removeColliderHandleBlockType(Z){this._colliderHandleBlockTypeMap.delete(Z)}removeColliderHandleCollisionCallback(Z){this._colliderHandleCollisionCallbackMap.delete(Z)}removeColliderHandleEntity(Z){this._colliderHandleEntityMap.delete(Z)}setColliderBlockType(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleBlockType(Z.rawCollider.handle,J)}setColliderCollisionCallback(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleCollisionCallback(Z.rawCollider.handle,J)}setColliderEntity(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleEntity(Z.rawCollider.handle,J)}setColliderHandleBlockType(Z,J){this._colliderHandleBlockTypeMap.set(Z,J),this._cleanupBlockTypeColliderHandles.delete(Z),this._pendingCleanupBlockTypeColliderHandles.delete(Z)}setColliderHandleCollisionCallback(Z,J){this._colliderHandleCollisionCallbackMap.set(Z,J),this._cleanupCollisionCallbackColliderHandles.delete(Z),this._pendingCleanupCollisionCallbackColliderHandles.delete(Z)}setColliderHandleEntity(Z,J){this._colliderHandleEntityMap.set(Z,J),this._cleanupEntityColliderHandles.delete(Z),this._pendingCleanupEntityColliderHandles.delete(Z)}queueColliderHandleForCleanup(Z){if(this._colliderHandleBlockTypeMap.has(Z))this._pendingCleanupBlockTypeColliderHandles.add(Z);if(this._colliderHandleCollisionCallbackMap.has(Z))this._pendingCleanupCollisionCallbackColliderHandles.add(Z);if(this._colliderHandleEntityMap.has(Z))this._pendingCleanupEntityColliderHandles.add(Z)}cleanup(){for(let Z of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(Z);if(this._cleanupBlockTypeColliderHandles.size>0)this._cleanupBlockTypeColliderHandles.clear();for(let Z of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(Z);if(this._cleanupCollisionCallbackColliderHandles.size>0)this._cleanupCollisionCallbackColliderHandles.clear();for(let Z of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(Z);if(this._cleanupEntityColliderHandles.size>0)this._cleanupEntityColliderHandles.clear();for(let Z of this._pendingCleanupBlockTypeColliderHandles)this._cleanupBlockTypeColliderHandles.add(Z);if(this._pendingCleanupBlockTypeColliderHandles.size>0)this._pendingCleanupBlockTypeColliderHandles.clear();for(let Z of this._pendingCleanupCollisionCallbackColliderHandles)this._cleanupCollisionCallbackColliderHandles.add(Z);if(this._pendingCleanupCollisionCallbackColliderHandles.size>0)this._pendingCleanupCollisionCallbackColliderHandles.clear();for(let Z of this._pendingCleanupEntityColliderHandles)this._cleanupEntityColliderHandles.add(Z);if(this._pendingCleanupEntityColliderHandles.size>0)this._pendingCleanupEntityColliderHandles.clear()}_requireSimulatedCollider(Z){if(!Z.rawCollider)p.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!Z.rawCollider}}var O80={type:"dynamic",softCcdPrediction:1},P80=0.015625,T80=Math.cos(0.026),Az;((L)=>{L.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";L.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";L.DESPAWN="ENTITY.DESPAWN";L.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";L.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";L.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";L.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";L.SET_MODEL_SCALE="ENTITY.SET_MODEL_SCALE";L.SET_MODEL_SHOWN_NODES="ENTITY.SET_MODEL_SHOWN_NODES";L.SET_MODEL_TEXTURE_URI="ENTITY.SET_MODEL_TEXTURE_URI";L.SET_OPACITY="ENTITY.SET_OPACITY";L.SET_PARENT="ENTITY.SET_PARENT";L.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";L.SPAWN="ENTITY.SPAWN";L.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";L.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";L.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";L.TICK="ENTITY.TICK";L.UPDATE_POSITION="ENTITY.UPDATE_POSITION";L.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(Az||={});class j8 extends l${_id;_blockHalfExtents;_blockTextureUri;_controller;_isEnvironmental=!1;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelPreferredShape;_modelScale=1;_modelShownNodes=new Set;_modelTextureUri;_modelUri;_name;_opacity;_parent;_parentNodeName;_tag;_tintColor;_lastUpdatedPosition={x:0,y:0,z:0};_lastUpdatedRotation={x:0,y:0,z:0,w:1};_lastParentlessType="dynamic";_world;_positionUpdateThresholdSq;_rotationUpdateThreshold;constructor(Z){let J="blockTextureUri"in Z,X="modelUri"in Z;if(!J===!X)p.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J&&!Z.blockHalfExtents)p.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(Z.parent&&!Z.parent.isSpawned)p.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(Z.parent?.modelUri&&Z.parentNodeName&&!j6.instance.modelHasNode(Z.parent.modelUri,Z.parentNodeName))p.fatalError(`Entity.constructor(): Parent node name ${Z.parentNodeName} not found in parent model ${Z.parent.modelUri}!`);super(Z.rigidBodyOptions??O80);if(J)this._blockHalfExtents=Z.blockHalfExtents,this._blockTextureUri=Z.blockTextureUri;if(X)this._modelAnimationsPlaybackRate=Z.modelAnimationsPlaybackRate??1,this._modelPreferredShape=Z.modelPreferredShape,this._modelScale=Z.modelScale??1,this._modelTextureUri=Z.modelTextureUri,this._modelUri=Z.modelUri,Z.modelHiddenNodes?.forEach(($)=>this._modelHiddenNodes.add($.toLowerCase())),Z.modelLoopedAnimations?.forEach(($)=>this._modelLoopedAnimations.add($)),Z.modelShownNodes?.forEach(($)=>this._modelShownNodes.add($.toLowerCase()));if(this._isEnvironmental=Z.isEnvironmental??!1,this._name=Z.name??"Nameless",this._opacity=Z.opacity??1,this._parent=Z.parent,this._parentNodeName=Z.parentNodeName,this._tag=Z.tag,this._tintColor=Z.tintColor,this._positionUpdateThresholdSq=P80,this._rotationUpdateThreshold=T80,Z.controller)this.setController(Z.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get depth(){return this.isModelEntity?j6.instance.getDepth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.z*2}get height(){return this.isModelEntity?j6.instance.getHeight(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.y*2}get modelAnimationsPlaybackRate(){return this._modelAnimationsPlaybackRate}get modelHiddenNodes(){return this._modelHiddenNodes}get modelLoopedAnimations(){return this._modelLoopedAnimations}get modelPreferredShape(){return this._modelPreferredShape}get modelScale(){return this._modelScale}get modelShownNodes(){return this._modelShownNodes}get modelTextureUri(){return this._modelTextureUri}get modelUri(){return this._modelUri}get name(){return this._name}get opacity(){return this._opacity}get parent(){return this._parent}get parentNodeName(){return this._parentNodeName}get tag(){return this._tag}get tintColor(){return this._tintColor}get isBlockEntity(){return!!this._blockTextureUri}get isEnvironmental(){return this._isEnvironmental}get isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get width(){return this.isModelEntity?j6.instance.getWidth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.x*2}get world(){return this._world}spawn(Z,J,X){if(this.isSpawned)return p.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(Z.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new m5(m5.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0&&this._modelPreferredShape!=="none")this.addChildColliderToSimulation(new m5(m5.optionsFromModelUri(this._modelUri,this._modelScale,this._modelPreferredShape)));if(this.colliders.forEach(($)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))$.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups($.collisionGroups)){let Y=this.isEnvironmental?[8]:[$.isSensor?4:2],Q=this.isEnvironmental?[65535&~8&~1]:[65535];$.setCollisionGroups({belongsTo:Y,collidesWith:Q})}}),this.setPosition(J),X)this.setRotation(X);if(this._id=Z.entityManager.registerEntity(this),this._world=Z,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,J,X);this.colliders.forEach(($)=>{Z.simulation.colliderMap.setColliderEntity($,this)}),this.emitWithWorld(Z,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((Z)=>{Z.despawn()}),this._controller)this._controller.detach(this),this._controller.despawn(this);if(this.emitWithWorld(this._world,"ENTITY.DESPAWN",{entity:this}),this.isSimulated)this.removeFromSimulation();this._world.entityManager.unregisterEntity(this),this._world.audioManager.unregisterEntityAttachedAudios(this),this._world.lightManager.despawnEntityAttachedLights(this),this._world.particleEmitterManager.despawnEntityAttachedParticleEmitters(this),this._world.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setController(Z){if(this._controller===Z)return;if(this._controller)this._controller.detach(this);if(this._controller=Z,this._controller)this._controller.attach(this)}setModelAnimationsPlaybackRate(Z){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===Z)return;this._modelAnimationsPlaybackRate=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:Z})}setModelHiddenNodes(Z){if(!this._requireSpawned("setModelHiddenNodes"))return;if(!this.isModelEntity)return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setModelScale(Z){if(!this._requireSpawned("setModelScale"))return;if(!this.isModelEntity||this._modelScale===Z)return;let J=Z/this._modelScale;this._modelScale=Z,this.colliders.forEach((X)=>X.scale(J)),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SCALE",{entity:this,modelScale:Z})}setModelShownNodes(Z){if(!this._requireSpawned("setModelShownNodes"))return;if(!this.isModelEntity)return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SHOWN_NODES",{entity:this,modelShownNodes:this._modelShownNodes})}setModelTextureUri(Z){if(!this._requireSpawned("setModelTextureUri"))return;if(!this.isModelEntity||this._modelTextureUri===Z)return;this._modelTextureUri=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_TEXTURE_URI",{entity:this,modelTextureUri:Z})}setOpacity(Z){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===Z)return;this._opacity=Z,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:Z})}setParent(Z,J,X,$){if(!this._requireSpawned("setParent"))return;if(Z&&!Z.isSpawned)return p.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&Z)this._lastParentlessType=this.type;if(this._parent=Z,this._parentNodeName=J,this.colliders.forEach((Y)=>Y.setEnabled(!Z)),this.setType(!Z?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation($??{x:0,y:0,z:0,w:1}),!this.isKinematicPositionBased)this.resetAngularVelocity(),this.resetForces(),this.resetLinearVelocity(),this.resetTorques();this.emitWithWorld(this._world,"ENTITY.SET_PARENT",{entity:this,parent:Z,parentNodeName:J})}setTintColor(Z){if(!this._requireSpawned("setTintColor"))return;if(!Z&&!this._tintColor||Z&&this._tintColor&&Z.r===this._tintColor.r&&Z.g===this._tintColor.g&&Z.b===this._tintColor.b)return;this._tintColor=Z,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:Z})}startModelLoopedAnimations(Z){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>!this._modelLoopedAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(Z)})}startModelOneshotAnimations(Z){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!Z.length)return;Z.forEach((J)=>{this._modelOneshotAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(Z)})}stopAllModelAnimations(Z=[]){if(!this._requireSpawned("stopAllModelAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations,this._modelOneshotAnimations],Z)}stopAllModelLoopedAnimations(Z=[]){if(!this._requireSpawned("stopAllModelLoopedAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations],Z)}stopAllModelOneshotAnimations(Z=[]){if(!this._requireSpawned("stopAllModelOneshotAnimations"))return;this._stopAnimationsFromSets([this._modelOneshotAnimations],Z)}stopModelAnimations(Z){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>this._modelLoopedAnimations.has(J))&&!Z.some((J)=>this._modelOneshotAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.delete(J),this._modelOneshotAnimations.delete(J)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(Z)})}serialize(){return T0.serializeEntity(this)}tick(Z){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:Z}),this._controller)this._controller.tick(this,Z)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let Z=this.position,J=this.rotation;if(this._rotationExceedsThreshold(J,this._lastUpdatedRotation))this._lastUpdatedRotation=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:J});if(this._positionExceedsThreshold(Z,this._lastUpdatedPosition))this._lastUpdatedPosition=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:Z})}_positionExceedsThreshold(Z,J){let X=Z.x-J.x,$=Z.y-J.y,Y=Z.z-J.z;return X*X+$*$+Y*Y>this._positionUpdateThresholdSq}_requireSpawned(Z){if(!this.isSpawned)p.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${Z}()!`);return this.isSpawned}_rotationExceedsThreshold(Z,J){return Math.abs(Z.x*J.x+Z.y*J.y+Z.z*J.z+Z.w*J.w)<this._rotationUpdateThreshold}_stopAnimationsFromSets(Z,J=[]){if(!this.isModelEntity)return;let X=new Set(J),$=[];for(let Y of Z)for(let Q of Y)if(!X.has(Q))$.push(Q);if($.length>0)this.stopModelAnimations($)}}class b1 extends w${static BASE_ENTITY_HEIGHT=1.5;static GROUND_SENSOR_HEIGHT_SCALE=0.125;static GROUND_SENSOR_RADIUS_SCALE=0.23;static JUMP_LAND_HEAVY_VELOCITY_THRESHOLD=-12;static WALL_COLLIDER_HEIGHT_SCALE=0.33;static WALL_COLLIDER_RADIUS_SCALE=0.4;static MOVEMENT_ROTATIONS={wa:Math.PI/4,wd:-Math.PI/4,sa:Math.PI-Math.PI/4,sd:Math.PI+Math.PI/4,s:Math.PI,asd:Math.PI,a:Math.PI/2,d:-Math.PI/2};static EXTERNAL_IMPULSE_DECAY_RATE=0.253;static SWIM_UPWARD_COOLDOWN_MS=600;static SWIMMING_DRAG_FACTOR=0.05;static WATER_ENTRY_SINKING_FACTOR=0.8;static WATER_ENTRY_SINKING_MS=250;applyDirectionalMovementRotations=!0;autoCancelMouseLeftClick=!0;canJump=()=>!0;canRun=()=>!0;canSwim=()=>!0;canWalk=()=>!0;faceForwardOnStop=!0;idleLoopedAnimations=["idle-upper","idle-lower"];interactOneshotAnimations=["simple-interact"];jumpLandHeavyOneshotAnimations=["jump-post-heavy"];jumpLandLightOneshotAnimations=["jump-post-light"];jumpOneshotAnimations=["jump-loop"];jumpVelocity=10;runLoopedAnimations=["run-upper","run-lower"];runVelocity=8;sticksToPlatforms=!0;swimFastVelocity=5;swimGravity=0;swimIdleLoopedAnimations=["swim-idle"];swimLoopedAnimations=["swim-forward"];swimMaxGravityVelocity=-1;swimSlowVelocity=3;swimUpwardVelocity=2;walkLoopedAnimations=["walk-upper","walk-lower"];walkVelocity=4;_externalVelocity={x:0,y:0,z:0};_magnitudeYTracker=0;_groundContactCount=0;_internalApplyImpulse=()=>{};_isActivelyMoving=!1;_isFullySubmerged=!1;_justSubmergedUntil=0;_liquidContactCount=0;_platform;_reusableImpulse={x:0,y:0,z:0};_reusablePlatformVelocity={x:0,y:0,z:0};_reusableTargetVelocities={x:0,y:0,z:0};_reusableVelocityClamp={x:0,y:0,z:0};_stepAudio;_swimUpwardCooldownAt=0;constructor(Z={}){super();this.applyDirectionalMovementRotations=Z.applyDirectionalMovementRotations??this.applyDirectionalMovementRotations,this.autoCancelMouseLeftClick=Z.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.faceForwardOnStop=Z.faceForwardOnStop??this.faceForwardOnStop,this.sticksToPlatforms=Z.sticksToPlatforms??this.sticksToPlatforms,this.canJump=Z.canJump??this.canJump,this.canRun=Z.canRun??this.canRun,this.canSwim=Z.canSwim??this.canSwim,this.canWalk=Z.canWalk??this.canWalk,this.jumpVelocity=Z.jumpVelocity??this.jumpVelocity,this.runVelocity=Z.runVelocity??this.runVelocity,this.walkVelocity=Z.walkVelocity??this.walkVelocity,this.swimFastVelocity=Z.swimFastVelocity??this.swimFastVelocity,this.swimSlowVelocity=Z.swimSlowVelocity??this.swimSlowVelocity,this.swimUpwardVelocity=Z.swimUpwardVelocity??this.swimUpwardVelocity,this.swimGravity=Z.swimGravity??this.swimGravity,this.swimMaxGravityVelocity=Z.swimMaxGravityVelocity??this.swimMaxGravityVelocity,this.idleLoopedAnimations=Z.idleLoopedAnimations??this.idleLoopedAnimations,this.interactOneshotAnimations=Z.interactOneshotAnimations??this.interactOneshotAnimations,this.jumpOneshotAnimations=Z.jumpOneshotAnimations??this.jumpOneshotAnimations,this.jumpLandHeavyOneshotAnimations=Z.jumpLandHeavyOneshotAnimations??this.jumpLandHeavyOneshotAnimations,this.jumpLandLightOneshotAnimations=Z.jumpLandLightOneshotAnimations??this.jumpLandLightOneshotAnimations,this.runLoopedAnimations=Z.runLoopedAnimations??this.runLoopedAnimations,this.swimLoopedAnimations=Z.swimLoopedAnimations??this.swimLoopedAnimations,this.swimIdleLoopedAnimations=Z.swimIdleLoopedAnimations??this.swimIdleLoopedAnimations,this.walkLoopedAnimations=Z.walkLoopedAnimations??this.walkLoopedAnimations}get isActivelyMoving(){return this._isActivelyMoving}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get isSwimming(){return this._liquidContactCount>0}get platform(){return this._platform}attach(Z){super.attach(Z),this._internalApplyImpulse=Z.applyImpulse.bind(Z),Z.applyImpulse=(J)=>{let X=Z.mass||1;this._externalVelocity.x+=J.x/X,this._externalVelocity.y+=J.y/X,this._externalVelocity.z+=J.z/X},this._stepAudio=new RW({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,referenceDistance:2,cutoffDistance:15,attachedToEntity:Z}),Z.setCcdEnabled(!0),Z.lockAllRotations(),Z.on("ENTITY.BLOCK_COLLISION",({blockType:J,started:X})=>{if(!J.isLiquid||!this.canSwim(this))return;if(this._liquidContactCount<=0&&X){let $=Z.linearVelocity;Z.setLinearVelocity({x:$.x*this.swimGravity,y:$.y*this.swimGravity,z:$.z*this.swimGravity})}if(this._liquidContactCount+=X?1:-1,this._liquidContactCount>0)Z.setGravityScale(this.swimGravity),Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),this._swimUpwardCooldownAt=performance.now()+b1.SWIM_UPWARD_COOLDOWN_MS;else Z.setGravityScale(1),Z.stopModelAnimations(this.swimLoopedAnimations)})}spawn(Z){if(!Z.isSpawned)return p.error("DefaultPlayerEntityController.spawn(): Entity is not spawned!");Z.createAndAddChildCollider({shape:"cylinder",radius:b1.GROUND_SENSOR_RADIUS_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),halfHeight:b1.GROUND_SENSOR_HEIGHT_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},isSensor:!0,relativePosition:{x:0,y:-Z.height/2,z:0},tag:"groundSensor",onCollision:(J,X)=>{if(!Z.isSpawned)return;if(!(J instanceof u5)||!J.isLiquid){if(X&&this._groundContactCount===0&&Z.linearVelocity.y<-1)if(Z.linearVelocity.y<b1.JUMP_LAND_HEAVY_VELOCITY_THRESHOLD)Z.startModelOneshotAnimations(this.jumpLandHeavyOneshotAnimations);else Z.startModelOneshotAnimations(this.jumpLandLightOneshotAnimations);this._groundContactCount+=X?1:-1}if(!this._groundContactCount&&!this.isSwimming)Z.startModelOneshotAnimations(this.jumpOneshotAnimations);else Z.stopModelAnimations(this.jumpOneshotAnimations);if(!(J instanceof j8))return;if(X&&this.sticksToPlatforms)this._platform=J;else if(J===this._platform&&!X)this._platform=void 0}}),Z.createAndAddChildCollider({shape:"capsule",halfHeight:b1.WALL_COLLIDER_HEIGHT_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),radius:b1.WALL_COLLIDER_RADIUS_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(Z,J,X,$){if(!Z.isSpawned||!Z.world)return;if(super.tickWithPlayerInput(Z,J,X,$),Z.parent)return;let{w:Y,a:Q,s:K,d:W,c:G,sp:z,sh:v,ml:H}=J,{yaw:V}=X,q=Z.linearVelocity;this._reusableTargetVelocities.x=0,this._reusableTargetVelocities.y=0,this._reusableTargetVelocities.z=0,this._isActivelyMoving=!!(Y||Q||K||W);let F=v,x=Q&&W&&!Y&&!K||Y&&K&&!Q&&!W,w=F&&this.canRun(this)||!F&&this.canWalk(this);if(this.isSwimming&&!this._isFullySubmerged)this._isFullySubmerged=!0,this._justSubmergedUntil=performance.now()+b1.WATER_ENTRY_SINKING_MS;else if(!this.isSwimming)this._isFullySubmerged=!1,this._justSubmergedUntil=0;if(this.isGrounded&&!this.isSwimming&&this._isActivelyMoving&&!x&&w){let M=F?this.runLoopedAnimations:this.walkLoopedAnimations;Z.stopAllModelLoopedAnimations(M),Z.startModelLoopedAnimations(M),this._stepAudio?.setPlaybackRate(F?0.75:0.51),this._stepAudio?.play(Z.world,!this._stepAudio?.isPlaying)}else if(this._isFullySubmerged&&this.canSwim(this))if(this._stepAudio?.pause(),this._isActivelyMoving)Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),Z.startModelLoopedAnimations(this.swimLoopedAnimations);else Z.stopAllModelLoopedAnimations(this.swimIdleLoopedAnimations),Z.startModelLoopedAnimations(this.swimIdleLoopedAnimations);else this._stepAudio?.pause(),Z.stopAllModelLoopedAnimations(this.idleLoopedAnimations),Z.startModelLoopedAnimations(this.idleLoopedAnimations);let c;if(this.applyDirectionalMovementRotations&&w){if(Y&&Q&&!W&&!K)c=b1.MOVEMENT_ROTATIONS.wa;else if(Y&&W&&!Q&&!K)c=b1.MOVEMENT_ROTATIONS.wd;else if(K&&Q&&!Y&&!W)c=b1.MOVEMENT_ROTATIONS.sa;else if(K&&W&&!Y&&!Q)c=b1.MOVEMENT_ROTATIONS.sd;else if(K&&!Y&&!Q&&!W||Q&&K&&W&&!Y)c=b1.MOVEMENT_ROTATIONS.s;else if(Q&&!Y&&!K&&!W)c=b1.MOVEMENT_ROTATIONS.a;else if(W&&!Y&&!Q&&!K)c=b1.MOVEMENT_ROTATIONS.d}if(H)Z.startModelOneshotAnimations(this.interactOneshotAnimations),J.ml=!this.autoCancelMouseLeftClick;if(w){let M=!this.isSwimming?F?this.runVelocity:this.walkVelocity:F?this.swimFastVelocity:this.swimSlowVelocity,N=Math.sin(V),P=Math.cos(V);if(Y)this._reusableTargetVelocities.x-=M*N,this._reusableTargetVelocities.z-=M*P;if(K)this._reusableTargetVelocities.x+=M*N,this._reusableTargetVelocities.z+=M*P;if(Q)this._reusableTargetVelocities.x-=M*P,this._reusableTargetVelocities.z+=M*N;if(W)this._reusableTargetVelocities.x+=M*P,this._reusableTargetVelocities.z-=M*N;let O=Math.sqrt(this._reusableTargetVelocities.x*this._reusableTargetVelocities.x+this._reusableTargetVelocities.z*this._reusableTargetVelocities.z);if(O>M){let _=M/O;this._reusableTargetVelocities.x*=_,this._reusableTargetVelocities.z*=_}}if(this.isSwimming){if(q.y<this.swimMaxGravityVelocity)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimMaxGravityVelocity,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(q.y>this.swimUpwardVelocity*2)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimUpwardVelocity*2,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(G)this._reusableTargetVelocities.y=-this.swimUpwardVelocity;else if(performance.now()<this._justSubmergedUntil)this._reusableTargetVelocities.y=-this.swimUpwardVelocity*b1.WATER_ENTRY_SINKING_FACTOR;else if(!z)this._reusableTargetVelocities.y=-q.y*b1.SWIMMING_DRAG_FACTOR}if(z&&this.canJump(this)){if(this.isGrounded&&!this.isSwimming&&q.y>-0.001&&q.y<=3)this._reusableTargetVelocities.y=this.jumpVelocity;else if(this.isSwimming&&performance.now()>this._swimUpwardCooldownAt)this._reusableTargetVelocities.y=this.swimUpwardVelocity}let B=this._platform?.linearVelocity??this._reusablePlatformVelocity;if(this._externalVelocity.y!==0)this._magnitudeYTracker+=this._externalVelocity.y;if(this._externalVelocity.x!==0||this._externalVelocity.y!==0||this._externalVelocity.z!==0){if(this.isGrounded){let M=Math.sqrt(this._externalVelocity.x*this._externalVelocity.x+this._magnitudeYTracker*this._magnitudeYTracker+this._externalVelocity.z*this._externalVelocity.z);if(M>0.01){let P=Math.max(0,M-b1.EXTERNAL_IMPULSE_DECAY_RATE)/M;this._externalVelocity.x*=P,this._magnitudeYTracker*=P,this._externalVelocity.z*=P}else this._externalVelocity.x=0,this._externalVelocity.y=0,this._magnitudeYTracker=0,this._externalVelocity.z=0}}let j=this._reusableTargetVelocities.x+this._externalVelocity.x-q.x+B.x,L=this._reusableTargetVelocities.y+this._externalVelocity.y+B.y,R=this._reusableTargetVelocities.z+this._externalVelocity.z-q.z+B.z;if(this._externalVelocity.y=0,j!==0||L!==0||R!==0){let M=Z.mass;this._reusableImpulse.x=j*M,this._reusableImpulse.y=L*M,this._reusableImpulse.z=R*M,this._internalApplyImpulse(this._reusableImpulse)}if(V!==void 0&&(this.faceForwardOnStop||this.isActivelyMoving)){let N=(c!==void 0?V+c:V)*0.5;Z.setRotation({x:0,y:Math.sin(N),z:0,w:Math.cos(N)})}}}var aP;((W)=>{W.LOAD="SCENE_UI.LOAD";W.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";W.SET_OFFSET="SCENE_UI.SET_OFFSET";W.SET_POSITION="SCENE_UI.SET_POSITION";W.SET_STATE="SCENE_UI.SET_STATE";W.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";W.UNLOAD="SCENE_UI.UNLOAD"})(aP||={});class mz extends B0{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)p.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=Z.attachedToEntity,this._offset=Z.offset,this._position=Z.position,this._state=Z.state??{},this._templateId=Z.templateId,this._viewDistance=Z.viewDistance}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get isLoaded(){return this._id!==void 0}get offset(){return this._offset}get position(){return this._position}get state(){return this._state}get templateId(){return this._templateId}get viewDistance(){return this._viewDistance}get world(){return this._world}load(Z){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return p.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=Z.sceneUIManager.registerSceneUI(this),this._world=Z,this.emitWithWorld(Z,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(Z){if(!Z.isSpawned)return p.error(`SceneUI.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:Z})}setOffset(Z){if(this._offset===Z)return;if(this._offset=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:Z})}setPosition(Z){if(this._position===Z)return;if(this._attachedToEntity=void 0,this._position=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:Z})}setState(Z){if(this._state={...this._state,...Z},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(Z){if(this._viewDistance=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:Z})}unload(){if(!this.isLoaded||!this._world)return;this._world.sceneUIManager.unregisterSceneUI(this),this.emitWithWorld(this._world,"SCENE_UI.UNLOAD",{sceneUI:this}),this._id=void 0,this._world=void 0}serialize(){return T0.serializeSceneUI(this)}}var C80=0.010000000000000002,f80=Math.cos(0.026);class F7 extends j8{player;nametagSceneUI;constructor(Z){super(Z);this._positionUpdateThresholdSq=C80,this._rotationUpdateThreshold=f80,this.player=Z.player,this.nametagSceneUI=new mz({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}})}spawn(Z,J,X){super.spawn(Z,J,X),this.nametagSceneUI.load(Z),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:$})=>{this.nametagSceneUI.setState({chat:$})})}tick(Z){if(!this.isSpawned||!this.world)return;if(!this.controller)return p.error(`PlayerEntity.tick(): PlayerEntity "${this.name}" must have a controller.`);let{input:J,camera:X}=this.player;this.controller.tickWithPlayerInput(this,J,X.orientation,Z),super.tick(Z)}}var k80="models/players/player.gltf",nI1={BACK:"back-anchor",HEAD:"head-anchor",LEFT_ARM:"arm-left-anchor",LEFT_FOOT:"foot-left-anchor",LEFT_HAND:"hand-left-anchor",LEFT_ITEM:"hand-left-anchor",LEFT_LEG:"leg-left-anchor",RIGHT_ARM:"arm-right-anchor",RIGHT_FOOT:"foot-right-anchor",RIGHT_HAND:"hand-right-anchor",RIGHT_ITEM:"hand-right-anchor",RIGHT_LEG:"leg-right-anchor",TORSO:"torso-anchor"};class nP extends F7{_cosmeticHiddenSlots;constructor(Z){super({modelUri:k80,modelLoopedAnimations:["idle_lower","idle_upper"],modelHiddenNodes:["hair-"],modelShownNodes:["hair-0003"],...Z});if(this._cosmeticHiddenSlots=Z.cosmeticHiddenSlots??[],!Z.controller)this.setController(new b1)}get cosmeticHiddenSlots(){return this._cosmeticHiddenSlots}spawn(Z,J,X){super.spawn(Z,J,X),this.player.cosmetics.then(($)=>{if(!$||!this.modelUri)return;let Y=this.modelShownNodes.values().toArray().filter((W)=>!W.includes("hair-"));if(!($.equippedItems.some((W)=>W.item.flags.includes("HIDES_HAIR"))&&!this._cosmeticHiddenSlots.includes("ALL")&&!this._cosmeticHiddenSlots.includes("HEAD")))Y.push(`hair-${String($.hairStyle).padStart(4,"0")}`);if(this.setModelShownNodes(Y),this.modelUri===k80)this.setModelTextureUri($.skinTextureUri);if(this._cosmeticHiddenSlots.includes("ALL"))return;let K=[];for(let W of $.equippedItems){let{item:G,slot:z}=W;if(this._cosmeticHiddenSlots.includes(z))continue;let v=nI1[z];if(!v||!j6.instance.modelHasNode(this.modelUri,v)){p.warning(`DefaultPlayerEntity.spawn(): Model ${this.modelUri} does not have node anchor "${v}" for slot "${z}". Skipping...`);continue}if(G.flags.includes("REPLACES_LIMB")){let V=v.split("-").slice(0,-1).join("-");K.push(`${V}-clothing`,`${V}-geometry`)}new j8({modelUri:G.modelUrl,modelPreferredShape:"none",parent:this,parentNodeName:v}).spawn(Z,{x:0,y:0,z:0})}if(K.length>0)this.setModelHiddenNodes([...this.modelHiddenNodes.values().toArray(),...K])}).catch(($)=>p.warning(`DefaultPlayerEntity.spawn(): Failed to get player cosmetics: ${$}`))}}class uz{_activeEntities=new Set;_entities=new Map;_nextEntityId=1;_world;constructor(Z){this._world=Z}get entityCount(){return this._entities.size}get world(){return this._world}registerEntity(Z){if(Z.id!==void 0)p.fatalError(`EntityManager.registerEntity(): Entity ${Z.name} is already assigned the id ${Z.id}!`);let J=this._nextEntityId;if(this._entities.set(J,Z),this._nextEntityId++,!Z.isEnvironmental)this._activeEntities.add(Z);return J}unregisterEntity(Z){if(Z.id===void 0)return p.error(`EntityManager.unregisterEntity(): Entity ${Z.name} is not assigned an id!`);if(this._entities.delete(Z.id),!Z.isEnvironmental)this._activeEntities.delete(Z)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let Z=[];return this._entities.forEach((J)=>{if(J instanceof F7)Z.push(J)}),Z}getPlayerEntitiesByPlayer(Z){let J=[];return this._entities.forEach((X)=>{if(X instanceof F7&&X.player===Z)J.push(X)}),J}getEntity(Z){return this._entities.get(Z)}getEntitiesByTag(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag===Z)J.push(X)}),J}getEntitiesByTagSubstring(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag?.includes(Z))J.push(X)}),J}getEntityChildren(Z){let J=[];return this._entities.forEach((X)=>{if(X.parent===Z)J.push(X)}),J}tickEntities(Z){for(let J of this._activeEntities)J.tick(Z)}checkAndEmitUpdates(){for(let Z of this._activeEntities)Z.checkAndEmitUpdates()}}import{gzipSync as dJ6}from"zlib";var n6=t(b60(),1),Cb6=n6.default.v1,fb6=n6.default.v1ToV6,kb6=n6.default.v3,h60=n6.default.v4,Eb6=n6.default.v5,Ib6=n6.default.v6,_b6=n6.default.v6ToV1,bb6=n6.default.v7,hb6=n6.default.NIL,Sb6=n6.default.MAX,Ab6=n6.default.version,mb6=n6.default.validate,ub6=n6.default.stringify,lb6=n6.default.parse;var XT;try{XT=new TextDecoder}catch(Z){}var X0,g5,m=0;var KT=[],XY=KT,pz=0,f1={},Y1,bZ,i5=0,P4=0,S8,hZ,L5=[],e0,S60={useRecords:!1,mapsAsObjects:!0};class Xc{}var WT=new Xc;WT.name="MessagePack 0xC1";var YX=!1,g60=2,$T,YT,QT;try{new Function("")}catch(Z){g60=1/0}class SZ{constructor(Z){if(Z){if(Z.useRecords===!1&&Z.mapsAsObjects===void 0)Z.mapsAsObjects=!0;if(Z.sequential&&Z.trusted!==!1){if(Z.trusted=!0,!Z.structures&&Z.useRecords!=!1){if(Z.structures=[],!Z.maxSharedStructures)Z.maxSharedStructures=0}}if(Z.structures)Z.structures.sharedLength=Z.structures.length;else if(Z.getStructures)(Z.structures=[]).uninitialized=!0,Z.structures.sharedLength=0;if(Z.int64AsNumber)Z.int64AsType="number"}Object.assign(this,Z)}unpack(Z,J){if(X0)return X50(()=>{return Jc(),this?this.unpack(Z,J):SZ.prototype.unpack.call(S60,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")g5=J.end||Z.length,m=J.start||0;else m=0,g5=J>-1?J:Z.length;pz=0,P4=0,bZ=null,XY=KT,S8=null,X0=Z;try{e0=Z.dataView||(Z.dataView=new DataView(Z.buffer,Z.byteOffset,Z.byteLength))}catch(X){if(X0=null,Z instanceof Uint8Array)throw X;throw new Error("Source must be a Uint8Array or Buffer but was a "+(Z&&typeof Z=="object"?Z.constructor.name:typeof Z))}if(this instanceof SZ){if(f1=this,this.structures)return Y1=this.structures,ew(J);else if(!Y1||Y1.length>0)Y1=[]}else if(f1=S60,!Y1||Y1.length>0)Y1=[];return ew(J)}unpackMultiple(Z,J){let X,$=0;try{YX=!0;let Y=Z.length,Q=this?this.unpack(Z,Y):$c.unpack(Z,Y);if(J){if(J(Q,$,m)===!1)return;while(m<Y)if($=m,J(ew(),$,m)===!1)return}else{X=[Q];while(m<Y)$=m,X.push(ew());return X}}catch(Y){throw Y.lastPosition=$,Y.values=X,Y}finally{YX=!1,Jc()}}_mergeStructures(Z,J){if(YT)Z=YT.call(this,Z);if(Z=Z||[],Object.isFrozen(Z))Z=Z.map((X)=>X.slice(0));for(let X=0,$=Z.length;X<$;X++){let Y=Z[X];if(Y){if(Y.isShared=!0,X>=32)Y.highByte=X-32>>5}}Z.sharedLength=Z.length;for(let X in J||[])if(X>=0){let $=Z[X],Y=J[X];if(Y){if($)(Z.restoreStructures||(Z.restoreStructures=[]))[X]=$;Z[X]=Y}}return this.structures=Z}decode(Z,J){return this.unpack(Z,J)}}function ew(Z){try{if(!f1.trusted&&!YX){let X=Y1.sharedLength||0;if(X<Y1.length)Y1.length=X}let J;if(f1.randomAccessStructure&&X0[m]<64&&X0[m]>=32&&$T){if(J=$T(X0,m,g5,f1),X0=null,!(Z&&Z.lazy)&&J)J=J.toJSON();m=g5}else J=L8();if(S8)m=S8.postBundlePosition,S8=null;if(YX)Y1.restoreStructures=null;if(m==g5){if(Y1&&Y1.restoreStructures)A60();if(Y1=null,X0=null,hZ)hZ=null}else if(m>g5)throw new Error("Unexpected end of MessagePack data");else if(!YX){let X;try{X=JSON.stringify(J,($,Y)=>typeof Y==="bigint"?`${Y}n`:Y).slice(0,100)}catch($){X="(JSON view not available "+$+")"}throw new Error("Data read, but end of buffer not reached "+X)}return J}catch(J){if(Y1&&Y1.restoreStructures)A60();if(Jc(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||m>g5)J.incomplete=!0;throw J}}function A60(){for(let Z in Y1.restoreStructures)Y1[Z]=Y1.restoreStructures[Z];Y1.restoreStructures=null}function L8(){let Z=X0[m++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=Y1[Z&63]||f1.getStructures&&d60()[Z&63];if(J){if(!J.read)J.read=GT(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,f1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let $=Z50();if($==="__proto__")$="__proto_";J[$]=L8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(L8(),L8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=L8();if(f1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(P4>=m)return bZ.slice(m-i5,(m+=J)-i5);if(P4==0&&g5<140){let X=J<16?zT(J):e60(J);if(X!=null)return X}return Zc(J)}else{let J;switch(Z){case 192:return null;case 193:if(S8)if(J=L8(),J>0)return S8[1].slice(S8.position1,S8.position1+=J);else return S8[0].slice(S8.position0,S8.position0-=J);return WT;case 194:return!1;case 195:return!0;case 196:if(J=X0[m++],J===void 0)throw new Error("Unexpected end of buffer");return JT(J);case 197:return J=e0.getUint16(m),m+=2,JT(J);case 198:return J=e0.getUint32(m),m+=4,JT(J);case 199:return JY(X0[m++]);case 200:return J=e0.getUint16(m),m+=2,JY(J);case 201:return J=e0.getUint32(m),m+=4,JY(J);case 202:if(J=e0.getFloat32(m),f1.useFloat32>2){let X=YY[(X0[m]&127)<<1|X0[m+1]>>7];return m+=4,(X*J+(J>0?0.5:-0.5)>>0)/X}return m+=4,J;case 203:return J=e0.getFloat64(m),m+=8,J;case 204:return X0[m++];case 205:return J=e0.getUint16(m),m+=2,J;case 206:return J=e0.getUint32(m),m+=4,J;case 207:if(f1.int64AsType==="number")J=e0.getUint32(m)*4294967296,J+=e0.getUint32(m+4);else if(f1.int64AsType==="string")J=e0.getBigUint64(m).toString();else if(f1.int64AsType==="auto"){if(J=e0.getBigUint64(m),J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=e0.getBigUint64(m);return m+=8,J;case 208:return e0.getInt8(m++);case 209:return J=e0.getInt16(m),m+=2,J;case 210:return J=e0.getInt32(m),m+=4,J;case 211:if(f1.int64AsType==="number")J=e0.getInt32(m)*4294967296,J+=e0.getUint32(m+4);else if(f1.int64AsType==="string")J=e0.getBigInt64(m).toString();else if(f1.int64AsType==="auto"){if(J=e0.getBigInt64(m),J>=BigInt(-2)<<BigInt(52)&&J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=e0.getBigInt64(m);return m+=8,J;case 212:if(J=X0[m++],J==114)return i60(X0[m++]&63);else{let X=L5[J];if(X)if(X.read)return m++,X.read(L8());else if(X.noBuffer)return m++,X();else return X(X0.subarray(m,++m));else throw new Error("Unknown extension "+J)}case 213:if(J=X0[m],J==114)return m++,i60(X0[m++]&63,X0[m++]);else return JY(2);case 214:return JY(4);case 215:return JY(8);case 216:return JY(16);case 217:if(J=X0[m++],P4>=m)return bZ.slice(m-i5,(m+=J)-i5);return a60(J);case 218:if(J=e0.getUint16(m),m+=2,P4>=m)return bZ.slice(m-i5,(m+=J)-i5);return n60(J);case 219:if(J=e0.getUint32(m),m+=4,P4>=m)return bZ.slice(m-i5,(m+=J)-i5);return s60(J);case 220:return J=e0.getUint16(m),m+=2,u60(J);case 221:return J=e0.getUint32(m),m+=4,u60(J);case 222:return J=e0.getUint16(m),m+=2,l60(J);case 223:return J=e0.getUint32(m),m+=4,l60(J);default:if(Z>=224)return Z-256;if(Z===void 0){let X=new Error("Unexpected end of MessagePack data");throw X.incomplete=!0,X}throw new Error("Unknown MessagePack token "+Z)}}}var Mb1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function GT(Z,J){function X(){if(X.count++>g60){let Y=Z.read=new Function("r","return function(){return "+(f1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":Mb1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(L8);if(Z.highByte===0)Z.read=m60(J,Z.read);return Y()}let $={};for(let Y=0,Q=Z.length;Y<Q;Y++){let K=Z[Y];if(K==="__proto__")K="__proto_";$[K]=L8()}if(f1.freezeData)return Object.freeze($);return $}if(X.count=0,Z.highByte===0)return m60(J,X);return X}var m60=(Z,J)=>{return function(){let X=X0[m++];if(X===0)return J();let $=Z<32?-(Z+(X<<5)):Z+(X<<5),Y=Y1[$]||d60()[$];if(!Y)throw new Error("Record id is not defined for "+$);if(!Y.read)Y.read=GT(Y,Z);return Y.read()}};function d60(){let Z=X50(()=>{return X0=null,f1.getStructures()});return Y1=f1._mergeStructures(Z,Y1)}var Zc=$Y,a60=$Y,n60=$Y,s60=$Y,o60=!1;function r60(Z){o60=!0,Zc=J(1),a60=J(2),n60=J(3),s60=J(5);function J(X){return function $(Y){let Q=XY[pz++];if(Q==null){if(S8)return $Y(Y);let W=X0.byteOffset,G=Z(m-X+W,g5+W,X0.buffer);if(typeof G=="string")Q=G,XY=KT;else if(XY=G,pz=1,P4=1,Q=XY[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=Y)return m+=Y,Q;return bZ=Q,i5=m,P4=m+K,m+=Y,Q.slice(0,Y)}}}function $Y(Z){let J;if(Z<16){if(J=zT(Z))return J}if(Z>64&&XT)return XT.decode(X0.subarray(m,m+=Z));let X=m+Z,$=[];J="";while(m<X){let Y=X0[m++];if((Y&128)===0)$.push(Y);else if((Y&224)===192){let Q=X0[m++]&63;$.push((Y&31)<<6|Q)}else if((Y&240)===224){let Q=X0[m++]&63,K=X0[m++]&63;$.push((Y&31)<<12|Q<<6|K)}else if((Y&248)===240){let Q=X0[m++]&63,K=X0[m++]&63,W=X0[m++]&63,G=(Y&7)<<18|Q<<12|K<<6|W;if(G>65535)G-=65536,$.push(G>>>10&1023|55296),G=56320|G&1023;$.push(G)}else $.push(Y);if($.length>=4096)J+=a8.apply(String,$),$.length=0}if($.length>0)J+=a8.apply(String,$);return J}function t60(Z,J,X){let $=X0;X0=Z,m=J;try{return $Y(X)}finally{X0=$}}function u60(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=L8();if(f1.freezeData)return Object.freeze(J);return J}function l60(Z){if(f1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let $=Z50();if($==="__proto__")$="__proto_";J[$]=L8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(L8(),L8());return J}}var a8=String.fromCharCode;function e60(Z){let J=m,X=new Array(Z);for(let $=0;$<Z;$++){let Y=X0[m++];if((Y&128)>0){m=J;return}X[$]=Y}return a8.apply(String,X)}function zT(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=X0[m++];if((J&128)>1){m-=1;return}return a8(J)}else{let J=X0[m++],X=X0[m++];if((J&128)>0||(X&128)>0){m-=2;return}if(Z<3)return a8(J,X);let $=X0[m++];if(($&128)>0){m-=3;return}return a8(J,X,$)}else{let J=X0[m++],X=X0[m++],$=X0[m++],Y=X0[m++];if((J&128)>0||(X&128)>0||($&128)>0||(Y&128)>0){m-=4;return}if(Z<6)if(Z===4)return a8(J,X,$,Y);else{let Q=X0[m++];if((Q&128)>0){m-=5;return}return a8(J,X,$,Y,Q)}else if(Z<8){let Q=X0[m++],K=X0[m++];if((Q&128)>0||(K&128)>0){m-=6;return}if(Z<7)return a8(J,X,$,Y,Q,K);let W=X0[m++];if((W&128)>0){m-=7;return}return a8(J,X,$,Y,Q,K,W)}else{let Q=X0[m++],K=X0[m++],W=X0[m++],G=X0[m++];if((Q&128)>0||(K&128)>0||(W&128)>0||(G&128)>0){m-=8;return}if(Z<10)if(Z===8)return a8(J,X,$,Y,Q,K,W,G);else{let z=X0[m++];if((z&128)>0){m-=9;return}return a8(J,X,$,Y,Q,K,W,G,z)}else if(Z<12){let z=X0[m++],v=X0[m++];if((z&128)>0||(v&128)>0){m-=10;return}if(Z<11)return a8(J,X,$,Y,Q,K,W,G,z,v);let H=X0[m++];if((H&128)>0){m-=11;return}return a8(J,X,$,Y,Q,K,W,G,z,v,H)}else{let z=X0[m++],v=X0[m++],H=X0[m++],V=X0[m++];if((z&128)>0||(v&128)>0||(H&128)>0||(V&128)>0){m-=12;return}if(Z<14)if(Z===12)return a8(J,X,$,Y,Q,K,W,G,z,v,H,V);else{let q=X0[m++];if((q&128)>0){m-=13;return}return a8(J,X,$,Y,Q,K,W,G,z,v,H,V,q)}else{let q=X0[m++],F=X0[m++];if((q&128)>0||(F&128)>0){m-=14;return}if(Z<15)return a8(J,X,$,Y,Q,K,W,G,z,v,H,V,q,F);let x=X0[m++];if((x&128)>0){m-=15;return}return a8(J,X,$,Y,Q,K,W,G,z,v,H,V,q,F,x)}}}}}function y60(){let Z=X0[m++],J;if(Z<192)J=Z-160;else switch(Z){case 217:J=X0[m++];break;case 218:J=e0.getUint16(m),m+=2;break;case 219:J=e0.getUint32(m),m+=4;break;default:throw new Error("Expected string")}return $Y(J)}function JT(Z){return f1.copyBuffers?Uint8Array.prototype.slice.call(X0,m,m+=Z):X0.subarray(m,m+=Z)}function JY(Z){let J=X0[m++];if(L5[J]){let X;return L5[J](X0.subarray(m,X=m+=Z),($)=>{m=$;try{return L8()}finally{m=X}})}else throw new Error("Unknown extension type "+J)}var p60=new Array(4096);function Z50(){let Z=X0[m++];if(Z>=160&&Z<192){if(Z=Z-160,P4>=m)return bZ.slice(m-i5,(m+=Z)-i5);else if(!(P4==0&&g5<180))return Zc(Z)}else return m--,J50(L8());let J=(Z<<5^(Z>1?e0.getUint16(m):Z>0?X0[m]:0))&4095,X=p60[J],$=m,Y=m+Z-3,Q,K=0;if(X&&X.bytes==Z){while($<Y){if(Q=e0.getUint32($),Q!=X[K++]){$=1879048192;break}$+=4}Y+=3;while($<Y)if(Q=X0[$++],Q!=X[K++]){$=1879048192;break}if($===Y)return m=$,X.string;Y-=3,$=m}X=[],p60[J]=X,X.bytes=Z;while($<Y)Q=e0.getUint32($),X.push(Q),$+=4;Y+=3;while($<Y)Q=X0[$++],X.push(Q);let W=Z<16?zT(Z):e60(Z);if(W!=null)return X.string=W;return X.string=Zc(Z)}function J50(Z){if(typeof Z==="string")return Z;if(typeof Z==="number"||typeof Z==="boolean"||typeof Z==="bigint")return Z.toString();if(Z==null)return Z+"";if(f1.allowArraysInMapKeys&&Array.isArray(Z)&&Z.flat().every((J)=>["string","number","boolean","bigint"].includes(typeof J)))return Z.flat().toString();throw new Error(`Invalid property type for record: ${typeof Z}`)}var i60=(Z,J)=>{let X=L8().map(J50),$=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let Y=Y1[Z];if(Y&&(Y.isShared||YX))(Y1.restoreStructures||(Y1.restoreStructures=[]))[Z]=Y;return Y1[Z]=X,X.read=GT(X,$),X.read()};L5[0]=()=>{};L5[0].noBuffer=!0;L5[66]=(Z)=>{let J=Z.length,X=BigInt(Z[0]&128?Z[0]-256:Z[0]);for(let $=1;$<J;$++)X<<=BigInt(8),X+=BigInt(Z[$]);return X};var Rb1={Error,TypeError,ReferenceError};L5[101]=()=>{let Z=L8();return(Rb1[Z[0]]||Error)(Z[1],{cause:Z[2]})};L5[105]=(Z)=>{if(f1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=e0.getUint32(m-4);if(!hZ)hZ=new Map;let X=X0[m],$;if(X>=144&&X<160||X==220||X==221)$=[];else if(X>=128&&X<144||X==222||X==223)$=new Map;else if((X>=199&&X<=201||X>=212&&X<=216)&&X0[m+1]===115)$=new Set;else $={};let Y={target:$};hZ.set(J,Y);let Q=L8();if(!Y.used)return Y.target=Q;else Object.assign($,Q);if($ instanceof Map)for(let[K,W]of Q.entries())$.set(K,W);if($ instanceof Set)for(let K of Array.from(Q))$.add(K);return $};L5[112]=(Z)=>{if(f1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=e0.getUint32(m-4),X=hZ.get(J);return X.used=!0,X.target};L5[115]=()=>new Set(L8());var vT=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),Nb1=typeof globalThis==="object"?globalThis:window;L5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,$=vT[J];if(!$){if(J===16)return X;if(J===17)return new DataView(X);throw new Error("Could not find typed array for code "+J)}return new Nb1[$](X)};L5[120]=()=>{let Z=L8();return new RegExp(Z[0],Z[1])};var Ob1=[];L5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=m;return m+=J-Z.length,S8=Ob1,S8=[y60(),y60()],S8.position0=0,S8.position1=0,S8.postBundlePosition=m,m=X,L8()};L5[255]=(Z)=>{if(Z.length==4)return new Date((Z[0]*16777216+(Z[1]<<16)+(Z[2]<<8)+Z[3])*1000);else if(Z.length==8)return new Date(((Z[0]<<22)+(Z[1]<<14)+(Z[2]<<6)+(Z[3]>>2))/1e6+((Z[3]&3)*4294967296+Z[4]*16777216+(Z[5]<<16)+(Z[6]<<8)+Z[7])*1000);else if(Z.length==12)return new Date(((Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3])/1e6+((Z[4]&128?-281474976710656:0)+Z[6]*1099511627776+Z[7]*4294967296+Z[8]*16777216+(Z[9]<<16)+(Z[10]<<8)+Z[11])*1000);else return new Date("invalid")};function X50(Z){if(QT)QT();let J=g5,X=m,$=pz,Y=i5,Q=P4,K=bZ,W=XY,G=hZ,z=S8,v=new Uint8Array(X0.slice(0,g5)),H=Y1,V=Y1.slice(0,Y1.length),q=f1,F=YX,x=Z();return g5=J,m=X,pz=$,i5=Y,P4=Q,bZ=K,XY=W,hZ=G,S8=z,X0=v,YX=F,Y1=H,Y1.splice(0,Y1.length,...V),f1=q,e0=new DataView(X0.buffer,X0.byteOffset,X0.byteLength),x}function Jc(){X0=null,hZ=null,Y1=null}var YY=new Array(147);for(let Z=0;Z<256;Z++)YY[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var $c=new SZ({useRecords:!1}),Pb1=$c.unpack,Tb1=$c.unpackMultiple,Cb1=$c.unpack,iz={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fb1=new Float32Array(1),pb6=new Uint8Array(fb1.buffer,0,4);function $50(Z,J,X){$T=Z,YT=J,QT=X}var Qc;try{Qc=new TextEncoder}catch(Z){}var qT,K50,dz=typeof Buffer!=="undefined",Yc=dz?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,W50=dz?Buffer:Uint8Array,Y50=dz?4294967296:2144337920,n,gz,h1,y=0,s6,o1=null,G50,kb1=21760,Eb1=/[\u0080-\uFFFF]/,x7=Symbol("record-id");class QY extends SZ{constructor(Z){super(Z);this.offset=0;let J,X,$,Y,Q,K=W50.prototype.utf8Write?function(f,C){return n.utf8Write(f,C,n.byteLength-C)}:Qc&&Qc.encodeInto?function(f,C){return Qc.encodeInto(f,n.subarray(C)).written}:!1,W=this;if(!Z)Z={};let G=Z&&Z.sequential,z=Z.structures||Z.saveStructures,v=Z.maxSharedStructures;if(v==null)v=z?32:0;if(v>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let H=Z.maxOwnStructures;if(H==null)H=z?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let V=v>32||H+v>64,q=v+64,F=v+H+64;if(F>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],w=0,c=0;this.pack=this.encode=function(f,C){if(!n)n=new Yc(8192),h1=n.dataView||(n.dataView=new DataView(n.buffer,0,8192)),y=0;if(s6=n.length-10,s6-y<2048)n=new Yc(n.length),h1=n.dataView||(n.dataView=new DataView(n.buffer,0,n.length)),s6=n.length-10,y=0;else y=y+7&2147483640;if(X=y,C&mb1)y+=C&255;if(Q=W.structuredClone?new Map:null,W.bundleStrings&&typeof f!=="string")o1=[],o1.size=1/0;else o1=null;if(Y=W.structures,Y){if(Y.uninitialized)Y=W._mergeStructures(W.getStructures());let I=Y.sharedLength||0;if(I>v)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+Y.sharedLength);if(!Y.transitions){Y.transitions=Object.create(null);for(let a=0;a<I;a++){let s=Y[a];if(!s)continue;let Z0,o=Y.transitions;for(let M0=0,R0=s.length;M0<R0;M0++){let m0=s[M0];if(Z0=o[m0],!Z0)Z0=o[m0]=Object.create(null);o=Z0}o[x7]=a+64}this.lastNamedStructuresLength=I}if(!G)Y.nextId=I+64}if($)$=!1;let b;try{if(W.randomAccessStructure&&f&&f.constructor&&f.constructor===Object)h(f);else L(f);let I=o1;if(o1)Q50(X,L,0);if(Q&&Q.idsToInsert){let a=Q.idsToInsert.sort((M0,R0)=>M0.offset>R0.offset?1:-1),s=a.length,Z0=-1;while(I&&s>0){let M0=a[--s].offset+X;if(M0<I.stringsPosition+X&&Z0===-1)Z0=0;if(M0>I.position+X){if(Z0>=0)Z0+=6}else{if(Z0>=0)h1.setUint32(I.position+X,h1.getUint32(I.position+X)+Z0),Z0=-1;I=I.previous,s++}}if(Z0>=0&&I)h1.setUint32(I.position+X,h1.getUint32(I.position+X)+Z0);if(y+=a.length*6,y>s6)O(y);W.offset=y;let o=_b1(n.subarray(X,y),a);return Q=null,o}if(W.offset=y,C&Sb1)return n.start=X,n.end=y,n;return n.subarray(X,y)}catch(I){throw b=I,I}finally{if(Y){if(B(),$&&W.saveStructures){let I=Y.sharedLength||0,a=n.subarray(X,y),s=z50(Y,W);if(!b){if(W.saveStructures(s,s.isCompatible)===!1)return W.pack(f,C);if(W.lastNamedStructuresLength=I,n.length>1073741824)n=null;return a}}}if(n.length>1073741824)n=null;if(C&Ab1)y=X}};let B=()=>{if(c<10)c++;let f=Y.sharedLength||0;if(Y.length>f&&!G)Y.length=f;if(w>1e4){if(Y.transitions=null,c=0,w=0,x.length>0)x=[]}else if(x.length>0&&!G){for(let C=0,b=x.length;C<b;C++)x[C][x7]=0;x=[]}},j=(f)=>{var C=f.length;if(C<16)n[y++]=144|C;else if(C<65536)n[y++]=220,n[y++]=C>>8,n[y++]=C&255;else n[y++]=221,h1.setUint32(y,C),y+=4;for(let b=0;b<C;b++)L(f[b])},L=(f)=>{if(y>s6)n=O(y);var C=typeof f,b;if(C==="string"){let I=f.length;if(o1&&I>=4&&I<4096){if((o1.size+=I)>kb1){let o,M0=(o1[0]?o1[0].length*3+o1[1].length:0)+10;if(y+M0>s6)n=O(y+M0);let R0;if(o1.position)R0=o1,n[y]=200,y+=3,n[y++]=98,o=y-X,y+=4,Q50(X,L,0),h1.setUint16(o+X-3,y-X-o);else n[y++]=214,n[y++]=98,o=y-X,y+=4;o1=["",""],o1.previous=R0,o1.size=0,o1.position=o}let Z0=Eb1.test(f);o1[Z0?0:1]+=f,n[y++]=193,L(Z0?-I:I);return}let a;if(I<32)a=1;else if(I<256)a=2;else if(I<65536)a=3;else a=5;let s=I*3;if(y+s>s6)n=O(y+s);if(I<64||!K){let Z0,o,M0,R0=y+a;for(Z0=0;Z0<I;Z0++)if(o=f.charCodeAt(Z0),o<128)n[R0++]=o;else if(o<2048)n[R0++]=o>>6|192,n[R0++]=o&63|128;else if((o&64512)===55296&&((M0=f.charCodeAt(Z0+1))&64512)===56320)o=65536+((o&1023)<<10)+(M0&1023),Z0++,n[R0++]=o>>18|240,n[R0++]=o>>12&63|128,n[R0++]=o>>6&63|128,n[R0++]=o&63|128;else n[R0++]=o>>12|224,n[R0++]=o>>6&63|128,n[R0++]=o&63|128;b=R0-y-a}else b=K(f,y+a);if(b<32)n[y++]=160|b;else if(b<256){if(a<2)n.copyWithin(y+2,y+1,y+1+b);n[y++]=217,n[y++]=b}else if(b<65536){if(a<3)n.copyWithin(y+3,y+2,y+2+b);n[y++]=218,n[y++]=b>>8,n[y++]=b&255}else{if(a<5)n.copyWithin(y+5,y+3,y+3+b);n[y++]=219,h1.setUint32(y,b),y+=4}y+=b}else if(C==="number")if(f>>>0===f)if(f<32||f<128&&this.useRecords===!1||f<64&&!this.randomAccessStructure)n[y++]=f;else if(f<256)n[y++]=204,n[y++]=f;else if(f<65536)n[y++]=205,n[y++]=f>>8,n[y++]=f&255;else n[y++]=206,h1.setUint32(y,f),y+=4;else if(f>>0===f)if(f>=-32)n[y++]=256+f;else if(f>=-128)n[y++]=208,n[y++]=f+256;else if(f>=-32768)n[y++]=209,h1.setInt16(y,f),y+=2;else n[y++]=210,h1.setInt32(y,f),y+=4;else{let I;if((I=this.useFloat32)>0&&f<4294967296&&f>=-2147483648){n[y++]=202,h1.setFloat32(y,f);let a;if(I<4||(a=f*YY[(n[y]&127)<<1|n[y+1]>>7])>>0===a){y+=4;return}else y--}n[y++]=203,h1.setFloat64(y,f),y+=8}else if(C==="object"||C==="function")if(!f)n[y++]=192;else{if(Q){let a=Q.get(f);if(a){if(!a.id){let s=Q.idsToInsert||(Q.idsToInsert=[]);a.id=s.push(a)}n[y++]=214,n[y++]=112,h1.setUint32(y,a.id),y+=4;return}else Q.set(f,{offset:y-X})}let I=f.constructor;if(I===Object)P(f);else if(I===Array)j(f);else if(I===Map)if(this.mapAsEmptyObject)n[y++]=128;else{if(b=f.size,b<16)n[y++]=128|b;else if(b<65536)n[y++]=222,n[y++]=b>>8,n[y++]=b&255;else n[y++]=223,h1.setUint32(y,b),y+=4;for(let[a,s]of f)L(a),L(s)}else{for(let a=0,s=qT.length;a<s;a++){let Z0=K50[a];if(f instanceof Z0){let o=qT[a];if(o.write){if(o.type)n[y++]=212,n[y++]=o.type,n[y++]=0;let s0=o.write.call(this,f);if(s0===f)if(Array.isArray(f))j(f);else P(f);else L(s0);return}let M0=n,R0=h1,m0=y;n=null;let N1;try{N1=o.pack.call(this,f,(s0)=>{if(n=M0,M0=null,y+=s0,y>s6)O(y);return{target:n,targetView:h1,position:y-s0}},L)}finally{if(M0)n=M0,h1=R0,y=m0,s6=n.length-10}if(N1){if(N1.length+y>s6)O(N1.length+y);y=Ib1(N1,n,y,o.type)}return}}if(Array.isArray(f))j(f);else{if(f.toJSON){let a=f.toJSON();if(a!==f)return L(a)}if(C==="function")return L(this.writeFunction&&this.writeFunction(f));P(f)}}}else if(C==="boolean")n[y++]=f?195:194;else if(C==="bigint"){if(f<9223372036854776000&&f>=-9223372036854776000)n[y++]=211,h1.setBigInt64(y,f);else if(f<18446744073709552000&&f>0)n[y++]=207,h1.setBigUint64(y,f);else if(this.largeBigIntToFloat)n[y++]=203,h1.setFloat64(y,Number(f));else if(this.largeBigIntToString)return L(f.toString());else if((this.useBigIntExtension||this.moreTypes)&&f<BigInt(2)**BigInt(1023)&&f>-(BigInt(2)**BigInt(1023))){n[y++]=199,y++,n[y++]=66;let I=[],a;do{let s=f&BigInt(255);a=(s&BigInt(128))===(f<BigInt(0)?BigInt(128):BigInt(0)),I.push(s),f>>=BigInt(8)}while(!((f===BigInt(0)||f===BigInt(-1))&&a));n[y-2]=I.length;for(let s=I.length;s>0;)n[y++]=Number(I[--s]);return}else throw new RangeError(f+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string");y+=8}else if(C==="undefined")if(this.encodeUndefinedAsNil)n[y++]=192;else n[y++]=212,n[y++]=0,n[y++]=0;else throw new Error("Unknown type: "+C)},R=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(f)=>{let C;if(this.skipValues){C=[];for(let a in f)if((typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(a))&&!this.skipValues.includes(f[a]))C.push(a)}else C=Object.keys(f);let b=C.length;if(b<16)n[y++]=128|b;else if(b<65536)n[y++]=222,n[y++]=b>>8,n[y++]=b&255;else n[y++]=223,h1.setUint32(y,b),y+=4;let I;if(this.coercibleKeyAsNumber)for(let a=0;a<b;a++){I=C[a];let s=Number(I);L(isNaN(s)?I:s),L(f[I])}else for(let a=0;a<b;a++)L(I=C[a]),L(f[I])}:(f)=>{n[y++]=222;let C=y-X;y+=2;let b=0;for(let I in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(I))L(I),L(f[I]),b++;if(b>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');n[C+++X]=b>>8,n[C+X]=b&255},M=this.useRecords===!1?R:Z.progressiveRecords&&!V?(f)=>{let C,b=Y.transitions||(Y.transitions=Object.create(null)),I=y++-X,a;for(let s in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(s)){if(C=b[s],C)b=C;else{let Z0=Object.keys(f),o=b;b=Y.transitions;let M0=0;for(let R0=0,m0=Z0.length;R0<m0;R0++){let N1=Z0[R0];if(C=b[N1],!C)C=b[N1]=Object.create(null),M0++;b=C}if(I+X+1==y)y--,_(b,Z0,M0);else k(b,Z0,I,M0);a=!0,b=o[s]}L(f[s])}if(!a){let s=b[x7];if(s)n[I+X]=s;else k(b,Object.keys(f),I,0)}}:(f)=>{let C,b=Y.transitions||(Y.transitions=Object.create(null)),I=0;for(let s in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(s)){if(C=b[s],!C)C=b[s]=Object.create(null),I++;b=C}let a=b[x7];if(a)if(a>=96&&V)n[y++]=((a-=96)&31)+96,n[y++]=a>>5;else n[y++]=a;else _(b,b.__keys__||Object.keys(f),I);for(let s in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(s))L(f[s])},N=typeof this.useRecords=="function"&&this.useRecords,P=N?(f)=>{N(f)?M(f):R(f)}:M,O=(f)=>{let C;if(f>16777216){if(f-X>Y50)throw new Error("Packed buffer would be larger than maximum buffer size");C=Math.min(Y50,Math.round(Math.max((f-X)*(f>67108864?1.25:2),4194304)/4096)*4096)}else C=(Math.max(f-X<<2,n.length-1)>>12)+1<<12;let b=new Yc(C);if(h1=b.dataView||(b.dataView=new DataView(b.buffer,0,C)),f=Math.min(f,n.length),n.copy)n.copy(b,0,X,f);else b.set(n.slice(X,f));return y-=X,X=0,s6=b.length-10,n=b},_=(f,C,b)=>{let I=Y.nextId;if(!I)I=64;if(I<q&&this.shouldShareStructure&&!this.shouldShareStructure(C)){if(I=Y.nextOwnId,!(I<F))I=q;Y.nextOwnId=I+1}else{if(I>=F)I=q;Y.nextId=I+1}let a=C.highByte=I>=96&&V?I-96>>5:-1;if(f[x7]=I,f.__keys__=C,Y[I-64]=C,I<q)if(C.isShared=!0,Y.sharedLength=I-63,$=!0,a>=0)n[y++]=(I&31)+96,n[y++]=a;else n[y++]=I;else{if(a>=0)n[y++]=213,n[y++]=114,n[y++]=(I&31)+96,n[y++]=a;else n[y++]=212,n[y++]=114,n[y++]=I;if(b)w+=c*b;if(x.length>=H)x.shift()[x7]=0;x.push(f),L(C)}},k=(f,C,b,I)=>{let a=n,s=y,Z0=s6,o=X;if(n=gz,y=0,X=0,!n)gz=n=new Yc(8192);s6=n.length-10,_(f,C,I),gz=n;let M0=y;if(n=a,y=s,s6=Z0,X=o,M0>1){let R0=y+M0-1;if(R0>s6)O(R0);let m0=b+X;n.copyWithin(m0+M0,m0+1,y),n.set(gz.slice(0,M0),m0),y=R0}else n[b+X]=gz[0]},h=(f)=>{let C=G50(f,n,X,y,Y,O,(b,I,a)=>{if(a)return $=!0;y=I;let s=n;if(L(b),B(),s!==n)return{position:y,targetView:h1,target:n};return y},this);if(C===0)return P(f);y=C}}useBuffer(Z){n=Z,n.dataView||(n.dataView=new DataView(n.buffer,n.byteOffset,n.byteLength)),y=0}set position(Z){y=Z}get position(){return y}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}K50=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Xc];qT=[{pack(Z,J,X){let $=Z.getTime()/1000;if((this.useTimestamp32||Z.getMilliseconds()===0)&&$>=0&&$<4294967296){let{target:Y,targetView:Q,position:K}=J(6);Y[K++]=214,Y[K++]=255,Q.setUint32(K,$)}else if($>0&&$<4294967296){let{target:Y,targetView:Q,position:K}=J(10);Y[K++]=215,Y[K++]=255,Q.setUint32(K,Z.getMilliseconds()*4000000+($/1000/4294967296>>0)),Q.setUint32(K+4,$)}else if(isNaN($)){if(this.onInvalidDate)return J(0),X(this.onInvalidDate());let{target:Y,targetView:Q,position:K}=J(3);Y[K++]=212,Y[K++]=255,Y[K++]=255}else{let{target:Y,targetView:Q,position:K}=J(15);Y[K++]=199,Y[K++]=12,Y[K++]=255,Q.setUint32(K,Z.getMilliseconds()*1e6),Q.setBigInt64(K+4,BigInt(Math.floor($)))}}},{pack(Z,J,X){if(this.setAsEmptyObject)return J(0),X({});let $=Array.from(Z),{target:Y,position:Q}=J(this.moreTypes?3:0);if(this.moreTypes)Y[Q++]=212,Y[Q++]=115,Y[Q++]=0;X($)}},{pack(Z,J,X){let{target:$,position:Y}=J(this.moreTypes?3:0);if(this.moreTypes)$[Y++]=212,$[Y++]=101,$[Y++]=0;X([Z.name,Z.message,Z.cause])}},{pack(Z,J,X){let{target:$,position:Y}=J(this.moreTypes?3:0);if(this.moreTypes)$[Y++]=212,$[Y++]=120,$[Y++]=0;X([Z.source,Z.flags])}},{pack(Z,J){if(this.moreTypes)VT(Z,16,J);else HT(dz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==W50&&this.moreTypes)VT(Z,vT.indexOf(X.name),J);else HT(Z,J)}},{pack(Z,J){if(this.moreTypes)VT(Z,17,J);else HT(dz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:$}=J(1);X[$]=193}}];function VT(Z,J,X,$){let Y=Z.byteLength;if(Y+1<256){var{target:Q,position:K}=X(4+Y);Q[K++]=199,Q[K++]=Y+1}else if(Y+1<65536){var{target:Q,position:K}=X(5+Y);Q[K++]=200,Q[K++]=Y+1>>8,Q[K++]=Y+1&255}else{var{target:Q,position:K,targetView:W}=X(7+Y);Q[K++]=201,W.setUint32(K,Y+1),K+=4}if(Q[K++]=116,Q[K++]=J,!Z.buffer)Z=new Uint8Array(Z);Q.set(new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),K)}function HT(Z,J){let X=Z.byteLength;var $,Y;if(X<256){var{target:$,position:Y}=J(X+2);$[Y++]=196,$[Y++]=X}else if(X<65536){var{target:$,position:Y}=J(X+3);$[Y++]=197,$[Y++]=X>>8,$[Y++]=X&255}else{var{target:$,position:Y,targetView:Q}=J(X+5);$[Y++]=198,Q.setUint32(Y,X),Y+=4}$.set(Z,Y)}function Ib1(Z,J,X,$){let Y=Z.length;switch(Y){case 1:J[X++]=212;break;case 2:J[X++]=213;break;case 4:J[X++]=214;break;case 8:J[X++]=215;break;case 16:J[X++]=216;break;default:if(Y<256)J[X++]=199,J[X++]=Y;else if(Y<65536)J[X++]=200,J[X++]=Y>>8,J[X++]=Y&255;else J[X++]=201,J[X++]=Y>>24,J[X++]=Y>>16&255,J[X++]=Y>>8&255,J[X++]=Y&255}return J[X++]=$,J.set(Z,X),X+=Y,X}function _b1(Z,J){let X,$=J.length*6,Y=Z.length-$;while(X=J.pop()){let{offset:Q,id:K}=X;Z.copyWithin(Q+$,Q,Y),$-=6;let W=Q+$;Z[W++]=214,Z[W++]=105,Z[W++]=K>>24,Z[W++]=K>>16&255,Z[W++]=K>>8&255,Z[W++]=K&255,Y=Q}return Z}function Q50(Z,J,X){if(o1.length>0){h1.setUint32(o1.position+Z,y+X-o1.position-Z),o1.stringsPosition=y-Z;let $=o1;o1=null,J($[0]),J($[1])}}function z50(Z,J){return Z.isCompatible=(X)=>{let $=!X||(J.lastNamedStructuresLength||0)===X.length;if(!$)J._mergeStructures(X);return $},Z}function v50(Z,J){G50=Z,z50=J}var V50=new QY({useRecords:!1}),bb1=V50.pack,hb1=V50.pack;var Sb1=512,Ab1=1024,mb1=2048;var FT=3,aK=0,az=2,Kc=1,wT=16,q50=["num","object","string","ascii"];q50[wT]="date";var lb1=[!1,!0,!0,!1,!1,!0,!0,!1],F50;try{new Function(""),F50=!0}catch(Z){}var KY,yb1=typeof Buffer!=="undefined",Wc,w7;try{Wc=new TextEncoder}catch(Z){}var pb1=yb1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:Wc&&Wc.encodeInto?function(Z,J,X){return Wc.encodeInto(J,Z.subarray(X)).written}:!1,tb6=Symbol("type"),eb6=Symbol("parent");v50(x50,nb1);function x50(Z,J,X,$,Y,Q,K,W){let G=W.typedStructs||(W.typedStructs=[]),z=J.dataView,v=(G.lastStringStart||100)+$,H=J.length-10,V=$;if($>H)J=Q($),z=J.dataView,$-=X,V-=X,v-=X,X=0,H=J.length-10;let q,F=v,x=G.transitions||(G.transitions=Object.create(null)),w=G.nextId||G.length,c=w<15?1:w<240?2:w<61440?3:w<15728640?4:0;if(c===0)return 0;$+=c;let B=[],j,L=0;for(let M in Z){let N=Z[M],P=x[M];if(!P)x[M]=P={key:M,parent:x,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if($>H)J=Q($),z=J.dataView,$-=X,V-=X,v-=X,F-=X,X=0,H=J.length-10;switch(typeof N){case"number":let O=N;if(w<200||!P.num64){if(O>>0===O&&O<536870912&&O>-520093696){if(O<246&&O>=0&&(P.num8&&!(w>200&&P.num32)||O<32&&!P.num32))x=P.num8||D5(P,aK,1),J[$++]=O;else x=P.num32||D5(P,aK,4),z.setUint32($,O,!0),$+=4;break}else if(O<4294967296&&O>=-2147483648){if(z.setFloat32($,O,!0),lb1[J[$+3]>>>5]){let f;if((f=O*YY[(J[$+3]&127)<<1|J[$+2]>>7])>>0===f){x=P.num32||D5(P,aK,4),$+=4;break}}}}x=P.num64||D5(P,aK,8),z.setFloat64($,O,!0),$+=8;break;case"string":let _=N.length;if(q=F-v,(_<<2)+F>H)J=Q((_<<2)+F),z=J.dataView,$-=X,V-=X,v-=X,F-=X,X=0,H=J.length-10;if(_>65280+q>>2){B.push(M,N,$-V);break}let k,h=F;if(_<64){let f,C,b;for(f=0;f<_;f++)if(C=N.charCodeAt(f),C<128)J[F++]=C;else if(C<2048)k=!0,J[F++]=C>>6|192,J[F++]=C&63|128;else if((C&64512)===55296&&((b=N.charCodeAt(f+1))&64512)===56320)k=!0,C=65536+((C&1023)<<10)+(b&1023),f++,J[F++]=C>>18|240,J[F++]=C>>12&63|128,J[F++]=C>>6&63|128,J[F++]=C&63|128;else k=!0,J[F++]=C>>12|224,J[F++]=C>>6&63|128,J[F++]=C&63|128}else F+=pb1(J,N,F),k=F-h>_;if(q<160||q<246&&(P.ascii8||P.string8)){if(k){if(!(x=P.string8))if(G.length>10&&(x=P.ascii8))x.__type=az,P.ascii8=null,P.string8=x,K(null,0,!0);else x=D5(P,az,1)}else if(q===0&&!j){j=!0,x=P.ascii0||D5(P,FT,0);break}else if(!(x=P.ascii8)&&!(G.length>10&&(x=P.string8)))x=D5(P,FT,1);J[$++]=q}else x=P.string16||D5(P,az,2),z.setUint16($,q,!0),$+=2;break;case"object":if(N){if(N.constructor===Date)x=P.date64||D5(P,wT,8),z.setFloat64($,N.getTime(),!0),$+=8;else B.push(M,N,L);break}else if(P=H50(P,$,z,-10),P)x=P,$=KY;else B.push(M,N,L);break;case"boolean":x=P.num8||P.ascii8||D5(P,aK,1),J[$++]=N?249:248;break;case"undefined":if(P=H50(P,$,z,-9),P)x=P,$=KY;else B.push(M,N,L);break;default:B.push(M,N,L)}L++}for(let M=0,N=B.length;M<N;){let P=B[M++],O=B[M++],_=B[M++],k=x[P];if(!k)x[P]=k={key:P,parent:x,enumerationOffset:_-L,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let h;if(O){let f;if(q=F-v,q<65280)if(x=k.object16,x)f=2;else if(x=k.object32)f=4;else x=D5(k,Kc,2),f=2;else x=k.object32||D5(k,Kc,4),f=4;if(h=K(O,F),typeof h==="object")F=h.position,z=h.targetView,J=h.target,v-=X,$-=X,V-=X,X=0;else F=h;if(f===2)z.setUint16($,q,!0),$+=2;else z.setUint32($,q,!0),$+=4}else x=k.object16||D5(k,Kc,2),z.setInt16($,O===null?-10:-9,!0),$+=2;L++}let R=x[x7];if(R==null){R=W.typedStructs.length;let M=[],N=x,P,O;while((O=N.__type)!==void 0){let _=N.__size;N=N.__parent,P=N.key;let k=[O,_,P];if(N.enumerationOffset)k.push(N.enumerationOffset);M.push(k),N=N.parent}M.reverse(),x[x7]=R,W.typedStructs[R]=M,K(null,0,!0)}switch(c){case 1:if(R>=16)return 0;J[V]=R+32;break;case 2:if(R>=256)return 0;J[V]=56,J[V+1]=R;break;case 3:if(R>=65536)return 0;J[V]=57,z.setUint16(V+1,R,!0);break;case 4:if(R>=16777216)return 0;z.setUint32(V,(R<<8)+58,!0);break}if($<v){if(v===F)return $;J.copyWithin($,v,F),F+=$-v,G.lastStringStart=$-V}else if($>v){if(v===F)return $;return G.lastStringStart=$-V,x50(Z,J,X,V,Y,Q,K,W)}return F}function H50(Z,J,X,$){let Y;if(Y=Z.ascii8||Z.num8)return X.setInt8(J,$,!0),KY=J+1,Y;if(Y=Z.string16||Z.object16)return X.setInt16(J,$,!0),KY=J+2,Y;if(Y=Z.num32)return X.setUint32(J,3758096640+$,!0),KY=J+4,Y;if(Y=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,$),KY=J+8,Y;KY=J;return}function D5(Z,J,X){let $=q50[J]+(X<<3),Y=Z[$]||(Z[$]=Object.create(null));return Y.__type=J,Y.__size=X,Y.__parent=Z,Y}function ib1(Z){if(!(Z instanceof Map))return Z;let J=Z.get("typed")||[];if(Object.isFrozen(J))J=J.map((Y)=>Y.slice(0));let X=Z.get("named"),$=Object.create(null);for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y],W=$;for(let[G,z,v]of K){let H=W[v];if(!H)W[v]=H={key:v,parent:W,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};W=D5(H,G,z)}W[x7]=Y}return J.transitions=$,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var xT=Symbol.for("source");function gb1(Z,J,X,$){let Y=Z[J++]-32;if(Y>=24)switch(Y){case 24:Y=Z[J++];break;case 25:Y=Z[J++]+(Z[J++]<<8);break;case 26:Y=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16);break;case 27:Y=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16)+(Z[J++]<<24);break}let Q=$.typedStructs&&$.typedStructs[Y];if(!Q){if(Z=Uint8Array.prototype.slice.call(Z,J,X),X-=J,J=0,!$.getStructures)throw new Error(`Reference to shared structure ${Y} without getStructures method`);if($._mergeStructures($.getStructures()),!$.typedStructs)throw new Error("Could not find any shared typed structures");if($.lastTypedStructuresLength=$.typedStructs.length,Q=$.typedStructs[Y],!Q)throw new Error("Could not find typed structure "+Y)}var{construct:K,fullConstruct:W}=Q;if(!K){K=Q.construct=function q(){},W=Q.fullConstruct=function q(){},W.prototype=$.structPrototype??{};var G=K.prototype=$.structPrototype?Object.create($.structPrototype):{};let v=[],H=0,V;for(let q=0,F=Q.length;q<F;q++){let x=Q[q],[w,c,B,j]=x;if(B==="__proto__")B="__proto_";let L={key:B,offset:H};if(j)v.splice(q+j,0,L);else v.push(L);let R;switch(c){case 0:R=()=>0;break;case 1:R=(N,P)=>{let O=N.bytes[P+L.offset];return O>=246?dK(O):O};break;case 2:R=(N,P)=>{let O=N.bytes,k=(O.dataView||(O.dataView=new DataView(O.buffer,O.byteOffset,O.byteLength))).getUint16(P+L.offset,!0);return k>=65280?dK(k&255):k};break;case 4:R=(N,P)=>{let O=N.bytes,k=(O.dataView||(O.dataView=new DataView(O.buffer,O.byteOffset,O.byteLength))).getUint32(P+L.offset,!0);return k>=4294967040?dK(k&255):k};break}L.getRef=R,H+=c;let M;switch(w){case FT:if(V&&!V.next)V.next=L;V=L,L.multiGetCount=0,M=function(N){let{bytes:P,position:O}=N,_=H+O,k=R(N,O);if(typeof k!=="number")return k;let h,f=L.next;while(f){if(h=f.getRef(N,O),typeof h==="number")break;else h=null;f=f.next}if(h==null)h=N.bytesEnd-_;if(N.srcString)return N.srcString.slice(k,h);return t60(P,k+_,h-k)};break;case az:case Kc:if(V&&!V.next)V.next=L;V=L,M=function(N){let P=N.position,O=H+P,_=R(N,P);if(typeof _!=="number")return _;let k=N.bytes,h,f=L.next;while(f){if(h=f.getRef(N,P),typeof h==="number")break;else h=null;f=f.next}if(h==null)h=N.bytesEnd-O;if(w===az)return k.toString("utf8",_+O,h+O);else{w7=N;try{return $.unpack(k,{start:_+O,end:h+O})}finally{w7=null}}};break;case aK:switch(c){case 4:M=function(N){let P=N.bytes,O=P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength)),_=N.position+L.offset,k=O.getInt32(_,!0);if(k<536870912){if(k>-520093696)return k;if(k>-536870912)return dK(k&255)}let h=O.getFloat32(_,!0),f=YY[(P[_+3]&127)<<1|P[_+2]>>7];return(f*h+(h>0?0.5:-0.5)>>0)/f};break;case 8:M=function(N){let P=N.bytes,_=(P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength))).getFloat64(N.position+L.offset,!0);if(isNaN(_)){let k=P[N.position+L.offset];if(k>=246)return dK(k)}return _};break;case 1:M=function(N){let O=N.bytes[N.position+L.offset];return O<246?O:dK(O)};break}break;case wT:M=function(N){let P=N.bytes,O=P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength));return new Date(O.getFloat64(N.position+L.offset,!0))};break}L.get=M}if(F50){let q=[],F=[],x=0,w;for(let B of v){if($.alwaysLazyProperty&&$.alwaysLazyProperty(B.key)){w=!0;continue}Object.defineProperty(G,B.key,{get:db1(B.get),enumerable:!0});let j="v"+x++;F.push(j),q.push("o["+JSON.stringify(B.key)+"]="+j+"(s)")}if(w)q.push("__proto__:this");let c=new Function(...F,"var c=this;return function(s){var o=new c();"+q.join(";")+";return o;}").apply(W,v.map((B)=>B.get));Object.defineProperty(G,"toJSON",{value(B){return c.call(this,this[xT])}})}else Object.defineProperty(G,"toJSON",{value(q){let F={};for(let x=0,w=v.length;x<w;x++){let c=v[x].key;F[c]=this[c]}return F}})}var z=new K;return z[xT]={bytes:Z,position:J,srcString:"",bytesEnd:X},z}function dK(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function db1(Z){return function(){return Z(this[xT])}}function ab1(){if(w7)w7.bytes=Uint8Array.prototype.slice.call(w7.bytes,w7.position,w7.bytesEnd),w7.position=0,w7.bytesEnd=w7.bytes.length}function nb1(Z,J){if(J.typedStructs){let $=new Map;$.set("named",Z),$.set("typed",J.typedStructs),Z=$}let X=J.lastTypedStructuresLength||0;return Z.isCompatible=($)=>{let Y=!0;if($ instanceof Map){if(($.get("named")||[]).length!==(J.lastNamedStructuresLength||0))Y=!1;if(($.get("typed")||[]).length!==X)Y=!1}else if($ instanceof Array||Array.isArray($)){if($.length!==(J.lastNamedStructuresLength||0))Y=!1}if(!Y)J._mergeStructures($);return Y},J.lastTypedStructuresLength=J.typedStructs&&J.typedStructs.length,Z}$50(gb1,ib1,ab1);var rb1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!rb1){let Z;try{if(Z=g("msgpackr-extract"),Z)r60(Z.extractStrings)}catch(J){}}var WU=t(WY0(),1);import Ba1 from"http";import ja1 from"https";import KU from"fs";import La1 from"path";import Da1 from"url";var GY0=`-----BEGIN CERTIFICATE-----
405
+ }`});try{let $=(await J.next()).value?.data?.userById;if(!$)return p.warning(`PlatformGateway.getPlayerCosmetics(): No cosmetic data returned for user id "${Z}".`);let Y=$.equippedItems.map((W)=>({slot:W.slot,item:W.item.slots.find((G)=>G.type===W.slot)})).filter((W)=>!!W.item),Q=Number($.characterSettings?.hairStyle?.split("_")[1]||1),K=`https://d3qkovarww0lj1.cloudfront.net/?skin_tone=${$.characterSettings?.skinTone||"SKIN_COLOR_1"}&clothing=${$.characterSettings?.clothing||"CLOTHING_1"}&hair_style=${$.characterSettings?.hairStyle||"HAIR_STYLE_1"}&hair_color=${$.characterSettings?.hairColor||"HAIR_COLOR_1"}&eye_color=${$.characterSettings?.eyeColor||"00FF00"}`;return{equippedItems:Y,hairStyle:Q,skinTextureUri:K}}finally{await J.return?.()}}async getPlayerSession(Z){if(!this._creativeGateway)return;return await this._creativeGateway.getSession(Z)}async setData(Z,J){if(J.error)return p.warning("PlatformGateway.setData(): Cannot set data with an error property.");if(!this._creativeGateway&&process.env.NODE_ENV==="production")return p.warning("PlatformGateway.setData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be set.");return this._creativeGateway?await this._creativeGateway.kv.set(Z,J):this._writeDevDataLocally(Z,J)}_readDevDataLocally(Z){try{if(!e$.existsSync(kz))return;let J=D80.join(kz,`${Z}.json`);return JSON.parse(e$.readFileSync(J,"utf8"))}catch(J){p.warning(`PlatformGateway._readDevDataLocally(): Failed to read data for key "${Z}": ${J}`)}}_writeDevDataLocally(Z,J){try{if(!e$.existsSync(kz))e$.mkdirSync(kz,{recursive:!0});let X=D80.join(kz,`${Z}.json`),$={};if(e$.existsSync(X))$=JSON.parse(e$.readFileSync(X,"utf8"));let Y={...$,...J};e$.writeFileSync(X,JSON.stringify(Y,null,2),"utf8")}catch(X){p.warning(`PlatformGateway._writeDevDataLocally(): Failed to write data for key "${Z}": ${X}`)}}}class ZY{static instance=new ZY;constructor(){}async getGlobalData(Z){let J=await O4.instance.getData(Z);if(!J||J.error){if(J?.error)p.warning(`PersistenceManager.getGlobalData(): ${J.error.message}`);return}return J}async getPlayerData(Z){let J=await O4.instance.getData(this._getPlayerKey(Z));if(!J||J.error){if(J?.error)p.warning(`PersistenceManager.getPlayerData(): ${J.error.message}`);return}return J}async setGlobalData(Z,J){let X=await O4.instance.setData(Z,J);if(!X||X.error){if(X?.error)p.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(Z,J){let X=await O4.instance.setData(this._getPlayerKey(Z),J);if(!X||X.error){if(X?.error)p.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(Z){return`player-${Z.id}`}}var R80;(($)=>{$[$.FIRST_PERSON=0]="FIRST_PERSON";$[$.THIRD_PERSON=1]="THIRD_PERSON";$[$.SPECTATOR=2]="SPECTATOR"})(R80||={});var pP;((x)=>{x.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";x.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";x.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";x.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";x.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";x.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";x.SET_FOV="PLAYER_CAMERA.SET_FOV";x.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";x.SET_MODEL_SHOWN_NODES="PLAYER_CAMERA.SET_MODEL_SHOWN_NODES";x.SET_MODE="PLAYER_CAMERA.SET_MODE";x.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";x.SET_SHOULDER_ANGLE="PLAYER_CAMERA.SET_SHOULDER_ANGLE";x.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";x.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";x.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(pP||={});class Ez extends B0{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_modelShownNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_shoulderAngle=0;_trackedEntity;_trackedPosition;_zoom=1;constructor(Z){super();this.player=Z}get attachedToEntity(){return this._attachedToEntity}get attachedToPosition(){return this._attachedToPosition}get facingDirection(){return{x:-Math.sin(this._orientation.yaw)*Math.cos(this._orientation.pitch),y:Math.sin(this._orientation.pitch),z:-Math.cos(this._orientation.yaw)*Math.cos(this._orientation.pitch)}}get facingQuaternion(){let Z=this._orientation.pitch*0.5,J=this._orientation.yaw*0.5,X=Math.cos(Z),$=Math.sin(Z),Y=Math.cos(J),Q=Math.sin(J);return{x:$*Y,y:X*Q,z:-$*Q,w:X*Y}}get filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get modelShownNodes(){return this._modelShownNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get shoulderAngle(){return this._shoulderAngle}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(Z){if(!this._requirePlayerWorld("lookAtEntity"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:Z})}lookAtPosition(Z){if(!this._requirePlayerWorld("lookAtPosition"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:Z})}reset(){this._attachedToEntity=void 0,this._attachedToPosition=void 0,this._orientation={pitch:0,yaw:0},this._trackedEntity=void 0,this._trackedPosition=void 0}setAttachedToEntity(Z){if(!this._requirePlayerWorld("setAttachedToEntity"))return;if(!Z.isSpawned)return p.error(`PlayerCamera.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);this._attachedToEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:Z})}setAttachedToPosition(Z){if(!this._requirePlayerWorld("setAttachedToPosition"))return;this._attachedToPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:Z})}setFilmOffset(Z){if(!this._requirePlayerWorld("setFilmOffset"))return;this._filmOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:Z})}setForwardOffset(Z){if(!this._requirePlayerWorld("setForwardOffset"))return;this._forwardOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:Z})}setFov(Z){if(!this._requirePlayerWorld("setFov"))return;this._fov=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:Z})}setModelHiddenNodes(Z){if(!this._requirePlayerWorld("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setModelShownNodes(Z){if(!this._requirePlayerWorld("setModelShownNodes"))return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_SHOWN_NODES",{playerCamera:this,modelShownNodes:this._modelShownNodes})}setMode(Z){if(!this._requirePlayerWorld("setMode"))return;this._mode=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:Z})}setOffset(Z){if(!this._requirePlayerWorld("setOffset"))return;this._offset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:Z})}setOrientationPitch(Z){this._orientation.pitch=Z}setOrientationYaw(Z){this._orientation.yaw=Z}setShoulderAngle(Z){if(!this._requirePlayerWorld("setShoulderAngle"))return;this._shoulderAngle=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_SHOULDER_ANGLE",{playerCamera:this,shoulderAngle:Z})}setTrackedEntity(Z){if(!this._requirePlayerWorld("setTrackedEntity"))return;this._trackedEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:Z})}setTrackedPosition(Z){if(!this._requirePlayerWorld("setTrackedPosition"))return;this._trackedPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:Z})}setZoom(Z){if(!this._requirePlayerWorld("setZoom"))return;this._zoom=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:Z})}serialize(){return T0.serializePlayerCamera(this)}_requirePlayerWorld(Z){if(!this.player.world)p.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world, invoked method: ${Z}()`);return!!this.player.world}}var nw;((Y)=>{Y.DATA="PLAYER_UI.DATA";Y.LOAD="PLAYER_UI.LOAD";Y.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";Y.SEND_DATA="PLAYER_UI.SEND_DATA"})(nw||={});class Iz extends B0{player;constructor(Z){super();this.player=Z}load(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:Z})}lockPointer(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:Z})}sendData(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:Z})}}var N80=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","u","i","o","j","k","l","n","m","1","2","3","4","5","6","7","8","9","0"],_z;((Q)=>{Q.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";Q.JOINED_WORLD="PLAYER.JOINED_WORLD";Q.LEFT_WORLD="PLAYER.LEFT_WORLD";Q.RECONNECTED_WORLD="PLAYER.RECONNECTED_WORLD";Q.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(_z||={});class gK extends B0{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;cosmetics;ui;_input={};_lastUnreliableInputSequenceNumber=0;_persistedData;_world;_worldSwitched=!1;constructor(Z,J){super();this.id=J?.user.id??`player-${gK._devNextPlayerId++}`,this.username=J?.user.username??this.id,this.profilePictureUrl=J?.user.profilePictureURL??void 0,this.camera=new Ez(this),this.connection=Z,this.cosmetics=O4.instance.getPlayerCosmetics(this.id),this.ui=new Iz(this),Z.onPacket(Y0.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),Z.onPacket(Y0.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),Z.onPacket(Y0.PacketId.INPUT,this._onInputPacket),Z.onPacket(Y0.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),Z.onPacket(Y0.PacketId.UI_DATA_SEND,this._onUIDataSendPacket)}get input(){return this._input}get world(){return this._world}disconnect(){this._leaveWorld(),this.connection.disconnect()}getPersistedData(){return this._persistedData}joinWorld(Z){if(this._world===Z)return;if(!this._world)this._world=Z,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world});else{for(let J of this._world.entityManager.getPlayerEntitiesByPlayer(this))if(J.isSpawned)J.despawn();this.disconnect(),this._world=Z,this._worldSwitched=!0}}async loadInitialPersistedData(){if(this._persistedData)return;this._persistedData=await ZY.instance.getPlayerData(this)??void 0}reconnected(){if(!this._world)return;if(this._lastUnreliableInputSequenceNumber=0,!this._worldSwitched)this.emitWithWorld(this._world,"PLAYER.RECONNECTED_WORLD",{player:this,world:this._world});else this._worldSwitched=!1,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}resetInputs(){this._input={}}setPersistedData(Z){return this._persistedData={...this._persistedData,...Z},ZY.instance.setPlayerData(this,Z).catch((J)=>{}),this._persistedData}serialize(){return T0.serializePlayer(this)}_leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}_onChatMessageSendPacket=(Z)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:Z[1].m})};_onDebugConfigPacket=(Z)=>{console.log(Z)};_onInputPacket=(Z)=>{let J=Z[1];if(J.sq!==void 0){if(J.sq<this._lastUnreliableInputSequenceNumber)return;this._lastUnreliableInputSequenceNumber=J.sq}if(N80.forEach((X)=>{let $=X;if(J[$]!==void 0)this._input[$]=Boolean(J[$])}),J.cp!==void 0)this.camera.setOrientationPitch(J.cp);if(J.cy!==void 0)this.camera.setOrientationYaw(J.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(Z)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:Z[1]})}}var iP;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(iP||={});class bz extends B0{_commandCallbacks={};_world;constructor(Z){super();this._world=Z,this._subscribeToPlayerEvents()}registerCommand(Z,J){this._commandCallbacks[Z]=J}unregisterCommand(Z){delete this._commandCallbacks[Z]}sendBroadcastMessage(Z,J){this._sendBroadcastMessage(void 0,Z,J)}sendPlayerMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:Z,message:J,color:X})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(Z)=>{let{player:J,message:X}=Z,[$,...Y]=X.split(" "),Q=this._commandCallbacks[$];if(Q){Q(J,Y,X);return}this._sendBroadcastMessage(J,X)})}_sendBroadcastMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:Z,message:J,color:X})}}var y5=16,gP=y5-1,aI1=y5**3;class p5{_blocks;_originCoordinate;constructor(Z){this._blocks=new Uint8Array(aI1),this._originCoordinate=Z}get blocks(){return this._blocks}get originCoordinate(){return this._originCoordinate}static blockIndexToLocalCoordinate(Z){return{x:Z%y5,y:(Z/y5|0)%y5,z:Z/(y5*y5)|0}}static globalCoordinateToLocalCoordinate(Z){return{x:Z.x&y5-1,y:Z.y&y5-1,z:Z.z&y5-1}}static globalCoordinateToOriginCoordinate(Z){return{x:Z.x&~(y5-1),y:Z.y&~(y5-1),z:Z.z&~(y5-1)}}getBlockId(Z){return this._blocks[this._getIndex(Z)]}hasBlock(Z){return this._blocks[this._getIndex(Z)]!==0}setBlock(Z,J){if(!this._isValidLocalCoordinate(Z))return p.error("Chunk.setBlock(): Block local coordinate is out of bounds");let X=this._getIndex(Z);this._blocks[X]=J}serialize(){return T0.serializeChunk(this)}_getIndex(Z){return Z.x+(Z.y<<4)+(Z.z<<8)}_isValidLocalCoordinate(Z){return Z.x>=0&&Z.x<=gP&&Z.y>=0&&Z.y<=gP&&Z.z>=0&&Z.z<=gP}}var dP;(($)=>{$.ADD_CHUNK="CHUNK_LATTICE.ADD_CHUNK";$.REMOVE_CHUNK="CHUNK_LATTICE.REMOVE_CHUNK";$.SET_BLOCK="CHUNK_LATTICE.SET_BLOCK"})(dP||={});class hz extends B0{_blockTypeColliders=new Map;_blockTypeCounts=new Map;_chunks=new Map;_rigidBody;_world;constructor(Z){super();this._world=Z}get chunkCount(){return this._chunks.size}clear(){for(let Z of this._blockTypeColliders.values())this._world.simulation.colliderMap.removeColliderBlockType(Z),Z.removeFromSimulation();this._chunks.forEach((Z)=>{this.emitWithWorld(this._world,"CHUNK_LATTICE.REMOVE_CHUNK",{chunkLattice:this,chunk:Z})}),this._blockTypeColliders.clear(),this._blockTypeCounts.clear(),this._chunks.clear()}getBlockId(Z){let J=this.getChunk(p5.globalCoordinateToOriginCoordinate(Z));if(!J)return 0;return J.getBlockId(p5.globalCoordinateToLocalCoordinate(Z))}getBlockTypeCollider(Z){return this._blockTypeColliders.get(Z)}getBlockType(Z){let J=this.getBlockId(Z);return J?this._world.blockTypeRegistry.getBlockType(J):null}getBlockTypeCount(Z){return this._blockTypeCounts.get(Z)??0}getChunk(Z){return this._chunks.get(this._getChunkKey(p5.globalCoordinateToOriginCoordinate(Z)))}getOrCreateBlockTypeCollider(Z,J){let X=this._blockTypeColliders.get(Z);if(X)return X;let Y=this._world.blockTypeRegistry.getBlockType(Z).createCollider(J);return this._blockTypeColliders.set(Z,Y),Y}getOrCreateChunk(Z){let J=p5.globalCoordinateToOriginCoordinate(Z),X=this._chunks.get(this._getChunkKey(J));if(X)return X;return X=new p5(J),this._chunks.set(this._getChunkKey(J),X),this.emitWithWorld(this._world,"CHUNK_LATTICE.ADD_CHUNK",{chunkLattice:this,chunk:X}),X}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(Z){let J=this.getChunk(p5.globalCoordinateToOriginCoordinate(Z));if(!J)return!1;return J.hasBlock(p5.globalCoordinateToLocalCoordinate(Z))}hasChunk(Z){let J=p5.globalCoordinateToOriginCoordinate(Z);return this._chunks.has(this._getChunkKey(J))}setBlock(Z,J){let X=p5.globalCoordinateToLocalCoordinate(Z),$=this.getOrCreateChunk(Z),Y=$.getBlockId(X);if(Y===J)return;if($.setBlock(X,J),!this._rigidBody)this._rigidBody=new l$({type:"fixed"}),this._rigidBody.addToSimulation(this._world.simulation);if(Y!==0){let Q=Math.max(0,(this._blockTypeCounts.get(Y)??0)-1),K=this.getBlockTypeCollider(Y);if(K)if(Q===0)this._world.simulation.colliderMap.removeColliderBlockType(K),K.removeFromSimulation(),this._blockTypeColliders.delete(Y);else K.setVoxel(Z,!1),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set(Y,Q)}if(J!==0){let Q=(this._blockTypeCounts.get(J)??0)+1,K=this.getOrCreateBlockTypeCollider(J,[Z]);if(Q===1){let W=this._world.blockTypeRegistry.getBlockType(J);K.addToSimulation(this._world.simulation,this._rigidBody),this._world.simulation.colliderMap.setColliderBlockType(K,W),this._combineVoxelStates(K)}else K.setVoxel(Z,!0),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set(J,Q)}this.emitWithWorld(this._world,"CHUNK_LATTICE.SET_BLOCK",{chunkLattice:this,chunk:$,globalCoordinate:Z,localCoordinate:X,blockTypeId:J})}_combineVoxelStates(Z){if(Z.isSensor)return;for(let J of this._blockTypeColliders.values()){if(J===Z||J.isSensor)continue;Z.combineVoxelStates(J)}}_getChunkKey(Z){return`${Z.x},${Z.y},${Z.z}`}_propagateVoxelChange(Z,J){if(Z.isSensor)return;for(let X of this._blockTypeColliders.values()){if(X===Z||X.isSensor)continue;Z.propagateVoxelChange(X,J)}}}class Sz{_colliderHandleBlockTypeMap=new Map;_colliderHandleCollisionCallbackMap=new Map;_colliderHandleEntityMap=new Map;_cleanupBlockTypeColliderHandles=new Set;_pendingCleanupBlockTypeColliderHandles=new Set;_cleanupCollisionCallbackColliderHandles=new Set;_pendingCleanupCollisionCallbackColliderHandles=new Set;_cleanupEntityColliderHandles=new Set;_pendingCleanupEntityColliderHandles=new Set;getColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleBlockTypeMap.get(Z.rawCollider.handle)}getColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleCollisionCallbackMap.get(Z.rawCollider.handle)}getColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleEntityMap.get(Z.rawCollider.handle)}getColliderHandleBlockType(Z){return this._colliderHandleBlockTypeMap.get(Z)}getColliderHandleCollisionCallback(Z){return this._colliderHandleCollisionCallbackMap.get(Z)}getColliderHandleEntity(Z){return this._colliderHandleEntityMap.get(Z)}removeColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleBlockType(Z.rawCollider.handle)}removeColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleCollisionCallback(Z.rawCollider.handle)}removeColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleEntity(Z.rawCollider.handle)}removeColliderHandleBlockType(Z){this._colliderHandleBlockTypeMap.delete(Z)}removeColliderHandleCollisionCallback(Z){this._colliderHandleCollisionCallbackMap.delete(Z)}removeColliderHandleEntity(Z){this._colliderHandleEntityMap.delete(Z)}setColliderBlockType(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleBlockType(Z.rawCollider.handle,J)}setColliderCollisionCallback(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleCollisionCallback(Z.rawCollider.handle,J)}setColliderEntity(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleEntity(Z.rawCollider.handle,J)}setColliderHandleBlockType(Z,J){this._colliderHandleBlockTypeMap.set(Z,J),this._cleanupBlockTypeColliderHandles.delete(Z),this._pendingCleanupBlockTypeColliderHandles.delete(Z)}setColliderHandleCollisionCallback(Z,J){this._colliderHandleCollisionCallbackMap.set(Z,J),this._cleanupCollisionCallbackColliderHandles.delete(Z),this._pendingCleanupCollisionCallbackColliderHandles.delete(Z)}setColliderHandleEntity(Z,J){this._colliderHandleEntityMap.set(Z,J),this._cleanupEntityColliderHandles.delete(Z),this._pendingCleanupEntityColliderHandles.delete(Z)}queueColliderHandleForCleanup(Z){if(this._colliderHandleBlockTypeMap.has(Z))this._pendingCleanupBlockTypeColliderHandles.add(Z);if(this._colliderHandleCollisionCallbackMap.has(Z))this._pendingCleanupCollisionCallbackColliderHandles.add(Z);if(this._colliderHandleEntityMap.has(Z))this._pendingCleanupEntityColliderHandles.add(Z)}cleanup(){for(let Z of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(Z);if(this._cleanupBlockTypeColliderHandles.size>0)this._cleanupBlockTypeColliderHandles.clear();for(let Z of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(Z);if(this._cleanupCollisionCallbackColliderHandles.size>0)this._cleanupCollisionCallbackColliderHandles.clear();for(let Z of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(Z);if(this._cleanupEntityColliderHandles.size>0)this._cleanupEntityColliderHandles.clear();for(let Z of this._pendingCleanupBlockTypeColliderHandles)this._cleanupBlockTypeColliderHandles.add(Z);if(this._pendingCleanupBlockTypeColliderHandles.size>0)this._pendingCleanupBlockTypeColliderHandles.clear();for(let Z of this._pendingCleanupCollisionCallbackColliderHandles)this._cleanupCollisionCallbackColliderHandles.add(Z);if(this._pendingCleanupCollisionCallbackColliderHandles.size>0)this._pendingCleanupCollisionCallbackColliderHandles.clear();for(let Z of this._pendingCleanupEntityColliderHandles)this._cleanupEntityColliderHandles.add(Z);if(this._pendingCleanupEntityColliderHandles.size>0)this._pendingCleanupEntityColliderHandles.clear()}_requireSimulatedCollider(Z){if(!Z.rawCollider)p.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!Z.rawCollider}}var O80={type:"dynamic",softCcdPrediction:1},P80=0.015625,T80=Math.cos(0.026),Az;((L)=>{L.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";L.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";L.DESPAWN="ENTITY.DESPAWN";L.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";L.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";L.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";L.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";L.SET_MODEL_SCALE="ENTITY.SET_MODEL_SCALE";L.SET_MODEL_SHOWN_NODES="ENTITY.SET_MODEL_SHOWN_NODES";L.SET_MODEL_TEXTURE_URI="ENTITY.SET_MODEL_TEXTURE_URI";L.SET_OPACITY="ENTITY.SET_OPACITY";L.SET_PARENT="ENTITY.SET_PARENT";L.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";L.SPAWN="ENTITY.SPAWN";L.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";L.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";L.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";L.TICK="ENTITY.TICK";L.UPDATE_POSITION="ENTITY.UPDATE_POSITION";L.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(Az||={});class j8 extends l${_id;_blockHalfExtents;_blockTextureUri;_controller;_isEnvironmental=!1;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelPreferredShape;_modelScale=1;_modelShownNodes=new Set;_modelTextureUri;_modelUri;_name;_opacity;_parent;_parentNodeName;_tag;_tintColor;_lastUpdatedPosition={x:0,y:0,z:0};_lastUpdatedRotation={x:0,y:0,z:0,w:1};_lastParentlessType="dynamic";_world;_positionUpdateThresholdSq;_rotationUpdateThreshold;constructor(Z){let J="blockTextureUri"in Z,X="modelUri"in Z;if(!J===!X)p.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J&&!Z.blockHalfExtents)p.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(Z.parent&&!Z.parent.isSpawned)p.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(Z.parent?.modelUri&&Z.parentNodeName&&!j6.instance.modelHasNode(Z.parent.modelUri,Z.parentNodeName))p.fatalError(`Entity.constructor(): Parent node name ${Z.parentNodeName} not found in parent model ${Z.parent.modelUri}!`);super(Z.rigidBodyOptions??O80);if(J)this._blockHalfExtents=Z.blockHalfExtents,this._blockTextureUri=Z.blockTextureUri;if(X)this._modelAnimationsPlaybackRate=Z.modelAnimationsPlaybackRate??1,this._modelPreferredShape=Z.modelPreferredShape,this._modelScale=Z.modelScale??1,this._modelTextureUri=Z.modelTextureUri,this._modelUri=Z.modelUri,Z.modelHiddenNodes?.forEach(($)=>this._modelHiddenNodes.add($.toLowerCase())),Z.modelLoopedAnimations?.forEach(($)=>this._modelLoopedAnimations.add($)),Z.modelShownNodes?.forEach(($)=>this._modelShownNodes.add($.toLowerCase()));if(this._isEnvironmental=Z.isEnvironmental??!1,this._name=Z.name??"Nameless",this._opacity=Z.opacity??1,this._parent=Z.parent,this._parentNodeName=Z.parentNodeName,this._tag=Z.tag,this._tintColor=Z.tintColor,this._positionUpdateThresholdSq=P80,this._rotationUpdateThreshold=T80,Z.controller)this.setController(Z.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get depth(){return this.isModelEntity?j6.instance.getDepth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.z*2}get height(){return this.isModelEntity?j6.instance.getHeight(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.y*2}get modelAnimationsPlaybackRate(){return this._modelAnimationsPlaybackRate}get modelHiddenNodes(){return this._modelHiddenNodes}get modelLoopedAnimations(){return this._modelLoopedAnimations}get modelPreferredShape(){return this._modelPreferredShape}get modelScale(){return this._modelScale}get modelShownNodes(){return this._modelShownNodes}get modelTextureUri(){return this._modelTextureUri}get modelUri(){return this._modelUri}get name(){return this._name}get opacity(){return this._opacity}get parent(){return this._parent}get parentNodeName(){return this._parentNodeName}get tag(){return this._tag}get tintColor(){return this._tintColor}get isBlockEntity(){return!!this._blockTextureUri}get isEnvironmental(){return this._isEnvironmental}get isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get width(){return this.isModelEntity?j6.instance.getWidth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.x*2}get world(){return this._world}spawn(Z,J,X){if(this.isSpawned)return p.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(Z.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new m5(m5.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0&&this._modelPreferredShape!=="none")this.addChildColliderToSimulation(new m5(m5.optionsFromModelUri(this._modelUri,this._modelScale,this._modelPreferredShape)));if(this.colliders.forEach(($)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))$.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups($.collisionGroups)){let Y=this.isEnvironmental?[8]:[$.isSensor?4:2],Q=this.isEnvironmental?[65535&~8&~1]:[65535];$.setCollisionGroups({belongsTo:Y,collidesWith:Q})}}),this.setPosition(J),X)this.setRotation(X);if(this._id=Z.entityManager.registerEntity(this),this._world=Z,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,J,X);this.colliders.forEach(($)=>{Z.simulation.colliderMap.setColliderEntity($,this)}),this.emitWithWorld(Z,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((Z)=>{Z.despawn()}),this._controller)this._controller.detach(this),this._controller.despawn(this);if(this.emitWithWorld(this._world,"ENTITY.DESPAWN",{entity:this}),this.isSimulated)this.removeFromSimulation();this._world.entityManager.unregisterEntity(this),this._world.audioManager.unregisterEntityAttachedAudios(this),this._world.lightManager.despawnEntityAttachedLights(this),this._world.particleEmitterManager.despawnEntityAttachedParticleEmitters(this),this._world.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setController(Z){if(this._controller===Z)return;if(this._controller)this._controller.detach(this);if(this._controller=Z,this._controller)this._controller.attach(this)}setModelAnimationsPlaybackRate(Z){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===Z)return;this._modelAnimationsPlaybackRate=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:Z})}setModelHiddenNodes(Z){if(!this._requireSpawned("setModelHiddenNodes"))return;if(!this.isModelEntity)return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setModelScale(Z){if(!this._requireSpawned("setModelScale"))return;if(!this.isModelEntity||this._modelScale===Z)return;let J=Z/this._modelScale;this._modelScale=Z,this.colliders.forEach((X)=>X.scale(J)),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SCALE",{entity:this,modelScale:Z})}setModelShownNodes(Z){if(!this._requireSpawned("setModelShownNodes"))return;if(!this.isModelEntity)return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SHOWN_NODES",{entity:this,modelShownNodes:this._modelShownNodes})}setModelTextureUri(Z){if(!this._requireSpawned("setModelTextureUri"))return;if(!this.isModelEntity||this._modelTextureUri===Z)return;this._modelTextureUri=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_TEXTURE_URI",{entity:this,modelTextureUri:Z})}setOpacity(Z){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===Z)return;this._opacity=Z,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:Z})}setParent(Z,J,X,$){if(!this._requireSpawned("setParent"))return;if(Z&&!Z.isSpawned)return p.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&Z)this._lastParentlessType=this.type;if(this._parent=Z,this._parentNodeName=J,this.colliders.forEach((Y)=>Y.setEnabled(!Z)),this.setType(!Z?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation($??{x:0,y:0,z:0,w:1}),!this.isKinematicPositionBased)this.resetAngularVelocity(),this.resetForces(),this.resetLinearVelocity(),this.resetTorques();this.emitWithWorld(this._world,"ENTITY.SET_PARENT",{entity:this,parent:Z,parentNodeName:J})}setTintColor(Z){if(!this._requireSpawned("setTintColor"))return;if(!Z&&!this._tintColor||Z&&this._tintColor&&Z.r===this._tintColor.r&&Z.g===this._tintColor.g&&Z.b===this._tintColor.b)return;this._tintColor=Z,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:Z})}startModelLoopedAnimations(Z){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>!this._modelLoopedAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(Z)})}startModelOneshotAnimations(Z){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!Z.length)return;Z.forEach((J)=>{this._modelOneshotAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(Z)})}stopAllModelAnimations(Z=[]){if(!this._requireSpawned("stopAllModelAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations,this._modelOneshotAnimations],Z)}stopAllModelLoopedAnimations(Z=[]){if(!this._requireSpawned("stopAllModelLoopedAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations],Z)}stopAllModelOneshotAnimations(Z=[]){if(!this._requireSpawned("stopAllModelOneshotAnimations"))return;this._stopAnimationsFromSets([this._modelOneshotAnimations],Z)}stopModelAnimations(Z){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>this._modelLoopedAnimations.has(J))&&!Z.some((J)=>this._modelOneshotAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.delete(J),this._modelOneshotAnimations.delete(J)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(Z)})}serialize(){return T0.serializeEntity(this)}tick(Z){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:Z}),this._controller)this._controller.tick(this,Z)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let Z=this.position,J=this.rotation;if(this._rotationExceedsThreshold(J,this._lastUpdatedRotation))this._lastUpdatedRotation=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:J});if(this._positionExceedsThreshold(Z,this._lastUpdatedPosition))this._lastUpdatedPosition=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:Z})}_positionExceedsThreshold(Z,J){let X=Z.x-J.x,$=Z.y-J.y,Y=Z.z-J.z;return X*X+$*$+Y*Y>this._positionUpdateThresholdSq}_requireSpawned(Z){if(!this.isSpawned)p.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${Z}()!`);return this.isSpawned}_rotationExceedsThreshold(Z,J){return Math.abs(Z.x*J.x+Z.y*J.y+Z.z*J.z+Z.w*J.w)<this._rotationUpdateThreshold}_stopAnimationsFromSets(Z,J=[]){if(!this.isModelEntity)return;let X=new Set(J),$=[];for(let Y of Z)for(let Q of Y)if(!X.has(Q))$.push(Q);if($.length>0)this.stopModelAnimations($)}}class b1 extends w${static BASE_ENTITY_HEIGHT=1.5;static GROUND_SENSOR_HEIGHT_SCALE=0.125;static GROUND_SENSOR_RADIUS_SCALE=0.23;static JUMP_LAND_HEAVY_VELOCITY_THRESHOLD=-12;static WALL_COLLIDER_HEIGHT_SCALE=0.33;static WALL_COLLIDER_RADIUS_SCALE=0.4;static MOVEMENT_ROTATIONS={wa:Math.PI/4,wd:-Math.PI/4,sa:Math.PI-Math.PI/4,sd:Math.PI+Math.PI/4,s:Math.PI,asd:Math.PI,a:Math.PI/2,d:-Math.PI/2};static EXTERNAL_IMPULSE_DECAY_RATE=0.253;static SWIM_UPWARD_COOLDOWN_MS=600;static SWIMMING_DRAG_FACTOR=0.05;static WATER_ENTRY_SINKING_FACTOR=0.8;static WATER_ENTRY_SINKING_MS=250;applyDirectionalMovementRotations=!0;autoCancelMouseLeftClick=!0;canJump=()=>!0;canRun=()=>!0;canSwim=()=>!0;canWalk=()=>!0;faceForwardOnStop=!0;idleLoopedAnimations=["idle-upper","idle-lower"];interactOneshotAnimations=["simple-interact"];jumpLandHeavyOneshotAnimations=["jump-post-heavy"];jumpLandLightOneshotAnimations=["jump-post-light"];jumpOneshotAnimations=["jump-loop"];jumpVelocity=10;runLoopedAnimations=["run-upper","run-lower"];runVelocity=8;sticksToPlatforms=!0;swimFastVelocity=5;swimGravity=0;swimIdleLoopedAnimations=["swim-idle"];swimLoopedAnimations=["swim-forward"];swimMaxGravityVelocity=-1;swimSlowVelocity=3;swimUpwardVelocity=2;walkLoopedAnimations=["walk-upper","walk-lower"];walkVelocity=4;_externalVelocity={x:0,y:0,z:0};_magnitudeYTracker=0;_groundContactCount=0;_internalApplyImpulse=()=>{};_isActivelyMoving=!1;_isFullySubmerged=!1;_justSubmergedUntil=0;_liquidContactCount=0;_platform;_reusableImpulse={x:0,y:0,z:0};_reusablePlatformVelocity={x:0,y:0,z:0};_reusableTargetVelocities={x:0,y:0,z:0};_reusableVelocityClamp={x:0,y:0,z:0};_stepAudio;_swimUpwardCooldownAt=0;constructor(Z={}){super();this.applyDirectionalMovementRotations=Z.applyDirectionalMovementRotations??this.applyDirectionalMovementRotations,this.autoCancelMouseLeftClick=Z.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.faceForwardOnStop=Z.faceForwardOnStop??this.faceForwardOnStop,this.sticksToPlatforms=Z.sticksToPlatforms??this.sticksToPlatforms,this.canJump=Z.canJump??this.canJump,this.canRun=Z.canRun??this.canRun,this.canSwim=Z.canSwim??this.canSwim,this.canWalk=Z.canWalk??this.canWalk,this.jumpVelocity=Z.jumpVelocity??this.jumpVelocity,this.runVelocity=Z.runVelocity??this.runVelocity,this.walkVelocity=Z.walkVelocity??this.walkVelocity,this.swimFastVelocity=Z.swimFastVelocity??this.swimFastVelocity,this.swimSlowVelocity=Z.swimSlowVelocity??this.swimSlowVelocity,this.swimUpwardVelocity=Z.swimUpwardVelocity??this.swimUpwardVelocity,this.swimGravity=Z.swimGravity??this.swimGravity,this.swimMaxGravityVelocity=Z.swimMaxGravityVelocity??this.swimMaxGravityVelocity,this.idleLoopedAnimations=Z.idleLoopedAnimations??this.idleLoopedAnimations,this.interactOneshotAnimations=Z.interactOneshotAnimations??this.interactOneshotAnimations,this.jumpOneshotAnimations=Z.jumpOneshotAnimations??this.jumpOneshotAnimations,this.jumpLandHeavyOneshotAnimations=Z.jumpLandHeavyOneshotAnimations??this.jumpLandHeavyOneshotAnimations,this.jumpLandLightOneshotAnimations=Z.jumpLandLightOneshotAnimations??this.jumpLandLightOneshotAnimations,this.runLoopedAnimations=Z.runLoopedAnimations??this.runLoopedAnimations,this.swimLoopedAnimations=Z.swimLoopedAnimations??this.swimLoopedAnimations,this.swimIdleLoopedAnimations=Z.swimIdleLoopedAnimations??this.swimIdleLoopedAnimations,this.walkLoopedAnimations=Z.walkLoopedAnimations??this.walkLoopedAnimations}get isActivelyMoving(){return this._isActivelyMoving}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get isSwimming(){return this._liquidContactCount>0}get platform(){return this._platform}attach(Z){super.attach(Z),this._internalApplyImpulse=Z.applyImpulse.bind(Z),Z.applyImpulse=(J)=>{let X=Z.mass||1;this._externalVelocity.x+=J.x/X,this._externalVelocity.y+=J.y/X,this._externalVelocity.z+=J.z/X},this._stepAudio=new RW({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,referenceDistance:2,cutoffDistance:15,attachedToEntity:Z}),Z.setCcdEnabled(!0),Z.lockAllRotations(),Z.on("ENTITY.BLOCK_COLLISION",({blockType:J,started:X})=>{if(!J.isLiquid||!this.canSwim(this))return;if(this._liquidContactCount<=0&&X){let $=Z.linearVelocity;Z.setLinearVelocity({x:$.x*this.swimGravity,y:$.y*this.swimGravity,z:$.z*this.swimGravity})}if(this._liquidContactCount+=X?1:-1,this._liquidContactCount>0)Z.setGravityScale(this.swimGravity),Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),this._swimUpwardCooldownAt=performance.now()+b1.SWIM_UPWARD_COOLDOWN_MS;else Z.setGravityScale(1),Z.stopModelAnimations(this.swimLoopedAnimations)})}spawn(Z){if(!Z.isSpawned)return p.error("DefaultPlayerEntityController.spawn(): Entity is not spawned!");Z.createAndAddChildCollider({shape:"cylinder",radius:b1.GROUND_SENSOR_RADIUS_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),halfHeight:b1.GROUND_SENSOR_HEIGHT_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},isSensor:!0,relativePosition:{x:0,y:-Z.height/2,z:0},tag:"groundSensor",onCollision:(J,X)=>{if(!Z.isSpawned)return;if(!(J instanceof u5)||!J.isLiquid){if(X&&this._groundContactCount===0&&Z.linearVelocity.y<-1)if(Z.linearVelocity.y<b1.JUMP_LAND_HEAVY_VELOCITY_THRESHOLD)Z.startModelOneshotAnimations(this.jumpLandHeavyOneshotAnimations);else Z.startModelOneshotAnimations(this.jumpLandLightOneshotAnimations);this._groundContactCount+=X?1:-1}if(!this._groundContactCount&&!this.isSwimming)Z.startModelOneshotAnimations(this.jumpOneshotAnimations);else Z.stopModelAnimations(this.jumpOneshotAnimations);if(!(J instanceof j8))return;if(X&&this.sticksToPlatforms)this._platform=J;else if(J===this._platform&&!X)this._platform=void 0}}),Z.createAndAddChildCollider({shape:"capsule",halfHeight:b1.WALL_COLLIDER_HEIGHT_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),radius:b1.WALL_COLLIDER_RADIUS_SCALE*(Z.height/b1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(Z,J,X,$){if(!Z.isSpawned||!Z.world)return;if(super.tickWithPlayerInput(Z,J,X,$),Z.parent)return;let{w:Y,a:Q,s:K,d:W,c:G,sp:z,sh:v,ml:H}=J,{yaw:V}=X,q=Z.linearVelocity;this._reusableTargetVelocities.x=0,this._reusableTargetVelocities.y=0,this._reusableTargetVelocities.z=0,this._isActivelyMoving=!!(Y||Q||K||W);let F=v,x=Q&&W&&!Y&&!K||Y&&K&&!Q&&!W,w=F&&this.canRun(this)||!F&&this.canWalk(this);if(this.isSwimming&&!this._isFullySubmerged)this._isFullySubmerged=!0,this._justSubmergedUntil=performance.now()+b1.WATER_ENTRY_SINKING_MS;else if(!this.isSwimming)this._isFullySubmerged=!1,this._justSubmergedUntil=0;if(this.isGrounded&&!this.isSwimming&&this._isActivelyMoving&&!x&&w){let M=F?this.runLoopedAnimations:this.walkLoopedAnimations;Z.stopAllModelLoopedAnimations(M),Z.startModelLoopedAnimations(M),this._stepAudio?.setPlaybackRate(F?0.75:0.51),this._stepAudio?.play(Z.world,!this._stepAudio?.isPlaying)}else if(this._isFullySubmerged&&this.canSwim(this))if(this._stepAudio?.pause(),this._isActivelyMoving)Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),Z.startModelLoopedAnimations(this.swimLoopedAnimations);else Z.stopAllModelLoopedAnimations(this.swimIdleLoopedAnimations),Z.startModelLoopedAnimations(this.swimIdleLoopedAnimations);else this._stepAudio?.pause(),Z.stopAllModelLoopedAnimations(this.idleLoopedAnimations),Z.startModelLoopedAnimations(this.idleLoopedAnimations);let c;if(this.applyDirectionalMovementRotations&&w){if(Y&&Q&&!W&&!K)c=b1.MOVEMENT_ROTATIONS.wa;else if(Y&&W&&!Q&&!K)c=b1.MOVEMENT_ROTATIONS.wd;else if(K&&Q&&!Y&&!W)c=b1.MOVEMENT_ROTATIONS.sa;else if(K&&W&&!Y&&!Q)c=b1.MOVEMENT_ROTATIONS.sd;else if(K&&!Y&&!Q&&!W||Q&&K&&W&&!Y)c=b1.MOVEMENT_ROTATIONS.s;else if(Q&&!Y&&!K&&!W)c=b1.MOVEMENT_ROTATIONS.a;else if(W&&!Y&&!Q&&!K)c=b1.MOVEMENT_ROTATIONS.d}if(H)Z.startModelOneshotAnimations(this.interactOneshotAnimations),J.ml=!this.autoCancelMouseLeftClick;if(w){let M=!this.isSwimming?F?this.runVelocity:this.walkVelocity:F?this.swimFastVelocity:this.swimSlowVelocity,N=Math.sin(V),P=Math.cos(V);if(Y)this._reusableTargetVelocities.x-=M*N,this._reusableTargetVelocities.z-=M*P;if(K)this._reusableTargetVelocities.x+=M*N,this._reusableTargetVelocities.z+=M*P;if(Q)this._reusableTargetVelocities.x-=M*P,this._reusableTargetVelocities.z+=M*N;if(W)this._reusableTargetVelocities.x+=M*P,this._reusableTargetVelocities.z-=M*N;let O=Math.sqrt(this._reusableTargetVelocities.x*this._reusableTargetVelocities.x+this._reusableTargetVelocities.z*this._reusableTargetVelocities.z);if(O>M){let _=M/O;this._reusableTargetVelocities.x*=_,this._reusableTargetVelocities.z*=_}}if(this.isSwimming){if(q.y<this.swimMaxGravityVelocity)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimMaxGravityVelocity,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(q.y>this.swimUpwardVelocity*2)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimUpwardVelocity*2,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(G)this._reusableTargetVelocities.y=-this.swimUpwardVelocity;else if(performance.now()<this._justSubmergedUntil)this._reusableTargetVelocities.y=-this.swimUpwardVelocity*b1.WATER_ENTRY_SINKING_FACTOR;else if(!z)this._reusableTargetVelocities.y=-q.y*b1.SWIMMING_DRAG_FACTOR}if(z&&this.canJump(this)){if(this.isGrounded&&!this.isSwimming&&q.y>-0.001&&q.y<=3)this._reusableTargetVelocities.y=this.jumpVelocity;else if(this.isSwimming&&performance.now()>this._swimUpwardCooldownAt)this._reusableTargetVelocities.y=this.swimUpwardVelocity}let B=this._platform?.linearVelocity??this._reusablePlatformVelocity;if(this._externalVelocity.y!==0)this._magnitudeYTracker+=this._externalVelocity.y;if(this._externalVelocity.x!==0||this._externalVelocity.y!==0||this._externalVelocity.z!==0){if(this.isGrounded){let M=Math.sqrt(this._externalVelocity.x*this._externalVelocity.x+this._magnitudeYTracker*this._magnitudeYTracker+this._externalVelocity.z*this._externalVelocity.z);if(M>0.01){let P=Math.max(0,M-b1.EXTERNAL_IMPULSE_DECAY_RATE)/M;this._externalVelocity.x*=P,this._magnitudeYTracker*=P,this._externalVelocity.z*=P}else this._externalVelocity.x=0,this._externalVelocity.y=0,this._magnitudeYTracker=0,this._externalVelocity.z=0}}let j=this._reusableTargetVelocities.x+this._externalVelocity.x-q.x+B.x,L=this._reusableTargetVelocities.y+this._externalVelocity.y+B.y,R=this._reusableTargetVelocities.z+this._externalVelocity.z-q.z+B.z;if(this._externalVelocity.y=0,j!==0||L!==0||R!==0){let M=Z.mass;this._reusableImpulse.x=j*M,this._reusableImpulse.y=L*M,this._reusableImpulse.z=R*M,this._internalApplyImpulse(this._reusableImpulse)}if(V!==void 0&&(this.faceForwardOnStop||this.isActivelyMoving)){let N=(c!==void 0?V+c:V)*0.5;Z.setRotation({x:0,y:Math.sin(N),z:0,w:Math.cos(N)})}}}var aP;((W)=>{W.LOAD="SCENE_UI.LOAD";W.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";W.SET_OFFSET="SCENE_UI.SET_OFFSET";W.SET_POSITION="SCENE_UI.SET_POSITION";W.SET_STATE="SCENE_UI.SET_STATE";W.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";W.UNLOAD="SCENE_UI.UNLOAD"})(aP||={});class mz extends B0{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)p.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=Z.attachedToEntity,this._offset=Z.offset,this._position=Z.position,this._state=Z.state??{},this._templateId=Z.templateId,this._viewDistance=Z.viewDistance}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get isLoaded(){return this._id!==void 0}get offset(){return this._offset}get position(){return this._position}get state(){return this._state}get templateId(){return this._templateId}get viewDistance(){return this._viewDistance}get world(){return this._world}load(Z){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return p.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=Z.sceneUIManager.registerSceneUI(this),this._world=Z,this.emitWithWorld(Z,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(Z){if(!Z.isSpawned)return p.error(`SceneUI.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:Z})}setOffset(Z){if(this._offset===Z)return;if(this._offset=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:Z})}setPosition(Z){if(this._position===Z)return;if(this._attachedToEntity=void 0,this._position=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:Z})}setState(Z){if(this._state={...this._state,...Z},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(Z){if(this._viewDistance=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:Z})}unload(){if(!this.isLoaded||!this._world)return;this._world.sceneUIManager.unregisterSceneUI(this),this.emitWithWorld(this._world,"SCENE_UI.UNLOAD",{sceneUI:this}),this._id=void 0,this._world=void 0}serialize(){return T0.serializeSceneUI(this)}}var C80=0.010000000000000002,f80=Math.cos(0.026);class F7 extends j8{player;nametagSceneUI;constructor(Z){super(Z);this._positionUpdateThresholdSq=C80,this._rotationUpdateThreshold=f80,this.player=Z.player,this.nametagSceneUI=new mz({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}})}spawn(Z,J,X){super.spawn(Z,J,X),this.nametagSceneUI.load(Z),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:$})=>{this.nametagSceneUI.setState({chat:$})})}tick(Z){if(!this.isSpawned||!this.world)return;if(!this.controller)return p.error(`PlayerEntity.tick(): PlayerEntity "${this.name}" must have a controller.`);let{input:J,camera:X}=this.player;this.controller.tickWithPlayerInput(this,J,X.orientation,Z),super.tick(Z)}}var k80="models/players/player.gltf",nI1={BACK:"back-anchor",HEAD:"head-anchor",LEFT_ARM:"arm-left-anchor",LEFT_FOOT:"foot-left-anchor",LEFT_HAND:"hand-left-anchor",LEFT_ITEM:"hand-left-anchor",LEFT_LEG:"leg-left-anchor",RIGHT_ARM:"arm-right-anchor",RIGHT_FOOT:"foot-right-anchor",RIGHT_HAND:"hand-right-anchor",RIGHT_ITEM:"hand-right-anchor",RIGHT_LEG:"leg-right-anchor",TORSO:"torso-anchor"};class nP extends F7{_cosmeticHiddenSlots;constructor(Z){super({modelUri:k80,modelLoopedAnimations:["idle_lower","idle_upper"],modelHiddenNodes:["hair-"],modelShownNodes:["hair-0003"],...Z});if(this._cosmeticHiddenSlots=Z.cosmeticHiddenSlots??[],!Z.controller)this.setController(new b1)}get cosmeticHiddenSlots(){return this._cosmeticHiddenSlots}spawn(Z,J,X){super.spawn(Z,J,X),this.player.cosmetics.then(($)=>{if(!$||!this.modelUri)return;let Y=this.modelShownNodes.values().toArray().filter((W)=>!W.includes("hair-"));if(!($.equippedItems.some((W)=>W.item.flags.includes("HIDES_HAIR"))&&!this._cosmeticHiddenSlots.includes("ALL")&&!this._cosmeticHiddenSlots.includes("HEAD")))Y.push(`hair-${String($.hairStyle).padStart(4,"0")}`);if(this.setModelShownNodes(Y),this.modelUri===k80)this.setModelTextureUri($.skinTextureUri);if(this._cosmeticHiddenSlots.includes("ALL"))return;let K=[];for(let W of $.equippedItems){let{item:G,slot:z}=W;if(this._cosmeticHiddenSlots.includes(z))continue;let v=nI1[z];if(!v||!j6.instance.modelHasNode(this.modelUri,v))continue;if(G.flags.includes("REPLACES_LIMB")){let V=v.split("-").slice(0,-1).join("-");K.push(`${V}-clothing`,`${V}-geometry`)}new j8({modelUri:G.modelUrl,modelPreferredShape:"none",parent:this,parentNodeName:v}).spawn(Z,{x:0,y:0,z:0})}if(K.length>0)this.setModelHiddenNodes([...this.modelHiddenNodes.values().toArray(),...K])}).catch(($)=>p.warning(`DefaultPlayerEntity.spawn(): Failed to get player cosmetics: ${$}`))}}class uz{_activeEntities=new Set;_entities=new Map;_nextEntityId=1;_world;constructor(Z){this._world=Z}get entityCount(){return this._entities.size}get world(){return this._world}registerEntity(Z){if(Z.id!==void 0)p.fatalError(`EntityManager.registerEntity(): Entity ${Z.name} is already assigned the id ${Z.id}!`);let J=this._nextEntityId;if(this._entities.set(J,Z),this._nextEntityId++,!Z.isEnvironmental)this._activeEntities.add(Z);return J}unregisterEntity(Z){if(Z.id===void 0)return p.error(`EntityManager.unregisterEntity(): Entity ${Z.name} is not assigned an id!`);if(this._entities.delete(Z.id),!Z.isEnvironmental)this._activeEntities.delete(Z)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let Z=[];return this._entities.forEach((J)=>{if(J instanceof F7)Z.push(J)}),Z}getPlayerEntitiesByPlayer(Z){let J=[];return this._entities.forEach((X)=>{if(X instanceof F7&&X.player===Z)J.push(X)}),J}getEntity(Z){return this._entities.get(Z)}getEntitiesByTag(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag===Z)J.push(X)}),J}getEntitiesByTagSubstring(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag?.includes(Z))J.push(X)}),J}getEntityChildren(Z){let J=[];return this._entities.forEach((X)=>{if(X.parent===Z)J.push(X)}),J}tickEntities(Z){for(let J of this._activeEntities)J.tick(Z)}checkAndEmitUpdates(){for(let Z of this._activeEntities)Z.checkAndEmitUpdates()}}import{gzipSync as dJ6}from"zlib";var n6=t(b60(),1),Cb6=n6.default.v1,fb6=n6.default.v1ToV6,kb6=n6.default.v3,h60=n6.default.v4,Eb6=n6.default.v5,Ib6=n6.default.v6,_b6=n6.default.v6ToV1,bb6=n6.default.v7,hb6=n6.default.NIL,Sb6=n6.default.MAX,Ab6=n6.default.version,mb6=n6.default.validate,ub6=n6.default.stringify,lb6=n6.default.parse;var XT;try{XT=new TextDecoder}catch(Z){}var X0,g5,m=0;var KT=[],XY=KT,pz=0,f1={},Y1,bZ,i5=0,P4=0,S8,hZ,L5=[],e0,S60={useRecords:!1,mapsAsObjects:!0};class Xc{}var WT=new Xc;WT.name="MessagePack 0xC1";var YX=!1,g60=2,$T,YT,QT;try{new Function("")}catch(Z){g60=1/0}class SZ{constructor(Z){if(Z){if(Z.useRecords===!1&&Z.mapsAsObjects===void 0)Z.mapsAsObjects=!0;if(Z.sequential&&Z.trusted!==!1){if(Z.trusted=!0,!Z.structures&&Z.useRecords!=!1){if(Z.structures=[],!Z.maxSharedStructures)Z.maxSharedStructures=0}}if(Z.structures)Z.structures.sharedLength=Z.structures.length;else if(Z.getStructures)(Z.structures=[]).uninitialized=!0,Z.structures.sharedLength=0;if(Z.int64AsNumber)Z.int64AsType="number"}Object.assign(this,Z)}unpack(Z,J){if(X0)return X50(()=>{return Jc(),this?this.unpack(Z,J):SZ.prototype.unpack.call(S60,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")g5=J.end||Z.length,m=J.start||0;else m=0,g5=J>-1?J:Z.length;pz=0,P4=0,bZ=null,XY=KT,S8=null,X0=Z;try{e0=Z.dataView||(Z.dataView=new DataView(Z.buffer,Z.byteOffset,Z.byteLength))}catch(X){if(X0=null,Z instanceof Uint8Array)throw X;throw new Error("Source must be a Uint8Array or Buffer but was a "+(Z&&typeof Z=="object"?Z.constructor.name:typeof Z))}if(this instanceof SZ){if(f1=this,this.structures)return Y1=this.structures,ew(J);else if(!Y1||Y1.length>0)Y1=[]}else if(f1=S60,!Y1||Y1.length>0)Y1=[];return ew(J)}unpackMultiple(Z,J){let X,$=0;try{YX=!0;let Y=Z.length,Q=this?this.unpack(Z,Y):$c.unpack(Z,Y);if(J){if(J(Q,$,m)===!1)return;while(m<Y)if($=m,J(ew(),$,m)===!1)return}else{X=[Q];while(m<Y)$=m,X.push(ew());return X}}catch(Y){throw Y.lastPosition=$,Y.values=X,Y}finally{YX=!1,Jc()}}_mergeStructures(Z,J){if(YT)Z=YT.call(this,Z);if(Z=Z||[],Object.isFrozen(Z))Z=Z.map((X)=>X.slice(0));for(let X=0,$=Z.length;X<$;X++){let Y=Z[X];if(Y){if(Y.isShared=!0,X>=32)Y.highByte=X-32>>5}}Z.sharedLength=Z.length;for(let X in J||[])if(X>=0){let $=Z[X],Y=J[X];if(Y){if($)(Z.restoreStructures||(Z.restoreStructures=[]))[X]=$;Z[X]=Y}}return this.structures=Z}decode(Z,J){return this.unpack(Z,J)}}function ew(Z){try{if(!f1.trusted&&!YX){let X=Y1.sharedLength||0;if(X<Y1.length)Y1.length=X}let J;if(f1.randomAccessStructure&&X0[m]<64&&X0[m]>=32&&$T){if(J=$T(X0,m,g5,f1),X0=null,!(Z&&Z.lazy)&&J)J=J.toJSON();m=g5}else J=L8();if(S8)m=S8.postBundlePosition,S8=null;if(YX)Y1.restoreStructures=null;if(m==g5){if(Y1&&Y1.restoreStructures)A60();if(Y1=null,X0=null,hZ)hZ=null}else if(m>g5)throw new Error("Unexpected end of MessagePack data");else if(!YX){let X;try{X=JSON.stringify(J,($,Y)=>typeof Y==="bigint"?`${Y}n`:Y).slice(0,100)}catch($){X="(JSON view not available "+$+")"}throw new Error("Data read, but end of buffer not reached "+X)}return J}catch(J){if(Y1&&Y1.restoreStructures)A60();if(Jc(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||m>g5)J.incomplete=!0;throw J}}function A60(){for(let Z in Y1.restoreStructures)Y1[Z]=Y1.restoreStructures[Z];Y1.restoreStructures=null}function L8(){let Z=X0[m++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=Y1[Z&63]||f1.getStructures&&d60()[Z&63];if(J){if(!J.read)J.read=GT(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,f1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let $=Z50();if($==="__proto__")$="__proto_";J[$]=L8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(L8(),L8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=L8();if(f1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(P4>=m)return bZ.slice(m-i5,(m+=J)-i5);if(P4==0&&g5<140){let X=J<16?zT(J):e60(J);if(X!=null)return X}return Zc(J)}else{let J;switch(Z){case 192:return null;case 193:if(S8)if(J=L8(),J>0)return S8[1].slice(S8.position1,S8.position1+=J);else return S8[0].slice(S8.position0,S8.position0-=J);return WT;case 194:return!1;case 195:return!0;case 196:if(J=X0[m++],J===void 0)throw new Error("Unexpected end of buffer");return JT(J);case 197:return J=e0.getUint16(m),m+=2,JT(J);case 198:return J=e0.getUint32(m),m+=4,JT(J);case 199:return JY(X0[m++]);case 200:return J=e0.getUint16(m),m+=2,JY(J);case 201:return J=e0.getUint32(m),m+=4,JY(J);case 202:if(J=e0.getFloat32(m),f1.useFloat32>2){let X=YY[(X0[m]&127)<<1|X0[m+1]>>7];return m+=4,(X*J+(J>0?0.5:-0.5)>>0)/X}return m+=4,J;case 203:return J=e0.getFloat64(m),m+=8,J;case 204:return X0[m++];case 205:return J=e0.getUint16(m),m+=2,J;case 206:return J=e0.getUint32(m),m+=4,J;case 207:if(f1.int64AsType==="number")J=e0.getUint32(m)*4294967296,J+=e0.getUint32(m+4);else if(f1.int64AsType==="string")J=e0.getBigUint64(m).toString();else if(f1.int64AsType==="auto"){if(J=e0.getBigUint64(m),J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=e0.getBigUint64(m);return m+=8,J;case 208:return e0.getInt8(m++);case 209:return J=e0.getInt16(m),m+=2,J;case 210:return J=e0.getInt32(m),m+=4,J;case 211:if(f1.int64AsType==="number")J=e0.getInt32(m)*4294967296,J+=e0.getUint32(m+4);else if(f1.int64AsType==="string")J=e0.getBigInt64(m).toString();else if(f1.int64AsType==="auto"){if(J=e0.getBigInt64(m),J>=BigInt(-2)<<BigInt(52)&&J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=e0.getBigInt64(m);return m+=8,J;case 212:if(J=X0[m++],J==114)return i60(X0[m++]&63);else{let X=L5[J];if(X)if(X.read)return m++,X.read(L8());else if(X.noBuffer)return m++,X();else return X(X0.subarray(m,++m));else throw new Error("Unknown extension "+J)}case 213:if(J=X0[m],J==114)return m++,i60(X0[m++]&63,X0[m++]);else return JY(2);case 214:return JY(4);case 215:return JY(8);case 216:return JY(16);case 217:if(J=X0[m++],P4>=m)return bZ.slice(m-i5,(m+=J)-i5);return a60(J);case 218:if(J=e0.getUint16(m),m+=2,P4>=m)return bZ.slice(m-i5,(m+=J)-i5);return n60(J);case 219:if(J=e0.getUint32(m),m+=4,P4>=m)return bZ.slice(m-i5,(m+=J)-i5);return s60(J);case 220:return J=e0.getUint16(m),m+=2,u60(J);case 221:return J=e0.getUint32(m),m+=4,u60(J);case 222:return J=e0.getUint16(m),m+=2,l60(J);case 223:return J=e0.getUint32(m),m+=4,l60(J);default:if(Z>=224)return Z-256;if(Z===void 0){let X=new Error("Unexpected end of MessagePack data");throw X.incomplete=!0,X}throw new Error("Unknown MessagePack token "+Z)}}}var Mb1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function GT(Z,J){function X(){if(X.count++>g60){let Y=Z.read=new Function("r","return function(){return "+(f1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":Mb1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(L8);if(Z.highByte===0)Z.read=m60(J,Z.read);return Y()}let $={};for(let Y=0,Q=Z.length;Y<Q;Y++){let K=Z[Y];if(K==="__proto__")K="__proto_";$[K]=L8()}if(f1.freezeData)return Object.freeze($);return $}if(X.count=0,Z.highByte===0)return m60(J,X);return X}var m60=(Z,J)=>{return function(){let X=X0[m++];if(X===0)return J();let $=Z<32?-(Z+(X<<5)):Z+(X<<5),Y=Y1[$]||d60()[$];if(!Y)throw new Error("Record id is not defined for "+$);if(!Y.read)Y.read=GT(Y,Z);return Y.read()}};function d60(){let Z=X50(()=>{return X0=null,f1.getStructures()});return Y1=f1._mergeStructures(Z,Y1)}var Zc=$Y,a60=$Y,n60=$Y,s60=$Y,o60=!1;function r60(Z){o60=!0,Zc=J(1),a60=J(2),n60=J(3),s60=J(5);function J(X){return function $(Y){let Q=XY[pz++];if(Q==null){if(S8)return $Y(Y);let W=X0.byteOffset,G=Z(m-X+W,g5+W,X0.buffer);if(typeof G=="string")Q=G,XY=KT;else if(XY=G,pz=1,P4=1,Q=XY[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=Y)return m+=Y,Q;return bZ=Q,i5=m,P4=m+K,m+=Y,Q.slice(0,Y)}}}function $Y(Z){let J;if(Z<16){if(J=zT(Z))return J}if(Z>64&&XT)return XT.decode(X0.subarray(m,m+=Z));let X=m+Z,$=[];J="";while(m<X){let Y=X0[m++];if((Y&128)===0)$.push(Y);else if((Y&224)===192){let Q=X0[m++]&63;$.push((Y&31)<<6|Q)}else if((Y&240)===224){let Q=X0[m++]&63,K=X0[m++]&63;$.push((Y&31)<<12|Q<<6|K)}else if((Y&248)===240){let Q=X0[m++]&63,K=X0[m++]&63,W=X0[m++]&63,G=(Y&7)<<18|Q<<12|K<<6|W;if(G>65535)G-=65536,$.push(G>>>10&1023|55296),G=56320|G&1023;$.push(G)}else $.push(Y);if($.length>=4096)J+=a8.apply(String,$),$.length=0}if($.length>0)J+=a8.apply(String,$);return J}function t60(Z,J,X){let $=X0;X0=Z,m=J;try{return $Y(X)}finally{X0=$}}function u60(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=L8();if(f1.freezeData)return Object.freeze(J);return J}function l60(Z){if(f1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let $=Z50();if($==="__proto__")$="__proto_";J[$]=L8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(L8(),L8());return J}}var a8=String.fromCharCode;function e60(Z){let J=m,X=new Array(Z);for(let $=0;$<Z;$++){let Y=X0[m++];if((Y&128)>0){m=J;return}X[$]=Y}return a8.apply(String,X)}function zT(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=X0[m++];if((J&128)>1){m-=1;return}return a8(J)}else{let J=X0[m++],X=X0[m++];if((J&128)>0||(X&128)>0){m-=2;return}if(Z<3)return a8(J,X);let $=X0[m++];if(($&128)>0){m-=3;return}return a8(J,X,$)}else{let J=X0[m++],X=X0[m++],$=X0[m++],Y=X0[m++];if((J&128)>0||(X&128)>0||($&128)>0||(Y&128)>0){m-=4;return}if(Z<6)if(Z===4)return a8(J,X,$,Y);else{let Q=X0[m++];if((Q&128)>0){m-=5;return}return a8(J,X,$,Y,Q)}else if(Z<8){let Q=X0[m++],K=X0[m++];if((Q&128)>0||(K&128)>0){m-=6;return}if(Z<7)return a8(J,X,$,Y,Q,K);let W=X0[m++];if((W&128)>0){m-=7;return}return a8(J,X,$,Y,Q,K,W)}else{let Q=X0[m++],K=X0[m++],W=X0[m++],G=X0[m++];if((Q&128)>0||(K&128)>0||(W&128)>0||(G&128)>0){m-=8;return}if(Z<10)if(Z===8)return a8(J,X,$,Y,Q,K,W,G);else{let z=X0[m++];if((z&128)>0){m-=9;return}return a8(J,X,$,Y,Q,K,W,G,z)}else if(Z<12){let z=X0[m++],v=X0[m++];if((z&128)>0||(v&128)>0){m-=10;return}if(Z<11)return a8(J,X,$,Y,Q,K,W,G,z,v);let H=X0[m++];if((H&128)>0){m-=11;return}return a8(J,X,$,Y,Q,K,W,G,z,v,H)}else{let z=X0[m++],v=X0[m++],H=X0[m++],V=X0[m++];if((z&128)>0||(v&128)>0||(H&128)>0||(V&128)>0){m-=12;return}if(Z<14)if(Z===12)return a8(J,X,$,Y,Q,K,W,G,z,v,H,V);else{let q=X0[m++];if((q&128)>0){m-=13;return}return a8(J,X,$,Y,Q,K,W,G,z,v,H,V,q)}else{let q=X0[m++],F=X0[m++];if((q&128)>0||(F&128)>0){m-=14;return}if(Z<15)return a8(J,X,$,Y,Q,K,W,G,z,v,H,V,q,F);let x=X0[m++];if((x&128)>0){m-=15;return}return a8(J,X,$,Y,Q,K,W,G,z,v,H,V,q,F,x)}}}}}function y60(){let Z=X0[m++],J;if(Z<192)J=Z-160;else switch(Z){case 217:J=X0[m++];break;case 218:J=e0.getUint16(m),m+=2;break;case 219:J=e0.getUint32(m),m+=4;break;default:throw new Error("Expected string")}return $Y(J)}function JT(Z){return f1.copyBuffers?Uint8Array.prototype.slice.call(X0,m,m+=Z):X0.subarray(m,m+=Z)}function JY(Z){let J=X0[m++];if(L5[J]){let X;return L5[J](X0.subarray(m,X=m+=Z),($)=>{m=$;try{return L8()}finally{m=X}})}else throw new Error("Unknown extension type "+J)}var p60=new Array(4096);function Z50(){let Z=X0[m++];if(Z>=160&&Z<192){if(Z=Z-160,P4>=m)return bZ.slice(m-i5,(m+=Z)-i5);else if(!(P4==0&&g5<180))return Zc(Z)}else return m--,J50(L8());let J=(Z<<5^(Z>1?e0.getUint16(m):Z>0?X0[m]:0))&4095,X=p60[J],$=m,Y=m+Z-3,Q,K=0;if(X&&X.bytes==Z){while($<Y){if(Q=e0.getUint32($),Q!=X[K++]){$=1879048192;break}$+=4}Y+=3;while($<Y)if(Q=X0[$++],Q!=X[K++]){$=1879048192;break}if($===Y)return m=$,X.string;Y-=3,$=m}X=[],p60[J]=X,X.bytes=Z;while($<Y)Q=e0.getUint32($),X.push(Q),$+=4;Y+=3;while($<Y)Q=X0[$++],X.push(Q);let W=Z<16?zT(Z):e60(Z);if(W!=null)return X.string=W;return X.string=Zc(Z)}function J50(Z){if(typeof Z==="string")return Z;if(typeof Z==="number"||typeof Z==="boolean"||typeof Z==="bigint")return Z.toString();if(Z==null)return Z+"";if(f1.allowArraysInMapKeys&&Array.isArray(Z)&&Z.flat().every((J)=>["string","number","boolean","bigint"].includes(typeof J)))return Z.flat().toString();throw new Error(`Invalid property type for record: ${typeof Z}`)}var i60=(Z,J)=>{let X=L8().map(J50),$=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let Y=Y1[Z];if(Y&&(Y.isShared||YX))(Y1.restoreStructures||(Y1.restoreStructures=[]))[Z]=Y;return Y1[Z]=X,X.read=GT(X,$),X.read()};L5[0]=()=>{};L5[0].noBuffer=!0;L5[66]=(Z)=>{let J=Z.length,X=BigInt(Z[0]&128?Z[0]-256:Z[0]);for(let $=1;$<J;$++)X<<=BigInt(8),X+=BigInt(Z[$]);return X};var Rb1={Error,TypeError,ReferenceError};L5[101]=()=>{let Z=L8();return(Rb1[Z[0]]||Error)(Z[1],{cause:Z[2]})};L5[105]=(Z)=>{if(f1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=e0.getUint32(m-4);if(!hZ)hZ=new Map;let X=X0[m],$;if(X>=144&&X<160||X==220||X==221)$=[];else if(X>=128&&X<144||X==222||X==223)$=new Map;else if((X>=199&&X<=201||X>=212&&X<=216)&&X0[m+1]===115)$=new Set;else $={};let Y={target:$};hZ.set(J,Y);let Q=L8();if(!Y.used)return Y.target=Q;else Object.assign($,Q);if($ instanceof Map)for(let[K,W]of Q.entries())$.set(K,W);if($ instanceof Set)for(let K of Array.from(Q))$.add(K);return $};L5[112]=(Z)=>{if(f1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=e0.getUint32(m-4),X=hZ.get(J);return X.used=!0,X.target};L5[115]=()=>new Set(L8());var vT=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),Nb1=typeof globalThis==="object"?globalThis:window;L5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,$=vT[J];if(!$){if(J===16)return X;if(J===17)return new DataView(X);throw new Error("Could not find typed array for code "+J)}return new Nb1[$](X)};L5[120]=()=>{let Z=L8();return new RegExp(Z[0],Z[1])};var Ob1=[];L5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=m;return m+=J-Z.length,S8=Ob1,S8=[y60(),y60()],S8.position0=0,S8.position1=0,S8.postBundlePosition=m,m=X,L8()};L5[255]=(Z)=>{if(Z.length==4)return new Date((Z[0]*16777216+(Z[1]<<16)+(Z[2]<<8)+Z[3])*1000);else if(Z.length==8)return new Date(((Z[0]<<22)+(Z[1]<<14)+(Z[2]<<6)+(Z[3]>>2))/1e6+((Z[3]&3)*4294967296+Z[4]*16777216+(Z[5]<<16)+(Z[6]<<8)+Z[7])*1000);else if(Z.length==12)return new Date(((Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3])/1e6+((Z[4]&128?-281474976710656:0)+Z[6]*1099511627776+Z[7]*4294967296+Z[8]*16777216+(Z[9]<<16)+(Z[10]<<8)+Z[11])*1000);else return new Date("invalid")};function X50(Z){if(QT)QT();let J=g5,X=m,$=pz,Y=i5,Q=P4,K=bZ,W=XY,G=hZ,z=S8,v=new Uint8Array(X0.slice(0,g5)),H=Y1,V=Y1.slice(0,Y1.length),q=f1,F=YX,x=Z();return g5=J,m=X,pz=$,i5=Y,P4=Q,bZ=K,XY=W,hZ=G,S8=z,X0=v,YX=F,Y1=H,Y1.splice(0,Y1.length,...V),f1=q,e0=new DataView(X0.buffer,X0.byteOffset,X0.byteLength),x}function Jc(){X0=null,hZ=null,Y1=null}var YY=new Array(147);for(let Z=0;Z<256;Z++)YY[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var $c=new SZ({useRecords:!1}),Pb1=$c.unpack,Tb1=$c.unpackMultiple,Cb1=$c.unpack,iz={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fb1=new Float32Array(1),pb6=new Uint8Array(fb1.buffer,0,4);function $50(Z,J,X){$T=Z,YT=J,QT=X}var Qc;try{Qc=new TextEncoder}catch(Z){}var qT,K50,dz=typeof Buffer!=="undefined",Yc=dz?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,W50=dz?Buffer:Uint8Array,Y50=dz?4294967296:2144337920,n,gz,h1,y=0,s6,o1=null,G50,kb1=21760,Eb1=/[\u0080-\uFFFF]/,x7=Symbol("record-id");class QY extends SZ{constructor(Z){super(Z);this.offset=0;let J,X,$,Y,Q,K=W50.prototype.utf8Write?function(f,C){return n.utf8Write(f,C,n.byteLength-C)}:Qc&&Qc.encodeInto?function(f,C){return Qc.encodeInto(f,n.subarray(C)).written}:!1,W=this;if(!Z)Z={};let G=Z&&Z.sequential,z=Z.structures||Z.saveStructures,v=Z.maxSharedStructures;if(v==null)v=z?32:0;if(v>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let H=Z.maxOwnStructures;if(H==null)H=z?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let V=v>32||H+v>64,q=v+64,F=v+H+64;if(F>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],w=0,c=0;this.pack=this.encode=function(f,C){if(!n)n=new Yc(8192),h1=n.dataView||(n.dataView=new DataView(n.buffer,0,8192)),y=0;if(s6=n.length-10,s6-y<2048)n=new Yc(n.length),h1=n.dataView||(n.dataView=new DataView(n.buffer,0,n.length)),s6=n.length-10,y=0;else y=y+7&2147483640;if(X=y,C&mb1)y+=C&255;if(Q=W.structuredClone?new Map:null,W.bundleStrings&&typeof f!=="string")o1=[],o1.size=1/0;else o1=null;if(Y=W.structures,Y){if(Y.uninitialized)Y=W._mergeStructures(W.getStructures());let I=Y.sharedLength||0;if(I>v)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+Y.sharedLength);if(!Y.transitions){Y.transitions=Object.create(null);for(let a=0;a<I;a++){let s=Y[a];if(!s)continue;let Z0,o=Y.transitions;for(let M0=0,R0=s.length;M0<R0;M0++){let m0=s[M0];if(Z0=o[m0],!Z0)Z0=o[m0]=Object.create(null);o=Z0}o[x7]=a+64}this.lastNamedStructuresLength=I}if(!G)Y.nextId=I+64}if($)$=!1;let b;try{if(W.randomAccessStructure&&f&&f.constructor&&f.constructor===Object)h(f);else L(f);let I=o1;if(o1)Q50(X,L,0);if(Q&&Q.idsToInsert){let a=Q.idsToInsert.sort((M0,R0)=>M0.offset>R0.offset?1:-1),s=a.length,Z0=-1;while(I&&s>0){let M0=a[--s].offset+X;if(M0<I.stringsPosition+X&&Z0===-1)Z0=0;if(M0>I.position+X){if(Z0>=0)Z0+=6}else{if(Z0>=0)h1.setUint32(I.position+X,h1.getUint32(I.position+X)+Z0),Z0=-1;I=I.previous,s++}}if(Z0>=0&&I)h1.setUint32(I.position+X,h1.getUint32(I.position+X)+Z0);if(y+=a.length*6,y>s6)O(y);W.offset=y;let o=_b1(n.subarray(X,y),a);return Q=null,o}if(W.offset=y,C&Sb1)return n.start=X,n.end=y,n;return n.subarray(X,y)}catch(I){throw b=I,I}finally{if(Y){if(B(),$&&W.saveStructures){let I=Y.sharedLength||0,a=n.subarray(X,y),s=z50(Y,W);if(!b){if(W.saveStructures(s,s.isCompatible)===!1)return W.pack(f,C);if(W.lastNamedStructuresLength=I,n.length>1073741824)n=null;return a}}}if(n.length>1073741824)n=null;if(C&Ab1)y=X}};let B=()=>{if(c<10)c++;let f=Y.sharedLength||0;if(Y.length>f&&!G)Y.length=f;if(w>1e4){if(Y.transitions=null,c=0,w=0,x.length>0)x=[]}else if(x.length>0&&!G){for(let C=0,b=x.length;C<b;C++)x[C][x7]=0;x=[]}},j=(f)=>{var C=f.length;if(C<16)n[y++]=144|C;else if(C<65536)n[y++]=220,n[y++]=C>>8,n[y++]=C&255;else n[y++]=221,h1.setUint32(y,C),y+=4;for(let b=0;b<C;b++)L(f[b])},L=(f)=>{if(y>s6)n=O(y);var C=typeof f,b;if(C==="string"){let I=f.length;if(o1&&I>=4&&I<4096){if((o1.size+=I)>kb1){let o,M0=(o1[0]?o1[0].length*3+o1[1].length:0)+10;if(y+M0>s6)n=O(y+M0);let R0;if(o1.position)R0=o1,n[y]=200,y+=3,n[y++]=98,o=y-X,y+=4,Q50(X,L,0),h1.setUint16(o+X-3,y-X-o);else n[y++]=214,n[y++]=98,o=y-X,y+=4;o1=["",""],o1.previous=R0,o1.size=0,o1.position=o}let Z0=Eb1.test(f);o1[Z0?0:1]+=f,n[y++]=193,L(Z0?-I:I);return}let a;if(I<32)a=1;else if(I<256)a=2;else if(I<65536)a=3;else a=5;let s=I*3;if(y+s>s6)n=O(y+s);if(I<64||!K){let Z0,o,M0,R0=y+a;for(Z0=0;Z0<I;Z0++)if(o=f.charCodeAt(Z0),o<128)n[R0++]=o;else if(o<2048)n[R0++]=o>>6|192,n[R0++]=o&63|128;else if((o&64512)===55296&&((M0=f.charCodeAt(Z0+1))&64512)===56320)o=65536+((o&1023)<<10)+(M0&1023),Z0++,n[R0++]=o>>18|240,n[R0++]=o>>12&63|128,n[R0++]=o>>6&63|128,n[R0++]=o&63|128;else n[R0++]=o>>12|224,n[R0++]=o>>6&63|128,n[R0++]=o&63|128;b=R0-y-a}else b=K(f,y+a);if(b<32)n[y++]=160|b;else if(b<256){if(a<2)n.copyWithin(y+2,y+1,y+1+b);n[y++]=217,n[y++]=b}else if(b<65536){if(a<3)n.copyWithin(y+3,y+2,y+2+b);n[y++]=218,n[y++]=b>>8,n[y++]=b&255}else{if(a<5)n.copyWithin(y+5,y+3,y+3+b);n[y++]=219,h1.setUint32(y,b),y+=4}y+=b}else if(C==="number")if(f>>>0===f)if(f<32||f<128&&this.useRecords===!1||f<64&&!this.randomAccessStructure)n[y++]=f;else if(f<256)n[y++]=204,n[y++]=f;else if(f<65536)n[y++]=205,n[y++]=f>>8,n[y++]=f&255;else n[y++]=206,h1.setUint32(y,f),y+=4;else if(f>>0===f)if(f>=-32)n[y++]=256+f;else if(f>=-128)n[y++]=208,n[y++]=f+256;else if(f>=-32768)n[y++]=209,h1.setInt16(y,f),y+=2;else n[y++]=210,h1.setInt32(y,f),y+=4;else{let I;if((I=this.useFloat32)>0&&f<4294967296&&f>=-2147483648){n[y++]=202,h1.setFloat32(y,f);let a;if(I<4||(a=f*YY[(n[y]&127)<<1|n[y+1]>>7])>>0===a){y+=4;return}else y--}n[y++]=203,h1.setFloat64(y,f),y+=8}else if(C==="object"||C==="function")if(!f)n[y++]=192;else{if(Q){let a=Q.get(f);if(a){if(!a.id){let s=Q.idsToInsert||(Q.idsToInsert=[]);a.id=s.push(a)}n[y++]=214,n[y++]=112,h1.setUint32(y,a.id),y+=4;return}else Q.set(f,{offset:y-X})}let I=f.constructor;if(I===Object)P(f);else if(I===Array)j(f);else if(I===Map)if(this.mapAsEmptyObject)n[y++]=128;else{if(b=f.size,b<16)n[y++]=128|b;else if(b<65536)n[y++]=222,n[y++]=b>>8,n[y++]=b&255;else n[y++]=223,h1.setUint32(y,b),y+=4;for(let[a,s]of f)L(a),L(s)}else{for(let a=0,s=qT.length;a<s;a++){let Z0=K50[a];if(f instanceof Z0){let o=qT[a];if(o.write){if(o.type)n[y++]=212,n[y++]=o.type,n[y++]=0;let s0=o.write.call(this,f);if(s0===f)if(Array.isArray(f))j(f);else P(f);else L(s0);return}let M0=n,R0=h1,m0=y;n=null;let N1;try{N1=o.pack.call(this,f,(s0)=>{if(n=M0,M0=null,y+=s0,y>s6)O(y);return{target:n,targetView:h1,position:y-s0}},L)}finally{if(M0)n=M0,h1=R0,y=m0,s6=n.length-10}if(N1){if(N1.length+y>s6)O(N1.length+y);y=Ib1(N1,n,y,o.type)}return}}if(Array.isArray(f))j(f);else{if(f.toJSON){let a=f.toJSON();if(a!==f)return L(a)}if(C==="function")return L(this.writeFunction&&this.writeFunction(f));P(f)}}}else if(C==="boolean")n[y++]=f?195:194;else if(C==="bigint"){if(f<9223372036854776000&&f>=-9223372036854776000)n[y++]=211,h1.setBigInt64(y,f);else if(f<18446744073709552000&&f>0)n[y++]=207,h1.setBigUint64(y,f);else if(this.largeBigIntToFloat)n[y++]=203,h1.setFloat64(y,Number(f));else if(this.largeBigIntToString)return L(f.toString());else if((this.useBigIntExtension||this.moreTypes)&&f<BigInt(2)**BigInt(1023)&&f>-(BigInt(2)**BigInt(1023))){n[y++]=199,y++,n[y++]=66;let I=[],a;do{let s=f&BigInt(255);a=(s&BigInt(128))===(f<BigInt(0)?BigInt(128):BigInt(0)),I.push(s),f>>=BigInt(8)}while(!((f===BigInt(0)||f===BigInt(-1))&&a));n[y-2]=I.length;for(let s=I.length;s>0;)n[y++]=Number(I[--s]);return}else throw new RangeError(f+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string");y+=8}else if(C==="undefined")if(this.encodeUndefinedAsNil)n[y++]=192;else n[y++]=212,n[y++]=0,n[y++]=0;else throw new Error("Unknown type: "+C)},R=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(f)=>{let C;if(this.skipValues){C=[];for(let a in f)if((typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(a))&&!this.skipValues.includes(f[a]))C.push(a)}else C=Object.keys(f);let b=C.length;if(b<16)n[y++]=128|b;else if(b<65536)n[y++]=222,n[y++]=b>>8,n[y++]=b&255;else n[y++]=223,h1.setUint32(y,b),y+=4;let I;if(this.coercibleKeyAsNumber)for(let a=0;a<b;a++){I=C[a];let s=Number(I);L(isNaN(s)?I:s),L(f[I])}else for(let a=0;a<b;a++)L(I=C[a]),L(f[I])}:(f)=>{n[y++]=222;let C=y-X;y+=2;let b=0;for(let I in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(I))L(I),L(f[I]),b++;if(b>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');n[C+++X]=b>>8,n[C+X]=b&255},M=this.useRecords===!1?R:Z.progressiveRecords&&!V?(f)=>{let C,b=Y.transitions||(Y.transitions=Object.create(null)),I=y++-X,a;for(let s in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(s)){if(C=b[s],C)b=C;else{let Z0=Object.keys(f),o=b;b=Y.transitions;let M0=0;for(let R0=0,m0=Z0.length;R0<m0;R0++){let N1=Z0[R0];if(C=b[N1],!C)C=b[N1]=Object.create(null),M0++;b=C}if(I+X+1==y)y--,_(b,Z0,M0);else k(b,Z0,I,M0);a=!0,b=o[s]}L(f[s])}if(!a){let s=b[x7];if(s)n[I+X]=s;else k(b,Object.keys(f),I,0)}}:(f)=>{let C,b=Y.transitions||(Y.transitions=Object.create(null)),I=0;for(let s in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(s)){if(C=b[s],!C)C=b[s]=Object.create(null),I++;b=C}let a=b[x7];if(a)if(a>=96&&V)n[y++]=((a-=96)&31)+96,n[y++]=a>>5;else n[y++]=a;else _(b,b.__keys__||Object.keys(f),I);for(let s in f)if(typeof f.hasOwnProperty!=="function"||f.hasOwnProperty(s))L(f[s])},N=typeof this.useRecords=="function"&&this.useRecords,P=N?(f)=>{N(f)?M(f):R(f)}:M,O=(f)=>{let C;if(f>16777216){if(f-X>Y50)throw new Error("Packed buffer would be larger than maximum buffer size");C=Math.min(Y50,Math.round(Math.max((f-X)*(f>67108864?1.25:2),4194304)/4096)*4096)}else C=(Math.max(f-X<<2,n.length-1)>>12)+1<<12;let b=new Yc(C);if(h1=b.dataView||(b.dataView=new DataView(b.buffer,0,C)),f=Math.min(f,n.length),n.copy)n.copy(b,0,X,f);else b.set(n.slice(X,f));return y-=X,X=0,s6=b.length-10,n=b},_=(f,C,b)=>{let I=Y.nextId;if(!I)I=64;if(I<q&&this.shouldShareStructure&&!this.shouldShareStructure(C)){if(I=Y.nextOwnId,!(I<F))I=q;Y.nextOwnId=I+1}else{if(I>=F)I=q;Y.nextId=I+1}let a=C.highByte=I>=96&&V?I-96>>5:-1;if(f[x7]=I,f.__keys__=C,Y[I-64]=C,I<q)if(C.isShared=!0,Y.sharedLength=I-63,$=!0,a>=0)n[y++]=(I&31)+96,n[y++]=a;else n[y++]=I;else{if(a>=0)n[y++]=213,n[y++]=114,n[y++]=(I&31)+96,n[y++]=a;else n[y++]=212,n[y++]=114,n[y++]=I;if(b)w+=c*b;if(x.length>=H)x.shift()[x7]=0;x.push(f),L(C)}},k=(f,C,b,I)=>{let a=n,s=y,Z0=s6,o=X;if(n=gz,y=0,X=0,!n)gz=n=new Yc(8192);s6=n.length-10,_(f,C,I),gz=n;let M0=y;if(n=a,y=s,s6=Z0,X=o,M0>1){let R0=y+M0-1;if(R0>s6)O(R0);let m0=b+X;n.copyWithin(m0+M0,m0+1,y),n.set(gz.slice(0,M0),m0),y=R0}else n[b+X]=gz[0]},h=(f)=>{let C=G50(f,n,X,y,Y,O,(b,I,a)=>{if(a)return $=!0;y=I;let s=n;if(L(b),B(),s!==n)return{position:y,targetView:h1,target:n};return y},this);if(C===0)return P(f);y=C}}useBuffer(Z){n=Z,n.dataView||(n.dataView=new DataView(n.buffer,n.byteOffset,n.byteLength)),y=0}set position(Z){y=Z}get position(){return y}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}K50=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Xc];qT=[{pack(Z,J,X){let $=Z.getTime()/1000;if((this.useTimestamp32||Z.getMilliseconds()===0)&&$>=0&&$<4294967296){let{target:Y,targetView:Q,position:K}=J(6);Y[K++]=214,Y[K++]=255,Q.setUint32(K,$)}else if($>0&&$<4294967296){let{target:Y,targetView:Q,position:K}=J(10);Y[K++]=215,Y[K++]=255,Q.setUint32(K,Z.getMilliseconds()*4000000+($/1000/4294967296>>0)),Q.setUint32(K+4,$)}else if(isNaN($)){if(this.onInvalidDate)return J(0),X(this.onInvalidDate());let{target:Y,targetView:Q,position:K}=J(3);Y[K++]=212,Y[K++]=255,Y[K++]=255}else{let{target:Y,targetView:Q,position:K}=J(15);Y[K++]=199,Y[K++]=12,Y[K++]=255,Q.setUint32(K,Z.getMilliseconds()*1e6),Q.setBigInt64(K+4,BigInt(Math.floor($)))}}},{pack(Z,J,X){if(this.setAsEmptyObject)return J(0),X({});let $=Array.from(Z),{target:Y,position:Q}=J(this.moreTypes?3:0);if(this.moreTypes)Y[Q++]=212,Y[Q++]=115,Y[Q++]=0;X($)}},{pack(Z,J,X){let{target:$,position:Y}=J(this.moreTypes?3:0);if(this.moreTypes)$[Y++]=212,$[Y++]=101,$[Y++]=0;X([Z.name,Z.message,Z.cause])}},{pack(Z,J,X){let{target:$,position:Y}=J(this.moreTypes?3:0);if(this.moreTypes)$[Y++]=212,$[Y++]=120,$[Y++]=0;X([Z.source,Z.flags])}},{pack(Z,J){if(this.moreTypes)VT(Z,16,J);else HT(dz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==W50&&this.moreTypes)VT(Z,vT.indexOf(X.name),J);else HT(Z,J)}},{pack(Z,J){if(this.moreTypes)VT(Z,17,J);else HT(dz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:$}=J(1);X[$]=193}}];function VT(Z,J,X,$){let Y=Z.byteLength;if(Y+1<256){var{target:Q,position:K}=X(4+Y);Q[K++]=199,Q[K++]=Y+1}else if(Y+1<65536){var{target:Q,position:K}=X(5+Y);Q[K++]=200,Q[K++]=Y+1>>8,Q[K++]=Y+1&255}else{var{target:Q,position:K,targetView:W}=X(7+Y);Q[K++]=201,W.setUint32(K,Y+1),K+=4}if(Q[K++]=116,Q[K++]=J,!Z.buffer)Z=new Uint8Array(Z);Q.set(new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),K)}function HT(Z,J){let X=Z.byteLength;var $,Y;if(X<256){var{target:$,position:Y}=J(X+2);$[Y++]=196,$[Y++]=X}else if(X<65536){var{target:$,position:Y}=J(X+3);$[Y++]=197,$[Y++]=X>>8,$[Y++]=X&255}else{var{target:$,position:Y,targetView:Q}=J(X+5);$[Y++]=198,Q.setUint32(Y,X),Y+=4}$.set(Z,Y)}function Ib1(Z,J,X,$){let Y=Z.length;switch(Y){case 1:J[X++]=212;break;case 2:J[X++]=213;break;case 4:J[X++]=214;break;case 8:J[X++]=215;break;case 16:J[X++]=216;break;default:if(Y<256)J[X++]=199,J[X++]=Y;else if(Y<65536)J[X++]=200,J[X++]=Y>>8,J[X++]=Y&255;else J[X++]=201,J[X++]=Y>>24,J[X++]=Y>>16&255,J[X++]=Y>>8&255,J[X++]=Y&255}return J[X++]=$,J.set(Z,X),X+=Y,X}function _b1(Z,J){let X,$=J.length*6,Y=Z.length-$;while(X=J.pop()){let{offset:Q,id:K}=X;Z.copyWithin(Q+$,Q,Y),$-=6;let W=Q+$;Z[W++]=214,Z[W++]=105,Z[W++]=K>>24,Z[W++]=K>>16&255,Z[W++]=K>>8&255,Z[W++]=K&255,Y=Q}return Z}function Q50(Z,J,X){if(o1.length>0){h1.setUint32(o1.position+Z,y+X-o1.position-Z),o1.stringsPosition=y-Z;let $=o1;o1=null,J($[0]),J($[1])}}function z50(Z,J){return Z.isCompatible=(X)=>{let $=!X||(J.lastNamedStructuresLength||0)===X.length;if(!$)J._mergeStructures(X);return $},Z}function v50(Z,J){G50=Z,z50=J}var V50=new QY({useRecords:!1}),bb1=V50.pack,hb1=V50.pack;var Sb1=512,Ab1=1024,mb1=2048;var FT=3,aK=0,az=2,Kc=1,wT=16,q50=["num","object","string","ascii"];q50[wT]="date";var lb1=[!1,!0,!0,!1,!1,!0,!0,!1],F50;try{new Function(""),F50=!0}catch(Z){}var KY,yb1=typeof Buffer!=="undefined",Wc,w7;try{Wc=new TextEncoder}catch(Z){}var pb1=yb1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:Wc&&Wc.encodeInto?function(Z,J,X){return Wc.encodeInto(J,Z.subarray(X)).written}:!1,tb6=Symbol("type"),eb6=Symbol("parent");v50(x50,nb1);function x50(Z,J,X,$,Y,Q,K,W){let G=W.typedStructs||(W.typedStructs=[]),z=J.dataView,v=(G.lastStringStart||100)+$,H=J.length-10,V=$;if($>H)J=Q($),z=J.dataView,$-=X,V-=X,v-=X,X=0,H=J.length-10;let q,F=v,x=G.transitions||(G.transitions=Object.create(null)),w=G.nextId||G.length,c=w<15?1:w<240?2:w<61440?3:w<15728640?4:0;if(c===0)return 0;$+=c;let B=[],j,L=0;for(let M in Z){let N=Z[M],P=x[M];if(!P)x[M]=P={key:M,parent:x,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if($>H)J=Q($),z=J.dataView,$-=X,V-=X,v-=X,F-=X,X=0,H=J.length-10;switch(typeof N){case"number":let O=N;if(w<200||!P.num64){if(O>>0===O&&O<536870912&&O>-520093696){if(O<246&&O>=0&&(P.num8&&!(w>200&&P.num32)||O<32&&!P.num32))x=P.num8||D5(P,aK,1),J[$++]=O;else x=P.num32||D5(P,aK,4),z.setUint32($,O,!0),$+=4;break}else if(O<4294967296&&O>=-2147483648){if(z.setFloat32($,O,!0),lb1[J[$+3]>>>5]){let f;if((f=O*YY[(J[$+3]&127)<<1|J[$+2]>>7])>>0===f){x=P.num32||D5(P,aK,4),$+=4;break}}}}x=P.num64||D5(P,aK,8),z.setFloat64($,O,!0),$+=8;break;case"string":let _=N.length;if(q=F-v,(_<<2)+F>H)J=Q((_<<2)+F),z=J.dataView,$-=X,V-=X,v-=X,F-=X,X=0,H=J.length-10;if(_>65280+q>>2){B.push(M,N,$-V);break}let k,h=F;if(_<64){let f,C,b;for(f=0;f<_;f++)if(C=N.charCodeAt(f),C<128)J[F++]=C;else if(C<2048)k=!0,J[F++]=C>>6|192,J[F++]=C&63|128;else if((C&64512)===55296&&((b=N.charCodeAt(f+1))&64512)===56320)k=!0,C=65536+((C&1023)<<10)+(b&1023),f++,J[F++]=C>>18|240,J[F++]=C>>12&63|128,J[F++]=C>>6&63|128,J[F++]=C&63|128;else k=!0,J[F++]=C>>12|224,J[F++]=C>>6&63|128,J[F++]=C&63|128}else F+=pb1(J,N,F),k=F-h>_;if(q<160||q<246&&(P.ascii8||P.string8)){if(k){if(!(x=P.string8))if(G.length>10&&(x=P.ascii8))x.__type=az,P.ascii8=null,P.string8=x,K(null,0,!0);else x=D5(P,az,1)}else if(q===0&&!j){j=!0,x=P.ascii0||D5(P,FT,0);break}else if(!(x=P.ascii8)&&!(G.length>10&&(x=P.string8)))x=D5(P,FT,1);J[$++]=q}else x=P.string16||D5(P,az,2),z.setUint16($,q,!0),$+=2;break;case"object":if(N){if(N.constructor===Date)x=P.date64||D5(P,wT,8),z.setFloat64($,N.getTime(),!0),$+=8;else B.push(M,N,L);break}else if(P=H50(P,$,z,-10),P)x=P,$=KY;else B.push(M,N,L);break;case"boolean":x=P.num8||P.ascii8||D5(P,aK,1),J[$++]=N?249:248;break;case"undefined":if(P=H50(P,$,z,-9),P)x=P,$=KY;else B.push(M,N,L);break;default:B.push(M,N,L)}L++}for(let M=0,N=B.length;M<N;){let P=B[M++],O=B[M++],_=B[M++],k=x[P];if(!k)x[P]=k={key:P,parent:x,enumerationOffset:_-L,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let h;if(O){let f;if(q=F-v,q<65280)if(x=k.object16,x)f=2;else if(x=k.object32)f=4;else x=D5(k,Kc,2),f=2;else x=k.object32||D5(k,Kc,4),f=4;if(h=K(O,F),typeof h==="object")F=h.position,z=h.targetView,J=h.target,v-=X,$-=X,V-=X,X=0;else F=h;if(f===2)z.setUint16($,q,!0),$+=2;else z.setUint32($,q,!0),$+=4}else x=k.object16||D5(k,Kc,2),z.setInt16($,O===null?-10:-9,!0),$+=2;L++}let R=x[x7];if(R==null){R=W.typedStructs.length;let M=[],N=x,P,O;while((O=N.__type)!==void 0){let _=N.__size;N=N.__parent,P=N.key;let k=[O,_,P];if(N.enumerationOffset)k.push(N.enumerationOffset);M.push(k),N=N.parent}M.reverse(),x[x7]=R,W.typedStructs[R]=M,K(null,0,!0)}switch(c){case 1:if(R>=16)return 0;J[V]=R+32;break;case 2:if(R>=256)return 0;J[V]=56,J[V+1]=R;break;case 3:if(R>=65536)return 0;J[V]=57,z.setUint16(V+1,R,!0);break;case 4:if(R>=16777216)return 0;z.setUint32(V,(R<<8)+58,!0);break}if($<v){if(v===F)return $;J.copyWithin($,v,F),F+=$-v,G.lastStringStart=$-V}else if($>v){if(v===F)return $;return G.lastStringStart=$-V,x50(Z,J,X,V,Y,Q,K,W)}return F}function H50(Z,J,X,$){let Y;if(Y=Z.ascii8||Z.num8)return X.setInt8(J,$,!0),KY=J+1,Y;if(Y=Z.string16||Z.object16)return X.setInt16(J,$,!0),KY=J+2,Y;if(Y=Z.num32)return X.setUint32(J,3758096640+$,!0),KY=J+4,Y;if(Y=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,$),KY=J+8,Y;KY=J;return}function D5(Z,J,X){let $=q50[J]+(X<<3),Y=Z[$]||(Z[$]=Object.create(null));return Y.__type=J,Y.__size=X,Y.__parent=Z,Y}function ib1(Z){if(!(Z instanceof Map))return Z;let J=Z.get("typed")||[];if(Object.isFrozen(J))J=J.map((Y)=>Y.slice(0));let X=Z.get("named"),$=Object.create(null);for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y],W=$;for(let[G,z,v]of K){let H=W[v];if(!H)W[v]=H={key:v,parent:W,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};W=D5(H,G,z)}W[x7]=Y}return J.transitions=$,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var xT=Symbol.for("source");function gb1(Z,J,X,$){let Y=Z[J++]-32;if(Y>=24)switch(Y){case 24:Y=Z[J++];break;case 25:Y=Z[J++]+(Z[J++]<<8);break;case 26:Y=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16);break;case 27:Y=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16)+(Z[J++]<<24);break}let Q=$.typedStructs&&$.typedStructs[Y];if(!Q){if(Z=Uint8Array.prototype.slice.call(Z,J,X),X-=J,J=0,!$.getStructures)throw new Error(`Reference to shared structure ${Y} without getStructures method`);if($._mergeStructures($.getStructures()),!$.typedStructs)throw new Error("Could not find any shared typed structures");if($.lastTypedStructuresLength=$.typedStructs.length,Q=$.typedStructs[Y],!Q)throw new Error("Could not find typed structure "+Y)}var{construct:K,fullConstruct:W}=Q;if(!K){K=Q.construct=function q(){},W=Q.fullConstruct=function q(){},W.prototype=$.structPrototype??{};var G=K.prototype=$.structPrototype?Object.create($.structPrototype):{};let v=[],H=0,V;for(let q=0,F=Q.length;q<F;q++){let x=Q[q],[w,c,B,j]=x;if(B==="__proto__")B="__proto_";let L={key:B,offset:H};if(j)v.splice(q+j,0,L);else v.push(L);let R;switch(c){case 0:R=()=>0;break;case 1:R=(N,P)=>{let O=N.bytes[P+L.offset];return O>=246?dK(O):O};break;case 2:R=(N,P)=>{let O=N.bytes,k=(O.dataView||(O.dataView=new DataView(O.buffer,O.byteOffset,O.byteLength))).getUint16(P+L.offset,!0);return k>=65280?dK(k&255):k};break;case 4:R=(N,P)=>{let O=N.bytes,k=(O.dataView||(O.dataView=new DataView(O.buffer,O.byteOffset,O.byteLength))).getUint32(P+L.offset,!0);return k>=4294967040?dK(k&255):k};break}L.getRef=R,H+=c;let M;switch(w){case FT:if(V&&!V.next)V.next=L;V=L,L.multiGetCount=0,M=function(N){let{bytes:P,position:O}=N,_=H+O,k=R(N,O);if(typeof k!=="number")return k;let h,f=L.next;while(f){if(h=f.getRef(N,O),typeof h==="number")break;else h=null;f=f.next}if(h==null)h=N.bytesEnd-_;if(N.srcString)return N.srcString.slice(k,h);return t60(P,k+_,h-k)};break;case az:case Kc:if(V&&!V.next)V.next=L;V=L,M=function(N){let P=N.position,O=H+P,_=R(N,P);if(typeof _!=="number")return _;let k=N.bytes,h,f=L.next;while(f){if(h=f.getRef(N,P),typeof h==="number")break;else h=null;f=f.next}if(h==null)h=N.bytesEnd-O;if(w===az)return k.toString("utf8",_+O,h+O);else{w7=N;try{return $.unpack(k,{start:_+O,end:h+O})}finally{w7=null}}};break;case aK:switch(c){case 4:M=function(N){let P=N.bytes,O=P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength)),_=N.position+L.offset,k=O.getInt32(_,!0);if(k<536870912){if(k>-520093696)return k;if(k>-536870912)return dK(k&255)}let h=O.getFloat32(_,!0),f=YY[(P[_+3]&127)<<1|P[_+2]>>7];return(f*h+(h>0?0.5:-0.5)>>0)/f};break;case 8:M=function(N){let P=N.bytes,_=(P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength))).getFloat64(N.position+L.offset,!0);if(isNaN(_)){let k=P[N.position+L.offset];if(k>=246)return dK(k)}return _};break;case 1:M=function(N){let O=N.bytes[N.position+L.offset];return O<246?O:dK(O)};break}break;case wT:M=function(N){let P=N.bytes,O=P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength));return new Date(O.getFloat64(N.position+L.offset,!0))};break}L.get=M}if(F50){let q=[],F=[],x=0,w;for(let B of v){if($.alwaysLazyProperty&&$.alwaysLazyProperty(B.key)){w=!0;continue}Object.defineProperty(G,B.key,{get:db1(B.get),enumerable:!0});let j="v"+x++;F.push(j),q.push("o["+JSON.stringify(B.key)+"]="+j+"(s)")}if(w)q.push("__proto__:this");let c=new Function(...F,"var c=this;return function(s){var o=new c();"+q.join(";")+";return o;}").apply(W,v.map((B)=>B.get));Object.defineProperty(G,"toJSON",{value(B){return c.call(this,this[xT])}})}else Object.defineProperty(G,"toJSON",{value(q){let F={};for(let x=0,w=v.length;x<w;x++){let c=v[x].key;F[c]=this[c]}return F}})}var z=new K;return z[xT]={bytes:Z,position:J,srcString:"",bytesEnd:X},z}function dK(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function db1(Z){return function(){return Z(this[xT])}}function ab1(){if(w7)w7.bytes=Uint8Array.prototype.slice.call(w7.bytes,w7.position,w7.bytesEnd),w7.position=0,w7.bytesEnd=w7.bytes.length}function nb1(Z,J){if(J.typedStructs){let $=new Map;$.set("named",Z),$.set("typed",J.typedStructs),Z=$}let X=J.lastTypedStructuresLength||0;return Z.isCompatible=($)=>{let Y=!0;if($ instanceof Map){if(($.get("named")||[]).length!==(J.lastNamedStructuresLength||0))Y=!1;if(($.get("typed")||[]).length!==X)Y=!1}else if($ instanceof Array||Array.isArray($)){if($.length!==(J.lastNamedStructuresLength||0))Y=!1}if(!Y)J._mergeStructures($);return Y},J.lastTypedStructuresLength=J.typedStructs&&J.typedStructs.length,Z}$50(gb1,ib1,ab1);var rb1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!rb1){let Z;try{if(Z=g("msgpackr-extract"),Z)r60(Z.extractStrings)}catch(J){}}var WU=t(WY0(),1);import Ba1 from"http";import ja1 from"https";import KU from"fs";import La1 from"path";import Da1 from"url";var GY0=`-----BEGIN CERTIFICATE-----
406
406
  MIIDRjCCAi6gAwIBAgIFOTEzNTIwDQYJKoZIhvcNAQELBQAwWDEQMA4GA1UEAxMH
407
407
  SFlUT1BJQTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNV
408
408
  BAcTB1NlYXR0bGUxEDAOBgNVBAoTB0hZVE9QSUEwHhcNMjQxMTEzMjIyMjEwWhcN
@@ -447,7 +447,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
447
447
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
448
448
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
449
449
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
450
- -----END RSA PRIVATE KEY-----`;var Ef=process.env.PORT??8080,If="0.10.11",_f;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(_f||={});class F3 extends B0{static instance=new F3;_webserver=WU.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:If,runtime:"node"})}),this._webserver.use(WU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(WU.default.static(La1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ba1.createServer(this._webserver):ja1.createServer({key:KU.existsSync("assets/certs/localhost.key")?KU.readFileSync("assets/certs/localhost.key"):zY0,cert:KU.existsSync("assets/certs/localhost.crt")?KU.readFileSync("assets/certs/localhost.crt"):GY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Ef,this._onStarted),console.info(`WebServer.start(): Server running on port ${Ef}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Da1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&M7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await O4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
450
+ -----END RSA PRIVATE KEY-----`;var Ef=process.env.PORT??8080,If="0.10.12-prerelease-2",_f;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(_f||={});class F3 extends B0{static instance=new F3;_webserver=WU.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:If,runtime:"node"})}),this._webserver.use(WU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(WU.default.static(La1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ba1.createServer(this._webserver):ja1.createServer({key:KU.existsSync("assets/certs/localhost.key")?KU.readFileSync("assets/certs/localhost.key"):zY0,cert:KU.existsSync("assets/certs/localhost.crt")?KU.readFileSync("assets/certs/localhost.crt"):GY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Ef,this._onStarted),console.info(`WebServer.start(): Server running on port ${Ef}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Da1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&M7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await O4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
451
451
  Content-Type: text/plain\r
452
452
  Content-Length: ${W.length}\r
453
453
  Connection: close\r