hytopia 0.8.6-devtrace-9ad37b9 → 0.8.6-devtrace-e98ba7e

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/bun-server.mjs CHANGED
@@ -447,7 +447,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
447
447
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
448
448
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
449
449
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
450
- -----END RSA PRIVATE KEY-----`;var iS=process.env.PORT??8080,nS="0.8.6-devtrace-9ad37b9",aS;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(aS||={});class mK extends j0{static instance=new mK;_webserver=xj.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:nS,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(xj.default.static("assets"));try{this._webserver.use(xj.default.static(Pi1.dirname(c.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ni1.createServer(this._webserver):Di1.createServer({key:Aj.existsSync("assets/certs/localhost.key")?Aj.readFileSync("assets/certs/localhost.key"):v$0,cert:Aj.existsSync("assets/certs/localhost.crt")?Aj.readFileSync("assets/certs/localhost.crt"):I$0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else d.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(iS,this._onStarted),console.info(`WebServer.start(): Server running on port ${iS}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return d.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=Ci1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&a7.instance.isValidConnectionId($))Z.connectionId=$;else{let W=await b7.instance.getPlayerSession(Q);if(W?.error){let K=`${W.error.code}: ${W.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
450
+ -----END RSA PRIVATE KEY-----`;var iS=process.env.PORT??8080,nS="0.8.6-devtrace-e98ba7e",aS;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(aS||={});class mK extends j0{static instance=new mK;_webserver=xj.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:nS,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(xj.default.static("assets"));try{this._webserver.use(xj.default.static(Pi1.dirname(c.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ni1.createServer(this._webserver):Di1.createServer({key:Aj.existsSync("assets/certs/localhost.key")?Aj.readFileSync("assets/certs/localhost.key"):v$0,cert:Aj.existsSync("assets/certs/localhost.crt")?Aj.readFileSync("assets/certs/localhost.crt"):I$0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else d.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(iS,this._onStarted),console.info(`WebServer.start(): Server running on port ${iS}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return d.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=Ci1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&a7.instance.isValidConnectionId($))Z.connectionId=$;else{let W=await b7.instance.getPlayerSession(Q);if(W?.error){let K=`${W.error.code}: ${W.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
451
451
  Content-Type: text/plain\r
452
452
  Content-Length: ${K.length}\r
453
453
  Connection: close\r
@@ -482,6 +482,6 @@ ${$.stack}`:"unknown"}}}}}var tO8=(Z={})=>{let J=Z.limit??pO8;return{name:iO8,pr
482
482
  `;let K=R91(Y);Y.write(`${W}\r
483
483
  `);let{connect:G,buffered:z}=await K;if(Z.emit("proxyConnect",G),this.emit("proxyConnect",G,Z),G.statusCode===200){if(Z.once("socket",J86),J.secureEndpoint){UF("Upgrading socket connection to TLS");let V=J.servername||J.host;return ib.connect({...N91(J,"host","path","port"),socket:Y,servername:vJ.isIP(V)?void 0:V})}return Y}Y.destroy();let H=new vJ.Socket({writable:!1});return H.readable=!0,Z.once("socket",(V)=>{UF("Replaying proxy buffer for failed request"),V.push(z),V.push(null)}),H}}BR.__initStatic();function J86(Z){Z.resume()}function N91(Z,...J){let X={},Y;for(Y in Z)if(!J.includes(Y))X[Y]=Z[Y];return X}var W86=32768;function K86(Z){return new $86({read(){this.push(Z),this.push(null)}})}function wF(Z){let J;try{J=new URL(Z.url)}catch(G){return e0(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),L3(Z,()=>Promise.resolve({}))}let X=J.protocol==="https:",Y=G86(J,Z.proxy||(X?process.env.https_proxy:void 0)||process.env.http_proxy),$=X?Y86:X86,Q=Z.keepAlive===void 0?!1:Z.keepAlive,W=Y?new BR(Y):new $.Agent({keepAlive:Q,maxSockets:30,timeout:2000}),K=z86(Z,Z.httpModule??$,W);return L3(Z,K)}function G86(Z,J){let{no_proxy:X}=process.env;if(X?.split(",").some(($)=>Z.host.endsWith($)||Z.hostname.endsWith($)))return;else return J}function z86(Z,J,X){let{hostname:Y,pathname:$,port:Q,protocol:W,search:K}=new URL(Z.url);return function G(z){return new Promise((H,V)=>{OQ(()=>{let q=K86(z.body),F={...Z.headers};if(z.body.length>W86)F["content-encoding"]="gzip",q=q.pipe(Q86());let U=J.request({method:"POST",agent:X,headers:F,hostname:Y,path:`${$}${K}`,port:Q,protocol:W,ca:Z.caCerts},(B)=>{B.on("data",()=>{}),B.on("end",()=>{}),B.setEncoding("utf8");let w=B.headers["retry-after"]??null,j=B.headers["x-sentry-rate-limits"]??null;H({statusCode:B.statusCode,headers:{"retry-after":w,"x-sentry-rate-limits":Array.isArray(j)?j[0]||null:j}})});U.on("error",V),q.pipe(U)})})}}var H86=new Set(["false","f","n","no","off","0"]),V86=new Set(["true","t","y","yes","on","1"]);function LR(Z,J){let X=String(Z).toLowerCase();if(H86.has(X))return!1;if(V86.has(X))return!0;return J?.strict?null:Boolean(Z)}import{posix as q86,sep as F86}from"path";function D91(Z){return Z.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function BF(Z=process.argv[1]?Kf(process.argv[1]):process.cwd(),J=F86==="\\"){let X=J?D91(Z):Z;return(Y)=>{if(!Y)return;let $=J?D91(Y):Y,{dir:Q,base:W,ext:K}=q86.parse($);if(K===".js"||K===".mjs"||K===".cjs")W=W.slice(0,K.length*-1);let G=decodeURIComponent(W);if(!Q)Q=".";let z=Q.lastIndexOf("/node_modules");if(z>-1)return`${Q.slice(z+14).replace(/\//g,".")}:${G}`;if(Q.startsWith(X)){let H=Q.slice(X.length+1).replace(/\//g,".");return H?`${H}:${G}`:G}return G}}function LF(Z){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(O0.SENTRY_RELEASE?.id)return O0.SENTRY_RELEASE.id;let J=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,X=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,Y=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return J||X||Y||Z}var jF=lO(bf(BF()));var C91=e(Y0(),1);import*as P91 from"os";import{threadId as U86,isMainThread as w86}from"worker_threads";var B86=60000;class c3 extends UM{constructor(Z){let J=Z.includeServerName===!1?void 0:Z.serverName||global.process.env.SENTRY_NAME||P91.hostname(),X={...Z,platform:"node",runtime:{name:"node",version:global.process.version},serverName:J};if(Z.openTelemetryInstrumentations)D3({instrumentations:Z.openTelemetryInstrumentations});DQ(X,"node"),h.log(`Initializing Sentry: process: ${process.pid}, thread: ${w86?"main":`worker-${U86}`}.`);super(X);let{enableLogs:Y,_experiments:$}=this.getOptions();if(Y??$?.enableLogs){if(this._logOnExitFlushListener=()=>{tX(this)},J)this.on("beforeCaptureLog",(W)=>{W.attributes={...W.attributes,"server.address":J}});process.on("beforeExit",this._logOnExitFlushListener)}}get tracer(){if(this._tracer)return this._tracer;let Z="@sentry/node",J=M1,X=C91.trace.getTracer(Z,J);return this._tracer=X,X}async flush(Z){if(await this.traceProvider?.forceFlush(),this.getOptions().sendClientReports)this._flushOutcomes();return super.flush(Z)}close(Z){if(this._clientReportInterval)clearInterval(this._clientReportInterval);if(this._clientReportOnExitFlushListener)process.off("beforeExit",this._clientReportOnExitFlushListener);if(this._logOnExitFlushListener)process.off("beforeExit",this._logOnExitFlushListener);return super.close(Z)}startClientReportTracking(){let Z=this.getOptions();if(Z.sendClientReports)this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{G1&&h.log("Flushing client reports based on interval."),this._flushOutcomes()},Z.clientReportFlushInterval??B86).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener)}_getTraceInfoFromScope(Z){if(!Z)return[void 0,void 0];return C51(this,Z)}}var T91=e($q(),1);import L86 from"module";function k91(){let[Z=0,J=0]=process.versions.node.split(".").map(Number);if(Z>=21||Z===20&&J>=6||Z===18&&J>=19){if(!O0._sentryEsmLoaderHookRegistered)try{let{addHookMessagePort:X}=T91.createAddHookMessageChannel();L86.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:X,include:[]},transferList:[X]})}catch(X){h.warn("Failed to register ESM hook",X)}}else e0(()=>{console.warn(`[Sentry] You are using Node.js v${process.versions.node} in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.`)})}function jR(){return[Sq(),vq(),_q(),Aq(),xq(),h51(),g51(),GF(),zF(),YF(),QF(),XF(),VF(),M91(),WF()]}function nb(Z={}){return j86(Z,jR)}function j86(Z={},J){let X=O86(Z,J);if(X.debug===!0)if(G1)h.enable();else e0(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")});if(!L4()&&X.registerEsmLoaderHooks!==!1)k91();if(GR(),T0().update(X.initialScope),X.spotlight&&!X.integrations.some(({name:Q})=>Q===gb))X.integrations.push(HF({sidecarUrl:typeof X.spotlight==="string"?X.spotlight:void 0}));DQ(X,"node-core");let $=new c3(X);return T0().setClient($),$.init(),h.log(`Running in ${L4()?"CommonJS":"ESM"} mode.`),$.startClientReportTracking(),N86(),B51($),T51($),$}function OF(){if(!G1)return;let Z=M51(),J=["SentryContextManager","SentryPropagator"];if(c8())J.push("SentrySpanProcessor");for(let X of J)if(!Z.includes(X))h.error(`You have to set up the ${X}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);if(!Z.includes("SentrySampler"))h.warn("You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.")}function O86(Z,J){let X=M86(Z.release),Y=Z.spotlight??LR(process.env.SENTRY_SPOTLIGHT,{strict:!0})??process.env.SENTRY_SPOTLIGHT,$=R86(Z.tracesSampleRate),Q={...Z,dsn:Z.dsn??process.env.SENTRY_DSN,environment:Z.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:Z.sendClientReports??!0,transport:Z.transport??wF,stackParser:cx(Z.stackParser||jF),release:X,tracesSampleRate:$,spotlight:Y,debug:LR(Z.debug??process.env.SENTRY_DEBUG)},W=Z.integrations,K=Z.defaultIntegrations??J(Q);return{...Q,integrations:mh({defaultIntegrations:K,integrations:W})}}function M86(Z){if(Z!==void 0)return Z;let J=LF();if(J!==void 0)return J;return}function R86(Z){if(Z!==void 0)return Z;let J=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!J)return;let X=parseFloat(J);return isFinite(X)?X:void 0}function N86(){if(LR(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let Z=process.env.SENTRY_TRACE,J=process.env.SENTRY_BAGGAGE,X=FQ(Z,J);T0().setPropagationContext(X)}}function o1(Z,J){Z.setAttribute(_0,J)}var E91=(Z)=>({package:Z,"javascript.is_cjs":L4()});function SJ(Z,J){let X=X0()?.getOptions();if(!X?.disableInstrumentationWarnings&&!PJ(Z)&&MQ()&&c8(X))e0(()=>{if(L4())console.warn(`[Sentry] ${J} is not instrumented. This is likely because you required/imported ${J} before calling \`Sentry.init()\`.`);else console.warn(`[Sentry] ${J} is not instrumented. Please make sure to initialize Sentry in a separate file that you \`--import\` when running node, see: https://docs.sentry.io/platforms/javascript/guides/${J}/install/esm/.`)}),J7().setContext("missing_instrumentation",E91(J))}var D86=[["january","1"],["february","2"],["march","3"],["april","4"],["may","5"],["june","6"],["july","7"],["august","8"],["september","9"],["october","10"],["november","11"],["december","12"],["jan","1"],["feb","2"],["mar","3"],["apr","4"],["may","5"],["jun","6"],["jul","7"],["aug","8"],["sep","9"],["oct","10"],["nov","11"],["dec","12"],["sunday","0"],["monday","1"],["tuesday","2"],["wednesday","3"],["thursday","4"],["friday","5"],["saturday","6"],["sun","0"],["mon","1"],["tue","2"],["wed","3"],["thu","4"],["fri","5"],["sat","6"]];function mQ(Z){return D86.reduce((J,[X,Y])=>J.replace(new RegExp(X,"gi"),Y),Z)}var I91="Automatic instrumentation of CronJob only supports crontab string";function v91(Z,J){let X=!1;return new Proxy(Z,{construct(Y,$){let[Q,W,K,G,z,...H]=$;if(typeof Q!=="string")throw new Error(I91);if(X)throw new Error(`A job named '${J}' has already been scheduled`);X=!0;let V=mQ(Q);async function q(F,U){return QZ(J,async()=>{try{await W(F,U)}catch(B){throw Z1(B),B}},{schedule:{type:"crontab",value:V},timezone:z||void 0})}return new Y(Q,q,K,G,z,...H)},get(Y,$){if($==="from")return(Q)=>{let{cronTime:W,onTick:K,timeZone:G}=Q;if(typeof W!=="string")throw new Error(I91);if(X)throw new Error(`A job named '${J}' has already been scheduled`);X=!0;let z=mQ(W);return Q.onTick=async(H,V)=>{return QZ(J,async()=>{try{await K(H,V)}catch(q){throw Z1(q),q}},{schedule:{type:"crontab",value:z},timezone:G||void 0})},Y.from(Q)};else return Y[$]}})}function S91(Z){return new Proxy(Z,{get(J,X){if(X==="schedule"&&J.schedule)return new Proxy(J.schedule,{apply(Y,$,Q){let[W,K,G]=Q,z=G?.name,H=G?.timezone;if(!z)throw new Error('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');let V=async()=>{return QZ(z,async()=>{try{return await K()}catch(q){throw Z1(q),q}},{schedule:{type:"crontab",value:mQ(W)},timezone:H})};return Y.apply($,[W,V,G])}});else return J[X]}})}function _91(Z){return new Proxy(Z,{get(J,X){if(X==="scheduleJob")return new Proxy(J.scheduleJob,{apply(Y,$,Q){let[W,K,G]=Q;if(typeof W!=="string"||typeof K!=="string"||typeof G!=="function")throw new Error("Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string");let z=W,H=K;async function V(){return QZ(z,async()=>{await G?.()},{schedule:{type:"crontab",value:mQ(H)}})}return Y.apply($,[z,H,V])}});return J[X]}})}var ab={instrumentCron:v91,instrumentNodeCron:S91,instrumentNodeSchedule:_91};var sb="Http",A91="@opentelemetry_sentry-patched/instrumentation-http",P86=w0(`${sb}.sentry`,(Z)=>{return new g3(Z)}),ob=w0(sb,(Z)=>{let J=new h91.HttpInstrumentation(Z);try{J._diag=x91.diag.createComponentLogger({namespace:A91}),J.instrumentationName=A91}catch{}return J});function C86(Z,J={}){if(typeof Z.spans==="boolean")return Z.spans;if(J.skipOpenTelemetrySetup)return!1;if(!c8(J)&&I9.major>=22)return!1;return!0}var OR=a((Z={})=>{let J=Z.dropSpansForIncomingRequestStatusCodes??[[401,404],[300,399]];return{name:sb,setupOnce(){let X=C86(Z,X0()?.getOptions());if(P86({...Z,extractIncomingTraceFromHeader:!X,propagateTraceInOutgoingRequests:!X}),X){let Y=E86(Z);ob(Y)}},processEvent(X){if(X.type==="transaction"){let Y=X.contexts?.trace?.data?.["http.response.status_code"];if(typeof Y==="number"&&J.some(($)=>{if(typeof $==="number")return $===Y;let[Q,W]=$;return Y>=Q&&Y<=W}))return null}return X}}});function T86(Z){return"outputData"in Z&&"outputSize"in Z&&!("client"in Z)&&!("statusCode"in Z)}function k86(Z){return Z.headers["next-router-prefetch"]==="1"}function E86(Z={}){return{...Z.instrumentation?._experimentalConfig,disableIncomingRequestInstrumentation:Z.disableIncomingRequestSpans,ignoreOutgoingRequestHook:(X)=>{let Y=b3(X);if(!Y)return!1;let $=Z.ignoreOutgoingRequests;if($?.(Y,X))return!0;return!1},ignoreIncomingRequestHook:(X)=>{let Y=X.url,$=X.method?.toUpperCase();if($==="OPTIONS"||$==="HEAD")return!0;let Q=Z.ignoreIncomingRequests;if(Y&&Q?.(Y,X))return!0;return!1},requireParentforOutgoingSpans:!1,requireParentforIncomingSpans:!1,requestHook:(X,Y)=>{if(o1(X,"auto.http.otel.http"),!T86(Y)&&k86(Y))X.setAttribute("sentry.http.prefetch",!0);Z.instrumentation?.requestHook?.(X,Y)},responseHook:(X,Y)=>{Z.instrumentation?.responseHook?.(X,Y)},applyCustomAttributesOnSpan:(X,Y,$)=>{Z.instrumentation?.applyCustomAttributesOnSpan?.(X,Y,$)}}}var r91=e(o91(),1);var t91="NodeFetch",_86=w0(t91,r91.UndiciInstrumentation,(Z)=>{return b86(Z)}),A86=w0(`${t91}.sentry`,u3,(Z)=>{return Z}),x86=(Z={})=>{return{name:"NodeFetch",setupOnce(){if(f86(Z,X0()?.getOptions()))_86(Z);A86(Z)}}},RR=a(x86);function h86(Z,J="/"){let X=`${Z}`;if(X.endsWith("/")&&J.startsWith("/"))return`${X}${J.slice(1)}`;if(!X.endsWith("/")&&!J.startsWith("/"))return`${X}/${J.slice(1)}`;return`${X}${J}`}function f86(Z,J={}){return typeof Z.spans==="boolean"?Z.spans:!J.skipOpenTelemetrySetup&&c8(J)}function b86(Z={}){return{requireParentforSpans:!1,ignoreRequestHook:(X)=>{let Y=h86(X.origin,X.path),$=Z.ignoreOutgoingRequests;return!!($&&Y&&$(Y))},startSpanHook:()=>{return{[_0]:"auto.http.otel.node_fetch"}}}}var O41=e(L41(),1);var j41="FileSystem",M41=a((Z={})=>{return{name:j41,setupOnce(){w0(j41,()=>new O41.FsInstrumentation({requireParentSpan:!0,endHook(J,{args:X,span:Y,error:$}){if(Y.updateName(`fs.${J}`),Y.setAttributes({[N0]:"file",[_0]:"auto.file.fs"}),Z.recordErrorMessagesAsSpanAttributes){if(typeof X[0]==="string"&&o86.includes(J))Y.setAttribute("path_argument",X[0]);else if(typeof X[0]==="string"&&typeof X[1]==="string"&&s86.includes(J))Y.setAttribute("target_argument",X[0]),Y.setAttribute("path_argument",X[1]);else if(typeof X[0]==="string"&&a86.includes(J))Y.setAttribute("prefix_argument",X[0]);else if(typeof X[0]==="string"&&typeof X[1]==="string"&&n86.includes(J))Y.setAttribute("existing_path_argument",X[0]),Y.setAttribute("new_path_argument",X[1]);else if(typeof X[0]==="string"&&typeof X[1]==="string"&&i86.includes(J))Y.setAttribute("src_argument",X[0]),Y.setAttribute("dest_argument",X[1]);else if(typeof X[0]==="string"&&typeof X[1]==="string"&&p86.includes(J))Y.setAttribute("old_path_argument",X[0]),Y.setAttribute("new_path_argument",X[1])}if($&&Z.recordErrorMessagesAsSpanAttributes)Y.setAttribute("fs_error",$.message)}}))()}}}),p86=["rename","renameSync"],i86=["copyFile","cp","copyFileSync","cpSync"],n86=["link","linkSync"],a86=["mkdtemp","mkdtempSync"],s86=["symlink","symlinkSync"],o86=["access","appendFile","chmod","chown","exists","mkdir","lchown","lstat","lutimes","open","opendir","readdir","readFile","readlink","realpath","realpath.native","rm","rmdir","stat","truncate","unlink","utimes","writeFile","accessSync","appendFileSync","chmodSync","chownSync","existsSync","lchownSync","lstatSync","lutimesSync","opendirSync","mkdirSync","openSync","readdirSync","readFileSync","readlinkSync","realpathSync","realpathSync.native","rmdirSync","rmSync","statSync","truncateSync","unlinkSync","utimesSync","writeFileSync"];var s41=e(d41(),1);var j4=typeof __SENTRY_DEBUG__==="undefined"||__SENTRY_DEBUG__;var U7=e(Y0(),1);var a41=e(R1(),1);var O4;(function(Z){Z.EXPRESS_TYPE="express.type";let X="express.name";Z.EXPRESS_NAME=X})(O4||(O4={}));var AJ;(function(Z){Z.ROUTER="router";let X="middleware";Z.MIDDLEWARE=X;let Y="request_handler";Z.REQUEST_HANDLER=Y})(AJ||(AJ={}));var Yy=Symbol("express-layer-patched"),wY="__ot_middlewares";var l41=(Z,J)=>{if(Array.isArray(Z[wY])===!1)Object.defineProperty(Z,wY,{enumerable:!1,value:[]});if(J===void 0)return;Z[wY].push(J)},p41=(Z,J)=>{let X=J.handle?.stack?.[0];if(X?.route?.path)return`${Z}${X.route.path}`;if(X?.handle?.stack)return p41(Z,X);return Z},i41=(Z,J,X)=>{if(J.name==="router"){let Y=p41("",J),$=Y?Y:X||Z||"/";return{attributes:{[O4.EXPRESS_NAME]:$,[O4.EXPRESS_TYPE]:AJ.ROUTER},name:`router - ${$}`}}else if(J.name==="bound dispatch"||J.name==="handle")return{attributes:{[O4.EXPRESS_NAME]:(Z||X)??"request handler",[O4.EXPRESS_TYPE]:AJ.REQUEST_HANDLER},name:`request handler${J.path?` - ${Z||X}`:""}`};else return{attributes:{[O4.EXPRESS_NAME]:J.name,[O4.EXPRESS_TYPE]:AJ.MIDDLEWARE},name:`middleware - ${J.name}`}},U66=(Z,J)=>{if(typeof J==="string")return J===Z;else if(J instanceof RegExp)return J.test(Z);else if(typeof J==="function")return J(Z);else throw new TypeError("Pattern is in unsupported datatype")},n41=(Z,J,X)=>{if(Array.isArray(X?.ignoreLayersType)&&X?.ignoreLayersType?.includes(J))return!0;if(Array.isArray(X?.ignoreLayers)===!1)return!1;try{for(let Y of X.ignoreLayers)if(U66(Z,Y))return!0}catch{}return!1},$y=(Z)=>Z instanceof Error?[Z,Z.message]:[String(Z),String(Z)],kR=(Z)=>{let J=Z[0];if(Array.isArray(J))return J.map((X)=>c41(X)||"").join(",");return c41(J)},c41=(Z)=>{if(typeof Z==="string")return Z;if(Z instanceof RegExp||typeof Z==="number")return Z.toString();return};var w66="0.1.0",B66="@sentry/instrumentation-express-v5";class Qy extends h8{constructor(Z={}){super(B66,w66,Z)}init(){return[new a6("express",[">=5.0.0"],(Z)=>this._setup(Z),(Z)=>this._tearDown(Z))]}_setup(Z){let J=Z.Router.prototype;if(PJ(J.route))this._unwrap(J,"route");if(this._wrap(J,"route",this._getRoutePatch()),PJ(J.use))this._unwrap(J,"use");if(this._wrap(J,"use",this._getRouterUsePatch()),PJ(Z.application.use))this._unwrap(Z.application,"use");return this._wrap(Z.application,"use",this._getAppUsePatch()),Z}_tearDown(Z){if(Z===void 0)return;let J=Z.Router.prototype;this._unwrap(J,"route"),this._unwrap(J,"use"),this._unwrap(Z.application,"use")}_getRoutePatch(){let Z=this;return function(J){return function X(...Y){let $=J.apply(this,Y),Q=this.stack[this.stack.length-1];return Z._applyPatch(Q,kR(Y)),$}}}_getRouterUsePatch(){let Z=this;return function(J){return function X(...Y){let $=J.apply(this,Y),Q=this.stack[this.stack.length-1];return Z._applyPatch(Q,kR(Y)),$}}}_getAppUsePatch(){let Z=this;return function(J){return function X(...Y){let $=this.router,Q=J.apply(this,Y);if($){let W=$.stack[$.stack.length-1];Z._applyPatch(W,kR(Y))}return Q}}}_applyPatch(Z,J){let X=this;if(Z[Yy]===!0)return;Z[Yy]=!0,this._wrap(Z,"handle",(Y)=>{if(Y.length===4)return Y;let $=function(Q,W){l41(Q,J);let K=Q[wY].filter((O)=>O!=="/"&&O!=="/*").join("").replace(/\/{2,}/g,"/"),G=K.length>0?K:void 0,z={[a41.SEMATTRS_HTTP_ROUTE]:G},H=i41(K,Z,J),V=H.attributes[O4.EXPRESS_TYPE],q=EQ(U7.context.active());if(q?.type===EJ.HTTP)q.route=G;if(n41(H.name,V,X.getConfig())){if(V===AJ.MIDDLEWARE)Q[wY].pop();return Y.apply(this,arguments)}if(U7.trace.getSpan(U7.context.active())===void 0)return Y.apply(this,arguments);let F=X._getSpanName({request:Q,layerType:V,route:K},H.name),U=X.tracer.startSpan(F,{attributes:Object.assign(z,H.attributes)}),{requestHook:B}=X.getConfig();if(B)$Y(()=>B(U,{request:Q,layerType:V,route:K}),(O)=>{if(O)U7.diag.error("express instrumentation: request hook failed",O)},!0);let w=!1;if(H.attributes[O4.EXPRESS_TYPE]!==AJ.MIDDLEWARE)U.end(),w=!0;let j=()=>{if(w===!1)w=!0,U.end()},N=Array.from(arguments),R=N.findIndex((O)=>typeof O==="function");if(R>=0)arguments[R]=function(){let O=arguments[0],P=![void 0,null,"route","router"].includes(O);if(!w&&P){let[C,T]=$y(O);U.recordException(C),U.setStatus({code:U7.SpanStatusCode.ERROR,message:T})}if(w===!1)w=!0,Q.res?.removeListener("finish",j),U.end();if(!(Q.route&&P))Q[wY].pop();return N[R].apply(this,arguments)};try{return Y.apply(this,arguments)}catch(O){let[P,D]=$y(O);throw U.recordException(P),U.setStatus({code:U7.SpanStatusCode.ERROR,message:D}),O}finally{if(!w)W.once("finish",j)}};for(let Q in Y)Object.defineProperty($,Q,{get(){return Y[Q]},set(W){Y[Q]=W}});return $})}_getSpanName(Z,J){let{spanNameHook:X}=this.getConfig();if(!(X instanceof Function))return J;try{return X(Z,J)??J}catch(Y){return U7.diag.error("express instrumentation: error calling span name rewrite hook",Y),J}}}var o41="Express",L66="Express-V5";function r41(Z){o1(Z,"auto.http.otel.express");let J=B0(Z).data,X=J["express.type"];if(X)Z.setAttribute(N0,`${X}.express`);let Y=J["express.name"];if(typeof Y==="string")Z.updateName(Y)}function t41(Z,J){if(E0()===z4())return j4&&h.warn("Isolation scope is still default isolation scope - skipping setting transactionName"),J;if(Z.layerType==="request_handler"){let X=Z.request,Y=X.method?X.method.toUpperCase():"GET";E0().setTransactionName(`${Y} ${Z.route}`)}return J}var Wy=w0(o41,()=>new s41.ExpressInstrumentation({requestHook:(Z)=>r41(Z),spanNameHook:(Z,J)=>t41(Z,J)})),Ky=w0(L66,()=>new Qy({requestHook:(Z)=>r41(Z),spanNameHook:(Z,J)=>t41(Z,J)})),j66=()=>{return{name:o41,setupOnce(){Wy(),Ky()}}},ER=a(j66);function Gy(Z){return function J(X,Y,$,Q){let W=j3(Y);if(E0().setSDKProcessingMetadata({normalizedRequest:W}),(Z?.shouldHandleError||R66)(X)){let G=Z1(X,{mechanism:{type:"middleware",handled:!1}});$.sentry=G}Q(X)}}function O66(){return function Z(J,X,Y){let $=j3(J);E0().setSDKProcessingMetadata({normalizedRequest:$}),Y()}}function e41(Z,J){Z.use(O66()),Z.use(Gy(J)),SJ(Z.use,"express")}function M66(Z){let J=Z.status||Z.statusCode||Z.status_code||Z.output?.statusCode;return J?parseInt(J,10):500}function R66(Z){return M66(Z)>=500}import*as By from"diagnostics_channel";var f8=e(Y0(),1);import C71 from"diagnostics_channel";var l8=e(R1(),1);var M71=e(q71(),1);var PF=(Z)=>{if(typeof Z!=="string")throw new TypeError("invalid pattern");if(Z.length>65536)throw new TypeError("pattern is too long")};var I66={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},CF=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),v66=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),F71=(Z)=>Z.join(""),U71=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw new Error("not in a brace expression");let Y=[],$=[],Q=X+1,W=!1,K=!1,G=!1,z=!1,H=X,V="";Z:while(Q<Z.length){let B=Z.charAt(Q);if((B==="!"||B==="^")&&Q===X+1){z=!0,Q++;continue}if(B==="]"&&W&&!G){H=Q+1;break}if(W=!0,B==="\\"){if(!G){G=!0,Q++;continue}}if(B==="["&&!G){for(let[w,[j,N,R]]of Object.entries(I66))if(Z.startsWith(w,Q)){if(V)return["$.",!1,Z.length-X,!0];if(Q+=w.length,R)$.push(j);else Y.push(j);K=K||N;continue Z}}if(G=!1,V){if(B>V)Y.push(CF(V)+"-"+CF(B));else if(B===V)Y.push(CF(B));V="",Q++;continue}if(Z.startsWith("-]",Q+1)){Y.push(CF(B+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){V=B,Q+=2;continue}Y.push(CF(B)),Q++}if(H<Q)return["",!1,0,!1];if(!Y.length&&!$.length)return["$.",!1,Z.length-X,!0];if($.length===0&&Y.length===1&&/^\\?.$/.test(Y[0])&&!z){let B=Y[0].length===2?Y[0].slice(-1):Y[0];return[v66(B),!1,H-X,!1]}let q="["+(z?"^":"")+F71(Y)+"]",F="["+(z?"":"^")+F71($)+"]";return[Y.length&&$.length?"("+q+"|"+F+")":Y.length?q:F,K,H-X,!0]};var BY=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var S66=new Set(["!","?","+","*","@"]),w71=(Z)=>S66.has(Z),_66="(?!(?:^|/)\\.\\.?(?:$|/))",IR="(?!\\.)",A66=new Set(["[","."]),x66=new Set(["..","."]),h66=new Set("().*{}+?[]^$\\!"),f66=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Vy="[^/]",B71=Vy+"*?",L71=Vy+"+?";class k6{type;#Z;#J;#Y=!1;#X=[];#$;#H;#q;#K=!1;#G;#z;#V=!1;constructor(Z,J,X={}){if(this.type=Z,Z)this.#J=!0;if(this.#$=J,this.#Z=this.#$?this.#$.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#q=this.#Z===this?[]:this.#Z.#q,Z==="!"&&!this.#Z.#K)this.#q.push(this);this.#H=this.#$?this.#$.#X.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let Z of this.#X){if(typeof Z==="string")continue;if(Z.type||Z.hasMagic)return this.#J=!0}return this.#J}toString(){if(this.#z!==void 0)return this.#z;if(!this.type)return this.#z=this.#X.map((Z)=>String(Z)).join("");else return this.#z=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw new Error("should only call on root");if(this.#K)return this;this.toString(),this.#K=!0;let Z;while(Z=this.#q.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#$;while(X){for(let Y=J.#H+1;!X.type&&Y<X.#X.length;Y++)for(let $ of Z.#X){if(typeof $==="string")throw new Error("string part in extglob AST??");$.copyIn(X.#X[Y])}J=X,X=J.#$}}return this}push(...Z){for(let J of Z){if(J==="")continue;if(typeof J!=="string"&&!(J instanceof k6&&J.#$===this))throw new Error("invalid part: "+J);this.#X.push(J)}}toJSON(){let Z=this.type===null?this.#X.slice().map((J)=>typeof J==="string"?J:J.toJSON()):[this.type,...this.#X.map((J)=>J.toJSON())];if(this.isStart()&&!this.type)Z.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#K&&this.#$?.type==="!"))Z.push({});return Z}isStart(){if(this.#Z===this)return!0;if(!this.#$?.isStart())return!1;if(this.#H===0)return!0;let Z=this.#$;for(let J=0;J<this.#H;J++){let X=Z.#X[J];if(!(X instanceof k6&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#$?.type==="!")return!0;if(!this.#$?.isEnd())return!1;if(!this.type)return this.#$?.isEnd();let Z=this.#$?this.#$.#X.length:0;return this.#H===Z-1}copyIn(Z){if(typeof Z==="string")this.push(Z);else this.push(Z.clone(this))}clone(Z){let J=new k6(this.type,Z);for(let X of this.#X)J.copyIn(X);return J}static#U(Z,J,X,Y){let $=!1,Q=!1,W=-1,K=!1;if(J.type===null){let q=X,F="";while(q<Z.length){let U=Z.charAt(q++);if($||U==="\\"){$=!$,F+=U;continue}if(Q){if(q===W+1){if(U==="^"||U==="!")K=!0}else if(U==="]"&&!(q===W+2&&K))Q=!1;F+=U;continue}else if(U==="["){Q=!0,W=q,K=!1,F+=U;continue}if(!Y.noext&&w71(U)&&Z.charAt(q)==="("){J.push(F),F="";let B=new k6(U,J);q=k6.#U(Z,B,q,Y),J.push(B);continue}F+=U}return J.push(F),q}let G=X+1,z=new k6(null,J),H=[],V="";while(G<Z.length){let q=Z.charAt(G++);if($||q==="\\"){$=!$,V+=q;continue}if(Q){if(G===W+1){if(q==="^"||q==="!")K=!0}else if(q==="]"&&!(G===W+2&&K))Q=!1;V+=q;continue}else if(q==="["){Q=!0,W=G,K=!1,V+=q;continue}if(w71(q)&&Z.charAt(G)==="("){z.push(V),V="";let F=new k6(q,z);z.push(F),G=k6.#U(Z,F,G,Y);continue}if(q==="|"){z.push(V),V="",H.push(z),z=new k6(null,J);continue}if(q===")"){if(V===""&&J.#X.length===0)J.#V=!0;return z.push(V),V="",J.push(...H,z),G}V+=q}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new k6(null,void 0,J);return k6.#U(Z,X,0,J),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Z=this.toString(),[J,X,Y,$]=this.toRegExpSource();if(!(Y||this.#J||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Z.toUpperCase()!==Z.toLowerCase()))return X;let W=(this.#G.nocase?"i":"")+($?"u":"");return Object.assign(new RegExp(`^${J}$`,W),{_src:J,_glob:Z})}get options(){return this.#G}toRegExpSource(Z){let J=Z??!!this.#G.dot;if(this.#Z===this)this.#Q();if(!this.type){let K=this.isStart()&&this.isEnd(),G=this.#X.map((q)=>{let[F,U,B,w]=typeof q==="string"?k6.#w(q,this.#J,K):q.toRegExpSource(Z);return this.#J=this.#J||B,this.#Y=this.#Y||w,F}).join(""),z="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&x66.has(this.#X[0]))){let F=A66,U=J&&F.has(G.charAt(0))||G.startsWith("\\.")&&F.has(G.charAt(2))||G.startsWith("\\.\\.")&&F.has(G.charAt(4)),B=!J&&!Z&&F.has(G.charAt(0));z=U?_66:B?IR:""}}}let H="";if(this.isEnd()&&this.#Z.#K&&this.#$?.type==="!")H="(?:$|\\/)";return[z+G+H,BY(G),this.#J=!!this.#J,this.#Y]}let X=this.type==="*"||this.type==="+",Y=this.type==="!"?"(?:(?!(?:":"(?:",$=this.#B(J);if(this.isStart()&&this.isEnd()&&!$&&this.type!=="!"){let K=this.toString();return this.#X=[K],this.type=null,this.#J=void 0,[K,BY(this.toString()),!1,!1]}let Q=!X||Z||J||!IR?"":this.#B(!0);if(Q===$)Q="";if(Q)$=`(?:${$})(?:${Q})*?`;let W="";if(this.type==="!"&&this.#V)W=(this.isStart()&&!J?IR:"")+L71;else{let K=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?IR:"")+B71+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;W=Y+$+K}return[W,BY($),this.#J=!!this.#J,this.#Y]}#B(Z){return this.#X.map((J)=>{if(typeof J==="string")throw new Error("string type in extglob ast??");let[X,Y,$,Q]=J.toRegExpSource(Z);return this.#Y=this.#Y||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#w(Z,J,X=!1){let Y=!1,$="",Q=!1;for(let W=0;W<Z.length;W++){let K=Z.charAt(W);if(Y){Y=!1,$+=(h66.has(K)?"\\":"")+K;continue}if(K==="\\"){if(W===Z.length-1)$+="\\\\";else Y=!0;continue}if(K==="["){let[G,z,H,V]=U71(Z,W);if(H){$+=G,Q=Q||z,W+=H-1,J=J||V;continue}}if(K==="*"){if(X&&Z==="*")$+=L71;else $+=B71;J=!0;continue}if(K==="?"){$+=Vy,J=!0;continue}$+=f66(K)}return[$,BY(Z),!!J,Q]}}var qy=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var E6=(Z,J,X={})=>{if(PF(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new TF(J,X).match(Z)},b66=/^\*+([^+@!?\*\[\(]*)$/,y66=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),g66=(Z)=>(J)=>J.endsWith(Z),m66=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},u66=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},d66=/^\*+\.\*+$/,c66=(Z)=>!Z.startsWith(".")&&Z.includes("."),l66=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),p66=/^\.\*+$/,i66=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),n66=/^\*+$/,a66=(Z)=>Z.length!==0&&!Z.startsWith("."),s66=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",o66=/^\?+([^+@!?\*\[\(]*)?$/,r66=([Z,J=""])=>{let X=R71([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},t66=([Z,J=""])=>{let X=N71([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},e66=([Z,J=""])=>{let X=N71([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},Z56=([Z,J=""])=>{let X=R71([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},R71=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},N71=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},D71=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",j71={win32:{sep:"\\"},posix:{sep:"/"}},J56=D71==="win32"?j71.win32.sep:j71.posix.sep;E6.sep=J56;var R4=Symbol("globstar **");E6.GLOBSTAR=R4;var X56="[^/]",Y56=X56+"*?",$56="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Q56="(?:(?!(?:\\/|^)\\.).)*?",W56=(Z,J={})=>(X)=>E6(X,Z,J);E6.filter=W56;var M4=(Z,J={})=>Object.assign({},Z,J),K56=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return E6;let J=E6;return Object.assign((Y,$,Q={})=>J(Y,$,M4(Z,Q)),{Minimatch:class Y extends J.Minimatch{constructor($,Q={}){super($,M4(Z,Q))}static defaults($){return J.defaults(M4(Z,$)).Minimatch}},AST:class Y extends J.AST{constructor($,Q,W={}){super($,Q,M4(Z,W))}static fromGlob($,Q={}){return J.AST.fromGlob($,M4(Z,Q))}},unescape:(Y,$={})=>J.unescape(Y,M4(Z,$)),escape:(Y,$={})=>J.escape(Y,M4(Z,$)),filter:(Y,$={})=>J.filter(Y,M4(Z,$)),defaults:(Y)=>J.defaults(M4(Z,Y)),makeRe:(Y,$={})=>J.makeRe(Y,M4(Z,$)),braceExpand:(Y,$={})=>J.braceExpand(Y,M4(Z,$)),match:(Y,$,Q={})=>J.match(Y,$,M4(Z,Q)),sep:J.sep,GLOBSTAR:R4})};E6.defaults=K56;var P71=(Z,J={})=>{if(PF(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return M71.default(Z)};E6.braceExpand=P71;var G56=(Z,J={})=>new TF(Z,J).makeRe();E6.makeRe=G56;var z56=(Z,J,X={})=>{let Y=new TF(J,X);if(Z=Z.filter(($)=>Y.match($)),Y.options.nonull&&!Z.length)Z.push(J);return Z};E6.match=z56;var O71=/[?*]|[+@!]\(.*?\)|\[|\]/,H56=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class TF{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(PF(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||D71,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!J.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!J.nonegate,this.comment=!1,this.empty=!1,this.partial=!!J.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=J.windowsNoMagicRoot!==void 0?J.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Z of this.set)for(let J of Z)if(typeof J!=="string")return!0;return!1}debug(...Z){}make(){let Z=this.pattern,J=this.options;if(!J.nocomment&&Z.charAt(0)==="#"){this.comment=!0;return}if(!Z){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],J.debug)this.debug=(...$)=>console.error(...$);this.debug(this.pattern,this.globSet);let X=this.globSet.map(($)=>this.slashSplit($));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let Y=this.globParts.map(($,Q,W)=>{if(this.isWindows&&this.windowsNoMagicRoot){let K=$[0]===""&&$[1]===""&&($[2]==="?"||!O71.test($[2]))&&!O71.test($[3]),G=/^[a-z]:/i.test($[0]);if(K)return[...$.slice(0,4),...$.slice(4).map((z)=>this.parse(z))];else if(G)return[$[0],...$.slice(1).map((z)=>this.parse(z))]}return $.map((K)=>this.parse(K))});if(this.debug(this.pattern,Y),this.set=Y.filter(($)=>$.indexOf(!1)===-1),this.isWindows)for(let $=0;$<this.set.length;$++){let Q=this.set[$];if(Q[0]===""&&Q[1]===""&&this.globParts[$][2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]))Q[2]="?"}this.debug(this.pattern,this.set)}preprocess(Z){if(this.options.noglobstar){for(let X=0;X<Z.length;X++)for(let Y=0;Y<Z[X].length;Y++)if(Z[X][Y]==="**")Z[X][Y]="*"}let{optimizationLevel:J=1}=this.options;if(J>=2)Z=this.firstPhasePreProcess(Z),Z=this.secondPhasePreProcess(Z);else if(J>=1)Z=this.levelOneOptimize(Z);else Z=this.adjascentGlobstarOptimize(Z);return Z}adjascentGlobstarOptimize(Z){return Z.map((J)=>{let X=-1;while((X=J.indexOf("**",X+1))!==-1){let Y=X;while(J[Y+1]==="**")Y++;if(Y!==X)J.splice(X,Y-X)}return J})}levelOneOptimize(Z){return Z.map((J)=>{return J=J.reduce((X,Y)=>{let $=X[X.length-1];if(Y==="**"&&$==="**")return X;if(Y===".."){if($&&$!==".."&&$!=="."&&$!=="**")return X.pop(),X}return X.push(Y),X},[]),J.length===0?[""]:J})}levelTwoFileOptimize(Z){if(!Array.isArray(Z))Z=this.slashSplit(Z);let J=!1;do{if(J=!1,!this.preserveMultipleSlashes){for(let Y=1;Y<Z.length-1;Y++){let $=Z[Y];if(Y===1&&$===""&&Z[0]==="")continue;if($==="."||$==="")J=!0,Z.splice(Y,1),Y--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))J=!0,Z.pop()}let X=0;while((X=Z.indexOf("..",X+1))!==-1){let Y=Z[X-1];if(Y&&Y!=="."&&Y!==".."&&Y!=="**")J=!0,Z.splice(X-1,2),X-=2}}while(J);return Z.length===0?[""]:Z}firstPhasePreProcess(Z){let J=!1;do{J=!1;for(let X of Z){let Y=-1;while((Y=X.indexOf("**",Y+1))!==-1){let Q=Y;while(X[Q+1]==="**")Q++;if(Q>Y)X.splice(Y+1,Q-Y);let W=X[Y+1],K=X[Y+2],G=X[Y+3];if(W!=="..")continue;if(!K||K==="."||K===".."||!G||G==="."||G==="..")continue;J=!0,X.splice(Y,1);let z=X.slice(0);z[Y]="**",Z.push(z),Y--}if(!this.preserveMultipleSlashes){for(let Q=1;Q<X.length-1;Q++){let W=X[Q];if(Q===1&&W===""&&X[0]==="")continue;if(W==="."||W==="")J=!0,X.splice(Q,1),Q--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))J=!0,X.pop()}let $=0;while(($=X.indexOf("..",$+1))!==-1){let Q=X[$-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**"){J=!0;let K=$===1&&X[$+1]==="**"?["."]:[];if(X.splice($-1,2,...K),X.length===0)X.push("");$-=2}}}}while(J);return Z}secondPhasePreProcess(Z){for(let J=0;J<Z.length-1;J++)for(let X=J+1;X<Z.length;X++){let Y=this.partsMatch(Z[J],Z[X],!this.preserveMultipleSlashes);if(Y){Z[J]=[],Z[X]=Y;break}}return Z.filter((J)=>J.length)}partsMatch(Z,J,X=!1){let Y=0,$=0,Q=[],W="";while(Y<Z.length&&$<J.length)if(Z[Y]===J[$])Q.push(W==="b"?J[$]:Z[Y]),Y++,$++;else if(X&&Z[Y]==="**"&&J[$]===Z[Y+1])Q.push(Z[Y]),Y++;else if(X&&J[$]==="**"&&Z[Y]===J[$+1])Q.push(J[$]),$++;else if(Z[Y]==="*"&&J[$]&&(this.options.dot||!J[$].startsWith("."))&&J[$]!=="**"){if(W==="b")return!1;W="a",Q.push(Z[Y]),Y++,$++}else if(J[$]==="*"&&Z[Y]&&(this.options.dot||!Z[Y].startsWith("."))&&Z[Y]!=="**"){if(W==="a")return!1;W="b",Q.push(J[$]),Y++,$++}else return!1;return Z.length===J.length&&Q}parseNegate(){if(this.nonegate)return;let Z=this.pattern,J=!1,X=0;for(let Y=0;Y<Z.length&&Z.charAt(Y)==="!";Y++)J=!J,X++;if(X)this.pattern=Z.slice(X);this.negate=J}matchOne(Z,J,X=!1){let Y=this.options;if(this.isWindows){let U=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),B=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),w=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),j=!w&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),N=B?3:U?0:void 0,R=j?3:w?0:void 0;if(typeof N==="number"&&typeof R==="number"){let[O,P]=[Z[N],J[R]];if(O.toLowerCase()===P.toLowerCase()){if(J[R]=O,R>N)J=J.slice(R);else if(N>R)Z=Z.slice(N)}}}let{optimizationLevel:$=1}=this.options;if($>=2)Z=this.levelTwoFileOptimize(Z);this.debug("matchOne",this,{file:Z,pattern:J}),this.debug("matchOne",Z.length,J.length);for(var Q=0,W=0,K=Z.length,G=J.length;Q<K&&W<G;Q++,W++){this.debug("matchOne loop");var z=J[W],H=Z[Q];if(this.debug(J,z,H),z===!1)return!1;if(z===R4){this.debug("GLOBSTAR",[J,z,H]);var V=Q,q=W+1;if(q===G){this.debug("** at the end");for(;Q<K;Q++)if(Z[Q]==="."||Z[Q]===".."||!Y.dot&&Z[Q].charAt(0)===".")return!1;return!0}while(V<K){var F=Z[V];if(this.debug(`
484
484
  globstar while`,Z,V,J,q,F),this.matchOne(Z.slice(V),J.slice(q),X))return this.debug("globstar found match!",V,K,F),!0;else{if(F==="."||F===".."||!Y.dot&&F.charAt(0)==="."){this.debug("dot detected!",Z,V,J,q);break}this.debug("globstar swallow a segment, and continue"),V++}}if(X){if(this.debug(`
485
- >>> no match, partial?`,Z,V,J,q),V===K)return!0}return!1}let U;if(typeof z==="string")U=H===z,this.debug("string match",z,H,U);else U=z.test(H),this.debug("pattern match",z,H,U);if(!U)return!1}if(Q===K&&W===G)return!0;else if(Q===K)return X;else if(W===G)return Q===K-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return P71(this.pattern,this.options)}parse(Z){PF(Z);let J=this.options;if(Z==="**")return R4;if(Z==="")return"";let X,Y=null;if(X=Z.match(n66))Y=J.dot?s66:a66;else if(X=Z.match(b66))Y=(J.nocase?J.dot?u66:m66:J.dot?g66:y66)(X[1]);else if(X=Z.match(o66))Y=(J.nocase?J.dot?t66:r66:J.dot?e66:Z56)(X);else if(X=Z.match(d66))Y=J.dot?l66:c66;else if(X=Z.match(p66))Y=i66;let $=k6.fromGlob(Z,this.options).toMMPattern();if(Y&&typeof $==="object")Reflect.defineProperty($,"test",{value:Y});return $}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Z=this.set;if(!Z.length)return this.regexp=!1,this.regexp;let J=this.options,X=J.noglobstar?Y56:J.dot?$56:Q56,Y=new Set(J.nocase?["i"]:[]),$=Z.map((K)=>{let G=K.map((z)=>{if(z instanceof RegExp)for(let H of z.flags.split(""))Y.add(H);return typeof z==="string"?H56(z):z===R4?R4:z._src});return G.forEach((z,H)=>{let V=G[H+1],q=G[H-1];if(z!==R4||q===R4)return;if(q===void 0)if(V!==void 0&&V!==R4)G[H+1]="(?:\\/|"+X+"\\/)?"+V;else G[H]=X;else if(V===void 0)G[H-1]=q+"(?:\\/|"+X+")?";else if(V!==R4)G[H-1]=q+"(?:\\/|\\/"+X+"\\/)"+V,G[H+1]=R4}),G.filter((z)=>z!==R4).join("/")}).join("|"),[Q,W]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+W+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(K){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let Y=this.slashSplit(Z);this.debug(this.pattern,"split",Y);let $=this.set;this.debug(this.pattern,"set",$);let Q=Y[Y.length-1];if(!Q)for(let W=Y.length-2;!Q&&W>=0;W--)Q=Y[W];for(let W=0;W<$.length;W++){let K=$[W],G=Y;if(X.matchBase&&K.length===1)G=[Q];if(this.matchOne(G,K,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return E6.defaults(Z).Minimatch}}E6.AST=k6;E6.Minimatch=TF;E6.escape=qy;E6.unescape=BY;var T71="@fastify/otel",q56="0.8.0",F56=">=4.0.0 <6",k71=["onRequest","preParsing","preValidation","preHandler","preSerialization","onSend","onResponse","onError"],r1={HOOK_NAME:"hook.name",FASTIFY_TYPE:"fastify.type",HOOK_CALLBACK_NAME:"hook.callback.name",ROOT:"fastify.root"},LY={ROUTE:"route-hook",INSTANCE:"hook",HANDLER:"request-handler"},xJ="anonymous",D5=Symbol("fastify otel instance"),jY=Symbol("fastify otel request spans"),kF=Symbol("fastify otel request context"),E71=Symbol("fastify otel addhook original"),I71=Symbol("fastify otel setnotfound original"),vR=Symbol("fastify otel ignore path");class Fy extends h8{constructor(Z){super(T71,q56,Z);if(this.servername=Z?.servername??process.env.OTEL_SERVICE_NAME??"fastify",this[vR]=null,this._logger=f8.diag.createComponentLogger({namespace:T71}),Z?.ignorePaths!=null||process.env.OTEL_FASTIFY_IGNORE_PATHS!=null){let J=Z?.ignorePaths??process.env.OTEL_FASTIFY_IGNORE_PATHS;if((typeof J!=="string"||J.length===0)&&typeof J!=="function")throw new TypeError("ignorePaths must be a string or a function");let X=E6;this[vR]=(Y)=>{if(typeof J==="function")return J(Y);else return X(Y.url,J)}}}enable(){if(this._handleInitialization===void 0&&this.getConfig().registerOnInitialization){let Z=this.plugin();this._handleInitialization=(J)=>{J.fastify.register(Z)},C71.subscribe("fastify.initialization",this._handleInitialization)}return super.enable()}disable(){if(this._handleInitialization)C71.unsubscribe("fastify.initialization",this._handleInitialization),this._handleInitialization=void 0;return super.disable()}init(){return[]}plugin(){let Z=this;return J[Symbol.for("skip-override")]=!0,J[Symbol.for("fastify.display-name")]="@fastify/otel",J[Symbol.for("plugin-meta")]={fastify:F56,name:"@fastify/otel"},J;function J(X,Y,$){X.decorate(D5,Z),X.decorate(E71,X.addHook),X.decorate(I71,X.setNotFoundHandler),X.decorateRequest("opentelemetry",function H(){let V=this[kF];return{span:this[jY],tracer:Z.tracer,context:V,inject:(F,U)=>{return f8.propagation.inject(V,F,U)},extract:(F,U)=>{return f8.propagation.extract(V,F,U)}}}),X.decorateRequest(jY,null),X.decorateRequest(kF,null),X.addHook("onRoute",function(H){if(Z[vR]?.(H)===!0){Z._logger.debug(`Ignoring route instrumentation ${H.method} ${H.url} because it matches the ignore path`);return}for(let V of k71)if(H[V]!=null){let q=H[V];if(typeof q==="function")H[V]=z(q,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - route -> ${V}`,[r1.FASTIFY_TYPE]:LY.ROUTE,[l8.ATTR_HTTP_ROUTE]:H.url,[r1.HOOK_CALLBACK_NAME]:q.name?.length>0?q.name:xJ});else if(Array.isArray(q)){let F=[];for(let U of q)F.push(z(U,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - route -> ${V}`,[r1.FASTIFY_TYPE]:LY.ROUTE,[l8.ATTR_HTTP_ROUTE]:H.url,[r1.HOOK_CALLBACK_NAME]:U.name?.length>0?U.name:xJ}));H[V]=F}}if(H.onSend!=null)H.onSend=Array.isArray(H.onSend)?[...H.onSend,Q]:[H.onSend,Q];else H.onSend=Q;if(H.onError!=null)H.onError=Array.isArray(H.onError)?[...H.onError,W]:[H.onError,W];else H.onError=W;H.handler=z(H.handler,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - route-handler`,[r1.FASTIFY_TYPE]:LY.HANDLER,[l8.ATTR_HTTP_ROUTE]:H.url,[r1.HOOK_CALLBACK_NAME]:H.handler.name.length>0?H.handler.name:xJ})}),X.addHook("onRequest",function(H,V,q){if(this[D5].isEnabled()===!1)return q();else if(this[D5][vR]?.({url:H.url,method:H.method})===!0)return this[D5]._logger.debug(`Ignoring request ${H.method} ${H.url} because it matches the ignore path`),q();let F=f8.context.active();if(f8.trace.getSpan(F)==null)F=f8.propagation.extract(F,H.headers);let U=EQ(F);if(H.routeOptions.url!=null&&U?.type===EJ.HTTP)U.route=H.routeOptions.url;let B=this[D5].tracer.startSpan("request",{attributes:{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.ROOT]:"@fastify/otel",[l8.ATTR_HTTP_ROUTE]:H.url,[l8.ATTR_HTTP_REQUEST_METHOD]:H.method}},F);H[kF]=f8.trace.setSpan(F,B),H[jY]=B,f8.context.with(H[kF],()=>{q()})}),X.addHook("onResponse",function(H,V,q){let F=H[jY];if(F!=null)F.setStatus({code:f8.SpanStatusCode.OK,message:"OK"}),F.setAttributes({[l8.ATTR_HTTP_RESPONSE_STATUS_CODE]:404}),F.end();H[jY]=null,q()}),X.addHook=K,X.setNotFoundHandler=G,$();function Q(H,V,q,F){let U=H[jY];if(U!=null){if(V.statusCode<500)U.setStatus({code:f8.SpanStatusCode.OK,message:"OK"});U.setAttributes({[l8.ATTR_HTTP_RESPONSE_STATUS_CODE]:V.statusCode}),U.end()}H[jY]=null,F(null,q)}function W(H,V,q,F){let U=H[jY];if(U!=null)U.setStatus({code:f8.SpanStatusCode.ERROR,message:q.message}),U.recordException(q);F()}function K(H,V){let q=this[E71];if(k71.includes(H))return q.call(this,H,z(V,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - ${H}`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:V.name?.length>0?V.name:xJ}));else return q.call(this,H,V)}function G(H,V){let q=this[I71];if(typeof H==="function")V=z(H,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:H.name?.length>0?H.name:xJ}),q.call(this,V);else{if(H.preValidation!=null)H.preValidation=z(H.preValidation,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler - preValidation`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:H.preValidation.name?.length>0?H.preValidation.name:xJ});if(H.preHandler!=null)H.preHandler=z(H.preHandler,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler - preHandler`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:H.preHandler.name?.length>0?H.preHandler.name:xJ});V=z(V,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:V.name?.length>0?V.name:xJ}),q.call(this,H,V)}}function z(H,V={}){return function q(...F){let U=this[D5],[B]=F;if(U.isEnabled()===!1)return H.call(this,...F);let w=B[kF]??f8.context.active(),j=U.tracer.startSpan(`handler - ${H.name?.length>0?H.name:this.pluginName??xJ}`,{attributes:V},w);return f8.context.with(f8.trace.setSpan(w,j),function(){try{let N=H.call(this,...F);if(typeof N?.then==="function")return N.then((R)=>{return j.end(),R},(R)=>{return j.setStatus({code:f8.SpanStatusCode.ERROR,message:R.message}),j.recordException(R),j.end(),Promise.reject(R)});return j.end(),N}catch(N){throw j.setStatus({code:f8.SpanStatusCode.ERROR,message:N.message}),j.recordException(N),j.end(),N}},this)}}}}}var w7=e(Y0(),1);var x71=e(R1(),1);var hJ;(function(Z){Z.FASTIFY_NAME="fastify.name";let X="fastify.type";Z.FASTIFY_TYPE=X;let Y="hook.name";Z.HOOK_NAME=Y;let $="plugin.name";Z.PLUGIN_NAME=$})(hJ||(hJ={}));var EF;(function(Z){Z.MIDDLEWARE="middleware";let X="request_handler";Z.REQUEST_HANDLER=X})(EF||(EF={}));var IF;(function(Z){Z.MIDDLEWARE="middleware";let X="request handler";Z.REQUEST_HANDLER=X})(IF||(IF={}));var S71=e(Y0(),1);var vF=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function Uy(Z,J,X,Y={}){let $=J.startSpan(X,{attributes:Y}),Q=Z[vF]||[];return Q.push($),Object.defineProperty(Z,vF,{enumerable:!1,configurable:!0,value:Q}),$}function SR(Z,J){let X=Z[vF]||[];if(!X.length)return;X.forEach((Y)=>{if(J)Y.setStatus({code:S71.SpanStatusCode.ERROR,message:J.message}),Y.recordException(J);Y.end()}),delete Z[vF]}function _71(Z,J,X){let Y,$=void 0;try{if($=Z(),v71($))$.then((Q)=>J(void 0,Q),(Q)=>J(Q))}catch(Q){Y=Q}finally{if(!v71($)){if(J(Y,$),Y)throw Y}return $}}function v71(Z){return typeof Z==="object"&&Z&&typeof Object.getOwnPropertyDescriptor(Z,"then")?.value==="function"||!1}var U56="0.1.0",w56="@sentry/instrumentation-fastify-v3",A71="anonymous",B56=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]);class wy extends h8{constructor(Z={}){super(w56,U56,Z)}init(){return[new a6("fastify",[">=3.0.0 <4"],(Z)=>{return this._patchConstructor(Z)})]}_hookOnRequest(){let Z=this;return function J(X,Y,$){if(!Z.isEnabled())return $();Z._wrap(Y,"send",Z._patchSend());let Q=X,W=EQ(w7.context.active()),K=Q.routeOptions?Q.routeOptions.url:X.routerPath;if(K&&W?.type===EJ.HTTP)W.route=K;let G=X.method||"GET";E0().setTransactionName(`${G} ${K}`),$()}}_wrapHandler(Z,J,X,Y){let $=this;return this._diag.debug("Patching fastify route.handler function"),function(...Q){if(!$.isEnabled())return X.apply(this,Q);let W=X.name||Z||A71,K=`${IF.MIDDLEWARE} - ${W}`,G=Q[1],z=Uy(G,$.tracer,K,{[hJ.FASTIFY_TYPE]:EF.MIDDLEWARE,[hJ.PLUGIN_NAME]:Z,[hJ.HOOK_NAME]:J}),H=Y&&Q[Q.length-1];if(H)Q[Q.length-1]=function(...V){SR(G),H.apply(this,V)};return w7.context.with(w7.trace.setSpan(w7.context.active(),z),()=>{return _71(()=>{return X.apply(this,Q)},(V)=>{if(V instanceof Error)z.setStatus({code:w7.SpanStatusCode.ERROR,message:V.message}),z.recordException(V);if(!Y)SR(G)})})}}_wrapAddHook(){let Z=this;return this._diag.debug("Patching fastify server.addHook function"),function(J){return function X(...Y){let $=Y[0],Q=Y[1],W=this.pluginName;if(!B56.has($))return J.apply(this,Y);let K=typeof Y[Y.length-1]==="function"&&Q.constructor.name!=="AsyncFunction";return J.apply(this,[$,Z._wrapHandler(W,$,Q,K)])}}}_patchConstructor(Z){let J=this;function X(...Y){let $=Z.fastify.apply(this,Y);return $.addHook("onRequest",J._hookOnRequest()),$.addHook("preHandler",J._hookPreHandler()),L56(),J._wrap($,"addHook",J._wrapAddHook()),$}if(Z.errorCodes!==void 0)X.errorCodes=Z.errorCodes;return X.fastify=X,X.default=X,X}_patchSend(){let Z=this;return this._diag.debug("Patching fastify reply.send function"),function J(X){return function Y(...$){let Q=$[0];if(!Z.isEnabled())return X.apply(this,$);return $Y(()=>{return X.apply(this,$)},(W)=>{if(!W&&Q instanceof Error)W=Q;SR(this,W)})}}}_hookPreHandler(){let Z=this;return this._diag.debug("Patching fastify preHandler function"),function J(X,Y,$){if(!Z.isEnabled())return $();let Q=X,W=Q.routeOptions?.handler||Q.context?.handler,K=W?.name.startsWith("bound ")?W.name.substring(6):W?.name,G=`${IF.REQUEST_HANDLER} - ${K||this.pluginName||A71}`,z={[hJ.PLUGIN_NAME]:this.pluginName,[hJ.FASTIFY_TYPE]:EF.REQUEST_HANDLER,[x71.SEMATTRS_HTTP_ROUTE]:Q.routeOptions?Q.routeOptions.url:X.routerPath};if(K)z[hJ.FASTIFY_NAME]=K;let H=Uy(Y,Z.tracer,G,z);h71(H);let{requestHook:V}=Z.getConfig();if(V)$Y(()=>V(H,{request:X}),(q)=>{if(q)Z._diag.error("request hook failed",q)},!0);return w7.context.with(w7.trace.setSpan(w7.context.active(),H),()=>{$()})}}}function L56(){let Z=X0();if(Z)Z.on("spanStart",(J)=>{h71(J)})}function h71(Z){let J=B0(Z).data,X=J["fastify.type"];if(J[N0]||!X)return;Z.setAttributes({[_0]:"auto.http.otel.fastify",[N0]:`${X}.fastify`});let Y=J["fastify.name"]||J["plugin.name"]||J["hook.name"];if(typeof Y==="string"){let $=Y.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");Z.updateName($)}}var f71="Fastify",j56="Fastify-V5",O56="Fastify-V3",Ly=w0(O56,()=>new wy);function b71(){let Z=X0();if(!Z)return;else return Z.getIntegrationByName(f71)}function _R(Z,J,X,Y){let $=b71()?.getShouldHandleError()||y71;if(Y==="diagnostics-channel")this.diagnosticsChannelExists=!0;if(this.diagnosticsChannelExists&&Y==="onError-hook"){j4&&h.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}if($(Z,J,X))Z1(Z,{mechanism:{handled:!1,type:"fastify"}})}var jy=w0(j56,()=>{let Z=new Fy,J=Z.plugin();return By.subscribe("fastify.initialization",(X)=>{let Y=X.fastify;Y?.register(J).after(($)=>{if($)j4&&h.error("Failed to setup Fastify instrumentation",$);else if(R56(),Y)N56(Y)})}),By.subscribe("tracing:fastify.request.handler:error",(X)=>{let{error:Y,request:$,reply:Q}=X;_R.call(_R,Y,$,Q,"diagnostics-channel")}),Z}),M56=({shouldHandleError:Z})=>{let J;return{name:f71,setupOnce(){J=Z||y71,Ly(),jy()},getShouldHandleError(){return J},setShouldHandleError(X){J=X}}},AR=a((Z={})=>M56(Z));function y71(Z,J,X){let Y=X.statusCode;return Y>=500||Y<=299}function g71(Z,J){if(J?.shouldHandleError)b71()?.setShouldHandleError(J.shouldHandleError);let X=Object.assign(function(Y,$,Q){Y.addHook("onError",async(W,K,G)=>{_R.call(_R,G,W,K,"onError-hook")}),Q()},{[Symbol.for("skip-override")]:!0,[Symbol.for("fastify.display-name")]:"sentry-fastify-error-handler"});Z.register(X)}function m71(Z){let J=B0(Z),X=J.description,Y=J.data,$=Y["fastify.type"],Q=$==="hook",W=$===X?.startsWith("handler -"),K=X==="request"||$==="request-handler";if(Y[N0]||!W&&!K&&!Q)return;let G=Q?"hook":W?"middleware":K?"request-handler":"<unknown>";Z.setAttributes({[_0]:"auto.http.otel.fastify",[N0]:`${G}.fastify`});let z=Y["fastify.name"]||Y["plugin.name"]||Y["hook.name"];if(typeof z==="string"){let H=z.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");Z.updateName(H)}}function R56(){let Z=X0();if(Z)Z.on("spanStart",(J)=>{m71(J)})}function N56(Z){Z.addHook("onRequest",async(J,X)=>{if(J.opentelemetry){let{span:Q}=J.opentelemetry();if(Q)m71(Q)}let Y=J.routeOptions?.url,$=J.method||"GET";E0().setTransactionName(`${$} ${Y}`)})}var PZ1=e(Y0(),1),CZ1=e(DZ1(),1);var TZ1="Graphql",Cy=w0(TZ1,CZ1.GraphQLInstrumentation,(Z)=>{let J=kZ1(Z);return{...J,responseHook(X,Y){if(o1(X,"auto.graphql.otel.graphql"),Y.errors?.length&&!B0(X).status)X.setStatus({code:PZ1.SpanStatusCode.ERROR});let Q=B0(X).data,W=Q["graphql.operation.type"],K=Q["graphql.operation.name"];if(J.useOperationNameForRootSpan&&W){let G=s1(X),H=B0(G).data[h3]||[],V=K?`${W} ${K}`:`${W}`;if(Array.isArray(H))H.push(V),G.setAttribute(h3,H);else if(typeof H==="string")G.setAttribute(h3,[H,V]);else G.setAttribute(h3,V);if(!B0(G).data["original-description"])G.setAttribute("original-description",B0(G).description);G.updateName(`${B0(G).data["original-description"]} (${s56(H)})`)}}}}),a56=(Z={})=>{return{name:TZ1,setupOnce(){Cy(kZ1(Z))}}},bR=a(a56);function kZ1(Z){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...Z}}function s56(Z){if(Array.isArray(Z)){let J=Z.slice().sort();if(J.length<=5)return J.join(", ");else return`${J.slice(0,5).join(", ")}, +${J.length-5}`}return`${Z}`}var lZ1=e(cZ1(),1);var pZ1="Kafka",Ty=w0(pZ1,()=>new lZ1.KafkaJsInstrumentation({consumerHook(Z){o1(Z,"auto.kafkajs.otel.consumer")},producerHook(Z){o1(Z,"auto.kafkajs.otel.producer")}})),t56=()=>{return{name:pZ1,setupOnce(){Ty()}}},yR=a(t56);var YJ1=e(XJ1(),1);var $J1="LruMemoizer",ky=w0($J1,()=>new YJ1.LruMemoizerInstrumentation),X96=()=>{return{name:$J1,setupOnce(){ky()}}},gR=a(X96);var OJ1=e(jJ1(),1);var MJ1="Mongo",_y=w0(MJ1,()=>new OJ1.MongoDBInstrumentation({dbStatementSerializer:K96,responseHook(Z){o1(Z,"auto.db.otel.mongo")}}));function K96(Z){let J=Sy(Z);return JSON.stringify(J)}function Sy(Z){if(Array.isArray(Z))return Z.map((J)=>Sy(J));if(G96(Z)){let J={};return Object.entries(Z).map(([X,Y])=>[X,Sy(Y)]).reduce((X,Y)=>{if(H96(Y))X[Y[0]]=Y[1];return X},J)}return"?"}function G96(Z){return typeof Z==="object"&&Z!==null&&!z96(Z)}function z96(Z){let J=!1;if(typeof Buffer!=="undefined")J=Buffer.isBuffer(Z);return J}function H96(Z){return Array.isArray(Z)}var V96=()=>{return{name:MJ1,setupOnce(){_y()}}},mR=a(V96);var uJ1=e(mJ1(),1);var dJ1="Mongoose",hy=w0(dJ1,()=>new uJ1.MongooseInstrumentation({responseHook(Z){o1(Z,"auto.db.otel.mongoose")}})),P96=()=>{return{name:dJ1,setupOnce(){hy()}}},dR=a(P96);var WX1=e(QX1(),1);var KX1="Mysql",gy=w0(KX1,()=>new WX1.MySQLInstrumentation({})),m96=()=>{return{name:KX1,setupOnce(){gy()}}},lR=a(m96);var kX1=e(TX1(),1);var EX1="Mysql2",ly=w0(EX1,()=>new kX1.MySQL2Instrumentation({responseHook(Z){o1(Z,"auto.db.otel.mysql2")}})),Y46=()=>{return{name:EX1,setupOnce(){ly()}}},iR=a(Y46);var wY1=e(nX1(),1),BY1=e(HY1(),1);var L46=["get","set","setex"],iy=["get","mget"],j46=["set","setex"];function gF(Z,J){return Z.includes(J.toLowerCase())}function ny(Z){if(gF(iy,Z))return"cache.get";else if(gF(j46,Z))return"cache.put";else return}function O46(Z,J){return J.some((X)=>Z.startsWith(X))}function qY1(Z,J){try{if(J.length===0)return;let X=($)=>{if(typeof $==="string"||typeof $==="number"||Buffer.isBuffer($))return[$.toString()];else if(Array.isArray($))return VY1($.map((Q)=>X(Q)));else return["<unknown>"]},Y=J[0];if(gF(L46,Z)&&Y!=null)return X(Y);return VY1(J.map(($)=>X($)))}catch{return}}function FY1(Z,J,X){if(!ny(Z))return!1;for(let Y of J)if(O46(Y,X))return!0;return!1}function UY1(Z){let J=(X)=>{try{if(Buffer.isBuffer(X))return X.byteLength;else if(typeof X==="string")return X.length;else if(typeof X==="number")return X.toString().length;else if(X===null||X===void 0)return 0;return JSON.stringify(X).length}catch{return}};return Array.isArray(Z)?Z.reduce((X,Y)=>{let $=J(Y);return typeof $==="number"?X!==void 0?X+$:$:X},0):J(Z)}function VY1(Z){let J=[],X=(Y)=>{Y.forEach(($)=>{if(Array.isArray($))X($);else J.push($)})};return X(Z),J}var LY1="Redis",ay={},jY1=(Z,J,X,Y)=>{Z.setAttribute(_0,"auto.db.otel.redis");let $=qY1(J,X),Q=ny(J);if(!$||!Q||!ay.cachePrefixes||!FY1(J,$,ay.cachePrefixes))return;let W=B0(Z).data["net.peer.name"],K=B0(Z).data["net.peer.port"];if(K&&W)Z.setAttributes({"network.peer.address":W,"network.peer.port":K});let G=UY1(Y);if(G)Z.setAttribute(Gh,G);if(gF(iy,J)&&G!==void 0)Z.setAttribute(Wh,G>0);Z.setAttributes({[N0]:Q,[Kh]:$});let z=$.join(", ");Z.updateName(s5(z,1024))},M46=w0("IORedis",()=>{return new wY1.IORedisInstrumentation({responseHook:jY1})}),R46=w0("Redis-4",()=>{return new BY1.RedisInstrumentation({responseHook:jY1})}),sy=Object.assign(()=>{M46(),R46()},{id:LY1}),N46=(Z={})=>{return{name:LY1,setupOnce(){ay=Z,sy()}}},aR=a(N46);var oY1=e(sY1(),1);var rY1="Postgres",Yg=w0(rY1,()=>new oY1.PgInstrumentation({requireParentSpan:!0,requestHook(Z){o1(Z,"auto.db.otel.postgres")}})),W76=()=>{return{name:rY1,setupOnce(){Yg()}}},tR=a(W76);var r3=e(Y0(),1);var r6=e(R1(),1);var $g="PostgresJs",tY1=[">=3.0.0 <4"],Qg=w0($g,(Z)=>new eY1({requireParentSpan:Z?.requireParentSpan??!0,requestHook:Z?.requestHook}));class eY1 extends h8{constructor(Z){super("sentry-postgres-js",M1,Z)}init(){let Z=new a6("postgres",tY1);return["src","cf/src","cjs/src"].forEach((J)=>{Z.files.push(new fM(`postgres/${J}/connection.js`,["*"],this._patchConnection.bind(this),this._unwrap.bind(this))),Z.files.push(new fM(`postgres/${J}/query.js`,tY1,this._patchQuery.bind(this),this._unwrap.bind(this)))}),[Z]}_shouldCreateSpans(){let Z=this.getConfig();return r3.trace.getSpan(r3.context.active())!==void 0||!Z.requireParentSpan}_patchReject(Z,J){return new Proxy(Z,{apply:(X,Y,$)=>{J.setStatus({code:x8,message:$?.[0]?.message||"unknown_error"});let Q=Reflect.apply(X,Y,$);return J.setAttribute(r6.ATTR_DB_RESPONSE_STATUS_CODE,$?.[0]?.code||"Unknown error"),J.setAttribute(r6.ATTR_ERROR_TYPE,$?.[0]?.name||"Unknown error"),J.end(),Q}})}_patchResolve(Z,J){return new Proxy(Z,{apply:(X,Y,$)=>{let Q=Reflect.apply(X,Y,$),W=$?.[0]?.command;if(W)J.setAttribute(r6.ATTR_DB_OPERATION_NAME,W);return J.end(),Q}})}_patchQuery(Z){return Z.Query.prototype.handle=new Proxy(Z.Query.prototype.handle,{apply:async(J,X,Y)=>{if(!this._shouldCreateSpans())return Reflect.apply(J,X,Y);let $=this._sanitizeSqlQuery(X.strings?.[0]);return jQ({name:$||"postgresjs.query",op:"db"},(Q)=>{let K=T0().getScopeData().contexts.postgresjsConnection;o1(Q,"auto.db.otel.postgres");let{requestHook:G}=this.getConfig();if(G)$Y(()=>G(Q,$,K),(q)=>{if(q)h.error(`Error in requestHook for ${$g} integration:`,q)});let z=K?.ATTR_DB_NAMESPACE||"<unknown database>",H=K?.ATTR_SERVER_ADDRESS||"<unknown host>",V=K?.ATTR_SERVER_PORT||"<unknown port>";Q.setAttribute(r6.ATTR_DB_SYSTEM_NAME,"postgres"),Q.setAttribute(r6.ATTR_DB_NAMESPACE,z),Q.setAttribute(r6.ATTR_SERVER_ADDRESS,H),Q.setAttribute(r6.ATTR_SERVER_PORT,V),Q.setAttribute(r6.ATTR_DB_QUERY_TEXT,$),X.resolve=this._patchResolve(X.resolve,Q),X.reject=this._patchReject(X.reject,Q);try{return Reflect.apply(J,X,Y)}catch(q){throw Q.setStatus({code:x8}),Q.end(),q}})}}),Z}_patchConnection(Z){return new Proxy(Z,{apply:(J,X,Y)=>{let $=Y[0]?.database||"<unknown database>",Q=Y[0]?.host?.[0]||"<unknown host>",W=Y[0]?.port?.[0]||"<unknown port>";return T0().setContext("postgresjsConnection",{ATTR_DB_NAMESPACE:$,ATTR_SERVER_ADDRESS:Q,ATTR_SERVER_PORT:W}),Reflect.apply(J,X,Y)}})}_sanitizeSqlQuery(Z){if(!Z)return"Unknown SQL Query";return Z.replace(/\s+/g," ").trim().substring(0,1024).replace(/--.*?(\r?\n|$)/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\b\d+\b/g,"?").replace(/\s+/g," ").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/g,"IN (?)")}}var K76=()=>{return{name:$g,setupOnce(){Qg()}}},eR=a(K76);var X$1=e(Y0(),1);var AY=e(Y0(),1);var G76=process.env.PRISMA_SHOW_ALL_TRACES==="true",z76="00-10-10-00";function H76(Z){switch(Z){case"client":return AY.SpanKind.CLIENT;case"internal":default:return AY.SpanKind.INTERNAL}}var V76=class{traceMiddleware;tracerProvider;ignoreSpanTypes;constructor({traceMiddleware:Z,tracerProvider:J,ignoreSpanTypes:X}){this.traceMiddleware=Z,this.tracerProvider=J,this.ignoreSpanTypes=X}isEnabled(){return!0}getTraceParent(Z){let J=AY.trace.getSpanContext(Z??AY.context.active());if(J)return`00-${J.traceId}-${J.spanId}-0${J.traceFlags}`;return z76}dispatchEngineSpans(Z){let J=this.tracerProvider.getTracer("prisma"),X=new Map,Y=Z.filter(($)=>$.parentId===null);for(let $ of Y)Y$1(J,$,Z,X,this.ignoreSpanTypes)}getActiveContext(){return AY.context.active()}runInChildSpan(Z,J){if(typeof Z==="string")Z={name:Z};if(Z.internal&&!G76)return J();if(Z.middleware&&!this.traceMiddleware)return J();let X=this.tracerProvider.getTracer("prisma"),Y=Z.context??this.getActiveContext(),$=`prisma:client:${Z.name}`;if($$1($,this.ignoreSpanTypes))return J();if(Z.active===!1){let Q=X.startSpan($,Z,Y);return Z$1(Q,J(Q,Y))}return X.startActiveSpan($,Z,(Q)=>Z$1(Q,J(Q,Y)))}};function Y$1(Z,J,X,Y,$){if($$1(J.name,$))return;let Q={attributes:J.attributes,kind:H76(J.kind),startTime:J.startTime};Z.startActiveSpan(J.name,Q,(W)=>{if(Y.set(J.id,W.spanContext().spanId),J.links)W.addLinks(J.links.flatMap((G)=>{let z=Y.get(G);if(!z)return[];return{context:{spanId:z,traceId:W.spanContext().traceId,traceFlags:W.spanContext().traceFlags}}}));let K=X.filter((G)=>G.parentId===J.id);for(let G of K)Y$1(Z,G,X,Y,$);W.end(J.endTime)})}function Z$1(Z,J){if(q76(J))return J.then((X)=>{return Z.end(),X},(X)=>{throw Z.end(),X});return Z.end(),J}function q76(Z){return Z!=null&&typeof Z.then==="function"}function $$1(Z,J){return J.some((X)=>typeof X==="string"?X===Z:X.test(Z))}var Q$1={name:"@prisma/instrumentation",version:"6.11.1",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@prisma/internals":"workspace:*","@swc/core":"1.11.5","@types/jest":"29.5.14","@types/node":"18.19.76","@opentelemetry/api":"1.9.0",jest:"29.7.0","jest-junit":"16.0.0",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":"^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"jest"},sideEffects:!1},Kg=Q$1.version,F76=Kg.split(".")[0],J$1="PRISMA_INSTRUMENTATION",Wg=`V${F76}_PRISMA_INSTRUMENTATION`,U76=Q$1.name,w76="@prisma/client",W$1=class extends h8{tracerProvider;constructor(Z={}){super(U76,Kg,Z)}setTracerProvider(Z){this.tracerProvider=Z}init(){return[new a6(w76,[Kg])]}enable(){let Z=this._config,J={helper:new V76({traceMiddleware:Z.middleware??!1,tracerProvider:this.tracerProvider??X$1.trace.getTracerProvider(),ignoreSpanTypes:Z.ignoreSpanTypes??[]})};global[J$1]=J,global[Wg]=J}disable(){delete global[J$1],delete global[Wg]}isEnabled(){return Boolean(global[Wg])}};var K$1="Prisma";function B76(Z){return!!Z&&typeof Z==="object"&&"dispatchEngineSpans"in Z}function G$1(){let Z=globalThis.PRISMA_INSTRUMENTATION;return Z&&typeof Z==="object"&&"helper"in Z?Z.helper:void 0}class z$1 extends W$1{constructor(){super()}enable(){super.enable();let Z=G$1(),J=!1;if(B76(Z))Z.createEngineSpan=()=>{e0(()=>{if(!J)J=!0,console.warn("[Sentry] The Sentry SDK supports tracing with Prisma version 5 only with limited capabilities. For full tracing capabilities pass `prismaInstrumentation` for version 5 to the Sentry `prismaIntegration`. Read more: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/")})}}}var L76=w0(K$1,(Z)=>{if(Z?.prismaInstrumentation)return Z.prismaInstrumentation;return new z$1}),ZN=a(({prismaInstrumentation:Z}={})=>{return{name:K$1,setupOnce(){L76({prismaInstrumentation:Z})},setup(J){if(!G$1())return;J.on("spanStart",(X)=>{let Y=B0(X);if(Y.description?.startsWith("prisma:"))X.setAttribute(_0,"auto.db.otel.prisma");if(Y.description==="prisma:engine:db_query"&&Y.data["db.query.text"])X.updateName(Y.data["db.query.text"]);if(Y.description==="prisma:engine:db_query"&&!Y.data["db.system"])X.setAttribute("db.system","prisma")})}}});var k$1=e(T$1(),1);var E$1="Hapi",YN=w0(E$1,()=>new k$1.HapiInstrumentation),y76=()=>{return{name:E$1,setupOnce(){YN()}}},$N=a(y76);function g76(Z){return!!(Z&&typeof Z==="object"&&("error"in Z)&&Z.error)}function m76(Z){Z1(Z,{mechanism:{type:"hapi",handled:!1,data:{function:"hapiErrorPlugin"}}})}var u76={name:"SentryHapiErrorPlugin",version:M1,register:async function(Z){Z.events.on({name:"request",channels:["error"]},(X,Y)=>{if(E0()!==z4()){let $=X.route;if($.path)E0().setTransactionName(`${$.method.toUpperCase()} ${$.path}`)}else j4&&h.warn("Isolation scope is still the default isolation scope - skipping setting transactionName");if(g76(Y))m76(Y.error)})}};async function I$1(Z){await Z.register(u76);let J=X0();if(J)J.on("spanStart",(X)=>{d76(X)});SJ(Z.register,"hapi")}function d76(Z){let J=B0(Z).data,X=J["hapi.type"];if(J[N0]||!X)return;Z.setAttributes({[_0]:"auto.http.otel.hapi",[N0]:`${X}.hapi`})}var t$1=e(r$1(),1),e$1=e(R1(),1);var ZQ1="Koa",Bg=w0(ZQ1,t$1.KoaInstrumentation,(Z={})=>{return{ignoreLayersType:Z.ignoreLayersType,requestHook(J,X){o1(J,"auto.http.otel.koa");let Y=B0(J).data,$=Y["koa.type"];if($)J.setAttribute(N0,`${$}.koa`);let Q=Y["koa.name"];if(typeof Q==="string")J.updateName(Q||"< unknown >");if(E0()===z4()){j4&&h.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let W=Y[e$1.ATTR_HTTP_ROUTE],K=X.context?.request?.method?.toUpperCase()||"GET";if(W)E0().setTransactionName(`${K} ${W}`)}}}),r76=(Z={})=>{return{name:ZQ1,setupOnce(){Bg(Z)}}},KN=a(r76),JQ1=(Z)=>{Z.use(async(J,X)=>{try{await X()}catch(Y){throw Z1(Y),Y}}),SJ(Z.use,"koa")};var NQ1=e(RQ1(),1);var DQ1="Connect",Rg=w0(DQ1,()=>new NQ1.ConnectInstrumentation),VZ6=()=>{return{name:DQ1,setupOnce(){Rg()}}},zN=a(VZ6);function qZ6(Z,J,X,Y){Z1(Z),Y(Z)}var PQ1=(Z)=>{Z.use(qZ6);let J=X0();if(J)J.on("spanStart",(X)=>{FZ6(X)});SJ(Z.use,"connect")};function FZ6(Z){let J=B0(Z).data,X=J["connect.type"];if(J[N0]||!X)return;Z.setAttributes({[_0]:"auto.http.otel.connect",[N0]:`${X}.connect`});let Y=J["connect.name"];if(typeof Y==="string")Z.updateName(Y)}var pQ1=e(lQ1(),1);var iQ1="Knex",IZ6=w0(iQ1,()=>new pQ1.KnexInstrumentation({requireParentSpan:!0})),vZ6=()=>{let Z;return{name:iQ1,setupOnce(){let J=IZ6();Z=TJ(J)},setup(J){Z?.(()=>J.on("spanStart",(X)=>{let{data:Y}=B0(X);if("knex.version"in Y)X.setAttribute(_0,"auto.db.otel.knex")}))}}},nQ1=a(vZ6);var VW1=e(HW1(),1);var bZ6=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),qW1="Tedious",Dg=w0(qW1,()=>new VW1.TediousInstrumentation({})),yZ6=()=>{let Z;return{name:qW1,setupOnce(){let J=Dg();Z=TJ(J)},setup(J){Z?.(()=>J.on("spanStart",(X)=>{let{description:Y,data:$}=B0(X);if(!Y||$["db.system"]!=="mssql")return;let Q=Y.split(" ")[0]||"";if(bZ6.has(Q))X.setAttribute(_0,"auto.db.otel.tedious")}))}}},UN=a(yZ6);var NW1=e(RW1(),1);var DW1="GenericPool",Cg=w0(DW1,()=>new NW1.GenericPoolInstrumentation({})),dZ6=()=>{let Z;return{name:DW1,setupOnce(){let J=Cg();Z=TJ(J)},setup(J){Z?.(()=>J.on("spanStart",(X)=>{let $=B0(X).description;if($==="generic-pool.aquire"||$==="generic-pool.acquire")X.setAttribute(_0,"auto.db.otel.generic_pool")}))}}},wN=a(dZ6);var fW1=e(hW1(),1);var bW1="Dataloader",pZ6=w0(bW1,()=>new fW1.DataloaderInstrumentation({requireParentSpan:!0})),iZ6=()=>{let Z;return{name:bW1,setupOnce(){let J=pZ6();Z=TJ(J)},setup(J){Z?.(()=>{J.on("spanStart",(X)=>{let Y=B0(X);if(Y.description?.startsWith("dataloader"))X.setAttribute(_0,"auto.db.otel.dataloader");if(Y.description==="dataloader.load"||Y.description==="dataloader.loadMany"||Y.description==="dataloader.batch")X.setAttribute(N0,"cache.get")})})}}},yW1=a(iZ6);var $K1=e(YK1(),1);var QK1="Amqplib",qJ6={consumeEndHook:(Z)=>{o1(Z,"auto.amqplib.otel.consumer")},publishHook:(Z)=>{o1(Z,"auto.amqplib.otel.publisher")}},vg=w0(QK1,()=>new $K1.AmqplibInstrumentation(qJ6)),FJ6=()=>{return{name:QK1,setupOnce(){vg()}}},jN=a(FJ6);var pF="VercelAI";var WK1=["generateText","streamText","generateObject","streamObject","embed","embedMany"];function UJ6(Z,J,X,Y){let $=Z?.recordInputs!==void 0?Z.recordInputs:J.recordInputs!==void 0?J.recordInputs:X===!0?!0:Y,Q=Z?.recordOutputs!==void 0?Z.recordOutputs:J.recordOutputs!==void 0?J.recordOutputs:X===!0?!0:Y;return{recordInputs:$,recordOutputs:Q}}class iF extends h8{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(Z={}){super("@sentry/instrumentation-vercel-ai",M1,Z);iF.prototype.__init.call(this),iF.prototype.__init2.call(this)}init(){return new a6("ai",[">=3.0.0 <5"],this._patch.bind(this))}callWhenPatched(Z){if(this._isPatched)Z();else this._callbacks.push(Z)}_patch(Z){this._isPatched=!0,this._callbacks.forEach((X)=>X()),this._callbacks=[];function J(X){return(...Y)=>{let $=Y[0].experimental_telemetry||{},Q=$.isEnabled,W=T0().getClient(),K=W?.getIntegrationByName(pF),G=K?.options,z=K?Boolean(W?.getOptions().sendDefaultPii):!1,{recordInputs:H,recordOutputs:V}=UJ6(G,$,Q,z);return Y[0].experimental_telemetry={...$,isEnabled:Q!==void 0?Q:!0,recordInputs:H,recordOutputs:V},MJ(()=>{return X.apply(this,Y)},(q)=>{if(q&&typeof q==="object")J8(q,"_sentry_active_span",T6())})}}if(Object.prototype.toString.call(Z)==="[object Module]"){for(let X of WK1)Z[X]=J(Z[X]);return Z}else{let X=WK1.reduce((Y,$)=>{return Y[$]=J(Z[$]),Y},{});return{...Z,...X}}}}var Sg=w0(pF,()=>new iF({}));function wJ6(Z){return!!Z.getIntegrationByName("Modules")?.getModules?.()?.ai}var BJ6=(Z={})=>{let J;return{name:pF,options:Z,setupOnce(){J=Sg()},afterAllSetup(X){if(Z.force??wJ6(X))kM(X);else J?.callWhenPatched(()=>kM(X))}}},ON=a(BJ6);var LJ6=[">=4.0.0 <6"];function jJ6(Z,J){let X=Z?.recordInputs??J,Y=Z?.recordOutputs??J;return{recordInputs:X,recordOutputs:Y}}class _g extends h8{constructor(Z={}){super("@sentry/instrumentation-openai",M1,Z)}init(){return new a6("openai",LJ6,this._patch.bind(this))}_patch(Z){let J=Z.OpenAI,X=function(...Y){let $=Reflect.construct(J,Y),Q=T0().getClient(),K=Q?.getIntegrationByName(XY)?.options,G=Boolean(Q?.getOptions().sendDefaultPii),{recordInputs:z,recordOutputs:H}=jJ6(K,G);return ff($,{recordInputs:z,recordOutputs:H})};Object.setPrototypeOf(X,J),Object.setPrototypeOf(X.prototype,J.prototype);for(let Y of Object.getOwnPropertyNames(J))if(!["length","name","prototype"].includes(Y)){let $=Object.getOwnPropertyDescriptor(J,Y);if($)Object.defineProperty(X,Y,$)}try{Z.OpenAI=X}catch(Y){Object.defineProperty(Z,"OpenAI",{value:X,writable:!0,configurable:!0,enumerable:!0})}return Z}}var Ag=w0(XY,()=>new _g({})),OJ6=(Z={})=>{return{name:XY,options:Z,setupOnce(){Ag()}}},MN=a(OJ6);var KK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The launchDarklyIntegration() can only be used in the browser.")});return{name:"LaunchDarkly"}});function GK1(){if(!z7())e0(()=>{console.warn("The buildLaunchDarklyFlagUsedHandler() can only be used in the browser.")});return{name:"sentry-flag-auditor",type:"flag-used",synchronous:!0,method:()=>null}}var zK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The openFeatureIntegration() can only be used in the browser.")});return{name:"OpenFeature"}});class xg{constructor(){if(!z7())e0(()=>{console.warn("The OpenFeatureIntegrationHook can only be used in the browser.")})}after(){}error(){}}var HK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The statsigIntegration() can only be used in the browser.")});return{name:"Statsig"}});var VK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The unleashIntegration() can only be used in the browser.")});return{name:"Unleash"}});function RN(){return[ER(),AR(),bR(),mR(),dR(),lR(),iR(),aR(),tR(),ZN(),$N(),KN(),zN(),UN(),wN(),yR(),jN(),gR(),ON(),MN(),eR()]}function qK1(){return[ob,Wy,Ky,Rg,jy,Ly,YN,Ty,Bg,ky,_y,hy,gy,ly,Yg,YN,Cy,sy,Dg,Cg,vg,Sg,Ag,Qg]}var XG=e(Y0(),1);var YG=e(R1(),1);var FK1=e($q(),1);import MJ6 from"module";var hg=1e6;function NN(Z,J={}){if(Z.getOptions().debug)cb();let X=DJ6(Z,J);Z.traceProvider=X}function RJ6(){let[Z=0,J=0]=process.versions.node.split(".").map(Number);if(Z>=21||Z===20&&J>=6||Z===18&&J>=19){if(!O0._sentryEsmLoaderHookRegistered)try{let{addHookMessagePort:X}=FK1.createAddHookMessageChannel();MJ6.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:X,include:[]},transferList:[X]})}catch(X){h.warn("Failed to register ESM hook",X)}}else e0(()=>{console.warn(`[Sentry] You are using Node.js v${process.versions.node} in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.`)})}function UK1(Z={}){let{debug:J}=Z;if(J)h.enable();if(!L4())RJ6();NJ6(Z.integrations).forEach((X)=>{if(X(),J)h.log(`[Sentry] Preloaded ${X.id} instrumentation`)})}function NJ6(Z){let J=qK1();if(!Z)return J;return J.filter((X)=>Z.includes(X.id))}function DJ6(Z,J={}){let X=new Hb({sampler:new Ib(Z),resource:new _3({[YG.ATTR_SERVICE_NAME]:"node",[YG.SEMRESATTRS_SERVICE_NAMESPACE]:"sentry",[YG.ATTR_SERVICE_VERSION]:M1}),forceFlushTimeoutMillis:500,spanProcessors:[new Eb({timeout:PJ6(Z.getOptions().maxSpanWaitDuration)}),...J.spanProcessors||[]]});return XG.trace.setGlobalTracerProvider(X),XG.propagation.setGlobalPropagator(new Db),XG.context.setGlobalContextManager(new qF),X}function PJ6(Z){if(Z==null)return;if(Z>hg)return j4&&h.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${hg}`),hg;else if(Z<=0||Number.isNaN(Z)){j4&&h.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return Z}function fg(){return jR().filter((J)=>J.name!=="Http"&&J.name!=="NodeFetch").concat(OR(),RR())}function bg(Z){return[...fg(),...c8(Z)?RN():[]]}function DN(Z={}){return wK1(Z,bg)}function wK1(Z={},J){DQ(Z,"node");let X=nb({...Z,defaultIntegrations:Z.defaultIntegrations??J(Z)});if(X&&!Z.skipOpenTelemetrySetup)NN(X,{spanProcessors:Z.openTelemetrySpanProcessors}),OF();return X}function BK1(Z={}){return wK1(Z,()=>[])}var sQ;((B)=>{B.BUILD_PACKETS="build_packets";B.ENTITIES_EMIT_UPDATES="entities_emit_updates";B.ENTITIES_TICK="entities_tick";B.NETWORK_SYNCHRONIZE="network_synchronize";B.NETWORK_SYNCHRONIZE_CLEANUP="network_synchronize_cleanup";B.PHYSICS_CLEANUP="physics_cleanup";B.PHYSICS_STEP="physics_step";B.SEND_ALL_PACKETS="send_all_packets";B.SEND_PACKETS="send_packets";B.SERIALIZE_FREE_BUFFERS="serialize_free_buffers";B.SERIALIZE_PACKETS="serialize_packets";B.SERIALIZE_PACKETS_ENCODE="serialize_packets_encode";B.SIMULATION_STEP="simulation_step";B.TICKER_TICK="ticker_tick";B.WORLD_TICK="world_tick"})(sQ||={});class N8{static getProcessStats(Z=!1){let J=process.memoryUsage(),X={jsHeapSizeMb:{value:J.heapUsed/1024/1024,unit:"megabyte"},jsHeapCapacityMb:{value:J.heapTotal/1024/1024,unit:"megabyte"},jsHeapUsagePercent:{value:J.heapUsed/J.heapTotal,unit:"percent"},processHeapSizeMb:{value:J.heapUsed/1024/1024,unit:"megabyte"},rssSizeMb:{value:J.rss/1024/1024,unit:"megabyte"}};if(Z)return X;return Object.fromEntries(Object.entries(X).map(([Y,$])=>[Y,$.value]))}static initializeSentry(Z,J=50){DN({dsn:Z,release:nS,environment:process.env.NODE_ENV||"development",tracesSampleRate:1,initialScope:{tags:{gameId:process.env.HYTOPIA_GAME_ID??"unknown",gameSlug:process.env.HYTOPIA_GAME_SLUG??"unknown",lobbyId:process.env.HYTOPIA_LOBBY_ID??"unknown",region:process.env.REGION??"unknown"}},beforeSend:(X)=>{return X.extra=N8.getProcessStats(),X},beforeSendTransaction:(X)=>{if(X.contexts?.trace?.op==="ticker_tick"){let $=X?.start_timestamp,Q=X?.timestamp;if(!$||!Q)return null;if((Q-$)*1000>J)return X.measurements=N8.getProcessStats(!0),X}return null}})}static startSpan(Z,J){if(Eq())return q4({attributes:Z.attributes,name:Z.operation,op:Z.operation},J);else return J()}static sentry(){return yg}}var LK1=new I$,kJ6=5000;class o4 extends j0{static _cachedPacketsSerializedBuffer=new Map;_closeTimeout=null;_wrtcDirectTransport=null;_wrtcClientServerTransport=null;_wrtcClientServerDataProducers=[];_wrtcClientServerDataConsumers=[];_wrtcServerClientTransport=null;_wrtcServerClientReliableDataProducer=null;_wrtcServerClientUnreliableDataProducer=null;_wrtcServerClientDataConsumers=[];_ws;id;constructor(Z,J){super();this.id=q50(),this.onPacket(Q0.PacketId.CONNECTION,this._onConnectionPacket),this.onPacket(Q0.PacketId.HEARTBEAT,this._onHeartbeatPacket),this.bindWs(Z),j0.globalInstance.emit("CONNECTION.OPENED",{connection:this,req:J})}static clearCachedPacketsSerializedBuffers(){if(o4._cachedPacketsSerializedBuffer.size>0)o4._cachedPacketsSerializedBuffer.clear()}static serializePackets(Z){for(let X of Z)if(!Q0.isValidPacket(X))return d.error(`Connection.serializePackets(): Invalid packet payload: ${JSON.stringify(X)}`);let J=o4._cachedPacketsSerializedBuffer.get(Z);if(J)return J;return N8.startSpan({operation:"serialize_packets",attributes:{packets:Z.length,packetIds:Z.map((X)=>X[0]).join(",")}},(X)=>{let Y=LK1.pack(Z);if(Y.byteLength>1500)Y=CJ6(Y,{level:1});return X?.setAttribute("serializedBytes",Y.byteLength),o4._cachedPacketsSerializedBuffer.set(Z,Y),Y})}bindWs(Z){let J=!!this._ws;if(J&&this._closeTimeout)clearTimeout(this._closeTimeout),this._closeTimeout=null;if(this._ws)this._ws.onmessage=()=>{},this._ws.onclose=()=>{},this._ws.onerror=()=>{},this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{k:!0})]);if(this._ws=Z,this._ws.binaryType="nodebuffer",this._ws.onmessage=(X)=>this._onMessage(X.data),this._ws.onclose=this._onWsClose,this._ws.onerror=this._onWsError,this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{i:this.id})],!0,!0),J)this.emitWithGlobal("CONNECTION.RECONNECTED",{connection:this});if(a7.instance.isWrtcEnabled)this._upgradeToWRTC()}closeWrtc(){this._closeWrtcClientServerTransport(),this._closeWrtcServerClientTransport()}disconnect(){try{this._ws.close()}catch(Z){d.error(`Connection.disconnect(): Connection disconnect failed. Error: ${Z}`)}}onPacket(Z,J){this.on("CONNECTION.PACKET_RECEIVED",({packet:X})=>{if(X[0]===Z)J(X)})}send(Z,J=!0,X=!1){if(this._closeTimeout)return;if(this._ws.readyState!==TJ6.OPEN)return;N8.startSpan({operation:"send_packets",attributes:{forceWs:X?"true":"false",wrtcConnected:this._wrtcServerClientTransport?.iceState==="completed"?"true":"false"}},()=>{try{let Y=o4.serializePackets(Z);if(!Y)return;if(this._wrtcServerClientTransport?.iceState==="completed"&&Y.length<(this._wrtcServerClientTransport?.sctpParameters?.maxMessageSize??0)&&!X)try{(J?this._wrtcServerClientReliableDataProducer:this._wrtcServerClientUnreliableDataProducer).send(Y)}catch{this._ws.send(Y)}else this._ws.send(Y);this.emitWithGlobal("CONNECTION.PACKETS_SENT",{connection:this,packets:Z})}catch(Y){d.error(`Connection.send(): Packet send failed. Error: ${Y}`)}})}_closeWrtcClientServerTransport(){this._wrtcDirectTransport?.close(),this._wrtcDirectTransport=null,this._wrtcClientServerTransport?.close(),this._wrtcClientServerTransport=null,this._wrtcClientServerDataProducers.forEach((Z)=>Z.close()),this._wrtcClientServerDataProducers=[],this._wrtcClientServerDataConsumers.forEach((Z)=>Z.close()),this._wrtcClientServerDataConsumers=[]}_closeWrtcServerClientTransport(){this._wrtcServerClientTransport?.close(),this._wrtcServerClientTransport=null,this._wrtcServerClientDataConsumers.forEach((Z)=>Z.close()),this._wrtcServerClientDataConsumers=[],this._wrtcServerClientReliableDataProducer?.close(),this._wrtcServerClientReliableDataProducer=null,this._wrtcServerClientUnreliableDataProducer?.close(),this._wrtcServerClientUnreliableDataProducer=null}_onConnectionPacket=async(Z)=>{let J=Z[1],X=J.c,Y=J.d;if(X){let{i:$,d:Q}=X,W=!1;if($==this._wrtcClientServerTransport?.id)await this._wrtcClientServerTransport.connect({dtlsParameters:Q}),W=!0;if($==this._wrtcServerClientTransport?.id)await this._wrtcServerClientTransport.connect({dtlsParameters:Q}),W=!0;if(W)this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{ca:{i:$}})])}if(Y)for(let $ of Y){let{s:Q,l:W}=$,K=await this._wrtcClientServerTransport.produceData({label:W,sctpStreamParameters:Q}),G=await this._wrtcDirectTransport.consumeData({dataProducerId:K.id});this._wrtcClientServerDataProducers.push(K),this._wrtcClientServerDataConsumers.push(G),G.on("message",(z)=>this._onMessage(z)),this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{pa:{i:K.id,l:W}})])}};_onHeartbeatPacket=()=>{this.send([Q0.createPacket(Q0.bidirectionalPackets.heartbeatPacketDefinition,null)],!0,!0)};_onMessage=(Z)=>{try{let J=this._deserialize(Z);if(!J)return;this.emitWithGlobal("CONNECTION.PACKET_RECEIVED",{connection:this,packet:J})}catch(J){d.error(`Connection._ws.onmessage(): Error: ${J}`)}};_onWrtcIceStateChange=(Z,J)=>{if(["disconnected","closed"].includes(J)){if(Z==this._wrtcClientServerTransport)this._closeWrtcClientServerTransport();else if(Z==this._wrtcServerClientTransport)this._closeWrtcServerClientTransport()}};_onWsClose=()=>{this.closeWrtc(),this.emitWithGlobal("CONNECTION.DISCONNECTED",{connection:this}),this._closeTimeout=setTimeout(()=>{this.emitWithGlobal("CONNECTION.CLOSED",{connection:this}),this.offAll()},kJ6)};_onWsError=(Z)=>{this.emitWithGlobal("CONNECTION.ERROR",{connection:this,error:Z})};_upgradeToWRTC=async()=>{let Z=await a7.instance.createWrtcTransports();if(!Z)return!1;let{directTransport:J,clientServerTransport:X,serverClientTransport:Y}=Z;this._wrtcDirectTransport=J,this._wrtcClientServerTransport=X,this._wrtcClientServerTransport.on("icestatechange",(W)=>{this._onWrtcIceStateChange(this._wrtcClientServerTransport,W)}),this._wrtcServerClientTransport=Y,this._wrtcServerClientTransport.on("icestatechange",(W)=>{this._onWrtcIceStateChange(this._wrtcServerClientTransport,W)}),this._wrtcServerClientReliableDataProducer=await this._wrtcServerClientTransport.produceData({label:"scr",sctpStreamParameters:{streamId:0,ordered:!0}}),this._wrtcServerClientUnreliableDataProducer=await this._wrtcServerClientTransport.produceData({label:"scu",sctpStreamParameters:{streamId:1,ordered:!1,maxPacketLifeTime:35}});let $=await this._wrtcServerClientTransport.consumeData({dataProducerId:this._wrtcServerClientReliableDataProducer.id}),Q=await this._wrtcServerClientTransport.consumeData({dataProducerId:this._wrtcServerClientUnreliableDataProducer.id});return this._wrtcServerClientDataConsumers.push($,Q),this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{d:[{i:$.id,pi:$.dataProducerId,l:"scr",s:$.sctpStreamParameters},{i:Q.id,pi:Q.dataProducerId,l:"scu",s:Q.sctpStreamParameters}],t:[{i:this._wrtcClientServerTransport.id,f:"cs",d:this._wrtcClientServerTransport.dtlsParameters,ic:this._wrtcClientServerTransport.iceCandidates,ip:this._wrtcClientServerTransport.iceParameters,s:this._wrtcClientServerTransport.sctpParameters},{i:this._wrtcServerClientTransport.id,f:"sc",d:this._wrtcServerClientTransport.dtlsParameters,ic:this._wrtcServerClientTransport.iceCandidates,ip:this._wrtcServerClientTransport.iceParameters,s:this._wrtcServerClientTransport.sctpParameters}]})]),!0};_deserialize(Z){let J=LK1.unpack(Z);if(!J||typeof J!=="object"||typeof J[0]!=="number")return d.error(`Connection._deserialize(): Invalid packet format. Packet: ${JSON.stringify(J)}`);if(!Q0.isValidPacket(J))return d.error(`Connection._deserialize(): Invalid packet payload. Packet: ${JSON.stringify(J)}`);return J}}class nF{_lights=new Map;_nextLightId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}despawnEntityAttachedLights(Z){this.getAllEntityAttachedLights(Z).forEach((J)=>{J.despawn()})}getAllLights(){return Array.from(this._lights.values())}getAllEntityAttachedLights(Z){return this.getAllLights().filter((J)=>J.attachedToEntity===Z)}registerLight(Z){if(Z.id!==void 0)return Z.id;let J=this._nextLightId;return this._lights.set(J,Z),this._nextLightId++,J}unregisterLight(Z){if(Z.id===void 0)return;this._lights.delete(Z.id)}}class B6{_map=new Map;_values=[];_isDirty=!1;get size(){return this._map.size}get valuesArray(){if(this._isDirty)this._syncArray();return this._values}get(Z){return this._map.get(Z)}set(Z,J){let X=this._map.has(Z);if(this._map.set(Z,J),!X)this._values.push(J);else this._isDirty=!0;return this}has(Z){return this._map.has(Z)}delete(Z){let J=this._map.delete(Z);if(J)this._isDirty=!0;return J}clear(){this._map.clear(),this._values.length=0,this._isDirty=!1}forEach(Z,J){this._map.forEach((X,Y)=>{Z.call(J,X,Y,this)})}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}[Symbol.iterator](){return this._map[Symbol.iterator]()}_syncArray(){this._values.length=0;for(let Z of this._map.values())this._values.push(Z);this._isDirty=!1}}var jK1;((X)=>{X[X.POINTLIGHT=0]="POINTLIGHT";X[X.SPOTLIGHT=1]="SPOTLIGHT"})(jK1||={});var gg;((q)=>{q.DESPAWN="LIGHT.DESPAWN";q.SET_ANGLE="LIGHT.SET_ANGLE";q.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";q.SET_COLOR="LIGHT.SET_COLOR";q.SET_DISTANCE="LIGHT.SET_DISTANCE";q.SET_INTENSITY="LIGHT.SET_INTENSITY";q.SET_OFFSET="LIGHT.SET_OFFSET";q.SET_PENUMBRA="LIGHT.SET_PENUMBRA";q.SET_POSITION="LIGHT.SET_POSITION";q.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";q.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";q.SPAWN="LIGHT.SPAWN"})(gg||={});class mg extends j0{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)d.fatalError("Either attachedToEntity or position must be set, but not both.");super();d.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=Z.angle,this._attachedToEntity=Z.attachedToEntity,this._color=Z.color??{r:255,g:255,b:255},this._distance=Z.distance,this._intensity=Z.intensity??1,this._offset=Z.offset,this._penumbra=Z.penumbra,this._position=Z.position,this._trackedEntity=Z.trackedEntity,this._trackedPosition=Z.trackedPosition,this._type=Z.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(Z){if(this._angle===Z)return;if(this._angle=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ANGLE",{light:this,angle:Z})}setAttachedToEntity(Z){if(!Z.isSpawned)return d.error(`Light.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ATTACHED_TO_ENTITY",{light:this,entity:Z})}setColor(Z){if(this._color.r===Z.r&&this._color.g===Z.g&&this._color.b===Z.b)return;if(this._color=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_COLOR",{light:this,color:Z})}setDistance(Z){if(this._distance===Z)return;if(this._distance=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_DISTANCE",{light:this,distance:Z})}setIntensity(Z){if(this._intensity===Z)return;if(this._intensity=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_INTENSITY",{light:this,intensity:Z})}setOffset(Z){if(this._offset&&this._offset.x===Z.x&&this._offset.y===Z.y&&this._offset.z===Z.z)return;if(this._offset=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_OFFSET",{light:this,offset:Z})}setPenumbra(Z){if(this._penumbra===Z)return;if(this._penumbra=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_PENUMBRA",{light:this,penumbra:Z})}setPosition(Z){if(this._position&&this._position.x===Z.x&&this._position.y===Z.y&&this._position.z===Z.z)return;if(this._position=Z,this._attachedToEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_POSITION",{light:this,position:Z})}setTrackedEntity(Z){if(!Z.isSpawned)return d.error(`Light.setTrackedEntity(): Entity ${Z.id} is not spawned!`);if(this._trackedEntity===Z)return;if(this._trackedEntity=Z,this._trackedPosition=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_ENTITY",{light:this,entity:Z})}setTrackedPosition(Z){if(this._trackedPosition===Z)return;if(this._trackedPosition=Z,this._trackedEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_POSITION",{light:this,position:Z})}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(Z){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return d.error(`Light.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning Light!`);this._id=Z.lightManager.registerLight(this),this._world=Z,this.emitWithWorld(Z,"LIGHT.SPAWN",{light:this})}serialize(){return k0.serializeLight(this)}}var ug;((m)=>{m.BURST="PARTICLE_EMITTER.BURST";m.DESPAWN="PARTICLE_EMITTER.DESPAWN";m.SET_ALPHA_TEST="PARTICLE_EMITTER.SET_ALPHA_TEST";m.SET_ATTACHED_TO_ENTITY="PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY";m.SET_ATTACHED_TO_ENTITY_NODE_NAME="PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY_NODE_NAME";m.SET_COLOR_END="PARTICLE_EMITTER.SET_COLOR_END";m.SET_COLOR_END_VARIANCE="PARTICLE_EMITTER.SET_COLOR_END_VARIANCE";m.SET_COLOR_START="PARTICLE_EMITTER.SET_COLOR_START";m.SET_COLOR_START_VARIANCE="PARTICLE_EMITTER.SET_COLOR_START_VARIANCE";m.SET_GRAVITY="PARTICLE_EMITTER.SET_GRAVITY";m.SET_LIFETIME="PARTICLE_EMITTER.SET_LIFETIME";m.SET_LIFETIME_VARIANCE="PARTICLE_EMITTER.SET_LIFETIME_VARIANCE";m.SET_MAX_PARTICLES="PARTICLE_EMITTER.SET_MAX_PARTICLES";m.SET_OFFSET="PARTICLE_EMITTER.SET_OFFSET";m.SET_OPACITY_END="PARTICLE_EMITTER.SET_OPACITY_END";m.SET_OPACITY_END_VARIANCE="PARTICLE_EMITTER.SET_OPACITY_END_VARIANCE";m.SET_OPACITY_START="PARTICLE_EMITTER.SET_OPACITY_START";m.SET_OPACITY_START_VARIANCE="PARTICLE_EMITTER.SET_OPACITY_START_VARIANCE";m.SET_PAUSED="PARTICLE_EMITTER.SET_PAUSED";m.SET_POSITION="PARTICLE_EMITTER.SET_POSITION";m.SET_POSITION_VARIANCE="PARTICLE_EMITTER.SET_POSITION_VARIANCE";m.SET_RATE="PARTICLE_EMITTER.SET_RATE";m.SET_RATE_VARIANCE="PARTICLE_EMITTER.SET_RATE_VARIANCE";m.SET_SIZE_END="PARTICLE_EMITTER.SET_SIZE_END";m.SET_SIZE_END_VARIANCE="PARTICLE_EMITTER.SET_SIZE_END_VARIANCE";m.SET_SIZE_START="PARTICLE_EMITTER.SET_SIZE_START";m.SET_SIZE_START_VARIANCE="PARTICLE_EMITTER.SET_SIZE_START_VARIANCE";m.SET_TEXTURE_URI="PARTICLE_EMITTER.SET_TEXTURE_URI";m.SET_TRANSPARENT="PARTICLE_EMITTER.SET_TRANSPARENT";m.SET_VELOCITY="PARTICLE_EMITTER.SET_VELOCITY";m.SET_VELOCITY_VARIANCE="PARTICLE_EMITTER.SET_VELOCITY_VARIANCE";m.SPAWN="PARTICLE_EMITTER.SPAWN"})(ug||={});class dg extends j0{_id;_alphaTest;_attachedToEntity;_attachedToEntityNodeName;_colorEnd;_colorEndVariance;_colorStart;_colorStartVariance;_gravity;_lifetime;_lifetimeVariance;_maxParticles;_offset;_opacityEnd;_opacityEndVariance;_opacityStart;_opacityStartVariance;_paused;_position;_positionVariance;_rate;_rateVariance;_sizeEnd;_sizeEndVariance;_sizeStart;_sizeStartVariance;_sizeVariance;_textureUri;_transparent;_velocity;_velocityVariance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)d.fatalError("Either attachedToEntity or position must be set, but not both.");if(!Z.textureUri)d.fatalError("ParticleEmitter.constructor(): textureUri must be provided.");super();this._alphaTest=Z.alphaTest??0.5,this._attachedToEntity=Z.attachedToEntity,this._attachedToEntityNodeName=Z.attachedToEntityNodeName,this._colorEnd=Z.colorEnd,this._colorEndVariance=Z.colorEndVariance,this._colorStart=Z.colorStart,this._colorStartVariance=Z.colorStartVariance,this._gravity=Z.gravity,this._lifetime=Z.lifetime,this._lifetimeVariance=Z.lifetimeVariance,this._maxParticles=Z.maxParticles,this._offset=Z.offset,this._opacityEnd=Z.opacityEnd,this._opacityEndVariance=Z.opacityEndVariance,this._opacityStart=Z.opacityStart,this._opacityStartVariance=Z.opacityStartVariance,this._paused=!1,this._position=Z.position,this._positionVariance=Z.positionVariance,this._rate=Z.rate,this._rateVariance=Z.rateVariance,this._sizeEnd=Z.sizeEnd,this._sizeEndVariance=Z.sizeEndVariance,this._sizeStart=Z.sizeStart,this._sizeStartVariance=Z.sizeStartVariance,this._textureUri=Z.textureUri,this._transparent=Z.transparent,this._velocity=Z.velocity,this._velocityVariance=Z.velocityVariance}get id(){return this._id}get alphaTest(){return this._alphaTest}get attachedToEntity(){return this._attachedToEntity}get attachedToEntityNodeName(){return this._attachedToEntityNodeName}get colorEnd(){return this._colorEnd}get colorEndVariance(){return this._colorEndVariance}get colorStart(){return this._colorStart}get colorStartVariance(){return this._colorStartVariance}get gravity(){return this._gravity}get isSpawned(){return this._id!==void 0}get lifetime(){return this._lifetime}get lifetimeVariance(){return this._lifetimeVariance}get maxParticles(){return this._maxParticles}get offset(){return this._offset}get opacityEnd(){return this._opacityEnd}get opacityEndVariance(){return this._opacityEndVariance}get opacityStart(){return this._opacityStart}get opacityStartVariance(){return this._opacityStartVariance}get paused(){return this._paused}get position(){return this._position}get positionVariance(){return this._positionVariance}get rate(){return this._rate}get rateVariance(){return this._rateVariance}get sizeEnd(){return this._sizeEnd}get sizeEndVariance(){return this._sizeEndVariance}get sizeStart(){return this._sizeStart}get sizeStartVariance(){return this._sizeStartVariance}get sizeVariance(){return this._sizeVariance}get textureUri(){return this._textureUri}get transparent(){return this._transparent}get velocity(){return this._velocity}get velocityVariance(){return this._velocityVariance}get world(){return this._world}setAlphaTest(Z){if(this._alphaTest===Z)return;if(this._alphaTest=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_ALPHA_TEST",{particleEmitter:this,alphaTest:Z})}setAttachedToEntity(Z){if(!Z.isSpawned)return d.error(`ParticleEmitter.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY",{particleEmitter:this,entity:Z})}setAttachedToEntityNodeName(Z){if(this._attachedToEntityNodeName===Z)return;if(this._attachedToEntityNodeName=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY_NODE_NAME",{particleEmitter:this,attachedToEntityNodeName:Z})}setColorEnd(Z){if(this._colorEnd&&this._colorEnd.r===Z.r&&this._colorEnd.g===Z.g&&this._colorEnd.b===Z.b)return;if(this._colorEnd=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_END",{particleEmitter:this,colorEnd:Z})}setColorEndVariance(Z){if(this._colorEndVariance&&this._colorEndVariance.r===Z.r&&this._colorEndVariance.g===Z.g&&this._colorEndVariance.b===Z.b)return;if(this._colorEndVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_END_VARIANCE",{particleEmitter:this,colorEndVariance:Z})}setColorStart(Z){if(this._colorStart&&this._colorStart.r===Z.r&&this._colorStart.g===Z.g&&this._colorStart.b===Z.b)return;if(this._colorStart=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_START",{particleEmitter:this,colorStart:Z})}setColorStartVariance(Z){if(this._colorStartVariance&&this._colorStartVariance.r===Z.r&&this._colorStartVariance.g===Z.g&&this._colorStartVariance.b===Z.b)return;if(this._colorStartVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_START_VARIANCE",{particleEmitter:this,colorStartVariance:Z})}setGravity(Z){if(this._gravity&&this._gravity.x===Z.x&&this._gravity.y===Z.y&&this._gravity.z===Z.z)return;if(this._gravity=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_GRAVITY",{particleEmitter:this,gravity:Z})}setLifetime(Z){if(this._lifetime===Z)return;if(this._lifetime=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_LIFETIME",{particleEmitter:this,lifetime:Z})}setLifetimeVariance(Z){if(this._lifetimeVariance===Z)return;if(this._lifetimeVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_LIFETIME_VARIANCE",{particleEmitter:this,lifetimeVariance:Z})}setMaxParticles(Z){if(this._maxParticles===Z)return;if(this._maxParticles=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_MAX_PARTICLES",{particleEmitter:this,maxParticles:Z})}setOffset(Z){if(this._offset&&this._offset.x===Z.x&&this._offset.y===Z.y&&this._offset.z===Z.z)return;if(this._offset=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OFFSET",{particleEmitter:this,offset:Z})}setOpacityEnd(Z){if(this._opacityEnd===Z)return;if(this._opacityEnd=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_END",{particleEmitter:this,opacityEnd:Z})}setOpacityEndVariance(Z){if(this._opacityEndVariance===Z)return;if(this._opacityEndVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_END_VARIANCE",{particleEmitter:this,opacityEndVariance:Z})}setOpacityStart(Z){if(this._opacityStart===Z)return;if(this._opacityStart=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_START",{particleEmitter:this,opacityStart:Z})}setOpacityStartVariance(Z){if(this._opacityStartVariance===Z)return;if(this._opacityStartVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_START_VARIANCE",{particleEmitter:this,opacityStartVariance:Z})}setPosition(Z){if(this._position&&this._position.x===Z.x&&this._position.y===Z.y&&this._position.z===Z.z)return;if(this._position=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_POSITION",{particleEmitter:this,position:Z})}setPositionVariance(Z){if(this._positionVariance&&this._positionVariance.x===Z.x&&this._positionVariance.y===Z.y&&this._positionVariance.z===Z.z)return;if(this._positionVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_POSITION_VARIANCE",{particleEmitter:this,positionVariance:Z})}setRate(Z){if(this._rate===Z)return;if(this._rate=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_RATE",{particleEmitter:this,rate:Z})}setRateVariance(Z){if(this._rateVariance===Z)return;if(this._rateVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_RATE_VARIANCE",{particleEmitter:this,rateVariance:Z})}setSizeEnd(Z){if(this._sizeEnd===Z)return;if(this._sizeEnd=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_END",{particleEmitter:this,sizeEnd:Z})}setSizeEndVariance(Z){if(this._sizeEndVariance===Z)return;if(this._sizeEndVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_END_VARIANCE",{particleEmitter:this,sizeEndVariance:Z})}setSizeStart(Z){if(this._sizeStart===Z)return;if(this._sizeStart=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_START",{particleEmitter:this,sizeStart:Z})}setSizeStartVariance(Z){if(this._sizeStartVariance===Z)return;if(this._sizeStartVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_START_VARIANCE",{particleEmitter:this,sizeStartVariance:Z})}setTextureUri(Z){if(this._textureUri===Z)return;if(this._textureUri=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_TEXTURE_URI",{particleEmitter:this,textureUri:Z})}setTransparent(Z){if(this._transparent===Z)return;if(this._transparent=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_TRANSPARENT",{particleEmitter:this,transparent:Z})}setVelocity(Z){if(this._velocity&&this._velocity.x===Z.x&&this._velocity.y===Z.y&&this._velocity.z===Z.z)return;if(this._velocity=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_VELOCITY",{particleEmitter:this,velocity:Z})}setVelocityVariance(Z){if(this._velocityVariance&&this._velocityVariance.x===Z.x&&this._velocityVariance.y===Z.y&&this._velocityVariance.z===Z.z)return;if(this._velocityVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_VELOCITY_VARIANCE",{particleEmitter:this,velocityVariance:Z})}burst(Z){if(this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.BURST",{particleEmitter:this,count:Z})}despawn(){if(!this.isSpawned||!this._world)return;this._world.particleEmitterManager.unregisterParticleEmitter(this),this.emitWithWorld(this._world,"PARTICLE_EMITTER.DESPAWN",{particleEmitter:this}),this._id=void 0,this._world=void 0}restart(){if(!this._paused)return;if(this._paused=!1,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_PAUSED",{particleEmitter:this,paused:this._paused})}stop(){if(this._paused)return;if(this._paused=!0,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_PAUSED",{particleEmitter:this,paused:this._paused})}spawn(Z){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return d.error(`ParticleEmitter.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning ParticleEmitter!`);this._id=Z.particleEmitterManager.registerParticleEmitter(this),this._world=Z,this.emitWithWorld(Z,"PARTICLE_EMITTER.SPAWN",{particleEmitter:this})}serialize(){return k0.serializeParticleEmitter(this)}}var EJ6={x:0,y:-32,z:0},cg=60,lg;(($)=>{$.STEP_START="SIMULATION.STEP_START";$.STEP_END="SIMULATION.STEP_END";$.DEBUG_RAYCAST="SIMULATION.DEBUG_RAYCAST";$.DEBUG_RENDER="SIMULATION.DEBUG_RENDER"})(lg||={});class aF extends j0{_colliderMap=new FH;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_debugRenderingFilterFlags;_rapierEventQueue;_rapierSimulation;_world;constructor(Z,J=cg,X=EJ6){super();this._rapierEventQueue=new Q1.EventQueue(!0),this._rapierSimulation=new Q1.World(X),this._rapierSimulation.timestep=Math.fround(1/J),this._world=Z}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}createRawCollider(Z,J){return this._rapierSimulation.createCollider(Z,J)}createRawRigidBody(Z){return this._rapierSimulation.createRigidBody(Z)}enableDebugRaycasting(Z){this._debugRaycastingEnabled=Z}enableDebugRendering(Z,J=Q1.QueryFilterFlags.EXCLUDE_FIXED){this._debugRenderingEnabled=Z,this._debugRenderingFilterFlags=J}getContactManifolds(Z,J){let X=[];return this._rapierSimulation.narrowPhase.contactPair(Z,J,(Y,$)=>{if(Y.numContacts()===0)return;let Q=Y.normal(),W=[];for(let K=0;K<Y.numSolverContacts();K++)W.push(Y.solverContactPoint(K));X.push({contactPoints:W,localNormalA:!$?Y.localNormal1():Y.localNormal2(),localNormalB:!$?Y.localNormal2():Y.localNormal1(),normal:!$?Q:{x:-Q.x,y:-Q.y,z:-Q.z}})}),X}intersectionsWithRawShape(Z,J,X,Y={}){let $=new Set,Q=[];return this._rapierSimulation.intersectionsWithShape(J,X,Z,(W)=>{let K=this._colliderMap.getColliderHandleBlockType(W.handle);if(K&&!$.has(K))return $.add(K),Q.push({intersectedBlockType:K}),!0;let G=this._colliderMap.getColliderHandleEntity(W.handle);if(G&&!$.has(G))return $.add(G),Q.push({intersectedEntity:G}),!0;return!0},Y.filterFlags,Y.filterGroups,Y.filterExcludeCollider,Y.filterExcludeRigidBody,Y.filterPredicate),Q}raycast(Z,J,X,Y={}){let $=new Q1.Ray(Z,J),Q=this._rapierSimulation.castRay($,X,Y.solidMode??!0,Y.filterFlags,Y.filterGroups,Y.filterExcludeCollider,Y.filterExcludeRigidBody,Y.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:Z,direction:J,length:X,hit:!!Q});if(!Q)return null;let W=$.pointAt(Q.timeOfImpact),K=Q.timeOfImpact,G=Q.collider,z=this._colliderMap.getColliderHandleBlockType(G.handle);if(z)return{hitBlock:JW.fromGlobalCoordinate({x:Math.floor(W.x-($.dir.x<0?0.0001:-0.0001)),y:Math.floor(W.y-($.dir.y<0?0.0001:-0.0001)),z:Math.floor(W.z-($.dir.z<0?0.0001:-0.0001))},z),hitPoint:W,hitDistance:K};let H=this._colliderMap.getColliderHandleEntity(G.handle);if(H)return{hitEntity:H,hitPoint:W,hitDistance:K};return null}removeRawCollider(Z){this._colliderMap.queueColliderHandleForCleanup(Z.handle),this._rapierSimulation.removeCollider(Z,!1)}removeRawRigidBody(Z){this._rapierSimulation.removeRigidBody(Z)}setGravity(Z){this._rapierSimulation.gravity=Z}step=(Z)=>{this.emitWithWorld(this._world,"SIMULATION.STEP_START",{simulation:this,tickDeltaMs:Z});let J=performance.now();if(N8.startSpan({operation:"physics_step"},()=>{this._rapierSimulation.step(this._rapierEventQueue)}),N8.startSpan({operation:"physics_cleanup"},()=>{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()-J}),this._debugRenderingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RENDER",{simulation:this,...this._rapierSimulation.debugRender(this._debugRenderingFilterFlags)})};_onCollisionEvent=(Z,J,X)=>{let[Y,$]=this._getCollisionObjects(Z,J);if(!Y||!$)return;let Q=(W,K)=>{if(W instanceof q9&&K instanceof o8&&W.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))W.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:W,entity:K,started:X,colliderHandleA:Z,colliderHandleB:J});else if(W instanceof o8&&K instanceof q9&&W.hasListeners("ENTITY.BLOCK_COLLISION"))W.emit("ENTITY.BLOCK_COLLISION",{entity:W,blockType:K,started:X,colliderHandleA:Z,colliderHandleB:J});else if(W instanceof o8&&K instanceof o8&&W.hasListeners("ENTITY.ENTITY_COLLISION"))W.emit("ENTITY.ENTITY_COLLISION",{entity:W,otherEntity:K,started:X,colliderHandleA:Z,colliderHandleB:J});else if(typeof W==="function"&&(K instanceof o8||K instanceof q9))W(K,X,Z,J)};Q(Y,$),Q($,Y)};_onContactForceEvent=(Z)=>{let[J,X]=this._getCollisionObjects(Z.collider1(),Z.collider2());if(!J||typeof J==="function"||!X||typeof X==="function")return;let Y={totalForce:Z.totalForce(),totalForceMagnitude:Z.totalForceMagnitude(),maxForceDirection:Z.maxForceDirection(),maxForceMagnitude:Z.maxForceMagnitude()},$=(Q,W)=>{if(Q instanceof q9&&W instanceof o8&&Q.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))Q.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:Q,entity:W,contactForceData:Y});else if(Q instanceof o8&&W instanceof q9&&Q.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))Q.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:Q,blockType:W,contactForceData:Y});else if(Q instanceof o8&&W instanceof o8&&Q.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))Q.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:Q,otherEntity:W,contactForceData:Y})};$(J,X),$(X,J)};_getCollisionObjects(Z,J){let X=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z),Y=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J);return[X,Y]}}class PN{_synchronizedPlayerReliablePackets=new B6;_queuedBroadcasts=[];_queuedAudioSynchronizations=new B6;_queuedBlockSynchronizations=new B6;_queuedBlockTypeSynchronizations=new B6;_queuedChunkSynchronizations=new B6;_queuedDebugRaycastSynchronizations=[];_queuedEntitySynchronizations=new B6;_queuedLightSynchronizations=new B6;_queuedParticleEmitterSynchronizations=new B6;_queuedPerPlayerSynchronizations=new B6;_queuedPerPlayerCameraSynchronizations=new B6;_queuedPerPlayerUISynchronizations=new B6;_queuedPerPlayerUIDatasSynchronizations=new B6;_queuedPlayerSynchronizations=new B6;_queuedSceneUISynchronizations=new B6;_queuedWorldSynchronization;_loadedSceneUIs=new Set;_spawnedChunks=new Set;_spawnedEntities=new Set;_world;constructor(Z){this._world=Z,this._subscribeToAudioEvents(),this._subscribeToBlockTypeRegistryEvents(),this._subscribeToChatEvents(),this._subscribeToChunkLatticeEvents(),this._subscribeToEntityEvents(),this._subscribeToLightEvents(),this._subscribeToParticleEmitterEvents(),this._subscribeToPlayerEvents(),this._subscribeToPlayerCameraEvents(),this._subscribeToPlayerUIEvents(),this._subscribeToSceneUIEvents(),this._subscribeToSimulationEvents(),this._subscribeToWorldEvents()}synchronize(){let Z=[],J=[],X=this._world.loop.currentTick;if(this._queuedPerPlayerSynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerSynchronizations)this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(...$);if(this._queuedEntitySynchronizations.size>0){let Y=[],$=[];for(let Q of this._queuedEntitySynchronizations.valuesArray){let W=!1;for(let K in Q)if(K!=="i"&&K!=="p"&&K!=="r"){W=!0;break}if(W)Y.push(Q);else $.push(Q)}if($.length>0){let Q=Q0.createPacket(Q0.outboundPackets.entitiesPacketDefinition,$,X);J.push(Q)}if(Y.length>0){let Q=Q0.createPacket(Q0.outboundPackets.entitiesPacketDefinition,Y,X);Z.push(Q);for(let W of this._synchronizedPlayerReliablePackets.valuesArray)W.push(Q)}}if(this._queuedAudioSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.audiosPacketDefinition,this._queuedAudioSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedBlockTypeSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.blockTypesPacketDefinition,this._queuedBlockTypeSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedChunkSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.chunksPacketDefinition,this._queuedChunkSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedBlockSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.blocksPacketDefinition,this._queuedBlockSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedLightSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.lightsPacketDefinition,this._queuedLightSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedParticleEmitterSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.particleEmittersPacketDefinition,this._queuedParticleEmitterSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedPerPlayerUISynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerUISynchronizations){let Q=Q0.createPacket(Q0.outboundPackets.uiPacketDefinition,$,X);this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(Q)}if(this._queuedPerPlayerUIDatasSynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerUIDatasSynchronizations){let Q=Q0.createPacket(Q0.outboundPackets.uiDatasPacketDefinition,$,X);this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(Q)}if(this._queuedSceneUISynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.sceneUIsPacketDefinition,this._queuedSceneUISynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedWorldSynchronization){let Y=Q0.createPacket(Q0.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedPerPlayerCameraSynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerCameraSynchronizations){let Q=Q0.createPacket(Q0.outboundPackets.cameraPacketDefinition,$,X);this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(Q)}if(this._queuedPlayerSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.playersPacketDefinition,this._queuedPlayerSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedBroadcasts.length>0)for(let Y of this._queuedBroadcasts){Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedDebugRaycastSynchronizations.length>0){let Y=Q0.createPacket(Q0.outboundPackets.physicsDebugRaycastsPacketDefinition,this._queuedDebugRaycastSynchronizations,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}N8.startSpan({operation:"send_all_packets"},()=>{for(let Y of j9.instance.getConnectedPlayersByWorld(this._world)){let $=this._synchronizedPlayerReliablePackets.get(Y)??Z;if($.length>0)Y.connection.send($);if(J.length>0)Y.connection.send(J,!1)}}),N8.startSpan({operation:"network_synchronize_cleanup"},()=>{if(this._queuedBroadcasts.length>0)this._queuedBroadcasts.length=0;if(this._queuedAudioSynchronizations.size>0)this._queuedAudioSynchronizations.clear();if(this._queuedBlockSynchronizations.size>0)this._queuedBlockSynchronizations.clear();if(this._queuedBlockTypeSynchronizations.size>0)this._queuedBlockTypeSynchronizations.clear();if(this._queuedChunkSynchronizations.size>0)this._queuedChunkSynchronizations.clear();if(this._queuedDebugRaycastSynchronizations.length>0)this._queuedDebugRaycastSynchronizations.length=0;if(this._queuedEntitySynchronizations.size>0)this._queuedEntitySynchronizations.clear();if(this._queuedLightSynchronizations.size>0)this._queuedLightSynchronizations.clear();if(this._queuedParticleEmitterSynchronizations.size>0)this._queuedParticleEmitterSynchronizations.clear();if(this._queuedPerPlayerSynchronizations.size>0)this._queuedPerPlayerSynchronizations.clear();if(this._queuedPerPlayerCameraSynchronizations.size>0)this._queuedPerPlayerCameraSynchronizations.clear();if(this._queuedPerPlayerUISynchronizations.size>0)this._queuedPerPlayerUISynchronizations.clear();if(this._queuedPerPlayerUIDatasSynchronizations.size>0)this._queuedPerPlayerUIDatasSynchronizations.clear();if(this._queuedPlayerSynchronizations.size>0)this._queuedPlayerSynchronizations.clear();if(this._queuedSceneUISynchronizations.size>0)this._queuedSceneUISynchronizations.clear();if(this._queuedWorldSynchronization)this._queuedWorldSynchronization=void 0;if(this._loadedSceneUIs.size>0)this._loadedSceneUIs.clear();if(this._spawnedChunks.size>0)this._spawnedChunks.clear();if(this._spawnedEntities.size>0)this._spawnedEntities.clear();if(this._synchronizedPlayerReliablePackets.size>0)this._synchronizedPlayerReliablePackets.clear();o4.clearCachedPacketsSerializedBuffers()})}_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_CUTOFF_DISTANCE",this._onAudioSetCutoffDistance),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)}_subscribeToChunkLatticeEvents(){this._world.final("CHUNK_LATTICE.ADD_CHUNK",this._onChunkLatticeAddChunk),this._world.final("CHUNK_LATTICE.REMOVE_CHUNK",this._onChunkLatticeRemoveChunk),this._world.final("CHUNK_LATTICE.SET_BLOCK",this._onChunkLatticeSetBlock)}_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_MODEL_SCALE",this._onEntitySetModelScale),this._world.final("ENTITY.SET_MODEL_SHOWN_NODES",this._onEntitySetModelShownNodes),this._world.final("ENTITY.SET_MODEL_TEXTURE_URI",this._onEntitySetModelTextureUri),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)}_subscribeToParticleEmitterEvents(){this._world.final("PARTICLE_EMITTER.DESPAWN",this._onParticleEmitterDespawn),this._world.final("PARTICLE_EMITTER.BURST",this._onParticleEmitterBurst),this._world.final("PARTICLE_EMITTER.SET_ALPHA_TEST",this._onParticleEmitterSetAlphaTest),this._world.final("PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY",this._onParticleEmitterSetAttachedToEntity),this._world.final("PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY_NODE_NAME",this._onParticleEmitterSetAttachedToEntityNodeName),this._world.final("PARTICLE_EMITTER.SET_COLOR_END",this._onParticleEmitterSetColorEnd),this._world.final("PARTICLE_EMITTER.SET_COLOR_END_VARIANCE",this._onParticleEmitterSetColorEndVariance),this._world.final("PARTICLE_EMITTER.SET_COLOR_START",this._onParticleEmitterSetColorStart),this._world.final("PARTICLE_EMITTER.SET_COLOR_START_VARIANCE",this._onParticleEmitterSetColorStartVariance),this._world.final("PARTICLE_EMITTER.SET_GRAVITY",this._onParticleEmitterSetGravity),this._world.final("PARTICLE_EMITTER.SET_LIFETIME",this._onParticleEmitterSetLifetime),this._world.final("PARTICLE_EMITTER.SET_LIFETIME_VARIANCE",this._onParticleEmitterSetLifetimeVariance),this._world.final("PARTICLE_EMITTER.SET_MAX_PARTICLES",this._onParticleEmitterSetMaxParticles),this._world.final("PARTICLE_EMITTER.SET_OFFSET",this._onParticleEmitterSetOffset),this._world.final("PARTICLE_EMITTER.SET_OPACITY_END",this._onParticleEmitterSetOpacityEnd),this._world.final("PARTICLE_EMITTER.SET_OPACITY_END_VARIANCE",this._onParticleEmitterSetOpacityEndVariance),this._world.final("PARTICLE_EMITTER.SET_OPACITY_START",this._onParticleEmitterSetOpacityStart),this._world.final("PARTICLE_EMITTER.SET_OPACITY_START_VARIANCE",this._onParticleEmitterSetOpacityStartVariance),this._world.final("PARTICLE_EMITTER.SET_PAUSED",this._onParticleEmitterSetPaused),this._world.final("PARTICLE_EMITTER.SET_POSITION",this._onParticleEmitterSetPosition),this._world.final("PARTICLE_EMITTER.SET_POSITION_VARIANCE",this._onParticleEmitterSetPositionVariance),this._world.final("PARTICLE_EMITTER.SET_RATE",this._onParticleEmitterSetRate),this._world.final("PARTICLE_EMITTER.SET_RATE_VARIANCE",this._onParticleEmitterSetRateVariance),this._world.final("PARTICLE_EMITTER.SET_SIZE_END",this._onParticleEmitterSetSizeEnd),this._world.final("PARTICLE_EMITTER.SET_SIZE_END_VARIANCE",this._onParticleEmitterSetSizeEndVariance),this._world.final("PARTICLE_EMITTER.SET_SIZE_START",this._onParticleEmitterSetSizeStart),this._world.final("PARTICLE_EMITTER.SET_SIZE_START_VARIANCE",this._onParticleEmitterSetSizeStartVariance),this._world.final("PARTICLE_EMITTER.SET_TEXTURE_URI",this._onParticleEmitterSetTextureUri),this._world.final("PARTICLE_EMITTER.SET_TRANSPARENT",this._onParticleEmitterSetTransparent),this._world.final("PARTICLE_EMITTER.SET_VELOCITY",this._onParticleEmitterSetVelocity),this._world.final("PARTICLE_EMITTER.SET_VELOCITY_VARIANCE",this._onParticleEmitterSetVelocityVariance),this._world.final("PARTICLE_EMITTER.SPAWN",this._onParticleEmitterSpawn)}_subscribeToPlayerEvents(){this._world.final("PLAYER.JOINED_WORLD",this._onPlayerJoinedWorld),this._world.final("PLAYER.LEFT_WORLD",this._onPlayerLeftWorld),this._world.final("PLAYER.RECONNECTED_WORLD",this._onPlayerReconnectedWorld),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_MODEL_SHOWN_NODES",this._onPlayerCameraSetModelShownNodes),this._world.final("PLAYER_CAMERA.SET_MODE",this._onPlayerCameraSetMode),this._world.final("PLAYER_CAMERA.SET_OFFSET",this._onPlayerCameraSetOffset),this._world.final("PLAYER_CAMERA.SET_SHOULDER_ANGLE",this._onPlayerCameraSetShoulderAngle),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),this._world.final("WORLD.SET_FOG_COLOR",this._onWorldSetFogColor),this._world.final("WORLD.SET_FOG_FAR",this._onWorldSetFogFar),this._world.final("WORLD.SET_FOG_NEAR",this._onWorldSetFogNear),this._world.final("WORLD.SET_SKYBOX_INTENSITY",this._onWorldSetSkyboxIntensity)}_onAudioPause=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.pa=!0,delete J.pl,delete J.r};_onAudioPlay=(Z)=>{let J=Z.audio.serialize();J.pl=!0,delete J.pa,delete J.r,this._queuedAudioSynchronizations.set(J.i,J)};_onAudioPlayRestart=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.r=!0,delete J.pa,delete J.pl,this._queuedAudioSynchronizations.set(J.i,J)};_onAudioSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onAudioSetCutoffDistance=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.cd=Z.cutoffDistance};_onAudioSetDetune=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.de=Z.detune};_onAudioSetDistortion=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.di=Z.distortion};_onAudioSetPosition=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.e=Z.position?void 0:J.e,J.p=Z.position?k0.serializeVector(Z.position):void 0};_onAudioSetPlaybackRate=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.pr=Z.playbackRate};_onAudioSetReferenceDistance=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.rd=Z.referenceDistance};_onAudioSetVolume=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.v=Z.volume};_onBlockTypeRegistryRegisterBlockType=(Z)=>{let J=Z.blockType.serialize();this._queuedBlockTypeSynchronizations.set(Z.blockType.id,J)};_onChatSendBroadcastMessage=(Z)=>{let{player:J,message:X,color:Y}=Z;this._queuedBroadcasts.push(Q0.createPacket(Q0.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y,p:J?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(Z)=>{let{player:J,message:X,color:Y}=Z,$=this._queuedPerPlayerSynchronizations.get(J)??[];$.push(Q0.createPacket(Q0.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y}],this._world.loop.currentTick)),this._queuedPerPlayerSynchronizations.set(J,$)};_onChunkLatticeAddChunk=(Z)=>{let J=this._createOrGetQueuedChunkSync(Z.chunk);J.b=Array.from(Z.chunk.blocks),J.rm=void 0,this._spawnedChunks.add(J.c.join(","))};_onChunkLatticeRemoveChunk=(Z)=>{let J=this._createOrGetQueuedChunkSync(Z.chunk),X=J.c.join(",");if(this._spawnedChunks.has(X))this._queuedChunkSynchronizations.delete(X),this._spawnedChunks.delete(X);else J.rm=!0};_onChunkLatticeSetBlock=(Z)=>{let J=this._createOrGetQueuedBlockSync(Z.globalCoordinate);J.i=Z.blockTypeId};_onEntitySetModelAnimationsPlaybackRate=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.ap=Z.playbackRate};_onEntitySpawn=(Z)=>{let J=Z.entity.serialize();this._queuedEntitySynchronizations.set(J.i,J),this._spawnedEntities.add(J.i)};_onEntityDespawn=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(this._spawnedEntities.has(J.i))this._queuedEntitySynchronizations.delete(J.i),this._spawnedEntities.delete(J.i);else J.rm=!0};_onEntitySetModelHiddenNodes=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.h=Array.from(Z.modelHiddenNodes)};_onEntitySetModelScale=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.s=Z.modelScale};_onEntitySetModelShownNodes=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.sn=Array.from(Z.modelShownNodes)};_onEntitySetModelTextureUri=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.mt=Z.modelTextureUri};_onEntitySetOpacity=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.o=Z.opacity};_onEntitySetParent=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.pe=Z.parent?Z.parent.id:void 0,J.pn=Z.parentNodeName};_onEntitySetTintColor=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.t=Z.tintColor?k0.serializeRgbColor(Z.tintColor):void 0};_onEntityStartModelLoopedAnimations=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(J.al=Array.from(new Set([...J.al??[],...Z.animations])),J.as)J.as=J.as.filter((X)=>!Z.animations.has(X)).filter(Boolean)};_onEntityStartModelOneshotAnimations=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(J.ao=Array.from(new Set([...J.ao??[],...Z.animations])),J.as)J.as=J.as.filter((X)=>!Z.animations.has(X)).filter(Boolean)};_onEntityStopModelAnimations=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(J.al)J.al=J.al.filter((X)=>!Z.animations.has(X)).filter(Boolean);if(J.ao)J.ao=J.ao.filter((X)=>!Z.animations.has(X)).filter(Boolean);J.as=Array.from(new Set([...J.as??[],...Z.animations]))};_onEntityUpdateRotation=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.r=[Z.rotation.x,Z.rotation.y,Z.rotation.z,Z.rotation.w]};_onEntityUpdatePosition=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.p=[Z.position.x,Z.position.y,Z.position.z]};_onLightDespawn=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.rm=!0};_onLightSetAngle=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.a=Z.angle};_onLightSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onLightSetColor=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.c=k0.serializeRgbColor(Z.color)};_onLightSetDistance=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.d=Z.distance};_onLightSetIntensity=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.n=Z.intensity};_onLightSetOffset=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onLightSetPenumbra=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.pe=Z.penumbra};_onLightSetPosition=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.p=Z.position?k0.serializeVector(Z.position):void 0,J.e=Z.position?void 0:J.e};_onLightSetTrackedEntity=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.te=Z.entity?Z.entity.id:void 0,J.tp=Z.entity?void 0:J.tp};_onLightSetTrackedPosition=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.tp=Z.position?k0.serializeVector(Z.position):void 0,J.te=Z.position?void 0:J.te};_onLightSpawn=(Z)=>{let J=Z.light.serialize();this._queuedLightSynchronizations.set(J.i,J)};_onParticleEmitterBurst=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.b=Z.count};_onParticleEmitterDespawn=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.rm=!0};_onParticleEmitterSetAlphaTest=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.at=Z.alphaTest};_onParticleEmitterSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onParticleEmitterSetAttachedToEntityNodeName=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.en=Z.attachedToEntityNodeName};_onParticleEmitterSetColorEnd=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.ce=Z.colorEnd?k0.serializeRgbColor(Z.colorEnd):void 0};_onParticleEmitterSetColorEndVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.cev=Z.colorEndVariance?k0.serializeRgbColor(Z.colorEndVariance):void 0};_onParticleEmitterSetColorStart=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.cs=Z.colorStart?k0.serializeRgbColor(Z.colorStart):void 0};_onParticleEmitterSetColorStartVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.csv=Z.colorStartVariance?k0.serializeRgbColor(Z.colorStartVariance):void 0};_onParticleEmitterSetGravity=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.g=Z.gravity?k0.serializeVector(Z.gravity):void 0};_onParticleEmitterSetLifetime=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.l=Z.lifetime};_onParticleEmitterSetLifetimeVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.lv=Z.lifetimeVariance};_onParticleEmitterSetMaxParticles=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.mp=Z.maxParticles};_onParticleEmitterSetOffset=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onParticleEmitterSetOpacityEnd=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.oe=Z.opacityEnd};_onParticleEmitterSetOpacityEndVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.oev=Z.opacityEndVariance};_onParticleEmitterSetOpacityStart=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.os=Z.opacityStart};_onParticleEmitterSetOpacityStartVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.osv=Z.opacityStartVariance};_onParticleEmitterSetPaused=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.pa=Z.paused};_onParticleEmitterSetPosition=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.p=Z.position?k0.serializeVector(Z.position):void 0,J.e=Z.position?void 0:J.e,J.en=Z.position?void 0:J.en};_onParticleEmitterSetPositionVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.pv=Z.positionVariance?k0.serializeVector(Z.positionVariance):void 0};_onParticleEmitterSetRate=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.r=Z.rate};_onParticleEmitterSetRateVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.rv=Z.rateVariance};_onParticleEmitterSetSizeEnd=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.se=Z.sizeEnd};_onParticleEmitterSetSizeEndVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.sev=Z.sizeEndVariance};_onParticleEmitterSetSizeStart=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.ss=Z.sizeStart};_onParticleEmitterSetSizeStartVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.ssv=Z.sizeStartVariance};_onParticleEmitterSetTextureUri=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.tu=Z.textureUri};_onParticleEmitterSetTransparent=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.t=Z.transparent};_onParticleEmitterSetVelocity=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.v=Z.velocity?k0.serializeVector(Z.velocity):void 0};_onParticleEmitterSetVelocityVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.vv=Z.velocityVariance?k0.serializeVector(Z.velocityVariance):void 0};_onParticleEmitterSpawn=(Z)=>{let J=Z.particleEmitter.serialize();this._queuedParticleEmitterSynchronizations.set(J.i,J)};_onPlayerCameraLookAtEntity=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.pl=k0.serializeVector(Z.entity.position),delete J.et,delete J.pt};_onPlayerCameraLookAtPosition=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.pl=Z.position?k0.serializeVector(Z.position):void 0,delete J.et,delete J.pt};_onPlayerCameraSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.e=Z.entity.id,delete J.p};_onPlayerCameraSetAttachedToPosition=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.p=Z.position?k0.serializeVector(Z.position):void 0,delete J.e};_onPlayerCameraSetFilmOffset=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.fo=Z.filmOffset};_onPlayerCameraSetForwardOffset=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.ffo=Z.forwardOffset};_onPlayerCameraSetFov=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.fv=Z.fov};_onPlayerCameraSetModelHiddenNodes=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.h=Array.from(Z.modelHiddenNodes)};_onPlayerCameraSetModelShownNodes=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.s=Array.from(Z.modelShownNodes)};_onPlayerCameraSetMode=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.m=Z.mode};_onPlayerCameraSetOffset=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onPlayerCameraSetShoulderAngle=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.sa=Z.shoulderAngle};_onPlayerCameraSetTrackedEntity=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.et=Z.entity?Z.entity.id:void 0,delete J.pl,delete J.pt};_onPlayerCameraSetTrackedPosition=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.pt=Z.position?k0.serializeVector(Z.position):void 0,delete J.et,delete J.pl};_onPlayerCameraSetZoom=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.z=Z.zoom};_onPlayerJoinedWorld=(Z)=>{let{player:J}=Z,X=this._queuedPerPlayerSynchronizations.get(J)??[];X.push(Q0.createPacket(Q0.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map(($)=>{if(J.camera.attachedToEntity===void 0&&$ instanceof y7&&$.player===J)J.camera.setAttachedToEntity($);return $.serialize()}),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllAudios().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.particleEmittersPacketDefinition,this._world.particleEmitterManager.getAllParticleEmitters().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.playersPacketDefinition,j9.instance.getConnectedPlayers().map(($)=>$.serialize()),this._world.loop.currentTick));let Y=this._createOrGetQueuedPlayerCameraSync(J.camera);this._queuedPerPlayerCameraSynchronizations.set(J,{...J.camera.serialize(),...Y}),this._queuedPerPlayerSynchronizations.set(J,X),this._queuedPlayerSynchronizations.set(J.id,J.serialize())};_onPlayerLeftWorld=(Z)=>{let J=this._createOrGetQueuedPlayerSync(Z.player);J.rm=!0};_onPlayerReconnectedWorld=(Z)=>{this._onPlayerJoinedWorld(Z)};_onPlayerRequestSync=(Z)=>{Z.player.connection.send([Q0.createPacket(Q0.outboundPackets.syncResponsePacketDefinition,{r:Z.receivedAt,s:Date.now(),p:performance.now()-Z.receivedAtMs,n:this._world.loop.nextTickMs},this._world.loop.currentTick)])};_onPlayerUILoad=(Z)=>{let J=this._createOrGetQueuedPlayerUISync(Z.playerUI);J.u=Z.htmlUri};_onPlayerUILockPointer=(Z)=>{let J=this._createOrGetQueuedPlayerUISync(Z.playerUI);J.p=Z.lock};_onPlayerUISendData=(Z)=>{this._createOrGetQueuedPlayerUIDatasSync(Z.playerUI).push(Z.data)};_onSceneUILoad=(Z)=>{let J=Z.sceneUI.serialize();this._queuedSceneUISynchronizations.set(J.i,J),this._loadedSceneUIs.add(J.i)};_onSceneUISetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onSceneUISetOffset=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onSceneUISetPosition=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.p=Z.position?k0.serializeVector(Z.position):void 0,J.e=Z.position?void 0:J.e};_onSceneUISetState=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.s=Z.state};_onSceneUISetViewDistance=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.v=Z.viewDistance};_onSceneUIUnload=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);if(this._loadedSceneUIs.has(J.i))this._queuedSceneUISynchronizations.delete(J.i),this._loadedSceneUIs.delete(J.i);else J.rm=!0};_onSimulationDebugRaycast=(Z)=>{this._queuedDebugRaycastSynchronizations.push(k0.serializePhysicsDebugRaycast(Z))};_onSimulationDebugRender=(Z)=>{this._queuedBroadcasts.push(Q0.createPacket(Q0.outboundPackets.physicsDebugRenderPacketDefinition,{v:Array.from(Z.vertices),c:Array.from(Z.colors)},this._world.loop.currentTick))};_onWorldSetAmbientLightColor=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.ac=k0.serializeRgbColor(Z.color)};_onWorldSetAmbientLightIntensity=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.ai=Z.intensity};_onWorldSetDirectionalLightColor=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.dc=k0.serializeRgbColor(Z.color)};_onWorldSetDirectionalLightIntensity=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.di=Z.intensity};_onWorldSetDirectionalLightPosition=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.dp=k0.serializeVector(Z.position)};_onWorldSetFogColor=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.fc=k0.serializeRgbColor(Z.color)};_onWorldSetFogFar=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.ff=Z.far};_onWorldSetFogNear=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.fn=Z.near};_onWorldSetSkyboxIntensity=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.si=Z.intensity};_createOrGetQueuedAudioSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");let J=this._queuedAudioSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedAudioSynchronizations.set(Z.id,J);return J}_createOrGetQueuedBlockSync(Z){let{x:J,y:X,z:Y}=Z,$=`${J},${X},${Y}`,Q=this._queuedBlockSynchronizations.get($);if(!Q)Q={i:0,c:[J,X,Y]},this._queuedBlockSynchronizations.set($,Q);return Q}_createOrGetQueuedChunkSync(Z){if(!Z.originCoordinate)d.fatalError("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:J,y:X,z:Y}=Z.originCoordinate,$=`${J},${X},${Y}`,Q=this._queuedChunkSynchronizations.get($);if(!Q)Q={c:[J,X,Y]},this._queuedChunkSynchronizations.set($,Q);return Q}_createOrGetQueuedEntitySync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");let J=this._queuedEntitySynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedEntitySynchronizations.set(Z.id,J);return J}_createOrGetQueuedLightSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");let J=this._queuedLightSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedLightSynchronizations.set(Z.id,J);return J}_createOrGetQueuedParticleEmitterSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedParticleEmitterSync(): ParticleEmitter has no id!");let J=this._queuedParticleEmitterSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedParticleEmitterSynchronizations.set(Z.id,J);return J}_createOrGetQueuedPlayerSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedPlayerSync(): Player has no id!");let J=this._queuedPlayerSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedPlayerSynchronizations.set(Z.id,J);return J}_createOrGetQueuedPlayerCameraSync(Z){let J=this._queuedPerPlayerCameraSynchronizations.get(Z.player);if(!J)J={},this._queuedPerPlayerCameraSynchronizations.set(Z.player,J);return J}_createOrGetQueuedPlayerUISync(Z){let J=this._queuedPerPlayerUISynchronizations.get(Z.player);if(!J)J={},this._queuedPerPlayerUISynchronizations.set(Z.player,J);return J}_createOrGetQueuedPlayerUIDatasSync(Z){let J=this._queuedPerPlayerUIDatasSynchronizations.get(Z.player);if(!J)J=[],this._queuedPerPlayerUIDatasSynchronizations.set(Z.player,J);return J}_createOrGetQueuedSceneUISync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");let J=this._queuedSceneUISynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedSceneUISynchronizations.set(Z.id,J);return J}_createOrGetQueuedWorldSync(Z){if(Z.id!==this._world.id)d.fatalError("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:Z.id}}_createOrGetSynchronizedPlayerReliablePackets(Z,J){let X=this._synchronizedPlayerReliablePackets.get(Z);if(!X)X=[...J],this._synchronizedPlayerReliablePackets.set(Z,X);return X}}class sF{_particleEmitters=new Map;_nextParticleEmitterId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}despawnEntityAttachedParticleEmitters(Z){this.getAllEntityAttachedParticleEmitters(Z).forEach((J)=>{J.despawn()})}getAllParticleEmitters(){return Array.from(this._particleEmitters.values())}getAllEntityAttachedParticleEmitters(Z){return this.getAllParticleEmitters().filter((J)=>J.attachedToEntity===Z)}registerParticleEmitter(Z){if(Z.id!==void 0)return Z.id;let J=this._nextParticleEmitterId;return this._particleEmitters.set(J,Z),this._nextParticleEmitterId++,J}unregisterParticleEmitter(Z){if(Z.id===void 0)return;this._particleEmitters.delete(Z.id)}}class oF{_sceneUIs=new Map;_nextSceneUIId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}getAllSceneUIs(){return Array.from(this._sceneUIs.values())}getAllEntityAttachedSceneUIs(Z){return this.getAllSceneUIs().filter((J)=>J.attachedToEntity===Z)}getSceneUIById(Z){return this._sceneUIs.get(Z)}registerSceneUI(Z){if(Z.id!==void 0)return Z.id;let J=this._nextSceneUIId;return this._sceneUIs.set(J,Z),this._nextSceneUIId++,J}unloadEntityAttachedSceneUIs(Z){this.getAllEntityAttachedSceneUIs(Z).forEach((J)=>{J.unload()})}unregisterSceneUI(Z){if(Z.id===void 0)return;this._sceneUIs.delete(Z.id)}}var IJ6=2,vJ6=3;class rF{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_maxAccumulatorMs;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(Z,J,X){this._targetTicksPerSecond=Z,this._fixedTimestepS=Math.fround(1/Z),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._maxAccumulatorMs=this._fixedTimestepMs*vJ6,this._tickFunction=J,this._tickErrorCallback=X}get targetTicksPerSecond(){return this._targetTicksPerSecond}get fixedTimestepMs(){return this._fixedTimestepMs}get fixedTimestepS(){return this._fixedTimestepS}get isStarted(){return!!this._tickHandle}get nextTickMs(){return this._nextTickMs}start(){if(this._tickHandle)return;this._lastLoopTimeMs=performance.now();let Z=()=>{let J=performance.now(),X=J-this._lastLoopTimeMs;if(this._lastLoopTimeMs=J,this._accumulatorMs+=X,this._accumulatorMs>this._maxAccumulatorMs)this._accumulatorMs=this._maxAccumulatorMs;if(this._accumulatorMs>=this._fixedTimestepMs)N8.startSpan({operation:"ticker_tick"},()=>{let Y=0;while(this._accumulatorMs>=this._fixedTimestepMs&&Y<IJ6)this._tick(this._fixedTimestepMs),this._accumulatorMs-=this._fixedTimestepMs,Y++});this._nextTickMs=Math.max(0,this._fixedTimestepMs-this._accumulatorMs),this._tickHandle=setTimeout(Z,this._nextTickMs)};Z()}stop(){if(!this._tickHandle)return;clearTimeout(this._tickHandle),this._tickHandle=null}_tick(Z){try{this._tickFunction(Z)}catch(J){if(J instanceof Error&&this._tickErrorCallback)this._tickErrorCallback(J);else d.warning(`Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error: ${J}`)}}}var OK1;((Q)=>{Q.START="WORLD_LOOP.START";Q.STOP="WORLD_LOOP.STOP";Q.TICK_START="WORLD_LOOP.TICK_START";Q.TICK_END="WORLD_LOOP.TICK_END";Q.TICK_ERROR="WORLD_LOOP.TICK_ERROR"})(OK1||={});class tF extends j0{_currentTick=0;_ticker;_world;constructor(Z,J=cg){super();this._ticker=new rF(J,this._tick,this._onTickError),this._world=Z}get currentTick(){return this._currentTick}get isStarted(){return this._ticker.isStarted}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=(Z)=>{this.emitWithWorld(this._world,"WORLD_LOOP.TICK_START",{worldLoop:this,tickDeltaMs:Z});let J=performance.now();N8.startSpan({operation:"world_tick",attributes:{serverPlayerCount:j9.instance.playerCount,targetTickRate:this._ticker.targetTicksPerSecond,targetTickRateMs:this._ticker.fixedTimestepMs,worldId:this._world.id,worldName:this._world.name,worldChunkCount:this._world.chunkLattice.chunkCount,worldEntityCount:this._world.entityManager.entityCount,worldLoopTick:this._currentTick}},()=>{N8.startSpan({operation:"entities_tick"},()=>this._world.entityManager.tickEntities(Z)),N8.startSpan({operation:"simulation_step"},()=>this._world.simulation.step(Z)),N8.startSpan({operation:"entities_emit_updates"},()=>this._world.entityManager.checkAndEmitUpdates()),N8.startSpan({operation:"network_synchronize"},()=>this._world.networkSynchronizer.synchronize())}),this._currentTick++,this.emitWithWorld(this._world,"WORLD_LOOP.TICK_END",{worldLoop:this,tickDurationMs:performance.now()-J})};_onTickError=(Z)=>{d.error(`WorldLoop._onTickError(): Error: ${Z}`),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:Z})}}var pg;((V)=>{V.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";V.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";V.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";V.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";V.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";V.SET_FOG_COLOR="WORLD.SET_FOG_COLOR";V.SET_FOG_FAR="WORLD.SET_FOG_FAR";V.SET_FOG_NEAR="WORLD.SET_FOG_NEAR";V.SET_SKYBOX_INTENSITY="WORLD.SET_SKYBOX_INTENSITY";V.START="WORLD.START";V.STOP="WORLD.STOP"})(pg||={});class eF extends j0{_id;_ambientLightColor;_ambientLightIntensity;_directionalLightColor;_directionalLightIntensity;_directionalLightPosition;_fogColor;_fogFar;_fogNear;_name;_skyboxIntensity;_skyboxUri;_audioManager;_blockTypeRegistry;_chatManager;_chunkLattice;_entityManager;_lightManager;_loop;_networkSynchronizer;_particleEmitterManager;_sceneUIManager;_simulation;_tag;constructor(Z){super();if(this._id=Z.id,this._ambientLightColor=Z.ambientLightColor??{r:255,g:255,b:255},this._ambientLightIntensity=Z.ambientLightIntensity??1,this._directionalLightColor=Z.directionalLightColor??{r:255,g:255,b:255},this._directionalLightIntensity=Z.directionalLightIntensity??3,this._directionalLightPosition=Z.directionalLightPosition??{x:100,y:150,z:100},this._fogColor=Z.fogColor,this._fogFar=Z.fogFar??550,this._fogNear=Z.fogNear??500,this._name=Z.name,this._skyboxIntensity=Z.skyboxIntensity??1,this._skyboxUri=Z.skyboxUri,this._tag=Z.tag,this._audioManager=new zG(this),this._blockTypeRegistry=new hz(this),this._chatManager=new VH(this),this._chunkLattice=new qH(this),this._entityManager=new BH(this),this._lightManager=new nF(this),this._loop=new tF(this,Z.tickRate),this._networkSynchronizer=new PN(this),this._particleEmitterManager=new sF(this),this._sceneUIManager=new oF(this),this._simulation=new aF(this,Z.tickRate,Z.gravity),Z.map)this.loadMap(Z.map)}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 fogColor(){return this._fogColor}get fogFar(){return this._fogFar}get fogNear(){return this._fogNear}get name(){return this._name}get skyboxIntensity(){return this._skyboxIntensity}get skyboxUri(){return this._skyboxUri}get audioManager(){return this._audioManager}get tag(){return this._tag}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 particleEmitterManager(){return this._particleEmitterManager}get sceneUIManager(){return this._sceneUIManager}get simulation(){return this._simulation}loadMap(Z){if(this.chunkLattice.clear(),Z.blockTypes)for(let J of Z.blockTypes)this.blockTypeRegistry.registerGenericBlockType({id:J.id,isLiquid:J.isLiquid,name:J.name,textureUri:J.textureUri});if(Z.blocks)for(let[J,X]of Object.entries(Z.blocks)){let[Y,$,Q]=J.split(",").map(Number);this.chunkLattice.setBlock({x:Y,y:$,z:Q},X)}if(Z.entities)for(let[J,X]of Object.entries(Z.entities)){let[Y,$,Q]=J.split(",").map(Number);new o8({isEnvironmental:!0,...X}).spawn(this,{x:Y,y:$,z:Q})}}setAmbientLightColor(Z){this._ambientLightColor=Z,this.emit("WORLD.SET_AMBIENT_LIGHT_COLOR",{world:this,color:Z})}setAmbientLightIntensity(Z){this._ambientLightIntensity=Z,this.emit("WORLD.SET_AMBIENT_LIGHT_INTENSITY",{world:this,intensity:Z})}setDirectionalLightColor(Z){this._directionalLightColor=Z,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",{world:this,color:Z})}setDirectionalLightIntensity(Z){this._directionalLightIntensity=Z,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",{world:this,intensity:Z})}setDirectionalLightPosition(Z){this._directionalLightPosition=Z,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",{world:this,position:Z})}setFogColor(Z){this._fogColor=Z,this.emit("WORLD.SET_FOG_COLOR",{world:this,color:Z})}setFogFar(Z){this._fogFar=Z,this.emit("WORLD.SET_FOG_FAR",{world:this,far:Z})}setFogNear(Z){this._fogNear=Z,this.emit("WORLD.SET_FOG_NEAR",{world:this,near:Z})}setSkyboxIntensity(Z){this._skyboxIntensity=Z,this.emit("WORLD.SET_SKYBOX_INTENSITY",{world:this,intensity:Z})}start(){if(this._loop.isStarted)return;this._loop.start(),this.emit("WORLD.START",{world:this,startedAtMs:Date.now()})}stop(){if(!this._loop.isStarted)return;this._loop.stop(),this.emit("WORLD.STOP",{world:this,stoppedAtMs:Date.now()})}serialize(){return k0.serializeWorld(this)}}var MK1;((J)=>J.WORLD_CREATED="WORLD_MANAGER.WORLD_CREATED")(MK1||={});class cY{static instance=new cY;_defaultWorld;_nextWorldId=1;_worlds=new Map;createWorld(Z){let J=new eF({...Z,id:this._nextWorldId++});return J.start(),this._worlds.set(J.id,J),j0.globalInstance.emit("WORLD_MANAGER.WORLD_CREATED",{world:J}),J}getAllWorlds(){return Array.from(this._worlds.values())}getDefaultWorld(){return this._defaultWorld??=this.createWorld({name:"Default World",skyboxUri:"skyboxes/partly-cloudy"}),this._defaultWorld}getWorldsByTag(Z){let J=[];return this._worlds.forEach((X)=>{if(X.tag===Z)J.push(X)}),J}getWorld(Z){return this._worlds.get(Z)}setDefaultWorld(Z){this._defaultWorld=Z}}var RK1;((Y)=>{Y.PLAYER_CONNECTED="PLAYER_MANAGER.PLAYER_CONNECTED";Y.PLAYER_DISCONNECTED="PLAYER_MANAGER.PLAYER_DISCONNECTED";Y.PLAYER_RECONNECTED="PLAYER_MANAGER.PLAYER_RECONNECTED"})(RK1||={});class j9{static instance=new j9;worldSelectionHandler;_connectionPlayers=new Map;constructor(){j0.globalInstance.on("CONNECTION.OPENED",({connection:Z,req:J})=>{this._onConnectionOpened(Z,J.session)}),j0.globalInstance.on("CONNECTION.DISCONNECTED",({connection:Z})=>{this._onConnectionDisconnected(Z)}),j0.globalInstance.on("CONNECTION.RECONNECTED",({connection:Z})=>{this._onConnectionReconnected(Z)}),j0.globalInstance.on("CONNECTION.CLOSED",({connection:Z})=>{this._onConnectionClosed(Z)})}get playerCount(){return this._connectionPlayers.size}getConnectedPlayers(){return Array.from(this._connectionPlayers.values())}getConnectedPlayersByWorld(Z){return this.getConnectedPlayers().filter((J)=>J.world===Z)}getConnectedPlayerByUsername(Z){return Array.from(this._connectionPlayers.values()).find((J)=>{return J.username.toLowerCase()===Z.toLowerCase()})}async _onConnectionOpened(Z,J){let X=new QK(Z,J);await X.loadInitialPersistedData(),this._connectionPlayers.set(Z,X),j0.globalInstance.emit("PLAYER_MANAGER.PLAYER_CONNECTED",{player:X});let Y=await this.worldSelectionHandler?.(X);X.joinWorld(Y??cY.instance.getDefaultWorld())}_onConnectionDisconnected(Z){let J=this._connectionPlayers.get(Z);if(J)J.resetInputs(),J.camera.reset()}_onConnectionReconnected(Z){let J=this._connectionPlayers.get(Z);if(J)J.reconnected(),j0.globalInstance.emit("PLAYER_MANAGER.PLAYER_RECONNECTED",{player:J});else d.warning(`PlayerManager._onConnectionReconnected(): Connection ${Z.id} not in the PlayerManager._connectionPlayers map.`)}_onConnectionClosed(Z){let J=this._connectionPlayers.get(Z);if(J)J.disconnect(),this._connectionPlayers.delete(Z),j0.globalInstance.emit("PLAYER_MANAGER.PLAYER_DISCONNECTED",{player:J});else d.warning(`PlayerManager._onConnectionClosed(): Connection ${Z.id} not in the PlayerManager._connectionPlayers map.`)}}Buffer.poolSize=134217728;var NK1;((X)=>{X.START="GAMESERVER.START";X.STOP="GAMESERVER.STOP"})(NK1||={});function SJ6(Z){Q1.init().then(()=>{return oQ.instance.modelRegistry.preloadModels()}).then(()=>{if(Z.length>0)Z(oQ.instance.worldManager.getDefaultWorld());else Z();oQ.instance.start()}).catch((J)=>{d.fatalError(`Failed to initialize the game engine, exiting. Error: ${J}`)})}class oQ{static _instance;_modelRegistry=h5.instance;_playerManager=j9.instance;_socket=a7.instance;_worldManager=cY.instance;_webServer=mK.instance;constructor(){}static get instance(){if(!this._instance)this._instance=new oQ;return this._instance}get modelRegistry(){return this._modelRegistry}get playerManager(){return this._playerManager}get socket(){return this._socket}get webServer(){return this._webServer}get worldManager(){return this._worldManager}start(){j0.globalInstance.emit("GAMESERVER.START",{startedAtMs:performance.now()}),this._webServer.start()}}var v0=0.000001,z1=typeof Float32Array!=="undefined"?Float32Array:Array,jZ=Math.random;var CX5=Math.PI/180;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};var i8={};_9(i8,{transpose:()=>yJ6,subtract:()=>PK1,sub:()=>JX6,str:()=>iJ6,set:()=>bJ6,scale:()=>cJ6,rotate:()=>dJ6,multiplyScalarAndAdd:()=>eJ6,multiplyScalar:()=>tJ6,multiply:()=>DK1,mul:()=>ZX6,invert:()=>gJ6,identity:()=>hJ6,fromValues:()=>fJ6,fromScaling:()=>pJ6,fromRotation:()=>lJ6,frob:()=>nJ6,exactEquals:()=>oJ6,equals:()=>rJ6,determinant:()=>uJ6,create:()=>_J6,copy:()=>xJ6,clone:()=>AJ6,adjoint:()=>mJ6,add:()=>sJ6,LDU:()=>aJ6});function _J6(){var Z=new z1(4);if(z1!=Float32Array)Z[1]=0,Z[2]=0;return Z[0]=1,Z[3]=1,Z}function AJ6(Z){var J=new z1(4);return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function xJ6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function hJ6(Z){return Z[0]=1,Z[1]=0,Z[2]=0,Z[3]=1,Z}function fJ6(Z,J,X,Y){var $=new z1(4);return $[0]=Z,$[1]=J,$[2]=X,$[3]=Y,$}function bJ6(Z,J,X,Y,$){return Z[0]=J,Z[1]=X,Z[2]=Y,Z[3]=$,Z}function yJ6(Z,J){if(Z===J){var X=J[1];Z[1]=J[2],Z[2]=X}else Z[0]=J[0],Z[1]=J[2],Z[2]=J[1],Z[3]=J[3];return Z}function gJ6(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=X*Q-$*Y;if(!W)return null;return W=1/W,Z[0]=Q*W,Z[1]=-Y*W,Z[2]=-$*W,Z[3]=X*W,Z}function mJ6(Z,J){var X=J[0];return Z[0]=J[3],Z[1]=-J[1],Z[2]=-J[2],Z[3]=X,Z}function uJ6(Z){return Z[0]*Z[3]-Z[2]*Z[1]}function DK1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=X[0],G=X[1],z=X[2],H=X[3];return Z[0]=Y*K+Q*G,Z[1]=$*K+W*G,Z[2]=Y*z+Q*H,Z[3]=$*z+W*H,Z}function dJ6(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G+Q*K,Z[1]=$*G+W*K,Z[2]=Y*-K+Q*G,Z[3]=$*-K+W*G,Z}function cJ6(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=X[0],G=X[1];return Z[0]=Y*K,Z[1]=$*K,Z[2]=Q*G,Z[3]=W*G,Z}function lJ6(Z,J){var X=Math.sin(J),Y=Math.cos(J);return Z[0]=Y,Z[1]=X,Z[2]=-X,Z[3]=Y,Z}function pJ6(Z,J){return Z[0]=J[0],Z[1]=0,Z[2]=0,Z[3]=J[1],Z}function iJ6(Z){return"mat2("+Z[0]+", "+Z[1]+", "+Z[2]+", "+Z[3]+")"}function nJ6(Z){return Math.hypot(Z[0],Z[1],Z[2],Z[3])}function aJ6(Z,J,X,Y){return Z[2]=Y[2]/Y[0],X[0]=Y[0],X[1]=Y[1],X[3]=Y[3]-Z[2]*X[1],[Z,J,X]}function sJ6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function PK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z}function oJ6(Z,J){return Z[0]===J[0]&&Z[1]===J[1]&&Z[2]===J[2]&&Z[3]===J[3]}function rJ6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=Z[3],W=J[0],K=J[1],G=J[2],z=J[3];return Math.abs(X-W)<=v0*Math.max(1,Math.abs(X),Math.abs(W))&&Math.abs(Y-K)<=v0*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs($-G)<=v0*Math.max(1,Math.abs($),Math.abs(G))&&Math.abs(Q-z)<=v0*Math.max(1,Math.abs(Q),Math.abs(z))}function tJ6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function eJ6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z[2]=J[2]+X[2]*Y,Z[3]=J[3]+X[3]*Y,Z}var ZX6=DK1,JX6=PK1;var e1={};_9(e1,{transpose:()=>GX6,translate:()=>qX6,subtract:()=>TK1,sub:()=>vX6,str:()=>NX6,set:()=>WX6,scale:()=>UX6,rotate:()=>FX6,projection:()=>RX6,normalFromMat4:()=>MX6,multiplyScalarAndAdd:()=>TX6,multiplyScalar:()=>CX6,multiply:()=>CK1,mul:()=>IX6,invert:()=>zX6,identity:()=>KX6,fromValues:()=>QX6,fromTranslation:()=>wX6,fromScaling:()=>LX6,fromRotation:()=>BX6,fromQuat:()=>OX6,fromMat4:()=>XX6,fromMat2d:()=>jX6,frob:()=>DX6,exactEquals:()=>kX6,equals:()=>EX6,determinant:()=>VX6,create:()=>ig,copy:()=>$X6,clone:()=>YX6,adjoint:()=>HX6,add:()=>PX6});function ig(){var Z=new z1(9);if(z1!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function XX6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[4],Z[4]=J[5],Z[5]=J[6],Z[6]=J[8],Z[7]=J[9],Z[8]=J[10],Z}function YX6(Z){var J=new z1(9);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 $X6(Z,J){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],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],q=J[1],F=J[2],U=J[3],B=J[4],w=J[5],j=J[6],N=J[7],R=J[8];return Math.abs(X-V)<=v0*Math.max(1,Math.abs(X),Math.abs(V))&&Math.abs(Y-q)<=v0*Math.max(1,Math.abs(Y),Math.abs(q))&&Math.abs($-F)<=v0*Math.max(1,Math.abs($),Math.abs(F))&&Math.abs(Q-U)<=v0*Math.max(1,Math.abs(Q),Math.abs(U))&&Math.abs(W-B)<=v0*Math.max(1,Math.abs(W),Math.abs(B))&&Math.abs(K-w)<=v0*Math.max(1,Math.abs(K),Math.abs(w))&&Math.abs(G-j)<=v0*Math.max(1,Math.abs(G),Math.abs(j))&&Math.abs(z-N)<=v0*Math.max(1,Math.abs(z),Math.abs(N))&&Math.abs(H-R)<=v0*Math.max(1,Math.abs(H),Math.abs(R))}var IX6=CK1,vX6=TK1;var r0={};_9(r0,{transpose:()=>fX6,translate:()=>mX6,targetTo:()=>VY6,subtract:()=>AK1,sub:()=>MY6,str:()=>qY6,set:()=>hX6,scale:()=>uX6,rotateZ:()=>pX6,rotateY:()=>lX6,rotateX:()=>cX6,rotate:()=>dX6,perspectiveZO:()=>WY6,perspectiveNO:()=>SK1,perspectiveFromFieldOfView:()=>KY6,perspective:()=>QY6,orthoZO:()=>zY6,orthoNO:()=>_K1,ortho:()=>GY6,multiplyScalarAndAdd:()=>BY6,multiplyScalar:()=>wY6,multiply:()=>EK1,mul:()=>OY6,lookAt:()=>HY6,invert:()=>bX6,identity:()=>kK1,getTranslation:()=>eX6,getScaling:()=>vK1,getRotation:()=>ZY6,frustum:()=>$Y6,fromZRotation:()=>rX6,fromYRotation:()=>oX6,fromXRotation:()=>sX6,fromValues:()=>xX6,fromTranslation:()=>iX6,fromScaling:()=>nX6,fromRotationTranslationScaleOrigin:()=>XY6,fromRotationTranslationScale:()=>JY6,fromRotationTranslation:()=>IK1,fromRotation:()=>aX6,fromQuat2:()=>tX6,fromQuat:()=>YY6,frob:()=>FY6,exactEquals:()=>LY6,equals:()=>jY6,determinant:()=>gX6,create:()=>SX6,copy:()=>AX6,clone:()=>_X6,adjoint:()=>yX6,add:()=>UY6});function SX6(){var Z=new z1(16);if(z1!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[4]=0,Z[6]=0,Z[7]=0,Z[8]=0,Z[9]=0,Z[11]=0,Z[12]=0,Z[13]=0,Z[14]=0;return Z[0]=1,Z[5]=1,Z[10]=1,Z[15]=1,Z}function _X6(Z){var J=new z1(16);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 AX6(Z,J){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 xX6(Z,J,X,Y,$,Q,W,K,G,z,H,V,q,F,U,B){var w=new z1(16);return w[0]=Z,w[1]=J,w[2]=X,w[3]=Y,w[4]=$,w[5]=Q,w[6]=W,w[7]=K,w[8]=G,w[9]=z,w[10]=H,w[11]=V,w[12]=q,w[13]=F,w[14]=U,w[15]=B,w}function hX6(Z,J,X,Y,$,Q,W,K,G,z,H,V,q,F,U,B,w){return Z[0]=J,Z[1]=X,Z[2]=Y,Z[3]=$,Z[4]=Q,Z[5]=W,Z[6]=K,Z[7]=G,Z[8]=z,Z[9]=H,Z[10]=V,Z[11]=q,Z[12]=F,Z[13]=U,Z[14]=B,Z[15]=w,Z}function kK1(Z){return Z[0]=1,Z[1]=0,Z[2]=0,Z[3]=0,Z[4]=0,Z[5]=1,Z[6]=0,Z[7]=0,Z[8]=0,Z[9]=0,Z[10]=1,Z[11]=0,Z[12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){var $=J[0],Q=J[1],W=J[2],K=Y[0],G=Y[1],z=Y[2],H=$-X[0],V=Q-X[1],q=W-X[2],F=H*H+V*V+q*q;if(F>0)F=1/Math.sqrt(F),H*=F,V*=F,q*=F;var U=G*q-z*V,B=z*H-K*q,w=K*V-G*H;if(F=U*U+B*B+w*w,F>0)F=1/Math.sqrt(F),U*=F,B*=F,w*=F;return Z[0]=U,Z[1]=B,Z[2]=w,Z[3]=0,Z[4]=V*w-q*B,Z[5]=q*U-H*w,Z[6]=H*B-V*U,Z[7]=0,Z[8]=H,Z[9]=V,Z[10]=q,Z[11]=0,Z[12]=$,Z[13]=Q,Z[14]=W,Z[15]=1,Z}function qY6(Z){return"mat4("+Z[0]+", "+Z[1]+", "+Z[2]+", "+Z[3]+", "+Z[4]+", "+Z[5]+", "+Z[6]+", "+Z[7]+", "+Z[8]+", "+Z[9]+", "+Z[10]+", "+Z[11]+", "+Z[12]+", "+Z[13]+", "+Z[14]+", "+Z[15]+")"}function FY6(Z){return Math.hypot(Z[0],Z[1],Z[2],Z[3],Z[4],Z[5],Z[6],Z[7],Z[8],Z[9],Z[10],Z[11],Z[12],Z[13],Z[14],Z[15])}function UY6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z[4]=J[4]+X[4],Z[5]=J[5]+X[5],Z[6]=J[6]+X[6],Z[7]=J[7]+X[7],Z[8]=J[8]+X[8],Z[9]=J[9]+X[9],Z[10]=J[10]+X[10],Z[11]=J[11]+X[11],Z[12]=J[12]+X[12],Z[13]=J[13]+X[13],Z[14]=J[14]+X[14],Z[15]=J[15]+X[15],Z}function AK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z[4]=J[4]-X[4],Z[5]=J[5]-X[5],Z[6]=J[6]-X[6],Z[7]=J[7]-X[7],Z[8]=J[8]-X[8],Z[9]=J[9]-X[9],Z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],x=J[10],I=J[11],S=J[12],y=J[13],m=J[14],i=J[15];return Math.abs(X-N)<=v0*Math.max(1,Math.abs(X),Math.abs(N))&&Math.abs(Y-R)<=v0*Math.max(1,Math.abs(Y),Math.abs(R))&&Math.abs($-O)<=v0*Math.max(1,Math.abs($),Math.abs(O))&&Math.abs(Q-P)<=v0*Math.max(1,Math.abs(Q),Math.abs(P))&&Math.abs(W-D)<=v0*Math.max(1,Math.abs(W),Math.abs(D))&&Math.abs(K-C)<=v0*Math.max(1,Math.abs(K),Math.abs(C))&&Math.abs(G-T)<=v0*Math.max(1,Math.abs(G),Math.abs(T))&&Math.abs(z-k)<=v0*Math.max(1,Math.abs(z),Math.abs(k))&&Math.abs(H-A)<=v0*Math.max(1,Math.abs(H),Math.abs(A))&&Math.abs(V-v)<=v0*Math.max(1,Math.abs(V),Math.abs(v))&&Math.abs(q-x)<=v0*Math.max(1,Math.abs(q),Math.abs(x))&&Math.abs(F-I)<=v0*Math.max(1,Math.abs(F),Math.abs(I))&&Math.abs(U-S)<=v0*Math.max(1,Math.abs(U),Math.abs(S))&&Math.abs(B-y)<=v0*Math.max(1,Math.abs(B),Math.abs(y))&&Math.abs(w-m)<=v0*Math.max(1,Math.abs(w),Math.abs(m))&&Math.abs(j-i)<=v0*Math.max(1,Math.abs(j),Math.abs(i))}var OY6=EK1,MY6=AK1;var C1={};_9(C1,{str:()=>B$6,squaredLength:()=>G31,sqrLen:()=>C$6,sqlerp:()=>I$6,slerp:()=>EN,setAxisAngle:()=>Z31,setAxes:()=>v$6,set:()=>M$6,scale:()=>Q31,rotationTo:()=>E$6,rotateZ:()=>z$6,rotateY:()=>G$6,rotateX:()=>K$6,random:()=>q$6,pow:()=>V$6,normalize:()=>og,multiply:()=>J31,mul:()=>N$6,ln:()=>Y31,lerp:()=>D$6,length:()=>K31,len:()=>P$6,invert:()=>F$6,identity:()=>$$6,getAxisAngle:()=>Q$6,getAngle:()=>W$6,fromValues:()=>j$6,fromMat3:()=>$31,fromEuler:()=>w$6,exp:()=>X31,exactEquals:()=>T$6,equals:()=>k$6,dot:()=>W31,create:()=>sg,copy:()=>O$6,conjugate:()=>U$6,clone:()=>L$6,calculateW:()=>H$6,add:()=>R$6});var J1={};_9(J1,{zero:()=>pY6,transformQuat:()=>mY6,transformMat4:()=>yY6,transformMat3:()=>gY6,subtract:()=>hK1,sub:()=>sY6,str:()=>iY6,squaredLength:()=>mK1,squaredDistance:()=>gK1,sqrLen:()=>Z$6,sqrDist:()=>eY6,set:()=>DY6,scaleAndAdd:()=>SY6,scale:()=>vY6,round:()=>IY6,rotateZ:()=>cY6,rotateY:()=>dY6,rotateX:()=>uY6,random:()=>bY6,normalize:()=>ng,negate:()=>_Y6,multiply:()=>fK1,mul:()=>oY6,min:()=>kY6,max:()=>EY6,lerp:()=>xY6,length:()=>xK1,len:()=>ag,inverse:()=>AY6,hermite:()=>hY6,fromValues:()=>TN,forEach:()=>J$6,floor:()=>TY6,exactEquals:()=>nY6,equals:()=>aY6,dot:()=>kN,divide:()=>bK1,div:()=>rY6,distance:()=>yK1,dist:()=>tY6,cross:()=>ZU,create:()=>CN,copy:()=>NY6,clone:()=>RY6,ceil:()=>CY6,bezier:()=>fY6,angle:()=>lY6,add:()=>PY6});function CN(){var Z=new z1(3);if(z1!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function RY6(Z){var J=new z1(3);return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function xK1(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function TN(Z,J,X){var Y=new z1(3);return Y[0]=Z,Y[1]=J,Y[2]=X,Y}function NY6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function DY6(Z,J,X,Y){return Z[0]=J,Z[1]=X,Z[2]=Y,Z}function PY6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z}function hK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z}function fK1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function bK1(Z,J,X){return Z[0]=J[0]/X[0],Z[1]=J[1]/X[1],Z[2]=J[2]/X[2],Z}function CY6(Z,J){return Z[0]=Math.ceil(J[0]),Z[1]=Math.ceil(J[1]),Z[2]=Math.ceil(J[2]),Z}function TY6(Z,J){return Z[0]=Math.floor(J[0]),Z[1]=Math.floor(J[1]),Z[2]=Math.floor(J[2]),Z}function kY6(Z,J,X){return Z[0]=Math.min(J[0],X[0]),Z[1]=Math.min(J[1],X[1]),Z[2]=Math.min(J[2],X[2]),Z}function EY6(Z,J,X){return Z[0]=Math.max(J[0],X[0]),Z[1]=Math.max(J[1],X[1]),Z[2]=Math.max(J[2],X[2]),Z}function IY6(Z,J){return Z[0]=Math.round(J[0]),Z[1]=Math.round(J[1]),Z[2]=Math.round(J[2]),Z}function vY6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z}function SY6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z[2]=J[2]+X[2]*Y,Z}function yK1(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1],$=J[2]-Z[2];return Math.hypot(X,Y,$)}function gK1(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1],$=J[2]-Z[2];return X*X+Y*Y+$*$}function mK1(Z){var J=Z[0],X=Z[1],Y=Z[2];return J*J+X*X+Y*Y}function _Y6(Z,J){return Z[0]=-J[0],Z[1]=-J[1],Z[2]=-J[2],Z}function AY6(Z,J){return Z[0]=1/J[0],Z[1]=1/J[1],Z[2]=1/J[2],Z}function ng(Z,J){var X=J[0],Y=J[1],$=J[2],Q=X*X+Y*Y+$*$;if(Q>0)Q=1/Math.sqrt(Q);return Z[0]=J[0]*Q,Z[1]=J[1]*Q,Z[2]=J[2]*Q,Z}function kN(Z,J){return Z[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,J,X){var Y=X[0],$=X[1],Q=X[2],W=X[3],K=J[0],G=J[1],z=J[2],H=$*z-Q*G,V=Q*K-Y*z,q=Y*G-$*K,F=$*q-Q*V,U=Q*H-Y*q,B=Y*V-$*H,w=W*2;return H*=w,V*=w,q*=w,F*=2,U*=2,B*=2,Z[0]=K+H+F,Z[1]=G+V+U,Z[2]=z+q+B,Z}function uY6(Z,J,X,Y){var $=[],Q=[];return $[0]=J[0]-X[0],$[1]=J[1]-X[1],$[2]=J[2]-X[2],Q[0]=$[0],Q[1]=$[1]*Math.cos(Y)-$[2]*Math.sin(Y),Q[2]=$[1]*Math.sin(Y)+$[2]*Math.cos(Y),Z[0]=Q[0]+X[0],Z[1]=Q[1]+X[1],Z[2]=Q[2]+X[2],Z}function dY6(Z,J,X,Y){var $=[],Q=[];return $[0]=J[0]-X[0],$[1]=J[1]-X[1],$[2]=J[2]-X[2],Q[0]=$[2]*Math.sin(Y)+$[0]*Math.cos(Y),Q[1]=$[1],Q[2]=$[2]*Math.cos(Y)-$[0]*Math.sin(Y),Z[0]=Q[0]+X[0],Z[1]=Q[1]+X[1],Z[2]=Q[2]+X[2],Z}function cY6(Z,J,X,Y){var $=[],Q=[];return $[0]=J[0]-X[0],$[1]=J[1]-X[1],$[2]=J[2]-X[2],Q[0]=$[0]*Math.cos(Y)-$[1]*Math.sin(Y),Q[1]=$[0]*Math.sin(Y)+$[1]*Math.cos(Y),Q[2]=$[2],Z[0]=Q[0]+X[0],Z[1]=Q[1]+X[1],Z[2]=Q[2]+X[2],Z}function lY6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=J[0],W=J[1],K=J[2],G=Math.sqrt(X*X+Y*Y+$*$),z=Math.sqrt(Q*Q+W*W+K*K),H=G*z,V=H&&kN(Z,J)/H;return Math.acos(Math.min(Math.max(V,-1),1))}function pY6(Z){return Z[0]=0,Z[1]=0,Z[2]=0,Z}function iY6(Z){return"vec3("+Z[0]+", "+Z[1]+", "+Z[2]+")"}function nY6(Z,J){return Z[0]===J[0]&&Z[1]===J[1]&&Z[2]===J[2]}function aY6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=J[0],W=J[1],K=J[2];return Math.abs(X-Q)<=v0*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(Y-W)<=v0*Math.max(1,Math.abs(Y),Math.abs(W))&&Math.abs($-K)<=v0*Math.max(1,Math.abs($),Math.abs(K))}var sY6=hK1,oY6=fK1,rY6=bK1,tY6=yK1,eY6=gK1,ag=xK1,Z$6=mK1,J$6=function(){var Z=CN();return function(J,X,Y,$,Q,W){var K,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(K=Y;K<G;K+=X)Z[0]=J[K],Z[1]=J[K+1],Z[2]=J[K+2],Q(Z,Z,W),J[K]=Z[0],J[K+1]=Z[1],J[K+2]=Z[2];return J}}();function X$6(){var Z=new z1(4);if(z1!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function uK1(Z){var J=new z1(4);return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function dK1(Z,J,X,Y){var $=new z1(4);return $[0]=Z,$[1]=J,$[2]=X,$[3]=Y,$}function cK1(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function lK1(Z,J,X,Y,$){return Z[0]=J,Z[1]=X,Z[2]=Y,Z[3]=$,Z}function pK1(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function iK1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function nK1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}function aK1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return J*J+X*X+Y*Y+$*$}function sK1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=X*X+Y*Y+$*$+Q*Q;if(W>0)W=1/Math.sqrt(W);return Z[0]=X*W,Z[1]=Y*W,Z[2]=$*W,Z[3]=Q*W,Z}function oK1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}function rK1(Z,J,X,Y){var $=J[0],Q=J[1],W=J[2],K=J[3];return Z[0]=$+Y*(X[0]-$),Z[1]=Q+Y*(X[1]-Q),Z[2]=W+Y*(X[2]-W),Z[3]=K+Y*(X[3]-K),Z}function tK1(Z,J){return Z[0]===J[0]&&Z[1]===J[1]&&Z[2]===J[2]&&Z[3]===J[3]}function eK1(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=Z[3],W=J[0],K=J[1],G=J[2],z=J[3];return Math.abs(X-W)<=v0*Math.max(1,Math.abs(X),Math.abs(W))&&Math.abs(Y-K)<=v0*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs($-G)<=v0*Math.max(1,Math.abs($),Math.abs(G))&&Math.abs(Q-z)<=v0*Math.max(1,Math.abs(Q),Math.abs(z))}var TX5=function(){var Z=X$6();return function(J,X,Y,$,Q,W){var K,G;if(!X)X=4;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(K=Y;K<G;K+=X)Z[0]=J[K],Z[1]=J[K+1],Z[2]=J[K+2],Z[3]=J[K+3],Q(Z,Z,W),J[K]=Z[0],J[K+1]=Z[1],J[K+2]=Z[2],J[K+3]=Z[3];return J}}();function sg(){var Z=new z1(4);if(z1!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z[3]=1,Z}function $$6(Z){return Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=1,Z}function Z31(Z,J,X){X=X*0.5;var Y=Math.sin(X);return Z[0]=Y*J[0],Z[1]=Y*J[1],Z[2]=Y*J[2],Z[3]=Math.cos(X),Z}function Q$6(Z,J){var X=Math.acos(J[3])*2,Y=Math.sin(X/2);if(Y>v0)Z[0]=J[0]/Y,Z[1]=J[1]/Y,Z[2]=J[2]/Y;else Z[0]=1,Z[1]=0,Z[2]=0;return X}function W$6(Z,J){var X=W31(Z,J);return Math.acos(2*X*X-1)}function J31(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=X[0],G=X[1],z=X[2],H=X[3];return Z[0]=Y*H+W*K+$*z-Q*G,Z[1]=$*H+W*G+Q*K-Y*z,Z[2]=Q*H+W*z+Y*G-$*K,Z[3]=W*H-Y*K-$*G-Q*z,Z}function K$6(Z,J,X){X*=0.5;var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G+W*K,Z[1]=$*G+Q*K,Z[2]=Q*G-$*K,Z[3]=W*G-Y*K,Z}function G$6(Z,J,X){X*=0.5;var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G-Q*K,Z[1]=$*G+W*K,Z[2]=Q*G+Y*K,Z[3]=W*G-$*K,Z}function z$6(Z,J,X){X*=0.5;var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G+$*K,Z[1]=$*G-Y*K,Z[2]=Q*G+W*K,Z[3]=W*G-Q*K,Z}function H$6(Z,J){var X=J[0],Y=J[1],$=J[2];return Z[0]=X,Z[1]=Y,Z[2]=$,Z[3]=Math.sqrt(Math.abs(1-X*X-Y*Y-$*$)),Z}function X31(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=Math.sqrt(X*X+Y*Y+$*$),K=Math.exp(Q),G=W>0?K*Math.sin(W)/W:0;return Z[0]=X*G,Z[1]=Y*G,Z[2]=$*G,Z[3]=K*Math.cos(W),Z}function Y31(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=Math.sqrt(X*X+Y*Y+$*$),K=W>0?Math.atan2(W,Q)/W:0;return Z[0]=X*K,Z[1]=Y*K,Z[2]=$*K,Z[3]=0.5*Math.log(X*X+Y*Y+$*$+Q*Q),Z}function V$6(Z,J,X){return Y31(Z,J),Q31(Z,Z,X),X31(Z,Z),Z}function EN(Z,J,X,Y){var $=J[0],Q=J[1],W=J[2],K=J[3],G=X[0],z=X[1],H=X[2],V=X[3],q,F,U,B,w;if(F=$*G+Q*z+W*H+K*V,F<0)F=-F,G=-G,z=-z,H=-H,V=-V;if(1-F>v0)q=Math.acos(F),U=Math.sin(q),B=Math.sin((1-Y)*q)/U,w=Math.sin(Y*q)/U;else B=1-Y,w=Y;return Z[0]=B*$+w*G,Z[1]=B*Q+w*z,Z[2]=B*W+w*H,Z[3]=B*K+w*V,Z}function q$6(Z){var J=jZ(),X=jZ(),Y=jZ(),$=Math.sqrt(1-J),Q=Math.sqrt(J);return Z[0]=$*Math.sin(2*Math.PI*X),Z[1]=$*Math.cos(2*Math.PI*X),Z[2]=Q*Math.sin(2*Math.PI*Y),Z[3]=Q*Math.cos(2*Math.PI*Y),Z}function F$6(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=X*X+Y*Y+$*$+Q*Q,K=W?1/W:0;return Z[0]=-X*K,Z[1]=-Y*K,Z[2]=-$*K,Z[3]=Q*K,Z}function U$6(Z,J){return Z[0]=-J[0],Z[1]=-J[1],Z[2]=-J[2],Z[3]=J[3],Z}function $31(Z,J){var X=J[0]+J[4]+J[8],Y;if(X>0)Y=Math.sqrt(X+1),Z[3]=0.5*Y,Y=0.5/Y,Z[0]=(J[5]-J[7])*Y,Z[1]=(J[6]-J[2])*Y,Z[2]=(J[1]-J[3])*Y;else{var $=0;if(J[4]>J[0])$=1;if(J[8]>J[$*3+$])$=2;var Q=($+1)%3,W=($+2)%3;Y=Math.sqrt(J[$*3+$]-J[Q*3+Q]-J[W*3+W]+1),Z[$]=0.5*Y,Y=0.5/Y,Z[3]=(J[Q*3+W]-J[W*3+Q])*Y,Z[Q]=(J[Q*3+$]+J[$*3+Q])*Y,Z[W]=(J[W*3+$]+J[$*3+W])*Y}return Z}function w$6(Z,J,X,Y){var $=0.5*Math.PI/180;J*=$,X*=$,Y*=$;var Q=Math.sin(J),W=Math.cos(J),K=Math.sin(X),G=Math.cos(X),z=Math.sin(Y),H=Math.cos(Y);return Z[0]=Q*G*H-W*K*z,Z[1]=W*K*H+Q*G*z,Z[2]=W*G*z-Q*K*H,Z[3]=W*G*H+Q*K*z,Z}function B$6(Z){return"quat("+Z[0]+", "+Z[1]+", "+Z[2]+", "+Z[3]+")"}var L$6=uK1,j$6=dK1,O$6=cK1,M$6=lK1,R$6=pK1,N$6=J31,Q31=iK1,W31=oK1,D$6=rK1,K31=nK1,P$6=K31,G31=aK1,C$6=G31,og=sK1,T$6=tK1,k$6=eK1,E$6=function(){var Z=CN(),J=TN(1,0,0),X=TN(0,1,0);return function(Y,$,Q){var W=kN($,Q);if(W<-0.999999){if(ZU(Z,J,$),ag(Z)<0.000001)ZU(Z,X,$);return ng(Z,Z),Z31(Y,Z,Math.PI),Y}else if(W>0.999999)return Y[0]=0,Y[1]=0,Y[2]=0,Y[3]=1,Y;else return ZU(Z,$,Q),Y[0]=Z[0],Y[1]=Z[1],Y[2]=Z[2],Y[3]=1+W,og(Y,Y)}}(),I$6=function(){var Z=sg(),J=sg();return function(X,Y,$,Q,W,K){return EN(Z,Y,W,K),EN(J,$,Q,K),EN(X,Z,J,2*K*(1-K)),X}}(),v$6=function(){var Z=ig();return function(J,X,Y,$){return Z[0]=Y[0],Z[3]=Y[1],Z[6]=Y[2],Z[1]=$[0],Z[4]=$[1],Z[7]=$[2],Z[2]=-X[0],Z[5]=-X[1],Z[8]=-X[2],og(J,$31(J,Z))}}();var q1={};_9(q1,{zero:()=>XQ6,transformMat4:()=>e$6,transformMat3:()=>t$6,transformMat2d:()=>r$6,transformMat2:()=>o$6,subtract:()=>H31,sub:()=>KQ6,str:()=>YQ6,squaredLength:()=>B31,squaredDistance:()=>U31,sqrLen:()=>qQ6,sqrDist:()=>VQ6,set:()=>x$6,scaleAndAdd:()=>d$6,scale:()=>u$6,round:()=>m$6,rotate:()=>ZQ6,random:()=>s$6,normalize:()=>p$6,negate:()=>c$6,multiply:()=>V31,mul:()=>GQ6,min:()=>y$6,max:()=>g$6,lerp:()=>a$6,length:()=>w31,len:()=>WQ6,inverse:()=>l$6,fromValues:()=>_$6,forEach:()=>FQ6,floor:()=>b$6,exactEquals:()=>$Q6,equals:()=>QQ6,dot:()=>i$6,divide:()=>q31,div:()=>zQ6,distance:()=>F31,dist:()=>HQ6,cross:()=>n$6,create:()=>z31,copy:()=>A$6,clone:()=>S$6,ceil:()=>f$6,angle:()=>JQ6,add:()=>h$6});function z31(){var Z=new z1(2);if(z1!=Float32Array)Z[0]=0,Z[1]=0;return Z}function S$6(Z){var J=new z1(2);return J[0]=Z[0],J[1]=Z[1],J}function _$6(Z,J){var X=new z1(2);return X[0]=Z,X[1]=J,X}function A$6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z}function x$6(Z,J,X){return Z[0]=J,Z[1]=X,Z}function h$6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z}function H31(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z}function V31(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z}function q31(Z,J,X){return Z[0]=J[0]/X[0],Z[1]=J[1]/X[1],Z}function f$6(Z,J){return Z[0]=Math.ceil(J[0]),Z[1]=Math.ceil(J[1]),Z}function b$6(Z,J){return Z[0]=Math.floor(J[0]),Z[1]=Math.floor(J[1]),Z}function y$6(Z,J,X){return Z[0]=Math.min(J[0],X[0]),Z[1]=Math.min(J[1],X[1]),Z}function g$6(Z,J,X){return Z[0]=Math.max(J[0],X[0]),Z[1]=Math.max(J[1],X[1]),Z}function m$6(Z,J){return Z[0]=Math.round(J[0]),Z[1]=Math.round(J[1]),Z}function u$6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z}function d$6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z}function F31(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1];return Math.hypot(X,Y)}function U31(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1];return X*X+Y*Y}function w31(Z){var J=Z[0],X=Z[1];return Math.hypot(J,X)}function B31(Z){var J=Z[0],X=Z[1];return J*J+X*X}function c$6(Z,J){return Z[0]=-J[0],Z[1]=-J[1],Z}function l$6(Z,J){return Z[0]=1/J[0],Z[1]=1/J[1],Z}function p$6(Z,J){var X=J[0],Y=J[1],$=X*X+Y*Y;if($>0)$=1/Math.sqrt($);return Z[0]=J[0]*$,Z[1]=J[1]*$,Z}function i$6(Z,J){return Z[0]*J[0]+Z[1]*J[1]}function n$6(Z,J,X){var Y=J[0]*X[1]-J[1]*X[0];return Z[0]=Z[1]=0,Z[2]=Y,Z}function a$6(Z,J,X,Y){var $=J[0],Q=J[1];return Z[0]=$+Y*(X[0]-$),Z[1]=Q+Y*(X[1]-Q),Z}function s$6(Z,J){J=J||1;var X=jZ()*2*Math.PI;return Z[0]=Math.cos(X)*J,Z[1]=Math.sin(X)*J,Z}function o$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[2]*$,Z[1]=X[1]*Y+X[3]*$,Z}function r$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[2]*$+X[4],Z[1]=X[1]*Y+X[3]*$+X[5],Z}function t$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[3]*$+X[6],Z[1]=X[1]*Y+X[4]*$+X[7],Z}function e$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[4]*$+X[12],Z[1]=X[1]*Y+X[5]*$+X[13],Z}function ZQ6(Z,J,X,Y){var $=J[0]-X[0],Q=J[1]-X[1],W=Math.sin(Y),K=Math.cos(Y);return Z[0]=$*K-Q*W+X[0],Z[1]=$*W+Q*K+X[1],Z}function JQ6(Z,J){var X=Z[0],Y=Z[1],$=J[0],Q=J[1],W=Math.sqrt(X*X+Y*Y)*Math.sqrt($*$+Q*Q),K=W&&(X*$+Y*Q)/W;return Math.acos(Math.min(Math.max(K,-1),1))}function XQ6(Z){return Z[0]=0,Z[1]=0,Z}function YQ6(Z){return"vec2("+Z[0]+", "+Z[1]+")"}function $Q6(Z,J){return Z[0]===J[0]&&Z[1]===J[1]}function QQ6(Z,J){var X=Z[0],Y=Z[1],$=J[0],Q=J[1];return Math.abs(X-$)<=v0*Math.max(1,Math.abs(X),Math.abs($))&&Math.abs(Y-Q)<=v0*Math.max(1,Math.abs(Y),Math.abs(Q))}var WQ6=w31,KQ6=H31,GQ6=V31,zQ6=q31,HQ6=F31,VQ6=U31,qQ6=B31,FQ6=function(){var Z=z31();return function(J,X,Y,$,Q,W){var K,G;if(!X)X=2;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(K=Y;K<G;K+=X)Z[0]=J[K],Z[1]=J[K+1],Q(Z,Z,W),J[K]=Z[0],J[K+1]=Z[1];return J}}();class tQ extends Float32Array{constructor(Z,J,X,Y){super([Z,J,X,Y])}get determinant(){return i8.determinant(this)}get frobeniusNorm(){return i8.frob(this)}static create(){let Z=new tQ(0,0,0,0);return i8.identity(Z),Z}static fromRotation(Z){let J=tQ.create();return i8.fromRotation(J,Z),J}static fromScaling(Z){let J=tQ.create();return i8.fromScaling(J,Z),J}add(Z){return i8.add(this,this,Z),this}adjoint(){return i8.adjoint(this,this),this}clone(){return new tQ(this[0],this[1],this[2],this[3])}copy(Z){return i8.copy(this,Z),this}equals(Z){return i8.equals(this,Z)}exactEquals(Z){return i8.exactEquals(this,Z)}identity(){return i8.identity(this),this}invert(){return i8.invert(this,this),this}multiply(Z){return i8.mul(this,this,Z),this}multiplyScalar(Z){return i8.multiplyScalar(this,this,Z),this}rotate(Z){return i8.rotate(this,this,Z),this}subtract(Z){return i8.sub(this,this,Z),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return i8.transpose(this,this),this}}class OZ extends Float32Array{constructor(Z,J,X,Y,$,Q,W,K,G){super([Z,J,X,Y,$,Q,W,K,G])}get determinant(){return e1.determinant(this)}get frobeniusNorm(){return e1.frob(this)}static create(){let Z=new OZ(0,0,0,0,0,0,0,0,0);return e1.identity(Z),Z}static fromMatrix4(Z){let J=OZ.create();return e1.fromMat4(J,Z),J}static fromQuaternion(Z){let J=OZ.create();return e1.fromQuat(J,Z),J}static fromRotation(Z){let J=OZ.create();return e1.fromRotation(J,Z),J}static fromScaling(Z){let J=OZ.create();return e1.fromScaling(J,Z),J}static fromTranslation(Z){let J=OZ.create();return e1.fromTranslation(J,Z),J}add(Z){return e1.add(this,this,Z),this}adjoint(){return e1.adjoint(this,this),this}clone(){return new OZ(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(Z){return e1.copy(this,Z),this}equals(Z){return e1.equals(this,Z)}exactEquals(Z){return e1.exactEquals(this,Z)}identity(){return e1.identity(this),this}invert(){return e1.invert(this,this),this}multiply(Z){return e1.mul(this,this,Z),this}multiplyScalar(Z){return e1.multiplyScalar(this,this,Z),this}transformVector(Z){return Z.transformMatrix3(this)}projection(Z,J){return e1.projection(this,Z,J),this}rotate(Z){return e1.rotate(this,this,Z),this}subtract(Z){return e1.sub(this,this,Z),this}toString(){return`[${this[0]},${this[1]},${this[2]}][${this[3]},${this[4]},${this[5]}][${this[6]},${this[7]},${this[8]}]`}transpose(){return e1.transpose(this,this),this}}class k5 extends Float32Array{constructor(Z,J,X,Y,$,Q,W,K,G,z,H,V,q,F,U,B){super([Z,J,X,Y,$,Q,W,K,G,z,H,V,q,F,U,B])}get determinant(){return r0.determinant(this)}get frobeniusNorm(){return r0.frob(this)}static create(){let Z=new k5(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return r0.identity(Z),Z}static fromQuaternion(Z){let J=k5.create();return r0.fromQuat(J,Z),J}static fromRotation(Z,J){let X=k5.create();return r0.fromRotation(X,Z,J),X}static fromRotationTranslation(Z,J){let X=k5.create();return r0.fromRotationTranslation(X,Z,J),X}static fromRotationTranslationScale(Z,J,X){let Y=k5.create();return r0.fromRotationTranslationScale(Y,Z,J,X),Y}static fromRotationTranslationScaleOrigin(Z,J,X,Y){let $=k5.create();return r0.fromRotationTranslationScaleOrigin($,Z,J,X,Y),$}static fromScaling(Z){let J=k5.create();return r0.fromScaling(J,Z),J}static fromTranslation(Z){let J=k5.create();return r0.fromTranslation(J,Z),J}static fromXRotation(Z){let J=k5.create();return r0.fromXRotation(J,Z),J}static fromYRotation(Z){let J=k5.create();return r0.fromYRotation(J,Z),J}static fromZRotation(Z){let J=k5.create();return r0.fromZRotation(J,Z),J}add(Z){return r0.add(this,this,Z),this}adjoint(){return r0.adjoint(this,this),this}clone(){return new k5(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(Z){return r0.copy(this,Z),this}equals(Z){return r0.equals(this,Z)}exactEquals(Z){return r0.exactEquals(this,Z)}frustrum(Z,J,X,Y,$,Q){return r0.frustum(this,Z,J,X,Y,$,Q),this}identity(){return r0.identity(this),this}invert(){return r0.invert(this,this),this}lookAt(Z,J,X){return r0.lookAt(this,Z,J,X),this}multiply(Z){return r0.mul(this,this,Z),this}multiplyScalar(Z){return r0.multiplyScalar(this,this,Z),this}orthographic(Z,J,X,Y,$,Q){return r0.ortho(this,Z,J,X,Y,$,Q),this}perspective(Z,J,X,Y){return r0.perspective(this,Z,J,X,Y),this}rotate(Z,J){return r0.rotate(this,this,Z,J),this}rotateX(Z){return r0.rotateX(this,this,Z),this}rotateY(Z){return r0.rotateY(this,this,Z),this}rotateZ(Z){return r0.rotateZ(this,this,Z),this}scale(Z){return r0.scale(this,this,Z),this}subtract(Z){return r0.sub(this,this,Z),this}targetTo(Z,J,X){return r0.targetTo(this,Z,J,X),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(Z){return r0.translate(this,this,Z),this}transpose(){return r0.transpose(this,this),this}}class QG extends Float32Array{constructor(Z,J,X,Y){super([Z,J,X,Y])}get length(){return C1.length(this)}get squaredLength(){return C1.squaredLength(this)}get magnitude(){return C1.length(this)}get squaredMagnitude(){return C1.squaredLength(this)}get x(){return this[0]}set x(Z){this[0]=Z}get y(){return this[1]}set y(Z){this[1]=Z}get z(){return this[2]}set z(Z){this[2]=Z}get w(){return this[3]}set w(Z){this[3]=Z}static fromEuler(Z,J,X){let Y=C1.fromEuler(new Float32Array(4),Z,J,X);return new QG(Y[0],Y[1],Y[2],Y[3])}static fromQuaternionLike(Z){return new QG(Z.x,Z.y,Z.z,Z.w)}clone(){return new QG(this.x,this.y,this.z,this.w)}conjugate(){return C1.conjugate(this,this),this}copy(Z){return C1.copy(this,Z),this}dot(Z){return C1.dot(this,Z)}exponential(){return C1.exp(this,this),this}equals(Z){return C1.equals(this,Z)}exactEquals(Z){return C1.exactEquals(this,Z)}getAngle(Z){return C1.getAngle(this,Z)}identity(){return C1.identity(this),this}invert(){return C1.invert(this,this),this}lerp(Z,J){return C1.lerp(this,this,Z,J),this}logarithm(){return C1.ln(this,this),this}multiply(Z){return C1.multiply(this,this,Z),this}transformVector(Z){return Z.transformQuaternion(this)}normalize(){return C1.normalize(this,this),this}power(Z){return C1.pow(this,this,Z),this}randomize(){return C1.random(this),this}rotateX(Z){return C1.rotateX(this,this,Z),this}rotateY(Z){return C1.rotateY(this,this,Z),this}rotateZ(Z){return C1.rotateZ(this,this,Z),this}scale(Z){return C1.scale(this,this,Z),this}setAxisAngle(Z,J){return C1.setAxisAngle(this,Z,J),this}slerp(Z,J){return C1.slerp(this,this,Z,J),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class JU extends Float32Array{constructor(Z,J){super([Z,J])}get length(){return q1.length(this)}get squaredLength(){return q1.squaredLength(this)}get magnitude(){return q1.length(this)}get squaredMagnitude(){return q1.squaredLength(this)}get x(){return this[0]}set x(Z){this[0]=Z}get y(){return this[1]}set y(Z){this[1]=Z}static create(){return new JU(0,0)}add(Z){return q1.add(this,this,Z),this}angle(Z){return q1.angle(this,Z)}ceil(){return q1.ceil(this,this),this}clone(){return new JU(this.x,this.y)}copy(Z){return q1.copy(this,Z),this}distance(Z){return q1.distance(this,Z)}divide(Z){return q1.divide(this,this,Z),this}dot(Z){return q1.dot(this,Z)}equals(Z){return q1.equals(this,Z)}exactEquals(Z){return q1.exactEquals(this,Z)}floor(){return q1.floor(this,this),this}invert(){return q1.inverse(this,this),this}lerp(Z,J){return q1.lerp(this,this,Z,J),this}max(Z){return q1.max(this,this,Z),this}min(Z){return q1.min(this,this,Z),this}multiply(Z){return q1.mul(this,this,Z),this}negate(){return q1.negate(this,this),this}normalize(){return q1.normalize(this,this),this}randomize(Z){return q1.random(this,Z),this}rotate(Z,J){return q1.rotate(this,this,Z,J),this}round(){return q1.round(this,this),this}scale(Z){return q1.scale(this,this,Z),this}scaleAndAdd(Z,J){return q1.scaleAndAdd(this,this,Z,J),this}subtract(Z){return q1.sub(this,this,Z),this}toString(){return`${this.x},${this.y}`}transformMatrix2(Z){return q1.transformMat2(this,this,Z),this}transformMatrix3(Z){return q1.transformMat3(this,this,Z),this}transformMatrix4(Z){return q1.transformMat4(this,this,Z),this}zero(){return q1.zero(this),this}}class WG extends Float32Array{constructor(Z,J,X){super([Z,J,X])}get length(){return J1.length(this)}get squaredLength(){return J1.squaredLength(this)}get magnitude(){return J1.length(this)}get squaredMagnitude(){return J1.squaredLength(this)}get x(){return this[0]}set x(Z){this[0]=Z}get y(){return this[1]}set y(Z){this[1]=Z}get z(){return this[2]}set z(Z){this[2]=Z}static create(){return new WG(0,0,0)}static fromVector3Like(Z){return new WG(Z.x,Z.y,Z.z)}add(Z){return J1.add(this,this,Z),this}ceil(){return J1.ceil(this,this),this}clone(){return new WG(this.x,this.y,this.z)}copy(Z){return J1.copy(this,Z),this}cross(Z){return J1.cross(this,this,Z),this}distance(Z){return J1.distance(this,Z)}divide(Z){return J1.div(this,this,Z),this}dot(Z){return J1.dot(this,Z)}equals(Z){return J1.equals(this,Z)}exactEquals(Z){return J1.exactEquals(this,Z)}floor(){return J1.floor(this,this),this}invert(){return J1.inverse(this,this),this}lerp(Z,J){return J1.lerp(this,this,Z,J),this}max(Z){return J1.max(this,this,Z),this}min(Z){return J1.min(this,this,Z),this}multiply(Z){return J1.mul(this,this,Z),this}negate(){return J1.negate(this,this),this}normalize(){return J1.normalize(this,this),this}randomize(Z){return J1.random(this,Z),this}rotateX(Z,J){return J1.rotateX(this,this,Z,J),this}rotateY(Z,J){return J1.rotateY(this,this,Z,J),this}rotateZ(Z,J){return J1.rotateZ(this,this,Z,J),this}round(){return J1.round(this,this),this}scale(Z){return J1.scale(this,this,Z),this}scaleAndAdd(Z,J){return J1.scaleAndAdd(this,this,Z,J),this}subtract(Z){return J1.sub(this,this,Z),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(Z){return J1.transformMat3(this,this,Z),this}transformMatrix4(Z){return J1.transformMat4(this,this,Z),this}transformQuaternion(Z){return J1.transformQuat(this,this,Z),this}zero(){return J1.zero(this),this}}var T1=function(Z,J,X,Y){function $(Q){return Q instanceof X?Q:new X(function(W){W(Q)})}return new(X||(X=Promise))(function(Q,W){function K(H){try{z(Y.next(H))}catch(V){W(V)}}function G(H){try{z(Y.throw(H))}catch(V){W(V)}}function z(H){H.done?Q(H.value):$(H.value).then(K,G)}z((Y=Y.apply(Z,J||[])).next())})},D1=function(Z,J){var X={label:0,sent:function(){if(Q[0]&1)throw Q[1];return Q[1]},trys:[],ops:[]},Y,$,Q,W=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return W.next=K(0),W.throw=K(1),W.return=K(2),typeof Symbol==="function"&&(W[Symbol.iterator]=function(){return this}),W;function K(z){return function(H){return G([z,H])}}function G(z){if(Y)throw new TypeError("Generator is already executing.");while(W&&(W=0,z[0]&&(X=0)),X)try{if(Y=1,$&&(Q=z[0]&2?$.return:z[0]?$.throw||((Q=$.return)&&Q.call($),0):$.next)&&!(Q=Q.call($,z[1])).done)return Q;if($=0,Q)z=[z[0]&2,Q.value];switch(z[0]){case 0:case 1:Q=z;break;case 4:return X.label++,{value:z[1],done:!1};case 5:X.label++,$=z[1],z=[0];continue;case 7:z=X.ops.pop(),X.trys.pop();continue;default:if((Q=X.trys,!(Q=Q.length>0&&Q[Q.length-1]))&&(z[0]===6||z[0]===2)){X=0;continue}if(z[0]===3&&(!Q||z[1]>Q[0]&&z[1]<Q[3])){X.label=z[1];break}if(z[0]===6&&X.label<Q[1]){X.label=Q[1],Q=z;break}if(Q&&X.label<Q[2]){X.label=Q[2],X.ops.push(z);break}if(Q[2])X.ops.pop();X.trys.pop();continue}z=J.call(Z,X)}catch(H){z=[6,H],$=0}finally{Y=Q=0}if(z[0]&5)throw z[1];return{value:z[0]?z[1]:void 0,done:!0}}},X9=function(Z,J){var X=typeof Symbol==="function"&&Z[Symbol.iterator];if(!X)return Z;var Y=X.call(Z),$,Q=[],W;try{while((J===void 0||J-- >0)&&!($=Y.next()).done)Q.push($.value)}catch(K){W={error:K}}finally{try{if($&&!$.done&&(X=Y.return))X.call(Y)}finally{if(W)throw W.error}}return Q},T4=function(Z,J,X){if(X||arguments.length===2){for(var Y=0,$=J.length,Q;Y<$;Y++)if(Q||!(Y in J)){if(!Q)Q=Array.prototype.slice.call(J,0,Y);Q[Y]=J[Y]}}return Z.concat(Q||Array.prototype.slice.call(J))},L31=function(Z){var J=typeof Symbol==="function"&&Symbol.iterator,X=J&&Z[J],Y=0;if(X)return X.call(Z);if(Z&&typeof Z.length==="number")return{next:function(){if(Z&&Y>=Z.length)Z=void 0;return{value:Z&&Z[Y++],done:!Z}}};throw new TypeError(J?"Object is not iterable.":"Symbol.iterator is not defined.")},AX5=function(){function Z(J){if(J===void 0)J=Z.minComparator;var X=this;this.compare=J,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(Y,$){return X.compare(Y,$).then(function(Q){return-1*Q})}}return Z.getChildrenIndexOf=function(J){return[J*2+1,J*2+2]},Z.getParentIndexOf=function(J){if(J<=0)return-1;var X=J%2?1:2;return Math.floor((J-X)/2)},Z.getSiblingIndexOf=function(J){if(J<=0)return-1;var X=J%2?1:-1;return J+X},Z.minComparator=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){if(J>X)return[2,1];else if(J<X)return[2,-1];else return[2,0]})})},Z.maxComparator=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){if(X>J)return[2,1];else if(X<J)return[2,-1];else return[2,0]})})},Z.minComparatorNumber=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){return[2,J-X]})})},Z.maxComparatorNumber=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){return[2,X-J]})})},Z.defaultIsEqual=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){return[2,J===X]})})},Z.print=function(J){function X(H){var V=Z.getParentIndexOf(H);return Math.floor(Math.log2(V+1))}function Y(H,V){var q="";for(;V>0;--V)q+=H;return q}var $=0,Q=[],W=X(J.length-1)+2,K=0;while($<J.length){var G=X($)+1;if($===0)G=0;var z=String(J.get($));if(z.length>K)K=z.length;Q[G]=Q[G]||[],Q[G].push(z),$+=1}return Q.map(function(H,V){var q=Math.pow(2,W-V)-1;return Y(" ",Math.floor(q/2)*K)+H.map(function(F){var U=(K-F.length)/2;return Y(" ",Math.ceil(U))+F+Y(" ",Math.floor(U))}).join(Y(" ",q*K))}).join(`
485
+ >>> no match, partial?`,Z,V,J,q),V===K)return!0}return!1}let U;if(typeof z==="string")U=H===z,this.debug("string match",z,H,U);else U=z.test(H),this.debug("pattern match",z,H,U);if(!U)return!1}if(Q===K&&W===G)return!0;else if(Q===K)return X;else if(W===G)return Q===K-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return P71(this.pattern,this.options)}parse(Z){PF(Z);let J=this.options;if(Z==="**")return R4;if(Z==="")return"";let X,Y=null;if(X=Z.match(n66))Y=J.dot?s66:a66;else if(X=Z.match(b66))Y=(J.nocase?J.dot?u66:m66:J.dot?g66:y66)(X[1]);else if(X=Z.match(o66))Y=(J.nocase?J.dot?t66:r66:J.dot?e66:Z56)(X);else if(X=Z.match(d66))Y=J.dot?l66:c66;else if(X=Z.match(p66))Y=i66;let $=k6.fromGlob(Z,this.options).toMMPattern();if(Y&&typeof $==="object")Reflect.defineProperty($,"test",{value:Y});return $}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Z=this.set;if(!Z.length)return this.regexp=!1,this.regexp;let J=this.options,X=J.noglobstar?Y56:J.dot?$56:Q56,Y=new Set(J.nocase?["i"]:[]),$=Z.map((K)=>{let G=K.map((z)=>{if(z instanceof RegExp)for(let H of z.flags.split(""))Y.add(H);return typeof z==="string"?H56(z):z===R4?R4:z._src});return G.forEach((z,H)=>{let V=G[H+1],q=G[H-1];if(z!==R4||q===R4)return;if(q===void 0)if(V!==void 0&&V!==R4)G[H+1]="(?:\\/|"+X+"\\/)?"+V;else G[H]=X;else if(V===void 0)G[H-1]=q+"(?:\\/|"+X+")?";else if(V!==R4)G[H-1]=q+"(?:\\/|\\/"+X+"\\/)"+V,G[H+1]=R4}),G.filter((z)=>z!==R4).join("/")}).join("|"),[Q,W]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+W+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(K){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let Y=this.slashSplit(Z);this.debug(this.pattern,"split",Y);let $=this.set;this.debug(this.pattern,"set",$);let Q=Y[Y.length-1];if(!Q)for(let W=Y.length-2;!Q&&W>=0;W--)Q=Y[W];for(let W=0;W<$.length;W++){let K=$[W],G=Y;if(X.matchBase&&K.length===1)G=[Q];if(this.matchOne(G,K,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return E6.defaults(Z).Minimatch}}E6.AST=k6;E6.Minimatch=TF;E6.escape=qy;E6.unescape=BY;var T71="@fastify/otel",q56="0.8.0",F56=">=4.0.0 <6",k71=["onRequest","preParsing","preValidation","preHandler","preSerialization","onSend","onResponse","onError"],r1={HOOK_NAME:"hook.name",FASTIFY_TYPE:"fastify.type",HOOK_CALLBACK_NAME:"hook.callback.name",ROOT:"fastify.root"},LY={ROUTE:"route-hook",INSTANCE:"hook",HANDLER:"request-handler"},xJ="anonymous",D5=Symbol("fastify otel instance"),jY=Symbol("fastify otel request spans"),kF=Symbol("fastify otel request context"),E71=Symbol("fastify otel addhook original"),I71=Symbol("fastify otel setnotfound original"),vR=Symbol("fastify otel ignore path");class Fy extends h8{constructor(Z){super(T71,q56,Z);if(this.servername=Z?.servername??process.env.OTEL_SERVICE_NAME??"fastify",this[vR]=null,this._logger=f8.diag.createComponentLogger({namespace:T71}),Z?.ignorePaths!=null||process.env.OTEL_FASTIFY_IGNORE_PATHS!=null){let J=Z?.ignorePaths??process.env.OTEL_FASTIFY_IGNORE_PATHS;if((typeof J!=="string"||J.length===0)&&typeof J!=="function")throw new TypeError("ignorePaths must be a string or a function");let X=E6;this[vR]=(Y)=>{if(typeof J==="function")return J(Y);else return X(Y.url,J)}}}enable(){if(this._handleInitialization===void 0&&this.getConfig().registerOnInitialization){let Z=this.plugin();this._handleInitialization=(J)=>{J.fastify.register(Z)},C71.subscribe("fastify.initialization",this._handleInitialization)}return super.enable()}disable(){if(this._handleInitialization)C71.unsubscribe("fastify.initialization",this._handleInitialization),this._handleInitialization=void 0;return super.disable()}init(){return[]}plugin(){let Z=this;return J[Symbol.for("skip-override")]=!0,J[Symbol.for("fastify.display-name")]="@fastify/otel",J[Symbol.for("plugin-meta")]={fastify:F56,name:"@fastify/otel"},J;function J(X,Y,$){X.decorate(D5,Z),X.decorate(E71,X.addHook),X.decorate(I71,X.setNotFoundHandler),X.decorateRequest("opentelemetry",function H(){let V=this[kF];return{span:this[jY],tracer:Z.tracer,context:V,inject:(F,U)=>{return f8.propagation.inject(V,F,U)},extract:(F,U)=>{return f8.propagation.extract(V,F,U)}}}),X.decorateRequest(jY,null),X.decorateRequest(kF,null),X.addHook("onRoute",function(H){if(Z[vR]?.(H)===!0){Z._logger.debug(`Ignoring route instrumentation ${H.method} ${H.url} because it matches the ignore path`);return}for(let V of k71)if(H[V]!=null){let q=H[V];if(typeof q==="function")H[V]=z(q,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - route -> ${V}`,[r1.FASTIFY_TYPE]:LY.ROUTE,[l8.ATTR_HTTP_ROUTE]:H.url,[r1.HOOK_CALLBACK_NAME]:q.name?.length>0?q.name:xJ});else if(Array.isArray(q)){let F=[];for(let U of q)F.push(z(U,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - route -> ${V}`,[r1.FASTIFY_TYPE]:LY.ROUTE,[l8.ATTR_HTTP_ROUTE]:H.url,[r1.HOOK_CALLBACK_NAME]:U.name?.length>0?U.name:xJ}));H[V]=F}}if(H.onSend!=null)H.onSend=Array.isArray(H.onSend)?[...H.onSend,Q]:[H.onSend,Q];else H.onSend=Q;if(H.onError!=null)H.onError=Array.isArray(H.onError)?[...H.onError,W]:[H.onError,W];else H.onError=W;H.handler=z(H.handler,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - route-handler`,[r1.FASTIFY_TYPE]:LY.HANDLER,[l8.ATTR_HTTP_ROUTE]:H.url,[r1.HOOK_CALLBACK_NAME]:H.handler.name.length>0?H.handler.name:xJ})}),X.addHook("onRequest",function(H,V,q){if(this[D5].isEnabled()===!1)return q();else if(this[D5][vR]?.({url:H.url,method:H.method})===!0)return this[D5]._logger.debug(`Ignoring request ${H.method} ${H.url} because it matches the ignore path`),q();let F=f8.context.active();if(f8.trace.getSpan(F)==null)F=f8.propagation.extract(F,H.headers);let U=EQ(F);if(H.routeOptions.url!=null&&U?.type===EJ.HTTP)U.route=H.routeOptions.url;let B=this[D5].tracer.startSpan("request",{attributes:{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.ROOT]:"@fastify/otel",[l8.ATTR_HTTP_ROUTE]:H.url,[l8.ATTR_HTTP_REQUEST_METHOD]:H.method}},F);H[kF]=f8.trace.setSpan(F,B),H[jY]=B,f8.context.with(H[kF],()=>{q()})}),X.addHook("onResponse",function(H,V,q){let F=H[jY];if(F!=null)F.setStatus({code:f8.SpanStatusCode.OK,message:"OK"}),F.setAttributes({[l8.ATTR_HTTP_RESPONSE_STATUS_CODE]:404}),F.end();H[jY]=null,q()}),X.addHook=K,X.setNotFoundHandler=G,$();function Q(H,V,q,F){let U=H[jY];if(U!=null){if(V.statusCode<500)U.setStatus({code:f8.SpanStatusCode.OK,message:"OK"});U.setAttributes({[l8.ATTR_HTTP_RESPONSE_STATUS_CODE]:V.statusCode}),U.end()}H[jY]=null,F(null,q)}function W(H,V,q,F){let U=H[jY];if(U!=null)U.setStatus({code:f8.SpanStatusCode.ERROR,message:q.message}),U.recordException(q);F()}function K(H,V){let q=this[E71];if(k71.includes(H))return q.call(this,H,z(V,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - ${H}`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:V.name?.length>0?V.name:xJ}));else return q.call(this,H,V)}function G(H,V){let q=this[I71];if(typeof H==="function")V=z(H,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:H.name?.length>0?H.name:xJ}),q.call(this,V);else{if(H.preValidation!=null)H.preValidation=z(H.preValidation,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler - preValidation`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:H.preValidation.name?.length>0?H.preValidation.name:xJ});if(H.preHandler!=null)H.preHandler=z(H.preHandler,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler - preHandler`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:H.preHandler.name?.length>0?H.preHandler.name:xJ});V=z(V,{[l8.ATTR_SERVICE_NAME]:X[D5].servername,[r1.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[r1.FASTIFY_TYPE]:LY.INSTANCE,[r1.HOOK_CALLBACK_NAME]:V.name?.length>0?V.name:xJ}),q.call(this,H,V)}}function z(H,V={}){return function q(...F){let U=this[D5],[B]=F;if(U.isEnabled()===!1)return H.call(this,...F);let w=B[kF]??f8.context.active(),j=U.tracer.startSpan(`handler - ${H.name?.length>0?H.name:this.pluginName??xJ}`,{attributes:V},w);return f8.context.with(f8.trace.setSpan(w,j),function(){try{let N=H.call(this,...F);if(typeof N?.then==="function")return N.then((R)=>{return j.end(),R},(R)=>{return j.setStatus({code:f8.SpanStatusCode.ERROR,message:R.message}),j.recordException(R),j.end(),Promise.reject(R)});return j.end(),N}catch(N){throw j.setStatus({code:f8.SpanStatusCode.ERROR,message:N.message}),j.recordException(N),j.end(),N}},this)}}}}}var w7=e(Y0(),1);var x71=e(R1(),1);var hJ;(function(Z){Z.FASTIFY_NAME="fastify.name";let X="fastify.type";Z.FASTIFY_TYPE=X;let Y="hook.name";Z.HOOK_NAME=Y;let $="plugin.name";Z.PLUGIN_NAME=$})(hJ||(hJ={}));var EF;(function(Z){Z.MIDDLEWARE="middleware";let X="request_handler";Z.REQUEST_HANDLER=X})(EF||(EF={}));var IF;(function(Z){Z.MIDDLEWARE="middleware";let X="request handler";Z.REQUEST_HANDLER=X})(IF||(IF={}));var S71=e(Y0(),1);var vF=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function Uy(Z,J,X,Y={}){let $=J.startSpan(X,{attributes:Y}),Q=Z[vF]||[];return Q.push($),Object.defineProperty(Z,vF,{enumerable:!1,configurable:!0,value:Q}),$}function SR(Z,J){let X=Z[vF]||[];if(!X.length)return;X.forEach((Y)=>{if(J)Y.setStatus({code:S71.SpanStatusCode.ERROR,message:J.message}),Y.recordException(J);Y.end()}),delete Z[vF]}function _71(Z,J,X){let Y,$=void 0;try{if($=Z(),v71($))$.then((Q)=>J(void 0,Q),(Q)=>J(Q))}catch(Q){Y=Q}finally{if(!v71($)){if(J(Y,$),Y)throw Y}return $}}function v71(Z){return typeof Z==="object"&&Z&&typeof Object.getOwnPropertyDescriptor(Z,"then")?.value==="function"||!1}var U56="0.1.0",w56="@sentry/instrumentation-fastify-v3",A71="anonymous",B56=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]);class wy extends h8{constructor(Z={}){super(w56,U56,Z)}init(){return[new a6("fastify",[">=3.0.0 <4"],(Z)=>{return this._patchConstructor(Z)})]}_hookOnRequest(){let Z=this;return function J(X,Y,$){if(!Z.isEnabled())return $();Z._wrap(Y,"send",Z._patchSend());let Q=X,W=EQ(w7.context.active()),K=Q.routeOptions?Q.routeOptions.url:X.routerPath;if(K&&W?.type===EJ.HTTP)W.route=K;let G=X.method||"GET";E0().setTransactionName(`${G} ${K}`),$()}}_wrapHandler(Z,J,X,Y){let $=this;return this._diag.debug("Patching fastify route.handler function"),function(...Q){if(!$.isEnabled())return X.apply(this,Q);let W=X.name||Z||A71,K=`${IF.MIDDLEWARE} - ${W}`,G=Q[1],z=Uy(G,$.tracer,K,{[hJ.FASTIFY_TYPE]:EF.MIDDLEWARE,[hJ.PLUGIN_NAME]:Z,[hJ.HOOK_NAME]:J}),H=Y&&Q[Q.length-1];if(H)Q[Q.length-1]=function(...V){SR(G),H.apply(this,V)};return w7.context.with(w7.trace.setSpan(w7.context.active(),z),()=>{return _71(()=>{return X.apply(this,Q)},(V)=>{if(V instanceof Error)z.setStatus({code:w7.SpanStatusCode.ERROR,message:V.message}),z.recordException(V);if(!Y)SR(G)})})}}_wrapAddHook(){let Z=this;return this._diag.debug("Patching fastify server.addHook function"),function(J){return function X(...Y){let $=Y[0],Q=Y[1],W=this.pluginName;if(!B56.has($))return J.apply(this,Y);let K=typeof Y[Y.length-1]==="function"&&Q.constructor.name!=="AsyncFunction";return J.apply(this,[$,Z._wrapHandler(W,$,Q,K)])}}}_patchConstructor(Z){let J=this;function X(...Y){let $=Z.fastify.apply(this,Y);return $.addHook("onRequest",J._hookOnRequest()),$.addHook("preHandler",J._hookPreHandler()),L56(),J._wrap($,"addHook",J._wrapAddHook()),$}if(Z.errorCodes!==void 0)X.errorCodes=Z.errorCodes;return X.fastify=X,X.default=X,X}_patchSend(){let Z=this;return this._diag.debug("Patching fastify reply.send function"),function J(X){return function Y(...$){let Q=$[0];if(!Z.isEnabled())return X.apply(this,$);return $Y(()=>{return X.apply(this,$)},(W)=>{if(!W&&Q instanceof Error)W=Q;SR(this,W)})}}}_hookPreHandler(){let Z=this;return this._diag.debug("Patching fastify preHandler function"),function J(X,Y,$){if(!Z.isEnabled())return $();let Q=X,W=Q.routeOptions?.handler||Q.context?.handler,K=W?.name.startsWith("bound ")?W.name.substring(6):W?.name,G=`${IF.REQUEST_HANDLER} - ${K||this.pluginName||A71}`,z={[hJ.PLUGIN_NAME]:this.pluginName,[hJ.FASTIFY_TYPE]:EF.REQUEST_HANDLER,[x71.SEMATTRS_HTTP_ROUTE]:Q.routeOptions?Q.routeOptions.url:X.routerPath};if(K)z[hJ.FASTIFY_NAME]=K;let H=Uy(Y,Z.tracer,G,z);h71(H);let{requestHook:V}=Z.getConfig();if(V)$Y(()=>V(H,{request:X}),(q)=>{if(q)Z._diag.error("request hook failed",q)},!0);return w7.context.with(w7.trace.setSpan(w7.context.active(),H),()=>{$()})}}}function L56(){let Z=X0();if(Z)Z.on("spanStart",(J)=>{h71(J)})}function h71(Z){let J=B0(Z).data,X=J["fastify.type"];if(J[N0]||!X)return;Z.setAttributes({[_0]:"auto.http.otel.fastify",[N0]:`${X}.fastify`});let Y=J["fastify.name"]||J["plugin.name"]||J["hook.name"];if(typeof Y==="string"){let $=Y.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");Z.updateName($)}}var f71="Fastify",j56="Fastify-V5",O56="Fastify-V3",Ly=w0(O56,()=>new wy);function b71(){let Z=X0();if(!Z)return;else return Z.getIntegrationByName(f71)}function _R(Z,J,X,Y){let $=b71()?.getShouldHandleError()||y71;if(Y==="diagnostics-channel")this.diagnosticsChannelExists=!0;if(this.diagnosticsChannelExists&&Y==="onError-hook"){j4&&h.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}if($(Z,J,X))Z1(Z,{mechanism:{handled:!1,type:"fastify"}})}var jy=w0(j56,()=>{let Z=new Fy,J=Z.plugin();return By.subscribe("fastify.initialization",(X)=>{let Y=X.fastify;Y?.register(J).after(($)=>{if($)j4&&h.error("Failed to setup Fastify instrumentation",$);else if(R56(),Y)N56(Y)})}),By.subscribe("tracing:fastify.request.handler:error",(X)=>{let{error:Y,request:$,reply:Q}=X;_R.call(_R,Y,$,Q,"diagnostics-channel")}),Z}),M56=({shouldHandleError:Z})=>{let J;return{name:f71,setupOnce(){J=Z||y71,Ly(),jy()},getShouldHandleError(){return J},setShouldHandleError(X){J=X}}},AR=a((Z={})=>M56(Z));function y71(Z,J,X){let Y=X.statusCode;return Y>=500||Y<=299}function g71(Z,J){if(J?.shouldHandleError)b71()?.setShouldHandleError(J.shouldHandleError);let X=Object.assign(function(Y,$,Q){Y.addHook("onError",async(W,K,G)=>{_R.call(_R,G,W,K,"onError-hook")}),Q()},{[Symbol.for("skip-override")]:!0,[Symbol.for("fastify.display-name")]:"sentry-fastify-error-handler"});Z.register(X)}function m71(Z){let J=B0(Z),X=J.description,Y=J.data,$=Y["fastify.type"],Q=$==="hook",W=$===X?.startsWith("handler -"),K=X==="request"||$==="request-handler";if(Y[N0]||!W&&!K&&!Q)return;let G=Q?"hook":W?"middleware":K?"request-handler":"<unknown>";Z.setAttributes({[_0]:"auto.http.otel.fastify",[N0]:`${G}.fastify`});let z=Y["fastify.name"]||Y["plugin.name"]||Y["hook.name"];if(typeof z==="string"){let H=z.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");Z.updateName(H)}}function R56(){let Z=X0();if(Z)Z.on("spanStart",(J)=>{m71(J)})}function N56(Z){Z.addHook("onRequest",async(J,X)=>{if(J.opentelemetry){let{span:Q}=J.opentelemetry();if(Q)m71(Q)}let Y=J.routeOptions?.url,$=J.method||"GET";E0().setTransactionName(`${$} ${Y}`)})}var PZ1=e(Y0(),1),CZ1=e(DZ1(),1);var TZ1="Graphql",Cy=w0(TZ1,CZ1.GraphQLInstrumentation,(Z)=>{let J=kZ1(Z);return{...J,responseHook(X,Y){if(o1(X,"auto.graphql.otel.graphql"),Y.errors?.length&&!B0(X).status)X.setStatus({code:PZ1.SpanStatusCode.ERROR});let Q=B0(X).data,W=Q["graphql.operation.type"],K=Q["graphql.operation.name"];if(J.useOperationNameForRootSpan&&W){let G=s1(X),H=B0(G).data[h3]||[],V=K?`${W} ${K}`:`${W}`;if(Array.isArray(H))H.push(V),G.setAttribute(h3,H);else if(typeof H==="string")G.setAttribute(h3,[H,V]);else G.setAttribute(h3,V);if(!B0(G).data["original-description"])G.setAttribute("original-description",B0(G).description);G.updateName(`${B0(G).data["original-description"]} (${s56(H)})`)}}}}),a56=(Z={})=>{return{name:TZ1,setupOnce(){Cy(kZ1(Z))}}},bR=a(a56);function kZ1(Z){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...Z}}function s56(Z){if(Array.isArray(Z)){let J=Z.slice().sort();if(J.length<=5)return J.join(", ");else return`${J.slice(0,5).join(", ")}, +${J.length-5}`}return`${Z}`}var lZ1=e(cZ1(),1);var pZ1="Kafka",Ty=w0(pZ1,()=>new lZ1.KafkaJsInstrumentation({consumerHook(Z){o1(Z,"auto.kafkajs.otel.consumer")},producerHook(Z){o1(Z,"auto.kafkajs.otel.producer")}})),t56=()=>{return{name:pZ1,setupOnce(){Ty()}}},yR=a(t56);var YJ1=e(XJ1(),1);var $J1="LruMemoizer",ky=w0($J1,()=>new YJ1.LruMemoizerInstrumentation),X96=()=>{return{name:$J1,setupOnce(){ky()}}},gR=a(X96);var OJ1=e(jJ1(),1);var MJ1="Mongo",_y=w0(MJ1,()=>new OJ1.MongoDBInstrumentation({dbStatementSerializer:K96,responseHook(Z){o1(Z,"auto.db.otel.mongo")}}));function K96(Z){let J=Sy(Z);return JSON.stringify(J)}function Sy(Z){if(Array.isArray(Z))return Z.map((J)=>Sy(J));if(G96(Z)){let J={};return Object.entries(Z).map(([X,Y])=>[X,Sy(Y)]).reduce((X,Y)=>{if(H96(Y))X[Y[0]]=Y[1];return X},J)}return"?"}function G96(Z){return typeof Z==="object"&&Z!==null&&!z96(Z)}function z96(Z){let J=!1;if(typeof Buffer!=="undefined")J=Buffer.isBuffer(Z);return J}function H96(Z){return Array.isArray(Z)}var V96=()=>{return{name:MJ1,setupOnce(){_y()}}},mR=a(V96);var uJ1=e(mJ1(),1);var dJ1="Mongoose",hy=w0(dJ1,()=>new uJ1.MongooseInstrumentation({responseHook(Z){o1(Z,"auto.db.otel.mongoose")}})),P96=()=>{return{name:dJ1,setupOnce(){hy()}}},dR=a(P96);var WX1=e(QX1(),1);var KX1="Mysql",gy=w0(KX1,()=>new WX1.MySQLInstrumentation({})),m96=()=>{return{name:KX1,setupOnce(){gy()}}},lR=a(m96);var kX1=e(TX1(),1);var EX1="Mysql2",ly=w0(EX1,()=>new kX1.MySQL2Instrumentation({responseHook(Z){o1(Z,"auto.db.otel.mysql2")}})),Y46=()=>{return{name:EX1,setupOnce(){ly()}}},iR=a(Y46);var wY1=e(nX1(),1),BY1=e(HY1(),1);var L46=["get","set","setex"],iy=["get","mget"],j46=["set","setex"];function gF(Z,J){return Z.includes(J.toLowerCase())}function ny(Z){if(gF(iy,Z))return"cache.get";else if(gF(j46,Z))return"cache.put";else return}function O46(Z,J){return J.some((X)=>Z.startsWith(X))}function qY1(Z,J){try{if(J.length===0)return;let X=($)=>{if(typeof $==="string"||typeof $==="number"||Buffer.isBuffer($))return[$.toString()];else if(Array.isArray($))return VY1($.map((Q)=>X(Q)));else return["<unknown>"]},Y=J[0];if(gF(L46,Z)&&Y!=null)return X(Y);return VY1(J.map(($)=>X($)))}catch{return}}function FY1(Z,J,X){if(!ny(Z))return!1;for(let Y of J)if(O46(Y,X))return!0;return!1}function UY1(Z){let J=(X)=>{try{if(Buffer.isBuffer(X))return X.byteLength;else if(typeof X==="string")return X.length;else if(typeof X==="number")return X.toString().length;else if(X===null||X===void 0)return 0;return JSON.stringify(X).length}catch{return}};return Array.isArray(Z)?Z.reduce((X,Y)=>{let $=J(Y);return typeof $==="number"?X!==void 0?X+$:$:X},0):J(Z)}function VY1(Z){let J=[],X=(Y)=>{Y.forEach(($)=>{if(Array.isArray($))X($);else J.push($)})};return X(Z),J}var LY1="Redis",ay={},jY1=(Z,J,X,Y)=>{Z.setAttribute(_0,"auto.db.otel.redis");let $=qY1(J,X),Q=ny(J);if(!$||!Q||!ay.cachePrefixes||!FY1(J,$,ay.cachePrefixes))return;let W=B0(Z).data["net.peer.name"],K=B0(Z).data["net.peer.port"];if(K&&W)Z.setAttributes({"network.peer.address":W,"network.peer.port":K});let G=UY1(Y);if(G)Z.setAttribute(Gh,G);if(gF(iy,J)&&G!==void 0)Z.setAttribute(Wh,G>0);Z.setAttributes({[N0]:Q,[Kh]:$});let z=$.join(", ");Z.updateName(s5(z,1024))},M46=w0("IORedis",()=>{return new wY1.IORedisInstrumentation({responseHook:jY1})}),R46=w0("Redis-4",()=>{return new BY1.RedisInstrumentation({responseHook:jY1})}),sy=Object.assign(()=>{M46(),R46()},{id:LY1}),N46=(Z={})=>{return{name:LY1,setupOnce(){ay=Z,sy()}}},aR=a(N46);var oY1=e(sY1(),1);var rY1="Postgres",Yg=w0(rY1,()=>new oY1.PgInstrumentation({requireParentSpan:!0,requestHook(Z){o1(Z,"auto.db.otel.postgres")}})),W76=()=>{return{name:rY1,setupOnce(){Yg()}}},tR=a(W76);var r3=e(Y0(),1);var r6=e(R1(),1);var $g="PostgresJs",tY1=[">=3.0.0 <4"],Qg=w0($g,(Z)=>new eY1({requireParentSpan:Z?.requireParentSpan??!0,requestHook:Z?.requestHook}));class eY1 extends h8{constructor(Z){super("sentry-postgres-js",M1,Z)}init(){let Z=new a6("postgres",tY1);return["src","cf/src","cjs/src"].forEach((J)=>{Z.files.push(new fM(`postgres/${J}/connection.js`,["*"],this._patchConnection.bind(this),this._unwrap.bind(this))),Z.files.push(new fM(`postgres/${J}/query.js`,tY1,this._patchQuery.bind(this),this._unwrap.bind(this)))}),[Z]}_shouldCreateSpans(){let Z=this.getConfig();return r3.trace.getSpan(r3.context.active())!==void 0||!Z.requireParentSpan}_patchReject(Z,J){return new Proxy(Z,{apply:(X,Y,$)=>{J.setStatus({code:x8,message:$?.[0]?.message||"unknown_error"});let Q=Reflect.apply(X,Y,$);return J.setAttribute(r6.ATTR_DB_RESPONSE_STATUS_CODE,$?.[0]?.code||"Unknown error"),J.setAttribute(r6.ATTR_ERROR_TYPE,$?.[0]?.name||"Unknown error"),J.end(),Q}})}_patchResolve(Z,J){return new Proxy(Z,{apply:(X,Y,$)=>{let Q=Reflect.apply(X,Y,$),W=$?.[0]?.command;if(W)J.setAttribute(r6.ATTR_DB_OPERATION_NAME,W);return J.end(),Q}})}_patchQuery(Z){return Z.Query.prototype.handle=new Proxy(Z.Query.prototype.handle,{apply:async(J,X,Y)=>{if(!this._shouldCreateSpans())return Reflect.apply(J,X,Y);let $=this._sanitizeSqlQuery(X.strings?.[0]);return jQ({name:$||"postgresjs.query",op:"db"},(Q)=>{let K=T0().getScopeData().contexts.postgresjsConnection;o1(Q,"auto.db.otel.postgres");let{requestHook:G}=this.getConfig();if(G)$Y(()=>G(Q,$,K),(q)=>{if(q)h.error(`Error in requestHook for ${$g} integration:`,q)});let z=K?.ATTR_DB_NAMESPACE||"<unknown database>",H=K?.ATTR_SERVER_ADDRESS||"<unknown host>",V=K?.ATTR_SERVER_PORT||"<unknown port>";Q.setAttribute(r6.ATTR_DB_SYSTEM_NAME,"postgres"),Q.setAttribute(r6.ATTR_DB_NAMESPACE,z),Q.setAttribute(r6.ATTR_SERVER_ADDRESS,H),Q.setAttribute(r6.ATTR_SERVER_PORT,V),Q.setAttribute(r6.ATTR_DB_QUERY_TEXT,$),X.resolve=this._patchResolve(X.resolve,Q),X.reject=this._patchReject(X.reject,Q);try{return Reflect.apply(J,X,Y)}catch(q){throw Q.setStatus({code:x8}),Q.end(),q}})}}),Z}_patchConnection(Z){return new Proxy(Z,{apply:(J,X,Y)=>{let $=Y[0]?.database||"<unknown database>",Q=Y[0]?.host?.[0]||"<unknown host>",W=Y[0]?.port?.[0]||"<unknown port>";return T0().setContext("postgresjsConnection",{ATTR_DB_NAMESPACE:$,ATTR_SERVER_ADDRESS:Q,ATTR_SERVER_PORT:W}),Reflect.apply(J,X,Y)}})}_sanitizeSqlQuery(Z){if(!Z)return"Unknown SQL Query";return Z.replace(/\s+/g," ").trim().substring(0,1024).replace(/--.*?(\r?\n|$)/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\b\d+\b/g,"?").replace(/\s+/g," ").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/g,"IN (?)")}}var K76=()=>{return{name:$g,setupOnce(){Qg()}}},eR=a(K76);var X$1=e(Y0(),1);var AY=e(Y0(),1);var G76=process.env.PRISMA_SHOW_ALL_TRACES==="true",z76="00-10-10-00";function H76(Z){switch(Z){case"client":return AY.SpanKind.CLIENT;case"internal":default:return AY.SpanKind.INTERNAL}}var V76=class{traceMiddleware;tracerProvider;ignoreSpanTypes;constructor({traceMiddleware:Z,tracerProvider:J,ignoreSpanTypes:X}){this.traceMiddleware=Z,this.tracerProvider=J,this.ignoreSpanTypes=X}isEnabled(){return!0}getTraceParent(Z){let J=AY.trace.getSpanContext(Z??AY.context.active());if(J)return`00-${J.traceId}-${J.spanId}-0${J.traceFlags}`;return z76}dispatchEngineSpans(Z){let J=this.tracerProvider.getTracer("prisma"),X=new Map,Y=Z.filter(($)=>$.parentId===null);for(let $ of Y)Y$1(J,$,Z,X,this.ignoreSpanTypes)}getActiveContext(){return AY.context.active()}runInChildSpan(Z,J){if(typeof Z==="string")Z={name:Z};if(Z.internal&&!G76)return J();if(Z.middleware&&!this.traceMiddleware)return J();let X=this.tracerProvider.getTracer("prisma"),Y=Z.context??this.getActiveContext(),$=`prisma:client:${Z.name}`;if($$1($,this.ignoreSpanTypes))return J();if(Z.active===!1){let Q=X.startSpan($,Z,Y);return Z$1(Q,J(Q,Y))}return X.startActiveSpan($,Z,(Q)=>Z$1(Q,J(Q,Y)))}};function Y$1(Z,J,X,Y,$){if($$1(J.name,$))return;let Q={attributes:J.attributes,kind:H76(J.kind),startTime:J.startTime};Z.startActiveSpan(J.name,Q,(W)=>{if(Y.set(J.id,W.spanContext().spanId),J.links)W.addLinks(J.links.flatMap((G)=>{let z=Y.get(G);if(!z)return[];return{context:{spanId:z,traceId:W.spanContext().traceId,traceFlags:W.spanContext().traceFlags}}}));let K=X.filter((G)=>G.parentId===J.id);for(let G of K)Y$1(Z,G,X,Y,$);W.end(J.endTime)})}function Z$1(Z,J){if(q76(J))return J.then((X)=>{return Z.end(),X},(X)=>{throw Z.end(),X});return Z.end(),J}function q76(Z){return Z!=null&&typeof Z.then==="function"}function $$1(Z,J){return J.some((X)=>typeof X==="string"?X===Z:X.test(Z))}var Q$1={name:"@prisma/instrumentation",version:"6.11.1",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@prisma/internals":"workspace:*","@swc/core":"1.11.5","@types/jest":"29.5.14","@types/node":"18.19.76","@opentelemetry/api":"1.9.0",jest:"29.7.0","jest-junit":"16.0.0",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":"^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"jest"},sideEffects:!1},Kg=Q$1.version,F76=Kg.split(".")[0],J$1="PRISMA_INSTRUMENTATION",Wg=`V${F76}_PRISMA_INSTRUMENTATION`,U76=Q$1.name,w76="@prisma/client",W$1=class extends h8{tracerProvider;constructor(Z={}){super(U76,Kg,Z)}setTracerProvider(Z){this.tracerProvider=Z}init(){return[new a6(w76,[Kg])]}enable(){let Z=this._config,J={helper:new V76({traceMiddleware:Z.middleware??!1,tracerProvider:this.tracerProvider??X$1.trace.getTracerProvider(),ignoreSpanTypes:Z.ignoreSpanTypes??[]})};global[J$1]=J,global[Wg]=J}disable(){delete global[J$1],delete global[Wg]}isEnabled(){return Boolean(global[Wg])}};var K$1="Prisma";function B76(Z){return!!Z&&typeof Z==="object"&&"dispatchEngineSpans"in Z}function G$1(){let Z=globalThis.PRISMA_INSTRUMENTATION;return Z&&typeof Z==="object"&&"helper"in Z?Z.helper:void 0}class z$1 extends W$1{constructor(){super()}enable(){super.enable();let Z=G$1(),J=!1;if(B76(Z))Z.createEngineSpan=()=>{e0(()=>{if(!J)J=!0,console.warn("[Sentry] The Sentry SDK supports tracing with Prisma version 5 only with limited capabilities. For full tracing capabilities pass `prismaInstrumentation` for version 5 to the Sentry `prismaIntegration`. Read more: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/")})}}}var L76=w0(K$1,(Z)=>{if(Z?.prismaInstrumentation)return Z.prismaInstrumentation;return new z$1}),ZN=a(({prismaInstrumentation:Z}={})=>{return{name:K$1,setupOnce(){L76({prismaInstrumentation:Z})},setup(J){if(!G$1())return;J.on("spanStart",(X)=>{let Y=B0(X);if(Y.description?.startsWith("prisma:"))X.setAttribute(_0,"auto.db.otel.prisma");if(Y.description==="prisma:engine:db_query"&&Y.data["db.query.text"])X.updateName(Y.data["db.query.text"]);if(Y.description==="prisma:engine:db_query"&&!Y.data["db.system"])X.setAttribute("db.system","prisma")})}}});var k$1=e(T$1(),1);var E$1="Hapi",YN=w0(E$1,()=>new k$1.HapiInstrumentation),y76=()=>{return{name:E$1,setupOnce(){YN()}}},$N=a(y76);function g76(Z){return!!(Z&&typeof Z==="object"&&("error"in Z)&&Z.error)}function m76(Z){Z1(Z,{mechanism:{type:"hapi",handled:!1,data:{function:"hapiErrorPlugin"}}})}var u76={name:"SentryHapiErrorPlugin",version:M1,register:async function(Z){Z.events.on({name:"request",channels:["error"]},(X,Y)=>{if(E0()!==z4()){let $=X.route;if($.path)E0().setTransactionName(`${$.method.toUpperCase()} ${$.path}`)}else j4&&h.warn("Isolation scope is still the default isolation scope - skipping setting transactionName");if(g76(Y))m76(Y.error)})}};async function I$1(Z){await Z.register(u76);let J=X0();if(J)J.on("spanStart",(X)=>{d76(X)});SJ(Z.register,"hapi")}function d76(Z){let J=B0(Z).data,X=J["hapi.type"];if(J[N0]||!X)return;Z.setAttributes({[_0]:"auto.http.otel.hapi",[N0]:`${X}.hapi`})}var t$1=e(r$1(),1),e$1=e(R1(),1);var ZQ1="Koa",Bg=w0(ZQ1,t$1.KoaInstrumentation,(Z={})=>{return{ignoreLayersType:Z.ignoreLayersType,requestHook(J,X){o1(J,"auto.http.otel.koa");let Y=B0(J).data,$=Y["koa.type"];if($)J.setAttribute(N0,`${$}.koa`);let Q=Y["koa.name"];if(typeof Q==="string")J.updateName(Q||"< unknown >");if(E0()===z4()){j4&&h.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let W=Y[e$1.ATTR_HTTP_ROUTE],K=X.context?.request?.method?.toUpperCase()||"GET";if(W)E0().setTransactionName(`${K} ${W}`)}}}),r76=(Z={})=>{return{name:ZQ1,setupOnce(){Bg(Z)}}},KN=a(r76),JQ1=(Z)=>{Z.use(async(J,X)=>{try{await X()}catch(Y){throw Z1(Y),Y}}),SJ(Z.use,"koa")};var NQ1=e(RQ1(),1);var DQ1="Connect",Rg=w0(DQ1,()=>new NQ1.ConnectInstrumentation),VZ6=()=>{return{name:DQ1,setupOnce(){Rg()}}},zN=a(VZ6);function qZ6(Z,J,X,Y){Z1(Z),Y(Z)}var PQ1=(Z)=>{Z.use(qZ6);let J=X0();if(J)J.on("spanStart",(X)=>{FZ6(X)});SJ(Z.use,"connect")};function FZ6(Z){let J=B0(Z).data,X=J["connect.type"];if(J[N0]||!X)return;Z.setAttributes({[_0]:"auto.http.otel.connect",[N0]:`${X}.connect`});let Y=J["connect.name"];if(typeof Y==="string")Z.updateName(Y)}var pQ1=e(lQ1(),1);var iQ1="Knex",IZ6=w0(iQ1,()=>new pQ1.KnexInstrumentation({requireParentSpan:!0})),vZ6=()=>{let Z;return{name:iQ1,setupOnce(){let J=IZ6();Z=TJ(J)},setup(J){Z?.(()=>J.on("spanStart",(X)=>{let{data:Y}=B0(X);if("knex.version"in Y)X.setAttribute(_0,"auto.db.otel.knex")}))}}},nQ1=a(vZ6);var VW1=e(HW1(),1);var bZ6=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),qW1="Tedious",Dg=w0(qW1,()=>new VW1.TediousInstrumentation({})),yZ6=()=>{let Z;return{name:qW1,setupOnce(){let J=Dg();Z=TJ(J)},setup(J){Z?.(()=>J.on("spanStart",(X)=>{let{description:Y,data:$}=B0(X);if(!Y||$["db.system"]!=="mssql")return;let Q=Y.split(" ")[0]||"";if(bZ6.has(Q))X.setAttribute(_0,"auto.db.otel.tedious")}))}}},UN=a(yZ6);var NW1=e(RW1(),1);var DW1="GenericPool",Cg=w0(DW1,()=>new NW1.GenericPoolInstrumentation({})),dZ6=()=>{let Z;return{name:DW1,setupOnce(){let J=Cg();Z=TJ(J)},setup(J){Z?.(()=>J.on("spanStart",(X)=>{let $=B0(X).description;if($==="generic-pool.aquire"||$==="generic-pool.acquire")X.setAttribute(_0,"auto.db.otel.generic_pool")}))}}},wN=a(dZ6);var fW1=e(hW1(),1);var bW1="Dataloader",pZ6=w0(bW1,()=>new fW1.DataloaderInstrumentation({requireParentSpan:!0})),iZ6=()=>{let Z;return{name:bW1,setupOnce(){let J=pZ6();Z=TJ(J)},setup(J){Z?.(()=>{J.on("spanStart",(X)=>{let Y=B0(X);if(Y.description?.startsWith("dataloader"))X.setAttribute(_0,"auto.db.otel.dataloader");if(Y.description==="dataloader.load"||Y.description==="dataloader.loadMany"||Y.description==="dataloader.batch")X.setAttribute(N0,"cache.get")})})}}},yW1=a(iZ6);var $K1=e(YK1(),1);var QK1="Amqplib",qJ6={consumeEndHook:(Z)=>{o1(Z,"auto.amqplib.otel.consumer")},publishHook:(Z)=>{o1(Z,"auto.amqplib.otel.publisher")}},vg=w0(QK1,()=>new $K1.AmqplibInstrumentation(qJ6)),FJ6=()=>{return{name:QK1,setupOnce(){vg()}}},jN=a(FJ6);var pF="VercelAI";var WK1=["generateText","streamText","generateObject","streamObject","embed","embedMany"];function UJ6(Z,J,X,Y){let $=Z?.recordInputs!==void 0?Z.recordInputs:J.recordInputs!==void 0?J.recordInputs:X===!0?!0:Y,Q=Z?.recordOutputs!==void 0?Z.recordOutputs:J.recordOutputs!==void 0?J.recordOutputs:X===!0?!0:Y;return{recordInputs:$,recordOutputs:Q}}class iF extends h8{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(Z={}){super("@sentry/instrumentation-vercel-ai",M1,Z);iF.prototype.__init.call(this),iF.prototype.__init2.call(this)}init(){return new a6("ai",[">=3.0.0 <5"],this._patch.bind(this))}callWhenPatched(Z){if(this._isPatched)Z();else this._callbacks.push(Z)}_patch(Z){this._isPatched=!0,this._callbacks.forEach((X)=>X()),this._callbacks=[];function J(X){return(...Y)=>{let $=Y[0].experimental_telemetry||{},Q=$.isEnabled,W=T0().getClient(),K=W?.getIntegrationByName(pF),G=K?.options,z=K?Boolean(W?.getOptions().sendDefaultPii):!1,{recordInputs:H,recordOutputs:V}=UJ6(G,$,Q,z);return Y[0].experimental_telemetry={...$,isEnabled:Q!==void 0?Q:!0,recordInputs:H,recordOutputs:V},MJ(()=>{return X.apply(this,Y)},(q)=>{if(q&&typeof q==="object")J8(q,"_sentry_active_span",T6())})}}if(Object.prototype.toString.call(Z)==="[object Module]"){for(let X of WK1)Z[X]=J(Z[X]);return Z}else{let X=WK1.reduce((Y,$)=>{return Y[$]=J(Z[$]),Y},{});return{...Z,...X}}}}var Sg=w0(pF,()=>new iF({}));function wJ6(Z){return!!Z.getIntegrationByName("Modules")?.getModules?.()?.ai}var BJ6=(Z={})=>{let J;return{name:pF,options:Z,setupOnce(){J=Sg()},afterAllSetup(X){if(Z.force??wJ6(X))kM(X);else J?.callWhenPatched(()=>kM(X))}}},ON=a(BJ6);var LJ6=[">=4.0.0 <6"];function jJ6(Z,J){let X=Z?.recordInputs??J,Y=Z?.recordOutputs??J;return{recordInputs:X,recordOutputs:Y}}class _g extends h8{constructor(Z={}){super("@sentry/instrumentation-openai",M1,Z)}init(){return new a6("openai",LJ6,this._patch.bind(this))}_patch(Z){let J=Z.OpenAI,X=function(...Y){let $=Reflect.construct(J,Y),Q=T0().getClient(),K=Q?.getIntegrationByName(XY)?.options,G=Boolean(Q?.getOptions().sendDefaultPii),{recordInputs:z,recordOutputs:H}=jJ6(K,G);return ff($,{recordInputs:z,recordOutputs:H})};Object.setPrototypeOf(X,J),Object.setPrototypeOf(X.prototype,J.prototype);for(let Y of Object.getOwnPropertyNames(J))if(!["length","name","prototype"].includes(Y)){let $=Object.getOwnPropertyDescriptor(J,Y);if($)Object.defineProperty(X,Y,$)}try{Z.OpenAI=X}catch(Y){Object.defineProperty(Z,"OpenAI",{value:X,writable:!0,configurable:!0,enumerable:!0})}return Z}}var Ag=w0(XY,()=>new _g({})),OJ6=(Z={})=>{return{name:XY,options:Z,setupOnce(){Ag()}}},MN=a(OJ6);var KK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The launchDarklyIntegration() can only be used in the browser.")});return{name:"LaunchDarkly"}});function GK1(){if(!z7())e0(()=>{console.warn("The buildLaunchDarklyFlagUsedHandler() can only be used in the browser.")});return{name:"sentry-flag-auditor",type:"flag-used",synchronous:!0,method:()=>null}}var zK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The openFeatureIntegration() can only be used in the browser.")});return{name:"OpenFeature"}});class xg{constructor(){if(!z7())e0(()=>{console.warn("The OpenFeatureIntegrationHook can only be used in the browser.")})}after(){}error(){}}var HK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The statsigIntegration() can only be used in the browser.")});return{name:"Statsig"}});var VK1=a((Z)=>{if(!z7())e0(()=>{console.warn("The unleashIntegration() can only be used in the browser.")});return{name:"Unleash"}});function RN(){return[ER(),AR(),bR(),mR(),dR(),lR(),iR(),aR(),tR(),ZN(),$N(),KN(),zN(),UN(),wN(),yR(),jN(),gR(),ON(),MN(),eR()]}function qK1(){return[ob,Wy,Ky,Rg,jy,Ly,YN,Ty,Bg,ky,_y,hy,gy,ly,Yg,YN,Cy,sy,Dg,Cg,vg,Sg,Ag,Qg]}var XG=e(Y0(),1);var YG=e(R1(),1);var FK1=e($q(),1);import MJ6 from"module";var hg=1e6;function NN(Z,J={}){if(Z.getOptions().debug)cb();let X=DJ6(Z,J);Z.traceProvider=X}function RJ6(){let[Z=0,J=0]=process.versions.node.split(".").map(Number);if(Z>=21||Z===20&&J>=6||Z===18&&J>=19){if(!O0._sentryEsmLoaderHookRegistered)try{let{addHookMessagePort:X}=FK1.createAddHookMessageChannel();MJ6.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:X,include:[]},transferList:[X]})}catch(X){h.warn("Failed to register ESM hook",X)}}else e0(()=>{console.warn(`[Sentry] You are using Node.js v${process.versions.node} in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.`)})}function UK1(Z={}){let{debug:J}=Z;if(J)h.enable();if(!L4())RJ6();NJ6(Z.integrations).forEach((X)=>{if(X(),J)h.log(`[Sentry] Preloaded ${X.id} instrumentation`)})}function NJ6(Z){let J=qK1();if(!Z)return J;return J.filter((X)=>Z.includes(X.id))}function DJ6(Z,J={}){let X=new Hb({sampler:new Ib(Z),resource:new _3({[YG.ATTR_SERVICE_NAME]:"node",[YG.SEMRESATTRS_SERVICE_NAMESPACE]:"sentry",[YG.ATTR_SERVICE_VERSION]:M1}),forceFlushTimeoutMillis:500,spanProcessors:[new Eb({timeout:PJ6(Z.getOptions().maxSpanWaitDuration)}),...J.spanProcessors||[]]});return XG.trace.setGlobalTracerProvider(X),XG.propagation.setGlobalPropagator(new Db),XG.context.setGlobalContextManager(new qF),X}function PJ6(Z){if(Z==null)return;if(Z>hg)return j4&&h.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${hg}`),hg;else if(Z<=0||Number.isNaN(Z)){j4&&h.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return Z}function fg(){return jR().filter((J)=>J.name!=="Http"&&J.name!=="NodeFetch").concat(OR(),RR())}function bg(Z){return[...fg(),...c8(Z)?RN():[]]}function DN(Z={}){return wK1(Z,bg)}function wK1(Z={},J){DQ(Z,"node");let X=nb({...Z,defaultIntegrations:Z.defaultIntegrations??J(Z)});if(X&&!Z.skipOpenTelemetrySetup)NN(X,{spanProcessors:Z.openTelemetrySpanProcessors}),OF();return X}function BK1(Z={}){return wK1(Z,()=>[])}var sQ;((B)=>{B.BUILD_PACKETS="build_packets";B.ENTITIES_EMIT_UPDATES="entities_emit_updates";B.ENTITIES_TICK="entities_tick";B.NETWORK_SYNCHRONIZE="network_synchronize";B.NETWORK_SYNCHRONIZE_CLEANUP="network_synchronize_cleanup";B.PHYSICS_CLEANUP="physics_cleanup";B.PHYSICS_STEP="physics_step";B.SEND_ALL_PACKETS="send_all_packets";B.SEND_PACKETS="send_packets";B.SERIALIZE_FREE_BUFFERS="serialize_free_buffers";B.SERIALIZE_PACKETS="serialize_packets";B.SERIALIZE_PACKETS_ENCODE="serialize_packets_encode";B.SIMULATION_STEP="simulation_step";B.TICKER_TICK="ticker_tick";B.WORLD_TICK="world_tick"})(sQ||={});class N8{static getProcessStats(Z=!1){let J=process.memoryUsage(),X={jsHeapSizeMb:{value:J.heapUsed/1024/1024,unit:"megabyte"},jsHeapCapacityMb:{value:J.heapTotal/1024/1024,unit:"megabyte"},jsHeapUsagePercent:{value:J.heapUsed/J.heapTotal,unit:"percent"},processHeapSizeMb:{value:J.heapUsed/1024/1024,unit:"megabyte"},rssSizeMb:{value:J.rss/1024/1024,unit:"megabyte"}};if(Z)return X;return Object.fromEntries(Object.entries(X).map(([Y,$])=>[Y,$.value]))}static initializeSentry(Z,J=50){DN({dsn:Z,release:nS,environment:process.env.NODE_ENV||"development",tracesSampleRate:1,initialScope:{tags:{gameId:process.env.HYTOPIA_GAME_ID??"unknown",gameSlug:process.env.HYTOPIA_GAME_SLUG??"unknown",lobbyId:process.env.HYTOPIA_LOBBY_ID??"unknown",region:process.env.REGION??"unknown"}},beforeSend:(X)=>{return X.extra=N8.getProcessStats(),X},beforeSendTransaction:(X)=>{if(X.contexts?.trace?.op==="ticker_tick"){let $=X?.start_timestamp,Q=X?.timestamp;if(!$||!Q)return null;if((Q-$)*1000>J)return X.measurements=N8.getProcessStats(!0),X}return null}})}static startSpan(Z,J){if(Eq())return q4({attributes:Z.attributes,name:Z.operation,op:Z.operation},J);else return J()}static sentry(){return yg}}var LK1=new I$,kJ6=5000;class o4 extends j0{static _cachedPacketsSerializedBuffer=new Map;_closeTimeout=null;_wrtcDirectTransport=null;_wrtcClientServerTransport=null;_wrtcClientServerDataProducers=[];_wrtcClientServerDataConsumers=[];_wrtcServerClientTransport=null;_wrtcServerClientReliableDataProducer=null;_wrtcServerClientUnreliableDataProducer=null;_wrtcServerClientDataConsumers=[];_ws;id;constructor(Z,J){super();this.id=q50(),this.onPacket(Q0.PacketId.CONNECTION,this._onConnectionPacket),this.onPacket(Q0.PacketId.HEARTBEAT,this._onHeartbeatPacket),this.bindWs(Z),j0.globalInstance.emit("CONNECTION.OPENED",{connection:this,req:J})}static clearCachedPacketsSerializedBuffers(){if(o4._cachedPacketsSerializedBuffer.size>0)o4._cachedPacketsSerializedBuffer.clear()}static serializePackets(Z){for(let X of Z)if(!Q0.isValidPacket(X))return d.error(`Connection.serializePackets(): Invalid packet payload: ${JSON.stringify(X)}`);let J=o4._cachedPacketsSerializedBuffer.get(Z);if(J)return J;return N8.startSpan({operation:"serialize_packets",attributes:{packets:Z.length,packetIds:Z.map((X)=>X[0]).join(",")}},(X)=>{let Y=LK1.pack(Z);if(Y.byteLength>65536)Y=CJ6(Y,{level:1});return X?.setAttribute("serializedBytes",Y.byteLength),o4._cachedPacketsSerializedBuffer.set(Z,Y),Y})}bindWs(Z){let J=!!this._ws;if(J&&this._closeTimeout)clearTimeout(this._closeTimeout),this._closeTimeout=null;if(this._ws)this._ws.onmessage=()=>{},this._ws.onclose=()=>{},this._ws.onerror=()=>{},this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{k:!0})]);if(this._ws=Z,this._ws.binaryType="nodebuffer",this._ws.onmessage=(X)=>this._onMessage(X.data),this._ws.onclose=this._onWsClose,this._ws.onerror=this._onWsError,this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{i:this.id})],!0,!0),J)this.emitWithGlobal("CONNECTION.RECONNECTED",{connection:this});if(a7.instance.isWrtcEnabled)this._upgradeToWRTC()}closeWrtc(){this._closeWrtcClientServerTransport(),this._closeWrtcServerClientTransport()}disconnect(){try{this._ws.close()}catch(Z){d.error(`Connection.disconnect(): Connection disconnect failed. Error: ${Z}`)}}onPacket(Z,J){this.on("CONNECTION.PACKET_RECEIVED",({packet:X})=>{if(X[0]===Z)J(X)})}send(Z,J=!0,X=!1){if(this._closeTimeout)return;if(this._ws.readyState!==TJ6.OPEN)return;N8.startSpan({operation:"send_packets",attributes:{forceWs:X?"true":"false",wrtcConnected:this._wrtcServerClientTransport?.iceState==="completed"?"true":"false"}},()=>{try{let Y=o4.serializePackets(Z);if(!Y)return;if(this._wrtcServerClientTransport?.iceState==="completed"&&Y.length<(this._wrtcServerClientTransport?.sctpParameters?.maxMessageSize??0)&&!X)try{(J?this._wrtcServerClientReliableDataProducer:this._wrtcServerClientUnreliableDataProducer).send(Y)}catch{this._ws.send(Y)}else this._ws.send(Y);this.emitWithGlobal("CONNECTION.PACKETS_SENT",{connection:this,packets:Z})}catch(Y){d.error(`Connection.send(): Packet send failed. Error: ${Y}`)}})}_closeWrtcClientServerTransport(){this._wrtcDirectTransport?.close(),this._wrtcDirectTransport=null,this._wrtcClientServerTransport?.close(),this._wrtcClientServerTransport=null,this._wrtcClientServerDataProducers.forEach((Z)=>Z.close()),this._wrtcClientServerDataProducers=[],this._wrtcClientServerDataConsumers.forEach((Z)=>Z.close()),this._wrtcClientServerDataConsumers=[]}_closeWrtcServerClientTransport(){this._wrtcServerClientTransport?.close(),this._wrtcServerClientTransport=null,this._wrtcServerClientDataConsumers.forEach((Z)=>Z.close()),this._wrtcServerClientDataConsumers=[],this._wrtcServerClientReliableDataProducer?.close(),this._wrtcServerClientReliableDataProducer=null,this._wrtcServerClientUnreliableDataProducer?.close(),this._wrtcServerClientUnreliableDataProducer=null}_onConnectionPacket=async(Z)=>{let J=Z[1],X=J.c,Y=J.d;if(X){let{i:$,d:Q}=X,W=!1;if($==this._wrtcClientServerTransport?.id)await this._wrtcClientServerTransport.connect({dtlsParameters:Q}),W=!0;if($==this._wrtcServerClientTransport?.id)await this._wrtcServerClientTransport.connect({dtlsParameters:Q}),W=!0;if(W)this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{ca:{i:$}})])}if(Y)for(let $ of Y){let{s:Q,l:W}=$,K=await this._wrtcClientServerTransport.produceData({label:W,sctpStreamParameters:Q}),G=await this._wrtcDirectTransport.consumeData({dataProducerId:K.id});this._wrtcClientServerDataProducers.push(K),this._wrtcClientServerDataConsumers.push(G),G.on("message",(z)=>this._onMessage(z)),this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{pa:{i:K.id,l:W}})])}};_onHeartbeatPacket=()=>{this.send([Q0.createPacket(Q0.bidirectionalPackets.heartbeatPacketDefinition,null)],!0,!0)};_onMessage=(Z)=>{try{let J=this._deserialize(Z);if(!J)return;this.emitWithGlobal("CONNECTION.PACKET_RECEIVED",{connection:this,packet:J})}catch(J){d.error(`Connection._ws.onmessage(): Error: ${J}`)}};_onWrtcIceStateChange=(Z,J)=>{if(["disconnected","closed"].includes(J)){if(Z==this._wrtcClientServerTransport)this._closeWrtcClientServerTransport();else if(Z==this._wrtcServerClientTransport)this._closeWrtcServerClientTransport()}};_onWsClose=()=>{this.closeWrtc(),this.emitWithGlobal("CONNECTION.DISCONNECTED",{connection:this}),this._closeTimeout=setTimeout(()=>{this.emitWithGlobal("CONNECTION.CLOSED",{connection:this}),this.offAll()},kJ6)};_onWsError=(Z)=>{this.emitWithGlobal("CONNECTION.ERROR",{connection:this,error:Z})};_upgradeToWRTC=async()=>{let Z=await a7.instance.createWrtcTransports();if(!Z)return!1;let{directTransport:J,clientServerTransport:X,serverClientTransport:Y}=Z;this._wrtcDirectTransport=J,this._wrtcClientServerTransport=X,this._wrtcClientServerTransport.on("icestatechange",(W)=>{this._onWrtcIceStateChange(this._wrtcClientServerTransport,W)}),this._wrtcServerClientTransport=Y,this._wrtcServerClientTransport.on("icestatechange",(W)=>{this._onWrtcIceStateChange(this._wrtcServerClientTransport,W)}),this._wrtcServerClientReliableDataProducer=await this._wrtcServerClientTransport.produceData({label:"scr",sctpStreamParameters:{streamId:0,ordered:!0}}),this._wrtcServerClientUnreliableDataProducer=await this._wrtcServerClientTransport.produceData({label:"scu",sctpStreamParameters:{streamId:1,ordered:!1,maxPacketLifeTime:35}});let $=await this._wrtcServerClientTransport.consumeData({dataProducerId:this._wrtcServerClientReliableDataProducer.id}),Q=await this._wrtcServerClientTransport.consumeData({dataProducerId:this._wrtcServerClientUnreliableDataProducer.id});return this._wrtcServerClientDataConsumers.push($,Q),this.send([Q0.createPacket(Q0.bidirectionalPackets.connectionPacketDefinition,{d:[{i:$.id,pi:$.dataProducerId,l:"scr",s:$.sctpStreamParameters},{i:Q.id,pi:Q.dataProducerId,l:"scu",s:Q.sctpStreamParameters}],t:[{i:this._wrtcClientServerTransport.id,f:"cs",d:this._wrtcClientServerTransport.dtlsParameters,ic:this._wrtcClientServerTransport.iceCandidates,ip:this._wrtcClientServerTransport.iceParameters,s:this._wrtcClientServerTransport.sctpParameters},{i:this._wrtcServerClientTransport.id,f:"sc",d:this._wrtcServerClientTransport.dtlsParameters,ic:this._wrtcServerClientTransport.iceCandidates,ip:this._wrtcServerClientTransport.iceParameters,s:this._wrtcServerClientTransport.sctpParameters}]})]),!0};_deserialize(Z){let J=LK1.unpack(Z);if(!J||typeof J!=="object"||typeof J[0]!=="number")return d.error(`Connection._deserialize(): Invalid packet format. Packet: ${JSON.stringify(J)}`);if(!Q0.isValidPacket(J))return d.error(`Connection._deserialize(): Invalid packet payload. Packet: ${JSON.stringify(J)}`);return J}}class nF{_lights=new Map;_nextLightId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}despawnEntityAttachedLights(Z){this.getAllEntityAttachedLights(Z).forEach((J)=>{J.despawn()})}getAllLights(){return Array.from(this._lights.values())}getAllEntityAttachedLights(Z){return this.getAllLights().filter((J)=>J.attachedToEntity===Z)}registerLight(Z){if(Z.id!==void 0)return Z.id;let J=this._nextLightId;return this._lights.set(J,Z),this._nextLightId++,J}unregisterLight(Z){if(Z.id===void 0)return;this._lights.delete(Z.id)}}class B6{_map=new Map;_values=[];_isDirty=!1;get size(){return this._map.size}get valuesArray(){if(this._isDirty)this._syncArray();return this._values}get(Z){return this._map.get(Z)}set(Z,J){let X=this._map.has(Z);if(this._map.set(Z,J),!X)this._values.push(J);else this._isDirty=!0;return this}has(Z){return this._map.has(Z)}delete(Z){let J=this._map.delete(Z);if(J)this._isDirty=!0;return J}clear(){this._map.clear(),this._values.length=0,this._isDirty=!1}forEach(Z,J){this._map.forEach((X,Y)=>{Z.call(J,X,Y,this)})}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}[Symbol.iterator](){return this._map[Symbol.iterator]()}_syncArray(){this._values.length=0;for(let Z of this._map.values())this._values.push(Z);this._isDirty=!1}}var jK1;((X)=>{X[X.POINTLIGHT=0]="POINTLIGHT";X[X.SPOTLIGHT=1]="SPOTLIGHT"})(jK1||={});var gg;((q)=>{q.DESPAWN="LIGHT.DESPAWN";q.SET_ANGLE="LIGHT.SET_ANGLE";q.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";q.SET_COLOR="LIGHT.SET_COLOR";q.SET_DISTANCE="LIGHT.SET_DISTANCE";q.SET_INTENSITY="LIGHT.SET_INTENSITY";q.SET_OFFSET="LIGHT.SET_OFFSET";q.SET_PENUMBRA="LIGHT.SET_PENUMBRA";q.SET_POSITION="LIGHT.SET_POSITION";q.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";q.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";q.SPAWN="LIGHT.SPAWN"})(gg||={});class mg extends j0{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)d.fatalError("Either attachedToEntity or position must be set, but not both.");super();d.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=Z.angle,this._attachedToEntity=Z.attachedToEntity,this._color=Z.color??{r:255,g:255,b:255},this._distance=Z.distance,this._intensity=Z.intensity??1,this._offset=Z.offset,this._penumbra=Z.penumbra,this._position=Z.position,this._trackedEntity=Z.trackedEntity,this._trackedPosition=Z.trackedPosition,this._type=Z.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(Z){if(this._angle===Z)return;if(this._angle=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ANGLE",{light:this,angle:Z})}setAttachedToEntity(Z){if(!Z.isSpawned)return d.error(`Light.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ATTACHED_TO_ENTITY",{light:this,entity:Z})}setColor(Z){if(this._color.r===Z.r&&this._color.g===Z.g&&this._color.b===Z.b)return;if(this._color=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_COLOR",{light:this,color:Z})}setDistance(Z){if(this._distance===Z)return;if(this._distance=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_DISTANCE",{light:this,distance:Z})}setIntensity(Z){if(this._intensity===Z)return;if(this._intensity=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_INTENSITY",{light:this,intensity:Z})}setOffset(Z){if(this._offset&&this._offset.x===Z.x&&this._offset.y===Z.y&&this._offset.z===Z.z)return;if(this._offset=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_OFFSET",{light:this,offset:Z})}setPenumbra(Z){if(this._penumbra===Z)return;if(this._penumbra=Z,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_PENUMBRA",{light:this,penumbra:Z})}setPosition(Z){if(this._position&&this._position.x===Z.x&&this._position.y===Z.y&&this._position.z===Z.z)return;if(this._position=Z,this._attachedToEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_POSITION",{light:this,position:Z})}setTrackedEntity(Z){if(!Z.isSpawned)return d.error(`Light.setTrackedEntity(): Entity ${Z.id} is not spawned!`);if(this._trackedEntity===Z)return;if(this._trackedEntity=Z,this._trackedPosition=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_ENTITY",{light:this,entity:Z})}setTrackedPosition(Z){if(this._trackedPosition===Z)return;if(this._trackedPosition=Z,this._trackedEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_POSITION",{light:this,position:Z})}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(Z){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return d.error(`Light.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning Light!`);this._id=Z.lightManager.registerLight(this),this._world=Z,this.emitWithWorld(Z,"LIGHT.SPAWN",{light:this})}serialize(){return k0.serializeLight(this)}}var ug;((m)=>{m.BURST="PARTICLE_EMITTER.BURST";m.DESPAWN="PARTICLE_EMITTER.DESPAWN";m.SET_ALPHA_TEST="PARTICLE_EMITTER.SET_ALPHA_TEST";m.SET_ATTACHED_TO_ENTITY="PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY";m.SET_ATTACHED_TO_ENTITY_NODE_NAME="PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY_NODE_NAME";m.SET_COLOR_END="PARTICLE_EMITTER.SET_COLOR_END";m.SET_COLOR_END_VARIANCE="PARTICLE_EMITTER.SET_COLOR_END_VARIANCE";m.SET_COLOR_START="PARTICLE_EMITTER.SET_COLOR_START";m.SET_COLOR_START_VARIANCE="PARTICLE_EMITTER.SET_COLOR_START_VARIANCE";m.SET_GRAVITY="PARTICLE_EMITTER.SET_GRAVITY";m.SET_LIFETIME="PARTICLE_EMITTER.SET_LIFETIME";m.SET_LIFETIME_VARIANCE="PARTICLE_EMITTER.SET_LIFETIME_VARIANCE";m.SET_MAX_PARTICLES="PARTICLE_EMITTER.SET_MAX_PARTICLES";m.SET_OFFSET="PARTICLE_EMITTER.SET_OFFSET";m.SET_OPACITY_END="PARTICLE_EMITTER.SET_OPACITY_END";m.SET_OPACITY_END_VARIANCE="PARTICLE_EMITTER.SET_OPACITY_END_VARIANCE";m.SET_OPACITY_START="PARTICLE_EMITTER.SET_OPACITY_START";m.SET_OPACITY_START_VARIANCE="PARTICLE_EMITTER.SET_OPACITY_START_VARIANCE";m.SET_PAUSED="PARTICLE_EMITTER.SET_PAUSED";m.SET_POSITION="PARTICLE_EMITTER.SET_POSITION";m.SET_POSITION_VARIANCE="PARTICLE_EMITTER.SET_POSITION_VARIANCE";m.SET_RATE="PARTICLE_EMITTER.SET_RATE";m.SET_RATE_VARIANCE="PARTICLE_EMITTER.SET_RATE_VARIANCE";m.SET_SIZE_END="PARTICLE_EMITTER.SET_SIZE_END";m.SET_SIZE_END_VARIANCE="PARTICLE_EMITTER.SET_SIZE_END_VARIANCE";m.SET_SIZE_START="PARTICLE_EMITTER.SET_SIZE_START";m.SET_SIZE_START_VARIANCE="PARTICLE_EMITTER.SET_SIZE_START_VARIANCE";m.SET_TEXTURE_URI="PARTICLE_EMITTER.SET_TEXTURE_URI";m.SET_TRANSPARENT="PARTICLE_EMITTER.SET_TRANSPARENT";m.SET_VELOCITY="PARTICLE_EMITTER.SET_VELOCITY";m.SET_VELOCITY_VARIANCE="PARTICLE_EMITTER.SET_VELOCITY_VARIANCE";m.SPAWN="PARTICLE_EMITTER.SPAWN"})(ug||={});class dg extends j0{_id;_alphaTest;_attachedToEntity;_attachedToEntityNodeName;_colorEnd;_colorEndVariance;_colorStart;_colorStartVariance;_gravity;_lifetime;_lifetimeVariance;_maxParticles;_offset;_opacityEnd;_opacityEndVariance;_opacityStart;_opacityStartVariance;_paused;_position;_positionVariance;_rate;_rateVariance;_sizeEnd;_sizeEndVariance;_sizeStart;_sizeStartVariance;_sizeVariance;_textureUri;_transparent;_velocity;_velocityVariance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)d.fatalError("Either attachedToEntity or position must be set, but not both.");if(!Z.textureUri)d.fatalError("ParticleEmitter.constructor(): textureUri must be provided.");super();this._alphaTest=Z.alphaTest??0.5,this._attachedToEntity=Z.attachedToEntity,this._attachedToEntityNodeName=Z.attachedToEntityNodeName,this._colorEnd=Z.colorEnd,this._colorEndVariance=Z.colorEndVariance,this._colorStart=Z.colorStart,this._colorStartVariance=Z.colorStartVariance,this._gravity=Z.gravity,this._lifetime=Z.lifetime,this._lifetimeVariance=Z.lifetimeVariance,this._maxParticles=Z.maxParticles,this._offset=Z.offset,this._opacityEnd=Z.opacityEnd,this._opacityEndVariance=Z.opacityEndVariance,this._opacityStart=Z.opacityStart,this._opacityStartVariance=Z.opacityStartVariance,this._paused=!1,this._position=Z.position,this._positionVariance=Z.positionVariance,this._rate=Z.rate,this._rateVariance=Z.rateVariance,this._sizeEnd=Z.sizeEnd,this._sizeEndVariance=Z.sizeEndVariance,this._sizeStart=Z.sizeStart,this._sizeStartVariance=Z.sizeStartVariance,this._textureUri=Z.textureUri,this._transparent=Z.transparent,this._velocity=Z.velocity,this._velocityVariance=Z.velocityVariance}get id(){return this._id}get alphaTest(){return this._alphaTest}get attachedToEntity(){return this._attachedToEntity}get attachedToEntityNodeName(){return this._attachedToEntityNodeName}get colorEnd(){return this._colorEnd}get colorEndVariance(){return this._colorEndVariance}get colorStart(){return this._colorStart}get colorStartVariance(){return this._colorStartVariance}get gravity(){return this._gravity}get isSpawned(){return this._id!==void 0}get lifetime(){return this._lifetime}get lifetimeVariance(){return this._lifetimeVariance}get maxParticles(){return this._maxParticles}get offset(){return this._offset}get opacityEnd(){return this._opacityEnd}get opacityEndVariance(){return this._opacityEndVariance}get opacityStart(){return this._opacityStart}get opacityStartVariance(){return this._opacityStartVariance}get paused(){return this._paused}get position(){return this._position}get positionVariance(){return this._positionVariance}get rate(){return this._rate}get rateVariance(){return this._rateVariance}get sizeEnd(){return this._sizeEnd}get sizeEndVariance(){return this._sizeEndVariance}get sizeStart(){return this._sizeStart}get sizeStartVariance(){return this._sizeStartVariance}get sizeVariance(){return this._sizeVariance}get textureUri(){return this._textureUri}get transparent(){return this._transparent}get velocity(){return this._velocity}get velocityVariance(){return this._velocityVariance}get world(){return this._world}setAlphaTest(Z){if(this._alphaTest===Z)return;if(this._alphaTest=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_ALPHA_TEST",{particleEmitter:this,alphaTest:Z})}setAttachedToEntity(Z){if(!Z.isSpawned)return d.error(`ParticleEmitter.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY",{particleEmitter:this,entity:Z})}setAttachedToEntityNodeName(Z){if(this._attachedToEntityNodeName===Z)return;if(this._attachedToEntityNodeName=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY_NODE_NAME",{particleEmitter:this,attachedToEntityNodeName:Z})}setColorEnd(Z){if(this._colorEnd&&this._colorEnd.r===Z.r&&this._colorEnd.g===Z.g&&this._colorEnd.b===Z.b)return;if(this._colorEnd=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_END",{particleEmitter:this,colorEnd:Z})}setColorEndVariance(Z){if(this._colorEndVariance&&this._colorEndVariance.r===Z.r&&this._colorEndVariance.g===Z.g&&this._colorEndVariance.b===Z.b)return;if(this._colorEndVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_END_VARIANCE",{particleEmitter:this,colorEndVariance:Z})}setColorStart(Z){if(this._colorStart&&this._colorStart.r===Z.r&&this._colorStart.g===Z.g&&this._colorStart.b===Z.b)return;if(this._colorStart=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_START",{particleEmitter:this,colorStart:Z})}setColorStartVariance(Z){if(this._colorStartVariance&&this._colorStartVariance.r===Z.r&&this._colorStartVariance.g===Z.g&&this._colorStartVariance.b===Z.b)return;if(this._colorStartVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_COLOR_START_VARIANCE",{particleEmitter:this,colorStartVariance:Z})}setGravity(Z){if(this._gravity&&this._gravity.x===Z.x&&this._gravity.y===Z.y&&this._gravity.z===Z.z)return;if(this._gravity=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_GRAVITY",{particleEmitter:this,gravity:Z})}setLifetime(Z){if(this._lifetime===Z)return;if(this._lifetime=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_LIFETIME",{particleEmitter:this,lifetime:Z})}setLifetimeVariance(Z){if(this._lifetimeVariance===Z)return;if(this._lifetimeVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_LIFETIME_VARIANCE",{particleEmitter:this,lifetimeVariance:Z})}setMaxParticles(Z){if(this._maxParticles===Z)return;if(this._maxParticles=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_MAX_PARTICLES",{particleEmitter:this,maxParticles:Z})}setOffset(Z){if(this._offset&&this._offset.x===Z.x&&this._offset.y===Z.y&&this._offset.z===Z.z)return;if(this._offset=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OFFSET",{particleEmitter:this,offset:Z})}setOpacityEnd(Z){if(this._opacityEnd===Z)return;if(this._opacityEnd=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_END",{particleEmitter:this,opacityEnd:Z})}setOpacityEndVariance(Z){if(this._opacityEndVariance===Z)return;if(this._opacityEndVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_END_VARIANCE",{particleEmitter:this,opacityEndVariance:Z})}setOpacityStart(Z){if(this._opacityStart===Z)return;if(this._opacityStart=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_START",{particleEmitter:this,opacityStart:Z})}setOpacityStartVariance(Z){if(this._opacityStartVariance===Z)return;if(this._opacityStartVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_OPACITY_START_VARIANCE",{particleEmitter:this,opacityStartVariance:Z})}setPosition(Z){if(this._position&&this._position.x===Z.x&&this._position.y===Z.y&&this._position.z===Z.z)return;if(this._position=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_POSITION",{particleEmitter:this,position:Z})}setPositionVariance(Z){if(this._positionVariance&&this._positionVariance.x===Z.x&&this._positionVariance.y===Z.y&&this._positionVariance.z===Z.z)return;if(this._positionVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_POSITION_VARIANCE",{particleEmitter:this,positionVariance:Z})}setRate(Z){if(this._rate===Z)return;if(this._rate=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_RATE",{particleEmitter:this,rate:Z})}setRateVariance(Z){if(this._rateVariance===Z)return;if(this._rateVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_RATE_VARIANCE",{particleEmitter:this,rateVariance:Z})}setSizeEnd(Z){if(this._sizeEnd===Z)return;if(this._sizeEnd=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_END",{particleEmitter:this,sizeEnd:Z})}setSizeEndVariance(Z){if(this._sizeEndVariance===Z)return;if(this._sizeEndVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_END_VARIANCE",{particleEmitter:this,sizeEndVariance:Z})}setSizeStart(Z){if(this._sizeStart===Z)return;if(this._sizeStart=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_START",{particleEmitter:this,sizeStart:Z})}setSizeStartVariance(Z){if(this._sizeStartVariance===Z)return;if(this._sizeStartVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_SIZE_START_VARIANCE",{particleEmitter:this,sizeStartVariance:Z})}setTextureUri(Z){if(this._textureUri===Z)return;if(this._textureUri=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_TEXTURE_URI",{particleEmitter:this,textureUri:Z})}setTransparent(Z){if(this._transparent===Z)return;if(this._transparent=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_TRANSPARENT",{particleEmitter:this,transparent:Z})}setVelocity(Z){if(this._velocity&&this._velocity.x===Z.x&&this._velocity.y===Z.y&&this._velocity.z===Z.z)return;if(this._velocity=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_VELOCITY",{particleEmitter:this,velocity:Z})}setVelocityVariance(Z){if(this._velocityVariance&&this._velocityVariance.x===Z.x&&this._velocityVariance.y===Z.y&&this._velocityVariance.z===Z.z)return;if(this._velocityVariance=Z,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_VELOCITY_VARIANCE",{particleEmitter:this,velocityVariance:Z})}burst(Z){if(this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.BURST",{particleEmitter:this,count:Z})}despawn(){if(!this.isSpawned||!this._world)return;this._world.particleEmitterManager.unregisterParticleEmitter(this),this.emitWithWorld(this._world,"PARTICLE_EMITTER.DESPAWN",{particleEmitter:this}),this._id=void 0,this._world=void 0}restart(){if(!this._paused)return;if(this._paused=!1,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_PAUSED",{particleEmitter:this,paused:this._paused})}stop(){if(this._paused)return;if(this._paused=!0,this.isSpawned)this.emitWithWorld(this._world,"PARTICLE_EMITTER.SET_PAUSED",{particleEmitter:this,paused:this._paused})}spawn(Z){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return d.error(`ParticleEmitter.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning ParticleEmitter!`);this._id=Z.particleEmitterManager.registerParticleEmitter(this),this._world=Z,this.emitWithWorld(Z,"PARTICLE_EMITTER.SPAWN",{particleEmitter:this})}serialize(){return k0.serializeParticleEmitter(this)}}var EJ6={x:0,y:-32,z:0},cg=60,lg;(($)=>{$.STEP_START="SIMULATION.STEP_START";$.STEP_END="SIMULATION.STEP_END";$.DEBUG_RAYCAST="SIMULATION.DEBUG_RAYCAST";$.DEBUG_RENDER="SIMULATION.DEBUG_RENDER"})(lg||={});class aF extends j0{_colliderMap=new FH;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_debugRenderingFilterFlags;_rapierEventQueue;_rapierSimulation;_world;constructor(Z,J=cg,X=EJ6){super();this._rapierEventQueue=new Q1.EventQueue(!0),this._rapierSimulation=new Q1.World(X),this._rapierSimulation.timestep=Math.fround(1/J),this._world=Z}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}createRawCollider(Z,J){return this._rapierSimulation.createCollider(Z,J)}createRawRigidBody(Z){return this._rapierSimulation.createRigidBody(Z)}enableDebugRaycasting(Z){this._debugRaycastingEnabled=Z}enableDebugRendering(Z,J=Q1.QueryFilterFlags.EXCLUDE_FIXED){this._debugRenderingEnabled=Z,this._debugRenderingFilterFlags=J}getContactManifolds(Z,J){let X=[];return this._rapierSimulation.narrowPhase.contactPair(Z,J,(Y,$)=>{if(Y.numContacts()===0)return;let Q=Y.normal(),W=[];for(let K=0;K<Y.numSolverContacts();K++)W.push(Y.solverContactPoint(K));X.push({contactPoints:W,localNormalA:!$?Y.localNormal1():Y.localNormal2(),localNormalB:!$?Y.localNormal2():Y.localNormal1(),normal:!$?Q:{x:-Q.x,y:-Q.y,z:-Q.z}})}),X}intersectionsWithRawShape(Z,J,X,Y={}){let $=new Set,Q=[];return this._rapierSimulation.intersectionsWithShape(J,X,Z,(W)=>{let K=this._colliderMap.getColliderHandleBlockType(W.handle);if(K&&!$.has(K))return $.add(K),Q.push({intersectedBlockType:K}),!0;let G=this._colliderMap.getColliderHandleEntity(W.handle);if(G&&!$.has(G))return $.add(G),Q.push({intersectedEntity:G}),!0;return!0},Y.filterFlags,Y.filterGroups,Y.filterExcludeCollider,Y.filterExcludeRigidBody,Y.filterPredicate),Q}raycast(Z,J,X,Y={}){let $=new Q1.Ray(Z,J),Q=this._rapierSimulation.castRay($,X,Y.solidMode??!0,Y.filterFlags,Y.filterGroups,Y.filterExcludeCollider,Y.filterExcludeRigidBody,Y.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:Z,direction:J,length:X,hit:!!Q});if(!Q)return null;let W=$.pointAt(Q.timeOfImpact),K=Q.timeOfImpact,G=Q.collider,z=this._colliderMap.getColliderHandleBlockType(G.handle);if(z)return{hitBlock:JW.fromGlobalCoordinate({x:Math.floor(W.x-($.dir.x<0?0.0001:-0.0001)),y:Math.floor(W.y-($.dir.y<0?0.0001:-0.0001)),z:Math.floor(W.z-($.dir.z<0?0.0001:-0.0001))},z),hitPoint:W,hitDistance:K};let H=this._colliderMap.getColliderHandleEntity(G.handle);if(H)return{hitEntity:H,hitPoint:W,hitDistance:K};return null}removeRawCollider(Z){this._colliderMap.queueColliderHandleForCleanup(Z.handle),this._rapierSimulation.removeCollider(Z,!1)}removeRawRigidBody(Z){this._rapierSimulation.removeRigidBody(Z)}setGravity(Z){this._rapierSimulation.gravity=Z}step=(Z)=>{this.emitWithWorld(this._world,"SIMULATION.STEP_START",{simulation:this,tickDeltaMs:Z});let J=performance.now();if(N8.startSpan({operation:"physics_step"},()=>{this._rapierSimulation.step(this._rapierEventQueue)}),N8.startSpan({operation:"physics_cleanup"},()=>{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()-J}),this._debugRenderingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RENDER",{simulation:this,...this._rapierSimulation.debugRender(this._debugRenderingFilterFlags)})};_onCollisionEvent=(Z,J,X)=>{let[Y,$]=this._getCollisionObjects(Z,J);if(!Y||!$)return;let Q=(W,K)=>{if(W instanceof q9&&K instanceof o8&&W.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))W.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:W,entity:K,started:X,colliderHandleA:Z,colliderHandleB:J});else if(W instanceof o8&&K instanceof q9&&W.hasListeners("ENTITY.BLOCK_COLLISION"))W.emit("ENTITY.BLOCK_COLLISION",{entity:W,blockType:K,started:X,colliderHandleA:Z,colliderHandleB:J});else if(W instanceof o8&&K instanceof o8&&W.hasListeners("ENTITY.ENTITY_COLLISION"))W.emit("ENTITY.ENTITY_COLLISION",{entity:W,otherEntity:K,started:X,colliderHandleA:Z,colliderHandleB:J});else if(typeof W==="function"&&(K instanceof o8||K instanceof q9))W(K,X,Z,J)};Q(Y,$),Q($,Y)};_onContactForceEvent=(Z)=>{let[J,X]=this._getCollisionObjects(Z.collider1(),Z.collider2());if(!J||typeof J==="function"||!X||typeof X==="function")return;let Y={totalForce:Z.totalForce(),totalForceMagnitude:Z.totalForceMagnitude(),maxForceDirection:Z.maxForceDirection(),maxForceMagnitude:Z.maxForceMagnitude()},$=(Q,W)=>{if(Q instanceof q9&&W instanceof o8&&Q.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))Q.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:Q,entity:W,contactForceData:Y});else if(Q instanceof o8&&W instanceof q9&&Q.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))Q.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:Q,blockType:W,contactForceData:Y});else if(Q instanceof o8&&W instanceof o8&&Q.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))Q.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:Q,otherEntity:W,contactForceData:Y})};$(J,X),$(X,J)};_getCollisionObjects(Z,J){let X=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z),Y=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J);return[X,Y]}}class PN{_synchronizedPlayerReliablePackets=new B6;_queuedBroadcasts=[];_queuedAudioSynchronizations=new B6;_queuedBlockSynchronizations=new B6;_queuedBlockTypeSynchronizations=new B6;_queuedChunkSynchronizations=new B6;_queuedDebugRaycastSynchronizations=[];_queuedEntitySynchronizations=new B6;_queuedLightSynchronizations=new B6;_queuedParticleEmitterSynchronizations=new B6;_queuedPerPlayerSynchronizations=new B6;_queuedPerPlayerCameraSynchronizations=new B6;_queuedPerPlayerUISynchronizations=new B6;_queuedPerPlayerUIDatasSynchronizations=new B6;_queuedPlayerSynchronizations=new B6;_queuedSceneUISynchronizations=new B6;_queuedWorldSynchronization;_loadedSceneUIs=new Set;_spawnedChunks=new Set;_spawnedEntities=new Set;_world;constructor(Z){this._world=Z,this._subscribeToAudioEvents(),this._subscribeToBlockTypeRegistryEvents(),this._subscribeToChatEvents(),this._subscribeToChunkLatticeEvents(),this._subscribeToEntityEvents(),this._subscribeToLightEvents(),this._subscribeToParticleEmitterEvents(),this._subscribeToPlayerEvents(),this._subscribeToPlayerCameraEvents(),this._subscribeToPlayerUIEvents(),this._subscribeToSceneUIEvents(),this._subscribeToSimulationEvents(),this._subscribeToWorldEvents()}synchronize(){let Z=[],J=[],X=this._world.loop.currentTick;if(this._queuedPerPlayerSynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerSynchronizations)this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(...$);if(this._queuedEntitySynchronizations.size>0){let Y=[],$=[];for(let Q of this._queuedEntitySynchronizations.valuesArray){let W=!1;for(let K in Q)if(K!=="i"&&K!=="p"&&K!=="r"){W=!0;break}if(W)Y.push(Q);else $.push(Q)}if($.length>0){let Q=Q0.createPacket(Q0.outboundPackets.entitiesPacketDefinition,$,X);J.push(Q)}if(Y.length>0){let Q=Q0.createPacket(Q0.outboundPackets.entitiesPacketDefinition,Y,X);Z.push(Q);for(let W of this._synchronizedPlayerReliablePackets.valuesArray)W.push(Q)}}if(this._queuedAudioSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.audiosPacketDefinition,this._queuedAudioSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedBlockTypeSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.blockTypesPacketDefinition,this._queuedBlockTypeSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedChunkSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.chunksPacketDefinition,this._queuedChunkSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedBlockSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.blocksPacketDefinition,this._queuedBlockSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedLightSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.lightsPacketDefinition,this._queuedLightSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedParticleEmitterSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.particleEmittersPacketDefinition,this._queuedParticleEmitterSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedPerPlayerUISynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerUISynchronizations){let Q=Q0.createPacket(Q0.outboundPackets.uiPacketDefinition,$,X);this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(Q)}if(this._queuedPerPlayerUIDatasSynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerUIDatasSynchronizations){let Q=Q0.createPacket(Q0.outboundPackets.uiDatasPacketDefinition,$,X);this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(Q)}if(this._queuedSceneUISynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.sceneUIsPacketDefinition,this._queuedSceneUISynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedWorldSynchronization){let Y=Q0.createPacket(Q0.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedPerPlayerCameraSynchronizations.size>0)for(let[Y,$]of this._queuedPerPlayerCameraSynchronizations){let Q=Q0.createPacket(Q0.outboundPackets.cameraPacketDefinition,$,X);this._createOrGetSynchronizedPlayerReliablePackets(Y,Z).push(Q)}if(this._queuedPlayerSynchronizations.size>0){let Y=Q0.createPacket(Q0.outboundPackets.playersPacketDefinition,this._queuedPlayerSynchronizations.valuesArray,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedBroadcasts.length>0)for(let Y of this._queuedBroadcasts){Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}if(this._queuedDebugRaycastSynchronizations.length>0){let Y=Q0.createPacket(Q0.outboundPackets.physicsDebugRaycastsPacketDefinition,this._queuedDebugRaycastSynchronizations,X);Z.push(Y);for(let $ of this._synchronizedPlayerReliablePackets.valuesArray)$.push(Y)}N8.startSpan({operation:"send_all_packets"},()=>{for(let Y of j9.instance.getConnectedPlayersByWorld(this._world)){let $=this._synchronizedPlayerReliablePackets.get(Y)??Z;if($.length>0)Y.connection.send($);if(J.length>0)Y.connection.send(J,!1)}}),N8.startSpan({operation:"network_synchronize_cleanup"},()=>{if(this._queuedBroadcasts.length>0)this._queuedBroadcasts.length=0;if(this._queuedAudioSynchronizations.size>0)this._queuedAudioSynchronizations.clear();if(this._queuedBlockSynchronizations.size>0)this._queuedBlockSynchronizations.clear();if(this._queuedBlockTypeSynchronizations.size>0)this._queuedBlockTypeSynchronizations.clear();if(this._queuedChunkSynchronizations.size>0)this._queuedChunkSynchronizations.clear();if(this._queuedDebugRaycastSynchronizations.length>0)this._queuedDebugRaycastSynchronizations.length=0;if(this._queuedEntitySynchronizations.size>0)this._queuedEntitySynchronizations.clear();if(this._queuedLightSynchronizations.size>0)this._queuedLightSynchronizations.clear();if(this._queuedParticleEmitterSynchronizations.size>0)this._queuedParticleEmitterSynchronizations.clear();if(this._queuedPerPlayerSynchronizations.size>0)this._queuedPerPlayerSynchronizations.clear();if(this._queuedPerPlayerCameraSynchronizations.size>0)this._queuedPerPlayerCameraSynchronizations.clear();if(this._queuedPerPlayerUISynchronizations.size>0)this._queuedPerPlayerUISynchronizations.clear();if(this._queuedPerPlayerUIDatasSynchronizations.size>0)this._queuedPerPlayerUIDatasSynchronizations.clear();if(this._queuedPlayerSynchronizations.size>0)this._queuedPlayerSynchronizations.clear();if(this._queuedSceneUISynchronizations.size>0)this._queuedSceneUISynchronizations.clear();if(this._queuedWorldSynchronization)this._queuedWorldSynchronization=void 0;if(this._loadedSceneUIs.size>0)this._loadedSceneUIs.clear();if(this._spawnedChunks.size>0)this._spawnedChunks.clear();if(this._spawnedEntities.size>0)this._spawnedEntities.clear();if(this._synchronizedPlayerReliablePackets.size>0)this._synchronizedPlayerReliablePackets.clear();o4.clearCachedPacketsSerializedBuffers()})}_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_CUTOFF_DISTANCE",this._onAudioSetCutoffDistance),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)}_subscribeToChunkLatticeEvents(){this._world.final("CHUNK_LATTICE.ADD_CHUNK",this._onChunkLatticeAddChunk),this._world.final("CHUNK_LATTICE.REMOVE_CHUNK",this._onChunkLatticeRemoveChunk),this._world.final("CHUNK_LATTICE.SET_BLOCK",this._onChunkLatticeSetBlock)}_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_MODEL_SCALE",this._onEntitySetModelScale),this._world.final("ENTITY.SET_MODEL_SHOWN_NODES",this._onEntitySetModelShownNodes),this._world.final("ENTITY.SET_MODEL_TEXTURE_URI",this._onEntitySetModelTextureUri),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)}_subscribeToParticleEmitterEvents(){this._world.final("PARTICLE_EMITTER.DESPAWN",this._onParticleEmitterDespawn),this._world.final("PARTICLE_EMITTER.BURST",this._onParticleEmitterBurst),this._world.final("PARTICLE_EMITTER.SET_ALPHA_TEST",this._onParticleEmitterSetAlphaTest),this._world.final("PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY",this._onParticleEmitterSetAttachedToEntity),this._world.final("PARTICLE_EMITTER.SET_ATTACHED_TO_ENTITY_NODE_NAME",this._onParticleEmitterSetAttachedToEntityNodeName),this._world.final("PARTICLE_EMITTER.SET_COLOR_END",this._onParticleEmitterSetColorEnd),this._world.final("PARTICLE_EMITTER.SET_COLOR_END_VARIANCE",this._onParticleEmitterSetColorEndVariance),this._world.final("PARTICLE_EMITTER.SET_COLOR_START",this._onParticleEmitterSetColorStart),this._world.final("PARTICLE_EMITTER.SET_COLOR_START_VARIANCE",this._onParticleEmitterSetColorStartVariance),this._world.final("PARTICLE_EMITTER.SET_GRAVITY",this._onParticleEmitterSetGravity),this._world.final("PARTICLE_EMITTER.SET_LIFETIME",this._onParticleEmitterSetLifetime),this._world.final("PARTICLE_EMITTER.SET_LIFETIME_VARIANCE",this._onParticleEmitterSetLifetimeVariance),this._world.final("PARTICLE_EMITTER.SET_MAX_PARTICLES",this._onParticleEmitterSetMaxParticles),this._world.final("PARTICLE_EMITTER.SET_OFFSET",this._onParticleEmitterSetOffset),this._world.final("PARTICLE_EMITTER.SET_OPACITY_END",this._onParticleEmitterSetOpacityEnd),this._world.final("PARTICLE_EMITTER.SET_OPACITY_END_VARIANCE",this._onParticleEmitterSetOpacityEndVariance),this._world.final("PARTICLE_EMITTER.SET_OPACITY_START",this._onParticleEmitterSetOpacityStart),this._world.final("PARTICLE_EMITTER.SET_OPACITY_START_VARIANCE",this._onParticleEmitterSetOpacityStartVariance),this._world.final("PARTICLE_EMITTER.SET_PAUSED",this._onParticleEmitterSetPaused),this._world.final("PARTICLE_EMITTER.SET_POSITION",this._onParticleEmitterSetPosition),this._world.final("PARTICLE_EMITTER.SET_POSITION_VARIANCE",this._onParticleEmitterSetPositionVariance),this._world.final("PARTICLE_EMITTER.SET_RATE",this._onParticleEmitterSetRate),this._world.final("PARTICLE_EMITTER.SET_RATE_VARIANCE",this._onParticleEmitterSetRateVariance),this._world.final("PARTICLE_EMITTER.SET_SIZE_END",this._onParticleEmitterSetSizeEnd),this._world.final("PARTICLE_EMITTER.SET_SIZE_END_VARIANCE",this._onParticleEmitterSetSizeEndVariance),this._world.final("PARTICLE_EMITTER.SET_SIZE_START",this._onParticleEmitterSetSizeStart),this._world.final("PARTICLE_EMITTER.SET_SIZE_START_VARIANCE",this._onParticleEmitterSetSizeStartVariance),this._world.final("PARTICLE_EMITTER.SET_TEXTURE_URI",this._onParticleEmitterSetTextureUri),this._world.final("PARTICLE_EMITTER.SET_TRANSPARENT",this._onParticleEmitterSetTransparent),this._world.final("PARTICLE_EMITTER.SET_VELOCITY",this._onParticleEmitterSetVelocity),this._world.final("PARTICLE_EMITTER.SET_VELOCITY_VARIANCE",this._onParticleEmitterSetVelocityVariance),this._world.final("PARTICLE_EMITTER.SPAWN",this._onParticleEmitterSpawn)}_subscribeToPlayerEvents(){this._world.final("PLAYER.JOINED_WORLD",this._onPlayerJoinedWorld),this._world.final("PLAYER.LEFT_WORLD",this._onPlayerLeftWorld),this._world.final("PLAYER.RECONNECTED_WORLD",this._onPlayerReconnectedWorld),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_MODEL_SHOWN_NODES",this._onPlayerCameraSetModelShownNodes),this._world.final("PLAYER_CAMERA.SET_MODE",this._onPlayerCameraSetMode),this._world.final("PLAYER_CAMERA.SET_OFFSET",this._onPlayerCameraSetOffset),this._world.final("PLAYER_CAMERA.SET_SHOULDER_ANGLE",this._onPlayerCameraSetShoulderAngle),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),this._world.final("WORLD.SET_FOG_COLOR",this._onWorldSetFogColor),this._world.final("WORLD.SET_FOG_FAR",this._onWorldSetFogFar),this._world.final("WORLD.SET_FOG_NEAR",this._onWorldSetFogNear),this._world.final("WORLD.SET_SKYBOX_INTENSITY",this._onWorldSetSkyboxIntensity)}_onAudioPause=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.pa=!0,delete J.pl,delete J.r};_onAudioPlay=(Z)=>{let J=Z.audio.serialize();J.pl=!0,delete J.pa,delete J.r,this._queuedAudioSynchronizations.set(J.i,J)};_onAudioPlayRestart=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.r=!0,delete J.pa,delete J.pl,this._queuedAudioSynchronizations.set(J.i,J)};_onAudioSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onAudioSetCutoffDistance=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.cd=Z.cutoffDistance};_onAudioSetDetune=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.de=Z.detune};_onAudioSetDistortion=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.di=Z.distortion};_onAudioSetPosition=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.e=Z.position?void 0:J.e,J.p=Z.position?k0.serializeVector(Z.position):void 0};_onAudioSetPlaybackRate=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.pr=Z.playbackRate};_onAudioSetReferenceDistance=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.rd=Z.referenceDistance};_onAudioSetVolume=(Z)=>{let J=this._createOrGetQueuedAudioSync(Z.audio);J.v=Z.volume};_onBlockTypeRegistryRegisterBlockType=(Z)=>{let J=Z.blockType.serialize();this._queuedBlockTypeSynchronizations.set(Z.blockType.id,J)};_onChatSendBroadcastMessage=(Z)=>{let{player:J,message:X,color:Y}=Z;this._queuedBroadcasts.push(Q0.createPacket(Q0.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y,p:J?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(Z)=>{let{player:J,message:X,color:Y}=Z,$=this._queuedPerPlayerSynchronizations.get(J)??[];$.push(Q0.createPacket(Q0.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y}],this._world.loop.currentTick)),this._queuedPerPlayerSynchronizations.set(J,$)};_onChunkLatticeAddChunk=(Z)=>{let J=this._createOrGetQueuedChunkSync(Z.chunk);J.b=Array.from(Z.chunk.blocks),J.rm=void 0,this._spawnedChunks.add(J.c.join(","))};_onChunkLatticeRemoveChunk=(Z)=>{let J=this._createOrGetQueuedChunkSync(Z.chunk),X=J.c.join(",");if(this._spawnedChunks.has(X))this._queuedChunkSynchronizations.delete(X),this._spawnedChunks.delete(X);else J.rm=!0};_onChunkLatticeSetBlock=(Z)=>{let J=this._createOrGetQueuedBlockSync(Z.globalCoordinate);J.i=Z.blockTypeId};_onEntitySetModelAnimationsPlaybackRate=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.ap=Z.playbackRate};_onEntitySpawn=(Z)=>{let J=Z.entity.serialize();this._queuedEntitySynchronizations.set(J.i,J),this._spawnedEntities.add(J.i)};_onEntityDespawn=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(this._spawnedEntities.has(J.i))this._queuedEntitySynchronizations.delete(J.i),this._spawnedEntities.delete(J.i);else J.rm=!0};_onEntitySetModelHiddenNodes=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.h=Array.from(Z.modelHiddenNodes)};_onEntitySetModelScale=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.s=Z.modelScale};_onEntitySetModelShownNodes=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.sn=Array.from(Z.modelShownNodes)};_onEntitySetModelTextureUri=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.mt=Z.modelTextureUri};_onEntitySetOpacity=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.o=Z.opacity};_onEntitySetParent=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.pe=Z.parent?Z.parent.id:void 0,J.pn=Z.parentNodeName};_onEntitySetTintColor=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.t=Z.tintColor?k0.serializeRgbColor(Z.tintColor):void 0};_onEntityStartModelLoopedAnimations=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(J.al=Array.from(new Set([...J.al??[],...Z.animations])),J.as)J.as=J.as.filter((X)=>!Z.animations.has(X)).filter(Boolean)};_onEntityStartModelOneshotAnimations=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(J.ao=Array.from(new Set([...J.ao??[],...Z.animations])),J.as)J.as=J.as.filter((X)=>!Z.animations.has(X)).filter(Boolean)};_onEntityStopModelAnimations=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);if(J.al)J.al=J.al.filter((X)=>!Z.animations.has(X)).filter(Boolean);if(J.ao)J.ao=J.ao.filter((X)=>!Z.animations.has(X)).filter(Boolean);J.as=Array.from(new Set([...J.as??[],...Z.animations]))};_onEntityUpdateRotation=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.r=[Z.rotation.x,Z.rotation.y,Z.rotation.z,Z.rotation.w]};_onEntityUpdatePosition=(Z)=>{let J=this._createOrGetQueuedEntitySync(Z.entity);J.p=[Z.position.x,Z.position.y,Z.position.z]};_onLightDespawn=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.rm=!0};_onLightSetAngle=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.a=Z.angle};_onLightSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onLightSetColor=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.c=k0.serializeRgbColor(Z.color)};_onLightSetDistance=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.d=Z.distance};_onLightSetIntensity=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.n=Z.intensity};_onLightSetOffset=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onLightSetPenumbra=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.pe=Z.penumbra};_onLightSetPosition=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.p=Z.position?k0.serializeVector(Z.position):void 0,J.e=Z.position?void 0:J.e};_onLightSetTrackedEntity=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.te=Z.entity?Z.entity.id:void 0,J.tp=Z.entity?void 0:J.tp};_onLightSetTrackedPosition=(Z)=>{let J=this._createOrGetQueuedLightSync(Z.light);J.tp=Z.position?k0.serializeVector(Z.position):void 0,J.te=Z.position?void 0:J.te};_onLightSpawn=(Z)=>{let J=Z.light.serialize();this._queuedLightSynchronizations.set(J.i,J)};_onParticleEmitterBurst=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.b=Z.count};_onParticleEmitterDespawn=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.rm=!0};_onParticleEmitterSetAlphaTest=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.at=Z.alphaTest};_onParticleEmitterSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onParticleEmitterSetAttachedToEntityNodeName=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.en=Z.attachedToEntityNodeName};_onParticleEmitterSetColorEnd=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.ce=Z.colorEnd?k0.serializeRgbColor(Z.colorEnd):void 0};_onParticleEmitterSetColorEndVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.cev=Z.colorEndVariance?k0.serializeRgbColor(Z.colorEndVariance):void 0};_onParticleEmitterSetColorStart=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.cs=Z.colorStart?k0.serializeRgbColor(Z.colorStart):void 0};_onParticleEmitterSetColorStartVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.csv=Z.colorStartVariance?k0.serializeRgbColor(Z.colorStartVariance):void 0};_onParticleEmitterSetGravity=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.g=Z.gravity?k0.serializeVector(Z.gravity):void 0};_onParticleEmitterSetLifetime=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.l=Z.lifetime};_onParticleEmitterSetLifetimeVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.lv=Z.lifetimeVariance};_onParticleEmitterSetMaxParticles=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.mp=Z.maxParticles};_onParticleEmitterSetOffset=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onParticleEmitterSetOpacityEnd=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.oe=Z.opacityEnd};_onParticleEmitterSetOpacityEndVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.oev=Z.opacityEndVariance};_onParticleEmitterSetOpacityStart=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.os=Z.opacityStart};_onParticleEmitterSetOpacityStartVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.osv=Z.opacityStartVariance};_onParticleEmitterSetPaused=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.pa=Z.paused};_onParticleEmitterSetPosition=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.p=Z.position?k0.serializeVector(Z.position):void 0,J.e=Z.position?void 0:J.e,J.en=Z.position?void 0:J.en};_onParticleEmitterSetPositionVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.pv=Z.positionVariance?k0.serializeVector(Z.positionVariance):void 0};_onParticleEmitterSetRate=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.r=Z.rate};_onParticleEmitterSetRateVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.rv=Z.rateVariance};_onParticleEmitterSetSizeEnd=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.se=Z.sizeEnd};_onParticleEmitterSetSizeEndVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.sev=Z.sizeEndVariance};_onParticleEmitterSetSizeStart=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.ss=Z.sizeStart};_onParticleEmitterSetSizeStartVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.ssv=Z.sizeStartVariance};_onParticleEmitterSetTextureUri=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.tu=Z.textureUri};_onParticleEmitterSetTransparent=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.t=Z.transparent};_onParticleEmitterSetVelocity=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.v=Z.velocity?k0.serializeVector(Z.velocity):void 0};_onParticleEmitterSetVelocityVariance=(Z)=>{let J=this._createOrGetQueuedParticleEmitterSync(Z.particleEmitter);J.vv=Z.velocityVariance?k0.serializeVector(Z.velocityVariance):void 0};_onParticleEmitterSpawn=(Z)=>{let J=Z.particleEmitter.serialize();this._queuedParticleEmitterSynchronizations.set(J.i,J)};_onPlayerCameraLookAtEntity=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.pl=k0.serializeVector(Z.entity.position),delete J.et,delete J.pt};_onPlayerCameraLookAtPosition=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.pl=Z.position?k0.serializeVector(Z.position):void 0,delete J.et,delete J.pt};_onPlayerCameraSetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.e=Z.entity.id,delete J.p};_onPlayerCameraSetAttachedToPosition=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.p=Z.position?k0.serializeVector(Z.position):void 0,delete J.e};_onPlayerCameraSetFilmOffset=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.fo=Z.filmOffset};_onPlayerCameraSetForwardOffset=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.ffo=Z.forwardOffset};_onPlayerCameraSetFov=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.fv=Z.fov};_onPlayerCameraSetModelHiddenNodes=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.h=Array.from(Z.modelHiddenNodes)};_onPlayerCameraSetModelShownNodes=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.s=Array.from(Z.modelShownNodes)};_onPlayerCameraSetMode=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.m=Z.mode};_onPlayerCameraSetOffset=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onPlayerCameraSetShoulderAngle=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.sa=Z.shoulderAngle};_onPlayerCameraSetTrackedEntity=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.et=Z.entity?Z.entity.id:void 0,delete J.pl,delete J.pt};_onPlayerCameraSetTrackedPosition=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.pt=Z.position?k0.serializeVector(Z.position):void 0,delete J.et,delete J.pl};_onPlayerCameraSetZoom=(Z)=>{let J=this._createOrGetQueuedPlayerCameraSync(Z.playerCamera);J.z=Z.zoom};_onPlayerJoinedWorld=(Z)=>{let{player:J}=Z,X=this._queuedPerPlayerSynchronizations.get(J)??[];X.push(Q0.createPacket(Q0.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map(($)=>{if(J.camera.attachedToEntity===void 0&&$ instanceof y7&&$.player===J)J.camera.setAttachedToEntity($);return $.serialize()}),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllAudios().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.particleEmittersPacketDefinition,this._world.particleEmitterManager.getAllParticleEmitters().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map(($)=>$.serialize()),this._world.loop.currentTick)),X.push(Q0.createPacket(Q0.outboundPackets.playersPacketDefinition,j9.instance.getConnectedPlayers().map(($)=>$.serialize()),this._world.loop.currentTick));let Y=this._createOrGetQueuedPlayerCameraSync(J.camera);this._queuedPerPlayerCameraSynchronizations.set(J,{...J.camera.serialize(),...Y}),this._queuedPerPlayerSynchronizations.set(J,X),this._queuedPlayerSynchronizations.set(J.id,J.serialize())};_onPlayerLeftWorld=(Z)=>{let J=this._createOrGetQueuedPlayerSync(Z.player);J.rm=!0};_onPlayerReconnectedWorld=(Z)=>{this._onPlayerJoinedWorld(Z)};_onPlayerRequestSync=(Z)=>{Z.player.connection.send([Q0.createPacket(Q0.outboundPackets.syncResponsePacketDefinition,{r:Z.receivedAt,s:Date.now(),p:performance.now()-Z.receivedAtMs,n:this._world.loop.nextTickMs},this._world.loop.currentTick)])};_onPlayerUILoad=(Z)=>{let J=this._createOrGetQueuedPlayerUISync(Z.playerUI);J.u=Z.htmlUri};_onPlayerUILockPointer=(Z)=>{let J=this._createOrGetQueuedPlayerUISync(Z.playerUI);J.p=Z.lock};_onPlayerUISendData=(Z)=>{this._createOrGetQueuedPlayerUIDatasSync(Z.playerUI).push(Z.data)};_onSceneUILoad=(Z)=>{let J=Z.sceneUI.serialize();this._queuedSceneUISynchronizations.set(J.i,J),this._loadedSceneUIs.add(J.i)};_onSceneUISetAttachedToEntity=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.e=Z.entity?Z.entity.id:void 0,J.p=Z.entity?void 0:J.p};_onSceneUISetOffset=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.o=Z.offset?k0.serializeVector(Z.offset):void 0};_onSceneUISetPosition=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.p=Z.position?k0.serializeVector(Z.position):void 0,J.e=Z.position?void 0:J.e};_onSceneUISetState=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.s=Z.state};_onSceneUISetViewDistance=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);J.v=Z.viewDistance};_onSceneUIUnload=(Z)=>{let J=this._createOrGetQueuedSceneUISync(Z.sceneUI);if(this._loadedSceneUIs.has(J.i))this._queuedSceneUISynchronizations.delete(J.i),this._loadedSceneUIs.delete(J.i);else J.rm=!0};_onSimulationDebugRaycast=(Z)=>{this._queuedDebugRaycastSynchronizations.push(k0.serializePhysicsDebugRaycast(Z))};_onSimulationDebugRender=(Z)=>{this._queuedBroadcasts.push(Q0.createPacket(Q0.outboundPackets.physicsDebugRenderPacketDefinition,{v:Array.from(Z.vertices),c:Array.from(Z.colors)},this._world.loop.currentTick))};_onWorldSetAmbientLightColor=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.ac=k0.serializeRgbColor(Z.color)};_onWorldSetAmbientLightIntensity=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.ai=Z.intensity};_onWorldSetDirectionalLightColor=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.dc=k0.serializeRgbColor(Z.color)};_onWorldSetDirectionalLightIntensity=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.di=Z.intensity};_onWorldSetDirectionalLightPosition=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.dp=k0.serializeVector(Z.position)};_onWorldSetFogColor=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.fc=k0.serializeRgbColor(Z.color)};_onWorldSetFogFar=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.ff=Z.far};_onWorldSetFogNear=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.fn=Z.near};_onWorldSetSkyboxIntensity=(Z)=>{let J=this._createOrGetQueuedWorldSync(Z.world);J.si=Z.intensity};_createOrGetQueuedAudioSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");let J=this._queuedAudioSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedAudioSynchronizations.set(Z.id,J);return J}_createOrGetQueuedBlockSync(Z){let{x:J,y:X,z:Y}=Z,$=`${J},${X},${Y}`,Q=this._queuedBlockSynchronizations.get($);if(!Q)Q={i:0,c:[J,X,Y]},this._queuedBlockSynchronizations.set($,Q);return Q}_createOrGetQueuedChunkSync(Z){if(!Z.originCoordinate)d.fatalError("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:J,y:X,z:Y}=Z.originCoordinate,$=`${J},${X},${Y}`,Q=this._queuedChunkSynchronizations.get($);if(!Q)Q={c:[J,X,Y]},this._queuedChunkSynchronizations.set($,Q);return Q}_createOrGetQueuedEntitySync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");let J=this._queuedEntitySynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedEntitySynchronizations.set(Z.id,J);return J}_createOrGetQueuedLightSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");let J=this._queuedLightSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedLightSynchronizations.set(Z.id,J);return J}_createOrGetQueuedParticleEmitterSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedParticleEmitterSync(): ParticleEmitter has no id!");let J=this._queuedParticleEmitterSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedParticleEmitterSynchronizations.set(Z.id,J);return J}_createOrGetQueuedPlayerSync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedPlayerSync(): Player has no id!");let J=this._queuedPlayerSynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedPlayerSynchronizations.set(Z.id,J);return J}_createOrGetQueuedPlayerCameraSync(Z){let J=this._queuedPerPlayerCameraSynchronizations.get(Z.player);if(!J)J={},this._queuedPerPlayerCameraSynchronizations.set(Z.player,J);return J}_createOrGetQueuedPlayerUISync(Z){let J=this._queuedPerPlayerUISynchronizations.get(Z.player);if(!J)J={},this._queuedPerPlayerUISynchronizations.set(Z.player,J);return J}_createOrGetQueuedPlayerUIDatasSync(Z){let J=this._queuedPerPlayerUIDatasSynchronizations.get(Z.player);if(!J)J=[],this._queuedPerPlayerUIDatasSynchronizations.set(Z.player,J);return J}_createOrGetQueuedSceneUISync(Z){if(Z.id===void 0)d.fatalError("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");let J=this._queuedSceneUISynchronizations.get(Z.id);if(!J)J={i:Z.id},this._queuedSceneUISynchronizations.set(Z.id,J);return J}_createOrGetQueuedWorldSync(Z){if(Z.id!==this._world.id)d.fatalError("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:Z.id}}_createOrGetSynchronizedPlayerReliablePackets(Z,J){let X=this._synchronizedPlayerReliablePackets.get(Z);if(!X)X=[...J],this._synchronizedPlayerReliablePackets.set(Z,X);return X}}class sF{_particleEmitters=new Map;_nextParticleEmitterId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}despawnEntityAttachedParticleEmitters(Z){this.getAllEntityAttachedParticleEmitters(Z).forEach((J)=>{J.despawn()})}getAllParticleEmitters(){return Array.from(this._particleEmitters.values())}getAllEntityAttachedParticleEmitters(Z){return this.getAllParticleEmitters().filter((J)=>J.attachedToEntity===Z)}registerParticleEmitter(Z){if(Z.id!==void 0)return Z.id;let J=this._nextParticleEmitterId;return this._particleEmitters.set(J,Z),this._nextParticleEmitterId++,J}unregisterParticleEmitter(Z){if(Z.id===void 0)return;this._particleEmitters.delete(Z.id)}}class oF{_sceneUIs=new Map;_nextSceneUIId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}getAllSceneUIs(){return Array.from(this._sceneUIs.values())}getAllEntityAttachedSceneUIs(Z){return this.getAllSceneUIs().filter((J)=>J.attachedToEntity===Z)}getSceneUIById(Z){return this._sceneUIs.get(Z)}registerSceneUI(Z){if(Z.id!==void 0)return Z.id;let J=this._nextSceneUIId;return this._sceneUIs.set(J,Z),this._nextSceneUIId++,J}unloadEntityAttachedSceneUIs(Z){this.getAllEntityAttachedSceneUIs(Z).forEach((J)=>{J.unload()})}unregisterSceneUI(Z){if(Z.id===void 0)return;this._sceneUIs.delete(Z.id)}}var IJ6=2,vJ6=3;class rF{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_maxAccumulatorMs;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(Z,J,X){this._targetTicksPerSecond=Z,this._fixedTimestepS=Math.fround(1/Z),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._maxAccumulatorMs=this._fixedTimestepMs*vJ6,this._tickFunction=J,this._tickErrorCallback=X}get targetTicksPerSecond(){return this._targetTicksPerSecond}get fixedTimestepMs(){return this._fixedTimestepMs}get fixedTimestepS(){return this._fixedTimestepS}get isStarted(){return!!this._tickHandle}get nextTickMs(){return this._nextTickMs}start(){if(this._tickHandle)return;this._lastLoopTimeMs=performance.now();let Z=()=>{let J=performance.now(),X=J-this._lastLoopTimeMs;if(this._lastLoopTimeMs=J,this._accumulatorMs+=X,this._accumulatorMs>this._maxAccumulatorMs)this._accumulatorMs=this._maxAccumulatorMs;if(this._accumulatorMs>=this._fixedTimestepMs)N8.startSpan({operation:"ticker_tick"},()=>{let Y=0;while(this._accumulatorMs>=this._fixedTimestepMs&&Y<IJ6)this._tick(this._fixedTimestepMs),this._accumulatorMs-=this._fixedTimestepMs,Y++});this._nextTickMs=Math.max(0,this._fixedTimestepMs-this._accumulatorMs),this._tickHandle=setTimeout(Z,this._nextTickMs)};Z()}stop(){if(!this._tickHandle)return;clearTimeout(this._tickHandle),this._tickHandle=null}_tick(Z){try{this._tickFunction(Z)}catch(J){if(J instanceof Error&&this._tickErrorCallback)this._tickErrorCallback(J);else d.warning(`Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error: ${J}`)}}}var OK1;((Q)=>{Q.START="WORLD_LOOP.START";Q.STOP="WORLD_LOOP.STOP";Q.TICK_START="WORLD_LOOP.TICK_START";Q.TICK_END="WORLD_LOOP.TICK_END";Q.TICK_ERROR="WORLD_LOOP.TICK_ERROR"})(OK1||={});class tF extends j0{_currentTick=0;_ticker;_world;constructor(Z,J=cg){super();this._ticker=new rF(J,this._tick,this._onTickError),this._world=Z}get currentTick(){return this._currentTick}get isStarted(){return this._ticker.isStarted}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=(Z)=>{this.emitWithWorld(this._world,"WORLD_LOOP.TICK_START",{worldLoop:this,tickDeltaMs:Z});let J=performance.now();N8.startSpan({operation:"world_tick",attributes:{serverPlayerCount:j9.instance.playerCount,targetTickRate:this._ticker.targetTicksPerSecond,targetTickRateMs:this._ticker.fixedTimestepMs,worldId:this._world.id,worldName:this._world.name,worldChunkCount:this._world.chunkLattice.chunkCount,worldEntityCount:this._world.entityManager.entityCount,worldLoopTick:this._currentTick}},()=>{N8.startSpan({operation:"entities_tick"},()=>this._world.entityManager.tickEntities(Z)),N8.startSpan({operation:"simulation_step"},()=>this._world.simulation.step(Z)),N8.startSpan({operation:"entities_emit_updates"},()=>this._world.entityManager.checkAndEmitUpdates()),N8.startSpan({operation:"network_synchronize"},()=>this._world.networkSynchronizer.synchronize())}),this._currentTick++,this.emitWithWorld(this._world,"WORLD_LOOP.TICK_END",{worldLoop:this,tickDurationMs:performance.now()-J})};_onTickError=(Z)=>{d.error(`WorldLoop._onTickError(): Error: ${Z}`),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:Z})}}var pg;((V)=>{V.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";V.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";V.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";V.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";V.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";V.SET_FOG_COLOR="WORLD.SET_FOG_COLOR";V.SET_FOG_FAR="WORLD.SET_FOG_FAR";V.SET_FOG_NEAR="WORLD.SET_FOG_NEAR";V.SET_SKYBOX_INTENSITY="WORLD.SET_SKYBOX_INTENSITY";V.START="WORLD.START";V.STOP="WORLD.STOP"})(pg||={});class eF extends j0{_id;_ambientLightColor;_ambientLightIntensity;_directionalLightColor;_directionalLightIntensity;_directionalLightPosition;_fogColor;_fogFar;_fogNear;_name;_skyboxIntensity;_skyboxUri;_audioManager;_blockTypeRegistry;_chatManager;_chunkLattice;_entityManager;_lightManager;_loop;_networkSynchronizer;_particleEmitterManager;_sceneUIManager;_simulation;_tag;constructor(Z){super();if(this._id=Z.id,this._ambientLightColor=Z.ambientLightColor??{r:255,g:255,b:255},this._ambientLightIntensity=Z.ambientLightIntensity??1,this._directionalLightColor=Z.directionalLightColor??{r:255,g:255,b:255},this._directionalLightIntensity=Z.directionalLightIntensity??3,this._directionalLightPosition=Z.directionalLightPosition??{x:100,y:150,z:100},this._fogColor=Z.fogColor,this._fogFar=Z.fogFar??550,this._fogNear=Z.fogNear??500,this._name=Z.name,this._skyboxIntensity=Z.skyboxIntensity??1,this._skyboxUri=Z.skyboxUri,this._tag=Z.tag,this._audioManager=new zG(this),this._blockTypeRegistry=new hz(this),this._chatManager=new VH(this),this._chunkLattice=new qH(this),this._entityManager=new BH(this),this._lightManager=new nF(this),this._loop=new tF(this,Z.tickRate),this._networkSynchronizer=new PN(this),this._particleEmitterManager=new sF(this),this._sceneUIManager=new oF(this),this._simulation=new aF(this,Z.tickRate,Z.gravity),Z.map)this.loadMap(Z.map)}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 fogColor(){return this._fogColor}get fogFar(){return this._fogFar}get fogNear(){return this._fogNear}get name(){return this._name}get skyboxIntensity(){return this._skyboxIntensity}get skyboxUri(){return this._skyboxUri}get audioManager(){return this._audioManager}get tag(){return this._tag}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 particleEmitterManager(){return this._particleEmitterManager}get sceneUIManager(){return this._sceneUIManager}get simulation(){return this._simulation}loadMap(Z){if(this.chunkLattice.clear(),Z.blockTypes)for(let J of Z.blockTypes)this.blockTypeRegistry.registerGenericBlockType({id:J.id,isLiquid:J.isLiquid,name:J.name,textureUri:J.textureUri});if(Z.blocks)for(let[J,X]of Object.entries(Z.blocks)){let[Y,$,Q]=J.split(",").map(Number);this.chunkLattice.setBlock({x:Y,y:$,z:Q},X)}if(Z.entities)for(let[J,X]of Object.entries(Z.entities)){let[Y,$,Q]=J.split(",").map(Number);new o8({isEnvironmental:!0,...X}).spawn(this,{x:Y,y:$,z:Q})}}setAmbientLightColor(Z){this._ambientLightColor=Z,this.emit("WORLD.SET_AMBIENT_LIGHT_COLOR",{world:this,color:Z})}setAmbientLightIntensity(Z){this._ambientLightIntensity=Z,this.emit("WORLD.SET_AMBIENT_LIGHT_INTENSITY",{world:this,intensity:Z})}setDirectionalLightColor(Z){this._directionalLightColor=Z,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",{world:this,color:Z})}setDirectionalLightIntensity(Z){this._directionalLightIntensity=Z,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",{world:this,intensity:Z})}setDirectionalLightPosition(Z){this._directionalLightPosition=Z,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",{world:this,position:Z})}setFogColor(Z){this._fogColor=Z,this.emit("WORLD.SET_FOG_COLOR",{world:this,color:Z})}setFogFar(Z){this._fogFar=Z,this.emit("WORLD.SET_FOG_FAR",{world:this,far:Z})}setFogNear(Z){this._fogNear=Z,this.emit("WORLD.SET_FOG_NEAR",{world:this,near:Z})}setSkyboxIntensity(Z){this._skyboxIntensity=Z,this.emit("WORLD.SET_SKYBOX_INTENSITY",{world:this,intensity:Z})}start(){if(this._loop.isStarted)return;this._loop.start(),this.emit("WORLD.START",{world:this,startedAtMs:Date.now()})}stop(){if(!this._loop.isStarted)return;this._loop.stop(),this.emit("WORLD.STOP",{world:this,stoppedAtMs:Date.now()})}serialize(){return k0.serializeWorld(this)}}var MK1;((J)=>J.WORLD_CREATED="WORLD_MANAGER.WORLD_CREATED")(MK1||={});class cY{static instance=new cY;_defaultWorld;_nextWorldId=1;_worlds=new Map;createWorld(Z){let J=new eF({...Z,id:this._nextWorldId++});return J.start(),this._worlds.set(J.id,J),j0.globalInstance.emit("WORLD_MANAGER.WORLD_CREATED",{world:J}),J}getAllWorlds(){return Array.from(this._worlds.values())}getDefaultWorld(){return this._defaultWorld??=this.createWorld({name:"Default World",skyboxUri:"skyboxes/partly-cloudy"}),this._defaultWorld}getWorldsByTag(Z){let J=[];return this._worlds.forEach((X)=>{if(X.tag===Z)J.push(X)}),J}getWorld(Z){return this._worlds.get(Z)}setDefaultWorld(Z){this._defaultWorld=Z}}var RK1;((Y)=>{Y.PLAYER_CONNECTED="PLAYER_MANAGER.PLAYER_CONNECTED";Y.PLAYER_DISCONNECTED="PLAYER_MANAGER.PLAYER_DISCONNECTED";Y.PLAYER_RECONNECTED="PLAYER_MANAGER.PLAYER_RECONNECTED"})(RK1||={});class j9{static instance=new j9;worldSelectionHandler;_connectionPlayers=new Map;constructor(){j0.globalInstance.on("CONNECTION.OPENED",({connection:Z,req:J})=>{this._onConnectionOpened(Z,J.session)}),j0.globalInstance.on("CONNECTION.DISCONNECTED",({connection:Z})=>{this._onConnectionDisconnected(Z)}),j0.globalInstance.on("CONNECTION.RECONNECTED",({connection:Z})=>{this._onConnectionReconnected(Z)}),j0.globalInstance.on("CONNECTION.CLOSED",({connection:Z})=>{this._onConnectionClosed(Z)})}get playerCount(){return this._connectionPlayers.size}getConnectedPlayers(){return Array.from(this._connectionPlayers.values())}getConnectedPlayersByWorld(Z){return this.getConnectedPlayers().filter((J)=>J.world===Z)}getConnectedPlayerByUsername(Z){return Array.from(this._connectionPlayers.values()).find((J)=>{return J.username.toLowerCase()===Z.toLowerCase()})}async _onConnectionOpened(Z,J){let X=new QK(Z,J);await X.loadInitialPersistedData(),this._connectionPlayers.set(Z,X),j0.globalInstance.emit("PLAYER_MANAGER.PLAYER_CONNECTED",{player:X});let Y=await this.worldSelectionHandler?.(X);X.joinWorld(Y??cY.instance.getDefaultWorld())}_onConnectionDisconnected(Z){let J=this._connectionPlayers.get(Z);if(J)J.resetInputs(),J.camera.reset()}_onConnectionReconnected(Z){let J=this._connectionPlayers.get(Z);if(J)J.reconnected(),j0.globalInstance.emit("PLAYER_MANAGER.PLAYER_RECONNECTED",{player:J});else d.warning(`PlayerManager._onConnectionReconnected(): Connection ${Z.id} not in the PlayerManager._connectionPlayers map.`)}_onConnectionClosed(Z){let J=this._connectionPlayers.get(Z);if(J)J.disconnect(),this._connectionPlayers.delete(Z),j0.globalInstance.emit("PLAYER_MANAGER.PLAYER_DISCONNECTED",{player:J});else d.warning(`PlayerManager._onConnectionClosed(): Connection ${Z.id} not in the PlayerManager._connectionPlayers map.`)}}Buffer.poolSize=134217728;var NK1;((X)=>{X.START="GAMESERVER.START";X.STOP="GAMESERVER.STOP"})(NK1||={});function SJ6(Z){Q1.init().then(()=>{return oQ.instance.modelRegistry.preloadModels()}).then(()=>{if(Z.length>0)Z(oQ.instance.worldManager.getDefaultWorld());else Z();oQ.instance.start()}).catch((J)=>{d.fatalError(`Failed to initialize the game engine, exiting. Error: ${J}`)})}class oQ{static _instance;_modelRegistry=h5.instance;_playerManager=j9.instance;_socket=a7.instance;_worldManager=cY.instance;_webServer=mK.instance;constructor(){}static get instance(){if(!this._instance)this._instance=new oQ;return this._instance}get modelRegistry(){return this._modelRegistry}get playerManager(){return this._playerManager}get socket(){return this._socket}get webServer(){return this._webServer}get worldManager(){return this._worldManager}start(){j0.globalInstance.emit("GAMESERVER.START",{startedAtMs:performance.now()}),this._webServer.start()}}var v0=0.000001,z1=typeof Float32Array!=="undefined"?Float32Array:Array,jZ=Math.random;var CX5=Math.PI/180;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};var i8={};_9(i8,{transpose:()=>yJ6,subtract:()=>PK1,sub:()=>JX6,str:()=>iJ6,set:()=>bJ6,scale:()=>cJ6,rotate:()=>dJ6,multiplyScalarAndAdd:()=>eJ6,multiplyScalar:()=>tJ6,multiply:()=>DK1,mul:()=>ZX6,invert:()=>gJ6,identity:()=>hJ6,fromValues:()=>fJ6,fromScaling:()=>pJ6,fromRotation:()=>lJ6,frob:()=>nJ6,exactEquals:()=>oJ6,equals:()=>rJ6,determinant:()=>uJ6,create:()=>_J6,copy:()=>xJ6,clone:()=>AJ6,adjoint:()=>mJ6,add:()=>sJ6,LDU:()=>aJ6});function _J6(){var Z=new z1(4);if(z1!=Float32Array)Z[1]=0,Z[2]=0;return Z[0]=1,Z[3]=1,Z}function AJ6(Z){var J=new z1(4);return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function xJ6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function hJ6(Z){return Z[0]=1,Z[1]=0,Z[2]=0,Z[3]=1,Z}function fJ6(Z,J,X,Y){var $=new z1(4);return $[0]=Z,$[1]=J,$[2]=X,$[3]=Y,$}function bJ6(Z,J,X,Y,$){return Z[0]=J,Z[1]=X,Z[2]=Y,Z[3]=$,Z}function yJ6(Z,J){if(Z===J){var X=J[1];Z[1]=J[2],Z[2]=X}else Z[0]=J[0],Z[1]=J[2],Z[2]=J[1],Z[3]=J[3];return Z}function gJ6(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=X*Q-$*Y;if(!W)return null;return W=1/W,Z[0]=Q*W,Z[1]=-Y*W,Z[2]=-$*W,Z[3]=X*W,Z}function mJ6(Z,J){var X=J[0];return Z[0]=J[3],Z[1]=-J[1],Z[2]=-J[2],Z[3]=X,Z}function uJ6(Z){return Z[0]*Z[3]-Z[2]*Z[1]}function DK1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=X[0],G=X[1],z=X[2],H=X[3];return Z[0]=Y*K+Q*G,Z[1]=$*K+W*G,Z[2]=Y*z+Q*H,Z[3]=$*z+W*H,Z}function dJ6(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G+Q*K,Z[1]=$*G+W*K,Z[2]=Y*-K+Q*G,Z[3]=$*-K+W*G,Z}function cJ6(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=X[0],G=X[1];return Z[0]=Y*K,Z[1]=$*K,Z[2]=Q*G,Z[3]=W*G,Z}function lJ6(Z,J){var X=Math.sin(J),Y=Math.cos(J);return Z[0]=Y,Z[1]=X,Z[2]=-X,Z[3]=Y,Z}function pJ6(Z,J){return Z[0]=J[0],Z[1]=0,Z[2]=0,Z[3]=J[1],Z}function iJ6(Z){return"mat2("+Z[0]+", "+Z[1]+", "+Z[2]+", "+Z[3]+")"}function nJ6(Z){return Math.hypot(Z[0],Z[1],Z[2],Z[3])}function aJ6(Z,J,X,Y){return Z[2]=Y[2]/Y[0],X[0]=Y[0],X[1]=Y[1],X[3]=Y[3]-Z[2]*X[1],[Z,J,X]}function sJ6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function PK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z}function oJ6(Z,J){return Z[0]===J[0]&&Z[1]===J[1]&&Z[2]===J[2]&&Z[3]===J[3]}function rJ6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=Z[3],W=J[0],K=J[1],G=J[2],z=J[3];return Math.abs(X-W)<=v0*Math.max(1,Math.abs(X),Math.abs(W))&&Math.abs(Y-K)<=v0*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs($-G)<=v0*Math.max(1,Math.abs($),Math.abs(G))&&Math.abs(Q-z)<=v0*Math.max(1,Math.abs(Q),Math.abs(z))}function tJ6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function eJ6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z[2]=J[2]+X[2]*Y,Z[3]=J[3]+X[3]*Y,Z}var ZX6=DK1,JX6=PK1;var e1={};_9(e1,{transpose:()=>GX6,translate:()=>qX6,subtract:()=>TK1,sub:()=>vX6,str:()=>NX6,set:()=>WX6,scale:()=>UX6,rotate:()=>FX6,projection:()=>RX6,normalFromMat4:()=>MX6,multiplyScalarAndAdd:()=>TX6,multiplyScalar:()=>CX6,multiply:()=>CK1,mul:()=>IX6,invert:()=>zX6,identity:()=>KX6,fromValues:()=>QX6,fromTranslation:()=>wX6,fromScaling:()=>LX6,fromRotation:()=>BX6,fromQuat:()=>OX6,fromMat4:()=>XX6,fromMat2d:()=>jX6,frob:()=>DX6,exactEquals:()=>kX6,equals:()=>EX6,determinant:()=>VX6,create:()=>ig,copy:()=>$X6,clone:()=>YX6,adjoint:()=>HX6,add:()=>PX6});function ig(){var Z=new z1(9);if(z1!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function XX6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[4],Z[4]=J[5],Z[5]=J[6],Z[6]=J[8],Z[7]=J[9],Z[8]=J[10],Z}function YX6(Z){var J=new z1(9);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 $X6(Z,J){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 QX6(Z,J,X,Y,$,Q,W,K,G){var z=new z1(9);return z[0]=Z,z[1]=J,z[2]=X,z[3]=Y,z[4]=$,z[5]=Q,z[6]=W,z[7]=K,z[8]=G,z}function WX6(Z,J,X,Y,$,Q,W,K,G,z){return Z[0]=J,Z[1]=X,Z[2]=Y,Z[3]=$,Z[4]=Q,Z[5]=W,Z[6]=K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+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z[4]=J[4]+X[4],Z[5]=J[5]+X[5],Z[6]=J[6]+X[6],Z[7]=J[7]+X[7],Z[8]=J[8]+X[8],Z}function TK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z[4]=J[4]-X[4],Z[5]=J[5]-X[5],Z[6]=J[6]-X[6],Z[7]=J[7]-X[7],Z[8]=J[8]-X[8],Z}function CX6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z[4]=J[4]*X,Z[5]=J[5]*X,Z[6]=J[6]*X,Z[7]=J[7]*X,Z[8]=J[8]*X,Z}function TX6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z[2]=J[2]+X[2]*Y,Z[3]=J[3]+X[3]*Y,Z[4]=J[4]+X[4]*Y,Z[5]=J[5]+X[5]*Y,Z[6]=J[6]+X[6]*Y,Z[7]=J[7]+X[7]*Y,Z[8]=J[8]+X[8]*Y,Z}function kX6(Z,J){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]}function EX6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=Z[3],W=Z[4],K=Z[5],G=Z[6],z=Z[7],H=Z[8],V=J[0],q=J[1],F=J[2],U=J[3],B=J[4],w=J[5],j=J[6],N=J[7],R=J[8];return Math.abs(X-V)<=v0*Math.max(1,Math.abs(X),Math.abs(V))&&Math.abs(Y-q)<=v0*Math.max(1,Math.abs(Y),Math.abs(q))&&Math.abs($-F)<=v0*Math.max(1,Math.abs($),Math.abs(F))&&Math.abs(Q-U)<=v0*Math.max(1,Math.abs(Q),Math.abs(U))&&Math.abs(W-B)<=v0*Math.max(1,Math.abs(W),Math.abs(B))&&Math.abs(K-w)<=v0*Math.max(1,Math.abs(K),Math.abs(w))&&Math.abs(G-j)<=v0*Math.max(1,Math.abs(G),Math.abs(j))&&Math.abs(z-N)<=v0*Math.max(1,Math.abs(z),Math.abs(N))&&Math.abs(H-R)<=v0*Math.max(1,Math.abs(H),Math.abs(R))}var IX6=CK1,vX6=TK1;var r0={};_9(r0,{transpose:()=>fX6,translate:()=>mX6,targetTo:()=>VY6,subtract:()=>AK1,sub:()=>MY6,str:()=>qY6,set:()=>hX6,scale:()=>uX6,rotateZ:()=>pX6,rotateY:()=>lX6,rotateX:()=>cX6,rotate:()=>dX6,perspectiveZO:()=>WY6,perspectiveNO:()=>SK1,perspectiveFromFieldOfView:()=>KY6,perspective:()=>QY6,orthoZO:()=>zY6,orthoNO:()=>_K1,ortho:()=>GY6,multiplyScalarAndAdd:()=>BY6,multiplyScalar:()=>wY6,multiply:()=>EK1,mul:()=>OY6,lookAt:()=>HY6,invert:()=>bX6,identity:()=>kK1,getTranslation:()=>eX6,getScaling:()=>vK1,getRotation:()=>ZY6,frustum:()=>$Y6,fromZRotation:()=>rX6,fromYRotation:()=>oX6,fromXRotation:()=>sX6,fromValues:()=>xX6,fromTranslation:()=>iX6,fromScaling:()=>nX6,fromRotationTranslationScaleOrigin:()=>XY6,fromRotationTranslationScale:()=>JY6,fromRotationTranslation:()=>IK1,fromRotation:()=>aX6,fromQuat2:()=>tX6,fromQuat:()=>YY6,frob:()=>FY6,exactEquals:()=>LY6,equals:()=>jY6,determinant:()=>gX6,create:()=>SX6,copy:()=>AX6,clone:()=>_X6,adjoint:()=>yX6,add:()=>UY6});function SX6(){var Z=new z1(16);if(z1!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[4]=0,Z[6]=0,Z[7]=0,Z[8]=0,Z[9]=0,Z[11]=0,Z[12]=0,Z[13]=0,Z[14]=0;return Z[0]=1,Z[5]=1,Z[10]=1,Z[15]=1,Z}function _X6(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[3]=0,Z[4]=V*w-q*B,Z[5]=q*U-H*w,Z[6]=H*B-V*U,Z[7]=0,Z[8]=H,Z[9]=V,Z[10]=q,Z[11]=0,Z[12]=$,Z[13]=Q,Z[14]=W,Z[15]=1,Z}function qY6(Z){return"mat4("+Z[0]+", "+Z[1]+", "+Z[2]+", "+Z[3]+", "+Z[4]+", "+Z[5]+", "+Z[6]+", "+Z[7]+", "+Z[8]+", "+Z[9]+", "+Z[10]+", "+Z[11]+", "+Z[12]+", "+Z[13]+", "+Z[14]+", "+Z[15]+")"}function FY6(Z){return Math.hypot(Z[0],Z[1],Z[2],Z[3],Z[4],Z[5],Z[6],Z[7],Z[8],Z[9],Z[10],Z[11],Z[12],Z[13],Z[14],Z[15])}function UY6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z[4]=J[4]+X[4],Z[5]=J[5]+X[5],Z[6]=J[6]+X[6],Z[7]=J[7]+X[7],Z[8]=J[8]+X[8],Z[9]=J[9]+X[9],Z[10]=J[10]+X[10],Z[11]=J[11]+X[11],Z[12]=J[12]+X[12],Z[13]=J[13]+X[13],Z[14]=J[14]+X[14],Z[15]=J[15]+X[15],Z}function AK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z[4]=J[4]-X[4],Z[5]=J[5]-X[5],Z[6]=J[6]-X[6],Z[7]=J[7]-X[7],Z[8]=J[8]-X[8],Z[9]=J[9]-X[9],Z[10]=J[10]-X[10],Z[11]=J[11]-X[11],Z[12]=J[12]-X[12],Z[13]=J[13]-X[13],Z[14]=J[14]-X[14],Z[15]=J[15]-X[15],Z}function wY6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z[4]=J[4]*X,Z[5]=J[5]*X,Z[6]=J[6]*X,Z[7]=J[7]*X,Z[8]=J[8]*X,Z[9]=J[9]*X,Z[10]=J[10]*X,Z[11]=J[11]*X,Z[12]=J[12]*X,Z[13]=J[13]*X,Z[14]=J[14]*X,Z[15]=J[15]*X,Z}function BY6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z[2]=J[2]+X[2]*Y,Z[3]=J[3]+X[3]*Y,Z[4]=J[4]+X[4]*Y,Z[5]=J[5]+X[5]*Y,Z[6]=J[6]+X[6]*Y,Z[7]=J[7]+X[7]*Y,Z[8]=J[8]+X[8]*Y,Z[9]=J[9]+X[9]*Y,Z[10]=J[10]+X[10]*Y,Z[11]=J[11]+X[11]*Y,Z[12]=J[12]+X[12]*Y,Z[13]=J[13]+X[13]*Y,Z[14]=J[14]+X[14]*Y,Z[15]=J[15]+X[15]*Y,Z}function LY6(Z,J){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]}function jY6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=Z[3],W=Z[4],K=Z[5],G=Z[6],z=Z[7],H=Z[8],V=Z[9],q=Z[10],F=Z[11],U=Z[12],B=Z[13],w=Z[14],j=Z[15],N=J[0],R=J[1],O=J[2],P=J[3],D=J[4],C=J[5],T=J[6],k=J[7],A=J[8],v=J[9],x=J[10],I=J[11],S=J[12],y=J[13],m=J[14],i=J[15];return Math.abs(X-N)<=v0*Math.max(1,Math.abs(X),Math.abs(N))&&Math.abs(Y-R)<=v0*Math.max(1,Math.abs(Y),Math.abs(R))&&Math.abs($-O)<=v0*Math.max(1,Math.abs($),Math.abs(O))&&Math.abs(Q-P)<=v0*Math.max(1,Math.abs(Q),Math.abs(P))&&Math.abs(W-D)<=v0*Math.max(1,Math.abs(W),Math.abs(D))&&Math.abs(K-C)<=v0*Math.max(1,Math.abs(K),Math.abs(C))&&Math.abs(G-T)<=v0*Math.max(1,Math.abs(G),Math.abs(T))&&Math.abs(z-k)<=v0*Math.max(1,Math.abs(z),Math.abs(k))&&Math.abs(H-A)<=v0*Math.max(1,Math.abs(H),Math.abs(A))&&Math.abs(V-v)<=v0*Math.max(1,Math.abs(V),Math.abs(v))&&Math.abs(q-x)<=v0*Math.max(1,Math.abs(q),Math.abs(x))&&Math.abs(F-I)<=v0*Math.max(1,Math.abs(F),Math.abs(I))&&Math.abs(U-S)<=v0*Math.max(1,Math.abs(U),Math.abs(S))&&Math.abs(B-y)<=v0*Math.max(1,Math.abs(B),Math.abs(y))&&Math.abs(w-m)<=v0*Math.max(1,Math.abs(w),Math.abs(m))&&Math.abs(j-i)<=v0*Math.max(1,Math.abs(j),Math.abs(i))}var OY6=EK1,MY6=AK1;var C1={};_9(C1,{str:()=>B$6,squaredLength:()=>G31,sqrLen:()=>C$6,sqlerp:()=>I$6,slerp:()=>EN,setAxisAngle:()=>Z31,setAxes:()=>v$6,set:()=>M$6,scale:()=>Q31,rotationTo:()=>E$6,rotateZ:()=>z$6,rotateY:()=>G$6,rotateX:()=>K$6,random:()=>q$6,pow:()=>V$6,normalize:()=>og,multiply:()=>J31,mul:()=>N$6,ln:()=>Y31,lerp:()=>D$6,length:()=>K31,len:()=>P$6,invert:()=>F$6,identity:()=>$$6,getAxisAngle:()=>Q$6,getAngle:()=>W$6,fromValues:()=>j$6,fromMat3:()=>$31,fromEuler:()=>w$6,exp:()=>X31,exactEquals:()=>T$6,equals:()=>k$6,dot:()=>W31,create:()=>sg,copy:()=>O$6,conjugate:()=>U$6,clone:()=>L$6,calculateW:()=>H$6,add:()=>R$6});var J1={};_9(J1,{zero:()=>pY6,transformQuat:()=>mY6,transformMat4:()=>yY6,transformMat3:()=>gY6,subtract:()=>hK1,sub:()=>sY6,str:()=>iY6,squaredLength:()=>mK1,squaredDistance:()=>gK1,sqrLen:()=>Z$6,sqrDist:()=>eY6,set:()=>DY6,scaleAndAdd:()=>SY6,scale:()=>vY6,round:()=>IY6,rotateZ:()=>cY6,rotateY:()=>dY6,rotateX:()=>uY6,random:()=>bY6,normalize:()=>ng,negate:()=>_Y6,multiply:()=>fK1,mul:()=>oY6,min:()=>kY6,max:()=>EY6,lerp:()=>xY6,length:()=>xK1,len:()=>ag,inverse:()=>AY6,hermite:()=>hY6,fromValues:()=>TN,forEach:()=>J$6,floor:()=>TY6,exactEquals:()=>nY6,equals:()=>aY6,dot:()=>kN,divide:()=>bK1,div:()=>rY6,distance:()=>yK1,dist:()=>tY6,cross:()=>ZU,create:()=>CN,copy:()=>NY6,clone:()=>RY6,ceil:()=>CY6,bezier:()=>fY6,angle:()=>lY6,add:()=>PY6});function CN(){var Z=new z1(3);if(z1!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function RY6(Z){var J=new z1(3);return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function xK1(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function TN(Z,J,X){var Y=new z1(3);return Y[0]=Z,Y[1]=J,Y[2]=X,Y}function NY6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function DY6(Z,J,X,Y){return Z[0]=J,Z[1]=X,Z[2]=Y,Z}function PY6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z}function hK1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z}function fK1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function bK1(Z,J,X){return Z[0]=J[0]/X[0],Z[1]=J[1]/X[1],Z[2]=J[2]/X[2],Z}function CY6(Z,J){return Z[0]=Math.ceil(J[0]),Z[1]=Math.ceil(J[1]),Z[2]=Math.ceil(J[2]),Z}function TY6(Z,J){return Z[0]=Math.floor(J[0]),Z[1]=Math.floor(J[1]),Z[2]=Math.floor(J[2]),Z}function kY6(Z,J,X){return Z[0]=Math.min(J[0],X[0]),Z[1]=Math.min(J[1],X[1]),Z[2]=Math.min(J[2],X[2]),Z}function EY6(Z,J,X){return Z[0]=Math.max(J[0],X[0]),Z[1]=Math.max(J[1],X[1]),Z[2]=Math.max(J[2],X[2]),Z}function IY6(Z,J){return Z[0]=Math.round(J[0]),Z[1]=Math.round(J[1]),Z[2]=Math.round(J[2]),Z}function vY6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z}function SY6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z[2]=J[2]+X[2]*Y,Z}function yK1(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1],$=J[2]-Z[2];return Math.hypot(X,Y,$)}function gK1(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1],$=J[2]-Z[2];return X*X+Y*Y+$*$}function mK1(Z){var J=Z[0],X=Z[1],Y=Z[2];return J*J+X*X+Y*Y}function _Y6(Z,J){return Z[0]=-J[0],Z[1]=-J[1],Z[2]=-J[2],Z}function AY6(Z,J){return Z[0]=1/J[0],Z[1]=1/J[1],Z[2]=1/J[2],Z}function ng(Z,J){var X=J[0],Y=J[1],$=J[2],Q=X*X+Y*Y+$*$;if(Q>0)Q=1/Math.sqrt(Q);return Z[0]=J[0]*Q,Z[1]=J[1]*Q,Z[2]=J[2]*Q,Z}function kN(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]}function ZU(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=X[0],K=X[1],G=X[2];return Z[0]=$*G-Q*K,Z[1]=Q*W-Y*G,Z[2]=Y*K-$*W,Z}function xY6(Z,J,X,Y){var $=J[0],Q=J[1],W=J[2];return Z[0]=$+Y*(X[0]-$),Z[1]=Q+Y*(X[1]-Q),Z[2]=W+Y*(X[2]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]=J[0]-X[0],$[1]=J[1]-X[1],$[2]=J[2]-X[2],Q[0]=$[0],Q[1]=$[1]*Math.cos(Y)-$[2]*Math.sin(Y),Q[2]=$[1]*Math.sin(Y)+$[2]*Math.cos(Y),Z[0]=Q[0]+X[0],Z[1]=Q[1]+X[1],Z[2]=Q[2]+X[2],Z}function dY6(Z,J,X,Y){var $=[],Q=[];return $[0]=J[0]-X[0],$[1]=J[1]-X[1],$[2]=J[2]-X[2],Q[0]=$[2]*Math.sin(Y)+$[0]*Math.cos(Y),Q[1]=$[1],Q[2]=$[2]*Math.cos(Y)-$[0]*Math.sin(Y),Z[0]=Q[0]+X[0],Z[1]=Q[1]+X[1],Z[2]=Q[2]+X[2],Z}function cY6(Z,J,X,Y){var $=[],Q=[];return $[0]=J[0]-X[0],$[1]=J[1]-X[1],$[2]=J[2]-X[2],Q[0]=$[0]*Math.cos(Y)-$[1]*Math.sin(Y),Q[1]=$[0]*Math.sin(Y)+$[1]*Math.cos(Y),Q[2]=$[2],Z[0]=Q[0]+X[0],Z[1]=Q[1]+X[1],Z[2]=Q[2]+X[2],Z}function lY6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=J[0],W=J[1],K=J[2],G=Math.sqrt(X*X+Y*Y+$*$),z=Math.sqrt(Q*Q+W*W+K*K),H=G*z,V=H&&kN(Z,J)/H;return Math.acos(Math.min(Math.max(V,-1),1))}function pY6(Z){return Z[0]=0,Z[1]=0,Z[2]=0,Z}function iY6(Z){return"vec3("+Z[0]+", "+Z[1]+", "+Z[2]+")"}function nY6(Z,J){return Z[0]===J[0]&&Z[1]===J[1]&&Z[2]===J[2]}function aY6(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=J[0],W=J[1],K=J[2];return Math.abs(X-Q)<=v0*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(Y-W)<=v0*Math.max(1,Math.abs(Y),Math.abs(W))&&Math.abs($-K)<=v0*Math.max(1,Math.abs($),Math.abs(K))}var sY6=hK1,oY6=fK1,rY6=bK1,tY6=yK1,eY6=gK1,ag=xK1,Z$6=mK1,J$6=function(){var Z=CN();return function(J,X,Y,$,Q,W){var K,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(K=Y;K<G;K+=X)Z[0]=J[K],Z[1]=J[K+1],Z[2]=J[K+2],Q(Z,Z,W),J[K]=Z[0],J[K+1]=Z[1],J[K+2]=Z[2];return J}}();function X$6(){var Z=new z1(4);if(z1!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function uK1(Z){var J=new z1(4);return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function dK1(Z,J,X,Y){var $=new z1(4);return $[0]=Z,$[1]=J,$[2]=X,$[3]=Y,$}function cK1(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function lK1(Z,J,X,Y,$){return Z[0]=J,Z[1]=X,Z[2]=Y,Z[3]=$,Z}function pK1(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function iK1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function nK1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}function aK1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return J*J+X*X+Y*Y+$*$}function sK1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=X*X+Y*Y+$*$+Q*Q;if(W>0)W=1/Math.sqrt(W);return Z[0]=X*W,Z[1]=Y*W,Z[2]=$*W,Z[3]=Q*W,Z}function oK1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}function rK1(Z,J,X,Y){var $=J[0],Q=J[1],W=J[2],K=J[3];return Z[0]=$+Y*(X[0]-$),Z[1]=Q+Y*(X[1]-Q),Z[2]=W+Y*(X[2]-W),Z[3]=K+Y*(X[3]-K),Z}function tK1(Z,J){return Z[0]===J[0]&&Z[1]===J[1]&&Z[2]===J[2]&&Z[3]===J[3]}function eK1(Z,J){var X=Z[0],Y=Z[1],$=Z[2],Q=Z[3],W=J[0],K=J[1],G=J[2],z=J[3];return Math.abs(X-W)<=v0*Math.max(1,Math.abs(X),Math.abs(W))&&Math.abs(Y-K)<=v0*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs($-G)<=v0*Math.max(1,Math.abs($),Math.abs(G))&&Math.abs(Q-z)<=v0*Math.max(1,Math.abs(Q),Math.abs(z))}var TX5=function(){var Z=X$6();return function(J,X,Y,$,Q,W){var K,G;if(!X)X=4;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(K=Y;K<G;K+=X)Z[0]=J[K],Z[1]=J[K+1],Z[2]=J[K+2],Z[3]=J[K+3],Q(Z,Z,W),J[K]=Z[0],J[K+1]=Z[1],J[K+2]=Z[2],J[K+3]=Z[3];return J}}();function sg(){var Z=new z1(4);if(z1!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z[3]=1,Z}function $$6(Z){return Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=1,Z}function Z31(Z,J,X){X=X*0.5;var Y=Math.sin(X);return Z[0]=Y*J[0],Z[1]=Y*J[1],Z[2]=Y*J[2],Z[3]=Math.cos(X),Z}function Q$6(Z,J){var X=Math.acos(J[3])*2,Y=Math.sin(X/2);if(Y>v0)Z[0]=J[0]/Y,Z[1]=J[1]/Y,Z[2]=J[2]/Y;else Z[0]=1,Z[1]=0,Z[2]=0;return X}function W$6(Z,J){var X=W31(Z,J);return Math.acos(2*X*X-1)}function J31(Z,J,X){var Y=J[0],$=J[1],Q=J[2],W=J[3],K=X[0],G=X[1],z=X[2],H=X[3];return Z[0]=Y*H+W*K+$*z-Q*G,Z[1]=$*H+W*G+Q*K-Y*z,Z[2]=Q*H+W*z+Y*G-$*K,Z[3]=W*H-Y*K-$*G-Q*z,Z}function K$6(Z,J,X){X*=0.5;var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G+W*K,Z[1]=$*G+Q*K,Z[2]=Q*G-$*K,Z[3]=W*G-Y*K,Z}function G$6(Z,J,X){X*=0.5;var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G-Q*K,Z[1]=$*G+W*K,Z[2]=Q*G+Y*K,Z[3]=W*G-$*K,Z}function z$6(Z,J,X){X*=0.5;var Y=J[0],$=J[1],Q=J[2],W=J[3],K=Math.sin(X),G=Math.cos(X);return Z[0]=Y*G+$*K,Z[1]=$*G-Y*K,Z[2]=Q*G+W*K,Z[3]=W*G-Q*K,Z}function H$6(Z,J){var X=J[0],Y=J[1],$=J[2];return Z[0]=X,Z[1]=Y,Z[2]=$,Z[3]=Math.sqrt(Math.abs(1-X*X-Y*Y-$*$)),Z}function X31(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=Math.sqrt(X*X+Y*Y+$*$),K=Math.exp(Q),G=W>0?K*Math.sin(W)/W:0;return Z[0]=X*G,Z[1]=Y*G,Z[2]=$*G,Z[3]=K*Math.cos(W),Z}function Y31(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=Math.sqrt(X*X+Y*Y+$*$),K=W>0?Math.atan2(W,Q)/W:0;return Z[0]=X*K,Z[1]=Y*K,Z[2]=$*K,Z[3]=0.5*Math.log(X*X+Y*Y+$*$+Q*Q),Z}function V$6(Z,J,X){return Y31(Z,J),Q31(Z,Z,X),X31(Z,Z),Z}function EN(Z,J,X,Y){var $=J[0],Q=J[1],W=J[2],K=J[3],G=X[0],z=X[1],H=X[2],V=X[3],q,F,U,B,w;if(F=$*G+Q*z+W*H+K*V,F<0)F=-F,G=-G,z=-z,H=-H,V=-V;if(1-F>v0)q=Math.acos(F),U=Math.sin(q),B=Math.sin((1-Y)*q)/U,w=Math.sin(Y*q)/U;else B=1-Y,w=Y;return Z[0]=B*$+w*G,Z[1]=B*Q+w*z,Z[2]=B*W+w*H,Z[3]=B*K+w*V,Z}function q$6(Z){var J=jZ(),X=jZ(),Y=jZ(),$=Math.sqrt(1-J),Q=Math.sqrt(J);return Z[0]=$*Math.sin(2*Math.PI*X),Z[1]=$*Math.cos(2*Math.PI*X),Z[2]=Q*Math.sin(2*Math.PI*Y),Z[3]=Q*Math.cos(2*Math.PI*Y),Z}function F$6(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],W=X*X+Y*Y+$*$+Q*Q,K=W?1/W:0;return Z[0]=-X*K,Z[1]=-Y*K,Z[2]=-$*K,Z[3]=Q*K,Z}function U$6(Z,J){return Z[0]=-J[0],Z[1]=-J[1],Z[2]=-J[2],Z[3]=J[3],Z}function $31(Z,J){var X=J[0]+J[4]+J[8],Y;if(X>0)Y=Math.sqrt(X+1),Z[3]=0.5*Y,Y=0.5/Y,Z[0]=(J[5]-J[7])*Y,Z[1]=(J[6]-J[2])*Y,Z[2]=(J[1]-J[3])*Y;else{var $=0;if(J[4]>J[0])$=1;if(J[8]>J[$*3+$])$=2;var Q=($+1)%3,W=($+2)%3;Y=Math.sqrt(J[$*3+$]-J[Q*3+Q]-J[W*3+W]+1),Z[$]=0.5*Y,Y=0.5/Y,Z[3]=(J[Q*3+W]-J[W*3+Q])*Y,Z[Q]=(J[Q*3+$]+J[$*3+Q])*Y,Z[W]=(J[W*3+$]+J[$*3+W])*Y}return Z}function w$6(Z,J,X,Y){var $=0.5*Math.PI/180;J*=$,X*=$,Y*=$;var Q=Math.sin(J),W=Math.cos(J),K=Math.sin(X),G=Math.cos(X),z=Math.sin(Y),H=Math.cos(Y);return Z[0]=Q*G*H-W*K*z,Z[1]=W*K*H+Q*G*z,Z[2]=W*G*z-Q*K*H,Z[3]=W*G*H+Q*K*z,Z}function B$6(Z){return"quat("+Z[0]+", "+Z[1]+", "+Z[2]+", "+Z[3]+")"}var L$6=uK1,j$6=dK1,O$6=cK1,M$6=lK1,R$6=pK1,N$6=J31,Q31=iK1,W31=oK1,D$6=rK1,K31=nK1,P$6=K31,G31=aK1,C$6=G31,og=sK1,T$6=tK1,k$6=eK1,E$6=function(){var Z=CN(),J=TN(1,0,0),X=TN(0,1,0);return function(Y,$,Q){var W=kN($,Q);if(W<-0.999999){if(ZU(Z,J,$),ag(Z)<0.000001)ZU(Z,X,$);return ng(Z,Z),Z31(Y,Z,Math.PI),Y}else if(W>0.999999)return Y[0]=0,Y[1]=0,Y[2]=0,Y[3]=1,Y;else return ZU(Z,$,Q),Y[0]=Z[0],Y[1]=Z[1],Y[2]=Z[2],Y[3]=1+W,og(Y,Y)}}(),I$6=function(){var Z=sg(),J=sg();return function(X,Y,$,Q,W,K){return EN(Z,Y,W,K),EN(J,$,Q,K),EN(X,Z,J,2*K*(1-K)),X}}(),v$6=function(){var Z=ig();return function(J,X,Y,$){return Z[0]=Y[0],Z[3]=Y[1],Z[6]=Y[2],Z[1]=$[0],Z[4]=$[1],Z[7]=$[2],Z[2]=-X[0],Z[5]=-X[1],Z[8]=-X[2],og(J,$31(J,Z))}}();var q1={};_9(q1,{zero:()=>XQ6,transformMat4:()=>e$6,transformMat3:()=>t$6,transformMat2d:()=>r$6,transformMat2:()=>o$6,subtract:()=>H31,sub:()=>KQ6,str:()=>YQ6,squaredLength:()=>B31,squaredDistance:()=>U31,sqrLen:()=>qQ6,sqrDist:()=>VQ6,set:()=>x$6,scaleAndAdd:()=>d$6,scale:()=>u$6,round:()=>m$6,rotate:()=>ZQ6,random:()=>s$6,normalize:()=>p$6,negate:()=>c$6,multiply:()=>V31,mul:()=>GQ6,min:()=>y$6,max:()=>g$6,lerp:()=>a$6,length:()=>w31,len:()=>WQ6,inverse:()=>l$6,fromValues:()=>_$6,forEach:()=>FQ6,floor:()=>b$6,exactEquals:()=>$Q6,equals:()=>QQ6,dot:()=>i$6,divide:()=>q31,div:()=>zQ6,distance:()=>F31,dist:()=>HQ6,cross:()=>n$6,create:()=>z31,copy:()=>A$6,clone:()=>S$6,ceil:()=>f$6,angle:()=>JQ6,add:()=>h$6});function z31(){var Z=new z1(2);if(z1!=Float32Array)Z[0]=0,Z[1]=0;return Z}function S$6(Z){var J=new z1(2);return J[0]=Z[0],J[1]=Z[1],J}function _$6(Z,J){var X=new z1(2);return X[0]=Z,X[1]=J,X}function A$6(Z,J){return Z[0]=J[0],Z[1]=J[1],Z}function x$6(Z,J,X){return Z[0]=J,Z[1]=X,Z}function h$6(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z}function H31(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z}function V31(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z}function q31(Z,J,X){return Z[0]=J[0]/X[0],Z[1]=J[1]/X[1],Z}function f$6(Z,J){return Z[0]=Math.ceil(J[0]),Z[1]=Math.ceil(J[1]),Z}function b$6(Z,J){return Z[0]=Math.floor(J[0]),Z[1]=Math.floor(J[1]),Z}function y$6(Z,J,X){return Z[0]=Math.min(J[0],X[0]),Z[1]=Math.min(J[1],X[1]),Z}function g$6(Z,J,X){return Z[0]=Math.max(J[0],X[0]),Z[1]=Math.max(J[1],X[1]),Z}function m$6(Z,J){return Z[0]=Math.round(J[0]),Z[1]=Math.round(J[1]),Z}function u$6(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z}function d$6(Z,J,X,Y){return Z[0]=J[0]+X[0]*Y,Z[1]=J[1]+X[1]*Y,Z}function F31(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1];return Math.hypot(X,Y)}function U31(Z,J){var X=J[0]-Z[0],Y=J[1]-Z[1];return X*X+Y*Y}function w31(Z){var J=Z[0],X=Z[1];return Math.hypot(J,X)}function B31(Z){var J=Z[0],X=Z[1];return J*J+X*X}function c$6(Z,J){return Z[0]=-J[0],Z[1]=-J[1],Z}function l$6(Z,J){return Z[0]=1/J[0],Z[1]=1/J[1],Z}function p$6(Z,J){var X=J[0],Y=J[1],$=X*X+Y*Y;if($>0)$=1/Math.sqrt($);return Z[0]=J[0]*$,Z[1]=J[1]*$,Z}function i$6(Z,J){return Z[0]*J[0]+Z[1]*J[1]}function n$6(Z,J,X){var Y=J[0]*X[1]-J[1]*X[0];return Z[0]=Z[1]=0,Z[2]=Y,Z}function a$6(Z,J,X,Y){var $=J[0],Q=J[1];return Z[0]=$+Y*(X[0]-$),Z[1]=Q+Y*(X[1]-Q),Z}function s$6(Z,J){J=J||1;var X=jZ()*2*Math.PI;return Z[0]=Math.cos(X)*J,Z[1]=Math.sin(X)*J,Z}function o$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[2]*$,Z[1]=X[1]*Y+X[3]*$,Z}function r$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[2]*$+X[4],Z[1]=X[1]*Y+X[3]*$+X[5],Z}function t$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[3]*$+X[6],Z[1]=X[1]*Y+X[4]*$+X[7],Z}function e$6(Z,J,X){var Y=J[0],$=J[1];return Z[0]=X[0]*Y+X[4]*$+X[12],Z[1]=X[1]*Y+X[5]*$+X[13],Z}function ZQ6(Z,J,X,Y){var $=J[0]-X[0],Q=J[1]-X[1],W=Math.sin(Y),K=Math.cos(Y);return Z[0]=$*K-Q*W+X[0],Z[1]=$*W+Q*K+X[1],Z}function JQ6(Z,J){var X=Z[0],Y=Z[1],$=J[0],Q=J[1],W=Math.sqrt(X*X+Y*Y)*Math.sqrt($*$+Q*Q),K=W&&(X*$+Y*Q)/W;return Math.acos(Math.min(Math.max(K,-1),1))}function XQ6(Z){return Z[0]=0,Z[1]=0,Z}function YQ6(Z){return"vec2("+Z[0]+", "+Z[1]+")"}function $Q6(Z,J){return Z[0]===J[0]&&Z[1]===J[1]}function QQ6(Z,J){var X=Z[0],Y=Z[1],$=J[0],Q=J[1];return Math.abs(X-$)<=v0*Math.max(1,Math.abs(X),Math.abs($))&&Math.abs(Y-Q)<=v0*Math.max(1,Math.abs(Y),Math.abs(Q))}var WQ6=w31,KQ6=H31,GQ6=V31,zQ6=q31,HQ6=F31,VQ6=U31,qQ6=B31,FQ6=function(){var Z=z31();return function(J,X,Y,$,Q,W){var K,G;if(!X)X=2;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(K=Y;K<G;K+=X)Z[0]=J[K],Z[1]=J[K+1],Q(Z,Z,W),J[K]=Z[0],J[K+1]=Z[1];return J}}();class tQ extends Float32Array{constructor(Z,J,X,Y){super([Z,J,X,Y])}get determinant(){return i8.determinant(this)}get frobeniusNorm(){return i8.frob(this)}static create(){let Z=new tQ(0,0,0,0);return i8.identity(Z),Z}static fromRotation(Z){let J=tQ.create();return i8.fromRotation(J,Z),J}static fromScaling(Z){let J=tQ.create();return i8.fromScaling(J,Z),J}add(Z){return i8.add(this,this,Z),this}adjoint(){return i8.adjoint(this,this),this}clone(){return new tQ(this[0],this[1],this[2],this[3])}copy(Z){return i8.copy(this,Z),this}equals(Z){return i8.equals(this,Z)}exactEquals(Z){return i8.exactEquals(this,Z)}identity(){return i8.identity(this),this}invert(){return i8.invert(this,this),this}multiply(Z){return i8.mul(this,this,Z),this}multiplyScalar(Z){return i8.multiplyScalar(this,this,Z),this}rotate(Z){return i8.rotate(this,this,Z),this}subtract(Z){return i8.sub(this,this,Z),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return i8.transpose(this,this),this}}class OZ extends Float32Array{constructor(Z,J,X,Y,$,Q,W,K,G){super([Z,J,X,Y,$,Q,W,K,G])}get determinant(){return e1.determinant(this)}get frobeniusNorm(){return e1.frob(this)}static create(){let Z=new OZ(0,0,0,0,0,0,0,0,0);return e1.identity(Z),Z}static fromMatrix4(Z){let J=OZ.create();return e1.fromMat4(J,Z),J}static fromQuaternion(Z){let J=OZ.create();return e1.fromQuat(J,Z),J}static fromRotation(Z){let J=OZ.create();return e1.fromRotation(J,Z),J}static fromScaling(Z){let J=OZ.create();return e1.fromScaling(J,Z),J}static fromTranslation(Z){let J=OZ.create();return e1.fromTranslation(J,Z),J}add(Z){return e1.add(this,this,Z),this}adjoint(){return e1.adjoint(this,this),this}clone(){return new OZ(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(Z){return e1.copy(this,Z),this}equals(Z){return e1.equals(this,Z)}exactEquals(Z){return e1.exactEquals(this,Z)}identity(){return e1.identity(this),this}invert(){return e1.invert(this,this),this}multiply(Z){return e1.mul(this,this,Z),this}multiplyScalar(Z){return e1.multiplyScalar(this,this,Z),this}transformVector(Z){return Z.transformMatrix3(this)}projection(Z,J){return e1.projection(this,Z,J),this}rotate(Z){return e1.rotate(this,this,Z),this}subtract(Z){return e1.sub(this,this,Z),this}toString(){return`[${this[0]},${this[1]},${this[2]}][${this[3]},${this[4]},${this[5]}][${this[6]},${this[7]},${this[8]}]`}transpose(){return e1.transpose(this,this),this}}class k5 extends Float32Array{constructor(Z,J,X,Y,$,Q,W,K,G,z,H,V,q,F,U,B){super([Z,J,X,Y,$,Q,W,K,G,z,H,V,q,F,U,B])}get determinant(){return r0.determinant(this)}get frobeniusNorm(){return r0.frob(this)}static create(){let Z=new k5(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return r0.identity(Z),Z}static fromQuaternion(Z){let J=k5.create();return r0.fromQuat(J,Z),J}static fromRotation(Z,J){let X=k5.create();return r0.fromRotation(X,Z,J),X}static fromRotationTranslation(Z,J){let X=k5.create();return r0.fromRotationTranslation(X,Z,J),X}static fromRotationTranslationScale(Z,J,X){let Y=k5.create();return r0.fromRotationTranslationScale(Y,Z,J,X),Y}static fromRotationTranslationScaleOrigin(Z,J,X,Y){let $=k5.create();return r0.fromRotationTranslationScaleOrigin($,Z,J,X,Y),$}static fromScaling(Z){let J=k5.create();return r0.fromScaling(J,Z),J}static fromTranslation(Z){let J=k5.create();return r0.fromTranslation(J,Z),J}static fromXRotation(Z){let J=k5.create();return r0.fromXRotation(J,Z),J}static fromYRotation(Z){let J=k5.create();return r0.fromYRotation(J,Z),J}static fromZRotation(Z){let J=k5.create();return r0.fromZRotation(J,Z),J}add(Z){return r0.add(this,this,Z),this}adjoint(){return r0.adjoint(this,this),this}clone(){return new k5(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(Z){return r0.copy(this,Z),this}equals(Z){return r0.equals(this,Z)}exactEquals(Z){return r0.exactEquals(this,Z)}frustrum(Z,J,X,Y,$,Q){return r0.frustum(this,Z,J,X,Y,$,Q),this}identity(){return r0.identity(this),this}invert(){return r0.invert(this,this),this}lookAt(Z,J,X){return r0.lookAt(this,Z,J,X),this}multiply(Z){return r0.mul(this,this,Z),this}multiplyScalar(Z){return r0.multiplyScalar(this,this,Z),this}orthographic(Z,J,X,Y,$,Q){return r0.ortho(this,Z,J,X,Y,$,Q),this}perspective(Z,J,X,Y){return r0.perspective(this,Z,J,X,Y),this}rotate(Z,J){return r0.rotate(this,this,Z,J),this}rotateX(Z){return r0.rotateX(this,this,Z),this}rotateY(Z){return r0.rotateY(this,this,Z),this}rotateZ(Z){return r0.rotateZ(this,this,Z),this}scale(Z){return r0.scale(this,this,Z),this}subtract(Z){return r0.sub(this,this,Z),this}targetTo(Z,J,X){return r0.targetTo(this,Z,J,X),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(Z){return r0.translate(this,this,Z),this}transpose(){return r0.transpose(this,this),this}}class QG extends Float32Array{constructor(Z,J,X,Y){super([Z,J,X,Y])}get length(){return C1.length(this)}get squaredLength(){return C1.squaredLength(this)}get magnitude(){return C1.length(this)}get squaredMagnitude(){return C1.squaredLength(this)}get x(){return this[0]}set x(Z){this[0]=Z}get y(){return this[1]}set y(Z){this[1]=Z}get z(){return this[2]}set z(Z){this[2]=Z}get w(){return this[3]}set w(Z){this[3]=Z}static fromEuler(Z,J,X){let Y=C1.fromEuler(new Float32Array(4),Z,J,X);return new QG(Y[0],Y[1],Y[2],Y[3])}static fromQuaternionLike(Z){return new QG(Z.x,Z.y,Z.z,Z.w)}clone(){return new QG(this.x,this.y,this.z,this.w)}conjugate(){return C1.conjugate(this,this),this}copy(Z){return C1.copy(this,Z),this}dot(Z){return C1.dot(this,Z)}exponential(){return C1.exp(this,this),this}equals(Z){return C1.equals(this,Z)}exactEquals(Z){return C1.exactEquals(this,Z)}getAngle(Z){return C1.getAngle(this,Z)}identity(){return C1.identity(this),this}invert(){return C1.invert(this,this),this}lerp(Z,J){return C1.lerp(this,this,Z,J),this}logarithm(){return C1.ln(this,this),this}multiply(Z){return C1.multiply(this,this,Z),this}transformVector(Z){return Z.transformQuaternion(this)}normalize(){return C1.normalize(this,this),this}power(Z){return C1.pow(this,this,Z),this}randomize(){return C1.random(this),this}rotateX(Z){return C1.rotateX(this,this,Z),this}rotateY(Z){return C1.rotateY(this,this,Z),this}rotateZ(Z){return C1.rotateZ(this,this,Z),this}scale(Z){return C1.scale(this,this,Z),this}setAxisAngle(Z,J){return C1.setAxisAngle(this,Z,J),this}slerp(Z,J){return C1.slerp(this,this,Z,J),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class JU extends Float32Array{constructor(Z,J){super([Z,J])}get length(){return q1.length(this)}get squaredLength(){return q1.squaredLength(this)}get magnitude(){return q1.length(this)}get squaredMagnitude(){return q1.squaredLength(this)}get x(){return this[0]}set x(Z){this[0]=Z}get y(){return this[1]}set y(Z){this[1]=Z}static create(){return new JU(0,0)}add(Z){return q1.add(this,this,Z),this}angle(Z){return q1.angle(this,Z)}ceil(){return q1.ceil(this,this),this}clone(){return new JU(this.x,this.y)}copy(Z){return q1.copy(this,Z),this}distance(Z){return q1.distance(this,Z)}divide(Z){return q1.divide(this,this,Z),this}dot(Z){return q1.dot(this,Z)}equals(Z){return q1.equals(this,Z)}exactEquals(Z){return q1.exactEquals(this,Z)}floor(){return q1.floor(this,this),this}invert(){return q1.inverse(this,this),this}lerp(Z,J){return q1.lerp(this,this,Z,J),this}max(Z){return q1.max(this,this,Z),this}min(Z){return q1.min(this,this,Z),this}multiply(Z){return q1.mul(this,this,Z),this}negate(){return q1.negate(this,this),this}normalize(){return q1.normalize(this,this),this}randomize(Z){return q1.random(this,Z),this}rotate(Z,J){return q1.rotate(this,this,Z,J),this}round(){return q1.round(this,this),this}scale(Z){return q1.scale(this,this,Z),this}scaleAndAdd(Z,J){return q1.scaleAndAdd(this,this,Z,J),this}subtract(Z){return q1.sub(this,this,Z),this}toString(){return`${this.x},${this.y}`}transformMatrix2(Z){return q1.transformMat2(this,this,Z),this}transformMatrix3(Z){return q1.transformMat3(this,this,Z),this}transformMatrix4(Z){return q1.transformMat4(this,this,Z),this}zero(){return q1.zero(this),this}}class WG extends Float32Array{constructor(Z,J,X){super([Z,J,X])}get length(){return J1.length(this)}get squaredLength(){return J1.squaredLength(this)}get magnitude(){return J1.length(this)}get squaredMagnitude(){return J1.squaredLength(this)}get x(){return this[0]}set x(Z){this[0]=Z}get y(){return this[1]}set y(Z){this[1]=Z}get z(){return this[2]}set z(Z){this[2]=Z}static create(){return new WG(0,0,0)}static fromVector3Like(Z){return new WG(Z.x,Z.y,Z.z)}add(Z){return J1.add(this,this,Z),this}ceil(){return J1.ceil(this,this),this}clone(){return new WG(this.x,this.y,this.z)}copy(Z){return J1.copy(this,Z),this}cross(Z){return J1.cross(this,this,Z),this}distance(Z){return J1.distance(this,Z)}divide(Z){return J1.div(this,this,Z),this}dot(Z){return J1.dot(this,Z)}equals(Z){return J1.equals(this,Z)}exactEquals(Z){return J1.exactEquals(this,Z)}floor(){return J1.floor(this,this),this}invert(){return J1.inverse(this,this),this}lerp(Z,J){return J1.lerp(this,this,Z,J),this}max(Z){return J1.max(this,this,Z),this}min(Z){return J1.min(this,this,Z),this}multiply(Z){return J1.mul(this,this,Z),this}negate(){return J1.negate(this,this),this}normalize(){return J1.normalize(this,this),this}randomize(Z){return J1.random(this,Z),this}rotateX(Z,J){return J1.rotateX(this,this,Z,J),this}rotateY(Z,J){return J1.rotateY(this,this,Z,J),this}rotateZ(Z,J){return J1.rotateZ(this,this,Z,J),this}round(){return J1.round(this,this),this}scale(Z){return J1.scale(this,this,Z),this}scaleAndAdd(Z,J){return J1.scaleAndAdd(this,this,Z,J),this}subtract(Z){return J1.sub(this,this,Z),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(Z){return J1.transformMat3(this,this,Z),this}transformMatrix4(Z){return J1.transformMat4(this,this,Z),this}transformQuaternion(Z){return J1.transformQuat(this,this,Z),this}zero(){return J1.zero(this),this}}var T1=function(Z,J,X,Y){function $(Q){return Q instanceof X?Q:new X(function(W){W(Q)})}return new(X||(X=Promise))(function(Q,W){function K(H){try{z(Y.next(H))}catch(V){W(V)}}function G(H){try{z(Y.throw(H))}catch(V){W(V)}}function z(H){H.done?Q(H.value):$(H.value).then(K,G)}z((Y=Y.apply(Z,J||[])).next())})},D1=function(Z,J){var X={label:0,sent:function(){if(Q[0]&1)throw Q[1];return Q[1]},trys:[],ops:[]},Y,$,Q,W=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return W.next=K(0),W.throw=K(1),W.return=K(2),typeof Symbol==="function"&&(W[Symbol.iterator]=function(){return this}),W;function K(z){return function(H){return G([z,H])}}function G(z){if(Y)throw new TypeError("Generator is already executing.");while(W&&(W=0,z[0]&&(X=0)),X)try{if(Y=1,$&&(Q=z[0]&2?$.return:z[0]?$.throw||((Q=$.return)&&Q.call($),0):$.next)&&!(Q=Q.call($,z[1])).done)return Q;if($=0,Q)z=[z[0]&2,Q.value];switch(z[0]){case 0:case 1:Q=z;break;case 4:return X.label++,{value:z[1],done:!1};case 5:X.label++,$=z[1],z=[0];continue;case 7:z=X.ops.pop(),X.trys.pop();continue;default:if((Q=X.trys,!(Q=Q.length>0&&Q[Q.length-1]))&&(z[0]===6||z[0]===2)){X=0;continue}if(z[0]===3&&(!Q||z[1]>Q[0]&&z[1]<Q[3])){X.label=z[1];break}if(z[0]===6&&X.label<Q[1]){X.label=Q[1],Q=z;break}if(Q&&X.label<Q[2]){X.label=Q[2],X.ops.push(z);break}if(Q[2])X.ops.pop();X.trys.pop();continue}z=J.call(Z,X)}catch(H){z=[6,H],$=0}finally{Y=Q=0}if(z[0]&5)throw z[1];return{value:z[0]?z[1]:void 0,done:!0}}},X9=function(Z,J){var X=typeof Symbol==="function"&&Z[Symbol.iterator];if(!X)return Z;var Y=X.call(Z),$,Q=[],W;try{while((J===void 0||J-- >0)&&!($=Y.next()).done)Q.push($.value)}catch(K){W={error:K}}finally{try{if($&&!$.done&&(X=Y.return))X.call(Y)}finally{if(W)throw W.error}}return Q},T4=function(Z,J,X){if(X||arguments.length===2){for(var Y=0,$=J.length,Q;Y<$;Y++)if(Q||!(Y in J)){if(!Q)Q=Array.prototype.slice.call(J,0,Y);Q[Y]=J[Y]}}return Z.concat(Q||Array.prototype.slice.call(J))},L31=function(Z){var J=typeof Symbol==="function"&&Symbol.iterator,X=J&&Z[J],Y=0;if(X)return X.call(Z);if(Z&&typeof Z.length==="number")return{next:function(){if(Z&&Y>=Z.length)Z=void 0;return{value:Z&&Z[Y++],done:!Z}}};throw new TypeError(J?"Object is not iterable.":"Symbol.iterator is not defined.")},AX5=function(){function Z(J){if(J===void 0)J=Z.minComparator;var X=this;this.compare=J,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(Y,$){return X.compare(Y,$).then(function(Q){return-1*Q})}}return Z.getChildrenIndexOf=function(J){return[J*2+1,J*2+2]},Z.getParentIndexOf=function(J){if(J<=0)return-1;var X=J%2?1:2;return Math.floor((J-X)/2)},Z.getSiblingIndexOf=function(J){if(J<=0)return-1;var X=J%2?1:-1;return J+X},Z.minComparator=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){if(J>X)return[2,1];else if(J<X)return[2,-1];else return[2,0]})})},Z.maxComparator=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){if(X>J)return[2,1];else if(X<J)return[2,-1];else return[2,0]})})},Z.minComparatorNumber=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){return[2,J-X]})})},Z.maxComparatorNumber=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){return[2,X-J]})})},Z.defaultIsEqual=function(J,X){return T1(this,void 0,void 0,function(){return D1(this,function(Y){return[2,J===X]})})},Z.print=function(J){function X(H){var V=Z.getParentIndexOf(H);return Math.floor(Math.log2(V+1))}function Y(H,V){var q="";for(;V>0;--V)q+=H;return q}var $=0,Q=[],W=X(J.length-1)+2,K=0;while($<J.length){var G=X($)+1;if($===0)G=0;var z=String(J.get($));if(z.length>K)K=z.length;Q[G]=Q[G]||[],Q[G].push(z),$+=1}return Q.map(function(H,V){var q=Math.pow(2,W-V)-1;return Y(" ",Math.floor(q/2)*K)+H.map(function(F){var U=(K-F.length)/2;return Y(" ",Math.ceil(U))+F+Y(" ",Math.floor(U))}).join(Y(" ",q*K))}).join(`
486
486
  `)},Z.heapify=function(J,X){return T1(this,void 0,void 0,function(){var Y;return D1(this,function($){switch($.label){case 0:return Y=new Z(X),Y.heapArray=J,[4,Y.init()];case 1:return $.sent(),[2,Y]}})})},Z.heappop=function(J,X){var Y=new Z(X);return Y.heapArray=J,Y.pop()},Z.heappush=function(J,X,Y){return T1(this,void 0,void 0,function(){var $;return D1(this,function(Q){switch(Q.label){case 0:return $=new Z(Y),$.heapArray=J,[4,$.push(X)];case 1:return Q.sent(),[2]}})})},Z.heappushpop=function(J,X,Y){var $=new Z(Y);return $.heapArray=J,$.pushpop(X)},Z.heapreplace=function(J,X,Y){var $=new Z(Y);return $.heapArray=J,$.replace(X)},Z.heaptop=function(J,X,Y){if(X===void 0)X=1;var $=new Z(Y);return $.heapArray=J,$.top(X)},Z.heapbottom=function(J,X,Y){if(X===void 0)X=1;var $=new Z(Y);return $.heapArray=J,$.bottom(X)},Z.nlargest=function(J,X,Y){return T1(this,void 0,void 0,function(){var $;return D1(this,function(Q){switch(Q.label){case 0:return $=new Z(Y),$.heapArray=T4([],X9(X),!1),[4,$.init()];case 1:return Q.sent(),[2,$.top(J)]}})})},Z.nsmallest=function(J,X,Y){return T1(this,void 0,void 0,function(){var $;return D1(this,function(Q){switch(Q.label){case 0:return $=new Z(Y),$.heapArray=T4([],X9(X),!1),[4,$.init()];case 1:return Q.sent(),[2,$.bottom(J)]}})})},Z.prototype.add=function(J){return T1(this,void 0,void 0,function(){return D1(this,function(X){switch(X.label){case 0:return[4,this._sortNodeUp(this.heapArray.push(J)-1)];case 1:return X.sent(),this._applyLimit(),[2,!0]}})})},Z.prototype.addAll=function(J){return T1(this,void 0,void 0,function(){var X,Y,$;return D1(this,function(Q){switch(Q.label){case 0:X=this.length,($=this.heapArray).push.apply($,T4([],X9(J),!1)),Y=this.length,Q.label=1;case 1:if(!(X<Y))return[3,4];return[4,this._sortNodeUp(X)];case 2:Q.sent(),Q.label=3;case 3:return++X,[3,1];case 4:return this._applyLimit(),[2,!0]}})})},Z.prototype.bottom=function(){return T1(this,arguments,void 0,function(J){if(J===void 0)J=1;return D1(this,function(X){if(this.heapArray.length===0||J<=0)return[2,[]];else if(this.heapArray.length===1)return[2,[this.heapArray[0]]];else if(J>=this.heapArray.length)return[2,T4([],X9(this.heapArray),!1)];else return[2,this._bottomN_push(~~J)]})})},Z.prototype.check=function(){return T1(this,void 0,void 0,function(){var J,X,Y,$,Q,W,K,G,z;return D1(this,function(H){switch(H.label){case 0:J=0,H.label=1;case 1:if(!(J<this.heapArray.length))return[3,10];X=this.heapArray[J],Y=this.getChildrenOf(J),H.label=2;case 2:H.trys.push([2,7,8,9]),$=(G=void 0,L31(Y)),Q=$.next(),H.label=3;case 3:if(Q.done)return[3,6];return W=Q.value,[4,this.compare(X,W)];case 4:if(H.sent()>0)return[2,X];H.label=5;case 5:return Q=$.next(),[3,3];case 6:return[3,9];case 7:return K=H.sent(),G={error:K},[3,9];case 8:try{if(Q&&!Q.done&&(z=$.return))z.call($)}finally{if(G)throw G.error}return[7];case 9:return++J,[3,1];case 10:return[2]}})})},Z.prototype.clear=function(){this.heapArray=[]},Z.prototype.clone=function(){var J=new Z(this.comparator());return J.heapArray=this.toArray(),J._limit=this._limit,J},Z.prototype.comparator=function(){return this.compare},Z.prototype.contains=function(J){return T1(this,arguments,void 0,function(X,Y){var $,Q,W,K,G,z;if(Y===void 0)Y=Z.defaultIsEqual;return D1(this,function(H){switch(H.label){case 0:H.trys.push([0,5,6,7]),$=L31(this.heapArray),Q=$.next(),H.label=1;case 1:if(Q.done)return[3,4];return W=Q.value,[4,Y(W,X)];case 2:if(H.sent())return[2,!0];H.label=3;case 3:return Q=$.next(),[3,1];case 4:return[3,7];case 5:return K=H.sent(),G={error:K},[3,7];case 6:try{if(Q&&!Q.done&&(z=$.return))z.call($)}finally{if(G)throw G.error}return[7];case 7:return[2,!1]}})})},Z.prototype.init=function(J){return T1(this,void 0,void 0,function(){var X;return D1(this,function(Y){switch(Y.label){case 0:if(J)this.heapArray=T4([],X9(J),!1);X=Math.floor(this.heapArray.length),Y.label=1;case 1:if(!(X>=0))return[3,4];return[4,this._sortNodeDown(X)];case 2:Y.sent(),Y.label=3;case 3:return--X,[3,1];case 4:return this._applyLimit(),[2]}})})},Z.prototype.isEmpty=function(){return this.length===0},Z.prototype.leafs=function(){if(this.heapArray.length===0)return[];var J=Z.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(J+1)},Object.defineProperty(Z.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"limit",{get:function(){return this._limit},set:function(J){this._limit=~~J,this._applyLimit()},enumerable:!1,configurable:!0}),Z.prototype.peek=function(){return this.heapArray[0]},Z.prototype.pop=function(){return T1(this,void 0,void 0,function(){var J;return D1(this,function(X){if(J=this.heapArray.pop(),this.length>0&&J!==void 0)return[2,this.replace(J)];return[2,J]})})},Z.prototype.push=function(){var J=[];for(var X=0;X<arguments.length;X++)J[X]=arguments[X];return T1(this,void 0,void 0,function(){return D1(this,function(Y){if(J.length<1)return[2,!1];else if(J.length===1)return[2,this.add(J[0])];else return[2,this.addAll(J)]})})},Z.prototype.pushpop=function(J){return T1(this,void 0,void 0,function(){var X;return D1(this,function(Y){switch(Y.label){case 0:return[4,this.compare(this.heapArray[0],J)];case 1:if(!(Y.sent()<0))return[3,3];return X=X9([this.heapArray[0],J],2),J=X[0],this.heapArray[0]=X[1],[4,this._sortNodeDown(0)];case 2:Y.sent(),Y.label=3;case 3:return[2,J]}})})},Z.prototype.remove=function(J){return T1(this,arguments,void 0,function(X,Y){var $,Q,W,K=this;if(Y===void 0)Y=Z.defaultIsEqual;return D1(this,function(G){switch(G.label){case 0:if(!this.heapArray.length)return[2,!1];if(X!==void 0)return[3,2];return[4,this.pop()];case 1:return G.sent(),[2,!0];case 2:$=[0],G.label=3;case 3:if(!$.length)return[3,13];return Q=$.shift(),[4,Y(this.heapArray[Q],X)];case 4:if(!G.sent())return[3,11];if(Q!==0)return[3,6];return[4,this.pop()];case 5:return G.sent(),[3,10];case 6:if(Q!==this.heapArray.length-1)return[3,7];return this.heapArray.pop(),[3,10];case 7:return this.heapArray.splice(Q,1,this.heapArray.pop()),[4,this._sortNodeUp(Q)];case 8:return G.sent(),[4,this._sortNodeDown(Q)];case 9:G.sent(),G.label=10;case 10:return[2,!0];case 11:W=Z.getChildrenIndexOf(Q).filter(function(z){return z<K.heapArray.length}),$.push.apply($,T4([],X9(W),!1)),G.label=12;case 12:return[3,3];case 13:return[2,!1]}})})},Z.prototype.replace=function(J){return T1(this,void 0,void 0,function(){var X;return D1(this,function(Y){switch(Y.label){case 0:return X=this.heapArray[0],this.heapArray[0]=J,[4,this._sortNodeDown(0)];case 1:return Y.sent(),[2,X]}})})},Z.prototype.size=function(){return this.length},Z.prototype.top=function(){return T1(this,arguments,void 0,function(J){if(J===void 0)J=1;return D1(this,function(X){if(this.heapArray.length===0||J<=0)return[2,[]];else if(this.heapArray.length===1||J===1)return[2,[this.heapArray[0]]];else if(J>=this.heapArray.length)return[2,T4([],X9(this.heapArray),!1)];else return[2,this._topN_push(~~J)]})})},Z.prototype.toArray=function(){return T4([],X9(this.heapArray),!1)},Z.prototype.toString=function(){return this.heapArray.toString()},Z.prototype.get=function(J){return this.heapArray[J]},Z.prototype.getChildrenOf=function(J){var X=this;return Z.getChildrenIndexOf(J).map(function(Y){return X.heapArray[Y]}).filter(function(Y){return Y!==void 0})},Z.prototype.getParentOf=function(J){var X=Z.getParentIndexOf(J);return this.heapArray[X]},Z.prototype[Symbol.iterator]=function(){return D1(this,function(J){switch(J.label){case 0:if(!this.length)return[3,2];return[4,this.pop()];case 1:return J.sent(),[3,0];case 2:return[2]}})},Z.prototype.iterator=function(){return this},Z.prototype._applyLimit=function(){if(this._limit&&this._limit<this.heapArray.length){var J=this.heapArray.length-this._limit;while(J)this.heapArray.pop(),--J}},Z.prototype._bottomN_push=function(J){return T1(this,void 0,void 0,function(){var X,Y,$,Q,K,W,K;return D1(this,function(G){switch(G.label){case 0:return X=new Z(this.compare),X.limit=J,X.heapArray=this.heapArray.slice(-J),[4,X.init()];case 1:G.sent(),Y=this.heapArray.length-1-J,$=Z.getParentIndexOf(Y),Q=[];for(K=Y;K>$;--K)Q.push(K);W=this.heapArray,G.label=2;case 2:if(!Q.length)return[3,6];return K=Q.shift(),[4,this.compare(W[K],X.peek())];case 3:if(!(G.sent()>0))return[3,5];return[4,X.replace(W[K])];case 4:if(G.sent(),K%2)Q.push(Z.getParentIndexOf(K));G.label=5;case 5:return[3,2];case 6:return[2,X.toArray()]}})})},Z.prototype._moveNode=function(J,X){var Y;Y=X9([this.heapArray[X],this.heapArray[J]],2),this.heapArray[J]=Y[0],this.heapArray[X]=Y[1]},Z.prototype._sortNodeDown=function(J){return T1(this,void 0,void 0,function(){var X,Y,$,Q,W,K;return D1(this,function(G){switch(G.label){case 0:X=this.heapArray.length,G.label=1;case 1:if(Y=2*J+1,$=Y+1,Q=J,W=Y<X,!W)return[3,3];return[4,this.compare(this.heapArray[Y],this.heapArray[Q])];case 2:W=G.sent()<0,G.label=3;case 3:if(W)Q=Y;if(K=$<X,!K)return[3,5];return[4,this.compare(this.heapArray[$],this.heapArray[Q])];case 4:K=G.sent()<0,G.label=5;case 5:if(K)Q=$;if(Q===J)return[3,7];this._moveNode(J,Q),J=Q,G.label=6;case 6:return[3,1];case 7:return[2]}})})},Z.prototype._sortNodeUp=function(J){return T1(this,void 0,void 0,function(){var X;return D1(this,function(Y){switch(Y.label){case 0:if(!(J>0))return[3,2];return X=Z.getParentIndexOf(J),[4,this.compare(this.heapArray[J],this.heapArray[X])];case 1:if(Y.sent()<0)this._moveNode(J,X),J=X;else return[3,2];return[3,0];case 2:return[2]}})})},Z.prototype._topN_push=function(J){return T1(this,void 0,void 0,function(){var X,Y,$,Q;return D1(this,function(W){switch(W.label){case 0:X=new Z(this._invertedCompare),X.limit=J,Y=[0],$=this.heapArray,W.label=1;case 1:if(!Y.length)return[3,7];if(Q=Y.shift(),!(Q<$.length))return[3,6];if(!(X.length<J))return[3,3];return[4,X.push($[Q])];case 2:return W.sent(),Y.push.apply(Y,T4([],X9(Z.getChildrenIndexOf(Q)),!1)),[3,6];case 3:return[4,this.compare($[Q],X.peek())];case 4:if(!(W.sent()<0))return[3,6];return[4,X.replace($[Q])];case 5:W.sent(),Y.push.apply(Y,T4([],X9(Z.getChildrenIndexOf(Q)),!1)),W.label=6;case 6:return[3,1];case 7:return[2,X.toArray()]}})})},Z.prototype._topN_fill=function(J){return T1(this,void 0,void 0,function(){var X,Y,$,Q,W,W;return D1(this,function(K){switch(K.label){case 0:return X=this.heapArray,Y=new Z(this._invertedCompare),Y.limit=J,Y.heapArray=X.slice(0,J),[4,Y.init()];case 1:K.sent(),$=Z.getParentIndexOf(J-1)+1,Q=[];for(W=$;W<J;++W)Q.push.apply(Q,T4([],X9(Z.getChildrenIndexOf(W).filter(function(G){return G<X.length})),!1));if((J-1)%2)Q.push(J);K.label=2;case 2:if(!Q.length)return[3,6];if(W=Q.shift(),!(W<X.length))return[3,5];return[4,this.compare(X[W],Y.peek())];case 3:if(!(K.sent()<0))return[3,5];return[4,Y.replace(X[W])];case 4:K.sent(),Q.push.apply(Q,T4([],X9(Z.getChildrenIndexOf(W)),!1)),K.label=5;case 5:return[3,2];case 6:return[2,Y.toArray()]}})})},Z.prototype._topN_heap=function(J){return T1(this,void 0,void 0,function(){var X,Y,$,Q,W;return D1(this,function(K){switch(K.label){case 0:X=this.clone(),Y=[],$=0,K.label=1;case 1:if(!($<J))return[3,4];return W=(Q=Y).push,[4,X.pop()];case 2:W.apply(Q,[K.sent()]),K.label=3;case 3:return++$,[3,1];case 4:return[2,Y]}})})},Z.prototype._topIdxOf=function(J){return T1(this,void 0,void 0,function(){var X,Y,$,Q;return D1(this,function(W){switch(W.label){case 0:if(!J.length)return[2,-1];X=0,Y=J[X],$=1,W.label=1;case 1:if(!($<J.length))return[3,4];return[4,this.compare(J[$],Y)];case 2:if(Q=W.sent(),Q<0)X=$,Y=J[$];W.label=3;case 3:return++$,[3,1];case 4:return[2,X]}})})},Z.prototype._topOf=function(){var J=[];for(var X=0;X<arguments.length;X++)J[X]=arguments[X];return T1(this,void 0,void 0,function(){var Y;return D1(this,function($){switch($.label){case 0:return Y=new Z(this.compare),[4,Y.init(J)];case 1:return $.sent(),[2,Y.peek()]}})})},Z}(),UQ6=function(Z,J){var X={label:0,sent:function(){if(Q[0]&1)throw Q[1];return Q[1]},trys:[],ops:[]},Y,$,Q,W=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return W.next=K(0),W.throw=K(1),W.return=K(2),typeof Symbol==="function"&&(W[Symbol.iterator]=function(){return this}),W;function K(z){return function(H){return G([z,H])}}function G(z){if(Y)throw new TypeError("Generator is already executing.");while(W&&(W=0,z[0]&&(X=0)),X)try{if(Y=1,$&&(Q=z[0]&2?$.return:z[0]?$.throw||((Q=$.return)&&Q.call($),0):$.next)&&!(Q=Q.call($,z[1])).done)return Q;if($=0,Q)z=[z[0]&2,Q.value];switch(z[0]){case 0:case 1:Q=z;break;case 4:return X.label++,{value:z[1],done:!1};case 5:X.label++,$=z[1],z=[0];continue;case 7:z=X.ops.pop(),X.trys.pop();continue;default:if((Q=X.trys,!(Q=Q.length>0&&Q[Q.length-1]))&&(z[0]===6||z[0]===2)){X=0;continue}if(z[0]===3&&(!Q||z[1]>Q[0]&&z[1]<Q[3])){X.label=z[1];break}if(z[0]===6&&X.label<Q[1]){X.label=Q[1],Q=z;break}if(Q&&X.label<Q[2]){X.label=Q[2],X.ops.push(z);break}if(Q[2])X.ops.pop();X.trys.pop();continue}z=J.call(Z,X)}catch(H){z=[6,H],$=0}finally{Y=Q=0}if(z[0]&5)throw z[1];return{value:z[0]?z[1]:void 0,done:!0}}},v6=function(Z,J){var X=typeof Symbol==="function"&&Z[Symbol.iterator];if(!X)return Z;var Y=X.call(Z),$,Q=[],W;try{while((J===void 0||J-- >0)&&!($=Y.next()).done)Q.push($.value)}catch(K){W={error:K}}finally{try{if($&&!$.done&&(X=Y.return))X.call(Y)}finally{if(W)throw W.error}}return Q},E5=function(Z,J,X){if(X||arguments.length===2){for(var Y=0,$=J.length,Q;Y<$;Y++)if(Q||!(Y in J)){if(!Q)Q=Array.prototype.slice.call(J,0,Y);Q[Y]=J[Y]}}return Z.concat(Q||Array.prototype.slice.call(J))};var j31=function(){function Z(J){if(J===void 0)J=Z.minComparator;var X=this;this.compare=J,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this.removeAll=this.clear,this._invertedCompare=function(Y,$){return-1*X.compare(Y,$)}}return Z.getChildrenIndexOf=function(J){return[J*2+1,J*2+2]},Z.getParentIndexOf=function(J){if(J<=0)return-1;var X=J%2?1:2;return Math.floor((J-X)/2)},Z.getSiblingIndexOf=function(J){if(J<=0)return-1;var X=J%2?1:-1;return J+X},Z.minComparator=function(J,X){if(J>X)return 1;else if(J<X)return-1;else return 0},Z.maxComparator=function(J,X){if(X>J)return 1;else if(X<J)return-1;else return 0},Z.minComparatorNumber=function(J,X){return J-X},Z.maxComparatorNumber=function(J,X){return X-J},Z.defaultIsEqual=function(J,X){return J===X},Z.print=function(J){function X(H){var V=Z.getParentIndexOf(H);return Math.floor(Math.log2(V+1))}function Y(H,V){var q="";for(;V>0;--V)q+=H;return q}var $=0,Q=[],W=X(J.length-1)+2,K=0;while($<J.length){var G=X($)+1;if($===0)G=0;var z=String(J.get($));if(z.length>K)K=z.length;Q[G]=Q[G]||[],Q[G].push(z),$+=1}return Q.map(function(H,V){var q=Math.pow(2,W-V)-1;return Y(" ",Math.floor(q/2)*K)+H.map(function(F){var U=(K-F.length)/2;return Y(" ",Math.ceil(U))+F+Y(" ",Math.floor(U))}).join(Y(" ",q*K))}).join(`
487
487
  `)},Z.heapify=function(J,X){var Y=new Z(X);return Y.heapArray=J,Y.init(),Y},Z.heappop=function(J,X){var Y=new Z(X);return Y.heapArray=J,Y.pop()},Z.heappush=function(J,X,Y){var $=new Z(Y);$.heapArray=J,$.push(X)},Z.heappushpop=function(J,X,Y){var $=new Z(Y);return $.heapArray=J,$.pushpop(X)},Z.heapreplace=function(J,X,Y){var $=new Z(Y);return $.heapArray=J,$.replace(X)},Z.heaptop=function(J,X,Y){if(X===void 0)X=1;var $=new Z(Y);return $.heapArray=J,$.top(X)},Z.heapbottom=function(J,X,Y){if(X===void 0)X=1;var $=new Z(Y);return $.heapArray=J,$.bottom(X)},Z.nlargest=function(J,X,Y){var $=new Z(Y);return $.heapArray=E5([],v6(X),!1),$.init(),$.top(J)},Z.nsmallest=function(J,X,Y){var $=new Z(Y);return $.heapArray=E5([],v6(X),!1),$.init(),$.bottom(J)},Z.prototype.add=function(J){return this._sortNodeUp(this.heapArray.push(J)-1),this._applyLimit(),!0},Z.prototype.addAll=function(J){var X,Y=this.length;(X=this.heapArray).push.apply(X,E5([],v6(J),!1));for(var $=this.length;Y<$;++Y)this._sortNodeUp(Y);return this._applyLimit(),!0},Z.prototype.bottom=function(J){if(J===void 0)J=1;if(this.heapArray.length===0||J<=0)return[];else if(this.heapArray.length===1)return[this.heapArray[0]];else if(J>=this.heapArray.length)return E5([],v6(this.heapArray),!1);else return this._bottomN_push(~~J)},Z.prototype.check=function(){var J=this;return this.heapArray.find(function(X,Y){return!!J.getChildrenOf(Y).find(function($){return J.compare(X,$)>0})})},Z.prototype.clear=function(){this.heapArray=[]},Z.prototype.clone=function(){var J=new Z(this.comparator());return J.heapArray=this.toArray(),J._limit=this._limit,J},Z.prototype.comparator=function(){return this.compare},Z.prototype.contains=function(J,X){if(X===void 0)X=Z.defaultIsEqual;return this.indexOf(J,X)!==-1},Z.prototype.init=function(J){if(J)this.heapArray=E5([],v6(J),!1);for(var X=Math.floor(this.heapArray.length);X>=0;--X)this._sortNodeDown(X);this._applyLimit()},Z.prototype.isEmpty=function(){return this.length===0},Z.prototype.indexOf=function(J,X){if(X===void 0)X=Z.defaultIsEqual;if(this.heapArray.length===0)return-1;var Y=[],$=0;while($<this.heapArray.length){var Q=this.heapArray[$];if(X(Q,J))return $;else if(this.compare(Q,J)<=0)Y.push.apply(Y,E5([],v6(Z.getChildrenIndexOf($)),!1));$=Y.shift()||this.heapArray.length}return-1},Z.prototype.indexOfEvery=function(J,X){if(X===void 0)X=Z.defaultIsEqual;if(this.heapArray.length===0)return[];var Y=[],$=[],Q=0;while(Q<this.heapArray.length){var W=this.heapArray[Q];if(X(W,J))$.push(Q),Y.push.apply(Y,E5([],v6(Z.getChildrenIndexOf(Q)),!1));else if(this.compare(W,J)<=0)Y.push.apply(Y,E5([],v6(Z.getChildrenIndexOf(Q)),!1));Q=Y.shift()||this.heapArray.length}return $},Z.prototype.leafs=function(){if(this.heapArray.length===0)return[];var J=Z.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(J+1)},Object.defineProperty(Z.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"limit",{get:function(){return this._limit},set:function(J){if(J<0||isNaN(J))this._limit=0;else this._limit=~~J;this._applyLimit()},enumerable:!1,configurable:!0}),Z.prototype.setLimit=function(J){if(this.limit=J,J<0||isNaN(J))return NaN;else return this._limit},Z.prototype.peek=function(){return this.heapArray[0]},Z.prototype.pop=function(){var J=this.heapArray.pop();if(this.length>0&&J!==void 0)return this.replace(J);return J},Z.prototype.push=function(){var J=[];for(var X=0;X<arguments.length;X++)J[X]=arguments[X];if(J.length<1)return!1;else if(J.length===1)return this.add(J[0]);else return this.addAll(J)},Z.prototype.pushpop=function(J){var X;if(this.compare(this.heapArray[0],J)<0)X=v6([this.heapArray[0],J],2),J=X[0],this.heapArray[0]=X[1],this._sortNodeDown(0);return J},Z.prototype.remove=function(J,X){var Y=this;if(X===void 0)X=Z.defaultIsEqual;if(!this.heapArray.length)return!1;if(J===void 0)return this.pop(),!0;var $=[0];while($.length){var Q=$.shift();if(X(this.heapArray[Q],J)){if(Q===0)this.pop();else if(Q===this.heapArray.length-1)this.heapArray.pop();else this.heapArray.splice(Q,1,this.heapArray.pop()),this._sortNodeUp(Q),this._sortNodeDown(Q);return!0}else if(this.compare(this.heapArray[Q],J)<=0){var W=Z.getChildrenIndexOf(Q).filter(function(K){return K<Y.heapArray.length});$.push.apply($,E5([],v6(W),!1))}}return!1},Z.prototype.replace=function(J){var X=this.heapArray[0];return this.heapArray[0]=J,this._sortNodeDown(0),X},Z.prototype.size=function(){return this.length},Z.prototype.top=function(J){if(J===void 0)J=1;if(this.heapArray.length===0||J<=0)return[];else if(this.heapArray.length===1||J===1)return[this.heapArray[0]];else if(J>=this.heapArray.length)return E5([],v6(this.heapArray),!1);else return this._topN_push(~~J)},Z.prototype.toArray=function(){return E5([],v6(this.heapArray),!1)},Z.prototype.toString=function(){return this.heapArray.toString()},Z.prototype.get=function(J){return this.heapArray[J]},Z.prototype.getChildrenOf=function(J){var X=this;return Z.getChildrenIndexOf(J).map(function(Y){return X.heapArray[Y]}).filter(function(Y){return Y!==void 0})},Z.prototype.getParentOf=function(J){var X=Z.getParentIndexOf(J);return this.heapArray[X]},Z.prototype[Symbol.iterator]=function(){return UQ6(this,function(J){switch(J.label){case 0:if(!this.length)return[3,2];return[4,this.pop()];case 1:return J.sent(),[3,0];case 2:return[2]}})},Z.prototype.iterator=function(){return this.toArray()},Z.prototype._applyLimit=function(){if(this._limit>0&&this._limit<this.heapArray.length){var J=this.heapArray.length-this._limit;while(J)this.heapArray.pop(),--J}},Z.prototype._bottomN_push=function(J){var X=new Z(this.compare);X.limit=J,X.heapArray=this.heapArray.slice(-J),X.init();var Y=this.heapArray.length-1-J,$=Z.getParentIndexOf(Y),Q=[];for(var W=Y;W>$;--W)Q.push(W);var K=this.heapArray;while(Q.length){var W=Q.shift();if(this.compare(K[W],X.peek())>0){if(X.replace(K[W]),W%2)Q.push(Z.getParentIndexOf(W))}}return X.toArray()},Z.prototype._moveNode=function(J,X){var Y;Y=v6([this.heapArray[X],this.heapArray[J]],2),this.heapArray[J]=Y[0],this.heapArray[X]=Y[1]},Z.prototype._sortNodeDown=function(J){var X=this.heapArray.length;while(!0){var Y=2*J+1,$=Y+1,Q=J;if(Y<X&&this.compare(this.heapArray[Y],this.heapArray[Q])<0)Q=Y;if($<X&&this.compare(this.heapArray[$],this.heapArray[Q])<0)Q=$;if(Q===J)break;this._moveNode(J,Q),J=Q}},Z.prototype._sortNodeUp=function(J){while(J>0){var X=Z.getParentIndexOf(J);if(this.compare(this.heapArray[J],this.heapArray[X])<0)this._moveNode(J,X),J=X;else break}},Z.prototype._topN_push=function(J){var X=new Z(this._invertedCompare);X.limit=J;var Y=[0],$=this.heapArray;while(Y.length){var Q=Y.shift();if(Q<$.length){if(X.length<J)X.push($[Q]),Y.push.apply(Y,E5([],v6(Z.getChildrenIndexOf(Q)),!1));else if(this.compare($[Q],X.peek())<0)X.replace($[Q]),Y.push.apply(Y,E5([],v6(Z.getChildrenIndexOf(Q)),!1))}}return X.toArray()},Z.prototype._topN_fill=function(J){var X=this.heapArray,Y=new Z(this._invertedCompare);Y.limit=J,Y.heapArray=X.slice(0,J),Y.init();var $=Z.getParentIndexOf(J-1)+1,Q=[];for(var W=$;W<J;++W)Q.push.apply(Q,E5([],v6(Z.getChildrenIndexOf(W).filter(function(K){return K<X.length})),!1));if((J-1)%2)Q.push(J);while(Q.length){var W=Q.shift();if(W<X.length){if(this.compare(X[W],Y.peek())<0)Y.replace(X[W]),Q.push.apply(Q,E5([],v6(Z.getChildrenIndexOf(W)),!1))}}return Y.toArray()},Z.prototype._topN_heap=function(J){var X=this.clone(),Y=[];for(var $=0;$<J;++$)Y.push(X.pop());return Y},Z.prototype._topIdxOf=function(J){if(!J.length)return-1;var X=0,Y=J[X];for(var $=1;$<J.length;++$){var Q=this.compare(J[$],Y);if(Q<0)X=$,Y=J[$]}return X},Z.prototype._topOf=function(){var J=[];for(var X=0;X<arguments.length;X++)J[X]=arguments[X];var Y=new Z(this.compare);return Y.init(J),Y.peek()},Z}();var O31=0.099856;class XU extends pY{faceSpeed=0;idleLoopedAnimations=[];idleLoopedAnimationsSpeed;jumpOneshotAnimations=[];moveLoopedAnimations=[];moveLoopedAnimationsSpeed;moveSpeed=0;_faceTarget;_jumpHeight=0;_moveCompletesWhenStuck=!1;_moveIgnoreAxes={};_moveStartMoveAnimations=!1;_moveStartIdleAnimationsOnCompletion=!0;_moveStoppingDistanceSquared=O31;_moveStuckAccumulatorMs=0;_moveStuckLastPosition;_moveTarget;_onFace;_onFaceComplete;_onMove;_onMoveComplete;_stopFaceRequested=!1;_stopMoveRequested=!1;constructor(Z={}){super();this.idleLoopedAnimations=Z.idleLoopedAnimations??this.idleLoopedAnimations,this.idleLoopedAnimationsSpeed=Z.idleLoopedAnimationsSpeed??this.idleLoopedAnimationsSpeed,this.jumpOneshotAnimations=Z.jumpOneshotAnimations??this.jumpOneshotAnimations,this.moveLoopedAnimations=Z.moveLoopedAnimations??this.moveLoopedAnimations,this.moveLoopedAnimationsSpeed=Z.moveLoopedAnimationsSpeed??this.moveLoopedAnimationsSpeed}spawn(Z){super.spawn(Z),this._startIdleAnimations(Z)}face(Z,J,X){this._faceTarget=Z,this.faceSpeed=J,this._onFace=X?.faceCallback,this._onFaceComplete=X?.faceCompleteCallback}jump(Z){this._jumpHeight=Z}move(Z,J,X){this.moveSpeed=J,this._moveCompletesWhenStuck=X?.moveCompletesWhenStuck??!1,this._moveIgnoreAxes=X?.moveIgnoreAxes??{},this._moveStartIdleAnimationsOnCompletion=X?.moveStartIdleAnimationsOnCompletion??!0,this._moveStartMoveAnimations=!0,this._moveStoppingDistanceSquared=X?.moveStoppingDistance?X.moveStoppingDistance**2:O31,this._moveTarget=Z,this._onMove=X?.moveCallback,this._onMoveComplete=X?.moveCompleteCallback,this._moveStuckAccumulatorMs=0,this._moveStuckLastPosition=void 0}stopFace(){this._stopFaceRequested=!0}stopMove(){this._stopMoveRequested=!0}tick(Z,J){if(super.tick(Z,J),!this._moveTarget&&!this._faceTarget&&!this._jumpHeight)return;if(this._moveStartMoveAnimations)this._startMoveAnimations(Z),this._moveStartMoveAnimations=!1;let X=J/1000,Y=Z.position;if(Z.isDynamic&&this._jumpHeight>0){let $=Math.abs(Z.world.simulation.gravity.y),Q=Math.sqrt(2*$*this._jumpHeight);Z.applyImpulse({x:0,y:Q*Z.mass,z:0}),this._jumpHeight=0,this._startJumpAnimations(Z)}if(this._moveTarget){let $={x:this._moveIgnoreAxes.x?0:this._moveTarget.x-Y.x,y:this._moveIgnoreAxes.y?0:this._moveTarget.y-Y.y,z:this._moveIgnoreAxes.z?0:this._moveTarget.z-Y.z},Q=$.x*$.x+$.y*$.y+$.z*$.z,W=!1;if(this._moveCompletesWhenStuck){if(this._moveStuckAccumulatorMs+=J,this._moveStuckAccumulatorMs>=500){if(this._moveStuckLastPosition){let K=Y.x-this._moveStuckLastPosition.x,G=Y.y-this._moveStuckLastPosition.y,z=Y.z-this._moveStuckLastPosition.z;W=Math.sqrt(K*K+G*G+z*z)<this.moveSpeed*0.1}this._moveStuckLastPosition=Y,this._moveStuckAccumulatorMs=0}}if(Q>this._moveStoppingDistanceSquared&&!this._stopMoveRequested&&!W){let K=Math.sqrt(Q),G=this.moveSpeed*X,H=Math.min(K,G)/K,V={x:Y.x+$.x*H,y:Y.y+$.y*H,z:Y.z+$.z*H};if(Z.setPosition(V),this._onMove)this._onMove(V,this._moveTarget)}else{if(this._moveStuckAccumulatorMs=0,this._moveStuckLastPosition=void 0,this._moveTarget=void 0,this._stopMoveRequested=!1,this._moveStartIdleAnimationsOnCompletion)this._startIdleAnimations(Z);if(this._onMoveComplete){let K=this._onMoveComplete;this._onMove=void 0,this._onMoveComplete=void 0,K(Y)}}}if(this._faceTarget){let $={x:this._faceTarget.x-Y.x,z:this._faceTarget.z-Y.z},Q=Math.atan2(-$.x,-$.z),W=Z.rotation,K=Math.atan2(2*(W.w*W.y),1-2*(W.y*W.y)),G=Q-K;while(G>Math.PI)G-=2*Math.PI;while(G<-Math.PI)G+=2*Math.PI;if(Math.abs(G)>0.01&&!this._stopFaceRequested){let z=this.faceSpeed*X,H=Math.abs(G)<z?G:Math.sign(G)*z,q=(K+H)/2,F={x:0,y:Math.fround(Math.sin(q)),z:0,w:Math.fround(Math.cos(q))};if(Z.setRotation(F),this._onFace)this._onFace(W,F)}else if(this._faceTarget=void 0,this._stopFaceRequested=!1,this._onFaceComplete){let z=this._onFaceComplete;this._onFace=void 0,this._onFaceComplete=void 0,z(Z.rotation)}}}_startIdleAnimations(Z){if(this.idleLoopedAnimationsSpeed)Z.setModelAnimationsPlaybackRate(this.idleLoopedAnimationsSpeed);Z.stopModelAnimations(this.moveLoopedAnimations),Z.stopModelAnimations(this.jumpOneshotAnimations),Z.startModelLoopedAnimations(this.idleLoopedAnimations)}_startJumpAnimations(Z){Z.stopModelAnimations(this.moveLoopedAnimations),Z.stopModelAnimations(this.idleLoopedAnimations),Z.startModelOneshotAnimations(this.jumpOneshotAnimations)}_startMoveAnimations(Z){if(this.moveLoopedAnimationsSpeed)Z.setModelAnimationsPlaybackRate(this.moveLoopedAnimationsSpeed);Z.stopModelAnimations(this.jumpOneshotAnimations),Z.stopModelAnimations(this.idleLoopedAnimations),Z.startModelLoopedAnimations(this.moveLoopedAnimations)}}class rg extends XU{_debug=!1;_entity;_maxFall=0;_maxJump=0;_maxOpenSetIterations=200;_onPathfindAbort;_onPathfindComplete;_onWaypointMoveComplete;_onWaypointMoveSkipped;_speed=0;_target;_verticalPenalty=0;_waypoints=[];_waypointNextIndex=0;_waypointStoppingDistance;_waypointTimeoutMs=2000;constructor(Z={}){super(Z)}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(Z,J,X){if(this._target=Z,this._speed=J,this._debug=X?.debug??!1,this._maxFall=X?.maxFall?-Math.abs(X.maxFall):0,this._maxJump=X?.maxJump?Math.abs(X.maxJump):0,this._maxOpenSetIterations=X?.maxOpenSetIterations??200,this._onPathfindAbort=X?.pathfindAbortCallback,this._onPathfindComplete=X?.pathfindCompleteCallback,this._onWaypointMoveComplete=X?.waypointMoveCompleteCallback,this._onWaypointMoveSkipped=X?.waypointMoveSkippedCallback,this._verticalPenalty=X?.verticalPenalty??0,this._waypoints=[],this._waypointNextIndex=0,this._waypointStoppingDistance=X?.waypointStoppingDistance,this._waypointTimeoutMs=X?.waypointTimeoutMs??2000/J,!this._calculatePath())return!1;return this._moveToNextWaypoint(),!0}attach(Z){super.attach(Z),this._entity=Z}detach(Z){super.detach(Z),this._entity=void 0}_calculatePath(){if(!this._target||!this._entity?.world)return d.error("PathfindingEntityController._calculatePath: No target or world"),!1;let Z=this._entity.height,J=this._findGroundedStart();if(!J){if(this._debug)d.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 X={x:Math.floor(this._target.x),y:Math.floor(this._target.y),z:Math.floor(this._target.z)},Y=Math.abs(X.x-J.x),$=Math.abs(X.y-J.y),Q=Math.abs(X.z-J.z);if(Y<=2&&$<=2&&Q<=2&&!this._isNeighborCoordinateBlocked(J,X,this._entity.height))return this._waypoints=[{x:J.x+0.5,y:J.y+Z/2,z:J.z+0.5},{x:X.x+0.5,y:X.y+Z/2,z:X.z+0.5}],!0;if(J.x===X.x&&J.y===X.y&&J.z===X.z)return this._waypoints=[{x:J.x+0.5,y:J.y+Z/2,z:J.z+0.5}],!0;let K=this._coordinateToKey(J),G=new Map,z=new Map([[K,0]]),H=new Map([[K,this._pathfindingHeuristic(J,X)]]),V=new Set,q=new j31((R,O)=>{let P=H.get(R[0])??1/0,D=H.get(O[0])??1/0;return P-D});q.push([K,J]);let F=[{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}],U=[];for(let R=this._maxJump;R>=this._maxFall;R--){if(R===0)continue;let O=Math.abs(J.y+R-X.y);U.push({y:R,distanceToTargetY:O})}U.sort((R,O)=>R.distanceToTargetY-O.distanceToTargetY);let B=[...F,...U.flatMap(({y:R})=>F.map((O)=>({...O,y:R})))],w=0,j=Math.abs(X.x-J.x)+Math.abs(X.y-J.y)+Math.abs(X.z-J.z),N=Math.min(this._maxOpenSetIterations,j*20);while(!q.isEmpty()&&w<N){w++;let[R,O]=q.pop();if(O.x===X.x&&O.y===X.y&&O.z===X.z){let C=this._reconstructPath(G,O);if(this._waypoints=C.map((T)=>({x:T.x+0.5,y:T.y+Z/2,z:T.z+0.5})),this._debug)console.log(`PathfindingEntityController._calculatePath: Path found after ${w} open set iterations. Start: ${this._coordinateToKey(J)}, Target: ${this._coordinateToKey(this._target)}`);return!0}V.add(R);let P=z.get(R),D=new Map;for(let C of B){let T=`${C.x},${C.z}`,k=C.y<0;if(k&&D.has(T))continue;let A={x:O.x+C.x,y:O.y+C.y,z:O.z+C.z};if(Math.abs(X.x-A.x)+Math.abs(X.y-A.y)+Math.abs(X.z-A.z)>j*1.5)continue;let x=this._coordinateToKey(A);if(V.has(x))continue;let I=this._isNeighborCoordinateBlocked(O,A,this._entity.height);if(k&&I){D.set(T,!0);continue}if(I)continue;let S=Math.abs(C.x),y=Math.abs(C.y),m=Math.abs(C.z),i=y===0?0:this._verticalPenalty,t=(Math.max(S,y,m)===1&&S+y+m>1?1.4:1)+i,Z0=P+t,W0=z.get(x)??1/0;if(Z0>=W0)continue;G.set(x,O),z.set(x,Z0);let A0=Z0+this._pathfindingHeuristic(A,X);H.set(x,A0),q.push([x,A])}}if(w>=N){if(this._onPathfindAbort?.(),this._debug)d.warning(`PathfindingEntityController._calculatePath: Maximum open set iterations reached (${N}), path search aborted. Start: ${this._coordinateToKey(J)}, Target: ${this._coordinateToKey(this._target)}`)}else if(this._debug)d.warning(`PathfindingEntityController._calculatePath: No valid path found. Start: ${this._coordinateToKey(J)}, Target: ${this._coordinateToKey(this._target)}`);return this._target=void 0,this._waypoints=[],!1}_reconstructPath(Z,J){let X=[J],Y=J;while(Z.has(this._coordinateToKey(Y)))Y=Z.get(this._coordinateToKey(Y)),X.unshift(Y);return X}_coordinateToKey(Z){return`${Z.x},${Z.y},${Z.z}`}_moveToNextWaypoint(){let Z=this._waypointNextIndex>0?this._waypoints[this._waypointNextIndex-1]:void 0,J=this._waypoints[this._waypointNextIndex];if(!J||!this._entity)return;let X=0;if(this._entity.isDynamic&&Z&&J.y>Z.y){let Y=J.y-Z.y,$=Math.min(Y,this._maxJump)+0.75;this.jump($);let Q=Math.abs(this._entity.world.simulation.gravity.y),W=Math.sqrt(2*Q*$),K=Z.x+0.5,G=Z.z+0.5,z=J.x+0.5,H=J.z+0.5,V=z-K,q=H-G,F=Math.sqrt(V*V+q*q),U=W/Q,B=F/this._speed;X=Math.min(U*0.8,B)*1000}setTimeout(()=>{if(!this._entity)return;let Y=Date.now();this.face(J,this._speed),this.move(J,this._speed,{moveCompletesWhenStuck:!0,moveIgnoreAxes:{y:this._entity.isDynamic},moveStartIdleAnimationsOnCompletion:this._waypointNextIndex===this._waypoints.length-1,moveStoppingDistance:this._waypointStoppingDistance,moveCallback:()=>{if(Date.now()-Y>this._waypointTimeoutMs&&this._waypointNextIndex<this._waypoints.length-1)this._onWaypointMoveSkipped?.(J,this._waypointNextIndex),this._waypointNextIndex++,this._moveToNextWaypoint()},moveCompleteCallback:()=>{if(this._waypointNextIndex<this._waypoints.length-1)this._onWaypointMoveComplete?.(J,this._waypointNextIndex),this._waypointNextIndex++,this._moveToNextWaypoint();else this._onPathfindComplete?.()}})},X)}_pathfindingHeuristic(Z,J){return Math.abs(Z.x-J.x)+Math.abs(Z.y-J.y)+Math.abs(Z.z-J.z)}_isNeighborCoordinateBlocked(Z,J,X){if(!this._entity?.world)return!1;let Y=this._entity.world,$=Math.floor(J.x),Q=Math.floor(J.y),W=Math.floor(J.z),K=Math.floor(Z.x),G=Math.floor(Z.z);if(!Y.chunkLattice.hasBlock({x:$,y:Q-1,z:W}))return!0;for(let z=0;z<X;z++)if(Y.chunkLattice.hasBlock({x:$,y:Q+z,z:W}))return!0;if($!==K&&W!==G)for(let z=0;z<X;z++){let H=Y.chunkLattice.hasBlock({x:$,y:Q+z,z:G}),V=Y.chunkLattice.hasBlock({x:K,y:Q+z,z:W});if(H||V)return!0}return!1}_findGroundedStart(){if(!this._entity?.world)return;let{x:Z,y:J,z:X}=this._entity.position,Y={x:Math.floor(Z),y:Math.floor(J),z:Math.floor(X)};for(let $=0;$<=Math.abs(this._maxFall);$++)if(this._entity.world.chunkLattice.hasBlock({...Y,y:Y.y-$-1}))return{...Y,y:Y.y-$};return}}export{SJ6 as startServer,MK1 as WorldManagerEvent,cY as WorldManager,OK1 as WorldLoopEvent,tF as WorldLoop,pg as WorldEvent,eF as World,aS as WebServerEvent,mK as WebServer,WG as Vector3,JU as Vector2,rF as Ticker,sQ as TelemetrySpanOperation,N8 as Telemetry,lg as SimulationEvent,aF as Simulation,XU as SimpleEntityController,oF as SceneUIManager,FI as SceneUIEvent,wH as SceneUI,X60 as SUPPORTED_INPUT_KEYS,Az as RigidBodyType,B$ as RigidBody,QG as Quaternion,UL as PlayerUIEvent,zH as PlayerUI,RK1 as PlayerManagerEvent,j9 as PlayerManager,HH as PlayerEvent,y7 as PlayerEntity,J60 as PlayerCameraMode,zI as PlayerCameraEvent,GH as PlayerCamera,QK as Player,P$ as PersistenceManager,rg as PathfindingEntityController,sF as ParticleEmitterManager,ug as ParticleEmitterEvent,dg as ParticleEmitter,iS as PORT,K60 as PLAYER_ROTATION_UPDATE_THRESHOLD,W60 as PLAYER_POSITION_UPDATE_THRESHOLD_SQ,h5 as ModelRegistry,k5 as Matrix4,OZ as Matrix3,tQ as Matrix2,jK1 as LightType,nF as LightManager,gg as LightEvent,mg as Light,B6 as IterationMap,NK1 as GameServerEvent,oQ as GameServer,j0 as EventRouter,d as ErrorHandler,BH as EntityManager,UH as EntityEvent,o8 as Entity,Q60 as ENTITY_ROTATION_UPDATE_THRESHOLD,$60 as ENTITY_POSITION_UPDATE_THRESHOLD_SQ,m1 as DefaultPlayerEntityController,UI as DefaultPlayerEntity,Y60 as DEFAULT_ENTITY_RIGID_BODY_OPTIONS,S4 as CollisionGroupsBuilder,sY as CollisionGroup,xz as ColliderShape,FH as ColliderMap,V9 as Collider,Ek as CoefficientCombineRule,qI as ChunkLatticeEvent,qH as ChunkLattice,U9 as Chunk,VH as ChatManager,HI as ChatEvent,vk as BlockTypeRegistryEvent,hz as BlockTypeRegistry,Ik as BlockTypeEvent,q9 as BlockType,JW as Block,$m as BaseEntityControllerEvent,pY as BaseEntityController,zG as AudioManager,SN as AudioEvent,GG as Audio};