hytopia 0.3.24 → 0.3.26

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
@@ -247,6 +247,29 @@ function initEditorMcp(editorName, editorFlag) {
247
247
  function packageProject() {
248
248
  const sourceDir = process.cwd();
249
249
  const projectName = path.basename(sourceDir);
250
+ const packageJsonPath = path.join(sourceDir, 'package.json');
251
+
252
+ // Check if package.json exists
253
+ if (!fs.existsSync(packageJsonPath)) {
254
+ console.error('❌ Error: package.json not found. This directory does not appear to be a HYTOPIA project.');
255
+ console.error(' Please run this command in a valid HYTOPIA project directory.');
256
+ return;
257
+ }
258
+
259
+ // Check if package.json contains "hytopia"
260
+ try {
261
+ const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');
262
+ if (!packageJsonContent.includes('hytopia')) {
263
+ console.error('❌ Error: This directory does not appear to be a HYTOPIA project.');
264
+ console.error(' The package.json file does not contain a reference to HYTOPIA.');
265
+ return;
266
+ }
267
+ } catch (err) {
268
+ console.error('❌ Error: Could not read package.json file:', err.message);
269
+ return;
270
+ }
271
+
272
+ // Prepare to package
250
273
  const outputFile = path.join(sourceDir, `${projectName}.zip`);
251
274
 
252
275
  console.log(`📦 Packaging project "${projectName}"...`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -382,6 +382,6 @@ Instead, \`yield\` should either be called with a value, or not be called at all
382
382
  `),Z.write(`Content-Length: ${$.length}\r
383
383
  `),Z.write(`Connection: close\r
384
384
  `),Z.write(`\r
385
- `),Z.write($),Z.end();return}this.emitWithGlobal("WEBSERVER.UPGRADE",{req:J,socket:Z,head:Y})};_onError=(J)=>{this.emitWithGlobal("WEBSERVER.ERROR",{error:J})};_onStopped=()=>{this.emitWithGlobal("WEBSERVER.STOPPED",{})}}class NJ extends s{static instance=new NJ;_wss;constructor(){super();this._wss=new vZ0({noServer:!0}),this._wss.on("connection",this._onConnection),this._wss.on("error",this._onError),l8.on("WEBSERVER.UPGRADE",({req:J,socket:Z,head:Y})=>this._onUpgrade(J,Z,Y))}_onConnection=(J,Z)=>{new U9(J,Z)};_onError=(J,Z)=>{this.emitWithGlobal("SOCKET.ERROR",{ws:J,error:Z})};_onUpgrade=(J,Z,Y)=>{this._wss.handleUpgrade(J,Z,Y,(X)=>{this._wss.emit("connection",X,J)})}}var Q$;((K)=>{K.DYNAMIC="dynamic";K.FIXED="fixed";K.KINEMATIC_POSITION="kinematic_position";K.KINEMATIC_VELOCITY="kinematic_velocity"})(Q$||={});var Jq=0.001,$C="dynamic";class f9 extends s{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(J){super();J.type??=$C,this._rigidBodyDesc=this._createRigidBodyDesc(J),this._rigidBodyType=J.type,this._applyRigidBodyOptions(J),this._autoAddToSimulation(J)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:J,y:Z,z:Y,w:X}=this.rotation;return{x:2*(J*Y+X*Z),y:2*(Z*Y-X*J),z:1-2*(J*J+Z*Z)}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(J){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(J,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(J)}setAdditionalMassProperties(J){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:Z,centerOfMass:Y,principalAngularInertia:X,principalAngularInertiaLocalFrame:K}=J;this._rigidBody?this._rigidBody.setAdditionalMassProperties(Z,Y,X,K,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(Z,Y,X,K)}setAdditionalSolverIterations(J){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(J):this._rigidBodyDesc.setAdditionalSolverIterations(J)}setAngularDamping(J){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(J):this._rigidBodyDesc.setAngularDamping(J)}setAngularVelocity(J){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(J,!this._explicitSleep):this._rigidBodyDesc.setAngvel(J)}setCcdEnabled(J){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(J):this._rigidBodyDesc.setCcdEnabled(J)}setDominanceGroup(J){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(J):this._rigidBodyDesc.setDominanceGroup(J)}setEnabled(J){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(J):this._rigidBodyDesc.setEnabled(J)}setEnabledPositions(J){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(J.x,J.y,J.z),this._enabledPositions=J}setEnabledRotations(J){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(J.x,J.y,J.z),this._enabledRotations=J}setGravityScale(J){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(J,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(J)}setLinearDamping(J){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(J):this._rigidBodyDesc.setLinearDamping(J)}setLinearVelocity(J){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(J,!this._explicitSleep):this._rigidBodyDesc.setLinvel(J.x,J.y,J.z)}setNextKinematicRotation(J){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(J):this._rigidBodyDesc.setRotation(J)}setNextKinematicPosition(J){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(J):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setPosition(J){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(J,!this._explicitSleep):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setRotation(J){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(J,!this._explicitSleep):this._rigidBodyDesc.setRotation(J)}setSleeping(J){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?J?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=J,this._explicitSleep=J}setSoftCcdPrediction(J){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(J):this._rigidBodyDesc.setSoftCcdPrediction(J)}setCollisionGroupsForSolidColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((Z)=>{if(Z.isSensor)return;Z.setCollisionGroups(J)})}setCollisionGroupsForSensorColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((Z)=>{if(!Z.isSensor)return;Z.setCollisionGroups(J)})}setType(J){if(!this._requireNotRemoved("setType"))return;let Y={["dynamic"]:H0.RigidBodyType.Dynamic,["fixed"]:H0.RigidBodyType.Fixed,["kinematic_position"]:H0.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:H0.RigidBodyType.KinematicVelocityBased}[J];if(Y===void 0)return _.error(`Invalid RigidBodyType: ${J}`);this._rigidBody?this._rigidBody.setBodyType(Y,!this._explicitSleep):this._rigidBodyDesc.status=Y,this._rigidBodyType=J}addForce(J){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addForce(J,!this._explicitSleep)}addTorque(J){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addTorque(J,!this._explicitSleep)}addChildColliderToSimulation(J){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;J.addToSimulation(this._simulation,this)}addToSimulation(J){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return _.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=J,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((Z)=>{if(!Z.isSimulated)Z.addToSimulation(J,this)})}applyImpulse(J){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulse(J,!this._explicitSleep)}applyImpulseAtPoint(J,Z){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulseAtPoint(J,Z,!this._explicitSleep)}applyTorqueImpulse(J){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(J,!this._explicitSleep)}createAndAddChildCollider(J){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new n8({...J,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(J)}createAndAddChildCollidersToSimulation(J){let Z=[];return J.forEach((Y)=>{let X=this.createAndAddChildCollider(Y);if(X)Z.push(X)}),Z}getCollidersByTag(J){let Z=[];for(let Y of this._colliders)if(Y.tag===J)Z.push(Y);return Z}linkCollider(J){if(!this._requireNotRemoved("linkCollider"))return;if(J.parentRigidBody!==this)return _.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(J)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return _.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((J)=>{J.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(J){if(!this._requireNotRemoved("unlinkCollider"))return;if(!J.isRemoved)return _.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(J)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(J){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([Y,X])=>{if(Y in J)X(J[Y])})}_autoAddToSimulation(J){if(J.colliders)this._createAndAddPendingChildColliders(J.colliders);if(J.simulation)this.addToSimulation(J.simulation)}_createAndAddPendingChildCollider(J){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let Z=new n8(J);return this._colliders.add(Z),Z}_createAndAddPendingChildColliders(J){let Z=[];return J.forEach((Y)=>{let X=this._createAndAddPendingChildCollider(Y);if(X)Z.push(X)}),Z}_createRigidBodyDesc(J){let Z=J.type??$C;return{["dynamic"]:()=>H0.RigidBodyDesc.dynamic(),["fixed"]:()=>H0.RigidBodyDesc.fixed(),["kinematic_position"]:()=>H0.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>H0.RigidBodyDesc.kinematicVelocityBased()}[Z]()}_requireCreated(J){if(!this._rigidBody||!this._simulation)_.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(J){if(!this.isDynamic)_.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${J}()`);return this.isDynamic}_requireKinematic(J){if(!this.isKinematic)_.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${J}()`);return this.isKinematic}_requireNotKinematicPositionBased(J){if(this.isKinematicPositionBased)_.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${J}()`);return!this.isKinematicPositionBased}_requireNotRemoved(J){if(!this._rigidBody&&!this._rigidBodyDesc)_.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(J){if(this.isSimulated)_.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${J}()`);return!this.isSimulated}_isNegligibleVector(J){return Math.abs(J.x)<Jq&&Math.abs(J.y)<Jq&&Math.abs(J.z)<Jq}}var i0=16,r5=i0-1,QC=i0**3,jZ0=[{neighborOffset:[-1,0,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+0,J+0,Z+1,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+1]},{neighborOffset:[1,0,0],generateVertices:(J,Z,Y)=>[J+1,Z+0,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+1,J+1,Z+0,Y+1]},{neighborOffset:[0,-1,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+1,Z+0,Y+0,J+0,Z+0,Y+1,J+1,Z+0,Y+0,J+1,Z+0,Y+1,J+0,Z+0,Y+1]},{neighborOffset:[0,1,0],generateVertices:(J,Z,Y)=>[J+0,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+1]},{neighborOffset:[0,0,-1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+0]},{neighborOffset:[0,0,1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+1,J+1,Z+0,Y+1,J+0,Z+1,Y+1,J+0,Z+1,Y+1,J+1,Z+0,Y+1,J+1,Z+1,Y+1]}],Zq;((X)=>{X.DESPAWN="CHUNK.DESPAWN";X.SET_BLOCK="CHUNK.SET_BLOCK";X.SPAWN="CHUNK.SPAWN"})(Zq||={});class P8 extends s{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(QC)}get blocks(){return this._blocks}get requiresUpdate(){return this._requiresUpdate}get isSimulated(){return!!this._rigidBody}get isSpawned(){return!!this._originCoordinate&&!!this._world}get originCoordinate(){return this._originCoordinate}get world(){return this._world}static blockIndexToLocalCoordinate(J){return{x:J%i0,y:(J/i0|0)%i0,z:J/(i0*i0)|0}}static globalCoordinateToLocalCoordinate(J){return{x:J.x&i0-1,y:J.y&i0-1,z:J.z&i0-1}}static globalCoordinateToOriginCoordinate(J){return{x:J.x&~(i0-1),y:J.y&~(i0-1),z:J.z&~(i0-1)}}static isValidOriginCoordinate(J){return J.x%i0===0&&J.y%i0===0&&J.z%i0===0}spawn(J,Z){if(this.isSpawned){let{x:Y,y:X,z:K}=this.originCoordinate;return _.error(`Chunk.spawn(): Chunk is already spawned at origin ${Y}, ${X}, ${K}!`)}if(!P8.isValidOriginCoordinate(Z))return _.error(`Chunk.spawn(): Chunk coordinates must be divisible by ${i0}`);this._originCoordinate=Z,this._world=J,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)return _.error("Chunk.despawn(): Chunk has not been spawned and cannot be despawned!");this.emitWithWorld(this._world,"CHUNK.DESPAWN",{chunk:this}),this._removeFromSimulation(),this._world.chunkLattice.unregisterChunk(this),this._originCoordinate=void 0,this._world=void 0}getBlockId(J){return this._blocks[this._getIndex(J)]}hasBlock(J){return this._blocks[this._getIndex(J)]!==0}setBlock(J,Z){if(!this._isValidLocalCoordinate(J))return _.error("Chunk.setBlock(): Block local coordinate is out of bounds");if(this._blocks[this._getIndex(J)]===Z)return;if(this._blocks[this._getIndex(J)]=Z,this.isSpawned&&this.isSimulated){this.emitWithWorld(this._world,"CHUNK.SET_BLOCK",{chunk:this,globalCoordinate:this._getGlobalCoordinate(J),localCoordinate:J,blockTypeId:Z});let Y=this._getGlobalCoordinate(J),X=[];if(J.x===0)X.push({x:-1,y:0,z:0});if(J.y===0)X.push({x:0,y:-1,z:0});if(J.z===0)X.push({x:0,y:0,z:-1});if(J.x===r5)X.push({x:1,y:0,z:0});if(J.y===r5)X.push({x:0,y:1,z:0});if(J.z===r5)X.push({x:0,y:0,z:1});for(let K of X){let $={x:Y.x+K.x,y:Y.y+K.y,z:Y.z+K.z},Q=P8.globalCoordinateToOriginCoordinate($),F=this._world?.chunkLattice.getChunk(Q);if(!F?.hasBlock(P8.globalCoordinateToLocalCoordinate($)))continue;F.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(J){this._requiresUpdate=J}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)return _.error("Chunk.update(): Chunk is not spawned and cannot be updated.");let J=!this._rigidBody,Z=this._world.simulation;if(this._removeFromSimulation(),this._rigidBody=new f9({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([Y,X])=>{if(!Y.isSimulated)Y.addToSimulation(Z,this._rigidBody);Z.colliderMap.setColliderBlockType(Y,X)}),this._requiresUpdate=!1,J)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return e.serializeChunk(this)}_meshColliders(){if(!this._world)return _.error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed."),[];let J=new Map,Z=[];for(let X=0;X<QC;X++){if(this._blocks[X]===0)continue;let K=this._blocks[X],$=this._world.blockTypeRegistry.getBlockType(K),{x:Q,y:F,z:G}=P8.blockIndexToLocalCoordinate(X);if(!$.isMeshable){let V=$.createCollider();V.setRelativePosition({x:Q,y:F,z:G}),Z.push([V,$]);continue}let W=J.get($)??{indices:[],vertices:[]};J.set($,W);for(let V of jZ0){let[q,z,U]=V.neighborOffset,M={x:Q+q,y:F+z,z:G+U},R=this._getGlobalCoordinate(M),L=this._world.chunkLattice.getBlockType(R);if(L&&!L.isLiquid)continue;let O=W.indices.length;W.indices.push(O,O+1,O+2,O+3,O+4,O+5),W.vertices.push(...V.generateVertices(Q,F,G))}}let Y=[];return J.forEach((X,K)=>{if(!X.indices.length)return;let $=K.createCollider(new Uint32Array(X.indices),new Float32Array(X.vertices));Y.push([$,K])}),[...Z,...Y]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(J){if(!this.originCoordinate)_.fatalError("Chunk._getGlobalCoordinate(): Chunk is not spawned, calculating global coordinate is impossible.");return{x:this.originCoordinate.x+J.x,y:this.originCoordinate.y+J.y,z:this.originCoordinate.z+J.z}}_getIndex(J){return J.x+i0*(J.y+i0*J.z)}_isValidLocalCoordinate(J){return J.x>=0&&J.x<=r5&&J.y>=0&&J.y<=r5&&J.z>=0&&J.z<=r5}}class BJ{_chunks=new Map;_world;constructor(J){this._world=J}registerChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(J.originCoordinate)){let{x:Z,y:Y,z:X}=J.originCoordinate;return _.error(`ChunkLattice.registerChunk(): Chunk exists at origin (${Z}, ${Y}, ${X}), despawn the current chunk before registering another at the same origin.`)}if(J.world.id!==this._world.id)return _.error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(J.originCoordinate),J)}unregisterChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(J.world.id!==this._world.id)return _.error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(J.originCoordinate))}getBlockId(J){let Z=this.getChunk(P8.globalCoordinateToOriginCoordinate(J));if(!Z)return 0;return Z.getBlockId(P8.globalCoordinateToLocalCoordinate(J))}getBlockType(J){let Z=this.getBlockId(J);return Z?this._world.blockTypeRegistry.getBlockType(Z):null}getChunk(J){if(!P8.isValidOriginCoordinate(J)){_.error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${i0})`);return}return this._chunks.get(this._getChunkKey(J))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(J){let Z=this.getChunk(P8.globalCoordinateToOriginCoordinate(J));if(!Z)return!1;return Z.hasBlock(P8.globalCoordinateToLocalCoordinate(J))}hasChunk(J){return this._chunks.has(this._getChunkKey(J))}setBlock(J,Z){let Y=P8.globalCoordinateToLocalCoordinate(J),X=P8.globalCoordinateToOriginCoordinate(J),K=this.getChunk(X);if(!K)K=new P8,K.spawn(this._world,X);K.setBlock(Y,Z)}updateChunks(){this._chunks.forEach((J)=>{if(J.requiresUpdate)J.update()})}_getChunkKey(J){return`${J.x},${J.y},${J.z}`}}var FC={type:"dynamic",softCcdPrediction:1},GC=0.0025000000000000005,WC=Math.cos(0.005),F$;((O)=>{O.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";O.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";O.DESPAWN="ENTITY.DESPAWN";O.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";O.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";O.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";O.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";O.SET_OPACITY="ENTITY.SET_OPACITY";O.SET_PARENT="ENTITY.SET_PARENT";O.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";O.SPAWN="ENTITY.SPAWN";O.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";O.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";O.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";O.TICK="ENTITY.TICK";O.UPDATE_POSITION="ENTITY.UPDATE_POSITION";O.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(F$||={});class K8 extends f9{_id;_blockHalfExtents;_blockTextureUri;_controller;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelScale;_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;constructor(J){let Z="blockTextureUri"in J,Y="modelUri"in J;if(!Z===!Y)_.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(Z&&!J.blockHalfExtents)_.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(J.parent&&!J.parent.isSpawned)_.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(J.parent?.modelUri&&J.parentNodeName&&!M6.instance.modelHasNode(J.parent.modelUri,J.parentNodeName))_.fatalError(`Entity.constructor(): Parent node name ${J.parentNodeName} not found in parent model ${J.parent.modelUri}!`);super(J.rigidBodyOptions??FC);if(Z)this._blockHalfExtents=J.blockHalfExtents,this._blockTextureUri=J.blockTextureUri;if(Y)this._modelAnimationsPlaybackRate=J.modelAnimationsPlaybackRate??1,this._modelScale=J.modelScale,this._modelUri=J.modelUri,J.modelHiddenNodes?.forEach((X)=>this._modelHiddenNodes.add(X.toLowerCase())),J.modelLoopedAnimations?.forEach((X)=>this._modelLoopedAnimations.add(X));if(this._name=J.name??"Nameless",this._opacity=J.opacity??1,this._parent=J.parent,this._parentNodeName=J.parentNodeName,this._tag=J.tag,this._tintColor=J.tintColor,J.controller)this.setController(J.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get height(){return this.isModelEntity?M6.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 modelScale(){return this._modelScale}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 isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get world(){return this._world}spawn(J,Z,Y){if(this.isSpawned)return _.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(J.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new n8(n8.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0)this.addChildColliderToSimulation(new n8(n8.optionsFromModelUri(this._modelUri,this._modelScale)));if(this.colliders.forEach((X)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))X.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))X.enableContactForceEvents(!0);if(z6.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[X.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(Z),Y)this.setRotation(Y);if(this._id=J.entityManager.registerEntity(this),this._world=J,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,Z,Y);this.colliders.forEach((X)=>{J.simulation.colliderMap.setColliderEntity(X,this)}),this.emitWithWorld(J,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((J)=>{J.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.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setModelAnimationsPlaybackRate(J){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===J)return;this._modelAnimationsPlaybackRate=J,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:J})}setController(J){if(this._controller===J)return;if(this._controller)this._controller.detach(this);if(this._controller=J,this._controller)this._controller.attach(this)}setModelHiddenNodes(J){if(!this._requireSpawned("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setOpacity(J){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===J)return;this._opacity=J,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:J})}setParent(J,Z,Y,X){if(!this._requireSpawned("setParent"))return;if(J&&!J.isSpawned)return _.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&J)this._lastParentlessType=this.type;if(this._parent=J,this._parentNodeName=Z,this.colliders.forEach((K)=>K.setEnabled(!J)),this.setType(!J?this._lastParentlessType:"kinematic_velocity"),this.setPosition(Y??{x:0,y:0,z:0}),this.setRotation(X??{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:J,parentNodeName:Z})}setTintColor(J){if(!this._requireSpawned("setTintColor"))return;if(!J&&!this._tintColor||J&&this._tintColor&&J.r===this._tintColor.r&&J.g===this._tintColor.g&&J.b===this._tintColor.b)return;this._tintColor=J,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:J})}startModelLoopedAnimations(J){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>!this._modelLoopedAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(J)})}startModelOneshotAnimations(J){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!J.length)return;J.forEach((Z)=>{this._modelOneshotAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(J)})}stopModelAnimations(J){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>this._modelLoopedAnimations.has(Z))&&!J.some((Z)=>this._modelOneshotAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.delete(Z),this._modelOneshotAnimations.delete(Z)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(J)})}serialize(){return e.serializeEntity(this)}tick(J){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:J}),this._controller)this._controller.tick(this,J)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let J=this.position,Z=this.rotation;if(this._rotationExceedsThreshold(Z,this._lastUpdatedRotation))this._lastUpdatedRotation=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:Z});if(this._positionExceedsThreshold(J,this._lastUpdatedPosition))this._lastUpdatedPosition=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:J})}_requireSpawned(J){if(!this.isSpawned)_.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${J}()!`);return this.isSpawned}_positionExceedsThreshold(J,Z){let Y=J.x-Z.x,X=J.y-Z.y,K=J.z-Z.z;return Y*Y+X*X+K*K>GC}_rotationExceedsThreshold(J,Z){return Math.abs(J.x*Z.x+J.y*Z.y+J.z*Z.z+J.w*Z.w)<WC}}class vJ extends n1{autoCancelMouseLeftClick=!0;canWalk=()=>!0;canRun=()=>!0;canJump=()=>!0;idleLoopedAnimations=["idle_upper","idle_lower"];interactOneshotAnimations=["simple_interact"];jumpOneshotAnimations=["jump_loop"];jumpVelocity=10;runLoopedAnimations=["run_upper","run_lower"];runVelocity=8;sticksToPlatforms=!0;walkLoopedAnimations=["walk_upper","walk_lower"];walkVelocity=4;_stepAudio;_groundContactCount=0;_platform;constructor(J={}){super();this.autoCancelMouseLeftClick=J.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.jumpVelocity=J.jumpVelocity??this.jumpVelocity,this.runVelocity=J.runVelocity??this.runVelocity,this.walkVelocity=J.walkVelocity??this.walkVelocity,this.canWalk=J.canWalk??this.canWalk,this.canRun=J.canRun??this.canRun,this.canJump=J.canJump??this.canJump,this.sticksToPlatforms=J.sticksToPlatforms??this.sticksToPlatforms}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get platform(){return this._platform}attach(J){this._stepAudio=new K4({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,attachedToEntity:J}),J.setCcdEnabled(!0),J.lockAllRotations()}spawn(J){if(!J.isSpawned)return _.error("PlayerEntityController.createColliders(): Entity is not spawned!");J.createAndAddChildCollider({shape:"cylinder",radius:0.23,halfHeight:0.125,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},isSensor:!0,relativePosition:{x:0,y:-0.75,z:0},tag:"groundSensor",onCollision:(Z,Y)=>{if(!J.isSpawned)return;if(this._groundContactCount+=Y?1:-1,!this._groundContactCount)J.startModelOneshotAnimations(this.jumpOneshotAnimations);else J.stopModelAnimations(this.jumpOneshotAnimations);if(!(Z instanceof K8)||!Z.isKinematic)return;if(Y&&this.sticksToPlatforms)this._platform=Z;else if(Z===this._platform&&!Y)this._platform=void 0}}),J.createAndAddChildCollider({shape:"capsule",halfHeight:0.33,radius:0.4,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(J,Z,Y,X){if(!J.isSpawned||!J.world)return;if(super.tickWithPlayerInput(J,Z,Y,X),J.parent)return;let{w:K,a:$,s:Q,d:F,sp:G,sh:W,ml:V}=Z,{yaw:q}=Y,z=J.linearVelocity,U={x:0,y:0,z:0},M=W;if(this.isGrounded&&(K||$||Q||F)){if(M)J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((N)=>!this.runLoopedAnimations.includes(N))),J.startModelLoopedAnimations(this.runLoopedAnimations),this._stepAudio?.setPlaybackRate(0.75);else J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((N)=>!this.walkLoopedAnimations.includes(N))),J.startModelLoopedAnimations(this.walkLoopedAnimations),this._stepAudio?.setPlaybackRate(0.51);this._stepAudio?.play(J.world,!this._stepAudio?.isPlaying)}else this._stepAudio?.pause(),J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((N)=>!this.idleLoopedAnimations.includes(N))),J.startModelLoopedAnimations(this.idleLoopedAnimations);if(V)J.startModelOneshotAnimations(this.interactOneshotAnimations),Z.ml=!this.autoCancelMouseLeftClick;if(M&&this.canRun(this)||!M&&this.canWalk(this)){let N=M?this.runVelocity:this.walkVelocity;if(K)U.x-=N*Math.sin(q),U.z-=N*Math.cos(q);if(Q)U.x+=N*Math.sin(q),U.z+=N*Math.cos(q);if($)U.x-=N*Math.cos(q),U.z+=N*Math.sin(q);if(F)U.x+=N*Math.cos(q),U.z-=N*Math.sin(q);let B=Math.sqrt(U.x*U.x+U.z*U.z);if(B>N){let v=N/B;U.x*=v,U.z*=v}}if(G&&this.canJump(this)){if(this.isGrounded&&z.y>-0.001&&z.y<=3)U.y=this.jumpVelocity}let R=this._platform?this._platform.linearVelocity:{x:0,y:0,z:0},L={x:U.x-z.x+R.x,y:U.y+R.y,z:U.z-z.z+R.z};if(!(this.runVelocity>0&&Math.abs(z.x)>this.runVelocity||this.jumpVelocity>0&&Math.abs(z.y)>this.jumpVelocity||this.runVelocity>0&&Math.abs(z.z)>this.runVelocity)||this.isOnPlatform){if(Object.values(L).some((N)=>N!==0)){let N=J.mass;J.applyImpulse({x:L.x*N,y:L.y*N,z:L.z*N})}}if(q!==void 0){let N=q/2;J.setRotation({x:0,y:Math.fround(Math.sin(N)),z:0,w:Math.fround(Math.cos(N))})}}}var Yq;((F)=>{F.LOAD="SCENE_UI.LOAD";F.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";F.SET_OFFSET="SCENE_UI.SET_OFFSET";F.SET_POSITION="SCENE_UI.SET_POSITION";F.SET_STATE="SCENE_UI.SET_STATE";F.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";F.UNLOAD="SCENE_UI.UNLOAD"})(Yq||={});class jJ extends s{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=J.attachedToEntity,this._offset=J.offset,this._position=J.position,this._state=J.state??{},this._templateId=J.templateId,this._viewDistance=J.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(J){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=J.sceneUIManager.registerSceneUI(this),this._world=J,this.emitWithWorld(J,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`SceneUI.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:J})}setPosition(J){if(this._position===J)return;if(this._attachedToEntity=void 0,this._position=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:J})}setState(J){if(this._state={...this._state,...J},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(J){if(this._viewDistance=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:J})}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 e.serializeSceneUI(this)}}class i1 extends K8{player;nametagSceneUI;constructor(J){super(J);if(this.player=J.player,this.nametagSceneUI=new jJ({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}}),!J.controller)this.setController(new vJ)}spawn(J,Z,Y){super.spawn(J,Z,Y),this.nametagSceneUI.load(J),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:X})=>{this.nametagSceneUI.setState({chat:X})})}tick(J){if(!this.isSpawned||!this.world||!this.controller)return;let{input:Z,camera:Y}=this.player;this.controller.tickWithPlayerInput(this,Z,Y.orientation,J),super.tick(J)}}class xJ{_entities=new Map;_nextEntityId=1;_world;constructor(J){this._world=J}get world(){return this._world}registerEntity(J){if(J.id!==void 0)_.fatalError(`EntityManager.registerEntity(): Entity ${J.name} is already assigned the id ${J.id}!`);let Z=this._nextEntityId;return this._entities.set(Z,J),this._nextEntityId++,Z}unregisterEntity(J){if(J.id===void 0)return _.error(`EntityManager.unregisterEntity(): Entity ${J.name} is not assigned an id!`);this._entities.delete(J.id)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let J=[];return this._entities.forEach((Z)=>{if(Z instanceof i1)J.push(Z)}),J}getPlayerEntitiesByPlayer(J){let Z=[];return this._entities.forEach((Y)=>{if(Y instanceof i1&&Y.player===J)Z.push(Y)}),Z}getEntity(J){return this._entities.get(J)}getEntitiesByTag(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag===J)Z.push(Y)}),Z}getEntitiesByTagSubstring(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag?.includes(J))Z.push(Y)}),Z}getEntityChildren(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.parent===J)Z.push(Y)}),Z}tickEntities(J){this._entities.forEach((Z)=>{Z.tick(J)})}checkAndEmitUpdates(){this._entities.forEach((J)=>{if(!J.isSpawned)return;J.checkAndEmitUpdates()})}}class TJ{_lights=new Map;_nextLightId=1;_world;constructor(J){this._world=J}get world(){return this._world}despawnEntityAttachedLights(J){this.getAllEntityAttachedLights(J).forEach((Z)=>{Z.despawn()})}getAllLights(){return Array.from(this._lights.values())}getAllEntityAttachedLights(J){return this.getAllLights().filter((Z)=>Z.attachedToEntity===J)}registerLight(J){if(J.id!==void 0)return J.id;let Z=this._nextLightId;return this._lights.set(Z,J),this._nextLightId++,Z}unregisterLight(J){if(J.id===void 0)return;this._lights.delete(J.id)}}var VC;((Y)=>{Y[Y.POINTLIGHT=0]="POINTLIGHT";Y[Y.SPOTLIGHT=1]="SPOTLIGHT"})(VC||={});var Xq;((z)=>{z.DESPAWN="LIGHT.DESPAWN";z.SET_ANGLE="LIGHT.SET_ANGLE";z.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";z.SET_COLOR="LIGHT.SET_COLOR";z.SET_DISTANCE="LIGHT.SET_DISTANCE";z.SET_INTENSITY="LIGHT.SET_INTENSITY";z.SET_OFFSET="LIGHT.SET_OFFSET";z.SET_PENUMBRA="LIGHT.SET_PENUMBRA";z.SET_POSITION="LIGHT.SET_POSITION";z.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";z.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";z.SPAWN="LIGHT.SPAWN"})(Xq||={});class Kq extends s{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();_.warning("WARNING: Lights are poorly optimized at this time. Using more than a few lights in your game can cause extremely bad performance (FPS) issues. Use lights sparingly!"),this._angle=J.angle,this._attachedToEntity=J.attachedToEntity,this._color=J.color??{r:255,g:255,b:255},this._distance=J.distance,this._intensity=J.intensity??1,this._offset=J.offset,this._penumbra=J.penumbra,this._position=J.position,this._trackedEntity=J.trackedEntity,this._trackedPosition=J.trackedPosition,this._type=J.type??0}get id(){return this._id}get angle(){return this._angle}get attachedToEntity(){return this._attachedToEntity}get color(){return this._color}get distance(){return this._distance}get intensity(){return this._intensity}get isSpawned(){return this._id!==void 0}get offset(){return this._offset}get penumbra(){return this._penumbra}get position(){return this._position}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get type(){return this._type}get world(){return this._world}setAngle(J){if(this._angle===J)return;if(this._angle=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ANGLE",{light:this,angle:J})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`Light.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ATTACHED_TO_ENTITY",{light:this,entity:J})}setColor(J){if(this._color.r===J.r&&this._color.g===J.g&&this._color.b===J.b)return;if(this._color=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_COLOR",{light:this,color:J})}setDistance(J){if(this._distance===J)return;if(this._distance=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_DISTANCE",{light:this,distance:J})}setIntensity(J){if(this._intensity===J)return;if(this._intensity=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_INTENSITY",{light:this,intensity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_OFFSET",{light:this,offset:J})}setPenumbra(J){if(this._penumbra===J)return;if(this._penumbra=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_PENUMBRA",{light:this,penumbra:J})}setPosition(J){if(this._position===J)return;if(this._position=J,this._attachedToEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_POSITION",{light:this,position:J})}setTrackedEntity(J){if(!J.isSpawned)return _.error(`Light.setTrackedEntity(): Entity ${J.id} is not spawned!`);if(this._trackedEntity===J)return;if(this._trackedEntity=J,this._trackedPosition=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_ENTITY",{light:this,entity:J})}setTrackedPosition(J){if(this._trackedPosition===J)return;if(this._trackedPosition=J,this._trackedEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_POSITION",{light:this,position:J})}despawn(){if(!this.isSpawned||!this._world)return;this._world.lightManager.unregisterLight(this),this.emitWithWorld(this._world,"LIGHT.DESPAWN",{light:this}),this._id=void 0,this._world=void 0}spawn(J){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`Light.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning Light!`);this._id=J.lightManager.registerLight(this),this._world=J,this.emitWithWorld(J,"LIGHT.SPAWN",{light:this})}serialize(){return e.serializeLight(this)}}var qC;((X)=>{X[X.FIRST_PERSON=0]="FIRST_PERSON";X[X.THIRD_PERSON=1]="THIRD_PERSON";X[X.SPECTATOR=2]="SPECTATOR"})(qC||={});var $q;((U)=>{U.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";U.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";U.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";U.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";U.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";U.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";U.SET_FOV="PLAYER_CAMERA.SET_FOV";U.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";U.SET_MODE="PLAYER_CAMERA.SET_MODE";U.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";U.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";U.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";U.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})($q||={});class DJ extends s{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_trackedEntity;_trackedPosition;_zoom=1;constructor(J){super();this.player=J}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 filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:J})}lookAtPosition(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:J})}setAttachedToEntity(J){if(!this._requirePlayerWorld())return;if(!J.isSpawned)return _.error(`PlayerCamera.setAttachedToEntity(): Entity ${J.id} is not spawned!`);this._attachedToEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:J})}setAttachedToPosition(J){if(!this._requirePlayerWorld())return;this._attachedToPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:J})}setFilmOffset(J){if(!this._requirePlayerWorld())return;this._filmOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:J})}setForwardOffset(J){if(!this._requirePlayerWorld())return;this._forwardOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:J})}setFov(J){if(!this._requirePlayerWorld())return;this._fov=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:J})}setModelHiddenNodes(J){if(!this._requirePlayerWorld())return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setMode(J){if(!this._requirePlayerWorld())return;this._mode=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:J})}setOffset(J){if(!this._requirePlayerWorld())return;this._offset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:J})}setOrientationPitch(J){this._orientation.pitch=J}setOrientationYaw(J){this._orientation.yaw=J}setTrackedEntity(J){if(!this._requirePlayerWorld())return;this._trackedEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:J})}setTrackedPosition(J){if(!this._requirePlayerWorld())return;this._trackedPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:J})}setZoom(J){if(!this._requirePlayerWorld())return;this._zoom=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:J})}serialize(){return e.serializePlayerCamera(this)}_requirePlayerWorld(){if(!this.player.world)_.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world!`);return!!this.player.world}}var G$;((K)=>{K.DATA="PLAYER_UI.DATA";K.LOAD="PLAYER_UI.LOAD";K.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";K.SEND_DATA="PLAYER_UI.SEND_DATA"})(G$||={});class _J extends s{player;constructor(J){super();this.player=J}load(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:J})}lockPointer(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:J})}sendData(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:J})}}class EJ{_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(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleBlockTypeMap.get(J.rawCollider.handle)}getColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleCollisionCallbackMap.get(J.rawCollider.handle)}getColliderEntity(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleEntityMap.get(J.rawCollider.handle)}getColliderHandleBlockType(J){return this._colliderHandleBlockTypeMap.get(J)}getColliderHandleCollisionCallback(J){return this._colliderHandleCollisionCallbackMap.get(J)}getColliderHandleEntity(J){return this._colliderHandleEntityMap.get(J)}removeColliderBlockType(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleBlockType(J.rawCollider.handle)}removeColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleCollisionCallback(J.rawCollider.handle)}removeColliderEntity(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleEntity(J.rawCollider.handle)}removeColliderHandleBlockType(J){this._colliderHandleBlockTypeMap.delete(J)}removeColliderHandleCollisionCallback(J){this._colliderHandleCollisionCallbackMap.delete(J)}removeColliderHandleEntity(J){this._colliderHandleEntityMap.delete(J)}setColliderBlockType(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleBlockType(J.rawCollider.handle,Z)}setColliderCollisionCallback(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleCollisionCallback(J.rawCollider.handle,Z)}setColliderEntity(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleEntity(J.rawCollider.handle,Z)}setColliderHandleBlockType(J,Z){this._colliderHandleBlockTypeMap.set(J,Z),this._cleanupBlockTypeColliderHandles.delete(J),this._pendingCleanupBlockTypeColliderHandles.delete(J)}setColliderHandleCollisionCallback(J,Z){this._colliderHandleCollisionCallbackMap.set(J,Z),this._cleanupCollisionCallbackColliderHandles.delete(J),this._pendingCleanupCollisionCallbackColliderHandles.delete(J)}setColliderHandleEntity(J,Z){this._colliderHandleEntityMap.set(J,Z),this._cleanupEntityColliderHandles.delete(J),this._pendingCleanupEntityColliderHandles.delete(J)}queueColliderHandleForCleanup(J){if(this._colliderHandleBlockTypeMap.has(J))this._pendingCleanupBlockTypeColliderHandles.add(J);if(this._colliderHandleCollisionCallbackMap.has(J))this._pendingCleanupCollisionCallbackColliderHandles.add(J);if(this._colliderHandleEntityMap.has(J))this._pendingCleanupEntityColliderHandles.add(J)}cleanup(){for(let J of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(J);this._cleanupBlockTypeColliderHandles.clear();for(let J of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(J);this._cleanupCollisionCallbackColliderHandles.clear();for(let J of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(J);this._cleanupEntityColliderHandles.clear(),[[this._pendingCleanupBlockTypeColliderHandles,this._cleanupBlockTypeColliderHandles],[this._pendingCleanupCollisionCallbackColliderHandles,this._cleanupCollisionCallbackColliderHandles],[this._pendingCleanupEntityColliderHandles,this._cleanupEntityColliderHandles]].forEach(([J,Z])=>{for(let Y of J.keys())Z.add(Y);J.clear()})}_requireSimulatedCollider(J){if(!J.rawCollider)_.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!J.rawCollider}}var kZ0={x:0,y:-32,z:0},Qq=60,Fq;((K)=>{K.STEP_START="SIMULATION.STEP_START";K.STEP_END="SIMULATION.STEP_END";K.DEBUG_RAYCAST="SIMULATION.DEBUG_RAYCAST";K.DEBUG_RENDER="SIMULATION.DEBUG_RENDER"})(Fq||={});class CJ extends s{_colliderMap=new EJ;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_rapierEventQueue;_rapierSimulation;_world;constructor(J,Z=Qq,Y=kZ0){super();this._rapierEventQueue=new H0.EventQueue(!0),this._rapierSimulation=new H0.World(Y),this._rapierSimulation.timestep=Math.fround(1/Z),this._world=J}get colliderMap(){return this._colliderMap}get isDebugRaycastingEnabled(){return this._debugRaycastingEnabled}get isDebugRenderingEnabled(){return this._debugRenderingEnabled}get gravity(){return this._rapierSimulation.gravity}get timestepS(){return this._rapierSimulation.timestep}get world(){return this._world}raycast(J,Z,Y,X={}){let K=new H0.Ray(J,Z),$=this._rapierSimulation.castRay(K,Y,X.ignoresSensors??!0,X.filterFlags,X.filterGroups,X.filterExcludeCollider,X.filterExcludeRigidBody,X.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:J,direction:Z,length:Y,hit:!!$});if(!$)return null;let Q=K.pointAt($.timeOfImpact),F=$.timeOfImpact,G=$.collider,W=this._colliderMap.getColliderHandleBlockType(G.handle);if(W)return{hitBlock:A9.fromGlobalCoordinate({x:Math.floor(Q.x-(K.dir.x<0?0.0001:-0.0001)),y:Math.floor(Q.y-(K.dir.y<0?0.0001:-0.0001)),z:Math.floor(Q.z-(K.dir.z<0?0.0001:-0.0001))},W),hitPoint:Q,hitDistance:F};let V=this._colliderMap.getColliderHandleEntity(G.handle);if(V)return{hitEntity:V,hitPoint:Q,hitDistance:F};return null}createRawCollider(J,Z){return this._rapierSimulation.createCollider(J,Z)}createRawRigidBody(J){return this._rapierSimulation.createRigidBody(J)}enableDebugRaycasting(J){this._debugRaycastingEnabled=J}enableDebugRendering(J){this._debugRenderingEnabled=J}getContactManifolds(J,Z){let Y=[];return this._rapierSimulation.narrowPhase.contactPair(J,Z,(X,K)=>{if(X.numContacts()===0)return;let $=X.normal(),Q=[];for(let F=0;F<X.numSolverContacts();F++)Q.push(X.solverContactPoint(F));Y.push({contactPoints:Q,localNormalA:!K?X.localNormal1():X.localNormal2(),localNormalB:!K?X.localNormal2():X.localNormal1(),normal:!K?$:{x:-$.x,y:-$.y,z:-$.z}})}),Y}removeRawCollider(J){this._colliderMap.queueColliderHandleForCleanup(J.handle),this._rapierSimulation.removeCollider(J,!1)}removeRawRigidBody(J){this._rapierSimulation.removeRigidBody(J)}setGravity(J){this._rapierSimulation.gravity=J}step=(J)=>{this.emitWithWorld(this._world,"SIMULATION.STEP_START",{simulation:this,tickDeltaMs:J});let Z=performance.now();if(this._rapierSimulation.step(this._rapierEventQueue),this._rapierEventQueue.drainContactForceEvents(this._onContactForceEvent),this._rapierEventQueue.drainCollisionEvents(this._onCollisionEvent),this._colliderMap.cleanup(),this.emitWithWorld(this._world,"SIMULATION.STEP_END",{simulation:this,stepDurationMs:performance.now()-Z}),this._debugRenderingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RENDER",{simulation:this,...this._rapierSimulation.debugRender()})};_onCollisionEvent=(J,Z,Y)=>{let[X,K]=this._getCollisionObjects(J,Z);if(!X||!K)return;let $=(Q,F)=>{if(Q instanceof R6&&F instanceof K8&&Q.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))Q.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:Q,entity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof R6&&Q.hasListeners("ENTITY.BLOCK_COLLISION"))Q.emit("ENTITY.BLOCK_COLLISION",{entity:Q,blockType:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof K8&&Q.hasListeners("ENTITY.ENTITY_COLLISION"))Q.emit("ENTITY.ENTITY_COLLISION",{entity:Q,otherEntity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(typeof Q==="function"&&(F instanceof K8||F instanceof R6))Q(F,Y,J,Z)};$(X,K),$(K,X)};_onContactForceEvent=(J)=>{let[Z,Y]=this._getCollisionObjects(J.collider1(),J.collider2());if(!Z||typeof Z==="function"||!Y||typeof Y==="function")return;let X={totalForce:J.totalForce(),totalForceMagnitude:J.totalForceMagnitude(),maxForceDirection:J.maxForceDirection(),maxForceMagnitude:J.maxForceMagnitude()},K=($,Q)=>{if($ instanceof R6&&Q instanceof K8&&$.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))$.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:$,entity:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof R6&&$.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))$.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:$,blockType:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof K8&&$.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:$,otherEntity:Q,contactForceData:X})};K(Z,Y),K(Y,Z)};_getCollisionObjects(J,Z){let Y=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J),X=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z);return[Y,X]}}class W${_queuedBroadcasts=[];_queuedAudioSynchronizations={};_queuedBlockSynchronizations={};_queuedBlockTypeSynchronizations={};_queuedChunkSynchronizations={};_queuedDebugRaycastSynchronizations=[];_queuedEntitySynchronizations={};_queuedLightSynchronizations={};_queuedPerPlayerSynchronizations=new Map;_queuedPerPlayerCameraSynchronizations=new Map;_queuedPerPlayerUISynchronizations=new Map;_queuedPerPlayerUIDatasSynchronizations=new Map;_queuedPlayerSynchronizations={};_queuedSceneUISynchronizations={};_queuedWorldSynchronization;_loadedSceneUIs=new Set;_spawnedChunks=new Set;_spawnedEntities=new Set;_world;constructor(J){this._world=J,this._subscribeToAudioEvents(),this._subscribeToBlockTypeRegistryEvents(),this._subscribeToChatEvents(),this._subscribeToChunkEvents(),this._subscribeToEntityEvents(),this._subscribeToLightEvents(),this._subscribeToPlayerEvents(),this._subscribeToPlayerCameraEvents(),this._subscribeToPlayerUIEvents(),this._subscribeToSceneUIEvents(),this._subscribeToSimulationEvents(),this._subscribeToWorldEvents()}synchronize(){for(let[W,V]of this._queuedPerPlayerSynchronizations)for(let q of V)W.connection.send(q);let J=Object.values(this._queuedEntitySynchronizations);if(J.length>0){let W=g.createPacket(g.outboundPackets.entitiesPacketDefinition,J,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Z=Object.values(this._queuedAudioSynchronizations);if(Z.length>0){let W=g.createPacket(g.outboundPackets.audiosPacketDefinition,Z,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Y=Object.values(this._queuedBlockTypeSynchronizations);if(Y.length>0){let W=g.createPacket(g.outboundPackets.blockTypesPacketDefinition,Y,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let X=Object.values(this._queuedBlockSynchronizations);if(X.length>0){let W=g.createPacket(g.outboundPackets.blocksPacketDefinition,X,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let K=Object.values(this._queuedChunkSynchronizations);if(K.length>0){let W=g.createPacket(g.outboundPackets.chunksPacketDefinition,K,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let $=Object.values(this._queuedLightSynchronizations);if($.length>0){let W=g.createPacket(g.outboundPackets.lightsPacketDefinition,$,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerUISynchronizations){let q=g.createPacket(g.outboundPackets.uiPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}for(let[W,V]of this._queuedPerPlayerUIDatasSynchronizations){let q=g.createPacket(g.outboundPackets.uiDatasPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let Q=Object.values(this._queuedSceneUISynchronizations);if(Q.length>0){let W=g.createPacket(g.outboundPackets.sceneUIsPacketDefinition,Q,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}if(this._queuedWorldSynchronization){let W=g.createPacket(g.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerCameraSynchronizations){let q=g.createPacket(g.outboundPackets.cameraPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let F=Object.values(this._queuedPlayerSynchronizations);if(F.length>0){let W=g.createPacket(g.outboundPackets.playersPacketDefinition,F,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let W of this._queuedBroadcasts)Y8.instance.broadcastToWorld(this._world.id,W);let G=this._queuedDebugRaycastSynchronizations;if(G.length>0){let W=g.createPacket(g.outboundPackets.physicsDebugRaycastsPacketDefinition,G,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}this._queuedBroadcasts=[],this._queuedAudioSynchronizations={},this._queuedBlockSynchronizations={},this._queuedBlockTypeSynchronizations={},this._queuedChunkSynchronizations={},this._queuedDebugRaycastSynchronizations=[],this._queuedEntitySynchronizations={},this._queuedLightSynchronizations={},this._queuedPerPlayerSynchronizations.clear(),this._queuedPerPlayerCameraSynchronizations.clear(),this._queuedPerPlayerUISynchronizations.clear(),this._queuedPerPlayerUIDatasSynchronizations.clear(),this._queuedPlayerSynchronizations={},this._queuedSceneUISynchronizations={},this._queuedWorldSynchronization=void 0,this._loadedSceneUIs.clear(),this._spawnedChunks.clear(),this._spawnedEntities.clear()}_subscribeToAudioEvents(){this._world.final("AUDIO.PAUSE",this._onAudioPause),this._world.final("AUDIO.PLAY",this._onAudioPlay),this._world.final("AUDIO.PLAY_RESTART",this._onAudioPlayRestart),this._world.final("AUDIO.SET_ATTACHED_TO_ENTITY",this._onAudioSetAttachedToEntity),this._world.final("AUDIO.SET_DETUNE",this._onAudioSetDetune),this._world.final("AUDIO.SET_DISTORTION",this._onAudioSetDistortion),this._world.final("AUDIO.SET_POSITION",this._onAudioSetPosition),this._world.final("AUDIO.SET_PLAYBACK_RATE",this._onAudioSetPlaybackRate),this._world.final("AUDIO.SET_REFERENCE_DISTANCE",this._onAudioSetReferenceDistance),this._world.final("AUDIO.SET_VOLUME",this._onAudioSetVolume)}_subscribeToBlockTypeRegistryEvents(){this._world.final("BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",this._onBlockTypeRegistryRegisterBlockType)}_subscribeToChatEvents(){this._world.final("CHAT.BROADCAST_MESSAGE",this._onChatSendBroadcastMessage),this._world.final("CHAT.PLAYER_MESSAGE",this._onChatSendPlayerMessage)}_subscribeToChunkEvents(){this._world.final("CHUNK.SPAWN",this._onChunkSpawn),this._world.final("CHUNK.DESPAWN",this._onChunkDespawn),this._world.final("CHUNK.SET_BLOCK",this._onChunkSetBlock)}_subscribeToEntityEvents(){this._world.final("ENTITY.SPAWN",this._onEntitySpawn),this._world.final("ENTITY.DESPAWN",this._onEntityDespawn),this._world.final("ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",this._onEntitySetModelAnimationsPlaybackRate),this._world.final("ENTITY.SET_MODEL_HIDDEN_NODES",this._onEntitySetModelHiddenNodes),this._world.final("ENTITY.SET_OPACITY",this._onEntitySetOpacity),this._world.final("ENTITY.SET_PARENT",this._onEntitySetParent),this._world.final("ENTITY.SET_TINT_COLOR",this._onEntitySetTintColor),this._world.final("ENTITY.START_MODEL_LOOPED_ANIMATIONS",this._onEntityStartModelLoopedAnimations),this._world.final("ENTITY.START_MODEL_ONESHOT_ANIMATIONS",this._onEntityStartModelOneshotAnimations),this._world.final("ENTITY.STOP_MODEL_ANIMATIONS",this._onEntityStopModelAnimations),this._world.final("ENTITY.UPDATE_POSITION",this._onEntityUpdatePosition),this._world.final("ENTITY.UPDATE_ROTATION",this._onEntityUpdateRotation)}_subscribeToLightEvents(){this._world.final("LIGHT.DESPAWN",this._onLightDespawn),this._world.final("LIGHT.SET_ANGLE",this._onLightSetAngle),this._world.final("LIGHT.SET_ATTACHED_TO_ENTITY",this._onLightSetAttachedToEntity),this._world.final("LIGHT.SET_COLOR",this._onLightSetColor),this._world.final("LIGHT.SET_DISTANCE",this._onLightSetDistance),this._world.final("LIGHT.SET_INTENSITY",this._onLightSetIntensity),this._world.final("LIGHT.SET_OFFSET",this._onLightSetOffset),this._world.final("LIGHT.SET_PENUMBRA",this._onLightSetPenumbra),this._world.final("LIGHT.SET_POSITION",this._onLightSetPosition),this._world.final("LIGHT.SET_TRACKED_ENTITY",this._onLightSetTrackedEntity),this._world.final("LIGHT.SET_TRACKED_POSITION",this._onLightSetTrackedPosition),this._world.final("LIGHT.SPAWN",this._onLightSpawn)}_subscribeToPlayerEvents(){this._world.final("PLAYER.JOINED_WORLD",this._onPlayerJoinedWorld),this._world.final("PLAYER.LEFT_WORLD",this._onPlayerLeftWorld),this._world.final("PLAYER.REQUEST_SYNC",this._onPlayerRequestSync)}_subscribeToPlayerCameraEvents(){this._world.final("PLAYER_CAMERA.LOOK_AT_ENTITY",this._onPlayerCameraLookAtEntity),this._world.final("PLAYER_CAMERA.LOOK_AT_POSITION",this._onPlayerCameraLookAtPosition),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",this._onPlayerCameraSetAttachedToEntity),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",this._onPlayerCameraSetAttachedToPosition),this._world.final("PLAYER_CAMERA.SET_FILM_OFFSET",this._onPlayerCameraSetFilmOffset),this._world.final("PLAYER_CAMERA.SET_FORWARD_OFFSET",this._onPlayerCameraSetForwardOffset),this._world.final("PLAYER_CAMERA.SET_FOV",this._onPlayerCameraSetFov),this._world.final("PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",this._onPlayerCameraSetModelHiddenNodes),this._world.final("PLAYER_CAMERA.SET_MODE",this._onPlayerCameraSetMode),this._world.final("PLAYER_CAMERA.SET_OFFSET",this._onPlayerCameraSetOffset),this._world.final("PLAYER_CAMERA.SET_TRACKED_ENTITY",this._onPlayerCameraSetTrackedEntity),this._world.final("PLAYER_CAMERA.SET_TRACKED_POSITION",this._onPlayerCameraSetTrackedPosition),this._world.final("PLAYER_CAMERA.SET_ZOOM",this._onPlayerCameraSetZoom)}_subscribeToPlayerUIEvents(){this._world.final("PLAYER_UI.LOAD",this._onPlayerUILoad),this._world.final("PLAYER_UI.LOCK_POINTER",this._onPlayerUILockPointer),this._world.final("PLAYER_UI.SEND_DATA",this._onPlayerUISendData)}_subscribeToSceneUIEvents(){this._world.final("SCENE_UI.LOAD",this._onSceneUILoad),this._world.final("SCENE_UI.SET_ATTACHED_TO_ENTITY",this._onSceneUISetAttachedToEntity),this._world.final("SCENE_UI.SET_OFFSET",this._onSceneUISetOffset),this._world.final("SCENE_UI.SET_POSITION",this._onSceneUISetPosition),this._world.final("SCENE_UI.SET_STATE",this._onSceneUISetState),this._world.final("SCENE_UI.SET_VIEW_DISTANCE",this._onSceneUISetViewDistance),this._world.final("SCENE_UI.UNLOAD",this._onSceneUIUnload)}_subscribeToSimulationEvents(){this._world.final("SIMULATION.DEBUG_RAYCAST",this._onSimulationDebugRaycast),this._world.final("SIMULATION.DEBUG_RENDER",this._onSimulationDebugRender)}_subscribeToWorldEvents(){this._world.final("WORLD.SET_AMBIENT_LIGHT_COLOR",this._onWorldSetAmbientLightColor),this._world.final("WORLD.SET_AMBIENT_LIGHT_INTENSITY",this._onWorldSetAmbientLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",this._onWorldSetDirectionalLightColor),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",this._onWorldSetDirectionalLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",this._onWorldSetDirectionalLightPosition)}_onAudioPause=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pa=!0,delete Z.pl,delete Z.r};_onAudioPlay=(J)=>{let Z=J.audio.serialize();Z.pl=!0,delete Z.pa,delete Z.r,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioPlayRestart=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.r=!0,delete Z.pa,delete Z.pl,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onAudioSetDetune=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.de=J.detune};_onAudioSetDistortion=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.di=J.distortion};_onAudioSetPosition=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.position?void 0:Z.e,Z.p=J.position?e.serializeVector(J.position):void 0};_onAudioSetPlaybackRate=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pr=J.playbackRate};_onAudioSetReferenceDistance=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.rd=J.referenceDistance};_onAudioSetVolume=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.v=J.volume};_onBlockTypeRegistryRegisterBlockType=(J)=>{let Z=J.blockType.serialize();this._queuedBlockTypeSynchronizations[J.blockType.id]=Z};_onChatSendBroadcastMessage=(J)=>{let{player:Z,message:Y,color:X}=J;this._queuedBroadcasts.push(g.createPacket(g.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X,p:Z?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(J)=>{let{player:Z,message:Y,color:X}=J,K=this._queuedPerPlayerSynchronizations.get(Z)??[];K.push(g.createPacket(g.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X}],this._world.loop.currentTick)),this._queuedPerPlayerSynchronizations.set(Z,K)};_onChunkSpawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk);Z.b=Array.from(J.chunk.blocks),Z.rm=void 0,this._spawnedChunks.add(Z.c.join(","))};_onChunkDespawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk),Y=Z.c.join(",");if(this._spawnedChunks.has(Y))delete this._queuedChunkSynchronizations[Y],this._spawnedChunks.delete(Y);else Z.rm=!0};_onChunkSetBlock=(J)=>{let Z=this._createOrGetQueuedBlockSync(J.globalCoordinate);Z.i=J.blockTypeId};_onEntitySetModelAnimationsPlaybackRate=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.ap=J.playbackRate};_onEntitySpawn=(J)=>{let Z=J.entity.serialize();this._queuedEntitySynchronizations[Z.i]=Z,this._spawnedEntities.add(Z.i)};_onEntityDespawn=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(this._spawnedEntities.has(Z.i))delete this._queuedEntitySynchronizations[Z.i],this._spawnedEntities.delete(Z.i);else Z.rm=!0};_onEntitySetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.h=Array.from(J.modelHiddenNodes)};_onEntitySetOpacity=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.o=J.opacity};_onEntitySetParent=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.pe=J.parent?J.parent.id:void 0,Z.pn=J.parentNodeName};_onEntitySetTintColor=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.t=J.tintColor?e.serializeRgbColor(J.tintColor):void 0};_onEntityStartModelLoopedAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al=Array.from(new Set([...Z.al??[],...J.animations])),Z.as)Z.as=Z.as.filter((Y)=>!J.animations.has(Y)).filter(Boolean)};_onEntityStartModelOneshotAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.ao=Array.from(new Set([...Z.ao??[],...J.animations])),Z.as)Z.as=Z.as.filter((Y)=>!J.animations.has(Y)).filter(Boolean)};_onEntityStopModelAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al)Z.al=Z.al.filter((Y)=>!J.animations.has(Y)).filter(Boolean);if(Z.ao)Z.ao=Z.ao.filter((Y)=>!J.animations.has(Y)).filter(Boolean);Z.as=Array.from(new Set([...Z.as??[],...J.animations]))};_onEntityUpdateRotation=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.r=[J.rotation.x,J.rotation.y,J.rotation.z,J.rotation.w]};_onEntityUpdatePosition=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.p=[J.position.x,J.position.y,J.position.z]};_onLightDespawn=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.rm=!0};_onLightSetAngle=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.a=J.angle};_onLightSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onLightSetColor=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.c=e.serializeRgbColor(J.color)};_onLightSetDistance=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.d=J.distance};_onLightSetIntensity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.n=J.intensity};_onLightSetOffset=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.o=J.offset?e.serializeVector(J.offset):void 0};_onLightSetPenumbra=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.pe=J.penumbra};_onLightSetPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.p=J.position?e.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onLightSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.te=J.entity?J.entity.id:void 0,Z.tp=J.entity?void 0:Z.tp};_onLightSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.tp=J.position?e.serializeVector(J.position):void 0,Z.te=J.position?void 0:Z.te};_onLightSpawn=(J)=>{let Z=J.light.serialize();this._queuedLightSynchronizations[Z.i]=Z};_onPlayerCameraLookAtEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=e.serializeVector(J.entity.position),delete Z.et,delete Z.pt};_onPlayerCameraLookAtPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=J.position?e.serializeVector(J.position):void 0,delete Z.et,delete Z.pt};_onPlayerCameraSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.e=J.entity.id,delete Z.p};_onPlayerCameraSetAttachedToPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.p=J.position?e.serializeVector(J.position):void 0,delete Z.e};_onPlayerCameraSetFilmOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fo=J.filmOffset};_onPlayerCameraSetForwardOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.ffo=J.forwardOffset};_onPlayerCameraSetFov=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fv=J.fov};_onPlayerCameraSetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.h=Array.from(J.modelHiddenNodes)};_onPlayerCameraSetMode=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.m=J.mode};_onPlayerCameraSetOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.o=J.offset?e.serializeVector(J.offset):void 0};_onPlayerCameraSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.et=J.entity?J.entity.id:void 0,delete Z.pl,delete Z.pt};_onPlayerCameraSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pt=J.position?e.serializeVector(J.position):void 0,delete Z.et,delete Z.pl};_onPlayerCameraSetZoom=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.z=J.zoom};_onPlayerJoinedWorld=(J)=>{let{player:Z}=J,Y=this._queuedPerPlayerSynchronizations.get(Z)??[];Y.push(g.createPacket(g.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map((K)=>{if(Z.camera.attachedToEntity===void 0&&K instanceof i1&&K.player===Z)Z.camera.setAttachedToEntity(K);return K.serialize()}),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllAudios().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.playersPacketDefinition,Y8.instance.getConnectedPlayers().map((K)=>K.serialize()),this._world.loop.currentTick));let X=this._createOrGetQueuedPlayerCameraSync(Z.camera);this._queuedPerPlayerCameraSynchronizations.set(Z,{...Z.camera.serialize(),...X}),this._queuedPerPlayerSynchronizations.set(Z,Y),this._queuedPlayerSynchronizations[Z.id]=Z.serialize()};_onPlayerLeftWorld=(J)=>{let Z=this._createOrGetQueuedPlayerSync(J.player);Z.rm=!0};_onPlayerRequestSync=(J)=>{J.player.connection.send(g.createPacket(g.outboundPackets.syncResponsePacketDefinition,{r:J.receivedAt,s:Date.now(),p:performance.now()-J.receivedAtMs,n:this._world.loop.nextTickMs},this._world.loop.currentTick))};_onPlayerUILoad=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.u=J.htmlUri};_onPlayerUILockPointer=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.p=J.lock};_onPlayerUISendData=(J)=>{this._createOrGetQueuedPlayerUIDatasSync(J.playerUI).push(J.data)};_onSceneUILoad=(J)=>{let Z=J.sceneUI.serialize();this._queuedSceneUISynchronizations[Z.i]=Z,this._loadedSceneUIs.add(Z.i)};_onSceneUISetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onSceneUISetOffset=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.o=J.offset?e.serializeVector(J.offset):void 0};_onSceneUISetPosition=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.p=J.position?e.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onSceneUISetState=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.s=J.state};_onSceneUISetViewDistance=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.v=J.viewDistance};_onSceneUIUnload=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);if(this._loadedSceneUIs.has(Z.i))delete this._queuedSceneUISynchronizations[Z.i],this._loadedSceneUIs.delete(Z.i);else Z.rm=!0};_onSimulationDebugRaycast=(J)=>{this._queuedDebugRaycastSynchronizations.push(e.serializePhysicsDebugRaycast(J))};_onSimulationDebugRender=(J)=>{this._queuedBroadcasts.push(g.createPacket(g.outboundPackets.physicsDebugRenderPacketDefinition,{v:Array.from(J.vertices),c:Array.from(J.colors)},this._world.loop.currentTick))};_onWorldSetAmbientLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ac=e.serializeRgbColor(J.color)};_onWorldSetAmbientLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ai=J.intensity};_onWorldSetDirectionalLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dc=e.serializeRgbColor(J.color)};_onWorldSetDirectionalLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.di=J.intensity};_onWorldSetDirectionalLightPosition=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dp=e.serializeVector(J.position)};_createOrGetQueuedAudioSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");return this._queuedAudioSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedBlockSync(J){let{x:Z,y:Y,z:X}=J;return this._queuedBlockSynchronizations[`${Z},${Y},${X}`]??={i:0,c:[Z,Y,X]}}_createOrGetQueuedChunkSync(J){if(!J.originCoordinate)_.fatalError("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:Z,y:Y,z:X}=J.originCoordinate;return this._queuedChunkSynchronizations[`${Z},${Y},${X}`]??={c:[Z,Y,X]}}_createOrGetQueuedEntitySync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");return this._queuedEntitySynchronizations[J.id]??={i:J.id}}_createOrGetQueuedLightSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");return this._queuedLightSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedPlayerSync(): Player has no id!");return this._queuedPlayerSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerCameraSync(J){let Z=this._queuedPerPlayerCameraSynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerCameraSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUISync(J){let Z=this._queuedPerPlayerUISynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerUISynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUIDatasSync(J){let Z=this._queuedPerPlayerUIDatasSynchronizations.get(J.player);if(!Z)Z=[],this._queuedPerPlayerUIDatasSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedSceneUISync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");return this._queuedSceneUISynchronizations[J.id]??={i:J.id}}_createOrGetQueuedWorldSync(J){if(J.id!==this._world.id)_.fatalError("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:J.id}}}class SJ{_sceneUIs=new Map;_nextSceneUIId=1;_world;constructor(J){this._world=J}get world(){return this._world}getAllSceneUIs(){return Array.from(this._sceneUIs.values())}getAllEntityAttachedSceneUIs(J){return this.getAllSceneUIs().filter((Z)=>Z.attachedToEntity===J)}getSceneUIById(J){return this._sceneUIs.get(J)}registerSceneUI(J){if(J.id!==void 0)return J.id;let Z=this._nextSceneUIId;return this._sceneUIs.set(Z,J),this._nextSceneUIId++,Z}unloadEntityAttachedSceneUIs(J){this.getAllEntityAttachedSceneUIs(J).forEach((Z)=>{Z.unload()})}unregisterSceneUI(J){if(J.id===void 0)return;this._sceneUIs.delete(J.id)}}class IJ{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(J,Z,Y){this._targetTicksPerSecond=J,this._fixedTimestepS=Math.fround(1/J),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._tickFunction=Z,this._tickErrorCallback=Y}get targetTicksPerSecond(){return this._targetTicksPerSecond}get fixedTimestepMs(){return this._fixedTimestepMs}get fixedTimestepS(){return this._fixedTimestepS}get nextTickMs(){return this._nextTickMs}start(){if(this._tickHandle)return _.warning("Ticker.start(): ticker already running.");this._lastLoopTimeMs=performance.now();let J=()=>{let Z=performance.now(),Y=Z-this._lastLoopTimeMs;if(this._lastLoopTimeMs=Z,Y>250)Y=250;this._accumulatorMs+=Y;while(this._accumulatorMs>=this._fixedTimestepMs)this._tick(this._fixedTimestepMs),this._accumulatorMs-=this._fixedTimestepMs;this._nextTickMs=this._fixedTimestepMs-this._accumulatorMs,this._tickHandle=setTimeout(J,0)};J()}stop(){if(!this._tickHandle)return _.warning("Ticker.stop(): ticker not running.");clearTimeout(this._tickHandle),this._tickHandle=null}_tick(J){try{this._tickFunction(J)}catch(Z){if(Z instanceof Error&&this._tickErrorCallback)this._tickErrorCallback(Z);else _.warning(`Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error: ${Z}`)}}}var zC;(($)=>{$.START="WORLD_LOOP.START";$.STOP="WORLD_LOOP.STOP";$.TICK_START="WORLD_LOOP.TICK_START";$.TICK_END="WORLD_LOOP.TICK_END";$.TICK_ERROR="WORLD_LOOP.TICK_ERROR"})(zC||={});class fJ extends s{_currentTick=0;_ticker;_world;constructor(J,Z=Qq){super();this._ticker=new IJ(Z,this._tick,this._onTickError),this._world=J}get currentTick(){return this._currentTick}get nextTickMs(){return this._ticker.nextTickMs}get timestepS(){return this._ticker.fixedTimestepS}get world(){return this._world}start(){this._ticker.start(),this.emitWithWorld(this._world,"WORLD_LOOP.START",{worldLoop:this})}stop(){this._ticker.stop(),this.emitWithWorld(this._world,"WORLD_LOOP.STOP",{worldLoop:this})}_tick=(J)=>{this.emitWithWorld(this._world,"WORLD_LOOP.TICK_START",{worldLoop:this,tickDeltaMs:J});let Z=performance.now();this._world.chunkLattice.updateChunks(),this._world.entityManager.tickEntities(J),this._world.simulation.step(J),this._world.entityManager.checkAndEmitUpdates(),this._world.networkSynchronizer.synchronize(),this._currentTick++,this.emitWithWorld(this._world,"WORLD_LOOP.TICK_END",{worldLoop:this,tickDurationMs:performance.now()-Z})};_onTickError=(J)=>{_.error(`WorldLoop._onTickError(): Error: ${J}`),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:J})}}var Gq;((F)=>{F.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";F.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";F.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";F.START="WORLD.START";F.STOP="WORLD.STOP"})(Gq||={});class hJ extends s{_id;_ambientLightColor;_ambientLightIntensity;_directionalLightColor;_directionalLightIntensity;_directionalLightPosition;_name;_skyboxUri;_audioManager;_blockTypeRegistry;_chatManager;_chunkLattice;_entityManager;_lightManager;_loop;_networkSynchronizer;_sceneUIManager;_simulation;constructor(J){super();this._id=J.id,this._ambientLightColor=J.ambientLightColor??{r:255,g:255,b:255},this._ambientLightIntensity=J.ambientLightIntensity??1,this._directionalLightColor=J.directionalLightColor??{r:255,g:255,b:255},this._directionalLightIntensity=J.directionalLightIntensity??3,this._directionalLightPosition=J.directionalLightPosition??{x:100,y:150,z:100},this._name=J.name,this._skyboxUri=J.skyboxUri,this._audioManager=new $4(this),this._blockTypeRegistry=new d4(this),this._chatManager=new bJ(this),this._chunkLattice=new BJ(this),this._entityManager=new xJ(this),this._lightManager=new TJ(this),this._loop=new fJ(this,J.tickRate),this._networkSynchronizer=new W$(this),this._sceneUIManager=new SJ(this),this._simulation=new CJ(this,J.tickRate,J.gravity)}get id(){return this._id}get ambientLightColor(){return this._ambientLightColor}get ambientLightIntensity(){return this._ambientLightIntensity}get directionalLightColor(){return this._directionalLightColor}get directionalLightIntensity(){return this._directionalLightIntensity}get directionalLightPosition(){return this._directionalLightPosition}get name(){return this._name}get skyboxUri(){return this._skyboxUri}get audioManager(){return this._audioManager}get blockTypeRegistry(){return this._blockTypeRegistry}get chatManager(){return this._chatManager}get chunkLattice(){return this._chunkLattice}get entityManager(){return this._entityManager}get lightManager(){return this._lightManager}get loop(){return this._loop}get networkSynchronizer(){return this._networkSynchronizer}get sceneUIManager(){return this._sceneUIManager}get simulation(){return this._simulation}loadMap(J){if(J.blockTypes)for(let Z of J.blockTypes)this.blockTypeRegistry.registerGenericBlockType({id:Z.id,isLiquid:Z.isLiquid,name:Z.name,textureUri:Z.textureUri});if(J.blocks)for(let[Z,Y]of Object.entries(J.blocks)){let[X,K,$]=Z.split(",").map(Number);this.chunkLattice.setBlock({x:X,y:K,z:$},Y)}if(J.entities)for(let[Z,Y]of Object.entries(J.entities)){let[X,K,$]=Z.split(",").map(Number);new K8(Y).spawn(this,{x:X,y:K,z:$})}}setAmbientLightColor(J){this._ambientLightColor=J,this.emit("WORLD.SET_AMBIENT_LIGHT_COLOR",{world:this,color:J})}setAmbientLightIntensity(J){this._ambientLightIntensity=J,this.emit("WORLD.SET_AMBIENT_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightColor(J){this._directionalLightColor=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",{world:this,color:J})}setDirectionalLightIntensity(J){this._directionalLightIntensity=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightPosition(J){this._directionalLightPosition=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",{world:this,position:J})}start(){this._loop.start(),this.emit("WORLD.START",{world:this,startedAtMs:Date.now()})}stop(){this._loop.stop(),this.emit("WORLD.STOP",{world:this,stoppedAtMs:Date.now()})}serialize(){return e.serializeWorld(this)}}var HC;((Y)=>{Y.START="GAMESERVER.START";Y.STOP="GAMESERVER.STOP"})(HC||={});function xZ0(J){H0.init().then(()=>{return w1.instance.modelRegistry.preloadModels()}).then(()=>{J(w1.instance.worlds[0]),w1.instance.start()}).catch((Z)=>{_.fatalError(`Failed to initialize the game engine, exiting. Error: ${Z}`)})}class w1{static _instance;_modelRegistry=M6.instance;_playerManager=Y8.instance;_socket=NJ.instance;_webServer=o5.instance;_worlds={};constructor(){let J=new hJ({id:0,name:"Default World",skyboxUri:"skyboxes/partly-cloudy"});this._worlds[J.id]=J}static get instance(){if(!this._instance)this._instance=new w1;return this._instance}get modelRegistry(){return this._modelRegistry}get playerManager(){return this._playerManager}get socket(){return this._socket}get webServer(){return this._webServer}get worlds(){return this._worlds}start(){l8.emit("GAMESERVER.START",{startedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.start()),this._webServer.start()}stop(){l8.emit("GAMESERVER.STOP",{stoppedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.stop())}}class h9{static instance=new h9;constructor(){}async getGlobalData(J){let Z=await u6.instance.getData(J);if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getGlobalData(): ${Z.error.message}`);return}return Z}async getPlayerData(J){let Z=await u6.instance.getData(this._getPlayerKey(J));if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getPlayerData(): ${Z.error.message}`);return}return Z}async setGlobalData(J,Z){let Y=await u6.instance.setData(J,Z);if(!Y||Y.error){if(Y?.error)_.warning(`PersistenceManager.setGlobalData(): ${Y.error.message}`);return}return Y}async setPlayerData(J,Z){let Y=await u6.instance.setData(this._getPlayerKey(J),Z);if(!Y||Y.error){if(Y?.error)_.warning(`PersistenceManager.setPlayerData(): ${Y.error.message}`);return}return Y}_getPlayerKey(J){return`player-${J.id}`}}var LC=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","1","2","3","4","5","6","7","8","9","0"],kJ;((K)=>{K.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";K.JOINED_WORLD="PLAYER.JOINED_WORLD";K.LEFT_WORLD="PLAYER.LEFT_WORLD";K.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(kJ||={});class w5 extends s{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_world;constructor(J,Z){super();this.id=Z?.user.id??`player-${w5._devNextPlayerId++}`,this.username=Z?.user.username??this.id,this.profilePictureUrl=Z?.user.profilePictureURL??void 0,this.camera=new DJ(this),this.connection=J,this.ui=new _J(this),J.onPacket(g.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),J.onPacket(g.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),J.onPacket(g.PacketId.INPUT,this._onInputPacket),J.onPacket(g.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),J.onPacket(g.PacketId.UI_DATA_SEND,this._onUIDataSendPacket),this.joinWorld(w1.instance.worlds[0])}get input(){return this._input}get world(){return this._world}disconnect(){this.leaveWorld(),this.connection.close()}async getPersistedData(){return h9.instance.getPlayerData(this)}joinWorld(J){this.leaveWorld(),this._world=J,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}async setPersistedData(J){return h9.instance.setPlayerData(this,J)}serialize(){return e.serializePlayer(this)}_onChatMessageSendPacket=(J)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:J[1].m})};_onDebugConfigPacket=(J)=>{console.log(J)};_onInputPacket=(J)=>{let Z=J[1];if(LC.forEach((Y)=>{let X=Y;if(Z[X]!==void 0)this._input[X]=Boolean(Z[X])}),Z.cp!==void 0)this.camera.setOrientationPitch(Z.cp);if(Z.cy!==void 0)this.camera.setOrientationYaw(Z.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(J)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:J[1]})}}var Wq;((Y)=>{Y.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";Y.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(Wq||={});class bJ extends s{_commandCallbacks={};_world;constructor(J){super();this._world=J,this._subscribeToPlayerEvents()}registerCommand(J,Z){this._commandCallbacks[J]=Z}unregisterCommand(J){delete this._commandCallbacks[J]}sendBroadcastMessage(J,Z){this._sendBroadcastMessage(void 0,J,Z)}sendPlayerMessage(J,Z,Y){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:J,message:Z,color:Y})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(J)=>{let{player:Z,message:Y}=J,[X,...K]=Y.split(" "),$=this._commandCallbacks[X];if($){$(Z,K,Y);return}this._sendBroadcastMessage(Z,`${Z.username}: ${Y}`)})}_sendBroadcastMessage(J,Z,Y){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:J,message:Z,color:Y})}}var l=0.000001,F0=typeof Float32Array!=="undefined"?Float32Array:Array,d6=Math.random;var CD0=Math.PI/180;if(!Math.hypot)Math.hypot=function(){var J=0,Z=arguments.length;while(Z--)J+=arguments[Z]*arguments[Z];return Math.sqrt(J)};var J8={};s6(J8,{transpose:()=>IZ0,subtract:()=>MC,sub:()=>oZ0,str:()=>cZ0,set:()=>SZ0,scale:()=>AZ0,rotate:()=>pZ0,multiplyScalarAndAdd:()=>aZ0,multiplyScalar:()=>nZ0,multiply:()=>UC,mul:()=>sZ0,invert:()=>fZ0,identity:()=>EZ0,fromValues:()=>CZ0,fromScaling:()=>gZ0,fromRotation:()=>yZ0,frob:()=>mZ0,exactEquals:()=>dZ0,equals:()=>iZ0,determinant:()=>bZ0,create:()=>TZ0,copy:()=>_Z0,clone:()=>DZ0,adjoint:()=>hZ0,add:()=>uZ0,LDU:()=>lZ0});function TZ0(){var J=new F0(4);if(F0!=Float32Array)J[1]=0,J[2]=0;return J[0]=1,J[3]=1,J}function DZ0(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function _Z0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function EZ0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=1,J}function CZ0(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function SZ0(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function IZ0(J,Z){if(J===Z){var Y=Z[1];J[1]=Z[2],J[2]=Y}else J[0]=Z[0],J[1]=Z[2],J[2]=Z[1],J[3]=Z[3];return J}function fZ0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*$-K*X;if(!Q)return null;return Q=1/Q,J[0]=$*Q,J[1]=-X*Q,J[2]=-K*Q,J[3]=Y*Q,J}function hZ0(J,Z){var Y=Z[0];return J[0]=Z[3],J[1]=-Z[1],J[2]=-Z[2],J[3]=Y,J}function bZ0(J){return J[0]*J[3]-J[2]*J[1]}function UC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*F+$*G,J[1]=K*F+Q*G,J[2]=X*W+$*V,J[3]=K*W+Q*V,J}function pZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+$*F,J[1]=K*G+Q*F,J[2]=X*-F+$*G,J[3]=K*-F+Q*G,J}function AZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1];return J[0]=X*F,J[1]=K*F,J[2]=$*G,J[3]=Q*G,J}function yZ0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=-Y,J[3]=X,J}function gZ0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=Z[1],J}function cZ0(J){return"mat2("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}function mZ0(J){return Math.hypot(J[0],J[1],J[2],J[3])}function lZ0(J,Z,Y,X){return J[2]=X[2]/X[0],Y[0]=X[0],Y[1]=X[1],Y[3]=X[3]-J[2]*Y[1],[J,Z,Y]}function uZ0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function MC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J}function dZ0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function iZ0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}function nZ0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function aZ0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J}var sZ0=UC,oZ0=MC;var f0={};s6(f0,{transpose:()=>XY0,translate:()=>FY0,subtract:()=>wC,sub:()=>kY0,str:()=>RY0,set:()=>ZY0,scale:()=>WY0,rotate:()=>GY0,projection:()=>MY0,normalFromMat4:()=>UY0,multiplyScalarAndAdd:()=>NY0,multiplyScalar:()=>PY0,multiply:()=>RC,mul:()=>jY0,invert:()=>KY0,identity:()=>YY0,fromValues:()=>JY0,fromTranslation:()=>VY0,fromScaling:()=>zY0,fromRotation:()=>qY0,fromQuat:()=>LY0,fromMat4:()=>rZ0,fromMat2d:()=>HY0,frob:()=>wY0,exactEquals:()=>BY0,equals:()=>vY0,determinant:()=>QY0,create:()=>Vq,copy:()=>eZ0,clone:()=>tZ0,adjoint:()=>$Y0,add:()=>OY0});function Vq(){var J=new F0(9);if(F0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[5]=0,J[6]=0,J[7]=0;return J[0]=1,J[4]=1,J[8]=1,J}function rZ0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[4],J[4]=Z[5],J[5]=Z[6],J[6]=Z[8],J[7]=Z[9],J[8]=Z[10],J}function tZ0(J){var Z=new F0(9);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z}function eZ0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function JY0(J,Z,Y,X,K,$,Q,F,G){var W=new F0(9);return W[0]=J,W[1]=Z,W[2]=Y,W[3]=X,W[4]=K,W[5]=$,W[6]=Q,W[7]=F,W[8]=G,W}function ZY0(J,Z,Y,X,K,$,Q,F,G,W){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J}function YY0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function XY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[5];J[1]=Z[3],J[2]=Z[6],J[3]=Y,J[5]=Z[7],J[6]=X,J[7]=K}else J[0]=Z[0],J[1]=Z[3],J[2]=Z[6],J[3]=Z[1],J[4]=Z[4],J[5]=Z[7],J[6]=Z[2],J[7]=Z[5],J[8]=Z[8];return J}function KY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=V*Q-F*W,z=-V*$+F*G,U=W*$-Q*G,M=Y*q+X*z+K*U;if(!M)return null;return M=1/M,J[0]=q*M,J[1]=(-V*X+K*W)*M,J[2]=(F*X-K*Q)*M,J[3]=z*M,J[4]=(V*Y-K*G)*M,J[5]=(-F*Y+K*$)*M,J[6]=U*M,J[7]=(-W*Y+X*G)*M,J[8]=(Q*Y-X*$)*M,J}function $Y0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8];return J[0]=Q*V-F*W,J[1]=K*W-X*V,J[2]=X*F-K*Q,J[3]=F*G-$*V,J[4]=Y*V-K*G,J[5]=K*$-Y*F,J[6]=$*W-Q*G,J[7]=X*G-Y*W,J[8]=Y*Q-X*$,J}function QY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8];return Z*(W*$-Q*G)+Y*(-W*K+Q*F)+X*(G*K-$*F)}function RC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Y[0],U=Y[1],M=Y[2],R=Y[3],L=Y[4],O=Y[5],N=Y[6],B=Y[7],v=Y[8];return J[0]=z*X+U*Q+M*W,J[1]=z*K+U*F+M*V,J[2]=z*$+U*G+M*q,J[3]=R*X+L*Q+O*W,J[4]=R*K+L*F+O*V,J[5]=R*$+L*G+O*q,J[6]=N*X+B*Q+v*W,J[7]=N*K+B*F+v*V,J[8]=N*$+B*G+v*q,J}function FY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Y[0],U=Y[1];return J[0]=X,J[1]=K,J[2]=$,J[3]=Q,J[4]=F,J[5]=G,J[6]=z*X+U*Q+W,J[7]=z*K+U*F+V,J[8]=z*$+U*G+q,J}function GY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Math.sin(Y),U=Math.cos(Y);return J[0]=U*X+z*Q,J[1]=U*K+z*F,J[2]=U*$+z*G,J[3]=U*Q-z*X,J[4]=U*F-z*K,J[5]=U*G-z*$,J[6]=W,J[7]=V,J[8]=q,J}function WY0(J,Z,Y){var X=Y[0],K=Y[1];return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*Z[2],J[3]=K*Z[3],J[4]=K*Z[4],J[5]=K*Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function VY0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=Z[0],J[7]=Z[1],J[8]=1,J}function qY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=-Y,J[4]=X,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function zY0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=Z[1],J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function HY0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=0,J[3]=Z[2],J[4]=Z[3],J[5]=0,J[6]=Z[4],J[7]=Z[5],J[8]=1,J}function LY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,z=K*Q,U=K*F,M=K*G,R=$*Q,L=$*F,O=$*G;return J[0]=1-q-M,J[3]=V-O,J[6]=z+L,J[1]=V+O,J[4]=1-W-M,J[7]=U-R,J[2]=z-L,J[5]=U+R,J[8]=1-W-q,J}function UY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],z=Z[10],U=Z[11],M=Z[12],R=Z[13],L=Z[14],O=Z[15],N=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,E=V*R-q*M,C=V*L-z*M,S=V*O-U*M,I=q*L-z*R,h=q*O-U*R,A=z*O-U*L,f=N*A-B*h+v*I+k*S-w*C+x*E;if(!f)return null;return f=1/f,J[0]=(F*A-G*h+W*I)*f,J[1]=(G*S-Q*A-W*C)*f,J[2]=(Q*h-F*S+W*E)*f,J[3]=(K*h-X*A-$*I)*f,J[4]=(Y*A-K*S+$*C)*f,J[5]=(X*S-Y*h-$*E)*f,J[6]=(R*x-L*w+O*k)*f,J[7]=(L*v-M*x-O*B)*f,J[8]=(M*w-R*v+O*N)*f,J}function MY0(J,Z,Y){return J[0]=2/Z,J[1]=0,J[2]=0,J[3]=0,J[4]=-2/Y,J[5]=0,J[6]=-1,J[7]=1,J[8]=1,J}function RY0(J){return"mat3("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+")"}function wY0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8])}function OY0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J}function wC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J}function PY0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J[4]=Z[4]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J}function NY0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J}function BY0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]}function vY0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=Z[0],z=Z[1],U=Z[2],M=Z[3],R=Z[4],L=Z[5],O=Z[6],N=Z[7],B=Z[8];return Math.abs(Y-q)<=l*Math.max(1,Math.abs(Y),Math.abs(q))&&Math.abs(X-z)<=l*Math.max(1,Math.abs(X),Math.abs(z))&&Math.abs(K-U)<=l*Math.max(1,Math.abs(K),Math.abs(U))&&Math.abs($-M)<=l*Math.max(1,Math.abs($),Math.abs(M))&&Math.abs(Q-R)<=l*Math.max(1,Math.abs(Q),Math.abs(R))&&Math.abs(F-L)<=l*Math.max(1,Math.abs(F),Math.abs(L))&&Math.abs(G-O)<=l*Math.max(1,Math.abs(G),Math.abs(O))&&Math.abs(W-N)<=l*Math.max(1,Math.abs(W),Math.abs(N))&&Math.abs(V-B)<=l*Math.max(1,Math.abs(V),Math.abs(B))}var jY0=RC,kY0=wC;var Y0={};s6(Y0,{transpose:()=>CY0,translate:()=>hY0,targetTo:()=>QX0,subtract:()=>kC,sub:()=>UX0,str:()=>FX0,set:()=>EY0,scale:()=>bY0,rotateZ:()=>gY0,rotateY:()=>yY0,rotateX:()=>AY0,rotate:()=>pY0,perspectiveZO:()=>ZX0,perspectiveNO:()=>vC,perspectiveFromFieldOfView:()=>YX0,perspective:()=>JX0,orthoZO:()=>KX0,orthoNO:()=>jC,ortho:()=>XX0,multiplyScalarAndAdd:()=>qX0,multiplyScalar:()=>VX0,multiply:()=>PC,mul:()=>LX0,lookAt:()=>$X0,invert:()=>SY0,identity:()=>OC,getTranslation:()=>aY0,getScaling:()=>BC,getRotation:()=>sY0,frustum:()=>eY0,fromZRotation:()=>iY0,fromYRotation:()=>dY0,fromXRotation:()=>uY0,fromValues:()=>_Y0,fromTranslation:()=>cY0,fromScaling:()=>mY0,fromRotationTranslationScaleOrigin:()=>rY0,fromRotationTranslationScale:()=>oY0,fromRotationTranslation:()=>NC,fromRotation:()=>lY0,fromQuat2:()=>nY0,fromQuat:()=>tY0,frob:()=>GX0,exactEquals:()=>zX0,equals:()=>HX0,determinant:()=>fY0,create:()=>xY0,copy:()=>DY0,clone:()=>TY0,adjoint:()=>IY0,add:()=>WX0});function xY0(){var J=new F0(16);if(F0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=0,J[12]=0,J[13]=0,J[14]=0;return J[0]=1,J[5]=1,J[10]=1,J[15]=1,J}function TY0(J){var Z=new F0(16);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z[9]=J[9],Z[10]=J[10],Z[11]=J[11],Z[12]=J[12],Z[13]=J[13],Z[14]=J[14],Z[15]=J[15],Z}function DY0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function _Y0(J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R){var L=new F0(16);return L[0]=J,L[1]=Z,L[2]=Y,L[3]=X,L[4]=K,L[5]=$,L[6]=Q,L[7]=F,L[8]=G,L[9]=W,L[10]=V,L[11]=q,L[12]=z,L[13]=U,L[14]=M,L[15]=R,L}function EY0(J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R,L){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J[9]=V,J[10]=q,J[11]=z,J[12]=U,J[13]=M,J[14]=R,J[15]=L,J}function OC(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function CY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[3],$=Z[6],Q=Z[7],F=Z[11];J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Y,J[6]=Z[9],J[7]=Z[13],J[8]=X,J[9]=$,J[11]=Z[14],J[12]=K,J[13]=Q,J[14]=F}else J[0]=Z[0],J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Z[1],J[5]=Z[5],J[6]=Z[9],J[7]=Z[13],J[8]=Z[2],J[9]=Z[6],J[10]=Z[10],J[11]=Z[14],J[12]=Z[3],J[13]=Z[7],J[14]=Z[11],J[15]=Z[15];return J}function SY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],z=Z[10],U=Z[11],M=Z[12],R=Z[13],L=Z[14],O=Z[15],N=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,E=V*R-q*M,C=V*L-z*M,S=V*O-U*M,I=q*L-z*R,h=q*O-U*R,A=z*O-U*L,f=N*A-B*h+v*I+k*S-w*C+x*E;if(!f)return null;return f=1/f,J[0]=(F*A-G*h+W*I)*f,J[1]=(K*h-X*A-$*I)*f,J[2]=(R*x-L*w+O*k)*f,J[3]=(z*w-q*x-U*k)*f,J[4]=(G*S-Q*A-W*C)*f,J[5]=(Y*A-K*S+$*C)*f,J[6]=(L*v-M*x-O*B)*f,J[7]=(V*x-z*v+U*B)*f,J[8]=(Q*h-F*S+W*E)*f,J[9]=(X*S-Y*h-$*E)*f,J[10]=(M*w-R*v+O*N)*f,J[11]=(q*v-V*w-U*N)*f,J[12]=(F*C-Q*I-G*E)*f,J[13]=(Y*I-X*C+K*E)*f,J[14]=(R*B-M*k-L*N)*f,J[15]=(V*k-q*B+z*N)*f,J}function IY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],z=Z[10],U=Z[11],M=Z[12],R=Z[13],L=Z[14],O=Z[15];return J[0]=F*(z*O-U*L)-q*(G*O-W*L)+R*(G*U-W*z),J[1]=-(X*(z*O-U*L)-q*(K*O-$*L)+R*(K*U-$*z)),J[2]=X*(G*O-W*L)-F*(K*O-$*L)+R*(K*W-$*G),J[3]=-(X*(G*U-W*z)-F*(K*U-$*z)+q*(K*W-$*G)),J[4]=-(Q*(z*O-U*L)-V*(G*O-W*L)+M*(G*U-W*z)),J[5]=Y*(z*O-U*L)-V*(K*O-$*L)+M*(K*U-$*z),J[6]=-(Y*(G*O-W*L)-Q*(K*O-$*L)+M*(K*W-$*G)),J[7]=Y*(G*U-W*z)-Q*(K*U-$*z)+V*(K*W-$*G),J[8]=Q*(q*O-U*R)-V*(F*O-W*R)+M*(F*U-W*q),J[9]=-(Y*(q*O-U*R)-V*(X*O-$*R)+M*(X*U-$*q)),J[10]=Y*(F*O-W*R)-Q*(X*O-$*R)+M*(X*W-$*F),J[11]=-(Y*(F*U-W*q)-Q*(X*U-$*q)+V*(X*W-$*F)),J[12]=-(Q*(q*L-z*R)-V*(F*L-G*R)+M*(F*z-G*q)),J[13]=Y*(q*L-z*R)-V*(X*L-K*R)+M*(X*z-K*q),J[14]=-(Y*(F*L-G*R)-Q*(X*L-K*R)+M*(X*G-K*F)),J[15]=Y*(F*z-G*q)-Q*(X*z-K*q)+V*(X*G-K*F),J}function fY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8],V=J[9],q=J[10],z=J[11],U=J[12],M=J[13],R=J[14],L=J[15],O=Z*Q-Y*$,N=Z*F-X*$,B=Z*G-K*$,v=Y*F-X*Q,k=Y*G-K*Q,w=X*G-K*F,x=W*M-V*U,E=W*R-q*U,C=W*L-z*U,S=V*R-q*M,I=V*L-z*M,h=q*L-z*R;return O*h-N*I+B*S+v*C-k*E+w*x}function PC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Z[9],U=Z[10],M=Z[11],R=Z[12],L=Z[13],O=Z[14],N=Z[15],B=Y[0],v=Y[1],k=Y[2],w=Y[3];return J[0]=B*X+v*F+k*q+w*R,J[1]=B*K+v*G+k*z+w*L,J[2]=B*$+v*W+k*U+w*O,J[3]=B*Q+v*V+k*M+w*N,B=Y[4],v=Y[5],k=Y[6],w=Y[7],J[4]=B*X+v*F+k*q+w*R,J[5]=B*K+v*G+k*z+w*L,J[6]=B*$+v*W+k*U+w*O,J[7]=B*Q+v*V+k*M+w*N,B=Y[8],v=Y[9],k=Y[10],w=Y[11],J[8]=B*X+v*F+k*q+w*R,J[9]=B*K+v*G+k*z+w*L,J[10]=B*$+v*W+k*U+w*O,J[11]=B*Q+v*V+k*M+w*N,B=Y[12],v=Y[13],k=Y[14],w=Y[15],J[12]=B*X+v*F+k*q+w*R,J[13]=B*K+v*G+k*z+w*L,J[14]=B*$+v*W+k*U+w*O,J[15]=B*Q+v*V+k*M+w*N,J}function hY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q,F,G,W,V,q,z,U,M,R,L,O;if(Z===J)J[12]=Z[0]*X+Z[4]*K+Z[8]*$+Z[12],J[13]=Z[1]*X+Z[5]*K+Z[9]*$+Z[13],J[14]=Z[2]*X+Z[6]*K+Z[10]*$+Z[14],J[15]=Z[3]*X+Z[7]*K+Z[11]*$+Z[15];else Q=Z[0],F=Z[1],G=Z[2],W=Z[3],V=Z[4],q=Z[5],z=Z[6],U=Z[7],M=Z[8],R=Z[9],L=Z[10],O=Z[11],J[0]=Q,J[1]=F,J[2]=G,J[3]=W,J[4]=V,J[5]=q,J[6]=z,J[7]=U,J[8]=M,J[9]=R,J[10]=L,J[11]=O,J[12]=Q*X+V*K+M*$+Z[12],J[13]=F*X+q*K+R*$+Z[13],J[14]=G*X+z*K+L*$+Z[14],J[15]=W*X+U*K+O*$+Z[15];return J}function bY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2];return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J[4]=Z[4]*K,J[5]=Z[5]*K,J[6]=Z[6]*K,J[7]=Z[7]*K,J[8]=Z[8]*$,J[9]=Z[9]*$,J[10]=Z[10]*$,J[11]=Z[11]*$,J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function pY0(J,Z,Y,X){var K=X[0],$=X[1],Q=X[2],F=Math.hypot(K,$,Q),G,W,V,q,z,U,M,R,L,O,N,B,v,k,w,x,E,C,S,I,h,A,f,c;if(F<l)return null;if(F=1/F,K*=F,$*=F,Q*=F,G=Math.sin(Y),W=Math.cos(Y),V=1-W,q=Z[0],z=Z[1],U=Z[2],M=Z[3],R=Z[4],L=Z[5],O=Z[6],N=Z[7],B=Z[8],v=Z[9],k=Z[10],w=Z[11],x=K*K*V+W,E=$*K*V+Q*G,C=Q*K*V-$*G,S=K*$*V-Q*G,I=$*$*V+W,h=Q*$*V+K*G,A=K*Q*V+$*G,f=$*Q*V-K*G,c=Q*Q*V+W,J[0]=q*x+R*E+B*C,J[1]=z*x+L*E+v*C,J[2]=U*x+O*E+k*C,J[3]=M*x+N*E+w*C,J[4]=q*S+R*I+B*h,J[5]=z*S+L*I+v*h,J[6]=U*S+O*I+k*h,J[7]=M*S+N*I+w*h,J[8]=q*A+R*f+B*c,J[9]=z*A+L*f+v*c,J[10]=U*A+O*f+k*c,J[11]=M*A+N*f+w*c,Z!==J)J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J}function AY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[4],Q=Z[5],F=Z[6],G=Z[7],W=Z[8],V=Z[9],q=Z[10],z=Z[11];if(Z!==J)J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[4]=$*K+W*X,J[5]=Q*K+V*X,J[6]=F*K+q*X,J[7]=G*K+z*X,J[8]=W*K-$*X,J[9]=V*K-Q*X,J[10]=q*K-F*X,J[11]=z*K-G*X,J}function yY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[8],V=Z[9],q=Z[10],z=Z[11];if(Z!==J)J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K-W*X,J[1]=Q*K-V*X,J[2]=F*K-q*X,J[3]=G*K-z*X,J[8]=$*X+W*K,J[9]=Q*X+V*K,J[10]=F*X+q*K,J[11]=G*X+z*K,J}function gY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[4],V=Z[5],q=Z[6],z=Z[7];if(Z!==J)J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K+W*X,J[1]=Q*K+V*X,J[2]=F*K+q*X,J[3]=G*K+z*X,J[4]=W*K-$*X,J[5]=V*K-Q*X,J[6]=q*K-F*X,J[7]=z*K-G*X,J}function cY0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=Z[0],J[13]=Z[1],J[14]=Z[2],J[15]=1,J}function mY0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=Z[1],J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=Z[2],J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function lY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Math.hypot(X,K,$),F,G,W;if(Q<l)return null;return Q=1/Q,X*=Q,K*=Q,$*=Q,F=Math.sin(Z),G=Math.cos(Z),W=1-G,J[0]=X*X*W+G,J[1]=K*X*W+$*F,J[2]=$*X*W-K*F,J[3]=0,J[4]=X*K*W-$*F,J[5]=K*K*W+G,J[6]=$*K*W+X*F,J[7]=0,J[8]=X*$*W+K*F,J[9]=K*$*W-X*F,J[10]=$*$*W+G,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function uY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=X,J[6]=Y,J[7]=0,J[8]=0,J[9]=-Y,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function dY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=0,J[2]=-Y,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=Y,J[9]=0,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function iY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=0,J[4]=-Y,J[5]=X,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function NC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=X+X,G=K+K,W=$+$,V=X*F,q=X*G,z=X*W,U=K*G,M=K*W,R=$*W,L=Q*F,O=Q*G,N=Q*W;return J[0]=1-(U+R),J[1]=q+N,J[2]=z-O,J[3]=0,J[4]=q-N,J[5]=1-(V+R),J[6]=M+L,J[7]=0,J[8]=z+O,J[9]=M-L,J[10]=1-(V+U),J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function nY0(J,Z){var Y=new F0(3),X=-Z[0],K=-Z[1],$=-Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=X*X+K*K+$*$+Q*Q;if(q>0)Y[0]=(F*Q+V*X+G*$-W*K)*2/q,Y[1]=(G*Q+V*K+W*X-F*$)*2/q,Y[2]=(W*Q+V*$+F*K-G*X)*2/q;else Y[0]=(F*Q+V*X+G*$-W*K)*2,Y[1]=(G*Q+V*K+W*X-F*$)*2,Y[2]=(W*Q+V*$+F*K-G*X)*2;return NC(J,Z,Y),J}function aY0(J,Z){return J[0]=Z[12],J[1]=Z[13],J[2]=Z[14],J}function BC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[4],Q=Z[5],F=Z[6],G=Z[8],W=Z[9],V=Z[10];return J[0]=Math.hypot(Y,X,K),J[1]=Math.hypot($,Q,F),J[2]=Math.hypot(G,W,V),J}function sY0(J,Z){var Y=new F0(3);BC(Y,Z);var X=1/Y[0],K=1/Y[1],$=1/Y[2],Q=Z[0]*X,F=Z[1]*K,G=Z[2]*$,W=Z[4]*X,V=Z[5]*K,q=Z[6]*$,z=Z[8]*X,U=Z[9]*K,M=Z[10]*$,R=Q+V+M,L=0;if(R>0)L=Math.sqrt(R+1)*2,J[3]=0.25*L,J[0]=(q-U)/L,J[1]=(z-G)/L,J[2]=(F-W)/L;else if(Q>V&&Q>M)L=Math.sqrt(1+Q-V-M)*2,J[3]=(q-U)/L,J[0]=0.25*L,J[1]=(F+W)/L,J[2]=(z+G)/L;else if(V>M)L=Math.sqrt(1+V-Q-M)*2,J[3]=(z-G)/L,J[0]=(F+W)/L,J[1]=0.25*L,J[2]=(q+U)/L;else L=Math.sqrt(1+M-Q-V)*2,J[3]=(F-W)/L,J[0]=(z+G)/L,J[1]=(q+U)/L,J[2]=0.25*L;return J}function oY0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=K+K,W=$+$,V=Q+Q,q=K*G,z=K*W,U=K*V,M=$*W,R=$*V,L=Q*V,O=F*G,N=F*W,B=F*V,v=X[0],k=X[1],w=X[2];return J[0]=(1-(M+L))*v,J[1]=(z+B)*v,J[2]=(U-N)*v,J[3]=0,J[4]=(z-B)*k,J[5]=(1-(q+L))*k,J[6]=(R+O)*k,J[7]=0,J[8]=(U+N)*w,J[9]=(R-O)*w,J[10]=(1-(q+M))*w,J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function rY0(J,Z,Y,X,K){var $=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=$+$,V=Q+Q,q=F+F,z=$*W,U=$*V,M=$*q,R=Q*V,L=Q*q,O=F*q,N=G*W,B=G*V,v=G*q,k=X[0],w=X[1],x=X[2],E=K[0],C=K[1],S=K[2],I=(1-(R+O))*k,h=(U+v)*k,A=(M-B)*k,f=(U-v)*w,c=(1-(z+O))*w,J0=(L+N)*w,A0=(M+B)*x,n0=(L-N)*x,G6=(1-(z+R))*x;return J[0]=I,J[1]=h,J[2]=A,J[3]=0,J[4]=f,J[5]=c,J[6]=J0,J[7]=0,J[8]=A0,J[9]=n0,J[10]=G6,J[11]=0,J[12]=Y[0]+E-(I*E+f*C+A0*S),J[13]=Y[1]+C-(h*E+c*C+n0*S),J[14]=Y[2]+S-(A*E+J0*C+G6*S),J[15]=1,J}function tY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,z=K*Q,U=K*F,M=K*G,R=$*Q,L=$*F,O=$*G;return J[0]=1-q-M,J[1]=V+O,J[2]=z-L,J[3]=0,J[4]=V-O,J[5]=1-W-M,J[6]=U+R,J[7]=0,J[8]=z+L,J[9]=U-R,J[10]=1-W-q,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function eY0(J,Z,Y,X,K,$,Q){var F=1/(Y-Z),G=1/(K-X),W=1/($-Q);return J[0]=$*2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$*2*G,J[6]=0,J[7]=0,J[8]=(Y+Z)*F,J[9]=(K+X)*G,J[10]=(Q+$)*W,J[11]=-1,J[12]=0,J[13]=0,J[14]=Q*$*2*W,J[15]=0,J}function vC(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(X-K),J[10]=(K+X)*Q,J[14]=2*K*X*Q;else J[10]=-1,J[14]=-2*X;return J}var JX0=vC;function ZX0(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(X-K),J[10]=K*Q,J[14]=K*X*Q;else J[10]=-1,J[14]=-X;return J}function YX0(J,Z,Y,X){var K=Math.tan(Z.upDegrees*Math.PI/180),$=Math.tan(Z.downDegrees*Math.PI/180),Q=Math.tan(Z.leftDegrees*Math.PI/180),F=Math.tan(Z.rightDegrees*Math.PI/180),G=2/(Q+F),W=2/(K+$);return J[0]=G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=W,J[6]=0,J[7]=0,J[8]=-((Q-F)*G*0.5),J[9]=(K-$)*W*0.5,J[10]=X/(Y-X),J[11]=-1,J[12]=0,J[13]=0,J[14]=X*Y/(Y-X),J[15]=0,J}function jC(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=2*W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=(Q+$)*W,J[15]=1,J}var XX0=jC;function KX0(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=$*W,J[15]=1,J}function $X0(J,Z,Y,X){var K,$,Q,F,G,W,V,q,z,U,M=Z[0],R=Z[1],L=Z[2],O=X[0],N=X[1],B=X[2],v=Y[0],k=Y[1],w=Y[2];if(Math.abs(M-v)<l&&Math.abs(R-k)<l&&Math.abs(L-w)<l)return OC(J);if(V=M-v,q=R-k,z=L-w,U=1/Math.hypot(V,q,z),V*=U,q*=U,z*=U,K=N*z-B*q,$=B*V-O*z,Q=O*q-N*V,U=Math.hypot(K,$,Q),!U)K=0,$=0,Q=0;else U=1/U,K*=U,$*=U,Q*=U;if(F=q*Q-z*$,G=z*K-V*Q,W=V*$-q*K,U=Math.hypot(F,G,W),!U)F=0,G=0,W=0;else U=1/U,F*=U,G*=U,W*=U;return J[0]=K,J[1]=F,J[2]=V,J[3]=0,J[4]=$,J[5]=G,J[6]=q,J[7]=0,J[8]=Q,J[9]=W,J[10]=z,J[11]=0,J[12]=-(K*M+$*R+Q*L),J[13]=-(F*M+G*R+W*L),J[14]=-(V*M+q*R+z*L),J[15]=1,J}function QX0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=X[0],G=X[1],W=X[2],V=K-Y[0],q=$-Y[1],z=Q-Y[2],U=V*V+q*q+z*z;if(U>0)U=1/Math.sqrt(U),V*=U,q*=U,z*=U;var M=G*z-W*q,R=W*V-F*z,L=F*q-G*V;if(U=M*M+R*R+L*L,U>0)U=1/Math.sqrt(U),M*=U,R*=U,L*=U;return J[0]=M,J[1]=R,J[2]=L,J[3]=0,J[4]=q*L-z*R,J[5]=z*M-V*L,J[6]=V*R-q*M,J[7]=0,J[8]=V,J[9]=q,J[10]=z,J[11]=0,J[12]=K,J[13]=$,J[14]=Q,J[15]=1,J}function FX0(J){return"mat4("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+", "+J[9]+", "+J[10]+", "+J[11]+", "+J[12]+", "+J[13]+", "+J[14]+", "+J[15]+")"}function GX0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8],J[9],J[10],J[11],J[12],J[13],J[14],J[15])}function WX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J[9]=Z[9]+Y[9],J[10]=Z[10]+Y[10],J[11]=Z[11]+Y[11],J[12]=Z[12]+Y[12],J[13]=Z[13]+Y[13],J[14]=Z[14]+Y[14],J[15]=Z[15]+Y[15],J}function kC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J[9]=Z[9]-Y[9],J[10]=Z[10]-Y[10],J[11]=Z[11]-Y[11],J[12]=Z[12]-Y[12],J[13]=Z[13]-Y[13],J[14]=Z[14]-Y[14],J[15]=Z[15]-Y[15],J}function VX0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J[4]=Z[4]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J[9]=Z[9]*Y,J[10]=Z[10]*Y,J[11]=Z[11]*Y,J[12]=Z[12]*Y,J[13]=Z[13]*Y,J[14]=Z[14]*Y,J[15]=Z[15]*Y,J}function qX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J[9]=Z[9]+Y[9]*X,J[10]=Z[10]+Y[10]*X,J[11]=Z[11]+Y[11]*X,J[12]=Z[12]+Y[12]*X,J[13]=Z[13]+Y[13]*X,J[14]=Z[14]+Y[14]*X,J[15]=Z[15]+Y[15]*X,J}function zX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]&&J[9]===Z[9]&&J[10]===Z[10]&&J[11]===Z[11]&&J[12]===Z[12]&&J[13]===Z[13]&&J[14]===Z[14]&&J[15]===Z[15]}function HX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=J[9],z=J[10],U=J[11],M=J[12],R=J[13],L=J[14],O=J[15],N=Z[0],B=Z[1],v=Z[2],k=Z[3],w=Z[4],x=Z[5],E=Z[6],C=Z[7],S=Z[8],I=Z[9],h=Z[10],A=Z[11],f=Z[12],c=Z[13],J0=Z[14],A0=Z[15];return Math.abs(Y-N)<=l*Math.max(1,Math.abs(Y),Math.abs(N))&&Math.abs(X-B)<=l*Math.max(1,Math.abs(X),Math.abs(B))&&Math.abs(K-v)<=l*Math.max(1,Math.abs(K),Math.abs(v))&&Math.abs($-k)<=l*Math.max(1,Math.abs($),Math.abs(k))&&Math.abs(Q-w)<=l*Math.max(1,Math.abs(Q),Math.abs(w))&&Math.abs(F-x)<=l*Math.max(1,Math.abs(F),Math.abs(x))&&Math.abs(G-E)<=l*Math.max(1,Math.abs(G),Math.abs(E))&&Math.abs(W-C)<=l*Math.max(1,Math.abs(W),Math.abs(C))&&Math.abs(V-S)<=l*Math.max(1,Math.abs(V),Math.abs(S))&&Math.abs(q-I)<=l*Math.max(1,Math.abs(q),Math.abs(I))&&Math.abs(z-h)<=l*Math.max(1,Math.abs(z),Math.abs(h))&&Math.abs(U-A)<=l*Math.max(1,Math.abs(U),Math.abs(A))&&Math.abs(M-f)<=l*Math.max(1,Math.abs(M),Math.abs(f))&&Math.abs(R-c)<=l*Math.max(1,Math.abs(R),Math.abs(c))&&Math.abs(L-J0)<=l*Math.max(1,Math.abs(L),Math.abs(J0))&&Math.abs(O-A0)<=l*Math.max(1,Math.abs(O),Math.abs(A0))}var LX0=PC,UX0=kC;var v0={};s6(v0,{str:()=>qK0,squaredLength:()=>JS,sqrLen:()=>PK0,sqlerp:()=>jK0,slerp:()=>H$,setAxisAngle:()=>iC,setAxes:()=>kK0,set:()=>UK0,scale:()=>rC,rotationTo:()=>vK0,rotateZ:()=>KK0,rotateY:()=>XK0,rotateX:()=>YK0,random:()=>FK0,pow:()=>QK0,normalize:()=>Lq,multiply:()=>nC,mul:()=>RK0,ln:()=>sC,lerp:()=>wK0,length:()=>eC,len:()=>OK0,invert:()=>GK0,identity:()=>eX0,getAxisAngle:()=>JK0,getAngle:()=>ZK0,fromValues:()=>HK0,fromMat3:()=>oC,fromEuler:()=>VK0,exp:()=>aC,exactEquals:()=>NK0,equals:()=>BK0,dot:()=>tC,create:()=>Hq,copy:()=>LK0,conjugate:()=>WK0,clone:()=>zK0,calculateW:()=>$K0,add:()=>MK0});var $0={};s6($0,{zero:()=>gX0,transformQuat:()=>hX0,transformMat4:()=>IX0,transformMat3:()=>fX0,subtract:()=>TC,sub:()=>uX0,str:()=>cX0,squaredLength:()=>SC,squaredDistance:()=>CC,sqrLen:()=>sX0,sqrDist:()=>aX0,set:()=>wX0,scaleAndAdd:()=>xX0,scale:()=>kX0,round:()=>jX0,rotateZ:()=>AX0,rotateY:()=>pX0,rotateX:()=>bX0,random:()=>SX0,normalize:()=>qq,negate:()=>TX0,multiply:()=>DC,mul:()=>dX0,min:()=>BX0,max:()=>vX0,lerp:()=>_X0,length:()=>xC,len:()=>zq,inverse:()=>DX0,hermite:()=>EX0,fromValues:()=>q$,forEach:()=>oX0,floor:()=>NX0,exactEquals:()=>mX0,equals:()=>lX0,dot:()=>z$,divide:()=>_C,div:()=>iX0,distance:()=>EC,dist:()=>nX0,cross:()=>pJ,create:()=>V$,copy:()=>RX0,clone:()=>MX0,ceil:()=>PX0,bezier:()=>CX0,angle:()=>yX0,add:()=>OX0});function V$(){var J=new F0(3);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J}function MX0(J){var Z=new F0(3);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function xC(J){var Z=J[0],Y=J[1],X=J[2];return Math.hypot(Z,Y,X)}function q$(J,Z,Y){var X=new F0(3);return X[0]=J,X[1]=Z,X[2]=Y,X}function RX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function wX0(J,Z,Y,X){return J[0]=Z,J[1]=Y,J[2]=X,J}function OX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J}function TC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J}function DC(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J[2]=Z[2]*Y[2],J}function _C(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J[2]=Z[2]/Y[2],J}function PX0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J[2]=Math.ceil(Z[2]),J}function NX0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J[2]=Math.floor(Z[2]),J}function BX0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J[2]=Math.min(Z[2],Y[2]),J}function vX0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J[2]=Math.max(Z[2],Y[2]),J}function jX0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J[2]=Math.round(Z[2]),J}function kX0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J}function xX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J}function EC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Math.hypot(Y,X,K)}function CC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Y*Y+X*X+K*K}function SC(J){var Z=J[0],Y=J[1],X=J[2];return Z*Z+Y*Y+X*X}function TX0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J}function DX0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J[2]=1/Z[2],J}function qq(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Y*Y+X*X+K*K;if($>0)$=1/Math.sqrt($);return J[0]=Z[0]*$,J[1]=Z[1]*$,J[2]=Z[2]*$,J}function z$(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]}function pJ(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[0],F=Y[1],G=Y[2];return J[0]=K*G-$*F,J[1]=$*Q-X*G,J[2]=X*F-K*Q,J}function _X0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J}function EX0(J,Z,Y,X,K,$){var Q=$*$,F=Q*(2*$-3)+1,G=Q*($-2)+$,W=Q*($-1),V=Q*(3-2*$);return J[0]=Z[0]*F+Y[0]*G+X[0]*W+K[0]*V,J[1]=Z[1]*F+Y[1]*G+X[1]*W+K[1]*V,J[2]=Z[2]*F+Y[2]*G+X[2]*W+K[2]*V,J}function CX0(J,Z,Y,X,K,$){var Q=1-$,F=Q*Q,G=$*$,W=F*Q,V=3*$*F,q=3*G*Q,z=G*$;return J[0]=Z[0]*W+Y[0]*V+X[0]*q+K[0]*z,J[1]=Z[1]*W+Y[1]*V+X[1]*q+K[1]*z,J[2]=Z[2]*W+Y[2]*V+X[2]*q+K[2]*z,J}function SX0(J,Z){Z=Z||1;var Y=d6()*2*Math.PI,X=d6()*2-1,K=Math.sqrt(1-X*X)*Z;return J[0]=Math.cos(Y)*K,J[1]=Math.sin(Y)*K,J[2]=X*Z,J}function IX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[3]*X+Y[7]*K+Y[11]*$+Y[15];return Q=Q||1,J[0]=(Y[0]*X+Y[4]*K+Y[8]*$+Y[12])/Q,J[1]=(Y[1]*X+Y[5]*K+Y[9]*$+Y[13])/Q,J[2]=(Y[2]*X+Y[6]*K+Y[10]*$+Y[14])/Q,J}function fX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2];return J[0]=X*Y[0]+K*Y[3]+$*Y[6],J[1]=X*Y[1]+K*Y[4]+$*Y[7],J[2]=X*Y[2]+K*Y[5]+$*Y[8],J}function hX0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Y[3],F=Z[0],G=Z[1],W=Z[2],V=K*W-$*G,q=$*F-X*W,z=X*G-K*F,U=K*z-$*q,M=$*V-X*z,R=X*q-K*V,L=Q*2;return V*=L,q*=L,z*=L,U*=2,M*=2,R*=2,J[0]=F+V+U,J[1]=G+q+M,J[2]=W+z+R,J}function bX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0],$[1]=K[1]*Math.cos(X)-K[2]*Math.sin(X),$[2]=K[1]*Math.sin(X)+K[2]*Math.cos(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function pX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[2]*Math.sin(X)+K[0]*Math.cos(X),$[1]=K[1],$[2]=K[2]*Math.cos(X)-K[0]*Math.sin(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function AX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0]*Math.cos(X)-K[1]*Math.sin(X),$[1]=K[0]*Math.sin(X)+K[1]*Math.cos(X),$[2]=K[2],J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function yX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2],G=Math.sqrt(Y*Y+X*X+K*K),W=Math.sqrt($*$+Q*Q+F*F),V=G*W,q=V&&z$(J,Z)/V;return Math.acos(Math.min(Math.max(q,-1),1))}function gX0(J){return J[0]=0,J[1]=0,J[2]=0,J}function cX0(J){return"vec3("+J[0]+", "+J[1]+", "+J[2]+")"}function mX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]}function lX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2];return Math.abs(Y-$)<=l*Math.max(1,Math.abs(Y),Math.abs($))&&Math.abs(X-Q)<=l*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(K-F)<=l*Math.max(1,Math.abs(K),Math.abs(F))}var uX0=TC,dX0=DC,iX0=_C,nX0=EC,aX0=CC,zq=xC,sX0=SC,oX0=function(){var J=V$();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=3;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2];return Z}}();function rX0(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0,J[3]=0;return J}function IC(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function fC(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function hC(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function bC(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function pC(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function AC(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function yC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Math.hypot(Z,Y,X,K)}function gC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Z*Z+Y*Y+X*X+K*K}function cC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$;if(Q>0)Q=1/Math.sqrt(Q);return J[0]=Y*Q,J[1]=X*Q,J[2]=K*Q,J[3]=$*Q,J}function mC(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]+J[3]*Z[3]}function lC(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J[3]=F+X*(Y[3]-F),J}function uC(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function dC(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}var SD0=function(){var J=rX0();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=4;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],J[3]=Z[F+3],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2],Z[F+3]=J[3];return Z}}();function Hq(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J[3]=1,J}function eX0(J){return J[0]=0,J[1]=0,J[2]=0,J[3]=1,J}function iC(J,Z,Y){Y=Y*0.5;var X=Math.sin(Y);return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*Z[2],J[3]=Math.cos(Y),J}function JK0(J,Z){var Y=Math.acos(Z[3])*2,X=Math.sin(Y/2);if(X>l)J[0]=Z[0]/X,J[1]=Z[1]/X,J[2]=Z[2]/X;else J[0]=1,J[1]=0,J[2]=0;return Y}function ZK0(J,Z){var Y=tC(J,Z);return Math.acos(2*Y*Y-1)}function nC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*V+Q*F+K*W-$*G,J[1]=K*V+Q*G+$*F-X*W,J[2]=$*V+Q*W+X*G-K*F,J[3]=Q*V-X*F-K*G-$*W,J}function YK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+Q*F,J[1]=K*G+$*F,J[2]=$*G-K*F,J[3]=Q*G-X*F,J}function XK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G-$*F,J[1]=K*G+Q*F,J[2]=$*G+X*F,J[3]=Q*G-K*F,J}function KK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+K*F,J[1]=K*G-X*F,J[2]=$*G+Q*F,J[3]=Q*G-$*F,J}function $K0(J,Z){var Y=Z[0],X=Z[1],K=Z[2];return J[0]=Y,J[1]=X,J[2]=K,J[3]=Math.sqrt(Math.abs(1-Y*Y-X*X-K*K)),J}function aC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Math.exp($),G=Q>0?F*Math.sin(Q)/Q:0;return J[0]=Y*G,J[1]=X*G,J[2]=K*G,J[3]=F*Math.cos(Q),J}function sC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Q>0?Math.atan2(Q,$)/Q:0;return J[0]=Y*F,J[1]=X*F,J[2]=K*F,J[3]=0.5*Math.log(Y*Y+X*X+K*K+$*$),J}function QK0(J,Z,Y){return sC(J,Z),rC(J,J,Y),aC(J,J),J}function H$(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=Y[0],W=Y[1],V=Y[2],q=Y[3],z,U,M,R,L;if(U=K*G+$*W+Q*V+F*q,U<0)U=-U,G=-G,W=-W,V=-V,q=-q;if(1-U>l)z=Math.acos(U),M=Math.sin(z),R=Math.sin((1-X)*z)/M,L=Math.sin(X*z)/M;else R=1-X,L=X;return J[0]=R*K+L*G,J[1]=R*$+L*W,J[2]=R*Q+L*V,J[3]=R*F+L*q,J}function FK0(J){var Z=d6(),Y=d6(),X=d6(),K=Math.sqrt(1-Z),$=Math.sqrt(Z);return J[0]=K*Math.sin(2*Math.PI*Y),J[1]=K*Math.cos(2*Math.PI*Y),J[2]=$*Math.sin(2*Math.PI*X),J[3]=$*Math.cos(2*Math.PI*X),J}function GK0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$,F=Q?1/Q:0;return J[0]=-Y*F,J[1]=-X*F,J[2]=-K*F,J[3]=$*F,J}function WK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J[3]=Z[3],J}function oC(J,Z){var Y=Z[0]+Z[4]+Z[8],X;if(Y>0)X=Math.sqrt(Y+1),J[3]=0.5*X,X=0.5/X,J[0]=(Z[5]-Z[7])*X,J[1]=(Z[6]-Z[2])*X,J[2]=(Z[1]-Z[3])*X;else{var K=0;if(Z[4]>Z[0])K=1;if(Z[8]>Z[K*3+K])K=2;var $=(K+1)%3,Q=(K+2)%3;X=Math.sqrt(Z[K*3+K]-Z[$*3+$]-Z[Q*3+Q]+1),J[K]=0.5*X,X=0.5/X,J[3]=(Z[$*3+Q]-Z[Q*3+$])*X,J[$]=(Z[$*3+K]+Z[K*3+$])*X,J[Q]=(Z[Q*3+K]+Z[K*3+Q])*X}return J}function VK0(J,Z,Y,X){var K=0.5*Math.PI/180;Z*=K,Y*=K,X*=K;var $=Math.sin(Z),Q=Math.cos(Z),F=Math.sin(Y),G=Math.cos(Y),W=Math.sin(X),V=Math.cos(X);return J[0]=$*G*V-Q*F*W,J[1]=Q*F*V+$*G*W,J[2]=Q*G*W-$*F*V,J[3]=Q*G*V+$*F*W,J}function qK0(J){return"quat("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}var zK0=IC,HK0=fC,LK0=hC,UK0=bC,MK0=pC,RK0=nC,rC=AC,tC=mC,wK0=lC,eC=yC,OK0=eC,JS=gC,PK0=JS,Lq=cC,NK0=uC,BK0=dC,vK0=function(){var J=V$(),Z=q$(1,0,0),Y=q$(0,1,0);return function(X,K,$){var Q=z$(K,$);if(Q<-0.999999){if(pJ(J,Z,K),zq(J)<0.000001)pJ(J,Y,K);return qq(J,J),iC(X,J,Math.PI),X}else if(Q>0.999999)return X[0]=0,X[1]=0,X[2]=0,X[3]=1,X;else return pJ(J,K,$),X[0]=J[0],X[1]=J[1],X[2]=J[2],X[3]=1+Q,Lq(X,X)}}(),jK0=function(){var J=Hq(),Z=Hq();return function(Y,X,K,$,Q,F){return H$(J,X,Q,F),H$(Z,K,$,F),H$(Y,J,Z,2*F*(1-F)),Y}}(),kK0=function(){var J=Vq();return function(Z,Y,X,K){return J[0]=X[0],J[3]=X[1],J[6]=X[2],J[1]=K[0],J[4]=K[1],J[7]=K[2],J[2]=-Y[0],J[5]=-Y[1],J[8]=-Y[2],Lq(Z,oC(Z,J))}}();var q0={};s6(q0,{zero:()=>rK0,transformMat4:()=>aK0,transformMat3:()=>nK0,transformMat2d:()=>iK0,transformMat2:()=>dK0,subtract:()=>YS,sub:()=>Y$0,str:()=>tK0,squaredLength:()=>GS,squaredDistance:()=>QS,sqrLen:()=>F$0,sqrDist:()=>Q$0,set:()=>_K0,scaleAndAdd:()=>pK0,scale:()=>bK0,round:()=>hK0,rotate:()=>sK0,random:()=>uK0,normalize:()=>gK0,negate:()=>AK0,multiply:()=>XS,mul:()=>X$0,min:()=>IK0,max:()=>fK0,lerp:()=>lK0,length:()=>FS,len:()=>Z$0,inverse:()=>yK0,fromValues:()=>TK0,forEach:()=>G$0,floor:()=>SK0,exactEquals:()=>eK0,equals:()=>J$0,dot:()=>cK0,divide:()=>KS,div:()=>K$0,distance:()=>$S,dist:()=>$$0,cross:()=>mK0,create:()=>ZS,copy:()=>DK0,clone:()=>xK0,ceil:()=>CK0,angle:()=>oK0,add:()=>EK0});function ZS(){var J=new F0(2);if(F0!=Float32Array)J[0]=0,J[1]=0;return J}function xK0(J){var Z=new F0(2);return Z[0]=J[0],Z[1]=J[1],Z}function TK0(J,Z){var Y=new F0(2);return Y[0]=J,Y[1]=Z,Y}function DK0(J,Z){return J[0]=Z[0],J[1]=Z[1],J}function _K0(J,Z,Y){return J[0]=Z,J[1]=Y,J}function EK0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J}function YS(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J}function XS(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J}function KS(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J}function CK0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J}function SK0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J}function IK0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J}function fK0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J}function hK0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J}function bK0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J}function pK0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J}function $S(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Math.hypot(Y,X)}function QS(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Y*Y+X*X}function FS(J){var Z=J[0],Y=J[1];return Math.hypot(Z,Y)}function GS(J){var Z=J[0],Y=J[1];return Z*Z+Y*Y}function AK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J}function yK0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J}function gK0(J,Z){var Y=Z[0],X=Z[1],K=Y*Y+X*X;if(K>0)K=1/Math.sqrt(K);return J[0]=Z[0]*K,J[1]=Z[1]*K,J}function cK0(J,Z){return J[0]*Z[0]+J[1]*Z[1]}function mK0(J,Z,Y){var X=Z[0]*Y[1]-Z[1]*Y[0];return J[0]=J[1]=0,J[2]=X,J}function lK0(J,Z,Y,X){var K=Z[0],$=Z[1];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J}function uK0(J,Z){Z=Z||1;var Y=d6()*2*Math.PI;return J[0]=Math.cos(Y)*Z,J[1]=Math.sin(Y)*Z,J}function dK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K,J[1]=Y[1]*X+Y[3]*K,J}function iK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K+Y[4],J[1]=Y[1]*X+Y[3]*K+Y[5],J}function nK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[3]*K+Y[6],J[1]=Y[1]*X+Y[4]*K+Y[7],J}function aK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[4]*K+Y[12],J[1]=Y[1]*X+Y[5]*K+Y[13],J}function sK0(J,Z,Y,X){var K=Z[0]-Y[0],$=Z[1]-Y[1],Q=Math.sin(X),F=Math.cos(X);return J[0]=K*F-$*Q+Y[0],J[1]=K*Q+$*F+Y[1],J}function oK0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1],Q=Math.sqrt(Y*Y+X*X)*Math.sqrt(K*K+$*$),F=Q&&(Y*K+X*$)/Q;return Math.acos(Math.min(Math.max(F,-1),1))}function rK0(J){return J[0]=0,J[1]=0,J}function tK0(J){return"vec2("+J[0]+", "+J[1]+")"}function eK0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]}function J$0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1];return Math.abs(Y-K)<=l*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs(X-$)<=l*Math.max(1,Math.abs(X),Math.abs($))}var Z$0=FS,Y$0=YS,X$0=XS,K$0=KS,$$0=$S,Q$0=QS,F$0=GS,G$0=function(){var J=ZS();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=2;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1];return Z}}();class p9 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get determinant(){return J8.determinant(this)}get frobeniusNorm(){return J8.frob(this)}static create(){let J=new p9(0,0,0,0);return J8.identity(J),J}static fromRotation(J){let Z=p9.create();return J8.fromRotation(Z,J),Z}static fromScaling(J){let Z=p9.create();return J8.fromScaling(Z,J),Z}add(J){return J8.add(this,this,J),this}adjoint(){return J8.adjoint(this,this),this}clone(){return new p9(this[0],this[1],this[2],this[3])}copy(J){return J8.copy(this,J),this}equals(J){return J8.equals(this,J)}exactEquals(J){return J8.exactEquals(this,J)}identity(){return J8.identity(this),this}invert(){return J8.invert(this,this),this}multiply(J){return J8.mul(this,this,J),this}multiplyScalar(J){return J8.multiplyScalar(this,this,J),this}rotate(J){return J8.rotate(this,this,J),this}subtract(J){return J8.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return J8.transpose(this,this),this}}class i6 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G){super([J,Z,Y,X,K,$,Q,F,G])}get determinant(){return f0.determinant(this)}get frobeniusNorm(){return f0.frob(this)}static create(){let J=new i6(0,0,0,0,0,0,0,0,0);return f0.identity(J),J}static fromMatrix4(J){let Z=i6.create();return f0.fromMat4(Z,J),Z}static fromQuaternion(J){let Z=i6.create();return f0.fromQuat(Z,J),Z}static fromRotation(J){let Z=i6.create();return f0.fromRotation(Z,J),Z}static fromScaling(J){let Z=i6.create();return f0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=i6.create();return f0.fromTranslation(Z,J),Z}add(J){return f0.add(this,this,J),this}adjoint(){return f0.adjoint(this,this),this}clone(){return new i6(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(J){return f0.copy(this,J),this}equals(J){return f0.equals(this,J)}exactEquals(J){return f0.exactEquals(this,J)}identity(){return f0.identity(this),this}invert(){return f0.invert(this,this),this}multiply(J){return f0.mul(this,this,J),this}multiplyScalar(J){return f0.multiplyScalar(this,this,J),this}transformVector(J){return J.transformMatrix3(this)}projection(J,Z){return f0.projection(this,J,Z),this}rotate(J){return f0.rotate(this,this,J),this}subtract(J){return f0.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]},${this[2]}][${this[3]},${this[4]},${this[5]}][${this[6]},${this[7]},${this[8]}]`}transpose(){return f0.transpose(this,this),this}}class C8 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R){super([J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R])}get determinant(){return Y0.determinant(this)}get frobeniusNorm(){return Y0.frob(this)}static create(){let J=new C8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return Y0.identity(J),J}static fromQuaternion(J){let Z=C8.create();return Y0.fromQuat(Z,J),Z}static fromRotation(J,Z){let Y=C8.create();return Y0.fromRotation(Y,J,Z),Y}static fromRotationTranslation(J,Z){let Y=C8.create();return Y0.fromRotationTranslation(Y,J,Z),Y}static fromRotationTranslationScale(J,Z,Y){let X=C8.create();return Y0.fromRotationTranslationScale(X,J,Z,Y),X}static fromRotationTranslationScaleOrigin(J,Z,Y,X){let K=C8.create();return Y0.fromRotationTranslationScaleOrigin(K,J,Z,Y,X),K}static fromScaling(J){let Z=C8.create();return Y0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=C8.create();return Y0.fromTranslation(Z,J),Z}static fromXRotation(J){let Z=C8.create();return Y0.fromXRotation(Z,J),Z}static fromYRotation(J){let Z=C8.create();return Y0.fromYRotation(Z,J),Z}static fromZRotation(J){let Z=C8.create();return Y0.fromZRotation(Z,J),Z}add(J){return Y0.add(this,this,J),this}adjoint(){return Y0.adjoint(this,this),this}clone(){return new C8(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8],this[9],this[10],this[11],this[12],this[13],this[14],this[15])}copy(J){return Y0.copy(this,J),this}equals(J){return Y0.equals(this,J)}exactEquals(J){return Y0.exactEquals(this,J)}frustrum(J,Z,Y,X,K,$){return Y0.frustum(this,J,Z,Y,X,K,$),this}identity(){return Y0.identity(this),this}invert(){return Y0.invert(this,this),this}lookAt(J,Z,Y){return Y0.lookAt(this,J,Z,Y),this}multiply(J){return Y0.mul(this,this,J),this}multiplyScalar(J){return Y0.multiplyScalar(this,this,J),this}orthographic(J,Z,Y,X,K,$){return Y0.ortho(this,J,Z,Y,X,K,$),this}perspective(J,Z,Y,X){return Y0.perspective(this,J,Z,Y,X),this}rotate(J,Z){return Y0.rotate(this,this,J,Z),this}rotateX(J){return Y0.rotateX(this,this,J),this}rotateY(J){return Y0.rotateY(this,this,J),this}rotateZ(J){return Y0.rotateZ(this,this,J),this}scale(J){return Y0.scale(this,this,J),this}subtract(J){return Y0.sub(this,this,J),this}targetTo(J,Z,Y){return Y0.targetTo(this,J,Z,Y),this}toString(){return`[${this[0]},${this[1]},${this[2]},${this[3]}][${this[4]},${this[5]},${this[6]},${this[7]}][${this[8]},${this[9]},${this[10]},${this[11]}][${this[12]},${this[13]},${this[14]},${this[15]}]`}translate(J){return Y0.translate(this,this,J),this}transpose(){return Y0.transpose(this,this),this}}class e5 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get length(){return v0.length(this)}get squaredLength(){return v0.squaredLength(this)}get magnitude(){return v0.length(this)}get squaredMagnitude(){return v0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}get w(){return this[3]}set w(J){this[3]=J}static fromEuler(J,Z,Y){let X=v0.fromEuler(new Float32Array(4),J,Z,Y);return new e5(X[0],X[1],X[2],X[3])}static fromQuaternionLike(J){return new e5(J.x,J.y,J.z,J.w)}clone(){return new e5(this.x,this.y,this.z,this.w)}conjugate(){return v0.conjugate(this,this),this}copy(J){return v0.copy(this,J),this}dot(J){return v0.dot(this,J)}exponential(){return v0.exp(this,this),this}equals(J){return v0.equals(this,J)}exactEquals(J){return v0.exactEquals(this,J)}getAngle(J){return v0.getAngle(this,J)}identity(){return v0.identity(this),this}invert(){return v0.invert(this,this),this}lerp(J,Z){return v0.lerp(this,this,J,Z),this}logarithm(){return v0.ln(this,this),this}multiply(J){return v0.multiply(this,this,J),this}transformVector(J){return J.transformQuaternion(this)}normalize(){return v0.normalize(this,this),this}power(J){return v0.pow(this,this,J),this}randomize(){return v0.random(this),this}rotateX(J){return v0.rotateX(this,this,J),this}rotateY(J){return v0.rotateY(this,this,J),this}rotateZ(J){return v0.rotateZ(this,this,J),this}scale(J){return v0.scale(this,this,J),this}setAxisAngle(J,Z){return v0.setAxisAngle(this,J,Z),this}slerp(J,Z){return v0.slerp(this,this,J,Z),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class AJ extends Float32Array{constructor(J,Z){super([J,Z])}get length(){return q0.length(this)}get squaredLength(){return q0.squaredLength(this)}get magnitude(){return q0.length(this)}get squaredMagnitude(){return q0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}static create(){return new AJ(0,0)}add(J){return q0.add(this,this,J),this}angle(J){return q0.angle(this,J)}ceil(){return q0.ceil(this,this),this}clone(){return new AJ(this.x,this.y)}copy(J){return q0.copy(this,J),this}distance(J){return q0.distance(this,J)}divide(J){return q0.divide(this,this,J),this}dot(J){return q0.dot(this,J)}equals(J){return q0.equals(this,J)}exactEquals(J){return q0.exactEquals(this,J)}floor(){return q0.floor(this,this),this}invert(){return q0.inverse(this,this),this}lerp(J,Z){return q0.lerp(this,this,J,Z),this}max(J){return q0.max(this,this,J),this}min(J){return q0.min(this,this,J),this}multiply(J){return q0.mul(this,this,J),this}negate(){return q0.negate(this,this),this}normalize(){return q0.normalize(this,this),this}randomize(J){return q0.random(this,J),this}rotate(J,Z){return q0.rotate(this,this,J,Z),this}round(){return q0.round(this,this),this}scale(J){return q0.scale(this,this,J),this}scaleAndAdd(J,Z){return q0.scaleAndAdd(this,this,J,Z),this}subtract(J){return q0.sub(this,this,J),this}toString(){return`${this.x},${this.y}`}transformMatrix2(J){return q0.transformMat2(this,this,J),this}transformMatrix3(J){return q0.transformMat3(this,this,J),this}transformMatrix4(J){return q0.transformMat4(this,this,J),this}zero(){return q0.zero(this),this}}class J4 extends Float32Array{constructor(J,Z,Y){super([J,Z,Y])}get length(){return $0.length(this)}get squaredLength(){return $0.squaredLength(this)}get magnitude(){return $0.length(this)}get squaredMagnitude(){return $0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}static create(){return new J4(0,0,0)}static fromVector3Like(J){return new J4(J.x,J.y,J.z)}add(J){return $0.add(this,this,J),this}ceil(){return $0.ceil(this,this),this}clone(){return new J4(this.x,this.y,this.z)}copy(J){return $0.copy(this,J),this}cross(J){return $0.cross(this,this,J),this}distance(J){return $0.distance(this,J)}divide(J){return $0.div(this,this,J),this}dot(J){return $0.dot(this,J)}equals(J){return $0.equals(this,J)}exactEquals(J){return $0.exactEquals(this,J)}floor(){return $0.floor(this,this),this}invert(){return $0.inverse(this,this),this}lerp(J,Z){return $0.lerp(this,this,J,Z),this}max(J){return $0.max(this,this,J),this}min(J){return $0.min(this,this,J),this}multiply(J){return $0.mul(this,this,J),this}negate(){return $0.negate(this,this),this}normalize(){return $0.normalize(this,this),this}randomize(J){return $0.random(this,J),this}rotateX(J,Z){return $0.rotateX(this,this,J,Z),this}rotateY(J,Z){return $0.rotateY(this,this,J,Z),this}rotateZ(J,Z){return $0.rotateZ(this,this,J,Z),this}round(){return $0.round(this,this),this}scale(J){return $0.scale(this,this,J),this}scaleAndAdd(J,Z){return $0.scaleAndAdd(this,this,J,Z),this}subtract(J){return $0.sub(this,this,J),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(J){return $0.transformMat3(this,this,J),this}transformMatrix4(J){return $0.transformMat4(this,this,J),this}transformQuaternion(J){return $0.transformQuat(this,this,J),this}zero(){return $0.zero(this),this}}var j0=function(J,Z,Y,X){function K($){return $ instanceof Y?$:new Y(function(Q){Q($)})}return new(Y||(Y=Promise))(function($,Q){function F(V){try{W(X.next(V))}catch(q){Q(q)}}function G(V){try{W(X.throw(V))}catch(q){Q(q)}}function W(V){V.done?$(V.value):K(V.value).then(F,G)}W((X=X.apply(J,Z||[])).next())})},B0=function(J,Z){var Y={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},X,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=F(0),Q.throw=F(1),Q.return=F(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function F(W){return function(V){return G([W,V])}}function G(W){if(X)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(Y=0)),Y)try{if(X=1,K&&($=W[0]&2?K.return:W[0]?K.throw||(($=K.return)&&$.call(K),0):K.next)&&!($=$.call(K,W[1])).done)return $;if(K=0,$)W=[W[0]&2,$.value];switch(W[0]){case 0:case 1:$=W;break;case 4:return Y.label++,{value:W[1],done:!1};case 5:Y.label++,K=W[1],W=[0];continue;case 7:W=Y.ops.pop(),Y.trys.pop();continue;default:if(($=Y.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){Y=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){Y.label=W[1];break}if(W[0]===6&&Y.label<$[1]){Y.label=$[1],$=W;break}if($&&Y.label<$[2]){Y.label=$[2],Y.ops.push(W);break}if($[2])Y.ops.pop();Y.trys.pop();continue}W=Z.call(J,Y)}catch(V){W=[6,V],K=0}finally{X=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},m8=function(J,Z){var Y=typeof Symbol==="function"&&J[Symbol.iterator];if(!Y)return J;var X=Y.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=X.next()).done)$.push(K.value)}catch(F){Q={error:F}}finally{try{if(K&&!K.done&&(Y=X.return))Y.call(X)}finally{if(Q)throw Q.error}}return $},F6=function(J,Z,Y){if(Y||arguments.length===2){for(var X=0,K=Z.length,$;X<K;X++)if($||!(X in Z)){if(!$)$=Array.prototype.slice.call(Z,0,X);$[X]=Z[X]}}return J.concat($||Array.prototype.slice.call(Z))},WS=function(J){var Z=typeof Symbol==="function"&&Symbol.iterator,Y=Z&&J[Z],X=0;if(Y)return Y.call(J);if(J&&typeof J.length==="number")return{next:function(){if(J&&X>=J.length)J=void 0;return{value:J&&J[X++],done:!J}}};throw new TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")},yD0=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var Y=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(X,K){return Y.compare(X,K).then(function($){return-1*$})}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:2;return Math.floor((Z-Y)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:-1;return Z+Y},J.minComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Z>Y)return[2,1];else if(Z<Y)return[2,-1];else return[2,0]})})},J.maxComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Y>Z)return[2,1];else if(Y<Z)return[2,-1];else return[2,0]})})},J.minComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z-Y]})})},J.maxComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Y-Z]})})},J.defaultIsEqual=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z===Y]})})},J.print=function(Z){function Y(V){var q=J.getParentIndexOf(V);return Math.floor(Math.log2(q+1))}function X(V,q){var z="";for(;q>0;--q)z+=V;return z}var K=0,$=[],Q=Y(Z.length-1)+2,F=0;while(K<Z.length){var G=Y(K)+1;if(K===0)G=0;var W=String(Z.get(K));if(W.length>F)F=W.length;$[G]=$[G]||[],$[G].push(W),K+=1}return $.map(function(V,q){var z=Math.pow(2,Q-q)-1;return X(" ",Math.floor(z/2)*F)+V.map(function(U){var M=(F-U.length)/2;return X(" ",Math.ceil(M))+U+X(" ",Math.floor(M))}).join(X(" ",z*F))}).join(`
385
+ `),Z.write($),Z.end();return}this.emitWithGlobal("WEBSERVER.UPGRADE",{req:J,socket:Z,head:Y})};_onError=(J)=>{this.emitWithGlobal("WEBSERVER.ERROR",{error:J})};_onStopped=()=>{this.emitWithGlobal("WEBSERVER.STOPPED",{})}}class NJ extends s{static instance=new NJ;_wss;constructor(){super();this._wss=new vZ0({noServer:!0}),this._wss.on("connection",this._onConnection),this._wss.on("error",this._onError),l8.on("WEBSERVER.UPGRADE",({req:J,socket:Z,head:Y})=>this._onUpgrade(J,Z,Y))}_onConnection=(J,Z)=>{new U9(J,Z)};_onError=(J,Z)=>{this.emitWithGlobal("SOCKET.ERROR",{ws:J,error:Z})};_onUpgrade=(J,Z,Y)=>{this._wss.handleUpgrade(J,Z,Y,(X)=>{this._wss.emit("connection",X,J)})}}var Q$;((K)=>{K.DYNAMIC="dynamic";K.FIXED="fixed";K.KINEMATIC_POSITION="kinematic_position";K.KINEMATIC_VELOCITY="kinematic_velocity"})(Q$||={});var Jq=0.001,$C="dynamic";class f9 extends s{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(J){super();J.type??=$C,this._rigidBodyDesc=this._createRigidBodyDesc(J),this._rigidBodyType=J.type,this._applyRigidBodyOptions(J),this._autoAddToSimulation(J)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:J,y:Z,z:Y,w:X}=this.rotation;return{x:2*(J*Y+X*Z),y:2*(Z*Y-X*J),z:1-2*(J*J+Z*Z)}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(J){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(J,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(J)}setAdditionalMassProperties(J){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:Z,centerOfMass:Y,principalAngularInertia:X,principalAngularInertiaLocalFrame:K}=J;this._rigidBody?this._rigidBody.setAdditionalMassProperties(Z,Y,X,K,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(Z,Y,X,K)}setAdditionalSolverIterations(J){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(J):this._rigidBodyDesc.setAdditionalSolverIterations(J)}setAngularDamping(J){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(J):this._rigidBodyDesc.setAngularDamping(J)}setAngularVelocity(J){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(J,!this._explicitSleep):this._rigidBodyDesc.setAngvel(J)}setCcdEnabled(J){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(J):this._rigidBodyDesc.setCcdEnabled(J)}setDominanceGroup(J){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(J):this._rigidBodyDesc.setDominanceGroup(J)}setEnabled(J){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(J):this._rigidBodyDesc.setEnabled(J)}setEnabledPositions(J){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(J.x,J.y,J.z),this._enabledPositions=J}setEnabledRotations(J){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(J.x,J.y,J.z),this._enabledRotations=J}setGravityScale(J){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(J,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(J)}setLinearDamping(J){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(J):this._rigidBodyDesc.setLinearDamping(J)}setLinearVelocity(J){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(J,!this._explicitSleep):this._rigidBodyDesc.setLinvel(J.x,J.y,J.z)}setNextKinematicRotation(J){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(J):this._rigidBodyDesc.setRotation(J)}setNextKinematicPosition(J){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(J):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setPosition(J){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(J,!this._explicitSleep):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setRotation(J){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(J,!this._explicitSleep):this._rigidBodyDesc.setRotation(J)}setSleeping(J){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?J?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=J,this._explicitSleep=J}setSoftCcdPrediction(J){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(J):this._rigidBodyDesc.setSoftCcdPrediction(J)}setCollisionGroupsForSolidColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((Z)=>{if(Z.isSensor)return;Z.setCollisionGroups(J)})}setCollisionGroupsForSensorColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((Z)=>{if(!Z.isSensor)return;Z.setCollisionGroups(J)})}setType(J){if(!this._requireNotRemoved("setType"))return;let Y={["dynamic"]:H0.RigidBodyType.Dynamic,["fixed"]:H0.RigidBodyType.Fixed,["kinematic_position"]:H0.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:H0.RigidBodyType.KinematicVelocityBased}[J];if(Y===void 0)return _.error(`Invalid RigidBodyType: ${J}`);this._rigidBody?this._rigidBody.setBodyType(Y,!this._explicitSleep):this._rigidBodyDesc.status=Y,this._rigidBodyType=J}addForce(J){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addForce(J,!this._explicitSleep)}addTorque(J){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addTorque(J,!this._explicitSleep)}addChildColliderToSimulation(J){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;J.addToSimulation(this._simulation,this)}addToSimulation(J){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return _.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=J,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((Z)=>{if(!Z.isSimulated)Z.addToSimulation(J,this)})}applyImpulse(J){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulse(J,!this._explicitSleep)}applyImpulseAtPoint(J,Z){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulseAtPoint(J,Z,!this._explicitSleep)}applyTorqueImpulse(J){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(J,!this._explicitSleep)}createAndAddChildCollider(J){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new n8({...J,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(J)}createAndAddChildCollidersToSimulation(J){let Z=[];return J.forEach((Y)=>{let X=this.createAndAddChildCollider(Y);if(X)Z.push(X)}),Z}getCollidersByTag(J){let Z=[];for(let Y of this._colliders)if(Y.tag===J)Z.push(Y);return Z}linkCollider(J){if(!this._requireNotRemoved("linkCollider"))return;if(J.parentRigidBody!==this)return _.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(J)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return _.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((J)=>{J.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(J){if(!this._requireNotRemoved("unlinkCollider"))return;if(!J.isRemoved)return _.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(J)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(J){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([Y,X])=>{if(Y in J)X(J[Y])})}_autoAddToSimulation(J){if(J.colliders)this._createAndAddPendingChildColliders(J.colliders);if(J.simulation)this.addToSimulation(J.simulation)}_createAndAddPendingChildCollider(J){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let Z=new n8(J);return this._colliders.add(Z),Z}_createAndAddPendingChildColliders(J){let Z=[];return J.forEach((Y)=>{let X=this._createAndAddPendingChildCollider(Y);if(X)Z.push(X)}),Z}_createRigidBodyDesc(J){let Z=J.type??$C;return{["dynamic"]:()=>H0.RigidBodyDesc.dynamic(),["fixed"]:()=>H0.RigidBodyDesc.fixed(),["kinematic_position"]:()=>H0.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>H0.RigidBodyDesc.kinematicVelocityBased()}[Z]()}_requireCreated(J){if(!this._rigidBody||!this._simulation)_.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(J){if(!this.isDynamic)_.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${J}()`);return this.isDynamic}_requireKinematic(J){if(!this.isKinematic)_.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${J}()`);return this.isKinematic}_requireNotKinematicPositionBased(J){if(this.isKinematicPositionBased)_.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${J}()`);return!this.isKinematicPositionBased}_requireNotRemoved(J){if(!this._rigidBody&&!this._rigidBodyDesc)_.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(J){if(this.isSimulated)_.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${J}()`);return!this.isSimulated}_isNegligibleVector(J){return Math.abs(J.x)<Jq&&Math.abs(J.y)<Jq&&Math.abs(J.z)<Jq}}var i0=16,r5=i0-1,QC=i0**3,jZ0=[{neighborOffset:[-1,0,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+0,J+0,Z+1,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+1]},{neighborOffset:[1,0,0],generateVertices:(J,Z,Y)=>[J+1,Z+0,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+1,J+1,Z+0,Y+1]},{neighborOffset:[0,-1,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+1,Z+0,Y+0,J+0,Z+0,Y+1,J+1,Z+0,Y+0,J+1,Z+0,Y+1,J+0,Z+0,Y+1]},{neighborOffset:[0,1,0],generateVertices:(J,Z,Y)=>[J+0,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+1]},{neighborOffset:[0,0,-1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+0]},{neighborOffset:[0,0,1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+1,J+1,Z+0,Y+1,J+0,Z+1,Y+1,J+0,Z+1,Y+1,J+1,Z+0,Y+1,J+1,Z+1,Y+1]}],Zq;((X)=>{X.DESPAWN="CHUNK.DESPAWN";X.SET_BLOCK="CHUNK.SET_BLOCK";X.SPAWN="CHUNK.SPAWN"})(Zq||={});class P8 extends s{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(QC)}get blocks(){return this._blocks}get requiresUpdate(){return this._requiresUpdate}get isSimulated(){return!!this._rigidBody}get isSpawned(){return!!this._originCoordinate&&!!this._world}get originCoordinate(){return this._originCoordinate}get world(){return this._world}static blockIndexToLocalCoordinate(J){return{x:J%i0,y:(J/i0|0)%i0,z:J/(i0*i0)|0}}static globalCoordinateToLocalCoordinate(J){return{x:J.x&i0-1,y:J.y&i0-1,z:J.z&i0-1}}static globalCoordinateToOriginCoordinate(J){return{x:J.x&~(i0-1),y:J.y&~(i0-1),z:J.z&~(i0-1)}}static isValidOriginCoordinate(J){return J.x%i0===0&&J.y%i0===0&&J.z%i0===0}spawn(J,Z){if(this.isSpawned){let{x:Y,y:X,z:K}=this.originCoordinate;return _.error(`Chunk.spawn(): Chunk is already spawned at origin ${Y}, ${X}, ${K}!`)}if(!P8.isValidOriginCoordinate(Z))return _.error(`Chunk.spawn(): Chunk coordinates must be divisible by ${i0}`);this._originCoordinate=Z,this._world=J,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)return _.error("Chunk.despawn(): Chunk has not been spawned and cannot be despawned!");this.emitWithWorld(this._world,"CHUNK.DESPAWN",{chunk:this}),this._removeFromSimulation(),this._world.chunkLattice.unregisterChunk(this),this._originCoordinate=void 0,this._world=void 0}getBlockId(J){return this._blocks[this._getIndex(J)]}hasBlock(J){return this._blocks[this._getIndex(J)]!==0}setBlock(J,Z){if(!this._isValidLocalCoordinate(J))return _.error("Chunk.setBlock(): Block local coordinate is out of bounds");if(this._blocks[this._getIndex(J)]===Z)return;if(this._blocks[this._getIndex(J)]=Z,this.isSpawned&&this.isSimulated){this.emitWithWorld(this._world,"CHUNK.SET_BLOCK",{chunk:this,globalCoordinate:this._getGlobalCoordinate(J),localCoordinate:J,blockTypeId:Z});let Y=this._getGlobalCoordinate(J),X=[];if(J.x===0)X.push({x:-1,y:0,z:0});if(J.y===0)X.push({x:0,y:-1,z:0});if(J.z===0)X.push({x:0,y:0,z:-1});if(J.x===r5)X.push({x:1,y:0,z:0});if(J.y===r5)X.push({x:0,y:1,z:0});if(J.z===r5)X.push({x:0,y:0,z:1});for(let K of X){let $={x:Y.x+K.x,y:Y.y+K.y,z:Y.z+K.z},Q=P8.globalCoordinateToOriginCoordinate($),F=this._world?.chunkLattice.getChunk(Q);if(!F?.hasBlock(P8.globalCoordinateToLocalCoordinate($)))continue;F.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(J){this._requiresUpdate=J}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)return _.error("Chunk.update(): Chunk is not spawned and cannot be updated.");let J=!this._rigidBody,Z=this._world.simulation;if(this._removeFromSimulation(),this._rigidBody=new f9({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([Y,X])=>{if(!Y.isSimulated)Y.addToSimulation(Z,this._rigidBody);Z.colliderMap.setColliderBlockType(Y,X)}),this._requiresUpdate=!1,J)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return e.serializeChunk(this)}_meshColliders(){if(!this._world)return _.error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed."),[];let J=new Map,Z=[];for(let X=0;X<QC;X++){if(this._blocks[X]===0)continue;let K=this._blocks[X],$=this._world.blockTypeRegistry.getBlockType(K),{x:Q,y:F,z:G}=P8.blockIndexToLocalCoordinate(X);if(!$.isMeshable){let V=$.createCollider();V.setRelativePosition({x:Q,y:F,z:G}),Z.push([V,$]);continue}let W=J.get($)??{indices:[],vertices:[]};J.set($,W);for(let V of jZ0){let[q,z,U]=V.neighborOffset,M={x:Q+q,y:F+z,z:G+U},R=this._getGlobalCoordinate(M),L=this._world.chunkLattice.getBlockType(R);if(L&&!L.isLiquid)continue;let O=W.indices.length;W.indices.push(O,O+1,O+2,O+3,O+4,O+5),W.vertices.push(...V.generateVertices(Q,F,G))}}let Y=[];return J.forEach((X,K)=>{if(!X.indices.length)return;let $=K.createCollider(new Uint32Array(X.indices),new Float32Array(X.vertices));Y.push([$,K])}),[...Z,...Y]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(J){if(!this.originCoordinate)_.fatalError("Chunk._getGlobalCoordinate(): Chunk is not spawned, calculating global coordinate is impossible.");return{x:this.originCoordinate.x+J.x,y:this.originCoordinate.y+J.y,z:this.originCoordinate.z+J.z}}_getIndex(J){return J.x+i0*(J.y+i0*J.z)}_isValidLocalCoordinate(J){return J.x>=0&&J.x<=r5&&J.y>=0&&J.y<=r5&&J.z>=0&&J.z<=r5}}class BJ{_chunks=new Map;_world;constructor(J){this._world=J}registerChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(J.originCoordinate)){let{x:Z,y:Y,z:X}=J.originCoordinate;return _.error(`ChunkLattice.registerChunk(): Chunk exists at origin (${Z}, ${Y}, ${X}), despawn the current chunk before registering another at the same origin.`)}if(J.world.id!==this._world.id)return _.error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(J.originCoordinate),J)}unregisterChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(J.world.id!==this._world.id)return _.error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(J.originCoordinate))}getBlockId(J){let Z=this.getChunk(P8.globalCoordinateToOriginCoordinate(J));if(!Z)return 0;return Z.getBlockId(P8.globalCoordinateToLocalCoordinate(J))}getBlockType(J){let Z=this.getBlockId(J);return Z?this._world.blockTypeRegistry.getBlockType(Z):null}getChunk(J){if(!P8.isValidOriginCoordinate(J)){_.error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${i0})`);return}return this._chunks.get(this._getChunkKey(J))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(J){let Z=this.getChunk(P8.globalCoordinateToOriginCoordinate(J));if(!Z)return!1;return Z.hasBlock(P8.globalCoordinateToLocalCoordinate(J))}hasChunk(J){return this._chunks.has(this._getChunkKey(J))}setBlock(J,Z){let Y=P8.globalCoordinateToLocalCoordinate(J),X=P8.globalCoordinateToOriginCoordinate(J),K=this.getChunk(X);if(!K)K=new P8,K.spawn(this._world,X);K.setBlock(Y,Z)}updateChunks(){this._chunks.forEach((J)=>{if(J.requiresUpdate)J.update()})}_getChunkKey(J){return`${J.x},${J.y},${J.z}`}}var FC={type:"dynamic",softCcdPrediction:1},GC=0.0025000000000000005,WC=Math.cos(0.005),F$;((O)=>{O.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";O.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";O.DESPAWN="ENTITY.DESPAWN";O.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";O.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";O.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";O.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";O.SET_OPACITY="ENTITY.SET_OPACITY";O.SET_PARENT="ENTITY.SET_PARENT";O.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";O.SPAWN="ENTITY.SPAWN";O.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";O.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";O.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";O.TICK="ENTITY.TICK";O.UPDATE_POSITION="ENTITY.UPDATE_POSITION";O.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(F$||={});class K8 extends f9{_id;_blockHalfExtents;_blockTextureUri;_controller;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelScale;_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;constructor(J){let Z="blockTextureUri"in J,Y="modelUri"in J;if(!Z===!Y)_.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(Z&&!J.blockHalfExtents)_.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(J.parent&&!J.parent.isSpawned)_.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(J.parent?.modelUri&&J.parentNodeName&&!M6.instance.modelHasNode(J.parent.modelUri,J.parentNodeName))_.fatalError(`Entity.constructor(): Parent node name ${J.parentNodeName} not found in parent model ${J.parent.modelUri}!`);super(J.rigidBodyOptions??FC);if(Z)this._blockHalfExtents=J.blockHalfExtents,this._blockTextureUri=J.blockTextureUri;if(Y)this._modelAnimationsPlaybackRate=J.modelAnimationsPlaybackRate??1,this._modelScale=J.modelScale,this._modelUri=J.modelUri,J.modelHiddenNodes?.forEach((X)=>this._modelHiddenNodes.add(X.toLowerCase())),J.modelLoopedAnimations?.forEach((X)=>this._modelLoopedAnimations.add(X));if(this._name=J.name??"Nameless",this._opacity=J.opacity??1,this._parent=J.parent,this._parentNodeName=J.parentNodeName,this._tag=J.tag,this._tintColor=J.tintColor,J.controller)this.setController(J.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get height(){return this.isModelEntity?M6.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 modelScale(){return this._modelScale}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 isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get world(){return this._world}spawn(J,Z,Y){if(this.isSpawned)return _.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(J.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new n8(n8.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0)this.addChildColliderToSimulation(new n8(n8.optionsFromModelUri(this._modelUri,this._modelScale)));if(this.colliders.forEach((X)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))X.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))X.enableContactForceEvents(!0);if(z6.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[X.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(Z),Y)this.setRotation(Y);if(this._id=J.entityManager.registerEntity(this),this._world=J,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,Z,Y);this.colliders.forEach((X)=>{J.simulation.colliderMap.setColliderEntity(X,this)}),this.emitWithWorld(J,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((J)=>{J.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.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setModelAnimationsPlaybackRate(J){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===J)return;this._modelAnimationsPlaybackRate=J,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:J})}setController(J){if(this._controller===J)return;if(this._controller)this._controller.detach(this);if(this._controller=J,this._controller)this._controller.attach(this)}setModelHiddenNodes(J){if(!this._requireSpawned("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setOpacity(J){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===J)return;this._opacity=J,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:J})}setParent(J,Z,Y,X){if(!this._requireSpawned("setParent"))return;if(J&&!J.isSpawned)return _.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&J)this._lastParentlessType=this.type;if(this._parent=J,this._parentNodeName=Z,this.colliders.forEach((K)=>K.setEnabled(!J)),this.setType(!J?this._lastParentlessType:"kinematic_velocity"),this.setPosition(Y??{x:0,y:0,z:0}),this.setRotation(X??{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:J,parentNodeName:Z})}setTintColor(J){if(!this._requireSpawned("setTintColor"))return;if(!J&&!this._tintColor||J&&this._tintColor&&J.r===this._tintColor.r&&J.g===this._tintColor.g&&J.b===this._tintColor.b)return;this._tintColor=J,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:J})}startModelLoopedAnimations(J){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>!this._modelLoopedAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(J)})}startModelOneshotAnimations(J){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!J.length)return;J.forEach((Z)=>{this._modelOneshotAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(J)})}stopModelAnimations(J){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>this._modelLoopedAnimations.has(Z))&&!J.some((Z)=>this._modelOneshotAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.delete(Z),this._modelOneshotAnimations.delete(Z)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(J)})}serialize(){return e.serializeEntity(this)}tick(J){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:J}),this._controller)this._controller.tick(this,J)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let J=this.position,Z=this.rotation;if(this._rotationExceedsThreshold(Z,this._lastUpdatedRotation))this._lastUpdatedRotation=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:Z});if(this._positionExceedsThreshold(J,this._lastUpdatedPosition))this._lastUpdatedPosition=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:J})}_requireSpawned(J){if(!this.isSpawned)_.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${J}()!`);return this.isSpawned}_positionExceedsThreshold(J,Z){let Y=J.x-Z.x,X=J.y-Z.y,K=J.z-Z.z;return Y*Y+X*X+K*K>GC}_rotationExceedsThreshold(J,Z){return Math.abs(J.x*Z.x+J.y*Z.y+J.z*Z.z+J.w*Z.w)<WC}}class vJ extends n1{autoCancelMouseLeftClick=!0;canWalk=()=>!0;canRun=()=>!0;canJump=()=>!0;idleLoopedAnimations=["idle_upper","idle_lower"];interactOneshotAnimations=["simple_interact"];jumpOneshotAnimations=["jump_loop"];jumpVelocity=10;runLoopedAnimations=["run_upper","run_lower"];runVelocity=8;sticksToPlatforms=!0;walkLoopedAnimations=["walk_upper","walk_lower"];walkVelocity=4;_stepAudio;_groundContactCount=0;_platform;constructor(J={}){super();this.autoCancelMouseLeftClick=J.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.jumpVelocity=J.jumpVelocity??this.jumpVelocity,this.runVelocity=J.runVelocity??this.runVelocity,this.walkVelocity=J.walkVelocity??this.walkVelocity,this.canWalk=J.canWalk??this.canWalk,this.canRun=J.canRun??this.canRun,this.canJump=J.canJump??this.canJump,this.sticksToPlatforms=J.sticksToPlatforms??this.sticksToPlatforms}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get platform(){return this._platform}attach(J){this._stepAudio=new K4({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,attachedToEntity:J}),J.setCcdEnabled(!0),J.lockAllRotations()}spawn(J){if(!J.isSpawned)return _.error("PlayerEntityController.createColliders(): Entity is not spawned!");J.createAndAddChildCollider({shape:"cylinder",radius:0.23,halfHeight:0.125,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},isSensor:!0,relativePosition:{x:0,y:-0.75,z:0},tag:"groundSensor",onCollision:(Z,Y)=>{if(!J.isSpawned)return;if(this._groundContactCount+=Y?1:-1,!this._groundContactCount)J.startModelOneshotAnimations(this.jumpOneshotAnimations);else J.stopModelAnimations(this.jumpOneshotAnimations);if(!(Z instanceof K8)||!Z.isKinematic)return;if(Y&&this.sticksToPlatforms)this._platform=Z;else if(Z===this._platform&&!Y)this._platform=void 0}}),J.createAndAddChildCollider({shape:"capsule",halfHeight:0.33,radius:0.4,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(J,Z,Y,X){if(!J.isSpawned||!J.world)return;if(super.tickWithPlayerInput(J,Z,Y,X),J.parent)return;let{w:K,a:$,s:Q,d:F,sp:G,sh:W,ml:V}=Z,{yaw:q}=Y,z=J.linearVelocity,U={x:0,y:0,z:0},M=W;if(this.isGrounded&&(K||$||Q||F)){if(M)J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((N)=>!this.runLoopedAnimations.includes(N))),J.startModelLoopedAnimations(this.runLoopedAnimations),this._stepAudio?.setPlaybackRate(0.75);else J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((N)=>!this.walkLoopedAnimations.includes(N))),J.startModelLoopedAnimations(this.walkLoopedAnimations),this._stepAudio?.setPlaybackRate(0.51);this._stepAudio?.play(J.world,!this._stepAudio?.isPlaying)}else this._stepAudio?.pause(),J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((N)=>!this.idleLoopedAnimations.includes(N))),J.startModelLoopedAnimations(this.idleLoopedAnimations);if(V)J.startModelOneshotAnimations(this.interactOneshotAnimations),Z.ml=!this.autoCancelMouseLeftClick;if(M&&this.canRun(this)||!M&&this.canWalk(this)){let N=M?this.runVelocity:this.walkVelocity;if(K)U.x-=N*Math.sin(q),U.z-=N*Math.cos(q);if(Q)U.x+=N*Math.sin(q),U.z+=N*Math.cos(q);if($)U.x-=N*Math.cos(q),U.z+=N*Math.sin(q);if(F)U.x+=N*Math.cos(q),U.z-=N*Math.sin(q);let B=Math.sqrt(U.x*U.x+U.z*U.z);if(B>N){let v=N/B;U.x*=v,U.z*=v}}if(G&&this.canJump(this)){if(this.isGrounded&&z.y>-0.001&&z.y<=3)U.y=this.jumpVelocity}let R=this._platform?this._platform.linearVelocity:{x:0,y:0,z:0},L={x:U.x-z.x+R.x,y:U.y+R.y,z:U.z-z.z+R.z};if(!(this.runVelocity>0&&Math.abs(z.x)>this.runVelocity||this.jumpVelocity>0&&Math.abs(z.y)>this.jumpVelocity||this.runVelocity>0&&Math.abs(z.z)>this.runVelocity)||this.isOnPlatform){if(Object.values(L).some((N)=>N!==0)){let N=J.mass;J.applyImpulse({x:L.x*N,y:L.y*N,z:L.z*N})}}if(q!==void 0){let N=q/2;J.setRotation({x:0,y:Math.fround(Math.sin(N)),z:0,w:Math.fround(Math.cos(N))})}}}var Yq;((F)=>{F.LOAD="SCENE_UI.LOAD";F.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";F.SET_OFFSET="SCENE_UI.SET_OFFSET";F.SET_POSITION="SCENE_UI.SET_POSITION";F.SET_STATE="SCENE_UI.SET_STATE";F.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";F.UNLOAD="SCENE_UI.UNLOAD"})(Yq||={});class jJ extends s{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=J.attachedToEntity,this._offset=J.offset,this._position=J.position,this._state=J.state??{},this._templateId=J.templateId,this._viewDistance=J.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(J){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=J.sceneUIManager.registerSceneUI(this),this._world=J,this.emitWithWorld(J,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`SceneUI.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:J})}setPosition(J){if(this._position===J)return;if(this._attachedToEntity=void 0,this._position=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:J})}setState(J){if(this._state={...this._state,...J},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(J){if(this._viewDistance=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:J})}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 e.serializeSceneUI(this)}}class i1 extends K8{player;nametagSceneUI;constructor(J){super(J);if(this.player=J.player,this.nametagSceneUI=new jJ({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}}),!J.controller)this.setController(new vJ)}spawn(J,Z,Y){super.spawn(J,Z,Y),this.nametagSceneUI.load(J),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:X})=>{this.nametagSceneUI.setState({chat:X})})}tick(J){if(!this.isSpawned||!this.world||!this.controller)return;let{input:Z,camera:Y}=this.player;this.controller.tickWithPlayerInput(this,Z,Y.orientation,J),super.tick(J)}}class xJ{_entities=new Map;_nextEntityId=1;_world;constructor(J){this._world=J}get world(){return this._world}registerEntity(J){if(J.id!==void 0)_.fatalError(`EntityManager.registerEntity(): Entity ${J.name} is already assigned the id ${J.id}!`);let Z=this._nextEntityId;return this._entities.set(Z,J),this._nextEntityId++,Z}unregisterEntity(J){if(J.id===void 0)return _.error(`EntityManager.unregisterEntity(): Entity ${J.name} is not assigned an id!`);this._entities.delete(J.id)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let J=[];return this._entities.forEach((Z)=>{if(Z instanceof i1)J.push(Z)}),J}getPlayerEntitiesByPlayer(J){let Z=[];return this._entities.forEach((Y)=>{if(Y instanceof i1&&Y.player===J)Z.push(Y)}),Z}getEntity(J){return this._entities.get(J)}getEntitiesByTag(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag===J)Z.push(Y)}),Z}getEntitiesByTagSubstring(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag?.includes(J))Z.push(Y)}),Z}getEntityChildren(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.parent===J)Z.push(Y)}),Z}tickEntities(J){this._entities.forEach((Z)=>{Z.tick(J)})}checkAndEmitUpdates(){this._entities.forEach((J)=>{if(!J.isSpawned)return;J.checkAndEmitUpdates()})}}class TJ{_lights=new Map;_nextLightId=1;_world;constructor(J){this._world=J}get world(){return this._world}despawnEntityAttachedLights(J){this.getAllEntityAttachedLights(J).forEach((Z)=>{Z.despawn()})}getAllLights(){return Array.from(this._lights.values())}getAllEntityAttachedLights(J){return this.getAllLights().filter((Z)=>Z.attachedToEntity===J)}registerLight(J){if(J.id!==void 0)return J.id;let Z=this._nextLightId;return this._lights.set(Z,J),this._nextLightId++,Z}unregisterLight(J){if(J.id===void 0)return;this._lights.delete(J.id)}}var VC;((Y)=>{Y[Y.POINTLIGHT=0]="POINTLIGHT";Y[Y.SPOTLIGHT=1]="SPOTLIGHT"})(VC||={});var Xq;((z)=>{z.DESPAWN="LIGHT.DESPAWN";z.SET_ANGLE="LIGHT.SET_ANGLE";z.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";z.SET_COLOR="LIGHT.SET_COLOR";z.SET_DISTANCE="LIGHT.SET_DISTANCE";z.SET_INTENSITY="LIGHT.SET_INTENSITY";z.SET_OFFSET="LIGHT.SET_OFFSET";z.SET_PENUMBRA="LIGHT.SET_PENUMBRA";z.SET_POSITION="LIGHT.SET_POSITION";z.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";z.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";z.SPAWN="LIGHT.SPAWN"})(Xq||={});class Kq extends s{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();_.warning("WARNING: Lights are poorly optimized at this time. Using more than a few lights in your game can cause extremely bad performance (FPS) issues. Use lights sparingly!"),this._angle=J.angle,this._attachedToEntity=J.attachedToEntity,this._color=J.color??{r:255,g:255,b:255},this._distance=J.distance,this._intensity=J.intensity??1,this._offset=J.offset,this._penumbra=J.penumbra,this._position=J.position,this._trackedEntity=J.trackedEntity,this._trackedPosition=J.trackedPosition,this._type=J.type??0}get id(){return this._id}get angle(){return this._angle}get attachedToEntity(){return this._attachedToEntity}get color(){return this._color}get distance(){return this._distance}get intensity(){return this._intensity}get isSpawned(){return this._id!==void 0}get offset(){return this._offset}get penumbra(){return this._penumbra}get position(){return this._position}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get type(){return this._type}get world(){return this._world}setAngle(J){if(this._angle===J)return;if(this._angle=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ANGLE",{light:this,angle:J})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`Light.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ATTACHED_TO_ENTITY",{light:this,entity:J})}setColor(J){if(this._color.r===J.r&&this._color.g===J.g&&this._color.b===J.b)return;if(this._color=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_COLOR",{light:this,color:J})}setDistance(J){if(this._distance===J)return;if(this._distance=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_DISTANCE",{light:this,distance:J})}setIntensity(J){if(this._intensity===J)return;if(this._intensity=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_INTENSITY",{light:this,intensity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_OFFSET",{light:this,offset:J})}setPenumbra(J){if(this._penumbra===J)return;if(this._penumbra=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_PENUMBRA",{light:this,penumbra:J})}setPosition(J){if(this._position===J)return;if(this._position=J,this._attachedToEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_POSITION",{light:this,position:J})}setTrackedEntity(J){if(!J.isSpawned)return _.error(`Light.setTrackedEntity(): Entity ${J.id} is not spawned!`);if(this._trackedEntity===J)return;if(this._trackedEntity=J,this._trackedPosition=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_ENTITY",{light:this,entity:J})}setTrackedPosition(J){if(this._trackedPosition===J)return;if(this._trackedPosition=J,this._trackedEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_POSITION",{light:this,position:J})}despawn(){if(!this.isSpawned||!this._world)return;this._world.lightManager.unregisterLight(this),this.emitWithWorld(this._world,"LIGHT.DESPAWN",{light:this}),this._id=void 0,this._world=void 0}spawn(J){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`Light.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning Light!`);this._id=J.lightManager.registerLight(this),this._world=J,this.emitWithWorld(J,"LIGHT.SPAWN",{light:this})}serialize(){return e.serializeLight(this)}}var qC;((X)=>{X[X.FIRST_PERSON=0]="FIRST_PERSON";X[X.THIRD_PERSON=1]="THIRD_PERSON";X[X.SPECTATOR=2]="SPECTATOR"})(qC||={});var $q;((U)=>{U.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";U.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";U.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";U.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";U.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";U.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";U.SET_FOV="PLAYER_CAMERA.SET_FOV";U.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";U.SET_MODE="PLAYER_CAMERA.SET_MODE";U.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";U.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";U.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";U.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})($q||={});class DJ extends s{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_trackedEntity;_trackedPosition;_zoom=1;constructor(J){super();this.player=J}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 filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:J})}lookAtPosition(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:J})}setAttachedToEntity(J){if(!this._requirePlayerWorld())return;if(!J.isSpawned)return _.error(`PlayerCamera.setAttachedToEntity(): Entity ${J.id} is not spawned!`);this._attachedToEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:J})}setAttachedToPosition(J){if(!this._requirePlayerWorld())return;this._attachedToPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:J})}setFilmOffset(J){if(!this._requirePlayerWorld())return;this._filmOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:J})}setForwardOffset(J){if(!this._requirePlayerWorld())return;this._forwardOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:J})}setFov(J){if(!this._requirePlayerWorld())return;this._fov=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:J})}setModelHiddenNodes(J){if(!this._requirePlayerWorld())return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setMode(J){if(!this._requirePlayerWorld())return;this._mode=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:J})}setOffset(J){if(!this._requirePlayerWorld())return;this._offset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:J})}setOrientationPitch(J){this._orientation.pitch=J}setOrientationYaw(J){this._orientation.yaw=J}setTrackedEntity(J){if(!this._requirePlayerWorld())return;this._trackedEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:J})}setTrackedPosition(J){if(!this._requirePlayerWorld())return;this._trackedPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:J})}setZoom(J){if(!this._requirePlayerWorld())return;this._zoom=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:J})}serialize(){return e.serializePlayerCamera(this)}_requirePlayerWorld(){if(!this.player.world)_.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world!`);return!!this.player.world}}var G$;((K)=>{K.DATA="PLAYER_UI.DATA";K.LOAD="PLAYER_UI.LOAD";K.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";K.SEND_DATA="PLAYER_UI.SEND_DATA"})(G$||={});class _J extends s{player;constructor(J){super();this.player=J}load(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:J})}lockPointer(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:J})}sendData(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:J})}}class EJ{_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(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleBlockTypeMap.get(J.rawCollider.handle)}getColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleCollisionCallbackMap.get(J.rawCollider.handle)}getColliderEntity(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleEntityMap.get(J.rawCollider.handle)}getColliderHandleBlockType(J){return this._colliderHandleBlockTypeMap.get(J)}getColliderHandleCollisionCallback(J){return this._colliderHandleCollisionCallbackMap.get(J)}getColliderHandleEntity(J){return this._colliderHandleEntityMap.get(J)}removeColliderBlockType(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleBlockType(J.rawCollider.handle)}removeColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleCollisionCallback(J.rawCollider.handle)}removeColliderEntity(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleEntity(J.rawCollider.handle)}removeColliderHandleBlockType(J){this._colliderHandleBlockTypeMap.delete(J)}removeColliderHandleCollisionCallback(J){this._colliderHandleCollisionCallbackMap.delete(J)}removeColliderHandleEntity(J){this._colliderHandleEntityMap.delete(J)}setColliderBlockType(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleBlockType(J.rawCollider.handle,Z)}setColliderCollisionCallback(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleCollisionCallback(J.rawCollider.handle,Z)}setColliderEntity(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleEntity(J.rawCollider.handle,Z)}setColliderHandleBlockType(J,Z){this._colliderHandleBlockTypeMap.set(J,Z),this._cleanupBlockTypeColliderHandles.delete(J),this._pendingCleanupBlockTypeColliderHandles.delete(J)}setColliderHandleCollisionCallback(J,Z){this._colliderHandleCollisionCallbackMap.set(J,Z),this._cleanupCollisionCallbackColliderHandles.delete(J),this._pendingCleanupCollisionCallbackColliderHandles.delete(J)}setColliderHandleEntity(J,Z){this._colliderHandleEntityMap.set(J,Z),this._cleanupEntityColliderHandles.delete(J),this._pendingCleanupEntityColliderHandles.delete(J)}queueColliderHandleForCleanup(J){if(this._colliderHandleBlockTypeMap.has(J))this._pendingCleanupBlockTypeColliderHandles.add(J);if(this._colliderHandleCollisionCallbackMap.has(J))this._pendingCleanupCollisionCallbackColliderHandles.add(J);if(this._colliderHandleEntityMap.has(J))this._pendingCleanupEntityColliderHandles.add(J)}cleanup(){for(let J of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(J);this._cleanupBlockTypeColliderHandles.clear();for(let J of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(J);this._cleanupCollisionCallbackColliderHandles.clear();for(let J of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(J);this._cleanupEntityColliderHandles.clear(),[[this._pendingCleanupBlockTypeColliderHandles,this._cleanupBlockTypeColliderHandles],[this._pendingCleanupCollisionCallbackColliderHandles,this._cleanupCollisionCallbackColliderHandles],[this._pendingCleanupEntityColliderHandles,this._cleanupEntityColliderHandles]].forEach(([J,Z])=>{for(let Y of J.keys())Z.add(Y);J.clear()})}_requireSimulatedCollider(J){if(!J.rawCollider)_.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!J.rawCollider}}var kZ0={x:0,y:-32,z:0},Qq=60,Fq;((K)=>{K.STEP_START="SIMULATION.STEP_START";K.STEP_END="SIMULATION.STEP_END";K.DEBUG_RAYCAST="SIMULATION.DEBUG_RAYCAST";K.DEBUG_RENDER="SIMULATION.DEBUG_RENDER"})(Fq||={});class CJ extends s{_colliderMap=new EJ;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_rapierEventQueue;_rapierSimulation;_world;constructor(J,Z=Qq,Y=kZ0){super();this._rapierEventQueue=new H0.EventQueue(!0),this._rapierSimulation=new H0.World(Y),this._rapierSimulation.timestep=Math.fround(1/Z),this._world=J}get colliderMap(){return this._colliderMap}get isDebugRaycastingEnabled(){return this._debugRaycastingEnabled}get isDebugRenderingEnabled(){return this._debugRenderingEnabled}get gravity(){return this._rapierSimulation.gravity}get timestepS(){return this._rapierSimulation.timestep}get world(){return this._world}raycast(J,Z,Y,X={}){let K=new H0.Ray(J,Z),$=this._rapierSimulation.castRay(K,Y,X.ignoresSensors??!0,X.filterFlags,X.filterGroups,X.filterExcludeCollider,X.filterExcludeRigidBody,X.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:J,direction:Z,length:Y,hit:!!$});if(!$)return null;let Q=K.pointAt($.timeOfImpact),F=$.timeOfImpact,G=$.collider,W=this._colliderMap.getColliderHandleBlockType(G.handle);if(W)return{hitBlock:A9.fromGlobalCoordinate({x:Math.floor(Q.x-(K.dir.x<0?0.0001:-0.0001)),y:Math.floor(Q.y-(K.dir.y<0?0.0001:-0.0001)),z:Math.floor(Q.z-(K.dir.z<0?0.0001:-0.0001))},W),hitPoint:Q,hitDistance:F};let V=this._colliderMap.getColliderHandleEntity(G.handle);if(V)return{hitEntity:V,hitPoint:Q,hitDistance:F};return null}createRawCollider(J,Z){return this._rapierSimulation.createCollider(J,Z)}createRawRigidBody(J){return this._rapierSimulation.createRigidBody(J)}enableDebugRaycasting(J){this._debugRaycastingEnabled=J}enableDebugRendering(J){this._debugRenderingEnabled=J}getContactManifolds(J,Z){let Y=[];return this._rapierSimulation.narrowPhase.contactPair(J,Z,(X,K)=>{if(X.numContacts()===0)return;let $=X.normal(),Q=[];for(let F=0;F<X.numSolverContacts();F++)Q.push(X.solverContactPoint(F));Y.push({contactPoints:Q,localNormalA:!K?X.localNormal1():X.localNormal2(),localNormalB:!K?X.localNormal2():X.localNormal1(),normal:!K?$:{x:-$.x,y:-$.y,z:-$.z}})}),Y}removeRawCollider(J){this._colliderMap.queueColliderHandleForCleanup(J.handle),this._rapierSimulation.removeCollider(J,!1)}removeRawRigidBody(J){this._rapierSimulation.removeRigidBody(J)}setGravity(J){this._rapierSimulation.gravity=J}step=(J)=>{this.emitWithWorld(this._world,"SIMULATION.STEP_START",{simulation:this,tickDeltaMs:J});let Z=performance.now();if(this._rapierSimulation.step(this._rapierEventQueue),this._rapierEventQueue.drainContactForceEvents(this._onContactForceEvent),this._rapierEventQueue.drainCollisionEvents(this._onCollisionEvent),this._colliderMap.cleanup(),this.emitWithWorld(this._world,"SIMULATION.STEP_END",{simulation:this,stepDurationMs:performance.now()-Z}),this._debugRenderingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RENDER",{simulation:this,...this._rapierSimulation.debugRender()})};_onCollisionEvent=(J,Z,Y)=>{let[X,K]=this._getCollisionObjects(J,Z);if(!X||!K)return;let $=(Q,F)=>{if(Q instanceof R6&&F instanceof K8&&Q.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))Q.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:Q,entity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof R6&&Q.hasListeners("ENTITY.BLOCK_COLLISION"))Q.emit("ENTITY.BLOCK_COLLISION",{entity:Q,blockType:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof K8&&Q.hasListeners("ENTITY.ENTITY_COLLISION"))Q.emit("ENTITY.ENTITY_COLLISION",{entity:Q,otherEntity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(typeof Q==="function"&&(F instanceof K8||F instanceof R6))Q(F,Y,J,Z)};$(X,K),$(K,X)};_onContactForceEvent=(J)=>{let[Z,Y]=this._getCollisionObjects(J.collider1(),J.collider2());if(!Z||typeof Z==="function"||!Y||typeof Y==="function")return;let X={totalForce:J.totalForce(),totalForceMagnitude:J.totalForceMagnitude(),maxForceDirection:J.maxForceDirection(),maxForceMagnitude:J.maxForceMagnitude()},K=($,Q)=>{if($ instanceof R6&&Q instanceof K8&&$.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))$.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:$,entity:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof R6&&$.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))$.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:$,blockType:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof K8&&$.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:$,otherEntity:Q,contactForceData:X})};K(Z,Y),K(Y,Z)};_getCollisionObjects(J,Z){let Y=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J),X=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z);return[Y,X]}}class W${_queuedBroadcasts=[];_queuedAudioSynchronizations={};_queuedBlockSynchronizations={};_queuedBlockTypeSynchronizations={};_queuedChunkSynchronizations={};_queuedDebugRaycastSynchronizations=[];_queuedEntitySynchronizations={};_queuedLightSynchronizations={};_queuedPerPlayerSynchronizations=new Map;_queuedPerPlayerCameraSynchronizations=new Map;_queuedPerPlayerUISynchronizations=new Map;_queuedPerPlayerUIDatasSynchronizations=new Map;_queuedPlayerSynchronizations={};_queuedSceneUISynchronizations={};_queuedWorldSynchronization;_loadedSceneUIs=new Set;_spawnedChunks=new Set;_spawnedEntities=new Set;_world;constructor(J){this._world=J,this._subscribeToAudioEvents(),this._subscribeToBlockTypeRegistryEvents(),this._subscribeToChatEvents(),this._subscribeToChunkEvents(),this._subscribeToEntityEvents(),this._subscribeToLightEvents(),this._subscribeToPlayerEvents(),this._subscribeToPlayerCameraEvents(),this._subscribeToPlayerUIEvents(),this._subscribeToSceneUIEvents(),this._subscribeToSimulationEvents(),this._subscribeToWorldEvents()}synchronize(){for(let[W,V]of this._queuedPerPlayerSynchronizations)for(let q of V)W.connection.send(q);let J=Object.values(this._queuedEntitySynchronizations);if(J.length>0){let W=g.createPacket(g.outboundPackets.entitiesPacketDefinition,J,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Z=Object.values(this._queuedAudioSynchronizations);if(Z.length>0){let W=g.createPacket(g.outboundPackets.audiosPacketDefinition,Z,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Y=Object.values(this._queuedBlockTypeSynchronizations);if(Y.length>0){let W=g.createPacket(g.outboundPackets.blockTypesPacketDefinition,Y,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let X=Object.values(this._queuedBlockSynchronizations);if(X.length>0){let W=g.createPacket(g.outboundPackets.blocksPacketDefinition,X,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let K=Object.values(this._queuedChunkSynchronizations);if(K.length>0){let W=g.createPacket(g.outboundPackets.chunksPacketDefinition,K,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let $=Object.values(this._queuedLightSynchronizations);if($.length>0){let W=g.createPacket(g.outboundPackets.lightsPacketDefinition,$,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerUISynchronizations){let q=g.createPacket(g.outboundPackets.uiPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}for(let[W,V]of this._queuedPerPlayerUIDatasSynchronizations){let q=g.createPacket(g.outboundPackets.uiDatasPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let Q=Object.values(this._queuedSceneUISynchronizations);if(Q.length>0){let W=g.createPacket(g.outboundPackets.sceneUIsPacketDefinition,Q,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}if(this._queuedWorldSynchronization){let W=g.createPacket(g.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerCameraSynchronizations){let q=g.createPacket(g.outboundPackets.cameraPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let F=Object.values(this._queuedPlayerSynchronizations);if(F.length>0){let W=g.createPacket(g.outboundPackets.playersPacketDefinition,F,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let W of this._queuedBroadcasts)Y8.instance.broadcastToWorld(this._world.id,W);let G=this._queuedDebugRaycastSynchronizations;if(G.length>0){let W=g.createPacket(g.outboundPackets.physicsDebugRaycastsPacketDefinition,G,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}this._queuedBroadcasts=[],this._queuedAudioSynchronizations={},this._queuedBlockSynchronizations={},this._queuedBlockTypeSynchronizations={},this._queuedChunkSynchronizations={},this._queuedDebugRaycastSynchronizations=[],this._queuedEntitySynchronizations={},this._queuedLightSynchronizations={},this._queuedPerPlayerSynchronizations.clear(),this._queuedPerPlayerCameraSynchronizations.clear(),this._queuedPerPlayerUISynchronizations.clear(),this._queuedPerPlayerUIDatasSynchronizations.clear(),this._queuedPlayerSynchronizations={},this._queuedSceneUISynchronizations={},this._queuedWorldSynchronization=void 0,this._loadedSceneUIs.clear(),this._spawnedChunks.clear(),this._spawnedEntities.clear()}_subscribeToAudioEvents(){this._world.final("AUDIO.PAUSE",this._onAudioPause),this._world.final("AUDIO.PLAY",this._onAudioPlay),this._world.final("AUDIO.PLAY_RESTART",this._onAudioPlayRestart),this._world.final("AUDIO.SET_ATTACHED_TO_ENTITY",this._onAudioSetAttachedToEntity),this._world.final("AUDIO.SET_DETUNE",this._onAudioSetDetune),this._world.final("AUDIO.SET_DISTORTION",this._onAudioSetDistortion),this._world.final("AUDIO.SET_POSITION",this._onAudioSetPosition),this._world.final("AUDIO.SET_PLAYBACK_RATE",this._onAudioSetPlaybackRate),this._world.final("AUDIO.SET_REFERENCE_DISTANCE",this._onAudioSetReferenceDistance),this._world.final("AUDIO.SET_VOLUME",this._onAudioSetVolume)}_subscribeToBlockTypeRegistryEvents(){this._world.final("BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",this._onBlockTypeRegistryRegisterBlockType)}_subscribeToChatEvents(){this._world.final("CHAT.BROADCAST_MESSAGE",this._onChatSendBroadcastMessage),this._world.final("CHAT.PLAYER_MESSAGE",this._onChatSendPlayerMessage)}_subscribeToChunkEvents(){this._world.final("CHUNK.SPAWN",this._onChunkSpawn),this._world.final("CHUNK.DESPAWN",this._onChunkDespawn),this._world.final("CHUNK.SET_BLOCK",this._onChunkSetBlock)}_subscribeToEntityEvents(){this._world.final("ENTITY.SPAWN",this._onEntitySpawn),this._world.final("ENTITY.DESPAWN",this._onEntityDespawn),this._world.final("ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",this._onEntitySetModelAnimationsPlaybackRate),this._world.final("ENTITY.SET_MODEL_HIDDEN_NODES",this._onEntitySetModelHiddenNodes),this._world.final("ENTITY.SET_OPACITY",this._onEntitySetOpacity),this._world.final("ENTITY.SET_PARENT",this._onEntitySetParent),this._world.final("ENTITY.SET_TINT_COLOR",this._onEntitySetTintColor),this._world.final("ENTITY.START_MODEL_LOOPED_ANIMATIONS",this._onEntityStartModelLoopedAnimations),this._world.final("ENTITY.START_MODEL_ONESHOT_ANIMATIONS",this._onEntityStartModelOneshotAnimations),this._world.final("ENTITY.STOP_MODEL_ANIMATIONS",this._onEntityStopModelAnimations),this._world.final("ENTITY.UPDATE_POSITION",this._onEntityUpdatePosition),this._world.final("ENTITY.UPDATE_ROTATION",this._onEntityUpdateRotation)}_subscribeToLightEvents(){this._world.final("LIGHT.DESPAWN",this._onLightDespawn),this._world.final("LIGHT.SET_ANGLE",this._onLightSetAngle),this._world.final("LIGHT.SET_ATTACHED_TO_ENTITY",this._onLightSetAttachedToEntity),this._world.final("LIGHT.SET_COLOR",this._onLightSetColor),this._world.final("LIGHT.SET_DISTANCE",this._onLightSetDistance),this._world.final("LIGHT.SET_INTENSITY",this._onLightSetIntensity),this._world.final("LIGHT.SET_OFFSET",this._onLightSetOffset),this._world.final("LIGHT.SET_PENUMBRA",this._onLightSetPenumbra),this._world.final("LIGHT.SET_POSITION",this._onLightSetPosition),this._world.final("LIGHT.SET_TRACKED_ENTITY",this._onLightSetTrackedEntity),this._world.final("LIGHT.SET_TRACKED_POSITION",this._onLightSetTrackedPosition),this._world.final("LIGHT.SPAWN",this._onLightSpawn)}_subscribeToPlayerEvents(){this._world.final("PLAYER.JOINED_WORLD",this._onPlayerJoinedWorld),this._world.final("PLAYER.LEFT_WORLD",this._onPlayerLeftWorld),this._world.final("PLAYER.REQUEST_SYNC",this._onPlayerRequestSync)}_subscribeToPlayerCameraEvents(){this._world.final("PLAYER_CAMERA.LOOK_AT_ENTITY",this._onPlayerCameraLookAtEntity),this._world.final("PLAYER_CAMERA.LOOK_AT_POSITION",this._onPlayerCameraLookAtPosition),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",this._onPlayerCameraSetAttachedToEntity),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",this._onPlayerCameraSetAttachedToPosition),this._world.final("PLAYER_CAMERA.SET_FILM_OFFSET",this._onPlayerCameraSetFilmOffset),this._world.final("PLAYER_CAMERA.SET_FORWARD_OFFSET",this._onPlayerCameraSetForwardOffset),this._world.final("PLAYER_CAMERA.SET_FOV",this._onPlayerCameraSetFov),this._world.final("PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",this._onPlayerCameraSetModelHiddenNodes),this._world.final("PLAYER_CAMERA.SET_MODE",this._onPlayerCameraSetMode),this._world.final("PLAYER_CAMERA.SET_OFFSET",this._onPlayerCameraSetOffset),this._world.final("PLAYER_CAMERA.SET_TRACKED_ENTITY",this._onPlayerCameraSetTrackedEntity),this._world.final("PLAYER_CAMERA.SET_TRACKED_POSITION",this._onPlayerCameraSetTrackedPosition),this._world.final("PLAYER_CAMERA.SET_ZOOM",this._onPlayerCameraSetZoom)}_subscribeToPlayerUIEvents(){this._world.final("PLAYER_UI.LOAD",this._onPlayerUILoad),this._world.final("PLAYER_UI.LOCK_POINTER",this._onPlayerUILockPointer),this._world.final("PLAYER_UI.SEND_DATA",this._onPlayerUISendData)}_subscribeToSceneUIEvents(){this._world.final("SCENE_UI.LOAD",this._onSceneUILoad),this._world.final("SCENE_UI.SET_ATTACHED_TO_ENTITY",this._onSceneUISetAttachedToEntity),this._world.final("SCENE_UI.SET_OFFSET",this._onSceneUISetOffset),this._world.final("SCENE_UI.SET_POSITION",this._onSceneUISetPosition),this._world.final("SCENE_UI.SET_STATE",this._onSceneUISetState),this._world.final("SCENE_UI.SET_VIEW_DISTANCE",this._onSceneUISetViewDistance),this._world.final("SCENE_UI.UNLOAD",this._onSceneUIUnload)}_subscribeToSimulationEvents(){this._world.final("SIMULATION.DEBUG_RAYCAST",this._onSimulationDebugRaycast),this._world.final("SIMULATION.DEBUG_RENDER",this._onSimulationDebugRender)}_subscribeToWorldEvents(){this._world.final("WORLD.SET_AMBIENT_LIGHT_COLOR",this._onWorldSetAmbientLightColor),this._world.final("WORLD.SET_AMBIENT_LIGHT_INTENSITY",this._onWorldSetAmbientLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",this._onWorldSetDirectionalLightColor),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",this._onWorldSetDirectionalLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",this._onWorldSetDirectionalLightPosition)}_onAudioPause=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pa=!0,delete Z.pl,delete Z.r};_onAudioPlay=(J)=>{let Z=J.audio.serialize();Z.pl=!0,delete Z.pa,delete Z.r,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioPlayRestart=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.r=!0,delete Z.pa,delete Z.pl,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onAudioSetDetune=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.de=J.detune};_onAudioSetDistortion=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.di=J.distortion};_onAudioSetPosition=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.position?void 0:Z.e,Z.p=J.position?e.serializeVector(J.position):void 0};_onAudioSetPlaybackRate=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pr=J.playbackRate};_onAudioSetReferenceDistance=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.rd=J.referenceDistance};_onAudioSetVolume=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.v=J.volume};_onBlockTypeRegistryRegisterBlockType=(J)=>{let Z=J.blockType.serialize();this._queuedBlockTypeSynchronizations[J.blockType.id]=Z};_onChatSendBroadcastMessage=(J)=>{let{player:Z,message:Y,color:X}=J;this._queuedBroadcasts.push(g.createPacket(g.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X,p:Z?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(J)=>{let{player:Z,message:Y,color:X}=J,K=this._queuedPerPlayerSynchronizations.get(Z)??[];K.push(g.createPacket(g.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X}],this._world.loop.currentTick)),this._queuedPerPlayerSynchronizations.set(Z,K)};_onChunkSpawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk);Z.b=Array.from(J.chunk.blocks),Z.rm=void 0,this._spawnedChunks.add(Z.c.join(","))};_onChunkDespawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk),Y=Z.c.join(",");if(this._spawnedChunks.has(Y))delete this._queuedChunkSynchronizations[Y],this._spawnedChunks.delete(Y);else Z.rm=!0};_onChunkSetBlock=(J)=>{let Z=this._createOrGetQueuedBlockSync(J.globalCoordinate);Z.i=J.blockTypeId};_onEntitySetModelAnimationsPlaybackRate=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.ap=J.playbackRate};_onEntitySpawn=(J)=>{let Z=J.entity.serialize();this._queuedEntitySynchronizations[Z.i]=Z,this._spawnedEntities.add(Z.i)};_onEntityDespawn=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(this._spawnedEntities.has(Z.i))delete this._queuedEntitySynchronizations[Z.i],this._spawnedEntities.delete(Z.i);else Z.rm=!0};_onEntitySetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.h=Array.from(J.modelHiddenNodes)};_onEntitySetOpacity=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.o=J.opacity};_onEntitySetParent=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.pe=J.parent?J.parent.id:void 0,Z.pn=J.parentNodeName};_onEntitySetTintColor=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.t=J.tintColor?e.serializeRgbColor(J.tintColor):void 0};_onEntityStartModelLoopedAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al=Array.from(new Set([...Z.al??[],...J.animations])),Z.as)Z.as=Z.as.filter((Y)=>!J.animations.has(Y)).filter(Boolean)};_onEntityStartModelOneshotAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.ao=Array.from(new Set([...Z.ao??[],...J.animations])),Z.as)Z.as=Z.as.filter((Y)=>!J.animations.has(Y)).filter(Boolean)};_onEntityStopModelAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al)Z.al=Z.al.filter((Y)=>!J.animations.has(Y)).filter(Boolean);if(Z.ao)Z.ao=Z.ao.filter((Y)=>!J.animations.has(Y)).filter(Boolean);Z.as=Array.from(new Set([...Z.as??[],...J.animations]))};_onEntityUpdateRotation=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.r=[J.rotation.x,J.rotation.y,J.rotation.z,J.rotation.w]};_onEntityUpdatePosition=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.p=[J.position.x,J.position.y,J.position.z]};_onLightDespawn=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.rm=!0};_onLightSetAngle=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.a=J.angle};_onLightSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onLightSetColor=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.c=e.serializeRgbColor(J.color)};_onLightSetDistance=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.d=J.distance};_onLightSetIntensity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.n=J.intensity};_onLightSetOffset=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.o=J.offset?e.serializeVector(J.offset):void 0};_onLightSetPenumbra=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.pe=J.penumbra};_onLightSetPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.p=J.position?e.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onLightSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.te=J.entity?J.entity.id:void 0,Z.tp=J.entity?void 0:Z.tp};_onLightSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.tp=J.position?e.serializeVector(J.position):void 0,Z.te=J.position?void 0:Z.te};_onLightSpawn=(J)=>{let Z=J.light.serialize();this._queuedLightSynchronizations[Z.i]=Z};_onPlayerCameraLookAtEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=e.serializeVector(J.entity.position),delete Z.et,delete Z.pt};_onPlayerCameraLookAtPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=J.position?e.serializeVector(J.position):void 0,delete Z.et,delete Z.pt};_onPlayerCameraSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.e=J.entity.id,delete Z.p};_onPlayerCameraSetAttachedToPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.p=J.position?e.serializeVector(J.position):void 0,delete Z.e};_onPlayerCameraSetFilmOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fo=J.filmOffset};_onPlayerCameraSetForwardOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.ffo=J.forwardOffset};_onPlayerCameraSetFov=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fv=J.fov};_onPlayerCameraSetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.h=Array.from(J.modelHiddenNodes)};_onPlayerCameraSetMode=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.m=J.mode};_onPlayerCameraSetOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.o=J.offset?e.serializeVector(J.offset):void 0};_onPlayerCameraSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.et=J.entity?J.entity.id:void 0,delete Z.pl,delete Z.pt};_onPlayerCameraSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pt=J.position?e.serializeVector(J.position):void 0,delete Z.et,delete Z.pl};_onPlayerCameraSetZoom=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.z=J.zoom};_onPlayerJoinedWorld=(J)=>{let{player:Z}=J,Y=this._queuedPerPlayerSynchronizations.get(Z)??[];Y.push(g.createPacket(g.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map((K)=>{if(Z.camera.attachedToEntity===void 0&&K instanceof i1&&K.player===Z)Z.camera.setAttachedToEntity(K);return K.serialize()}),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllAudios().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(g.createPacket(g.outboundPackets.playersPacketDefinition,Y8.instance.getConnectedPlayers().map((K)=>K.serialize()),this._world.loop.currentTick));let X=this._createOrGetQueuedPlayerCameraSync(Z.camera);this._queuedPerPlayerCameraSynchronizations.set(Z,{...Z.camera.serialize(),...X}),this._queuedPerPlayerSynchronizations.set(Z,Y),this._queuedPlayerSynchronizations[Z.id]=Z.serialize()};_onPlayerLeftWorld=(J)=>{let Z=this._createOrGetQueuedPlayerSync(J.player);Z.rm=!0};_onPlayerRequestSync=(J)=>{J.player.connection.send(g.createPacket(g.outboundPackets.syncResponsePacketDefinition,{r:J.receivedAt,s:Date.now(),p:performance.now()-J.receivedAtMs,n:this._world.loop.nextTickMs},this._world.loop.currentTick))};_onPlayerUILoad=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.u=J.htmlUri};_onPlayerUILockPointer=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.p=J.lock};_onPlayerUISendData=(J)=>{this._createOrGetQueuedPlayerUIDatasSync(J.playerUI).push(J.data)};_onSceneUILoad=(J)=>{let Z=J.sceneUI.serialize();this._queuedSceneUISynchronizations[Z.i]=Z,this._loadedSceneUIs.add(Z.i)};_onSceneUISetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onSceneUISetOffset=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.o=J.offset?e.serializeVector(J.offset):void 0};_onSceneUISetPosition=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.p=J.position?e.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onSceneUISetState=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.s=J.state};_onSceneUISetViewDistance=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.v=J.viewDistance};_onSceneUIUnload=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);if(this._loadedSceneUIs.has(Z.i))delete this._queuedSceneUISynchronizations[Z.i],this._loadedSceneUIs.delete(Z.i);else Z.rm=!0};_onSimulationDebugRaycast=(J)=>{this._queuedDebugRaycastSynchronizations.push(e.serializePhysicsDebugRaycast(J))};_onSimulationDebugRender=(J)=>{this._queuedBroadcasts.push(g.createPacket(g.outboundPackets.physicsDebugRenderPacketDefinition,{v:Array.from(J.vertices),c:Array.from(J.colors)},this._world.loop.currentTick))};_onWorldSetAmbientLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ac=e.serializeRgbColor(J.color)};_onWorldSetAmbientLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ai=J.intensity};_onWorldSetDirectionalLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dc=e.serializeRgbColor(J.color)};_onWorldSetDirectionalLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.di=J.intensity};_onWorldSetDirectionalLightPosition=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dp=e.serializeVector(J.position)};_createOrGetQueuedAudioSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");return this._queuedAudioSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedBlockSync(J){let{x:Z,y:Y,z:X}=J;return this._queuedBlockSynchronizations[`${Z},${Y},${X}`]??={i:0,c:[Z,Y,X]}}_createOrGetQueuedChunkSync(J){if(!J.originCoordinate)_.fatalError("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:Z,y:Y,z:X}=J.originCoordinate;return this._queuedChunkSynchronizations[`${Z},${Y},${X}`]??={c:[Z,Y,X]}}_createOrGetQueuedEntitySync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");return this._queuedEntitySynchronizations[J.id]??={i:J.id}}_createOrGetQueuedLightSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");return this._queuedLightSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedPlayerSync(): Player has no id!");return this._queuedPlayerSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerCameraSync(J){let Z=this._queuedPerPlayerCameraSynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerCameraSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUISync(J){let Z=this._queuedPerPlayerUISynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerUISynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUIDatasSync(J){let Z=this._queuedPerPlayerUIDatasSynchronizations.get(J.player);if(!Z)Z=[],this._queuedPerPlayerUIDatasSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedSceneUISync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");return this._queuedSceneUISynchronizations[J.id]??={i:J.id}}_createOrGetQueuedWorldSync(J){if(J.id!==this._world.id)_.fatalError("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:J.id}}}class SJ{_sceneUIs=new Map;_nextSceneUIId=1;_world;constructor(J){this._world=J}get world(){return this._world}getAllSceneUIs(){return Array.from(this._sceneUIs.values())}getAllEntityAttachedSceneUIs(J){return this.getAllSceneUIs().filter((Z)=>Z.attachedToEntity===J)}getSceneUIById(J){return this._sceneUIs.get(J)}registerSceneUI(J){if(J.id!==void 0)return J.id;let Z=this._nextSceneUIId;return this._sceneUIs.set(Z,J),this._nextSceneUIId++,Z}unloadEntityAttachedSceneUIs(J){this.getAllEntityAttachedSceneUIs(J).forEach((Z)=>{Z.unload()})}unregisterSceneUI(J){if(J.id===void 0)return;this._sceneUIs.delete(J.id)}}class IJ{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(J,Z,Y){this._targetTicksPerSecond=J,this._fixedTimestepS=Math.fround(1/J),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._tickFunction=Z,this._tickErrorCallback=Y}get targetTicksPerSecond(){return this._targetTicksPerSecond}get fixedTimestepMs(){return this._fixedTimestepMs}get fixedTimestepS(){return this._fixedTimestepS}get nextTickMs(){return this._nextTickMs}start(){if(this._tickHandle)return _.warning("Ticker.start(): ticker already running.");this._lastLoopTimeMs=performance.now();let J=()=>{let Z=performance.now(),Y=Z-this._lastLoopTimeMs;if(this._lastLoopTimeMs=Z,Y>250)Y=250;this._accumulatorMs+=Y;while(this._accumulatorMs>=this._fixedTimestepMs)this._tick(this._fixedTimestepMs),this._accumulatorMs-=this._fixedTimestepMs;this._nextTickMs=this._fixedTimestepMs-this._accumulatorMs,this._tickHandle=setTimeout(J,0)};J()}stop(){if(!this._tickHandle)return _.warning("Ticker.stop(): ticker not running.");clearTimeout(this._tickHandle),this._tickHandle=null}_tick(J){try{this._tickFunction(J)}catch(Z){if(Z instanceof Error&&this._tickErrorCallback)this._tickErrorCallback(Z);else _.warning(`Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error: ${Z}`)}}}var zC;(($)=>{$.START="WORLD_LOOP.START";$.STOP="WORLD_LOOP.STOP";$.TICK_START="WORLD_LOOP.TICK_START";$.TICK_END="WORLD_LOOP.TICK_END";$.TICK_ERROR="WORLD_LOOP.TICK_ERROR"})(zC||={});class fJ extends s{_currentTick=0;_ticker;_world;constructor(J,Z=Qq){super();this._ticker=new IJ(Z,this._tick,this._onTickError),this._world=J}get currentTick(){return this._currentTick}get nextTickMs(){return this._ticker.nextTickMs}get timestepS(){return this._ticker.fixedTimestepS}get world(){return this._world}start(){this._ticker.start(),this.emitWithWorld(this._world,"WORLD_LOOP.START",{worldLoop:this})}stop(){this._ticker.stop(),this.emitWithWorld(this._world,"WORLD_LOOP.STOP",{worldLoop:this})}_tick=(J)=>{this.emitWithWorld(this._world,"WORLD_LOOP.TICK_START",{worldLoop:this,tickDeltaMs:J});let Z=performance.now();this._world.chunkLattice.updateChunks(),this._world.entityManager.tickEntities(J),this._world.simulation.step(J),this._world.entityManager.checkAndEmitUpdates(),this._world.networkSynchronizer.synchronize(),this._currentTick++,this.emitWithWorld(this._world,"WORLD_LOOP.TICK_END",{worldLoop:this,tickDurationMs:performance.now()-Z})};_onTickError=(J)=>{_.error(`WorldLoop._onTickError(): Error: ${J}`),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:J})}}var Gq;((F)=>{F.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";F.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";F.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";F.START="WORLD.START";F.STOP="WORLD.STOP"})(Gq||={});class hJ extends s{_id;_ambientLightColor;_ambientLightIntensity;_directionalLightColor;_directionalLightIntensity;_directionalLightPosition;_name;_skyboxUri;_audioManager;_blockTypeRegistry;_chatManager;_chunkLattice;_entityManager;_lightManager;_loop;_networkSynchronizer;_sceneUIManager;_simulation;constructor(J){super();this._id=J.id,this._ambientLightColor=J.ambientLightColor??{r:255,g:255,b:255},this._ambientLightIntensity=J.ambientLightIntensity??1,this._directionalLightColor=J.directionalLightColor??{r:255,g:255,b:255},this._directionalLightIntensity=J.directionalLightIntensity??3,this._directionalLightPosition=J.directionalLightPosition??{x:100,y:150,z:100},this._name=J.name,this._skyboxUri=J.skyboxUri,this._audioManager=new $4(this),this._blockTypeRegistry=new d4(this),this._chatManager=new bJ(this),this._chunkLattice=new BJ(this),this._entityManager=new xJ(this),this._lightManager=new TJ(this),this._loop=new fJ(this,J.tickRate),this._networkSynchronizer=new W$(this),this._sceneUIManager=new SJ(this),this._simulation=new CJ(this,J.tickRate,J.gravity)}get id(){return this._id}get ambientLightColor(){return this._ambientLightColor}get ambientLightIntensity(){return this._ambientLightIntensity}get directionalLightColor(){return this._directionalLightColor}get directionalLightIntensity(){return this._directionalLightIntensity}get directionalLightPosition(){return this._directionalLightPosition}get name(){return this._name}get skyboxUri(){return this._skyboxUri}get audioManager(){return this._audioManager}get blockTypeRegistry(){return this._blockTypeRegistry}get chatManager(){return this._chatManager}get chunkLattice(){return this._chunkLattice}get entityManager(){return this._entityManager}get lightManager(){return this._lightManager}get loop(){return this._loop}get networkSynchronizer(){return this._networkSynchronizer}get sceneUIManager(){return this._sceneUIManager}get simulation(){return this._simulation}loadMap(J){if(J.blockTypes)for(let Z of J.blockTypes)this.blockTypeRegistry.registerGenericBlockType({id:Z.id,isLiquid:Z.isLiquid,name:Z.name,textureUri:Z.textureUri});if(J.blocks)for(let[Z,Y]of Object.entries(J.blocks)){let[X,K,$]=Z.split(",").map(Number);this.chunkLattice.setBlock({x:X,y:K,z:$},Y)}if(J.entities)for(let[Z,Y]of Object.entries(J.entities)){let[X,K,$]=Z.split(",").map(Number);new K8(Y).spawn(this,{x:X,y:K,z:$})}}setAmbientLightColor(J){this._ambientLightColor=J,this.emit("WORLD.SET_AMBIENT_LIGHT_COLOR",{world:this,color:J})}setAmbientLightIntensity(J){this._ambientLightIntensity=J,this.emit("WORLD.SET_AMBIENT_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightColor(J){this._directionalLightColor=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",{world:this,color:J})}setDirectionalLightIntensity(J){this._directionalLightIntensity=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightPosition(J){this._directionalLightPosition=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",{world:this,position:J})}start(){this._loop.start(),this.emit("WORLD.START",{world:this,startedAtMs:Date.now()})}stop(){this._loop.stop(),this.emit("WORLD.STOP",{world:this,stoppedAtMs:Date.now()})}serialize(){return e.serializeWorld(this)}}var HC;((Y)=>{Y.START="GAMESERVER.START";Y.STOP="GAMESERVER.STOP"})(HC||={});function xZ0(J){H0.init().then(()=>{return w1.instance.modelRegistry.preloadModels()}).then(()=>{J(w1.instance.worlds[0]),w1.instance.start()}).catch((Z)=>{_.fatalError(`Failed to initialize the game engine, exiting. Error: ${Z}`)})}class w1{static _instance;_modelRegistry=M6.instance;_playerManager=Y8.instance;_socket=NJ.instance;_webServer=o5.instance;_worlds={};constructor(){let J=new hJ({id:0,name:"Default World",skyboxUri:"skyboxes/partly-cloudy"});this._worlds[J.id]=J}static get instance(){if(!this._instance)this._instance=new w1;return this._instance}get modelRegistry(){return this._modelRegistry}get playerManager(){return this._playerManager}get socket(){return this._socket}get webServer(){return this._webServer}get worlds(){return this._worlds}start(){l8.emit("GAMESERVER.START",{startedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.start()),this._webServer.start()}stop(){l8.emit("GAMESERVER.STOP",{stoppedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.stop())}}class h9{static instance=new h9;constructor(){}async getGlobalData(J){let Z=await u6.instance.getData(J);if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getGlobalData(): ${Z.error.message}`);return}return Z}async getPlayerData(J){let Z=await u6.instance.getData(this._getPlayerKey(J));if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getPlayerData(): ${Z.error.message}`);return}return Z}async setGlobalData(J,Z){let Y=await u6.instance.setData(J,Z);if(!Y||Y.error){if(Y?.error)_.warning(`PersistenceManager.setGlobalData(): ${Y.error.message}`);return}return Y}async setPlayerData(J,Z){let Y=await u6.instance.setData(this._getPlayerKey(J),Z);if(!Y||Y.error){if(Y?.error)_.warning(`PersistenceManager.setPlayerData(): ${Y.error.message}`);return}return Y}_getPlayerKey(J){return`player-${J.id}`}}var LC=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","1","2","3","4","5","6","7","8","9","0"],kJ;((K)=>{K.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";K.JOINED_WORLD="PLAYER.JOINED_WORLD";K.LEFT_WORLD="PLAYER.LEFT_WORLD";K.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(kJ||={});class w5 extends s{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_world;constructor(J,Z){super();this.id=Z?.user.id??`player-${w5._devNextPlayerId++}`,this.username=Z?.user.username??this.id,this.profilePictureUrl=Z?.user.profilePictureURL??void 0,this.camera=new DJ(this),this.connection=J,this.ui=new _J(this),J.onPacket(g.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),J.onPacket(g.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),J.onPacket(g.PacketId.INPUT,this._onInputPacket),J.onPacket(g.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),J.onPacket(g.PacketId.UI_DATA_SEND,this._onUIDataSendPacket),this.joinWorld(w1.instance.worlds[0])}get input(){return this._input}get world(){return this._world}disconnect(){this.leaveWorld(),this.connection.close()}async getPersistedData(){return h9.instance.getPlayerData(this)}joinWorld(J){this.leaveWorld(),this._world=J,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}async setPersistedData(J){return h9.instance.setPlayerData(this,J)}serialize(){return e.serializePlayer(this)}_onChatMessageSendPacket=(J)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:J[1].m})};_onDebugConfigPacket=(J)=>{console.log(J)};_onInputPacket=(J)=>{let Z=J[1];if(LC.forEach((Y)=>{let X=Y;if(Z[X]!==void 0)this._input[X]=Boolean(Z[X])}),Z.cp!==void 0)this.camera.setOrientationPitch(Z.cp);if(Z.cy!==void 0)this.camera.setOrientationYaw(Z.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(J)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:J[1]})}}var Wq;((Y)=>{Y.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";Y.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(Wq||={});class bJ extends s{_commandCallbacks={};_world;constructor(J){super();this._world=J,this._subscribeToPlayerEvents()}registerCommand(J,Z){this._commandCallbacks[J]=Z}unregisterCommand(J){delete this._commandCallbacks[J]}sendBroadcastMessage(J,Z){this._sendBroadcastMessage(void 0,J,Z)}sendPlayerMessage(J,Z,Y){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:J,message:Z,color:Y})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(J)=>{let{player:Z,message:Y}=J,[X,...K]=Y.split(" "),$=this._commandCallbacks[X];if($){$(Z,K,Y);return}this._sendBroadcastMessage(Z,Y)})}_sendBroadcastMessage(J,Z,Y){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:J,message:Z,color:Y})}}var l=0.000001,F0=typeof Float32Array!=="undefined"?Float32Array:Array,d6=Math.random;var CD0=Math.PI/180;if(!Math.hypot)Math.hypot=function(){var J=0,Z=arguments.length;while(Z--)J+=arguments[Z]*arguments[Z];return Math.sqrt(J)};var J8={};s6(J8,{transpose:()=>IZ0,subtract:()=>MC,sub:()=>oZ0,str:()=>cZ0,set:()=>SZ0,scale:()=>AZ0,rotate:()=>pZ0,multiplyScalarAndAdd:()=>aZ0,multiplyScalar:()=>nZ0,multiply:()=>UC,mul:()=>sZ0,invert:()=>fZ0,identity:()=>EZ0,fromValues:()=>CZ0,fromScaling:()=>gZ0,fromRotation:()=>yZ0,frob:()=>mZ0,exactEquals:()=>dZ0,equals:()=>iZ0,determinant:()=>bZ0,create:()=>TZ0,copy:()=>_Z0,clone:()=>DZ0,adjoint:()=>hZ0,add:()=>uZ0,LDU:()=>lZ0});function TZ0(){var J=new F0(4);if(F0!=Float32Array)J[1]=0,J[2]=0;return J[0]=1,J[3]=1,J}function DZ0(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function _Z0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function EZ0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=1,J}function CZ0(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function SZ0(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function IZ0(J,Z){if(J===Z){var Y=Z[1];J[1]=Z[2],J[2]=Y}else J[0]=Z[0],J[1]=Z[2],J[2]=Z[1],J[3]=Z[3];return J}function fZ0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*$-K*X;if(!Q)return null;return Q=1/Q,J[0]=$*Q,J[1]=-X*Q,J[2]=-K*Q,J[3]=Y*Q,J}function hZ0(J,Z){var Y=Z[0];return J[0]=Z[3],J[1]=-Z[1],J[2]=-Z[2],J[3]=Y,J}function bZ0(J){return J[0]*J[3]-J[2]*J[1]}function UC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*F+$*G,J[1]=K*F+Q*G,J[2]=X*W+$*V,J[3]=K*W+Q*V,J}function pZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+$*F,J[1]=K*G+Q*F,J[2]=X*-F+$*G,J[3]=K*-F+Q*G,J}function AZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1];return J[0]=X*F,J[1]=K*F,J[2]=$*G,J[3]=Q*G,J}function yZ0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=-Y,J[3]=X,J}function gZ0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=Z[1],J}function cZ0(J){return"mat2("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}function mZ0(J){return Math.hypot(J[0],J[1],J[2],J[3])}function lZ0(J,Z,Y,X){return J[2]=X[2]/X[0],Y[0]=X[0],Y[1]=X[1],Y[3]=X[3]-J[2]*Y[1],[J,Z,Y]}function uZ0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function MC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J}function dZ0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function iZ0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}function nZ0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function aZ0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J}var sZ0=UC,oZ0=MC;var f0={};s6(f0,{transpose:()=>XY0,translate:()=>FY0,subtract:()=>wC,sub:()=>kY0,str:()=>RY0,set:()=>ZY0,scale:()=>WY0,rotate:()=>GY0,projection:()=>MY0,normalFromMat4:()=>UY0,multiplyScalarAndAdd:()=>NY0,multiplyScalar:()=>PY0,multiply:()=>RC,mul:()=>jY0,invert:()=>KY0,identity:()=>YY0,fromValues:()=>JY0,fromTranslation:()=>VY0,fromScaling:()=>zY0,fromRotation:()=>qY0,fromQuat:()=>LY0,fromMat4:()=>rZ0,fromMat2d:()=>HY0,frob:()=>wY0,exactEquals:()=>BY0,equals:()=>vY0,determinant:()=>QY0,create:()=>Vq,copy:()=>eZ0,clone:()=>tZ0,adjoint:()=>$Y0,add:()=>OY0});function Vq(){var J=new F0(9);if(F0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[5]=0,J[6]=0,J[7]=0;return J[0]=1,J[4]=1,J[8]=1,J}function rZ0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[4],J[4]=Z[5],J[5]=Z[6],J[6]=Z[8],J[7]=Z[9],J[8]=Z[10],J}function tZ0(J){var Z=new F0(9);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z}function eZ0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function JY0(J,Z,Y,X,K,$,Q,F,G){var W=new F0(9);return W[0]=J,W[1]=Z,W[2]=Y,W[3]=X,W[4]=K,W[5]=$,W[6]=Q,W[7]=F,W[8]=G,W}function ZY0(J,Z,Y,X,K,$,Q,F,G,W){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J}function YY0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function XY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[5];J[1]=Z[3],J[2]=Z[6],J[3]=Y,J[5]=Z[7],J[6]=X,J[7]=K}else J[0]=Z[0],J[1]=Z[3],J[2]=Z[6],J[3]=Z[1],J[4]=Z[4],J[5]=Z[7],J[6]=Z[2],J[7]=Z[5],J[8]=Z[8];return J}function KY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=V*Q-F*W,z=-V*$+F*G,U=W*$-Q*G,M=Y*q+X*z+K*U;if(!M)return null;return M=1/M,J[0]=q*M,J[1]=(-V*X+K*W)*M,J[2]=(F*X-K*Q)*M,J[3]=z*M,J[4]=(V*Y-K*G)*M,J[5]=(-F*Y+K*$)*M,J[6]=U*M,J[7]=(-W*Y+X*G)*M,J[8]=(Q*Y-X*$)*M,J}function $Y0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8];return J[0]=Q*V-F*W,J[1]=K*W-X*V,J[2]=X*F-K*Q,J[3]=F*G-$*V,J[4]=Y*V-K*G,J[5]=K*$-Y*F,J[6]=$*W-Q*G,J[7]=X*G-Y*W,J[8]=Y*Q-X*$,J}function QY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8];return Z*(W*$-Q*G)+Y*(-W*K+Q*F)+X*(G*K-$*F)}function RC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Y[0],U=Y[1],M=Y[2],R=Y[3],L=Y[4],O=Y[5],N=Y[6],B=Y[7],v=Y[8];return J[0]=z*X+U*Q+M*W,J[1]=z*K+U*F+M*V,J[2]=z*$+U*G+M*q,J[3]=R*X+L*Q+O*W,J[4]=R*K+L*F+O*V,J[5]=R*$+L*G+O*q,J[6]=N*X+B*Q+v*W,J[7]=N*K+B*F+v*V,J[8]=N*$+B*G+v*q,J}function FY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Y[0],U=Y[1];return J[0]=X,J[1]=K,J[2]=$,J[3]=Q,J[4]=F,J[5]=G,J[6]=z*X+U*Q+W,J[7]=z*K+U*F+V,J[8]=z*$+U*G+q,J}function GY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Math.sin(Y),U=Math.cos(Y);return J[0]=U*X+z*Q,J[1]=U*K+z*F,J[2]=U*$+z*G,J[3]=U*Q-z*X,J[4]=U*F-z*K,J[5]=U*G-z*$,J[6]=W,J[7]=V,J[8]=q,J}function WY0(J,Z,Y){var X=Y[0],K=Y[1];return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*Z[2],J[3]=K*Z[3],J[4]=K*Z[4],J[5]=K*Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function VY0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=Z[0],J[7]=Z[1],J[8]=1,J}function qY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=-Y,J[4]=X,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function zY0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=Z[1],J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function HY0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=0,J[3]=Z[2],J[4]=Z[3],J[5]=0,J[6]=Z[4],J[7]=Z[5],J[8]=1,J}function LY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,z=K*Q,U=K*F,M=K*G,R=$*Q,L=$*F,O=$*G;return J[0]=1-q-M,J[3]=V-O,J[6]=z+L,J[1]=V+O,J[4]=1-W-M,J[7]=U-R,J[2]=z-L,J[5]=U+R,J[8]=1-W-q,J}function UY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],z=Z[10],U=Z[11],M=Z[12],R=Z[13],L=Z[14],O=Z[15],N=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,E=V*R-q*M,C=V*L-z*M,S=V*O-U*M,I=q*L-z*R,h=q*O-U*R,A=z*O-U*L,f=N*A-B*h+v*I+k*S-w*C+x*E;if(!f)return null;return f=1/f,J[0]=(F*A-G*h+W*I)*f,J[1]=(G*S-Q*A-W*C)*f,J[2]=(Q*h-F*S+W*E)*f,J[3]=(K*h-X*A-$*I)*f,J[4]=(Y*A-K*S+$*C)*f,J[5]=(X*S-Y*h-$*E)*f,J[6]=(R*x-L*w+O*k)*f,J[7]=(L*v-M*x-O*B)*f,J[8]=(M*w-R*v+O*N)*f,J}function MY0(J,Z,Y){return J[0]=2/Z,J[1]=0,J[2]=0,J[3]=0,J[4]=-2/Y,J[5]=0,J[6]=-1,J[7]=1,J[8]=1,J}function RY0(J){return"mat3("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+")"}function wY0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8])}function OY0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J}function wC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J}function PY0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J[4]=Z[4]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J}function NY0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J}function BY0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]}function vY0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=Z[0],z=Z[1],U=Z[2],M=Z[3],R=Z[4],L=Z[5],O=Z[6],N=Z[7],B=Z[8];return Math.abs(Y-q)<=l*Math.max(1,Math.abs(Y),Math.abs(q))&&Math.abs(X-z)<=l*Math.max(1,Math.abs(X),Math.abs(z))&&Math.abs(K-U)<=l*Math.max(1,Math.abs(K),Math.abs(U))&&Math.abs($-M)<=l*Math.max(1,Math.abs($),Math.abs(M))&&Math.abs(Q-R)<=l*Math.max(1,Math.abs(Q),Math.abs(R))&&Math.abs(F-L)<=l*Math.max(1,Math.abs(F),Math.abs(L))&&Math.abs(G-O)<=l*Math.max(1,Math.abs(G),Math.abs(O))&&Math.abs(W-N)<=l*Math.max(1,Math.abs(W),Math.abs(N))&&Math.abs(V-B)<=l*Math.max(1,Math.abs(V),Math.abs(B))}var jY0=RC,kY0=wC;var Y0={};s6(Y0,{transpose:()=>CY0,translate:()=>hY0,targetTo:()=>QX0,subtract:()=>kC,sub:()=>UX0,str:()=>FX0,set:()=>EY0,scale:()=>bY0,rotateZ:()=>gY0,rotateY:()=>yY0,rotateX:()=>AY0,rotate:()=>pY0,perspectiveZO:()=>ZX0,perspectiveNO:()=>vC,perspectiveFromFieldOfView:()=>YX0,perspective:()=>JX0,orthoZO:()=>KX0,orthoNO:()=>jC,ortho:()=>XX0,multiplyScalarAndAdd:()=>qX0,multiplyScalar:()=>VX0,multiply:()=>PC,mul:()=>LX0,lookAt:()=>$X0,invert:()=>SY0,identity:()=>OC,getTranslation:()=>aY0,getScaling:()=>BC,getRotation:()=>sY0,frustum:()=>eY0,fromZRotation:()=>iY0,fromYRotation:()=>dY0,fromXRotation:()=>uY0,fromValues:()=>_Y0,fromTranslation:()=>cY0,fromScaling:()=>mY0,fromRotationTranslationScaleOrigin:()=>rY0,fromRotationTranslationScale:()=>oY0,fromRotationTranslation:()=>NC,fromRotation:()=>lY0,fromQuat2:()=>nY0,fromQuat:()=>tY0,frob:()=>GX0,exactEquals:()=>zX0,equals:()=>HX0,determinant:()=>fY0,create:()=>xY0,copy:()=>DY0,clone:()=>TY0,adjoint:()=>IY0,add:()=>WX0});function xY0(){var J=new F0(16);if(F0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=0,J[12]=0,J[13]=0,J[14]=0;return J[0]=1,J[5]=1,J[10]=1,J[15]=1,J}function TY0(J){var Z=new F0(16);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z[9]=J[9],Z[10]=J[10],Z[11]=J[11],Z[12]=J[12],Z[13]=J[13],Z[14]=J[14],Z[15]=J[15],Z}function DY0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function _Y0(J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R){var L=new F0(16);return L[0]=J,L[1]=Z,L[2]=Y,L[3]=X,L[4]=K,L[5]=$,L[6]=Q,L[7]=F,L[8]=G,L[9]=W,L[10]=V,L[11]=q,L[12]=z,L[13]=U,L[14]=M,L[15]=R,L}function EY0(J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R,L){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J[9]=V,J[10]=q,J[11]=z,J[12]=U,J[13]=M,J[14]=R,J[15]=L,J}function OC(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function CY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[3],$=Z[6],Q=Z[7],F=Z[11];J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Y,J[6]=Z[9],J[7]=Z[13],J[8]=X,J[9]=$,J[11]=Z[14],J[12]=K,J[13]=Q,J[14]=F}else J[0]=Z[0],J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Z[1],J[5]=Z[5],J[6]=Z[9],J[7]=Z[13],J[8]=Z[2],J[9]=Z[6],J[10]=Z[10],J[11]=Z[14],J[12]=Z[3],J[13]=Z[7],J[14]=Z[11],J[15]=Z[15];return J}function SY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],z=Z[10],U=Z[11],M=Z[12],R=Z[13],L=Z[14],O=Z[15],N=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,E=V*R-q*M,C=V*L-z*M,S=V*O-U*M,I=q*L-z*R,h=q*O-U*R,A=z*O-U*L,f=N*A-B*h+v*I+k*S-w*C+x*E;if(!f)return null;return f=1/f,J[0]=(F*A-G*h+W*I)*f,J[1]=(K*h-X*A-$*I)*f,J[2]=(R*x-L*w+O*k)*f,J[3]=(z*w-q*x-U*k)*f,J[4]=(G*S-Q*A-W*C)*f,J[5]=(Y*A-K*S+$*C)*f,J[6]=(L*v-M*x-O*B)*f,J[7]=(V*x-z*v+U*B)*f,J[8]=(Q*h-F*S+W*E)*f,J[9]=(X*S-Y*h-$*E)*f,J[10]=(M*w-R*v+O*N)*f,J[11]=(q*v-V*w-U*N)*f,J[12]=(F*C-Q*I-G*E)*f,J[13]=(Y*I-X*C+K*E)*f,J[14]=(R*B-M*k-L*N)*f,J[15]=(V*k-q*B+z*N)*f,J}function IY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],z=Z[10],U=Z[11],M=Z[12],R=Z[13],L=Z[14],O=Z[15];return J[0]=F*(z*O-U*L)-q*(G*O-W*L)+R*(G*U-W*z),J[1]=-(X*(z*O-U*L)-q*(K*O-$*L)+R*(K*U-$*z)),J[2]=X*(G*O-W*L)-F*(K*O-$*L)+R*(K*W-$*G),J[3]=-(X*(G*U-W*z)-F*(K*U-$*z)+q*(K*W-$*G)),J[4]=-(Q*(z*O-U*L)-V*(G*O-W*L)+M*(G*U-W*z)),J[5]=Y*(z*O-U*L)-V*(K*O-$*L)+M*(K*U-$*z),J[6]=-(Y*(G*O-W*L)-Q*(K*O-$*L)+M*(K*W-$*G)),J[7]=Y*(G*U-W*z)-Q*(K*U-$*z)+V*(K*W-$*G),J[8]=Q*(q*O-U*R)-V*(F*O-W*R)+M*(F*U-W*q),J[9]=-(Y*(q*O-U*R)-V*(X*O-$*R)+M*(X*U-$*q)),J[10]=Y*(F*O-W*R)-Q*(X*O-$*R)+M*(X*W-$*F),J[11]=-(Y*(F*U-W*q)-Q*(X*U-$*q)+V*(X*W-$*F)),J[12]=-(Q*(q*L-z*R)-V*(F*L-G*R)+M*(F*z-G*q)),J[13]=Y*(q*L-z*R)-V*(X*L-K*R)+M*(X*z-K*q),J[14]=-(Y*(F*L-G*R)-Q*(X*L-K*R)+M*(X*G-K*F)),J[15]=Y*(F*z-G*q)-Q*(X*z-K*q)+V*(X*G-K*F),J}function fY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8],V=J[9],q=J[10],z=J[11],U=J[12],M=J[13],R=J[14],L=J[15],O=Z*Q-Y*$,N=Z*F-X*$,B=Z*G-K*$,v=Y*F-X*Q,k=Y*G-K*Q,w=X*G-K*F,x=W*M-V*U,E=W*R-q*U,C=W*L-z*U,S=V*R-q*M,I=V*L-z*M,h=q*L-z*R;return O*h-N*I+B*S+v*C-k*E+w*x}function PC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],z=Z[9],U=Z[10],M=Z[11],R=Z[12],L=Z[13],O=Z[14],N=Z[15],B=Y[0],v=Y[1],k=Y[2],w=Y[3];return J[0]=B*X+v*F+k*q+w*R,J[1]=B*K+v*G+k*z+w*L,J[2]=B*$+v*W+k*U+w*O,J[3]=B*Q+v*V+k*M+w*N,B=Y[4],v=Y[5],k=Y[6],w=Y[7],J[4]=B*X+v*F+k*q+w*R,J[5]=B*K+v*G+k*z+w*L,J[6]=B*$+v*W+k*U+w*O,J[7]=B*Q+v*V+k*M+w*N,B=Y[8],v=Y[9],k=Y[10],w=Y[11],J[8]=B*X+v*F+k*q+w*R,J[9]=B*K+v*G+k*z+w*L,J[10]=B*$+v*W+k*U+w*O,J[11]=B*Q+v*V+k*M+w*N,B=Y[12],v=Y[13],k=Y[14],w=Y[15],J[12]=B*X+v*F+k*q+w*R,J[13]=B*K+v*G+k*z+w*L,J[14]=B*$+v*W+k*U+w*O,J[15]=B*Q+v*V+k*M+w*N,J}function hY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q,F,G,W,V,q,z,U,M,R,L,O;if(Z===J)J[12]=Z[0]*X+Z[4]*K+Z[8]*$+Z[12],J[13]=Z[1]*X+Z[5]*K+Z[9]*$+Z[13],J[14]=Z[2]*X+Z[6]*K+Z[10]*$+Z[14],J[15]=Z[3]*X+Z[7]*K+Z[11]*$+Z[15];else Q=Z[0],F=Z[1],G=Z[2],W=Z[3],V=Z[4],q=Z[5],z=Z[6],U=Z[7],M=Z[8],R=Z[9],L=Z[10],O=Z[11],J[0]=Q,J[1]=F,J[2]=G,J[3]=W,J[4]=V,J[5]=q,J[6]=z,J[7]=U,J[8]=M,J[9]=R,J[10]=L,J[11]=O,J[12]=Q*X+V*K+M*$+Z[12],J[13]=F*X+q*K+R*$+Z[13],J[14]=G*X+z*K+L*$+Z[14],J[15]=W*X+U*K+O*$+Z[15];return J}function bY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2];return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J[4]=Z[4]*K,J[5]=Z[5]*K,J[6]=Z[6]*K,J[7]=Z[7]*K,J[8]=Z[8]*$,J[9]=Z[9]*$,J[10]=Z[10]*$,J[11]=Z[11]*$,J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function pY0(J,Z,Y,X){var K=X[0],$=X[1],Q=X[2],F=Math.hypot(K,$,Q),G,W,V,q,z,U,M,R,L,O,N,B,v,k,w,x,E,C,S,I,h,A,f,c;if(F<l)return null;if(F=1/F,K*=F,$*=F,Q*=F,G=Math.sin(Y),W=Math.cos(Y),V=1-W,q=Z[0],z=Z[1],U=Z[2],M=Z[3],R=Z[4],L=Z[5],O=Z[6],N=Z[7],B=Z[8],v=Z[9],k=Z[10],w=Z[11],x=K*K*V+W,E=$*K*V+Q*G,C=Q*K*V-$*G,S=K*$*V-Q*G,I=$*$*V+W,h=Q*$*V+K*G,A=K*Q*V+$*G,f=$*Q*V-K*G,c=Q*Q*V+W,J[0]=q*x+R*E+B*C,J[1]=z*x+L*E+v*C,J[2]=U*x+O*E+k*C,J[3]=M*x+N*E+w*C,J[4]=q*S+R*I+B*h,J[5]=z*S+L*I+v*h,J[6]=U*S+O*I+k*h,J[7]=M*S+N*I+w*h,J[8]=q*A+R*f+B*c,J[9]=z*A+L*f+v*c,J[10]=U*A+O*f+k*c,J[11]=M*A+N*f+w*c,Z!==J)J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J}function AY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[4],Q=Z[5],F=Z[6],G=Z[7],W=Z[8],V=Z[9],q=Z[10],z=Z[11];if(Z!==J)J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[4]=$*K+W*X,J[5]=Q*K+V*X,J[6]=F*K+q*X,J[7]=G*K+z*X,J[8]=W*K-$*X,J[9]=V*K-Q*X,J[10]=q*K-F*X,J[11]=z*K-G*X,J}function yY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[8],V=Z[9],q=Z[10],z=Z[11];if(Z!==J)J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K-W*X,J[1]=Q*K-V*X,J[2]=F*K-q*X,J[3]=G*K-z*X,J[8]=$*X+W*K,J[9]=Q*X+V*K,J[10]=F*X+q*K,J[11]=G*X+z*K,J}function gY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[4],V=Z[5],q=Z[6],z=Z[7];if(Z!==J)J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K+W*X,J[1]=Q*K+V*X,J[2]=F*K+q*X,J[3]=G*K+z*X,J[4]=W*K-$*X,J[5]=V*K-Q*X,J[6]=q*K-F*X,J[7]=z*K-G*X,J}function cY0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=Z[0],J[13]=Z[1],J[14]=Z[2],J[15]=1,J}function mY0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=Z[1],J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=Z[2],J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function lY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Math.hypot(X,K,$),F,G,W;if(Q<l)return null;return Q=1/Q,X*=Q,K*=Q,$*=Q,F=Math.sin(Z),G=Math.cos(Z),W=1-G,J[0]=X*X*W+G,J[1]=K*X*W+$*F,J[2]=$*X*W-K*F,J[3]=0,J[4]=X*K*W-$*F,J[5]=K*K*W+G,J[6]=$*K*W+X*F,J[7]=0,J[8]=X*$*W+K*F,J[9]=K*$*W-X*F,J[10]=$*$*W+G,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function uY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=X,J[6]=Y,J[7]=0,J[8]=0,J[9]=-Y,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function dY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=0,J[2]=-Y,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=Y,J[9]=0,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function iY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=0,J[4]=-Y,J[5]=X,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function NC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=X+X,G=K+K,W=$+$,V=X*F,q=X*G,z=X*W,U=K*G,M=K*W,R=$*W,L=Q*F,O=Q*G,N=Q*W;return J[0]=1-(U+R),J[1]=q+N,J[2]=z-O,J[3]=0,J[4]=q-N,J[5]=1-(V+R),J[6]=M+L,J[7]=0,J[8]=z+O,J[9]=M-L,J[10]=1-(V+U),J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function nY0(J,Z){var Y=new F0(3),X=-Z[0],K=-Z[1],$=-Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=X*X+K*K+$*$+Q*Q;if(q>0)Y[0]=(F*Q+V*X+G*$-W*K)*2/q,Y[1]=(G*Q+V*K+W*X-F*$)*2/q,Y[2]=(W*Q+V*$+F*K-G*X)*2/q;else Y[0]=(F*Q+V*X+G*$-W*K)*2,Y[1]=(G*Q+V*K+W*X-F*$)*2,Y[2]=(W*Q+V*$+F*K-G*X)*2;return NC(J,Z,Y),J}function aY0(J,Z){return J[0]=Z[12],J[1]=Z[13],J[2]=Z[14],J}function BC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[4],Q=Z[5],F=Z[6],G=Z[8],W=Z[9],V=Z[10];return J[0]=Math.hypot(Y,X,K),J[1]=Math.hypot($,Q,F),J[2]=Math.hypot(G,W,V),J}function sY0(J,Z){var Y=new F0(3);BC(Y,Z);var X=1/Y[0],K=1/Y[1],$=1/Y[2],Q=Z[0]*X,F=Z[1]*K,G=Z[2]*$,W=Z[4]*X,V=Z[5]*K,q=Z[6]*$,z=Z[8]*X,U=Z[9]*K,M=Z[10]*$,R=Q+V+M,L=0;if(R>0)L=Math.sqrt(R+1)*2,J[3]=0.25*L,J[0]=(q-U)/L,J[1]=(z-G)/L,J[2]=(F-W)/L;else if(Q>V&&Q>M)L=Math.sqrt(1+Q-V-M)*2,J[3]=(q-U)/L,J[0]=0.25*L,J[1]=(F+W)/L,J[2]=(z+G)/L;else if(V>M)L=Math.sqrt(1+V-Q-M)*2,J[3]=(z-G)/L,J[0]=(F+W)/L,J[1]=0.25*L,J[2]=(q+U)/L;else L=Math.sqrt(1+M-Q-V)*2,J[3]=(F-W)/L,J[0]=(z+G)/L,J[1]=(q+U)/L,J[2]=0.25*L;return J}function oY0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=K+K,W=$+$,V=Q+Q,q=K*G,z=K*W,U=K*V,M=$*W,R=$*V,L=Q*V,O=F*G,N=F*W,B=F*V,v=X[0],k=X[1],w=X[2];return J[0]=(1-(M+L))*v,J[1]=(z+B)*v,J[2]=(U-N)*v,J[3]=0,J[4]=(z-B)*k,J[5]=(1-(q+L))*k,J[6]=(R+O)*k,J[7]=0,J[8]=(U+N)*w,J[9]=(R-O)*w,J[10]=(1-(q+M))*w,J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function rY0(J,Z,Y,X,K){var $=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=$+$,V=Q+Q,q=F+F,z=$*W,U=$*V,M=$*q,R=Q*V,L=Q*q,O=F*q,N=G*W,B=G*V,v=G*q,k=X[0],w=X[1],x=X[2],E=K[0],C=K[1],S=K[2],I=(1-(R+O))*k,h=(U+v)*k,A=(M-B)*k,f=(U-v)*w,c=(1-(z+O))*w,J0=(L+N)*w,A0=(M+B)*x,n0=(L-N)*x,G6=(1-(z+R))*x;return J[0]=I,J[1]=h,J[2]=A,J[3]=0,J[4]=f,J[5]=c,J[6]=J0,J[7]=0,J[8]=A0,J[9]=n0,J[10]=G6,J[11]=0,J[12]=Y[0]+E-(I*E+f*C+A0*S),J[13]=Y[1]+C-(h*E+c*C+n0*S),J[14]=Y[2]+S-(A*E+J0*C+G6*S),J[15]=1,J}function tY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,z=K*Q,U=K*F,M=K*G,R=$*Q,L=$*F,O=$*G;return J[0]=1-q-M,J[1]=V+O,J[2]=z-L,J[3]=0,J[4]=V-O,J[5]=1-W-M,J[6]=U+R,J[7]=0,J[8]=z+L,J[9]=U-R,J[10]=1-W-q,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function eY0(J,Z,Y,X,K,$,Q){var F=1/(Y-Z),G=1/(K-X),W=1/($-Q);return J[0]=$*2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$*2*G,J[6]=0,J[7]=0,J[8]=(Y+Z)*F,J[9]=(K+X)*G,J[10]=(Q+$)*W,J[11]=-1,J[12]=0,J[13]=0,J[14]=Q*$*2*W,J[15]=0,J}function vC(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(X-K),J[10]=(K+X)*Q,J[14]=2*K*X*Q;else J[10]=-1,J[14]=-2*X;return J}var JX0=vC;function ZX0(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(X-K),J[10]=K*Q,J[14]=K*X*Q;else J[10]=-1,J[14]=-X;return J}function YX0(J,Z,Y,X){var K=Math.tan(Z.upDegrees*Math.PI/180),$=Math.tan(Z.downDegrees*Math.PI/180),Q=Math.tan(Z.leftDegrees*Math.PI/180),F=Math.tan(Z.rightDegrees*Math.PI/180),G=2/(Q+F),W=2/(K+$);return J[0]=G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=W,J[6]=0,J[7]=0,J[8]=-((Q-F)*G*0.5),J[9]=(K-$)*W*0.5,J[10]=X/(Y-X),J[11]=-1,J[12]=0,J[13]=0,J[14]=X*Y/(Y-X),J[15]=0,J}function jC(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=2*W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=(Q+$)*W,J[15]=1,J}var XX0=jC;function KX0(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=$*W,J[15]=1,J}function $X0(J,Z,Y,X){var K,$,Q,F,G,W,V,q,z,U,M=Z[0],R=Z[1],L=Z[2],O=X[0],N=X[1],B=X[2],v=Y[0],k=Y[1],w=Y[2];if(Math.abs(M-v)<l&&Math.abs(R-k)<l&&Math.abs(L-w)<l)return OC(J);if(V=M-v,q=R-k,z=L-w,U=1/Math.hypot(V,q,z),V*=U,q*=U,z*=U,K=N*z-B*q,$=B*V-O*z,Q=O*q-N*V,U=Math.hypot(K,$,Q),!U)K=0,$=0,Q=0;else U=1/U,K*=U,$*=U,Q*=U;if(F=q*Q-z*$,G=z*K-V*Q,W=V*$-q*K,U=Math.hypot(F,G,W),!U)F=0,G=0,W=0;else U=1/U,F*=U,G*=U,W*=U;return J[0]=K,J[1]=F,J[2]=V,J[3]=0,J[4]=$,J[5]=G,J[6]=q,J[7]=0,J[8]=Q,J[9]=W,J[10]=z,J[11]=0,J[12]=-(K*M+$*R+Q*L),J[13]=-(F*M+G*R+W*L),J[14]=-(V*M+q*R+z*L),J[15]=1,J}function QX0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=X[0],G=X[1],W=X[2],V=K-Y[0],q=$-Y[1],z=Q-Y[2],U=V*V+q*q+z*z;if(U>0)U=1/Math.sqrt(U),V*=U,q*=U,z*=U;var M=G*z-W*q,R=W*V-F*z,L=F*q-G*V;if(U=M*M+R*R+L*L,U>0)U=1/Math.sqrt(U),M*=U,R*=U,L*=U;return J[0]=M,J[1]=R,J[2]=L,J[3]=0,J[4]=q*L-z*R,J[5]=z*M-V*L,J[6]=V*R-q*M,J[7]=0,J[8]=V,J[9]=q,J[10]=z,J[11]=0,J[12]=K,J[13]=$,J[14]=Q,J[15]=1,J}function FX0(J){return"mat4("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+", "+J[9]+", "+J[10]+", "+J[11]+", "+J[12]+", "+J[13]+", "+J[14]+", "+J[15]+")"}function GX0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8],J[9],J[10],J[11],J[12],J[13],J[14],J[15])}function WX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J[9]=Z[9]+Y[9],J[10]=Z[10]+Y[10],J[11]=Z[11]+Y[11],J[12]=Z[12]+Y[12],J[13]=Z[13]+Y[13],J[14]=Z[14]+Y[14],J[15]=Z[15]+Y[15],J}function kC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J[9]=Z[9]-Y[9],J[10]=Z[10]-Y[10],J[11]=Z[11]-Y[11],J[12]=Z[12]-Y[12],J[13]=Z[13]-Y[13],J[14]=Z[14]-Y[14],J[15]=Z[15]-Y[15],J}function VX0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J[4]=Z[4]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J[9]=Z[9]*Y,J[10]=Z[10]*Y,J[11]=Z[11]*Y,J[12]=Z[12]*Y,J[13]=Z[13]*Y,J[14]=Z[14]*Y,J[15]=Z[15]*Y,J}function qX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J[9]=Z[9]+Y[9]*X,J[10]=Z[10]+Y[10]*X,J[11]=Z[11]+Y[11]*X,J[12]=Z[12]+Y[12]*X,J[13]=Z[13]+Y[13]*X,J[14]=Z[14]+Y[14]*X,J[15]=Z[15]+Y[15]*X,J}function zX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]&&J[9]===Z[9]&&J[10]===Z[10]&&J[11]===Z[11]&&J[12]===Z[12]&&J[13]===Z[13]&&J[14]===Z[14]&&J[15]===Z[15]}function HX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=J[9],z=J[10],U=J[11],M=J[12],R=J[13],L=J[14],O=J[15],N=Z[0],B=Z[1],v=Z[2],k=Z[3],w=Z[4],x=Z[5],E=Z[6],C=Z[7],S=Z[8],I=Z[9],h=Z[10],A=Z[11],f=Z[12],c=Z[13],J0=Z[14],A0=Z[15];return Math.abs(Y-N)<=l*Math.max(1,Math.abs(Y),Math.abs(N))&&Math.abs(X-B)<=l*Math.max(1,Math.abs(X),Math.abs(B))&&Math.abs(K-v)<=l*Math.max(1,Math.abs(K),Math.abs(v))&&Math.abs($-k)<=l*Math.max(1,Math.abs($),Math.abs(k))&&Math.abs(Q-w)<=l*Math.max(1,Math.abs(Q),Math.abs(w))&&Math.abs(F-x)<=l*Math.max(1,Math.abs(F),Math.abs(x))&&Math.abs(G-E)<=l*Math.max(1,Math.abs(G),Math.abs(E))&&Math.abs(W-C)<=l*Math.max(1,Math.abs(W),Math.abs(C))&&Math.abs(V-S)<=l*Math.max(1,Math.abs(V),Math.abs(S))&&Math.abs(q-I)<=l*Math.max(1,Math.abs(q),Math.abs(I))&&Math.abs(z-h)<=l*Math.max(1,Math.abs(z),Math.abs(h))&&Math.abs(U-A)<=l*Math.max(1,Math.abs(U),Math.abs(A))&&Math.abs(M-f)<=l*Math.max(1,Math.abs(M),Math.abs(f))&&Math.abs(R-c)<=l*Math.max(1,Math.abs(R),Math.abs(c))&&Math.abs(L-J0)<=l*Math.max(1,Math.abs(L),Math.abs(J0))&&Math.abs(O-A0)<=l*Math.max(1,Math.abs(O),Math.abs(A0))}var LX0=PC,UX0=kC;var v0={};s6(v0,{str:()=>qK0,squaredLength:()=>JS,sqrLen:()=>PK0,sqlerp:()=>jK0,slerp:()=>H$,setAxisAngle:()=>iC,setAxes:()=>kK0,set:()=>UK0,scale:()=>rC,rotationTo:()=>vK0,rotateZ:()=>KK0,rotateY:()=>XK0,rotateX:()=>YK0,random:()=>FK0,pow:()=>QK0,normalize:()=>Lq,multiply:()=>nC,mul:()=>RK0,ln:()=>sC,lerp:()=>wK0,length:()=>eC,len:()=>OK0,invert:()=>GK0,identity:()=>eX0,getAxisAngle:()=>JK0,getAngle:()=>ZK0,fromValues:()=>HK0,fromMat3:()=>oC,fromEuler:()=>VK0,exp:()=>aC,exactEquals:()=>NK0,equals:()=>BK0,dot:()=>tC,create:()=>Hq,copy:()=>LK0,conjugate:()=>WK0,clone:()=>zK0,calculateW:()=>$K0,add:()=>MK0});var $0={};s6($0,{zero:()=>gX0,transformQuat:()=>hX0,transformMat4:()=>IX0,transformMat3:()=>fX0,subtract:()=>TC,sub:()=>uX0,str:()=>cX0,squaredLength:()=>SC,squaredDistance:()=>CC,sqrLen:()=>sX0,sqrDist:()=>aX0,set:()=>wX0,scaleAndAdd:()=>xX0,scale:()=>kX0,round:()=>jX0,rotateZ:()=>AX0,rotateY:()=>pX0,rotateX:()=>bX0,random:()=>SX0,normalize:()=>qq,negate:()=>TX0,multiply:()=>DC,mul:()=>dX0,min:()=>BX0,max:()=>vX0,lerp:()=>_X0,length:()=>xC,len:()=>zq,inverse:()=>DX0,hermite:()=>EX0,fromValues:()=>q$,forEach:()=>oX0,floor:()=>NX0,exactEquals:()=>mX0,equals:()=>lX0,dot:()=>z$,divide:()=>_C,div:()=>iX0,distance:()=>EC,dist:()=>nX0,cross:()=>pJ,create:()=>V$,copy:()=>RX0,clone:()=>MX0,ceil:()=>PX0,bezier:()=>CX0,angle:()=>yX0,add:()=>OX0});function V$(){var J=new F0(3);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J}function MX0(J){var Z=new F0(3);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function xC(J){var Z=J[0],Y=J[1],X=J[2];return Math.hypot(Z,Y,X)}function q$(J,Z,Y){var X=new F0(3);return X[0]=J,X[1]=Z,X[2]=Y,X}function RX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function wX0(J,Z,Y,X){return J[0]=Z,J[1]=Y,J[2]=X,J}function OX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J}function TC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J}function DC(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J[2]=Z[2]*Y[2],J}function _C(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J[2]=Z[2]/Y[2],J}function PX0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J[2]=Math.ceil(Z[2]),J}function NX0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J[2]=Math.floor(Z[2]),J}function BX0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J[2]=Math.min(Z[2],Y[2]),J}function vX0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J[2]=Math.max(Z[2],Y[2]),J}function jX0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J[2]=Math.round(Z[2]),J}function kX0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J}function xX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J}function EC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Math.hypot(Y,X,K)}function CC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Y*Y+X*X+K*K}function SC(J){var Z=J[0],Y=J[1],X=J[2];return Z*Z+Y*Y+X*X}function TX0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J}function DX0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J[2]=1/Z[2],J}function qq(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Y*Y+X*X+K*K;if($>0)$=1/Math.sqrt($);return J[0]=Z[0]*$,J[1]=Z[1]*$,J[2]=Z[2]*$,J}function z$(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]}function pJ(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[0],F=Y[1],G=Y[2];return J[0]=K*G-$*F,J[1]=$*Q-X*G,J[2]=X*F-K*Q,J}function _X0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J}function EX0(J,Z,Y,X,K,$){var Q=$*$,F=Q*(2*$-3)+1,G=Q*($-2)+$,W=Q*($-1),V=Q*(3-2*$);return J[0]=Z[0]*F+Y[0]*G+X[0]*W+K[0]*V,J[1]=Z[1]*F+Y[1]*G+X[1]*W+K[1]*V,J[2]=Z[2]*F+Y[2]*G+X[2]*W+K[2]*V,J}function CX0(J,Z,Y,X,K,$){var Q=1-$,F=Q*Q,G=$*$,W=F*Q,V=3*$*F,q=3*G*Q,z=G*$;return J[0]=Z[0]*W+Y[0]*V+X[0]*q+K[0]*z,J[1]=Z[1]*W+Y[1]*V+X[1]*q+K[1]*z,J[2]=Z[2]*W+Y[2]*V+X[2]*q+K[2]*z,J}function SX0(J,Z){Z=Z||1;var Y=d6()*2*Math.PI,X=d6()*2-1,K=Math.sqrt(1-X*X)*Z;return J[0]=Math.cos(Y)*K,J[1]=Math.sin(Y)*K,J[2]=X*Z,J}function IX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[3]*X+Y[7]*K+Y[11]*$+Y[15];return Q=Q||1,J[0]=(Y[0]*X+Y[4]*K+Y[8]*$+Y[12])/Q,J[1]=(Y[1]*X+Y[5]*K+Y[9]*$+Y[13])/Q,J[2]=(Y[2]*X+Y[6]*K+Y[10]*$+Y[14])/Q,J}function fX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2];return J[0]=X*Y[0]+K*Y[3]+$*Y[6],J[1]=X*Y[1]+K*Y[4]+$*Y[7],J[2]=X*Y[2]+K*Y[5]+$*Y[8],J}function hX0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Y[3],F=Z[0],G=Z[1],W=Z[2],V=K*W-$*G,q=$*F-X*W,z=X*G-K*F,U=K*z-$*q,M=$*V-X*z,R=X*q-K*V,L=Q*2;return V*=L,q*=L,z*=L,U*=2,M*=2,R*=2,J[0]=F+V+U,J[1]=G+q+M,J[2]=W+z+R,J}function bX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0],$[1]=K[1]*Math.cos(X)-K[2]*Math.sin(X),$[2]=K[1]*Math.sin(X)+K[2]*Math.cos(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function pX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[2]*Math.sin(X)+K[0]*Math.cos(X),$[1]=K[1],$[2]=K[2]*Math.cos(X)-K[0]*Math.sin(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function AX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0]*Math.cos(X)-K[1]*Math.sin(X),$[1]=K[0]*Math.sin(X)+K[1]*Math.cos(X),$[2]=K[2],J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function yX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2],G=Math.sqrt(Y*Y+X*X+K*K),W=Math.sqrt($*$+Q*Q+F*F),V=G*W,q=V&&z$(J,Z)/V;return Math.acos(Math.min(Math.max(q,-1),1))}function gX0(J){return J[0]=0,J[1]=0,J[2]=0,J}function cX0(J){return"vec3("+J[0]+", "+J[1]+", "+J[2]+")"}function mX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]}function lX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2];return Math.abs(Y-$)<=l*Math.max(1,Math.abs(Y),Math.abs($))&&Math.abs(X-Q)<=l*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(K-F)<=l*Math.max(1,Math.abs(K),Math.abs(F))}var uX0=TC,dX0=DC,iX0=_C,nX0=EC,aX0=CC,zq=xC,sX0=SC,oX0=function(){var J=V$();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=3;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2];return Z}}();function rX0(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0,J[3]=0;return J}function IC(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function fC(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function hC(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function bC(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function pC(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function AC(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function yC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Math.hypot(Z,Y,X,K)}function gC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Z*Z+Y*Y+X*X+K*K}function cC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$;if(Q>0)Q=1/Math.sqrt(Q);return J[0]=Y*Q,J[1]=X*Q,J[2]=K*Q,J[3]=$*Q,J}function mC(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]+J[3]*Z[3]}function lC(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J[3]=F+X*(Y[3]-F),J}function uC(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function dC(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}var SD0=function(){var J=rX0();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=4;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],J[3]=Z[F+3],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2],Z[F+3]=J[3];return Z}}();function Hq(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J[3]=1,J}function eX0(J){return J[0]=0,J[1]=0,J[2]=0,J[3]=1,J}function iC(J,Z,Y){Y=Y*0.5;var X=Math.sin(Y);return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*Z[2],J[3]=Math.cos(Y),J}function JK0(J,Z){var Y=Math.acos(Z[3])*2,X=Math.sin(Y/2);if(X>l)J[0]=Z[0]/X,J[1]=Z[1]/X,J[2]=Z[2]/X;else J[0]=1,J[1]=0,J[2]=0;return Y}function ZK0(J,Z){var Y=tC(J,Z);return Math.acos(2*Y*Y-1)}function nC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*V+Q*F+K*W-$*G,J[1]=K*V+Q*G+$*F-X*W,J[2]=$*V+Q*W+X*G-K*F,J[3]=Q*V-X*F-K*G-$*W,J}function YK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+Q*F,J[1]=K*G+$*F,J[2]=$*G-K*F,J[3]=Q*G-X*F,J}function XK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G-$*F,J[1]=K*G+Q*F,J[2]=$*G+X*F,J[3]=Q*G-K*F,J}function KK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+K*F,J[1]=K*G-X*F,J[2]=$*G+Q*F,J[3]=Q*G-$*F,J}function $K0(J,Z){var Y=Z[0],X=Z[1],K=Z[2];return J[0]=Y,J[1]=X,J[2]=K,J[3]=Math.sqrt(Math.abs(1-Y*Y-X*X-K*K)),J}function aC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Math.exp($),G=Q>0?F*Math.sin(Q)/Q:0;return J[0]=Y*G,J[1]=X*G,J[2]=K*G,J[3]=F*Math.cos(Q),J}function sC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Q>0?Math.atan2(Q,$)/Q:0;return J[0]=Y*F,J[1]=X*F,J[2]=K*F,J[3]=0.5*Math.log(Y*Y+X*X+K*K+$*$),J}function QK0(J,Z,Y){return sC(J,Z),rC(J,J,Y),aC(J,J),J}function H$(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=Y[0],W=Y[1],V=Y[2],q=Y[3],z,U,M,R,L;if(U=K*G+$*W+Q*V+F*q,U<0)U=-U,G=-G,W=-W,V=-V,q=-q;if(1-U>l)z=Math.acos(U),M=Math.sin(z),R=Math.sin((1-X)*z)/M,L=Math.sin(X*z)/M;else R=1-X,L=X;return J[0]=R*K+L*G,J[1]=R*$+L*W,J[2]=R*Q+L*V,J[3]=R*F+L*q,J}function FK0(J){var Z=d6(),Y=d6(),X=d6(),K=Math.sqrt(1-Z),$=Math.sqrt(Z);return J[0]=K*Math.sin(2*Math.PI*Y),J[1]=K*Math.cos(2*Math.PI*Y),J[2]=$*Math.sin(2*Math.PI*X),J[3]=$*Math.cos(2*Math.PI*X),J}function GK0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$,F=Q?1/Q:0;return J[0]=-Y*F,J[1]=-X*F,J[2]=-K*F,J[3]=$*F,J}function WK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J[3]=Z[3],J}function oC(J,Z){var Y=Z[0]+Z[4]+Z[8],X;if(Y>0)X=Math.sqrt(Y+1),J[3]=0.5*X,X=0.5/X,J[0]=(Z[5]-Z[7])*X,J[1]=(Z[6]-Z[2])*X,J[2]=(Z[1]-Z[3])*X;else{var K=0;if(Z[4]>Z[0])K=1;if(Z[8]>Z[K*3+K])K=2;var $=(K+1)%3,Q=(K+2)%3;X=Math.sqrt(Z[K*3+K]-Z[$*3+$]-Z[Q*3+Q]+1),J[K]=0.5*X,X=0.5/X,J[3]=(Z[$*3+Q]-Z[Q*3+$])*X,J[$]=(Z[$*3+K]+Z[K*3+$])*X,J[Q]=(Z[Q*3+K]+Z[K*3+Q])*X}return J}function VK0(J,Z,Y,X){var K=0.5*Math.PI/180;Z*=K,Y*=K,X*=K;var $=Math.sin(Z),Q=Math.cos(Z),F=Math.sin(Y),G=Math.cos(Y),W=Math.sin(X),V=Math.cos(X);return J[0]=$*G*V-Q*F*W,J[1]=Q*F*V+$*G*W,J[2]=Q*G*W-$*F*V,J[3]=Q*G*V+$*F*W,J}function qK0(J){return"quat("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}var zK0=IC,HK0=fC,LK0=hC,UK0=bC,MK0=pC,RK0=nC,rC=AC,tC=mC,wK0=lC,eC=yC,OK0=eC,JS=gC,PK0=JS,Lq=cC,NK0=uC,BK0=dC,vK0=function(){var J=V$(),Z=q$(1,0,0),Y=q$(0,1,0);return function(X,K,$){var Q=z$(K,$);if(Q<-0.999999){if(pJ(J,Z,K),zq(J)<0.000001)pJ(J,Y,K);return qq(J,J),iC(X,J,Math.PI),X}else if(Q>0.999999)return X[0]=0,X[1]=0,X[2]=0,X[3]=1,X;else return pJ(J,K,$),X[0]=J[0],X[1]=J[1],X[2]=J[2],X[3]=1+Q,Lq(X,X)}}(),jK0=function(){var J=Hq(),Z=Hq();return function(Y,X,K,$,Q,F){return H$(J,X,Q,F),H$(Z,K,$,F),H$(Y,J,Z,2*F*(1-F)),Y}}(),kK0=function(){var J=Vq();return function(Z,Y,X,K){return J[0]=X[0],J[3]=X[1],J[6]=X[2],J[1]=K[0],J[4]=K[1],J[7]=K[2],J[2]=-Y[0],J[5]=-Y[1],J[8]=-Y[2],Lq(Z,oC(Z,J))}}();var q0={};s6(q0,{zero:()=>rK0,transformMat4:()=>aK0,transformMat3:()=>nK0,transformMat2d:()=>iK0,transformMat2:()=>dK0,subtract:()=>YS,sub:()=>Y$0,str:()=>tK0,squaredLength:()=>GS,squaredDistance:()=>QS,sqrLen:()=>F$0,sqrDist:()=>Q$0,set:()=>_K0,scaleAndAdd:()=>pK0,scale:()=>bK0,round:()=>hK0,rotate:()=>sK0,random:()=>uK0,normalize:()=>gK0,negate:()=>AK0,multiply:()=>XS,mul:()=>X$0,min:()=>IK0,max:()=>fK0,lerp:()=>lK0,length:()=>FS,len:()=>Z$0,inverse:()=>yK0,fromValues:()=>TK0,forEach:()=>G$0,floor:()=>SK0,exactEquals:()=>eK0,equals:()=>J$0,dot:()=>cK0,divide:()=>KS,div:()=>K$0,distance:()=>$S,dist:()=>$$0,cross:()=>mK0,create:()=>ZS,copy:()=>DK0,clone:()=>xK0,ceil:()=>CK0,angle:()=>oK0,add:()=>EK0});function ZS(){var J=new F0(2);if(F0!=Float32Array)J[0]=0,J[1]=0;return J}function xK0(J){var Z=new F0(2);return Z[0]=J[0],Z[1]=J[1],Z}function TK0(J,Z){var Y=new F0(2);return Y[0]=J,Y[1]=Z,Y}function DK0(J,Z){return J[0]=Z[0],J[1]=Z[1],J}function _K0(J,Z,Y){return J[0]=Z,J[1]=Y,J}function EK0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J}function YS(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J}function XS(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J}function KS(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J}function CK0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J}function SK0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J}function IK0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J}function fK0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J}function hK0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J}function bK0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J}function pK0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J}function $S(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Math.hypot(Y,X)}function QS(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Y*Y+X*X}function FS(J){var Z=J[0],Y=J[1];return Math.hypot(Z,Y)}function GS(J){var Z=J[0],Y=J[1];return Z*Z+Y*Y}function AK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J}function yK0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J}function gK0(J,Z){var Y=Z[0],X=Z[1],K=Y*Y+X*X;if(K>0)K=1/Math.sqrt(K);return J[0]=Z[0]*K,J[1]=Z[1]*K,J}function cK0(J,Z){return J[0]*Z[0]+J[1]*Z[1]}function mK0(J,Z,Y){var X=Z[0]*Y[1]-Z[1]*Y[0];return J[0]=J[1]=0,J[2]=X,J}function lK0(J,Z,Y,X){var K=Z[0],$=Z[1];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J}function uK0(J,Z){Z=Z||1;var Y=d6()*2*Math.PI;return J[0]=Math.cos(Y)*Z,J[1]=Math.sin(Y)*Z,J}function dK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K,J[1]=Y[1]*X+Y[3]*K,J}function iK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K+Y[4],J[1]=Y[1]*X+Y[3]*K+Y[5],J}function nK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[3]*K+Y[6],J[1]=Y[1]*X+Y[4]*K+Y[7],J}function aK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[4]*K+Y[12],J[1]=Y[1]*X+Y[5]*K+Y[13],J}function sK0(J,Z,Y,X){var K=Z[0]-Y[0],$=Z[1]-Y[1],Q=Math.sin(X),F=Math.cos(X);return J[0]=K*F-$*Q+Y[0],J[1]=K*Q+$*F+Y[1],J}function oK0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1],Q=Math.sqrt(Y*Y+X*X)*Math.sqrt(K*K+$*$),F=Q&&(Y*K+X*$)/Q;return Math.acos(Math.min(Math.max(F,-1),1))}function rK0(J){return J[0]=0,J[1]=0,J}function tK0(J){return"vec2("+J[0]+", "+J[1]+")"}function eK0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]}function J$0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1];return Math.abs(Y-K)<=l*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs(X-$)<=l*Math.max(1,Math.abs(X),Math.abs($))}var Z$0=FS,Y$0=YS,X$0=XS,K$0=KS,$$0=$S,Q$0=QS,F$0=GS,G$0=function(){var J=ZS();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=2;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1];return Z}}();class p9 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get determinant(){return J8.determinant(this)}get frobeniusNorm(){return J8.frob(this)}static create(){let J=new p9(0,0,0,0);return J8.identity(J),J}static fromRotation(J){let Z=p9.create();return J8.fromRotation(Z,J),Z}static fromScaling(J){let Z=p9.create();return J8.fromScaling(Z,J),Z}add(J){return J8.add(this,this,J),this}adjoint(){return J8.adjoint(this,this),this}clone(){return new p9(this[0],this[1],this[2],this[3])}copy(J){return J8.copy(this,J),this}equals(J){return J8.equals(this,J)}exactEquals(J){return J8.exactEquals(this,J)}identity(){return J8.identity(this),this}invert(){return J8.invert(this,this),this}multiply(J){return J8.mul(this,this,J),this}multiplyScalar(J){return J8.multiplyScalar(this,this,J),this}rotate(J){return J8.rotate(this,this,J),this}subtract(J){return J8.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return J8.transpose(this,this),this}}class i6 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G){super([J,Z,Y,X,K,$,Q,F,G])}get determinant(){return f0.determinant(this)}get frobeniusNorm(){return f0.frob(this)}static create(){let J=new i6(0,0,0,0,0,0,0,0,0);return f0.identity(J),J}static fromMatrix4(J){let Z=i6.create();return f0.fromMat4(Z,J),Z}static fromQuaternion(J){let Z=i6.create();return f0.fromQuat(Z,J),Z}static fromRotation(J){let Z=i6.create();return f0.fromRotation(Z,J),Z}static fromScaling(J){let Z=i6.create();return f0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=i6.create();return f0.fromTranslation(Z,J),Z}add(J){return f0.add(this,this,J),this}adjoint(){return f0.adjoint(this,this),this}clone(){return new i6(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(J){return f0.copy(this,J),this}equals(J){return f0.equals(this,J)}exactEquals(J){return f0.exactEquals(this,J)}identity(){return f0.identity(this),this}invert(){return f0.invert(this,this),this}multiply(J){return f0.mul(this,this,J),this}multiplyScalar(J){return f0.multiplyScalar(this,this,J),this}transformVector(J){return J.transformMatrix3(this)}projection(J,Z){return f0.projection(this,J,Z),this}rotate(J){return f0.rotate(this,this,J),this}subtract(J){return f0.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]},${this[2]}][${this[3]},${this[4]},${this[5]}][${this[6]},${this[7]},${this[8]}]`}transpose(){return f0.transpose(this,this),this}}class C8 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R){super([J,Z,Y,X,K,$,Q,F,G,W,V,q,z,U,M,R])}get determinant(){return Y0.determinant(this)}get frobeniusNorm(){return Y0.frob(this)}static create(){let J=new C8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return Y0.identity(J),J}static fromQuaternion(J){let Z=C8.create();return Y0.fromQuat(Z,J),Z}static fromRotation(J,Z){let Y=C8.create();return Y0.fromRotation(Y,J,Z),Y}static fromRotationTranslation(J,Z){let Y=C8.create();return Y0.fromRotationTranslation(Y,J,Z),Y}static fromRotationTranslationScale(J,Z,Y){let X=C8.create();return Y0.fromRotationTranslationScale(X,J,Z,Y),X}static fromRotationTranslationScaleOrigin(J,Z,Y,X){let K=C8.create();return Y0.fromRotationTranslationScaleOrigin(K,J,Z,Y,X),K}static fromScaling(J){let Z=C8.create();return Y0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=C8.create();return Y0.fromTranslation(Z,J),Z}static fromXRotation(J){let Z=C8.create();return Y0.fromXRotation(Z,J),Z}static fromYRotation(J){let Z=C8.create();return Y0.fromYRotation(Z,J),Z}static fromZRotation(J){let Z=C8.create();return Y0.fromZRotation(Z,J),Z}add(J){return Y0.add(this,this,J),this}adjoint(){return Y0.adjoint(this,this),this}clone(){return new C8(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8],this[9],this[10],this[11],this[12],this[13],this[14],this[15])}copy(J){return Y0.copy(this,J),this}equals(J){return Y0.equals(this,J)}exactEquals(J){return Y0.exactEquals(this,J)}frustrum(J,Z,Y,X,K,$){return Y0.frustum(this,J,Z,Y,X,K,$),this}identity(){return Y0.identity(this),this}invert(){return Y0.invert(this,this),this}lookAt(J,Z,Y){return Y0.lookAt(this,J,Z,Y),this}multiply(J){return Y0.mul(this,this,J),this}multiplyScalar(J){return Y0.multiplyScalar(this,this,J),this}orthographic(J,Z,Y,X,K,$){return Y0.ortho(this,J,Z,Y,X,K,$),this}perspective(J,Z,Y,X){return Y0.perspective(this,J,Z,Y,X),this}rotate(J,Z){return Y0.rotate(this,this,J,Z),this}rotateX(J){return Y0.rotateX(this,this,J),this}rotateY(J){return Y0.rotateY(this,this,J),this}rotateZ(J){return Y0.rotateZ(this,this,J),this}scale(J){return Y0.scale(this,this,J),this}subtract(J){return Y0.sub(this,this,J),this}targetTo(J,Z,Y){return Y0.targetTo(this,J,Z,Y),this}toString(){return`[${this[0]},${this[1]},${this[2]},${this[3]}][${this[4]},${this[5]},${this[6]},${this[7]}][${this[8]},${this[9]},${this[10]},${this[11]}][${this[12]},${this[13]},${this[14]},${this[15]}]`}translate(J){return Y0.translate(this,this,J),this}transpose(){return Y0.transpose(this,this),this}}class e5 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get length(){return v0.length(this)}get squaredLength(){return v0.squaredLength(this)}get magnitude(){return v0.length(this)}get squaredMagnitude(){return v0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}get w(){return this[3]}set w(J){this[3]=J}static fromEuler(J,Z,Y){let X=v0.fromEuler(new Float32Array(4),J,Z,Y);return new e5(X[0],X[1],X[2],X[3])}static fromQuaternionLike(J){return new e5(J.x,J.y,J.z,J.w)}clone(){return new e5(this.x,this.y,this.z,this.w)}conjugate(){return v0.conjugate(this,this),this}copy(J){return v0.copy(this,J),this}dot(J){return v0.dot(this,J)}exponential(){return v0.exp(this,this),this}equals(J){return v0.equals(this,J)}exactEquals(J){return v0.exactEquals(this,J)}getAngle(J){return v0.getAngle(this,J)}identity(){return v0.identity(this),this}invert(){return v0.invert(this,this),this}lerp(J,Z){return v0.lerp(this,this,J,Z),this}logarithm(){return v0.ln(this,this),this}multiply(J){return v0.multiply(this,this,J),this}transformVector(J){return J.transformQuaternion(this)}normalize(){return v0.normalize(this,this),this}power(J){return v0.pow(this,this,J),this}randomize(){return v0.random(this),this}rotateX(J){return v0.rotateX(this,this,J),this}rotateY(J){return v0.rotateY(this,this,J),this}rotateZ(J){return v0.rotateZ(this,this,J),this}scale(J){return v0.scale(this,this,J),this}setAxisAngle(J,Z){return v0.setAxisAngle(this,J,Z),this}slerp(J,Z){return v0.slerp(this,this,J,Z),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class AJ extends Float32Array{constructor(J,Z){super([J,Z])}get length(){return q0.length(this)}get squaredLength(){return q0.squaredLength(this)}get magnitude(){return q0.length(this)}get squaredMagnitude(){return q0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}static create(){return new AJ(0,0)}add(J){return q0.add(this,this,J),this}angle(J){return q0.angle(this,J)}ceil(){return q0.ceil(this,this),this}clone(){return new AJ(this.x,this.y)}copy(J){return q0.copy(this,J),this}distance(J){return q0.distance(this,J)}divide(J){return q0.divide(this,this,J),this}dot(J){return q0.dot(this,J)}equals(J){return q0.equals(this,J)}exactEquals(J){return q0.exactEquals(this,J)}floor(){return q0.floor(this,this),this}invert(){return q0.inverse(this,this),this}lerp(J,Z){return q0.lerp(this,this,J,Z),this}max(J){return q0.max(this,this,J),this}min(J){return q0.min(this,this,J),this}multiply(J){return q0.mul(this,this,J),this}negate(){return q0.negate(this,this),this}normalize(){return q0.normalize(this,this),this}randomize(J){return q0.random(this,J),this}rotate(J,Z){return q0.rotate(this,this,J,Z),this}round(){return q0.round(this,this),this}scale(J){return q0.scale(this,this,J),this}scaleAndAdd(J,Z){return q0.scaleAndAdd(this,this,J,Z),this}subtract(J){return q0.sub(this,this,J),this}toString(){return`${this.x},${this.y}`}transformMatrix2(J){return q0.transformMat2(this,this,J),this}transformMatrix3(J){return q0.transformMat3(this,this,J),this}transformMatrix4(J){return q0.transformMat4(this,this,J),this}zero(){return q0.zero(this),this}}class J4 extends Float32Array{constructor(J,Z,Y){super([J,Z,Y])}get length(){return $0.length(this)}get squaredLength(){return $0.squaredLength(this)}get magnitude(){return $0.length(this)}get squaredMagnitude(){return $0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}static create(){return new J4(0,0,0)}static fromVector3Like(J){return new J4(J.x,J.y,J.z)}add(J){return $0.add(this,this,J),this}ceil(){return $0.ceil(this,this),this}clone(){return new J4(this.x,this.y,this.z)}copy(J){return $0.copy(this,J),this}cross(J){return $0.cross(this,this,J),this}distance(J){return $0.distance(this,J)}divide(J){return $0.div(this,this,J),this}dot(J){return $0.dot(this,J)}equals(J){return $0.equals(this,J)}exactEquals(J){return $0.exactEquals(this,J)}floor(){return $0.floor(this,this),this}invert(){return $0.inverse(this,this),this}lerp(J,Z){return $0.lerp(this,this,J,Z),this}max(J){return $0.max(this,this,J),this}min(J){return $0.min(this,this,J),this}multiply(J){return $0.mul(this,this,J),this}negate(){return $0.negate(this,this),this}normalize(){return $0.normalize(this,this),this}randomize(J){return $0.random(this,J),this}rotateX(J,Z){return $0.rotateX(this,this,J,Z),this}rotateY(J,Z){return $0.rotateY(this,this,J,Z),this}rotateZ(J,Z){return $0.rotateZ(this,this,J,Z),this}round(){return $0.round(this,this),this}scale(J){return $0.scale(this,this,J),this}scaleAndAdd(J,Z){return $0.scaleAndAdd(this,this,J,Z),this}subtract(J){return $0.sub(this,this,J),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(J){return $0.transformMat3(this,this,J),this}transformMatrix4(J){return $0.transformMat4(this,this,J),this}transformQuaternion(J){return $0.transformQuat(this,this,J),this}zero(){return $0.zero(this),this}}var j0=function(J,Z,Y,X){function K($){return $ instanceof Y?$:new Y(function(Q){Q($)})}return new(Y||(Y=Promise))(function($,Q){function F(V){try{W(X.next(V))}catch(q){Q(q)}}function G(V){try{W(X.throw(V))}catch(q){Q(q)}}function W(V){V.done?$(V.value):K(V.value).then(F,G)}W((X=X.apply(J,Z||[])).next())})},B0=function(J,Z){var Y={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},X,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=F(0),Q.throw=F(1),Q.return=F(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function F(W){return function(V){return G([W,V])}}function G(W){if(X)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(Y=0)),Y)try{if(X=1,K&&($=W[0]&2?K.return:W[0]?K.throw||(($=K.return)&&$.call(K),0):K.next)&&!($=$.call(K,W[1])).done)return $;if(K=0,$)W=[W[0]&2,$.value];switch(W[0]){case 0:case 1:$=W;break;case 4:return Y.label++,{value:W[1],done:!1};case 5:Y.label++,K=W[1],W=[0];continue;case 7:W=Y.ops.pop(),Y.trys.pop();continue;default:if(($=Y.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){Y=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){Y.label=W[1];break}if(W[0]===6&&Y.label<$[1]){Y.label=$[1],$=W;break}if($&&Y.label<$[2]){Y.label=$[2],Y.ops.push(W);break}if($[2])Y.ops.pop();Y.trys.pop();continue}W=Z.call(J,Y)}catch(V){W=[6,V],K=0}finally{X=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},m8=function(J,Z){var Y=typeof Symbol==="function"&&J[Symbol.iterator];if(!Y)return J;var X=Y.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=X.next()).done)$.push(K.value)}catch(F){Q={error:F}}finally{try{if(K&&!K.done&&(Y=X.return))Y.call(X)}finally{if(Q)throw Q.error}}return $},F6=function(J,Z,Y){if(Y||arguments.length===2){for(var X=0,K=Z.length,$;X<K;X++)if($||!(X in Z)){if(!$)$=Array.prototype.slice.call(Z,0,X);$[X]=Z[X]}}return J.concat($||Array.prototype.slice.call(Z))},WS=function(J){var Z=typeof Symbol==="function"&&Symbol.iterator,Y=Z&&J[Z],X=0;if(Y)return Y.call(J);if(J&&typeof J.length==="number")return{next:function(){if(J&&X>=J.length)J=void 0;return{value:J&&J[X++],done:!J}}};throw new TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")},yD0=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var Y=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(X,K){return Y.compare(X,K).then(function($){return-1*$})}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:2;return Math.floor((Z-Y)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:-1;return Z+Y},J.minComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Z>Y)return[2,1];else if(Z<Y)return[2,-1];else return[2,0]})})},J.maxComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Y>Z)return[2,1];else if(Y<Z)return[2,-1];else return[2,0]})})},J.minComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z-Y]})})},J.maxComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Y-Z]})})},J.defaultIsEqual=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z===Y]})})},J.print=function(Z){function Y(V){var q=J.getParentIndexOf(V);return Math.floor(Math.log2(q+1))}function X(V,q){var z="";for(;q>0;--q)z+=V;return z}var K=0,$=[],Q=Y(Z.length-1)+2,F=0;while(K<Z.length){var G=Y(K)+1;if(K===0)G=0;var W=String(Z.get(K));if(W.length>F)F=W.length;$[G]=$[G]||[],$[G].push(W),K+=1}return $.map(function(V,q){var z=Math.pow(2,Q-q)-1;return X(" ",Math.floor(z/2)*F)+V.map(function(U){var M=(F-U.length)/2;return X(" ",Math.ceil(M))+U+X(" ",Math.floor(M))}).join(X(" ",z*F))}).join(`
386
386
  `)},J.heapify=function(Z,Y){return j0(this,void 0,void 0,function(){var X;return B0(this,function(K){switch(K.label){case 0:return X=new J(Y),X.heapArray=Z,[4,X.init()];case 1:return K.sent(),[2,X]}})})},J.heappop=function(Z,Y){var X=new J(Y);return X.heapArray=Z,X.pop()},J.heappush=function(Z,Y,X){return j0(this,void 0,void 0,function(){var K;return B0(this,function($){switch($.label){case 0:return K=new J(X),K.heapArray=Z,[4,K.push(Y)];case 1:return $.sent(),[2]}})})},J.heappushpop=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.pushpop(Y)},J.heapreplace=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.replace(Y)},J.heaptop=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.top(Y)},J.heapbottom=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.bottom(Y)},J.nlargest=function(Z,Y,X){return j0(this,void 0,void 0,function(){var K;return B0(this,function($){switch($.label){case 0:return K=new J(X),K.heapArray=F6([],m8(Y),!1),[4,K.init()];case 1:return $.sent(),[2,K.top(Z)]}})})},J.nsmallest=function(Z,Y,X){return j0(this,void 0,void 0,function(){var K;return B0(this,function($){switch($.label){case 0:return K=new J(X),K.heapArray=F6([],m8(Y),!1),[4,K.init()];case 1:return $.sent(),[2,K.bottom(Z)]}})})},J.prototype.add=function(Z){return j0(this,void 0,void 0,function(){return B0(this,function(Y){switch(Y.label){case 0:return[4,this._sortNodeUp(this.heapArray.push(Z)-1)];case 1:return Y.sent(),this._applyLimit(),[2,!0]}})})},J.prototype.addAll=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K;return B0(this,function($){switch($.label){case 0:Y=this.length,(K=this.heapArray).push.apply(K,F6([],m8(Z),!1)),X=this.length,$.label=1;case 1:if(!(Y<X))return[3,4];return[4,this._sortNodeUp(Y)];case 2:$.sent(),$.label=3;case 3:return++Y,[3,1];case 4:return this._applyLimit(),[2,!0]}})})},J.prototype.bottom=function(){return j0(this,arguments,void 0,function(Z){if(Z===void 0)Z=1;return B0(this,function(Y){if(this.heapArray.length===0||Z<=0)return[2,[]];else if(this.heapArray.length===1)return[2,[this.heapArray[0]]];else if(Z>=this.heapArray.length)return[2,F6([],m8(this.heapArray),!1)];else return[2,this._bottomN_push(~~Z)]})})},J.prototype.check=function(){return j0(this,void 0,void 0,function(){var Z,Y,X,K,$,Q,F,G,W;return B0(this,function(V){switch(V.label){case 0:Z=0,V.label=1;case 1:if(!(Z<this.heapArray.length))return[3,10];Y=this.heapArray[Z],X=this.getChildrenOf(Z),V.label=2;case 2:V.trys.push([2,7,8,9]),K=(G=void 0,WS(X)),$=K.next(),V.label=3;case 3:if($.done)return[3,6];return Q=$.value,[4,this.compare(Y,Q)];case 4:if(V.sent()>0)return[2,Y];V.label=5;case 5:return $=K.next(),[3,3];case 6:return[3,9];case 7:return F=V.sent(),G={error:F},[3,9];case 8:try{if($&&!$.done&&(W=K.return))W.call(K)}finally{if(G)throw G.error}return[7];case 9:return++Z,[3,1];case 10:return[2]}})})},J.prototype.clear=function(){this.heapArray=[]},J.prototype.clone=function(){var Z=new J(this.comparator());return Z.heapArray=this.toArray(),Z._limit=this._limit,Z},J.prototype.comparator=function(){return this.compare},J.prototype.contains=function(Z){return j0(this,arguments,void 0,function(Y,X){var K,$,Q,F,G,W;if(X===void 0)X=J.defaultIsEqual;return B0(this,function(V){switch(V.label){case 0:V.trys.push([0,5,6,7]),K=WS(this.heapArray),$=K.next(),V.label=1;case 1:if($.done)return[3,4];return Q=$.value,[4,X(Q,Y)];case 2:if(V.sent())return[2,!0];V.label=3;case 3:return $=K.next(),[3,1];case 4:return[3,7];case 5:return F=V.sent(),G={error:F},[3,7];case 6:try{if($&&!$.done&&(W=K.return))W.call(K)}finally{if(G)throw G.error}return[7];case 7:return[2,!1]}})})},J.prototype.init=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:if(Z)this.heapArray=F6([],m8(Z),!1);Y=Math.floor(this.heapArray.length),X.label=1;case 1:if(!(Y>=0))return[3,4];return[4,this._sortNodeDown(Y)];case 2:X.sent(),X.label=3;case 3:return--Y,[3,1];case 4:return this._applyLimit(),[2]}})})},J.prototype.isEmpty=function(){return this.length===0},J.prototype.leafs=function(){if(this.heapArray.length===0)return[];var Z=J.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(Z+1)},Object.defineProperty(J.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"limit",{get:function(){return this._limit},set:function(Z){this._limit=~~Z,this._applyLimit()},enumerable:!1,configurable:!0}),J.prototype.peek=function(){return this.heapArray[0]},J.prototype.pop=function(){return j0(this,void 0,void 0,function(){var Z;return B0(this,function(Y){if(Z=this.heapArray.pop(),this.length>0&&Z!==void 0)return[2,this.replace(Z)];return[2,Z]})})},J.prototype.push=function(){var Z=[];for(var Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Z.length<1)return[2,!1];else if(Z.length===1)return[2,this.add(Z[0])];else return[2,this.addAll(Z)]})})},J.prototype.pushpop=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:return[4,this.compare(this.heapArray[0],Z)];case 1:if(!(X.sent()<0))return[3,3];return Y=m8([this.heapArray[0],Z],2),Z=Y[0],this.heapArray[0]=Y[1],[4,this._sortNodeDown(0)];case 2:X.sent(),X.label=3;case 3:return[2,Z]}})})},J.prototype.remove=function(Z){return j0(this,arguments,void 0,function(Y,X){var K,$,Q,F=this;if(X===void 0)X=J.defaultIsEqual;return B0(this,function(G){switch(G.label){case 0:if(!this.heapArray.length)return[2,!1];if(Y!==void 0)return[3,2];return[4,this.pop()];case 1:return G.sent(),[2,!0];case 2:K=[0],G.label=3;case 3:if(!K.length)return[3,13];return $=K.shift(),[4,X(this.heapArray[$],Y)];case 4:if(!G.sent())return[3,11];if($!==0)return[3,6];return[4,this.pop()];case 5:return G.sent(),[3,10];case 6:if($!==this.heapArray.length-1)return[3,7];return this.heapArray.pop(),[3,10];case 7:return this.heapArray.splice($,1,this.heapArray.pop()),[4,this._sortNodeUp($)];case 8:return G.sent(),[4,this._sortNodeDown($)];case 9:G.sent(),G.label=10;case 10:return[2,!0];case 11:Q=J.getChildrenIndexOf($).filter(function(W){return W<F.heapArray.length}),K.push.apply(K,F6([],m8(Q),!1)),G.label=12;case 12:return[3,3];case 13:return[2,!1]}})})},J.prototype.replace=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:return Y=this.heapArray[0],this.heapArray[0]=Z,[4,this._sortNodeDown(0)];case 1:return X.sent(),[2,Y]}})})},J.prototype.size=function(){return this.length},J.prototype.top=function(){return j0(this,arguments,void 0,function(Z){if(Z===void 0)Z=1;return B0(this,function(Y){if(this.heapArray.length===0||Z<=0)return[2,[]];else if(this.heapArray.length===1||Z===1)return[2,[this.heapArray[0]]];else if(Z>=this.heapArray.length)return[2,F6([],m8(this.heapArray),!1)];else return[2,this._topN_push(~~Z)]})})},J.prototype.toArray=function(){return F6([],m8(this.heapArray),!1)},J.prototype.toString=function(){return this.heapArray.toString()},J.prototype.get=function(Z){return this.heapArray[Z]},J.prototype.getChildrenOf=function(Z){var Y=this;return J.getChildrenIndexOf(Z).map(function(X){return Y.heapArray[X]}).filter(function(X){return X!==void 0})},J.prototype.getParentOf=function(Z){var Y=J.getParentIndexOf(Z);return this.heapArray[Y]},J.prototype[Symbol.iterator]=function(){return B0(this,function(Z){switch(Z.label){case 0:if(!this.length)return[3,2];return[4,this.pop()];case 1:return Z.sent(),[3,0];case 2:return[2]}})},J.prototype.iterator=function(){return this},J.prototype._applyLimit=function(){if(this._limit&&this._limit<this.heapArray.length){var Z=this.heapArray.length-this._limit;while(Z)this.heapArray.pop(),--Z}},J.prototype._bottomN_push=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,F,Q,F;return B0(this,function(G){switch(G.label){case 0:return Y=new J(this.compare),Y.limit=Z,Y.heapArray=this.heapArray.slice(-Z),[4,Y.init()];case 1:G.sent(),X=this.heapArray.length-1-Z,K=J.getParentIndexOf(X),$=[];for(F=X;F>K;--F)$.push(F);Q=this.heapArray,G.label=2;case 2:if(!$.length)return[3,6];return F=$.shift(),[4,this.compare(Q[F],Y.peek())];case 3:if(!(G.sent()>0))return[3,5];return[4,Y.replace(Q[F])];case 4:if(G.sent(),F%2)$.push(J.getParentIndexOf(F));G.label=5;case 5:return[3,2];case 6:return[2,Y.toArray()]}})})},J.prototype._moveNode=function(Z,Y){var X;X=m8([this.heapArray[Y],this.heapArray[Z]],2),this.heapArray[Z]=X[0],this.heapArray[Y]=X[1]},J.prototype._sortNodeDown=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,Q,F;return B0(this,function(G){switch(G.label){case 0:Y=this.heapArray.length,G.label=1;case 1:if(X=2*Z+1,K=X+1,$=Z,Q=X<Y,!Q)return[3,3];return[4,this.compare(this.heapArray[X],this.heapArray[$])];case 2:Q=G.sent()<0,G.label=3;case 3:if(Q)$=X;if(F=K<Y,!F)return[3,5];return[4,this.compare(this.heapArray[K],this.heapArray[$])];case 4:F=G.sent()<0,G.label=5;case 5:if(F)$=K;if($===Z)return[3,7];this._moveNode(Z,$),Z=$,G.label=6;case 6:return[3,1];case 7:return[2]}})})},J.prototype._sortNodeUp=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:if(!(Z>0))return[3,2];return Y=J.getParentIndexOf(Z),[4,this.compare(this.heapArray[Z],this.heapArray[Y])];case 1:if(X.sent()<0)this._moveNode(Z,Y),Z=Y;else return[3,2];return[3,0];case 2:return[2]}})})},J.prototype._topN_push=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$;return B0(this,function(Q){switch(Q.label){case 0:Y=new J(this._invertedCompare),Y.limit=Z,X=[0],K=this.heapArray,Q.label=1;case 1:if(!X.length)return[3,7];if($=X.shift(),!($<K.length))return[3,6];if(!(Y.length<Z))return[3,3];return[4,Y.push(K[$])];case 2:return Q.sent(),X.push.apply(X,F6([],m8(J.getChildrenIndexOf($)),!1)),[3,6];case 3:return[4,this.compare(K[$],Y.peek())];case 4:if(!(Q.sent()<0))return[3,6];return[4,Y.replace(K[$])];case 5:Q.sent(),X.push.apply(X,F6([],m8(J.getChildrenIndexOf($)),!1)),Q.label=6;case 6:return[3,1];case 7:return[2,Y.toArray()]}})})},J.prototype._topN_fill=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,Q,Q;return B0(this,function(F){switch(F.label){case 0:return Y=this.heapArray,X=new J(this._invertedCompare),X.limit=Z,X.heapArray=Y.slice(0,Z),[4,X.init()];case 1:F.sent(),K=J.getParentIndexOf(Z-1)+1,$=[];for(Q=K;Q<Z;++Q)$.push.apply($,F6([],m8(J.getChildrenIndexOf(Q).filter(function(G){return G<Y.length})),!1));if((Z-1)%2)$.push(Z);F.label=2;case 2:if(!$.length)return[3,6];if(Q=$.shift(),!(Q<Y.length))return[3,5];return[4,this.compare(Y[Q],X.peek())];case 3:if(!(F.sent()<0))return[3,5];return[4,X.replace(Y[Q])];case 4:F.sent(),$.push.apply($,F6([],m8(J.getChildrenIndexOf(Q)),!1)),F.label=5;case 5:return[3,2];case 6:return[2,X.toArray()]}})})},J.prototype._topN_heap=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,Q;return B0(this,function(F){switch(F.label){case 0:Y=this.clone(),X=[],K=0,F.label=1;case 1:if(!(K<Z))return[3,4];return Q=($=X).push,[4,Y.pop()];case 2:Q.apply($,[F.sent()]),F.label=3;case 3:return++K,[3,1];case 4:return[2,X]}})})},J.prototype._topIdxOf=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$;return B0(this,function(Q){switch(Q.label){case 0:if(!Z.length)return[2,-1];Y=0,X=Z[Y],K=1,Q.label=1;case 1:if(!(K<Z.length))return[3,4];return[4,this.compare(Z[K],X)];case 2:if($=Q.sent(),$<0)Y=K,X=Z[K];Q.label=3;case 3:return++K,[3,1];case 4:return[2,Y]}})})},J.prototype._topOf=function(){var Z=[];for(var Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];return j0(this,void 0,void 0,function(){var X;return B0(this,function(K){switch(K.label){case 0:return X=new J(this.compare),[4,X.init(Z)];case 1:return K.sent(),[2,X.peek()]}})})},J}(),W$0=function(J,Z){var Y={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},X,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=F(0),Q.throw=F(1),Q.return=F(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function F(W){return function(V){return G([W,V])}}function G(W){if(X)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(Y=0)),Y)try{if(X=1,K&&($=W[0]&2?K.return:W[0]?K.throw||(($=K.return)&&$.call(K),0):K.next)&&!($=$.call(K,W[1])).done)return $;if(K=0,$)W=[W[0]&2,$.value];switch(W[0]){case 0:case 1:$=W;break;case 4:return Y.label++,{value:W[1],done:!1};case 5:Y.label++,K=W[1],W=[0];continue;case 7:W=Y.ops.pop(),Y.trys.pop();continue;default:if(($=Y.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){Y=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){Y.label=W[1];break}if(W[0]===6&&Y.label<$[1]){Y.label=$[1],$=W;break}if($&&Y.label<$[2]){Y.label=$[2],Y.ops.push(W);break}if($[2])Y.ops.pop();Y.trys.pop();continue}W=Z.call(J,Y)}catch(V){W=[6,V],K=0}finally{X=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},U8=function(J,Z){var Y=typeof Symbol==="function"&&J[Symbol.iterator];if(!Y)return J;var X=Y.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=X.next()).done)$.push(K.value)}catch(F){Q={error:F}}finally{try{if(K&&!K.done&&(Y=X.return))Y.call(X)}finally{if(Q)throw Q.error}}return $},S8=function(J,Z,Y){if(Y||arguments.length===2){for(var X=0,K=Z.length,$;X<K;X++)if($||!(X in Z)){if(!$)$=Array.prototype.slice.call(Z,0,X);$[X]=Z[X]}}return J.concat($||Array.prototype.slice.call(Z))};var VS=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var Y=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this.removeAll=this.clear,this._invertedCompare=function(X,K){return-1*Y.compare(X,K)}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:2;return Math.floor((Z-Y)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:-1;return Z+Y},J.minComparator=function(Z,Y){if(Z>Y)return 1;else if(Z<Y)return-1;else return 0},J.maxComparator=function(Z,Y){if(Y>Z)return 1;else if(Y<Z)return-1;else return 0},J.minComparatorNumber=function(Z,Y){return Z-Y},J.maxComparatorNumber=function(Z,Y){return Y-Z},J.defaultIsEqual=function(Z,Y){return Z===Y},J.print=function(Z){function Y(V){var q=J.getParentIndexOf(V);return Math.floor(Math.log2(q+1))}function X(V,q){var z="";for(;q>0;--q)z+=V;return z}var K=0,$=[],Q=Y(Z.length-1)+2,F=0;while(K<Z.length){var G=Y(K)+1;if(K===0)G=0;var W=String(Z.get(K));if(W.length>F)F=W.length;$[G]=$[G]||[],$[G].push(W),K+=1}return $.map(function(V,q){var z=Math.pow(2,Q-q)-1;return X(" ",Math.floor(z/2)*F)+V.map(function(U){var M=(F-U.length)/2;return X(" ",Math.ceil(M))+U+X(" ",Math.floor(M))}).join(X(" ",z*F))}).join(`
387
387
  `)},J.heapify=function(Z,Y){var X=new J(Y);return X.heapArray=Z,X.init(),X},J.heappop=function(Z,Y){var X=new J(Y);return X.heapArray=Z,X.pop()},J.heappush=function(Z,Y,X){var K=new J(X);K.heapArray=Z,K.push(Y)},J.heappushpop=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.pushpop(Y)},J.heapreplace=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.replace(Y)},J.heaptop=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.top(Y)},J.heapbottom=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.bottom(Y)},J.nlargest=function(Z,Y,X){var K=new J(X);return K.heapArray=S8([],U8(Y),!1),K.init(),K.top(Z)},J.nsmallest=function(Z,Y,X){var K=new J(X);return K.heapArray=S8([],U8(Y),!1),K.init(),K.bottom(Z)},J.prototype.add=function(Z){return this._sortNodeUp(this.heapArray.push(Z)-1),this._applyLimit(),!0},J.prototype.addAll=function(Z){var Y,X=this.length;(Y=this.heapArray).push.apply(Y,S8([],U8(Z),!1));for(var K=this.length;X<K;++X)this._sortNodeUp(X);return this._applyLimit(),!0},J.prototype.bottom=function(Z){if(Z===void 0)Z=1;if(this.heapArray.length===0||Z<=0)return[];else if(this.heapArray.length===1)return[this.heapArray[0]];else if(Z>=this.heapArray.length)return S8([],U8(this.heapArray),!1);else return this._bottomN_push(~~Z)},J.prototype.check=function(){var Z=this;return this.heapArray.find(function(Y,X){return!!Z.getChildrenOf(X).find(function(K){return Z.compare(Y,K)>0})})},J.prototype.clear=function(){this.heapArray=[]},J.prototype.clone=function(){var Z=new J(this.comparator());return Z.heapArray=this.toArray(),Z._limit=this._limit,Z},J.prototype.comparator=function(){return this.compare},J.prototype.contains=function(Z,Y){if(Y===void 0)Y=J.defaultIsEqual;return this.indexOf(Z,Y)!==-1},J.prototype.init=function(Z){if(Z)this.heapArray=S8([],U8(Z),!1);for(var Y=Math.floor(this.heapArray.length);Y>=0;--Y)this._sortNodeDown(Y);this._applyLimit()},J.prototype.isEmpty=function(){return this.length===0},J.prototype.indexOf=function(Z,Y){if(Y===void 0)Y=J.defaultIsEqual;if(this.heapArray.length===0)return-1;var X=[],K=0;while(K<this.heapArray.length){var $=this.heapArray[K];if(Y($,Z))return K;else if(this.compare($,Z)<=0)X.push.apply(X,S8([],U8(J.getChildrenIndexOf(K)),!1));K=X.shift()||this.heapArray.length}return-1},J.prototype.indexOfEvery=function(Z,Y){if(Y===void 0)Y=J.defaultIsEqual;if(this.heapArray.length===0)return[];var X=[],K=[],$=0;while($<this.heapArray.length){var Q=this.heapArray[$];if(Y(Q,Z))K.push($),X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1));else if(this.compare(Q,Z)<=0)X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1));$=X.shift()||this.heapArray.length}return K},J.prototype.leafs=function(){if(this.heapArray.length===0)return[];var Z=J.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(Z+1)},Object.defineProperty(J.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"limit",{get:function(){return this._limit},set:function(Z){if(Z<0||isNaN(Z))this._limit=0;else this._limit=~~Z;this._applyLimit()},enumerable:!1,configurable:!0}),J.prototype.setLimit=function(Z){if(this.limit=Z,Z<0||isNaN(Z))return NaN;else return this._limit},J.prototype.peek=function(){return this.heapArray[0]},J.prototype.pop=function(){var Z=this.heapArray.pop();if(this.length>0&&Z!==void 0)return this.replace(Z);return Z},J.prototype.push=function(){var Z=[];for(var Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];if(Z.length<1)return!1;else if(Z.length===1)return this.add(Z[0]);else return this.addAll(Z)},J.prototype.pushpop=function(Z){var Y;if(this.compare(this.heapArray[0],Z)<0)Y=U8([this.heapArray[0],Z],2),Z=Y[0],this.heapArray[0]=Y[1],this._sortNodeDown(0);return Z},J.prototype.remove=function(Z,Y){var X=this;if(Y===void 0)Y=J.defaultIsEqual;if(!this.heapArray.length)return!1;if(Z===void 0)return this.pop(),!0;var K=[0];while(K.length){var $=K.shift();if(Y(this.heapArray[$],Z)){if($===0)this.pop();else if($===this.heapArray.length-1)this.heapArray.pop();else this.heapArray.splice($,1,this.heapArray.pop()),this._sortNodeUp($),this._sortNodeDown($);return!0}else if(this.compare(this.heapArray[$],Z)<=0){var Q=J.getChildrenIndexOf($).filter(function(F){return F<X.heapArray.length});K.push.apply(K,S8([],U8(Q),!1))}}return!1},J.prototype.replace=function(Z){var Y=this.heapArray[0];return this.heapArray[0]=Z,this._sortNodeDown(0),Y},J.prototype.size=function(){return this.length},J.prototype.top=function(Z){if(Z===void 0)Z=1;if(this.heapArray.length===0||Z<=0)return[];else if(this.heapArray.length===1||Z===1)return[this.heapArray[0]];else if(Z>=this.heapArray.length)return S8([],U8(this.heapArray),!1);else return this._topN_push(~~Z)},J.prototype.toArray=function(){return S8([],U8(this.heapArray),!1)},J.prototype.toString=function(){return this.heapArray.toString()},J.prototype.get=function(Z){return this.heapArray[Z]},J.prototype.getChildrenOf=function(Z){var Y=this;return J.getChildrenIndexOf(Z).map(function(X){return Y.heapArray[X]}).filter(function(X){return X!==void 0})},J.prototype.getParentOf=function(Z){var Y=J.getParentIndexOf(Z);return this.heapArray[Y]},J.prototype[Symbol.iterator]=function(){return W$0(this,function(Z){switch(Z.label){case 0:if(!this.length)return[3,2];return[4,this.pop()];case 1:return Z.sent(),[3,0];case 2:return[2]}})},J.prototype.iterator=function(){return this.toArray()},J.prototype._applyLimit=function(){if(this._limit>0&&this._limit<this.heapArray.length){var Z=this.heapArray.length-this._limit;while(Z)this.heapArray.pop(),--Z}},J.prototype._bottomN_push=function(Z){var Y=new J(this.compare);Y.limit=Z,Y.heapArray=this.heapArray.slice(-Z),Y.init();var X=this.heapArray.length-1-Z,K=J.getParentIndexOf(X),$=[];for(var Q=X;Q>K;--Q)$.push(Q);var F=this.heapArray;while($.length){var Q=$.shift();if(this.compare(F[Q],Y.peek())>0){if(Y.replace(F[Q]),Q%2)$.push(J.getParentIndexOf(Q))}}return Y.toArray()},J.prototype._moveNode=function(Z,Y){var X;X=U8([this.heapArray[Y],this.heapArray[Z]],2),this.heapArray[Z]=X[0],this.heapArray[Y]=X[1]},J.prototype._sortNodeDown=function(Z){var Y=this.heapArray.length;while(!0){var X=2*Z+1,K=X+1,$=Z;if(X<Y&&this.compare(this.heapArray[X],this.heapArray[$])<0)$=X;if(K<Y&&this.compare(this.heapArray[K],this.heapArray[$])<0)$=K;if($===Z)break;this._moveNode(Z,$),Z=$}},J.prototype._sortNodeUp=function(Z){while(Z>0){var Y=J.getParentIndexOf(Z);if(this.compare(this.heapArray[Z],this.heapArray[Y])<0)this._moveNode(Z,Y),Z=Y;else break}},J.prototype._topN_push=function(Z){var Y=new J(this._invertedCompare);Y.limit=Z;var X=[0],K=this.heapArray;while(X.length){var $=X.shift();if($<K.length){if(Y.length<Z)Y.push(K[$]),X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1));else if(this.compare(K[$],Y.peek())<0)Y.replace(K[$]),X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1))}}return Y.toArray()},J.prototype._topN_fill=function(Z){var Y=this.heapArray,X=new J(this._invertedCompare);X.limit=Z,X.heapArray=Y.slice(0,Z),X.init();var K=J.getParentIndexOf(Z-1)+1,$=[];for(var Q=K;Q<Z;++Q)$.push.apply($,S8([],U8(J.getChildrenIndexOf(Q).filter(function(F){return F<Y.length})),!1));if((Z-1)%2)$.push(Z);while($.length){var Q=$.shift();if(Q<Y.length){if(this.compare(Y[Q],X.peek())<0)X.replace(Y[Q]),$.push.apply($,S8([],U8(J.getChildrenIndexOf(Q)),!1))}}return X.toArray()},J.prototype._topN_heap=function(Z){var Y=this.clone(),X=[];for(var K=0;K<Z;++K)X.push(Y.pop());return X},J.prototype._topIdxOf=function(Z){if(!Z.length)return-1;var Y=0,X=Z[Y];for(var K=1;K<Z.length;++K){var $=this.compare(Z[K],X);if($<0)Y=K,X=Z[K]}return Y},J.prototype._topOf=function(){var Z=[];for(var Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];var X=new J(this.compare);return X.init(Z),X.peek()},J}();class yJ extends n1{_faceSpeed=0;_faceTarget;_jumpHeight=0;_moveSpeed=0;_moveTarget;_moveIgnoreAxes={};_onFace;_onFaceComplete;_onMove;_onMoveComplete;face(J,Z,Y){this._faceTarget=J,this._faceSpeed=Z,this._onFace=Y?.faceCallback,this._onFaceComplete=Y?.faceCompleteCallback}jump(J){this._jumpHeight=J}move(J,Z,Y){this._moveTarget=J,this._moveSpeed=Z,this._moveIgnoreAxes=Y?.moveIgnoreAxes??{},this._onMove=Y?.moveCallback,this._onMoveComplete=Y?.moveCompleteCallback}tick(J,Z){if(super.tick(J,Z),!this._moveTarget&&!this._faceTarget&&!this._jumpHeight)return;let Y=Z/1000,X=J.position;if(J.isDynamic&&this._jumpHeight>0){let K=Math.abs(J.world.simulation.gravity.y),$=Math.sqrt(2*K*this._jumpHeight);J.applyImpulse({x:0,y:$*J.mass,z:0}),this._jumpHeight=0}if(this._moveTarget){let K={x:this._moveIgnoreAxes.x?0:this._moveTarget.x-X.x,y:this._moveIgnoreAxes.y?0:this._moveTarget.y-X.y,z:this._moveIgnoreAxes.z?0:this._moveTarget.z-X.z},$=K.x*K.x+K.y*K.y+K.z*K.z;if($>0.1){let Q=Math.sqrt($),F=this._moveSpeed*Y,W=Math.min(Q,F)/Q,V={x:X.x+K.x*W,y:X.y+K.y*W,z:X.z+K.z*W};if(J.setPosition(V),this._onMove)this._onMove(V,this._moveTarget)}else if(this._moveTarget=void 0,this._onMoveComplete){let Q=this._onMoveComplete;this._onMove=void 0,this._onMoveComplete=void 0,Q(X)}}if(this._faceTarget){let K={x:this._faceTarget.x-X.x,z:this._faceTarget.z-X.z},$=Math.atan2(-K.x,-K.z),Q=J.rotation,F=Math.atan2(2*(Q.w*Q.y),1-2*(Q.y*Q.y)),G=$-F;while(G>Math.PI)G-=2*Math.PI;while(G<-Math.PI)G+=2*Math.PI;if(Math.abs(G)>0.01){let W=this._faceSpeed*Y,V=Math.abs(G)<W?G:Math.sign(G)*W,z=(F+V)/2,U={x:0,y:Math.fround(Math.sin(z)),z:0,w:Math.fround(Math.cos(z))};if(J.setRotation(U),this._onFace)this._onFace(Q,U)}else if(this._faceTarget=void 0,this._onFaceComplete){let W=this._onFaceComplete;this._onFaceComplete=void 0,W(J.rotation)}}}}class Uq extends yJ{_debug=!1;_entity;_maxFall=0;_maxJump=0;_maxOpenSetIterations=200;_onPathfindAbort;_onPathfindComplete;_onWaypointMoveComplete;_onWaypointMoveSkipped;_speed=0;_target;_verticalPenalty=0;_waypoints=[];_waypointNextIndex=0;_waypointTimeoutMs=2000;get debug(){return this._debug}get maxFall(){return this._maxFall}get maxJump(){return this._maxJump}get maxOpenSetIterations(){return this._maxOpenSetIterations}get speed(){return this._speed}get target(){return this._target}get verticalPenalty(){return this._verticalPenalty}get waypoints(){return this._waypoints}get waypointNextIndex(){return this._waypointNextIndex}get waypointTimeoutMs(){return this._waypointTimeoutMs}pathfind(J,Z,Y){if(this._target=J,this._speed=Z,this._debug=Y?.debug??!1,this._maxFall=Y?.maxFall?-Math.abs(Y.maxFall):0,this._maxJump=Y?.maxJump?Math.abs(Y.maxJump):0,this._maxOpenSetIterations=Y?.maxOpenSetIterations??200,this._onPathfindAbort=Y?.pathfindAbortCallback,this._onPathfindComplete=Y?.pathfindCompleteCallback,this._onWaypointMoveComplete=Y?.waypointMoveCompleteCallback,this._onWaypointMoveSkipped=Y?.waypointMoveSkippedCallback,this._verticalPenalty=Y?.verticalPenalty??0,this._waypoints=[],this._waypointNextIndex=0,this._waypointTimeoutMs=Y?.waypointTimeoutMs??2000/Z,!this._calculatePath())return!1;return this._moveToNextWaypoint(),!0}attach(J){super.attach(J),this._entity=J}detach(J){super.detach(J),this._entity=void 0}tick(J,Z){super.tick(J,Z)}_calculatePath(){if(!this._target||!this._entity?.world)return _.error("PathfindingEntityController._calculatePath: No target or world"),!1;let J=this._entity.height,Z=this._findGroundedStart();if(!Z){if(this._debug)_.warning(`PathfindingEntityController._calculatePath: No valid grounded start found within maxFall distance, path search aborted. Start: ${this._coordinateToKey(this._target)}, Target: ${this._coordinateToKey(this._target)}`);return!1}let Y={x:Math.floor(this._target.x),y:Math.floor(this._target.y),z:Math.floor(this._target.z)},X=Math.abs(Y.x-Z.x),K=Math.abs(Y.y-Z.y),$=Math.abs(Y.z-Z.z);if(X<=2&&K<=2&&$<=2&&!this._isNeighborCoordinateBlocked(Z,Y,this._entity.height))return this._waypoints=[{x:Z.x+0.5,y:Z.y+J/2,z:Z.z+0.5},{x:Y.x+0.5,y:Y.y+J/2,z:Y.z+0.5}],!0;if(Z.x===Y.x&&Z.y===Y.y&&Z.z===Y.z)return this._waypoints=[{x:Z.x+0.5,y:Z.y+J/2,z:Z.z+0.5}],!0;let F=this._coordinateToKey(Z),G=new Map,W=new Map([[F,0]]),V=new Map([[F,this._pathfindingHeuristic(Z,Y)]]),q=new Set,z=new VS((B,v)=>{let k=V.get(B[0])??1/0,w=V.get(v[0])??1/0;return k-w});z.push([F,Z]);let U=[{x:0,y:0,z:1},{x:1,y:0,z:0},{x:0,y:0,z:-1},{x:-1,y:0,z:0},{x:1,y:0,z:1},{x:1,y:0,z:-1},{x:-1,y:0,z:1},{x:-1,y:0,z:-1}],M=[];for(let B=this._maxJump;B>=this._maxFall;B--){if(B===0)continue;let v=Math.abs(Z.y+B-Y.y);M.push({y:B,distanceToTargetY:v})}M.sort((B,v)=>B.distanceToTargetY-v.distanceToTargetY);let R=[...U,...M.flatMap(({y:B})=>U.map((v)=>({...v,y:B})))],L=0,O=Math.abs(Y.x-Z.x)+Math.abs(Y.y-Z.y)+Math.abs(Y.z-Z.z),N=Math.min(this._maxOpenSetIterations,O*20);while(!z.isEmpty()&&L<N){L++;let[B,v]=z.pop();if(v.x===Y.x&&v.y===Y.y&&v.z===Y.z){let x=this._reconstructPath(G,v);if(this._waypoints=x.map((E)=>({x:E.x+0.5,y:E.y+J/2,z:E.z+0.5})),this._debug)console.log(`PathfindingEntityController._calculatePath: Path found after ${L} open set iterations. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`);return!0}q.add(B);let k=W.get(B),w=new Map;for(let x of R){let E=`${x.x},${x.z}`,C=x.y<0;if(C&&w.has(E))continue;let S={x:v.x+x.x,y:v.y+x.y,z:v.z+x.z};if(Math.abs(Y.x-S.x)+Math.abs(Y.y-S.y)+Math.abs(Y.z-S.z)>O*1.5)continue;let h=this._coordinateToKey(S);if(q.has(h))continue;let A=this._isNeighborCoordinateBlocked(v,S,this._entity.height);if(C&&A){w.set(E,!0);continue}if(A)continue;let f=Math.abs(x.x),c=Math.abs(x.y),J0=Math.abs(x.z),A0=c===0?0:this._verticalPenalty,n0=(Math.max(f,c,J0)===1&&f+c+J0>1?1.4:1)+A0,G6=k+n0,n6=W.get(h)??1/0;if(G6>=n6)continue;G.set(h,v),W.set(h,G6);let Z4=G6+this._pathfindingHeuristic(S,Y);V.set(h,Z4),z.push([h,S])}}if(L>=N){if(this._onPathfindAbort?.(),this._debug)_.warning(`PathfindingEntityController._calculatePath: Maximum open set iterations reached (${N}), path search aborted. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`)}else if(this._debug)_.warning(`PathfindingEntityController._calculatePath: No valid path found. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`);return this._target=void 0,this._waypoints=[],!1}_reconstructPath(J,Z){let Y=[Z],X=Z;while(J.has(this._coordinateToKey(X)))X=J.get(this._coordinateToKey(X)),Y.unshift(X);return Y}_coordinateToKey(J){return`${J.x},${J.y},${J.z}`}_moveToNextWaypoint(){let J=this._waypointNextIndex>0?this._waypoints[this._waypointNextIndex-1]:void 0,Z=this._waypoints[this._waypointNextIndex];if(!Z||!this._entity)return;let Y=0;if(this._entity.isDynamic&&J&&Z.y>J.y){let X=Z.y-J.y,K=Math.min(X,this._maxJump)+0.75;this.jump(K);let $=Math.abs(this._entity.world.simulation.gravity.y),Q=Math.sqrt(2*$*K),F=J.x+0.5,G=J.z+0.5,W=Z.x+0.5,V=Z.z+0.5,q=W-F,z=V-G,U=Math.sqrt(q*q+z*z),M=Q/$,R=U/this._speed;Y=Math.min(M*0.8,R)*1000}setTimeout(()=>{if(!this._entity)return;let X=Date.now();this.face(Z,this._speed),this.move(Z,this._speed,{moveIgnoreAxes:{y:this._entity.isDynamic},moveCallback:()=>{if(Date.now()-X>this._waypointTimeoutMs&&this._waypointNextIndex<this._waypoints.length-1)this._onWaypointMoveSkipped?.(Z,this._waypointNextIndex),this._waypointNextIndex++,this._moveToNextWaypoint()},moveCompleteCallback:()=>{if(this._waypointNextIndex<this._waypoints.length-1)this._onWaypointMoveComplete?.(Z,this._waypointNextIndex),this._waypointNextIndex++,this._moveToNextWaypoint();else this._onPathfindComplete?.()}})},Y)}_pathfindingHeuristic(J,Z){return Math.abs(J.x-Z.x)+Math.abs(J.y-Z.y)+Math.abs(J.z-Z.z)}_isNeighborCoordinateBlocked(J,Z,Y){if(!this._entity?.world)return!1;let X=this._entity.world,K=Math.floor(Z.x),$=Math.floor(Z.y),Q=Math.floor(Z.z),F=Math.floor(J.x),G=Math.floor(J.z);if(!X.chunkLattice.hasBlock({x:K,y:$-1,z:Q}))return!0;for(let W=0;W<Y;W++)if(X.chunkLattice.hasBlock({x:K,y:$+W,z:Q}))return!0;if(K!==F&&Q!==G)for(let W=0;W<Y;W++){let V=X.chunkLattice.hasBlock({x:K,y:$+W,z:G}),q=X.chunkLattice.hasBlock({x:F,y:$+W,z:Q});if(V||q)return!0}return!1}_findGroundedStart(){if(!this._entity?.world)return;let{x:J,y:Z,z:Y}=this._entity.position,X={x:Math.floor(J),y:Math.floor(Z),z:Math.floor(Y)};for(let K=0;K<=Math.abs(this._maxFall);K++)if(this._entity.world.chunkLattice.hasBlock({...X,y:X.y-K-1}))return{...X,y:X.y-K};return}}export{xZ0 as startServer,zC as WorldLoopEvent,fJ as WorldLoop,Gq as WorldEvent,hJ as World,eV as WebServerEvent,o5 as WebServer,J4 as Vector3,AJ as Vector2,IJ as Ticker,Fq as SimulationEvent,CJ as Simulation,yJ as SimpleEntityController,SJ as SceneUIManager,Yq as SceneUIEvent,jJ as SceneUI,LC as SUPPORTED_INPUT_KEYS,Q$ as RigidBodyType,f9 as RigidBody,WC as ROTATION_UPDATE_THRESHOLD,e5 as Quaternion,G$ as PlayerUIEvent,_J as PlayerUI,oB as PlayerManagerEvent,Y8 as PlayerManager,kJ as PlayerEvent,vJ as PlayerEntityController,i1 as PlayerEntity,qC as PlayerCameraMode,$q as PlayerCameraEvent,DJ as PlayerCamera,w5 as Player,h9 as PersistenceManager,Uq as PathfindingEntityController,GC as POSITION_UPDATE_THRESHOLD_SQ,tV as PORT,M6 as ModelRegistry,C8 as Matrix4,i6 as Matrix3,p9 as Matrix2,VC as LightType,TJ as LightManager,Xq as LightEvent,Kq as Light,HC as GameServerEvent,w1 as GameServer,s as EventRouter,_ as ErrorHandler,xJ as EntityManager,F$ as EntityEvent,K8 as Entity,FC as DEFAULT_ENTITY_RIGID_BODY_OPTIONS,z6 as CollisionGroupsBuilder,t1 as CollisionGroup,YX as ColliderShape,EJ as ColliderMap,n8 as Collider,YG as CoefficientCombineRule,BJ as ChunkLattice,Zq as ChunkEvent,P8 as Chunk,bJ as ChatManager,Wq as ChatEvent,KG as BlockTypeRegistryEvent,d4 as BlockTypeRegistry,XG as BlockTypeEvent,R6 as BlockType,A9 as Block,Pq as BaseEntityControllerEvent,n1 as BaseEntityController,$4 as AudioManager,R$ as AudioEvent,K4 as Audio};