Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

Fix embedded viewer textures for Kiln 1.2.1 (#164)

Matthew Kissingerb3185d4ac3e5
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index f26243e3..e128c1cb 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "kiln",
"description": "Build and revise 3D assets with your coding agent. Write JavaScript, inspect selected views, edit saved source revisions, and export GLB files locally.",
- "version": "1.2.0",
+ "version": "1.2.1",
"author": {
"name": "Matthew Kissinger"
},
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index c04a39a6..81ceb9c5 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "kiln",
- "version": "1.2.0",
+ "version": "1.2.1",
"description": "Create, review, save, and refine procedural 3D assets with portable source and GLB collections.",
"author": {
"name": "Matthew Kissinger"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41ad3ddf..d8195372 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,22 @@ Source releases and installable package publication are separate milestones.
Published versions and tags are recorded by the npm registry; changing this file
does not publish a package.
+## 1.2.1 (unpublished)
+
+- Load embedded viewer textures through the browser image path, retaining
+ pixels, sampler settings and UV transforms under restrictive MCP Apps CSP.
+ This uses the shared viewer and existing presentation tool; local and hosted
+ tool counts remain unchanged.
+- Reject failed texture decoding instead of silently showing white geometry.
+ The chat component labels its saved-preview fallback and can recover when
+ another asset is presented. Advance the widget resource URI to invalidate
+ cached component bytes.
+- Generate the MCP manifest before building sibling runtimes so one complete
+ build keeps their identities consistent after a package or widget update.
+
+Actual ChatGPT-host acceptance and hosted production deployment remain separate
+from local browser regression evidence and package publication.
+
## 1.2.0
- Add an opt-in named MCP operation presentation generated from the shared
diff --git a/dist/agent-run.mjs b/dist/agent-run.mjs
index b9a27af3..96e04711 100644
--- a/dist/agent-run.mjs
+++ b/dist/agent-run.mjs
@@ -32939,7 +32939,7 @@ function createKilnSourceDef(store) {
}
// src/engine-identity.ts
-var ENGINE_VERSION = "1.2.0";
+var ENGINE_VERSION = "1.2.1";
var ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
function engineIdentity() {
return { version: ENGINE_VERSION, installUrl: ENGINE_INSTALL_URL };
@@ -37996,7 +37996,10 @@ function resolveViewRenderTimeoutMs(input) {
// src/tools/registry.ts
init_evidence_history();
init_background();
-var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html";
+
+// src/asset-widget-uri.ts
+var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v6.html";
+// src/tools/registry.ts
function proceduralTextureMaterialContract(rendered, context) {
const required = [...new Set(context.requiredProceduralTextureUsages ?? [])];
if (required.length === 0)
diff --git a/dist/build.json b/dist/build.json
index 8a420314..f93d1ec6 100644
--- a/dist/build.json
+++ b/dist/build.json
@@ -2,10 +2,10 @@
"schemaVersion": 1,
"entries": {
"worker": {
- "identity": "sha256:346e43cad83c3aa102b27bffa4c4a3e2a276058b5889ed44125596b9634eab5e",
- "engineVersion": "1.2.0",
+ "identity": "sha256:8e66149e74496eabefc532a0a1f8428f54170e4cfb339fea33cbf7136d0cac03",
+ "engineVersion": "1.2.1",
"toolchain": "[email protected]",
- "sourceHash": "86a6a158a1c48dc9b8d1bf7b6b2a551edf7b1daa080c9c7402eec4ba246e3e7a",
+ "sourceHash": "989fe1a693eb374934c40e475fd4362846f6e9b251cba6f49e273347cfdd802f",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "bb179f2715f8fd9059898ef3a2028947e8f5f7e7979ad7eafe59d7a464c18f9f",
"dependencies": {
@@ -39,10 +39,10 @@
"bundleHash": "sha256:37098a17b5304a5f5746131c9652498d937a5181c0fb0975861dec999721d5be"
},
"agent-run": {
- "identity": "sha256:346e43cad83c3aa102b27bffa4c4a3e2a276058b5889ed44125596b9634eab5e",
- "engineVersion": "1.2.0",
+ "identity": "sha256:8e66149e74496eabefc532a0a1f8428f54170e4cfb339fea33cbf7136d0cac03",
+ "engineVersion": "1.2.1",
"toolchain": "[email protected]",
- "sourceHash": "86a6a158a1c48dc9b8d1bf7b6b2a551edf7b1daa080c9c7402eec4ba246e3e7a",
+ "sourceHash": "989fe1a693eb374934c40e475fd4362846f6e9b251cba6f49e273347cfdd802f",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "bb179f2715f8fd9059898ef3a2028947e8f5f7e7979ad7eafe59d7a464c18f9f",
"dependencies": {
@@ -73,13 +73,13 @@
},
"target": "node",
"file": "agent-run.mjs",
- "bundleHash": "sha256:ba89d90f15b95d682dc64320e797ebe21c9cc281613eb0f68eab1855d56e4aca"
+ "bundleHash": "sha256:1b94eaa8afad97fdb32f8b30b7a56adfe10203f11fe2073807a4b483b9e6894c"
},
"agent-providers": {
- "identity": "sha256:346e43cad83c3aa102b27bffa4c4a3e2a276058b5889ed44125596b9634eab5e",
- "engineVersion": "1.2.0",
+ "identity": "sha256:8e66149e74496eabefc532a0a1f8428f54170e4cfb339fea33cbf7136d0cac03",
+ "engineVersion": "1.2.1",
"toolchain": "[email protected]",
- "sourceHash": "86a6a158a1c48dc9b8d1bf7b6b2a551edf7b1daa080c9c7402eec4ba246e3e7a",
+ "sourceHash": "989fe1a693eb374934c40e475fd4362846f6e9b251cba6f49e273347cfdd802f",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "bb179f2715f8fd9059898ef3a2028947e8f5f7e7979ad7eafe59d7a464c18f9f",
"dependencies": {
@@ -113,10 +113,10 @@
"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"
},
"mcp": {
- "identity": "sha256:346e43cad83c3aa102b27bffa4c4a3e2a276058b5889ed44125596b9634eab5e",
- "engineVersion": "1.2.0",
+ "identity": "sha256:8e66149e74496eabefc532a0a1f8428f54170e4cfb339fea33cbf7136d0cac03",
+ "engineVersion": "1.2.1",
"toolchain": "[email protected]",
- "sourceHash": "86a6a158a1c48dc9b8d1bf7b6b2a551edf7b1daa080c9c7402eec4ba246e3e7a",
+ "sourceHash": "989fe1a693eb374934c40e475fd4362846f6e9b251cba6f49e273347cfdd802f",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "bb179f2715f8fd9059898ef3a2028947e8f5f7e7979ad7eafe59d7a464c18f9f",
"dependencies": {
@@ -147,13 +147,13 @@
},
"target": "node",
"file": "mcp-server.mjs",
- "bundleHash": "sha256:c9966be32621d48519ab7c0088ed808f155bc4450eaf09ed4ce2a6c843b64cc7"
+ "bundleHash": "sha256:2a726598b66fce577a1f452134d15d47d7578165bc63e401371b2eef5c59333a"
},
"cli": {
- "identity": "sha256:346e43cad83c3aa102b27bffa4c4a3e2a276058b5889ed44125596b9634eab5e",
- "engineVersion": "1.2.0",
+ "identity": "sha256:8e66149e74496eabefc532a0a1f8428f54170e4cfb339fea33cbf7136d0cac03",
+ "engineVersion": "1.2.1",
"toolchain": "[email protected]",
- "sourceHash": "86a6a158a1c48dc9b8d1bf7b6b2a551edf7b1daa080c9c7402eec4ba246e3e7a",
+ "sourceHash": "989fe1a693eb374934c40e475fd4362846f6e9b251cba6f49e273347cfdd802f",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "bb179f2715f8fd9059898ef3a2028947e8f5f7e7979ad7eafe59d7a464c18f9f",
"dependencies": {
@@ -184,13 +184,13 @@
},
"target": "node",
"file": "cli.mjs",
- "bundleHash": "sha256:c1030e6929a5449b04f79d3f2bc7d331ccabc523e664cf537dbe42ab83a2d86b"
+ "bundleHash": "sha256:344e8790df8644bc5bfd05e76672dccd1a21b9cad01b7e5ed0c83a15500e3141"
},
"engine": {
- "identity": "sha256:346e43cad83c3aa102b27bffa4c4a3e2a276058b5889ed44125596b9634eab5e",
- "engineVersion": "1.2.0",
+ "identity": "sha256:8e66149e74496eabefc532a0a1f8428f54170e4cfb339fea33cbf7136d0cac03",
+ "engineVersion": "1.2.1",
"toolchain": "[email protected]",
- "sourceHash": "86a6a158a1c48dc9b8d1bf7b6b2a551edf7b1daa080c9c7402eec4ba246e3e7a",
+ "sourceHash": "989fe1a693eb374934c40e475fd4362846f6e9b251cba6f49e273347cfdd802f",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "bb179f2715f8fd9059898ef3a2028947e8f5f7e7979ad7eafe59d7a464c18f9f",
"dependencies": {
@@ -221,7 +221,7 @@
},
"target": "node",
"file": "mcp-engine.mjs",
- "bundleHash": "sha256:d286370c41304a3bcb313fb9427def5d5aad213d7b75d3ca10cabdc4f7db42df"
+ "bundleHash": "sha256:9f4c524c769aaf75c3dbb871352549ade6ad1bef1b3184b4dacbd510ce79daa3"
}
}
}
diff --git a/dist/cli.mjs b/dist/cli.mjs
index 386112d8..e84a7348 100644
--- a/dist/cli.mjs
+++ b/dist/cli.mjs
@@ -36171,7 +36171,7 @@ var init_program_artifacts = __esm(() => {
function engineIdentity() {
return { version: ENGINE_VERSION, installUrl: ENGINE_INSTALL_URL };
}
-var ENGINE_VERSION = "1.2.0", ENGINE_INSTALL_URL;
+var ENGINE_VERSION = "1.2.1", ENGINE_INSTALL_URL;
var init_engine_identity = __esm(() => {
ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
});
@@ -41029,6 +41029,9 @@ var init_view_render_timeout = __esm(() => {
WARM_UP_STATES = new Set(["unknown", "pending", "ready", "degraded"]);
});
+// src/asset-widget-uri.ts
+var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v6.html";
+
// src/views/port.ts
async function sha256Bytes(bytes) {
const input = new Uint8Array(bytes.byteLength);
@@ -43862,7 +43865,7 @@ function createKilnAssetDefs(context, presentation = "grouped") {
}
];
}
-var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html", DEFAULT_INLOOP_VIEW_RENDER_TIMEOUT_MS = 6000, viewEvidenceHistoryByContext, VIEW_EVIDENCE_GUIDANCE = " viewEvidence.current describes ONLY this request. lastFaithful is older hash-only evidence for reference, not reused pixels and not current verification.", validateInput, renderInput, renderViewsInput, reviewDetailOptions = (context) => ({
+var DEFAULT_INLOOP_VIEW_RENDER_TIMEOUT_MS = 6000, viewEvidenceHistoryByContext, VIEW_EVIDENCE_GUIDANCE = " viewEvidence.current describes ONLY this request. lastFaithful is older hash-only evidence for reference, not reused pixels and not current verification.", validateInput, renderInput, renderViewsInput, reviewDetailOptions = (context) => ({
retainedReport: () => {
const operation = context.liveReview?.currentOperation?.();
return operation ? {
diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjs
index 071ea508..44284c60 100644
--- a/dist/mcp-engine.mjs
+++ b/dist/mcp-engine.mjs
@@ -36103,10 +36103,10 @@ import {
import { readFile as readFile8 } from "node:fs/promises";
// src/asset-widget-uri.ts
-var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html";
+var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v6.html";
// src/engine-identity.ts
-var ENGINE_VERSION = "1.2.0";
+var ENGINE_VERSION = "1.2.1";
var ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
function engineIdentity() {
return { version: ENGINE_VERSION, installUrl: ENGINE_INSTALL_URL };
@@ -41937,7 +41937,6 @@ function resolveViewRenderTimeoutMs(input) {
// src/tools/registry.ts
init_evidence_history();
init_background();
-var KILN_ASSET_WIDGET_URI2 = "ui://kiln/asset-v5.html";
function proceduralTextureMaterialContract(rendered, context) {
const required = [...new Set(context.requiredProceduralTextureUsages ?? [])];
if (required.length === 0)
@@ -43490,7 +43489,7 @@ function createKilnAssetDefs(context, presentation = "grouped") {
downloadUrls: z23.record(z23.string(), z23.string()).optional()
}),
ui: {
- resourceUri: KILN_ASSET_WIDGET_URI2,
+ resourceUri: KILN_ASSET_WIDGET_URI,
data: async (output) => (await Promise.resolve().then(() => (init_asset_widget(), exports_asset_widget))).assetWidgetData(library(), output)
},
run: async (raw) => {
diff --git a/dist/mcp-server.mjs b/dist/mcp-server.mjs
index 16341298..470b3a47 100644
--- a/dist/mcp-server.mjs
+++ b/dist/mcp-server.mjs
@@ -1749,13 +1749,13 @@ var mcp_manifest_default = {
},
_meta: {
ui: {
- resourceUri: "ui://kiln/asset-v5.html",
+ resourceUri: "ui://kiln/asset-v6.html",
visibility: [
"model"
]
},
- "openai/outputTemplate": "ui://kiln/asset-v5.html",
- "ui/resourceUri": "ui://kiln/asset-v5.html"
+ "openai/outputTemplate": "ui://kiln/asset-v6.html",
+ "ui/resourceUri": "ui://kiln/asset-v6.html"
},
outputSchema: {
type: "object",
@@ -2034,7 +2034,7 @@ var mcp_manifest_default = {
],
resources: [
{
- uri: "ui://kiln/asset-v5.html",
+ uri: "ui://kiln/asset-v6.html",
name: "kiln-asset-viewer",
mimeType: "text/html;profile=mcp-app",
description: "Interactive Kiln asset viewer and downloads",
@@ -2082,10 +2082,10 @@ import {
import { readFile } from "node:fs/promises";
// src/asset-widget-uri.ts
-var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html";
+var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v6.html";
// src/engine-identity.ts
-var ENGINE_VERSION = "1.2.0";
+var ENGINE_VERSION = "1.2.1";
var ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
// src/requirements-json.ts
diff --git a/dist/viewer/app.js b/dist/viewer/app.js
index 0921149a..08cb6aff 100644
--- a/dist/viewer/app.js
+++ b/dist/viewer/app.js
@@ -1,8 +1,8 @@
-function to(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Tl(e,t="|"){return e.map((n)=>Cl(n)).join(t)}function no(e,t){if(typeof t==="bigint")return t.toString();return t}class Tf{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function io(e){return new Tf(e)}function Af(e){return e===null||e===void 0}function Ea(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Rf(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Dn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ro(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Li(e){return ro(e._zod.def)??e._zod.def.shape}function Cf(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Dn(this,t,i),i},enumerable:!0,configurable:!0})}function If(e,t,n){if(t in e)Dn(e,t,n);else e[t]=n}function Lr(e,t,n,i){let r=Li(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Cf(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else If(e,s,i?i(o.value,s):o.value)}}function Db(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Cf(e,n,()=>t[n]);else If(e,n,i.value)}}function Sn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Pf(e){return JSON.stringify(e)}function Lf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Al="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function os(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Nf=io(()=>{if(xn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Nr(e){if(os(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(os(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Rl(e){if(Nr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Df=new Set(["string","number","symbol"]);function Ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ci(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function De(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Cl(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Of(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ta=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Il={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ob(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Lr(s,e,Aa(e,t)),ci(e,Sn(n,{shape:s,checks:[]}))}function Aa(e,t){let n=Li(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function Ub(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Aa(e,t)),o={};return Lr(o,e,Reflect.ownKeys(Li(e)).filter((a)=>!s.has(a))),ci(e,Sn(n,{shape:o,checks:[]}))}function Fb(e,t){if(!Nr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Li(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ci(e,Sn(e._zod.def,{shape:Uf(e,t)}))}function Uf(e,t){let n={};return Lr(n,e,Reflect.ownKeys(Li(e))),Db(n,t),n}function zb(e,t){if(!Nr(t))throw Error("Invalid input to safeExtend: expected a plain object");return ci(e,Sn(e._zod.def,{shape:Uf(e,t)}))}function kb(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Lr(n,e,Reflect.ownKeys(Li(e))),Lr(n,t,Reflect.ownKeys(Li(t)));let i=Sn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ci(e,i)}function Ff(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Aa(t,n)):void 0,c={};return Lr(c,t,Reflect.ownKeys(Li(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),ci(t,Sn(t._zod.def,{shape:c,checks:[]}))}function Bb(e,t,n){let i=n?new Set(Aa(t,n)):void 0,r={};return Lr(r,t,Reflect.ownKeys(Li(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),ci(t,Sn(t._zod.def,{shape:r}))}function li(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function zf(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Qi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function eo(e){return typeof e==="string"?e:e?.message}function Pl(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ui(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:eo(e.inst?._zod.def?.error?.(e))??eo(s?.(e))??eo(t?.error?.(e))??eo(n.customError?.(e))??eo(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var Gb=/[\uD800-\uDBFF]/;function Ra(e){let t=e.length;if(!Gb.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Ca(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function kf(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Dr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Bf(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else Hb(e,n,i.value)}}function Ni(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Ia(e,t,n){return Ni(e,t,n,!1)}function Gf(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ni(this,n,i(this))},set(r){Ni(this,n,r)}})}return t}function Hb(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ni(this,t,n.bind(this))},set(i){Ni(this,t,i)}})}function Vb(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var El,Ki=!1,$b={configurable:!0,get(){Ki=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&El!==e._zod){El=void 0;return}El=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,$b);let r=Ki;Ki=!1;try{let s=n(this);if(Ki)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ki=Ki||r,s}catch(s){throw delete this[t],Ki=Ki||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Wb(e,t,n,i){let r=Vb(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var Zb="~constantCatch";function Hf(e){let t=()=>e;return t[Zb]=!0,t}var Vf;var Ll={value:void 0,enumerable:!1},$f="captureStackTrace"in Error?Error:null;function Xb(e){let t=$f;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return $f=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ie(e,t,n,i){let r={};function s(d){this.def=d,this.constr=h,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(d,f){if(!d._zod){Ll.value=new s(f);try{Object.defineProperty(d,"_zod",Ll)}finally{Ll.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let _=Object.getPrototypeOf(d),p=d._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let M=g??_;if(!a.has(M))a.add(M),Bf(M,o)}let m=h.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in d))d[_]=m[_].bind(d)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function h(d){let f=i?.Parent?Xb(u):this;c(f,d);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:(d)=>{if(i?.Parent&&d instanceof i.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class hi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class so extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Vf=globalThis).__zod_globalConfig??(Vf.__zod_globalConfig={});var xn=globalThis.__zod_globalConfig;function wn(e){if(e)Object.assign(xn,e);return xn}function jb(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,no,2)),e.message}function qb(e){this._zod.message=e}var Yb={get:jb,set:qb,enumerable:!0,configurable:!0},Dl={value:void 0,enumerable:!1},Wf=new WeakSet([Object.prototype,Error.prototype]),Zf=(e,t)=>{e.name="$ZodError",Dl.value=t,Object.defineProperty(e,"issues",Dl),Dl.value=void 0,Object.defineProperty(e,"message",Yb);let n=Object.getPrototypeOf(e);if(!Wf.has(n))Wf.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},Xf=ie("$ZodError",Zf),WC=ie("$ZodError",Zf,void 0,{Parent:Error});function Kb(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function jf(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)Kb(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function qf(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],h=l===a.length-1;if(u==="_errors"){if(h)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(h)d._errors.push(t(o));c=d,l++}}}};return i(e),n}function Pa(e,t){return{callee:t?.callee??e,Err:t?.Err}}var La=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new hi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Al(c,s?.callee??t),c}return a.value};return t};var Na=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Al(c,s?.callee??t),c}return a.value};return t};var Da=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new hi;return s.issues.length?Yf(e,s.issues,r):{success:!0,data:s.value}};function Yf(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>ui(r,n,wn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Oa=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?Yf(e,s.issues,r):{success:!0,data:s.value}};var Jb=Symbol.for("zod.compile.invalid"),Qb=Symbol.for("zod.compile.fallback"),Ol=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==Jb)return!0;if(i.definite===!0&&n===void 0)return!1}return eS(e,t,n)};function eS(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[Qb]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new hi;return s.issues.length===0}var Ul=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},Kf=(e)=>{let t=La(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Pa(n,o))};return n};var Jf=(e)=>{let t=La(e),n=(i,r,s,o)=>t(i,r,s,Pa(n,o));return n};var Qf=(e)=>{let t=Na(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Pa(n,o))};return n};var ep=(e)=>{let t=Na(e),n=async(i,r,s,o)=>await t(i,r,s,Pa(n,o));return n};var tp=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Da(e)(t,n,r)};var np=(e)=>(t,n,i)=>Da(e)(t,n,i);var ip=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Oa(e)(t,n,r)};var rp=(e)=>async(t,n,i)=>Oa(e)(t,n,i);var sp=/^[cC][0-9a-z]{6,}$/,op=/^[0-9a-z]+$/,ap=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,cp=/^[0-9a-vA-V]{20}$/,lp=/^[A-Za-z0-9]{27}$/,up=/^[a-zA-Z0-9_-]{21}$/;function hp(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var dp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var fp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zl=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var pp=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var tS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function mp(){return new RegExp(tS,"u")}var gp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_p=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var xp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,vp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bp=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Sp=/^https?$/,wp=/^\+[1-9]\d{6,14}$/;var Mp="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function nS(e){return new RegExp(`^${e}$`)}var Ep=nS(Mp);function Fl(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Tp(e){return new RegExp(`^${Fl(e)}$`)}function Ap(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Fl({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Fl({precision:e.precision})}`:n;return new RegExp(`^${Mp}T(?:${i})$`)}var Rp=/^[\s\S]{0,}$/;var kl=/^-?\d+$/,oo=/^-?\d+(?:\.\d+)?$/,Cp=/^(?:true|false)$/i;var Ip=/^[^A-Z]*$/,Pp=/^[^a-z]*$/;var nn=ie("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Bl=(e)=>{let t=e.value;return!Af(t)&&t.length!==void 0},Ua={number:"number",bigint:"bigint",object:"date"},Gl=ie("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);let n=Ua[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Ua[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hl=ie("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);let n=Ua[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Ua[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Lp=ie("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Rf(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Np=ie("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Ta[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Dp=ie("$ZodCheckMaxLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Bl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Ra(r):s)<=t.maximum)return;let a=Ca(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Op=ie("$ZodCheckMinLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Bl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Ra(r):s)>=t.minimum)return;let a=Ca(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Up=ie("$ZodCheckLengthEquals",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Bl),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Ra(r):s;if(o===t.length)return;let a=Ca(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),co=ie("$ZodCheckStringFormat",(e,t)=>{var n,i;if(nn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Fp=ie("$ZodCheckRegex",(e,t)=>{co.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),zp=ie("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ip),co.init(e,t)}),kp=ie("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Pp),co.init(e,t)}),Bp=ie("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);let n=Ji(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Gp=ie("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`^${Ji(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Hp=ie("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`.*${Ji(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Vp=ie("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Vl{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
+function ro(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Al(e,t="|"){return e.map((n)=>Il(n)).join(t)}function so(e,t){if(typeof t==="bigint")return t.toString();return t}class Af{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function oo(e){return new Af(e)}function Rf(e){return e===null||e===void 0}function Aa(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Cf(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Dn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ao(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ni(e){return ao(e._zod.def)??e._zod.def.shape}function If(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Dn(this,t,i),i},enumerable:!0,configurable:!0})}function Pf(e,t,n){if(t in e)Dn(e,t,n);else e[t]=n}function Nr(e,t,n,i){let r=Ni(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)If(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Pf(e,s,i?i(o.value,s):o.value)}}function Ub(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)If(e,n,()=>t[n]);else Pf(e,n,i.value)}}function Sn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Lf(e){return JSON.stringify(e)}function Nf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Rl="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function as(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Df=oo(()=>{if(xn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Dr(e){if(as(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(as(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Cl(e){if(Dr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Of=new Set(["string","number","symbol"]);function Qi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ci(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function De(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Il(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Uf(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ra=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Pl={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Fb(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Nr(s,e,Ca(e,t)),ci(e,Sn(n,{shape:s,checks:[]}))}function Ca(e,t){let n=Ni(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function zb(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Ca(e,t)),o={};return Nr(o,e,Reflect.ownKeys(Ni(e)).filter((a)=>!s.has(a))),ci(e,Sn(n,{shape:o,checks:[]}))}function kb(e,t){if(!Dr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Ni(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ci(e,Sn(e._zod.def,{shape:Ff(e,t)}))}function Ff(e,t){let n={};return Nr(n,e,Reflect.ownKeys(Ni(e))),Ub(n,t),n}function Bb(e,t){if(!Dr(t))throw Error("Invalid input to safeExtend: expected a plain object");return ci(e,Sn(e._zod.def,{shape:Ff(e,t)}))}function Gb(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Nr(n,e,Reflect.ownKeys(Ni(e))),Nr(n,t,Reflect.ownKeys(Ni(t)));let i=Sn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ci(e,i)}function zf(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ca(t,n)):void 0,c={};return Nr(c,t,Reflect.ownKeys(Ni(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),ci(t,Sn(t._zod.def,{shape:c,checks:[]}))}function Hb(e,t,n){let i=n?new Set(Ca(t,n)):void 0,r={};return Nr(r,t,Reflect.ownKeys(Ni(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),ci(t,Sn(t._zod.def,{shape:r}))}function li(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function kf(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function er(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function io(e){return typeof e==="string"?e:e?.message}function Ll(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ui(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:io(e.inst?._zod.def?.error?.(e))??io(s?.(e))??io(t?.error?.(e))??io(n.customError?.(e))??io(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var Vb=/[\uD800-\uDBFF]/;function Ia(e){let t=e.length;if(!Vb.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Pa(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Bf(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Or(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Gf(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else $b(e,n,i.value)}}function Di(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function La(e,t,n){return Di(e,t,n,!1)}function Hf(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Di(this,n,i(this))},set(r){Di(this,n,r)}})}return t}function $b(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Di(this,t,n.bind(this))},set(i){Di(this,t,i)}})}function Wb(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Tl,Ji=!1,Zb={configurable:!0,get(){Ji=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Tl!==e._zod){Tl=void 0;return}Tl=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,Zb);let r=Ji;Ji=!1;try{let s=n(this);if(Ji)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ji=Ji||r,s}catch(s){throw delete this[t],Ji=Ji||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Xb(e,t,n,i){let r=Wb(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var jb="~constantCatch";function Vf(e){let t=()=>e;return t[jb]=!0,t}var $f;var Nl={value:void 0,enumerable:!1},Wf="captureStackTrace"in Error?Error:null;function qb(e){let t=Wf;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Wf=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ie(e,t,n,i){let r={};function s(d){this.def=d,this.constr=h,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(d,f){if(!d._zod){Nl.value=new s(f);try{Object.defineProperty(d,"_zod",Nl)}finally{Nl.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let _=Object.getPrototypeOf(d),p=d._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let M=g??_;if(!a.has(M))a.add(M),Gf(M,o)}let m=h.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in d))d[_]=m[_].bind(d)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function h(d){let f=i?.Parent?qb(u):this;c(f,d);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:(d)=>{if(i?.Parent&&d instanceof i.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class hi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class co extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}($f=globalThis).__zod_globalConfig??($f.__zod_globalConfig={});var xn=globalThis.__zod_globalConfig;function wn(e){if(e)Object.assign(xn,e);return xn}function Yb(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,so,2)),e.message}function Kb(e){this._zod.message=e}var Jb={get:Yb,set:Kb,enumerable:!0,configurable:!0},Ol={value:void 0,enumerable:!1},Zf=new WeakSet([Object.prototype,Error.prototype]),Xf=(e,t)=>{e.name="$ZodError",Ol.value=t,Object.defineProperty(e,"issues",Ol),Ol.value=void 0,Object.defineProperty(e,"message",Jb);let n=Object.getPrototypeOf(e);if(!Zf.has(n))Zf.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},jf=ie("$ZodError",Xf),XC=ie("$ZodError",Xf,void 0,{Parent:Error});function Qb(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function qf(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)Qb(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Yf(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],h=l===a.length-1;if(u==="_errors"){if(h)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(h)d._errors.push(t(o));c=d,l++}}}};return i(e),n}function Na(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Da=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new hi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Rl(c,s?.callee??t),c}return a.value};return t};var Oa=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Rl(c,s?.callee??t),c}return a.value};return t};var Ua=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new hi;return s.issues.length?Kf(e,s.issues,r):{success:!0,data:s.value}};function Kf(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>ui(r,n,wn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Fa=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?Kf(e,s.issues,r):{success:!0,data:s.value}};var eS=Symbol.for("zod.compile.invalid"),tS=Symbol.for("zod.compile.fallback"),Ul=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==eS)return!0;if(i.definite===!0&&n===void 0)return!1}return nS(e,t,n)};function nS(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[tS]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new hi;return s.issues.length===0}var Fl=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},Jf=(e)=>{let t=Da(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Na(n,o))};return n};var Qf=(e)=>{let t=Da(e),n=(i,r,s,o)=>t(i,r,s,Na(n,o));return n};var ep=(e)=>{let t=Oa(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Na(n,o))};return n};var tp=(e)=>{let t=Oa(e),n=async(i,r,s,o)=>await t(i,r,s,Na(n,o));return n};var np=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Ua(e)(t,n,r)};var ip=(e)=>(t,n,i)=>Ua(e)(t,n,i);var rp=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Fa(e)(t,n,r)};var sp=(e)=>async(t,n,i)=>Fa(e)(t,n,i);var op=/^[cC][0-9a-z]{6,}$/,ap=/^[0-9a-z]+$/,cp=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,lp=/^[0-9a-vA-V]{20}$/,up=/^[A-Za-z0-9]{27}$/,hp=/^[a-zA-Z0-9_-]{21}$/;function dp(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var fp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var pp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,kl=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var mp=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var iS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function gp(){return new RegExp(iS,"u")}var _p=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var vp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sp=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var wp=/^https?$/,Mp=/^\+[1-9]\d{6,14}$/;var Ep="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function rS(e){return new RegExp(`^${e}$`)}var Tp=rS(Ep);function zl(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Ap(e){return new RegExp(`^${zl(e)}$`)}function Rp(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${zl({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${zl({precision:e.precision})}`:n;return new RegExp(`^${Ep}T(?:${i})$`)}var Cp=/^[\s\S]{0,}$/;var Bl=/^-?\d+$/,lo=/^-?\d+(?:\.\d+)?$/,Ip=/^(?:true|false)$/i;var Pp=/^[^A-Z]*$/,Lp=/^[^a-z]*$/;var nn=ie("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Gl=(e)=>{let t=e.value;return!Rf(t)&&t.length!==void 0},za={number:"number",bigint:"bigint",object:"date"},Hl=ie("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);let n=za[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:za[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vl=ie("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);let n=za[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:za[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Np=ie("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Cf(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Dp=ie("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Ra[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Op=ie("$ZodCheckMaxLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Gl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Ia(r):s)<=t.maximum)return;let a=Pa(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Up=ie("$ZodCheckMinLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Gl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Ia(r):s)>=t.minimum)return;let a=Pa(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Fp=ie("$ZodCheckLengthEquals",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Gl),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Ia(r):s;if(o===t.length)return;let a=Pa(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ho=ie("$ZodCheckStringFormat",(e,t)=>{var n,i;if(nn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),zp=ie("$ZodCheckRegex",(e,t)=>{ho.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kp=ie("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pp),ho.init(e,t)}),Bp=ie("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Lp),ho.init(e,t)}),Gp=ie("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);let n=Qi(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Hp=ie("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`^${Qi(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Vp=ie("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`.*${Qi(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var $p=ie("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class $l{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
`).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
${t.join(`
`)}
-};`)(...Object.values(this.closed))}}var Wp={major:4,minor:6,patch:5};var Ct=ie("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wp;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=li(a),h;for(let d of c){if(d._zod.def.when){if(zf(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new hi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Pl(a.issues,f,e),!u)u=li(a,f)});else{if(a.issues.length===f)continue;if(Pl(a.issues,f,e),!u)u=li(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(li(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new hi;return u.then((h)=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((h)=>o(h,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new hi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Ia(this,"~standard",Wl(this))},set "~standard"(e){Ni(this,"~standard",e)}}),nm=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ui(n,t,wn()))}:{value:e.value};async function iS(e,t){let n={async:!0};return nm(await e._zod.run({value:t,issues:[]},n),n)}function Wl(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return nm(i,n)}catch(i){}return iS(e,t)},vendor:"zod",version:1}}var Ba=ie("$ZodString",(e,t)=>{Ct.init(e,t),e._zod.pattern=t.pattern??Rp,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Tt=ie("$ZodStringFormat",(e,t)=>{co.init(e,t),Ba.init(e,t)}),im=ie("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fp),Tt.init(e,t)}),rm=ie("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=zl(i))}else t.pattern??(t.pattern=zl());Tt.init(e,t)}),sm=ie("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pp),Tt.init(e,t)}),om=1,za=2;function am(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function rS(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return am(e)||za;return sS(e,t)}function sS(e,t){if(!t.normalize&&t.protocol?.source===Sp.source&&!/^https?:\/\//i.test(e))return om;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??za}return new URL(e)}catch{return za}}var oS=/[\t\n\r]/g;function Zp(e){return e.replace(oS,"")}function aS(e,t){return t.lastIndex=0,t.test(e.hostname)}function cS(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var cm=ie("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=rS(i,t);if(r===om){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===za){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Zp(i);return}if(t.hostname&&!aS(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!cS(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:Zp(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),lm=ie("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=mp()),Tt.init(e,t)}),um=ie("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?up:hp(t.length)),Tt.init(e,t)}),hm=ie("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sp),Tt.init(e,t)}),dm=ie("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=op),Tt.init(e,t)}),fm=ie("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ap),Tt.init(e,t)}),pm=ie("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cp),Tt.init(e,t)}),mm=ie("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=lp),Tt.init(e,t)}),gm=ie("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ap(t)),Tt.init(e,t)}),_m=ie("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ep),Tt.init(e,t)}),xm=ie("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Tp(t)),Tt.init(e,t)}),vm=ie("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=dp),Tt.init(e,t)}),ym=ie("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gp),Tt.init(e,t)}),lS=/^[0-9a-fA-F:.]+$/;function bm(e){if(!lS.test(e))return!1;return am(`http://[${e}]`)}var Sm=ie("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=_p),Tt.init(e,t),e._zod.check=(n)=>{if(!bm(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var wm=ie("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=xp),Tt.init(e,t)});function uS(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return bm(n)}var Mm=ie("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vp),Tt.init(e,t),e._zod.check=(n)=>{if(!uS(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Em(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Zl=/^[0-9a-zA-Z+/]*={0,2}$/,Tm=ie("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Zl),Tt.init(e,t),e._zod.check=(n)=>{if(Em(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ga=/^[A-Za-z0-9_-]*$/;function hS(e){if(!Ga.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Em(n)}var Am=ie("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ga),Tt.init(e,t),e._zod.check=(n)=>{if(hS(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Rm=ie("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wp),Tt.init(e,t)});function dS(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var Cm=ie("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{if(dS(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Xl=ie("$ZodNumber",(e,t)=>{Ct.init(e,t),e._zod.pattern=oo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Im=ie("$ZodNumberFormat",(e,t)=>{Np.init(e,t),Xl.init(e,t)}),Pm=ie("$ZodBoolean",(e,t)=>{Ct.init(e,t),e._zod.pattern=Cp,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var Lm=ie("$ZodUnknown",(e,t)=>{Ct.init(e,t),e._zod.parse=(n)=>n}),Nm=ie("$ZodNever",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Xp(e,t,n){if(e.issues.length)t.issues.push(...Qi(n,e.issues));t.value[n]=e.value}var Dm=ie("$ZodArray",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((h)=>Xp(h,i,c)));else if(Xp(u,i,c),a&&u.issues.length!==0&&li(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function ka(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...Qi(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var fS=[];function Om(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:fS,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Of(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Um(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:h,optout:d}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(li(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>ka(p,n,m,t,h,d)));else ka(_,n,m,t,h,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var pS=ie("$ZodObject",(e,t)=>{Ct.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=io(()=>Om(t));at(e,"propValues",(l)=>{let u=l.def.shape,h={};for(let d in u){let f=u[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(h,d))Dn(h,d,new Set);for(let m of f.values)h[d].add(m);if(f.optin!==void 0)h[d].add(void 0)}}return h});let s=os,o=t.catchall,a,c=xn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let h=l.value;if(!s(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(li(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],M=g._zod.optin,T=g._zod.optout,v=g._zod.run({value:h[p],issues:[]},u);if(v instanceof Promise)d.push(v.then((S)=>ka(S,l,p,h,M,T)));else ka(v,l,p,h,M,T)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Um(d,h,l,u,r.value,e,m===!0)}}),Fm=ie("$ZodObjectJIT",(e,t)=>{pS.init(e,t);let n=e._zod.parse,i=io(()=>Om(t)),r=xn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new Vl(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(S)=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,M=(S,E)=>`
+};`)(...Object.values(this.closed))}}var Zp={major:4,minor:6,patch:5};var Ct=ie("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Zp;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=li(a),h;for(let d of c){if(d._zod.def.when){if(kf(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new hi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Ll(a.issues,f,e),!u)u=li(a,f)});else{if(a.issues.length===f)continue;if(Ll(a.issues,f,e),!u)u=li(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(li(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new hi;return u.then((h)=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((h)=>o(h,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new hi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return La(this,"~standard",Zl(this))},set "~standard"(e){Di(this,"~standard",e)}}),im=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ui(n,t,wn()))}:{value:e.value};async function sS(e,t){let n={async:!0};return im(await e._zod.run({value:t,issues:[]},n),n)}function Zl(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return im(i,n)}catch(i){}return sS(e,t)},vendor:"zod",version:1}}var Ha=ie("$ZodString",(e,t)=>{Ct.init(e,t),e._zod.pattern=t.pattern??Cp,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Tt=ie("$ZodStringFormat",(e,t)=>{ho.init(e,t),Ha.init(e,t)}),rm=ie("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=pp),Tt.init(e,t)}),sm=ie("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=kl(i))}else t.pattern??(t.pattern=kl());Tt.init(e,t)}),om=ie("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mp),Tt.init(e,t)}),am=1,Ba=2;function cm(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function oS(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return cm(e)||Ba;return aS(e,t)}function aS(e,t){if(!t.normalize&&t.protocol?.source===wp.source&&!/^https?:\/\//i.test(e))return am;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Ba}return new URL(e)}catch{return Ba}}var cS=/[\t\n\r]/g;function Xp(e){return e.replace(cS,"")}function lS(e,t){return t.lastIndex=0,t.test(e.hostname)}function uS(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var lm=ie("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=oS(i,t);if(r===am){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Ba){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Xp(i);return}if(t.hostname&&!lS(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!uS(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:Xp(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),um=ie("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=gp()),Tt.init(e,t)}),hm=ie("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?hp:dp(t.length)),Tt.init(e,t)}),dm=ie("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=op),Tt.init(e,t)}),fm=ie("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ap),Tt.init(e,t)}),pm=ie("$ZodULID",(e,t)=>{t.pattern??(t.pattern=cp),Tt.init(e,t)}),mm=ie("$ZodXID",(e,t)=>{t.pattern??(t.pattern=lp),Tt.init(e,t)}),gm=ie("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=up),Tt.init(e,t)}),_m=ie("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Rp(t)),Tt.init(e,t)}),xm=ie("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Tp),Tt.init(e,t)}),vm=ie("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ap(t)),Tt.init(e,t)}),ym=ie("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=fp),Tt.init(e,t)}),bm=ie("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=_p),Tt.init(e,t)}),hS=/^[0-9a-fA-F:.]+$/;function Sm(e){if(!hS.test(e))return!1;return cm(`http://[${e}]`)}var wm=ie("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=xp),Tt.init(e,t),e._zod.check=(n)=>{if(!Sm(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Mm=ie("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vp),Tt.init(e,t)});function dS(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return Sm(n)}var Em=ie("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yp),Tt.init(e,t),e._zod.check=(n)=>{if(!dS(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Tm(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Xl=/^[0-9a-zA-Z+/]*={0,2}$/,Am=ie("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Xl),Tt.init(e,t),e._zod.check=(n)=>{if(Tm(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Va=/^[A-Za-z0-9_-]*$/;function fS(e){if(!Va.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Tm(n)}var Rm=ie("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Va),Tt.init(e,t),e._zod.check=(n)=>{if(fS(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Cm=ie("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Mp),Tt.init(e,t)});function pS(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var Im=ie("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{if(pS(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var jl=ie("$ZodNumber",(e,t)=>{Ct.init(e,t),e._zod.pattern=lo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Pm=ie("$ZodNumberFormat",(e,t)=>{Dp.init(e,t),jl.init(e,t)}),Lm=ie("$ZodBoolean",(e,t)=>{Ct.init(e,t),e._zod.pattern=Ip,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var Nm=ie("$ZodUnknown",(e,t)=>{Ct.init(e,t),e._zod.parse=(n)=>n}),Dm=ie("$ZodNever",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function jp(e,t,n){if(e.issues.length)t.issues.push(...er(n,e.issues));t.value[n]=e.value}var Om=ie("$ZodArray",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((h)=>jp(h,i,c)));else if(jp(u,i,c),a&&u.issues.length!==0&&li(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function Ga(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...er(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var mS=[];function Um(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:mS,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Uf(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Fm(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:h,optout:d}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(li(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>Ga(p,n,m,t,h,d)));else Ga(_,n,m,t,h,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var gS=ie("$ZodObject",(e,t)=>{Ct.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=oo(()=>Um(t));at(e,"propValues",(l)=>{let u=l.def.shape,h={};for(let d in u){let f=u[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(h,d))Dn(h,d,new Set);for(let m of f.values)h[d].add(m);if(f.optin!==void 0)h[d].add(void 0)}}return h});let s=as,o=t.catchall,a,c=xn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let h=l.value;if(!s(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(li(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],M=g._zod.optin,T=g._zod.optout,v=g._zod.run({value:h[p],issues:[]},u);if(v instanceof Promise)d.push(v.then((S)=>Ga(S,l,p,h,M,T)));else Ga(v,l,p,h,M,T)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Fm(d,h,l,u,r.value,e,m===!0)}}),zm=ie("$ZodObjectJIT",(e,t)=>{gS.init(e,t);let n=e._zod.parse,i=oo(()=>Um(t)),r=xn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new $l(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(S)=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,M=(S,E)=>`
let ${S}_ab = false;
for (let i = 0; i < ${S}.issues.length; i++) {
const iss = ${S}.issues[i];
@@ -13,7 +13,7 @@ ${t.join(`
if (${S}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;p.write("const input = payload.value;");let T=Object.create(null),v=0;for(let S of m.allKeys)T[S]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let S of m.allKeys){if(S==="__proto__")continue;let E=T[S],R=typeof S==="symbol"?`syms[${_.indexOf(S)}]`:Pf(S),x=`${R} in input`,w=f[S],H=w?._zod?.optin,C=H!==void 0,N=w?._zod?.optout==="optional";if(p.write(`const ${E} = ${g(R)};`),C&&N){let ee=H==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;p.write(`
+ }`;p.write("const input = payload.value;");let T=Object.create(null),v=0;for(let S of m.allKeys)T[S]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let S of m.allKeys){if(S==="__proto__")continue;let E=T[S],R=typeof S==="symbol"?`syms[${_.indexOf(S)}]`:Lf(S),x=`${R} in input`,w=f[S],G=w?._zod?.optin,C=G!==void 0,D=w?._zod?.optout==="optional";if(p.write(`const ${E} = ${g(R)};`),C&&D){let ee=G==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;p.write(`
const ${E}_present = ${x};
if (!${E}.issues.length || ${E}_present) {
if (${E}.issues.length) {${M(E,R)}
@@ -48,24 +48,24 @@ ${t.join(`
`);else if(p.write(`
if (${E}.issues.length) {${M(E,R)}
}
- `),H==="defaulted")p.write(`newResult[${R}] = ${E}.value;`);else p.write(`
+ `),G==="defaulted")p.write(`newResult[${R}] = ${E}.value;`);else p.write(`
if (${E}.value !== undefined || ${x}) {
newResult[${R}] = ${E}.value;
}
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=os,c=!xn.jitless,u=c&&Nf.value,h=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!h)return f;return Um([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function jp(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!li(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>ui(o,i,wn())))}),t}var jl=ie("$ZodUnion",(e,t)=>{Ct.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Ea(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return jp(o,i,e,r);return Promise.all(o).then((a)=>jp(a,i,e,r))}});function mS(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var zm=ie("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,jl.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Dn(s,l,new Set);for(let h of u)s[l].add(h)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=ro(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=io(()=>mS(t));e._zod.parse=(r,s)=>{let o=r.value;if(!os(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),km=ie("$ZodIntersection",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>qp(n,c,l));return qp(n,s,o)}});function $l(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Nr(e)&&Nr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=$l(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=$l(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function qp(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let h;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),h=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);h=[d]}else return!1;for(let d of h){if(!i.has(d))i.set(d,{});i.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=$l(t.value,n.value);if(!c.valid){if(li(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Bm=ie("$ZodRecord",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Nr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((m)=>ui(m,r,wn())),input:u,path:[u],inst:e});continue}let d=h.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Qi(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Qi(u,f.issues));i.value[d]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&oo.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>ui(m,r,wn())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Qi(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Qi(l,f.issues));i.value[d]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Gm=ie("$ZodEnum",(e,t)=>{Ct.init(e,t);let n=to(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=to(r.def.entries).filter((o)=>Df.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Ji(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Hm=ie("$ZodLiteral",(e,t)=>{Ct.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Ji(s):s?Ji(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var Vm=ie("$ZodTransform",(e,t)=>{Ct.init(e,t),e._zod.optin="optional",xn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new so(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new hi;return n.value=r,n}});function Yp(e,t){return e.value=t.issues.length?void 0:t.value,e}var ql=ie("$ZodOptional",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Ea(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Yp(n,s));return Yp(n,r)}return t.innerType._zod.run(n,i)}}),$m=ie("$ZodExactOptional",(e,t)=>{ql.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Wm=ie("$ZodNullable",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Ea(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Zm=ie("$ZodDefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Kp(s,t));return Kp(r,t)}});function Kp(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Xm=ie("$ZodPrefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),jm=ie("$ZodNonOptional",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Jp(s,e));return Jp(r,e)}});function Jp(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Qp(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>ui(r,i,wn()))},input:e.value}),e}var qm=ie("$ZodCatch",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Qp(n,s,t,i));return Qp(n,r,t,i)}});var Ym=ie("$ZodPipe",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>Fa(o,t.in,i));return Fa(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Fa(s,t.out,i));return Fa(r,t.out,i)}});function Fa(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Km=ie("$ZodReadonly",(e,t)=>{Ct.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(em);return em(r)}});function em(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Jm=ie("$ZodCustom",(e,t)=>{nn.init(e,t),Ct.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>tm(s,n,i,e));tm(r,n,i,e);return}});function tm(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Dr(r))}}class eg extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Kl="~memo",Qm=[];function tg(e){return e!==null&&typeof e==="object"}function Yl(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var ng=new WeakMap,lo=0,$a=1,uo=2;function Wa(e,t,n){let i=ng.get(e);if(i!==void 0)return i?uo:lo;if(t.has(e))return uo;t.add(e);let r=lo,s=(u)=>{if(r!==uo&&u?._zod){let h=Wa(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=lo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?$a:m.value?._zod?Wa(m.value,t,n):lo;if(_>d)d=_}return d},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ro(c);a(u?o(u,!0):$a),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Wa(u,t,!1):$a);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let h=Object.getOwnPropertyDescriptor(c,u);if(!h||h.get)continue;let d=h.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let f of d)s(f)}}return t.delete(e),gS(e,r)}function gS(e,t){if(t!==$a)ng.set(e,t===uo);return t}function _S(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Ha,Va=[],xS={alloc(e,t,n){let i=Ha;if(!i)return n;Ha=void 0;let r={value:n,issues:null};return i.set(t.value,r),Va.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&vS(s,r.value))throw new eg;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=Wa(e,new Set,!1);if(g===lo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===uo||i)n=!0;else i=!0}let u=c.value;if(!tg(u))return o(c,l);let h=l[Kl];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[Kl]=h;let d;if(r===l)d=s;else d=_S(h,e),r=l,s=d;let f=d.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...Yl(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}Ha=d;let m=Va.length,_=o(c,l);Ha=void 0;let p=Va.length>m?Va.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?Yl(g.issues):Qm;return g});if(p)p.issues=_.issues.length?Yl(_.issues):Qm;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function ig(){return xS}function vS(e,t){let n=e[Kl]?.backEdges;return n!==void 0&&tg(t)&&n.has(t)}var yS=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=kf(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Cl(s.values[0])}`;return`Invalid option: expected one of ${Tl(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Tl(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Jl(){return{localeError:yS()}}var rg;class sg{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function bS(){return new sg}(rg=globalThis).__zod_globalRegistry??(rg.__zod_globalRegistry=bS());var Or=globalThis.__zod_globalRegistry;function og(e){if(e.checks)e.checks=[...e.checks];return e}function ag(e,t){return new e(og({type:"string",...De(t)}))}function cg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...De(t)})}function lg(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...De(t)})}function ug(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...De(t)})}function hg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...De(t)})}function dg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...De(t)})}function fg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...De(t)})}function pg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...De(t)})}function mg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...De(t)})}function gg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...De(t)})}function _g(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...De(t)})}function xg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...De(t)})}function vg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...De(t)})}function yg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...De(t)})}function bg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...De(t)})}function Sg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...De(t)})}function wg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...De(t)})}function Mg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...De(t)})}function Eg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...De(t)})}function Tg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...De(t)})}function Ag(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...De(t)})}function Rg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...De(t)})}function Cg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...De(t)})}function Ig(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...De(t)})}function Pg(e,t){return new e({type:"string",format:"date",check:"string_format",...De(t)})}function Lg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...De(t)})}function Ng(e,t){return new e({type:"string",format:"duration",check:"string_format",...De(t)})}function Dg(e,t){return new e(og({type:"number",checks:[],...De(t)}))}function Og(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...De(t)})}function Ug(e,t){return new e({type:"boolean",...De(t)})}function Fg(e){return new e({type:"unknown"})}function zg(e,t){return new e({type:"never",...De(t)})}function Za(e,t){return new Gl({check:"less_than",...De(t),value:e,inclusive:!1})}function ho(e,t){return new Gl({check:"less_than",...De(t),value:e,inclusive:!0})}function Xa(e,t){return new Hl({check:"greater_than",...De(t),value:e,inclusive:!1})}function fo(e,t){return new Hl({check:"greater_than",...De(t),value:e,inclusive:!0})}function ja(e,t){return new Lp({check:"multiple_of",...De(t),value:e})}function qa(e,t){return new Dp({check:"max_length",...De(t),maximum:e})}function as(e,t){return new Op({check:"min_length",...De(t),minimum:e})}function Ya(e,t){return new Up({check:"length_equals",...De(t),length:e})}function Ql(e,t){return new Fp({check:"string_format",format:"regex",...De(t),pattern:e})}function eu(e){return new zp({check:"string_format",format:"lowercase",...De(e)})}function tu(e){return new kp({check:"string_format",format:"uppercase",...De(e)})}function nu(e,t){return new Bp({check:"string_format",format:"includes",...De(t),includes:e})}function iu(e,t){return new Gp({check:"string_format",format:"starts_with",...De(t),prefix:e})}function ru(e,t){return new Hp({check:"string_format",format:"ends_with",...De(t),suffix:e})}function er(e){return new Vp({check:"overwrite",tx:e})}function su(e){return er((t)=>t.normalize(e))}function ou(){return er((e)=>e.trim())}function au(){return er((e)=>e.toLowerCase())}function cu(){return er((e)=>e.toUpperCase())}function lu(){return er((e)=>Lf(e))}function kg(e,t,n){return new e({type:"array",element:t,...De(n)})}function Bg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...De(n)})}function Gg(e,t){let n=SS((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Dr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Dr(s))}},e(i.value,i)),t);return n}function SS(e,t){let n=new nn({check:"custom",...De(t)});return n._zod.check=e,n}function po(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Dn(e,i,n[i]);return e}function hu(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Or,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function zt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,d,u)}let h=e._zod.parent;if(h){if(!o.ref)o.ref=h;zt(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)po(o.schema,c);if(t.io==="input"&&fn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Hg(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function du(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(o[0])?.id,d=e.external.uri??((m)=>m);if(h)return{ref:d(h)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${Hg(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Hg(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let h in u)delete u[h];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=as,c=!xn.jitless,u=c&&Df.value,h=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!h)return f;return Fm([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function qp(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!li(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>ui(o,i,wn())))}),t}var ql=ie("$ZodUnion",(e,t)=>{Ct.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Aa(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return qp(o,i,e,r);return Promise.all(o).then((a)=>qp(a,i,e,r))}});function _S(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var km=ie("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ql.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Dn(s,l,new Set);for(let h of u)s[l].add(h)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=ao(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=oo(()=>_S(t));e._zod.parse=(r,s)=>{let o=r.value;if(!as(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),Bm=ie("$ZodIntersection",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>Yp(n,c,l));return Yp(n,s,o)}});function Wl(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Dr(e)&&Dr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=Wl(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=Wl(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yp(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let h;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),h=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);h=[d]}else return!1;for(let d of h){if(!i.has(d))i.set(d,{});i.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Wl(t.value,n.value);if(!c.valid){if(li(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Gm=ie("$ZodRecord",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Dr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((m)=>ui(m,r,wn())),input:u,path:[u],inst:e});continue}let d=h.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...er(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...er(u,f.issues));i.value[d]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&lo.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>ui(m,r,wn())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...er(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...er(l,f.issues));i.value[d]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Hm=ie("$ZodEnum",(e,t)=>{Ct.init(e,t);let n=ro(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=ro(r.def.entries).filter((o)=>Of.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Qi(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Vm=ie("$ZodLiteral",(e,t)=>{Ct.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Qi(s):s?Qi(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var $m=ie("$ZodTransform",(e,t)=>{Ct.init(e,t),e._zod.optin="optional",xn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new co(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new hi;return n.value=r,n}});function Kp(e,t){return e.value=t.issues.length?void 0:t.value,e}var Yl=ie("$ZodOptional",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Aa(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Kp(n,s));return Kp(n,r)}return t.innerType._zod.run(n,i)}}),Wm=ie("$ZodExactOptional",(e,t)=>{Yl.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Zm=ie("$ZodNullable",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Aa(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Xm=ie("$ZodDefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Jp(s,t));return Jp(r,t)}});function Jp(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var jm=ie("$ZodPrefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),qm=ie("$ZodNonOptional",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Qp(s,e));return Qp(r,e)}});function Qp(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function em(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>ui(r,i,wn()))},input:e.value}),e}var Ym=ie("$ZodCatch",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>em(n,s,t,i));return em(n,r,t,i)}});var Km=ie("$ZodPipe",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>ka(o,t.in,i));return ka(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>ka(s,t.out,i));return ka(r,t.out,i)}});function ka(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Jm=ie("$ZodReadonly",(e,t)=>{Ct.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(tm);return tm(r)}});function tm(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Qm=ie("$ZodCustom",(e,t)=>{nn.init(e,t),Ct.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>nm(s,n,i,e));nm(r,n,i,e);return}});function nm(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Or(r))}}class tg extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Jl="~memo",eg=[];function ng(e){return e!==null&&typeof e==="object"}function Kl(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var ig=new WeakMap,fo=0,Za=1,po=2;function Xa(e,t,n){let i=ig.get(e);if(i!==void 0)return i?po:fo;if(t.has(e))return po;t.add(e);let r=fo,s=(u)=>{if(r!==po&&u?._zod){let h=Xa(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=fo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?Za:m.value?._zod?Xa(m.value,t,n):fo;if(_>d)d=_}return d},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ao(c);a(u?o(u,!0):Za),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Xa(u,t,!1):Za);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let h=Object.getOwnPropertyDescriptor(c,u);if(!h||h.get)continue;let d=h.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let f of d)s(f)}}return t.delete(e),xS(e,r)}function xS(e,t){if(t!==Za)ig.set(e,t===po);return t}function vS(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var $a,Wa=[],yS={alloc(e,t,n){let i=$a;if(!i)return n;$a=void 0;let r={value:n,issues:null};return i.set(t.value,r),Wa.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&bS(s,r.value))throw new tg;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=Xa(e,new Set,!1);if(g===fo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===po||i)n=!0;else i=!0}let u=c.value;if(!ng(u))return o(c,l);let h=l[Jl];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[Jl]=h;let d;if(r===l)d=s;else d=vS(h,e),r=l,s=d;let f=d.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...Kl(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}$a=d;let m=Wa.length,_=o(c,l);$a=void 0;let p=Wa.length>m?Wa.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?Kl(g.issues):eg;return g});if(p)p.issues=_.issues.length?Kl(_.issues):eg;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function rg(){return yS}function bS(e,t){let n=e[Jl]?.backEdges;return n!==void 0&&ng(t)&&n.has(t)}var SS=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Bf(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Il(s.values[0])}`;return`Invalid option: expected one of ${Al(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Al(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ql(){return{localeError:SS()}}var sg;class og{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function wS(){return new og}(sg=globalThis).__zod_globalRegistry??(sg.__zod_globalRegistry=wS());var Ur=globalThis.__zod_globalRegistry;function ag(e){if(e.checks)e.checks=[...e.checks];return e}function cg(e,t){return new e(ag({type:"string",...De(t)}))}function lg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...De(t)})}function ug(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...De(t)})}function hg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...De(t)})}function dg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...De(t)})}function fg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...De(t)})}function pg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...De(t)})}function mg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...De(t)})}function gg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...De(t)})}function _g(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...De(t)})}function xg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...De(t)})}function vg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...De(t)})}function yg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...De(t)})}function bg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...De(t)})}function Sg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...De(t)})}function wg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...De(t)})}function Mg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...De(t)})}function Eg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...De(t)})}function Tg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...De(t)})}function Ag(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...De(t)})}function Rg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...De(t)})}function Cg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...De(t)})}function Ig(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...De(t)})}function Pg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...De(t)})}function Lg(e,t){return new e({type:"string",format:"date",check:"string_format",...De(t)})}function Ng(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...De(t)})}function Dg(e,t){return new e({type:"string",format:"duration",check:"string_format",...De(t)})}function Og(e,t){return new e(ag({type:"number",checks:[],...De(t)}))}function Ug(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...De(t)})}function Fg(e,t){return new e({type:"boolean",...De(t)})}function zg(e){return new e({type:"unknown"})}function kg(e,t){return new e({type:"never",...De(t)})}function ja(e,t){return new Hl({check:"less_than",...De(t),value:e,inclusive:!1})}function mo(e,t){return new Hl({check:"less_than",...De(t),value:e,inclusive:!0})}function qa(e,t){return new Vl({check:"greater_than",...De(t),value:e,inclusive:!1})}function go(e,t){return new Vl({check:"greater_than",...De(t),value:e,inclusive:!0})}function Ya(e,t){return new Np({check:"multiple_of",...De(t),value:e})}function Ka(e,t){return new Op({check:"max_length",...De(t),maximum:e})}function cs(e,t){return new Up({check:"min_length",...De(t),minimum:e})}function Ja(e,t){return new Fp({check:"length_equals",...De(t),length:e})}function eu(e,t){return new zp({check:"string_format",format:"regex",...De(t),pattern:e})}function tu(e){return new kp({check:"string_format",format:"lowercase",...De(e)})}function nu(e){return new Bp({check:"string_format",format:"uppercase",...De(e)})}function iu(e,t){return new Gp({check:"string_format",format:"includes",...De(t),includes:e})}function ru(e,t){return new Hp({check:"string_format",format:"starts_with",...De(t),prefix:e})}function su(e,t){return new Vp({check:"string_format",format:"ends_with",...De(t),suffix:e})}function tr(e){return new $p({check:"overwrite",tx:e})}function ou(e){return tr((t)=>t.normalize(e))}function au(){return tr((e)=>e.trim())}function cu(){return tr((e)=>e.toLowerCase())}function lu(){return tr((e)=>e.toUpperCase())}function uu(){return tr((e)=>Nf(e))}function Bg(e,t,n){return new e({type:"array",element:t,...De(n)})}function Gg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...De(n)})}function Hg(e,t){let n=MS((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Or(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Or(s))}},e(i.value,i)),t);return n}function MS(e,t){let n=new nn({check:"custom",...De(t)});return n._zod.check=e,n}function _o(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Dn(e,i,n[i]);return e}function du(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Ur,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Oi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function zt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,d,u)}let h=e._zod.parent;if(h){if(!o.ref)o.ref=h;zt(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)_o(o.schema,c);if(t.io==="input"&&fn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Vg(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function fu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(o[0])?.id,d=e.external.uri??((m)=>m);if(h)return{ref:d(h)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${Vg(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Vg(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let h in u)delete u[h];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Wg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;Wg(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Zg=new Set(["type","properties","required","additionalProperties"]),Vg=["oneOf","anyOf"];function $g(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function uu(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!Zg.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??$g(l);if(u===null||u===void 0)continue;if(!a.some((h)=>JSON.stringify(h)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:uu(a)??{allOf:a};Dn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=$g(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function wS(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Zg)if(r in e)return;let n=t.filter((r)=>Vg.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=uu(t);else{let r=n[0],s=Vg.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>uu([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,po(e,i)}function fu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},h=c.ref;if(c.ref=null,h){i(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else po(l,m);if(po(l,u),a._zod.parent===h)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let d=a._zod.parent;if(d&&d!==h){i(d);let f=e.seen.get(d);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Wg(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let h=a.get(u);if(h)h.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])wS(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}po(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Dn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:mo(t,"input",e.processors),output:mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return fn(i.element,n);if(i.type==="set")return fn(i.valueType,n);if(i.type==="lazy")return fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return fn(i.innerType,n);if(i.type==="intersection")return fn(i.left,n)||fn(i.right,n);if(i.type==="record"||i.type==="map")return fn(i.keyType,n)||fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fn(i.in,n)||fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(fn(r,n))return!0;if(i.rest&&fn(i.rest,n))return!0;return!1}return!1}var Xg=(e,t={})=>(n)=>{let i=hu({...n,processors:t});return zt(e,i),du(i,e),fu(i,e)},mo=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=hu({...r??{},target:s,io:t,processors:n});return zt(e,o),du(o,e),fu(o,e)};var cs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},ls=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},jg=(e,t)=>{cs(e,"minimum",t),ls(e,"maximum",t)},Jg=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Qg=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},e_=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},t_=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},qg=(e,t)=>cs(e,"minimum",t.minimum),Yg=(e,t)=>ls(e,"maximum",t.maximum),Kg=(e)=>(t,n)=>{t_(t,n.format);let[i,r]=e[n.format];cs(t,"minimum",i),ls(t,"maximum",r)},MS={greater_than:(e,t)=>cs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ls(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Jg(e,t.value),number_format:Kg(Ta),bigint_format:Kg(Il),min_length:qg,max_length:Yg,length_equals:(e,t)=>jg(e,t.length),min_size:qg,max_size:Yg,size_equals:(e,t)=>jg(e,t.size),string_format:(e,t)=>{if(t_(e,t.format),t.pattern)Qg(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>e_(e,t.mime)};function On(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)MS[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)cs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)cs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)ls(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)ls(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)Jg(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)e_(t,r.mime);for(let s of r.patterns??[])Qg(t,s);return t}var ES={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},TS=new Map([[Zl,yp],[Ga,bp]]),n_=(e)=>TS.get(e)??e,i_=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=On(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=ES[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let h=[...c].map(n_);if(h.length===1)r.pattern=h[0].source;else if(h.length>1)r.allOf=[...h.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},r_=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=On(e);r.type=u?"integer":"number";let h=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(d)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else Di(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},s_=(e,t,n,i)=>{n.type="boolean"};var o_=(e,t,n,i)=>{n.not={}};var a_=(e,t,n,i)=>{};var c_=(e,t,n,i)=>{let r=e._zod.def,s=to(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},l_=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var u_=(e,t,n,i)=>{Di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var h_=(e,t,n,i)=>{Di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var d_=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=On(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=zt(s.element,t,{...i,path:[...i.path,"items"]})};function Ka(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ka(t.out);if(t.type==="catch")return Ka(t.innerType);return e._zod.optin}var f_=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Dn(r.properties,l,zt(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Ka(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=zt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},p_=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>zt(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},m_=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=zt(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function pu(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=pu(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>pu(e,g,n));if(p.some((g,M)=>g!==_[M]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:h,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?oo:kl).source;return f}var mu=new WeakMap;function AS(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of mu.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=pu(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var g_=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=On(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=zt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let h of a)Dn(r.patternProperties,n_(h).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=zt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=mu.get(t);if(!u)u=[],mu.set(t,u),t.deferred.push(()=>AS(t));u.push(e)}r.additionalProperties=zt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Ka(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((h)=>typeof h==="string"||typeof h==="number");if(u.length>0)r.required=u.map(String)}},__=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},x_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},gu=Symbol();function v_(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),gu}var y_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=v_(r.defaultValue,e,t,n,i);if(o!==gu)n.default=o},b_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=v_(r.defaultValue,e,t,n,i);if(o!==gu)n._prefault=o},S_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},w_=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;zt(o,t,i);let a=t.seen.get(e);a.ref=o},M_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var _u=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var E_=new WeakSet([Object.prototype,Error.prototype]);function Ja(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var OS=(e,t)=>{Xf.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(E_.has(n))return;E_.add(n),Ja(n,"format",(i)=>(r)=>qf(i,r)),Ja(n,"flatten",(i)=>(r)=>jf(i,r)),Ja(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,no,2)}),Ja(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,no,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=ie("ZodError",OS,void 0,{Parent:Error});var T_=La(Mn),A_=Na(Mn),R_=Da(Mn),C_=Oa(Mn),I_=Kf(Mn),P_=Jf(Mn),L_=Qf(Mn),N_=ep(Mn),D_=tp(Mn),O_=np(Mn),U_=ip(Mn),F_=rp(Mn);function FS(){if(!xn.localeError)wn(Jl())}function ec(){if(!xn.memoizer)wn({memoizer:ig()})}var Lt=ie("ZodType",(e,t)=>(FS(),Ct.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Sn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ci(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Dw(e,t))},superRefine(e,t){return this.check(Ow(e,t))},overwrite(e){return this.check(er(e))},optional(){return B_(this)},exactOptional(){return bw(this)},nullable(){return G_(this)},nullish(){return B_(G_(this))},nonoptional(e){return Aw(this,e)},array(){return wt(this)},or(e){return Z_([this,e])},and(e){return _w(this,e)},transform(e){return H_(this,yw(e))},default(e){return Mw(this,e)},prefault(e){return Tw(this,e)},catch(e){return Cw(this,e)},pipe(e){return H_(this,e)},readonly(){return Lw(this)},describe(e){let t=this.clone();return Or.add(t,{description:e}),t},meta(...e){if(e.length===0)return Or.get(this);let t=this.clone();return Or.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Ia(this,"~standard",{...Wl(this),jsonSchema:{input:mo(this,"input"),output:mo(this,"output")}})},set "~standard"(e){Ni(this,"~standard",e)},parse:function e(t,n){return T_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await A_(this,t,n,{callee:e})},safeParse(e,t){return R_(this,e,t)},async safeParseAsync(e,t){return C_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ni(this,"spa",e)},validate(e,t){return Ol(this,e,t)},validateAsync(e,t){return Ul(this,e,t)},encode:function e(t,n){return I_(this,t,n,{callee:e})},decode:function e(t,n){return P_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await L_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await N_(this,t,n,{callee:e})},safeEncode(e,t){return D_(this,e,t)},safeDecode(e,t){return O_(this,e,t)},async safeEncodeAsync(e,t){return U_(this,e,t)},async safeDecodeAsync(e,t){return F_(this,e,t)},toJSONSchema(e){return Xg(this,{})(e)},get description(){return Or.get(this)?.description},get _def(){return this._zod.def}}),V_=ie("_ZodString",(e,t)=>{Ba.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>i_(e,n,i,r)},Gf({format:(e)=>On(e).format??null,minLength:(e)=>On(e).minimum??null,maxLength:(e)=>On(e).maximum??null},{regex(...e){return this.check(Ql(...e))},includes(...e){return this.check(nu(...e))},startsWith(...e){return this.check(iu(...e))},endsWith(...e){return this.check(ru(...e))},min(...e){return this.check(as(...e))},max(...e){return this.check(qa(...e))},length(...e){return this.check(Ya(...e))},nonempty(...e){return this.check(as(1,...e))},lowercase(e){return this.check(eu(e))},uppercase(e){return this.check(tu(e))},trim(){return this.check(ou())},normalize(...e){return this.check(su(...e))},toLowerCase(){return this.check(au())},toUpperCase(){return this.check(cu())},slugify(){return this.check(lu())}})),zS=ie("ZodString",(e,t)=>{Ba.init(e,t),V_.init(e,t)},{email(e){return this.check(cg(VS,e))},url(e){return this.check(pg(WS,e))},jwt(e){return this.check(Cg(ow,e))},emoji(e){return this.check(mg(ZS,e))},guid(e){return this.check(lg($S,e))},uuid(e){return this.check(ug(Qa,e))},uuidv4(e){return this.check(hg(Qa,e))},uuidv6(e){return this.check(dg(Qa,e))},uuidv7(e){return this.check(fg(Qa,e))},nanoid(e){return this.check(gg(XS,e))},cuid(e){return this.check(_g(jS,e))},cuid2(e){return this.check(xg(qS,e))},ulid(e){return this.check(vg(YS,e))},base64(e){return this.check(Tg(iw,e))},base64url(e){return this.check(Ag(rw,e))},xid(e){return this.check(yg(KS,e))},ksuid(e){return this.check(bg(JS,e))},ipv4(e){return this.check(Sg(QS,e))},ipv6(e){return this.check(wg(ew,e))},cidrv4(e){return this.check(Mg(tw,e))},cidrv6(e){return this.check(Eg(nw,e))},e164(e){return this.check(Rg(sw,e))},datetime(e){return this.check(Ig(kS,e))},date(e){return this.check(Pg(BS,e))},time(e){return this.check(Lg(GS,e))},duration(e){return this.check(Ng(HS,e))}});function Fe(e){return ag(zS,e)}var Nt=ie("ZodStringFormat",(e,t)=>{Tt.init(e,t),V_.init(e,t)}),kS=ie("ZodISODateTime",(e,t)=>{gm.init(e,t),Nt.init(e,t)}),BS=ie("ZodISODate",(e,t)=>{_m.init(e,t),Nt.init(e,t)}),GS=ie("ZodISOTime",(e,t)=>{xm.init(e,t),Nt.init(e,t)}),HS=ie("ZodISODuration",(e,t)=>{vm.init(e,t),Nt.init(e,t)}),VS=ie("ZodEmail",(e,t)=>{sm.init(e,t),Nt.init(e,t)});var $S=ie("ZodGUID",(e,t)=>{im.init(e,t),Nt.init(e,t)});var Qa=ie("ZodUUID",(e,t)=>{rm.init(e,t),Nt.init(e,t)});var WS=ie("ZodURL",(e,t)=>{cm.init(e,t),Nt.init(e,t)});var ZS=ie("ZodEmoji",(e,t)=>{lm.init(e,t),Nt.init(e,t)});var XS=ie("ZodNanoID",(e,t)=>{um.init(e,t),Nt.init(e,t)});var jS=ie("ZodCUID",(e,t)=>{hm.init(e,t),Nt.init(e,t)});var qS=ie("ZodCUID2",(e,t)=>{dm.init(e,t),Nt.init(e,t)});var YS=ie("ZodULID",(e,t)=>{fm.init(e,t),Nt.init(e,t)});var KS=ie("ZodXID",(e,t)=>{pm.init(e,t),Nt.init(e,t)});var JS=ie("ZodKSUID",(e,t)=>{mm.init(e,t),Nt.init(e,t)});var QS=ie("ZodIPv4",(e,t)=>{ym.init(e,t),Nt.init(e,t)});var ew=ie("ZodIPv6",(e,t)=>{Sm.init(e,t),Nt.init(e,t)});var tw=ie("ZodCIDRv4",(e,t)=>{wm.init(e,t),Nt.init(e,t)});var nw=ie("ZodCIDRv6",(e,t)=>{Mm.init(e,t),Nt.init(e,t)});var iw=ie("ZodBase64",(e,t)=>{Tm.init(e,t),Nt.init(e,t)});var rw=ie("ZodBase64URL",(e,t)=>{Am.init(e,t),Nt.init(e,t)});var sw=ie("ZodE164",(e,t)=>{Rm.init(e,t),Nt.init(e,t)});var ow=ie("ZodJWT",(e,t)=>{Cm.init(e,t),Nt.init(e,t)});var $_=ie("ZodNumber",(e,t)=>{Xl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>r_(e,n,i,r),e.isFinite=!0},Gf({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=On(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=On(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=On(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>On(e).format??null},{gt(e,t){return this.check(Xa(e,t))},gte(e,t){return this.check(fo(e,t))},min(e,t){return this.check(fo(e,t))},lt(e,t){return this.check(Za(e,t))},lte(e,t){return this.check(ho(e,t))},max(e,t){return this.check(ho(e,t))},int(e){return this.check(z_(e))},safe(e){return this.check(z_(e))},positive(e){return this.check(Xa(0,e))},nonnegative(e){return this.check(fo(0,e))},negative(e){return this.check(Za(0,e))},nonpositive(e){return this.check(ho(0,e))},multipleOf(e,t){return this.check(ja(e,t))},step(e,t){return this.check(ja(e,t))},finite(){return this}}));function vt(e){return Dg($_,e)}var aw=ie("ZodNumberFormat",(e,t)=>{Im.init(e,t),$_.init(e,t)});function z_(e){return Og(aw,e)}var cw=ie("ZodBoolean",(e,t)=>{Pm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s_(e,n,i,r)});function go(e){return Ug(cw,e)}var lw=ie("ZodUnknown",(e,t)=>{Lm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a_(e,n,i,r)});function Ur(){return Fg(lw)}var uw=ie("ZodNever",(e,t)=>{Nm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o_(e,n,i,r)});function hw(e){return zg(uw,e)}var dw=ie("ZodArray",(e,t)=>{ec(),Dm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d_(e,n,i,r),e.element=t.element},{min(e,t){return this.check(as(e,t))},nonempty(e){return this.check(as(1,e))},max(e,t){return this.check(qa(e,t))},length(e,t){return this.check(Ya(e,t))},unwrap(){return this.element}});function wt(e,t){return kg(dw,e,t)}var fw=ie("ZodObject",(e,t)=>{ec(),Fm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f_(e,n,i,r),Wb(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return pn(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Sn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Sn(this._zod.def,{catchall:Ur()}))},loose(){return this.clone(Sn(this._zod.def,{catchall:Ur()}))},strict(){return this.clone(Sn(this._zod.def,{catchall:hw()}))},strip(){return this.clone(Sn(this._zod.def,{catchall:void 0}))},extend(e){return Fb(this,e)},safeExtend(e){return zb(this,e)},merge(e){return kb(this,e)},pick(e){return Ob(this,e)},omit(e){return Ub(this,e)},partial(...e){return Ff(X_,this,e[0])},exactPartial(...e){return Ff(j_,this,e[0],"exactPartial")},required(...e){return Bb(q_,this,e[0])}});function qe(e,t){let n={type:"object",shape:e??{},...De(t)};return new fw(n)}var W_=ie("ZodUnion",(e,t)=>{jl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p_(e,n,i,r),e.options=t.options});function Z_(e,t){return new W_({type:"union",options:e,...De(t)})}var pw=ie("ZodDiscriminatedUnion",(e,t)=>{W_.init(e,t),zm.init(e,t)});function mw(e,t,n){return new pw({type:"union",options:t,discriminator:e,...De(n)})}var gw=ie("ZodIntersection",(e,t)=>{km.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m_(e,n,i,r)});function _w(e,t){return new gw({type:"intersection",left:e,right:t})}var k_=ie("ZodRecord",(e,t)=>{ec(),Bm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>g_(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function tc(e,t,n){if(!t||!t._zod)return new k_({type:"record",keyType:Fe(),valueType:e,...De(t)});return new k_({type:"record",keyType:e,valueType:t,...De(n)})}var vu=ie("ZodEnum",(e,t)=>{Gm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>c_(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new vu({...t,checks:[],...De(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new vu({...t,checks:[],...De(r),entries:s})}});function pn(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new vu({type:"enum",entries:n,...De(t)})}var xw=ie("ZodLiteral",(e,t)=>{Hm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>l_(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function jt(e,t){return new xw({type:"literal",values:Array.isArray(e)?e:[e],...De(t)})}var vw=ie("ZodTransform",(e,t)=>{ec(),Vm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h_(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new so(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Dr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Dr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function yw(e){return new vw({type:"transform",transform:e})}var X_=ie("ZodOptional",(e,t)=>{ql.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_u(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function B_(e){return new X_({type:"optional",innerType:e})}var j_=ie("ZodExactOptional",(e,t)=>{$m.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_u(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function bw(e){return new j_({type:"optional",innerType:e})}var Sw=ie("ZodNullable",(e,t)=>{Wm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>__(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function G_(e){return new Sw({type:"nullable",innerType:e})}var ww=ie("ZodDefault",(e,t)=>{Zm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>y_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mw(e,t){return new ww({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Rl(t)}})}var Ew=ie("ZodPrefault",(e,t)=>{Xm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>b_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Tw(e,t){return new Ew({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Rl(t)}})}var q_=ie("ZodNonOptional",(e,t)=>{jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Aw(e,t){return new q_({type:"nonoptional",innerType:e,...De(t)})}var Rw=ie("ZodCatch",(e,t)=>{qm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>S_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cw(e,t){return new Rw({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Hf(t)})}var Iw=ie("ZodPipe",(e,t)=>{Ym.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w_(e,n,i,r),e.in=t.in,e.out=t.out});function H_(e,t){return new Iw({type:"pipe",in:e,out:t})}var Pw=ie("ZodReadonly",(e,t)=>{Km.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Lw(e){return new Pw({type:"readonly",innerType:e})}var Nw=ie("ZodCustom",(e,t)=>{Jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u_(e,n,i,r)});function Dw(e,t={}){return Bg(Nw,e,t)}function Ow(e,t){return Gg(e,t)}var nc={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var Y_;(function(e){})(Y_||(Y_={}));var K_=["neutral","dark","light"];var bu=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),J_=Object.freeze({neutral:bu("neutral",[170,177,188]),dark:bu("dark",[26,26,26]),light:bu("light",[223,227,232])});var mL=J_.neutral.rgb,gL=J_.neutral.hex;/*!
+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Zg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;Zg(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Xg=new Set(["type","properties","required","additionalProperties"]),$g=["oneOf","anyOf"];function Wg(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function hu(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!Xg.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??Wg(l);if(u===null||u===void 0)continue;if(!a.some((h)=>JSON.stringify(h)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:hu(a)??{allOf:a};Dn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=Wg(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function ES(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Xg)if(r in e)return;let n=t.filter((r)=>$g.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=hu(t);else{let r=n[0],s=$g.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>hu([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,_o(e,i)}function pu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},h=c.ref;if(c.ref=null,h){i(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else _o(l,m);if(_o(l,u),a._zod.parent===h)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let d=a._zod.parent;if(d&&d!==h){i(d);let f=e.seen.get(d);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Zg(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let h=a.get(u);if(h)h.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])ES(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}_o(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Dn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:xo(t,"input",e.processors),output:xo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return fn(i.element,n);if(i.type==="set")return fn(i.valueType,n);if(i.type==="lazy")return fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return fn(i.innerType,n);if(i.type==="intersection")return fn(i.left,n)||fn(i.right,n);if(i.type==="record"||i.type==="map")return fn(i.keyType,n)||fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fn(i.in,n)||fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(fn(r,n))return!0;if(i.rest&&fn(i.rest,n))return!0;return!1}return!1}var jg=(e,t={})=>(n)=>{let i=du({...n,processors:t});return zt(e,i),fu(i,e),pu(i,e)},xo=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=du({...r??{},target:s,io:t,processors:n});return zt(e,o),fu(o,e),pu(o,e)};var ls=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},us=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},qg=(e,t)=>{ls(e,"minimum",t),us(e,"maximum",t)},Qg=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},e_=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},t_=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},n_=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Yg=(e,t)=>ls(e,"minimum",t.minimum),Kg=(e,t)=>us(e,"maximum",t.maximum),Jg=(e)=>(t,n)=>{n_(t,n.format);let[i,r]=e[n.format];ls(t,"minimum",i),us(t,"maximum",r)},TS={greater_than:(e,t)=>ls(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>us(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Qg(e,t.value),number_format:Jg(Ra),bigint_format:Jg(Pl),min_length:Yg,max_length:Kg,length_equals:(e,t)=>qg(e,t.length),min_size:Yg,max_size:Kg,size_equals:(e,t)=>qg(e,t.size),string_format:(e,t)=>{if(n_(e,t.format),t.pattern)e_(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>t_(e,t.mime)};function On(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)TS[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)ls(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)ls(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)us(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)us(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)Qg(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)t_(t,r.mime);for(let s of r.patterns??[])e_(t,s);return t}var AS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},RS=new Map([[Xl,bp],[Va,Sp]]),i_=(e)=>RS.get(e)??e,r_=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=On(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=AS[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let h=[...c].map(i_);if(h.length===1)r.pattern=h[0].source;else if(h.length>1)r.allOf=[...h.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},s_=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=On(e);r.type=u?"integer":"number";let h=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(d)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else Oi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},o_=(e,t,n,i)=>{n.type="boolean"};var a_=(e,t,n,i)=>{n.not={}};var c_=(e,t,n,i)=>{};var l_=(e,t,n,i)=>{let r=e._zod.def,s=ro(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},u_=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Oi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Oi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var h_=(e,t,n,i)=>{Oi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var d_=(e,t,n,i)=>{Oi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var f_=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=On(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=zt(s.element,t,{...i,path:[...i.path,"items"]})};function Qa(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Qa(t.out);if(t.type==="catch")return Qa(t.innerType);return e._zod.optin}var p_=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Oi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Dn(r.properties,l,zt(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Qa(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=zt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},m_=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>zt(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},g_=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=zt(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function mu(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=mu(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>mu(e,g,n));if(p.some((g,M)=>g!==_[M]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:h,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?lo:Bl).source;return f}var gu=new WeakMap;function CS(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of gu.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=mu(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var __=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=On(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=zt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let h of a)Dn(r.patternProperties,i_(h).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=zt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=gu.get(t);if(!u)u=[],gu.set(t,u),t.deferred.push(()=>CS(t));u.push(e)}r.additionalProperties=zt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Qa(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((h)=>typeof h==="string"||typeof h==="number");if(u.length>0)r.required=u.map(String)}},x_=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},v_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},_u=Symbol();function y_(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Oi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),_u}var b_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=y_(r.defaultValue,e,t,n,i);if(o!==_u)n.default=o},S_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=y_(r.defaultValue,e,t,n,i);if(o!==_u)n._prefault=o},w_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Oi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},M_=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;zt(o,t,i);let a=t.seen.get(e);a.ref=o},E_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var xu=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var T_=new WeakSet([Object.prototype,Error.prototype]);function ec(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var FS=(e,t)=>{jf.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(T_.has(n))return;T_.add(n),ec(n,"format",(i)=>(r)=>Yf(i,r)),ec(n,"flatten",(i)=>(r)=>qf(i,r)),ec(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,so,2)}),ec(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,so,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=ie("ZodError",FS,void 0,{Parent:Error});var A_=Da(Mn),R_=Oa(Mn),C_=Ua(Mn),I_=Fa(Mn),P_=Jf(Mn),L_=Qf(Mn),N_=ep(Mn),D_=tp(Mn),O_=np(Mn),U_=ip(Mn),F_=rp(Mn),z_=sp(Mn);function kS(){if(!xn.localeError)wn(Ql())}function nc(){if(!xn.memoizer)wn({memoizer:rg()})}var Lt=ie("ZodType",(e,t)=>(kS(),Ct.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Sn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ci(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Uw(e,t))},superRefine(e,t){return this.check(Fw(e,t))},overwrite(e){return this.check(tr(e))},optional(){return G_(this)},exactOptional(){return ww(this)},nullable(){return H_(this)},nullish(){return G_(H_(this))},nonoptional(e){return Cw(this,e)},array(){return wt(this)},or(e){return X_([this,e])},and(e){return vw(this,e)},transform(e){return V_(this,Sw(e))},default(e){return Tw(this,e)},prefault(e){return Rw(this,e)},catch(e){return Pw(this,e)},pipe(e){return V_(this,e)},readonly(){return Dw(this)},describe(e){let t=this.clone();return Ur.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ur.get(this);let t=this.clone();return Ur.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return La(this,"~standard",{...Zl(this),jsonSchema:{input:xo(this,"input"),output:xo(this,"output")}})},set "~standard"(e){Di(this,"~standard",e)},parse:function e(t,n){return A_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await R_(this,t,n,{callee:e})},safeParse(e,t){return C_(this,e,t)},async safeParseAsync(e,t){return I_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Di(this,"spa",e)},validate(e,t){return Ul(this,e,t)},validateAsync(e,t){return Fl(this,e,t)},encode:function e(t,n){return P_(this,t,n,{callee:e})},decode:function e(t,n){return L_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await N_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await D_(this,t,n,{callee:e})},safeEncode(e,t){return O_(this,e,t)},safeDecode(e,t){return U_(this,e,t)},async safeEncodeAsync(e,t){return F_(this,e,t)},async safeDecodeAsync(e,t){return z_(this,e,t)},toJSONSchema(e){return jg(this,{})(e)},get description(){return Ur.get(this)?.description},get _def(){return this._zod.def}}),$_=ie("_ZodString",(e,t)=>{Ha.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>r_(e,n,i,r)},Hf({format:(e)=>On(e).format??null,minLength:(e)=>On(e).minimum??null,maxLength:(e)=>On(e).maximum??null},{regex(...e){return this.check(eu(...e))},includes(...e){return this.check(iu(...e))},startsWith(...e){return this.check(ru(...e))},endsWith(...e){return this.check(su(...e))},min(...e){return this.check(cs(...e))},max(...e){return this.check(Ka(...e))},length(...e){return this.check(Ja(...e))},nonempty(...e){return this.check(cs(1,...e))},lowercase(e){return this.check(tu(e))},uppercase(e){return this.check(nu(e))},trim(){return this.check(au())},normalize(...e){return this.check(ou(...e))},toLowerCase(){return this.check(cu())},toUpperCase(){return this.check(lu())},slugify(){return this.check(uu())}})),BS=ie("ZodString",(e,t)=>{Ha.init(e,t),$_.init(e,t)},{email(e){return this.check(lg(WS,e))},url(e){return this.check(mg(XS,e))},jwt(e){return this.check(Ig(cw,e))},emoji(e){return this.check(gg(jS,e))},guid(e){return this.check(ug(ZS,e))},uuid(e){return this.check(hg(tc,e))},uuidv4(e){return this.check(dg(tc,e))},uuidv6(e){return this.check(fg(tc,e))},uuidv7(e){return this.check(pg(tc,e))},nanoid(e){return this.check(_g(qS,e))},cuid(e){return this.check(xg(YS,e))},cuid2(e){return this.check(vg(KS,e))},ulid(e){return this.check(yg(JS,e))},base64(e){return this.check(Ag(sw,e))},base64url(e){return this.check(Rg(ow,e))},xid(e){return this.check(bg(QS,e))},ksuid(e){return this.check(Sg(ew,e))},ipv4(e){return this.check(wg(tw,e))},ipv6(e){return this.check(Mg(nw,e))},cidrv4(e){return this.check(Eg(iw,e))},cidrv6(e){return this.check(Tg(rw,e))},e164(e){return this.check(Cg(aw,e))},datetime(e){return this.check(Pg(GS,e))},date(e){return this.check(Lg(HS,e))},time(e){return this.check(Ng(VS,e))},duration(e){return this.check(Dg($S,e))}});function Fe(e){return cg(BS,e)}var Nt=ie("ZodStringFormat",(e,t)=>{Tt.init(e,t),$_.init(e,t)}),GS=ie("ZodISODateTime",(e,t)=>{_m.init(e,t),Nt.init(e,t)}),HS=ie("ZodISODate",(e,t)=>{xm.init(e,t),Nt.init(e,t)}),VS=ie("ZodISOTime",(e,t)=>{vm.init(e,t),Nt.init(e,t)}),$S=ie("ZodISODuration",(e,t)=>{ym.init(e,t),Nt.init(e,t)}),WS=ie("ZodEmail",(e,t)=>{om.init(e,t),Nt.init(e,t)});var ZS=ie("ZodGUID",(e,t)=>{rm.init(e,t),Nt.init(e,t)});var tc=ie("ZodUUID",(e,t)=>{sm.init(e,t),Nt.init(e,t)});var XS=ie("ZodURL",(e,t)=>{lm.init(e,t),Nt.init(e,t)});var jS=ie("ZodEmoji",(e,t)=>{um.init(e,t),Nt.init(e,t)});var qS=ie("ZodNanoID",(e,t)=>{hm.init(e,t),Nt.init(e,t)});var YS=ie("ZodCUID",(e,t)=>{dm.init(e,t),Nt.init(e,t)});var KS=ie("ZodCUID2",(e,t)=>{fm.init(e,t),Nt.init(e,t)});var JS=ie("ZodULID",(e,t)=>{pm.init(e,t),Nt.init(e,t)});var QS=ie("ZodXID",(e,t)=>{mm.init(e,t),Nt.init(e,t)});var ew=ie("ZodKSUID",(e,t)=>{gm.init(e,t),Nt.init(e,t)});var tw=ie("ZodIPv4",(e,t)=>{bm.init(e,t),Nt.init(e,t)});var nw=ie("ZodIPv6",(e,t)=>{wm.init(e,t),Nt.init(e,t)});var iw=ie("ZodCIDRv4",(e,t)=>{Mm.init(e,t),Nt.init(e,t)});var rw=ie("ZodCIDRv6",(e,t)=>{Em.init(e,t),Nt.init(e,t)});var sw=ie("ZodBase64",(e,t)=>{Am.init(e,t),Nt.init(e,t)});var ow=ie("ZodBase64URL",(e,t)=>{Rm.init(e,t),Nt.init(e,t)});var aw=ie("ZodE164",(e,t)=>{Cm.init(e,t),Nt.init(e,t)});var cw=ie("ZodJWT",(e,t)=>{Im.init(e,t),Nt.init(e,t)});var W_=ie("ZodNumber",(e,t)=>{jl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s_(e,n,i,r),e.isFinite=!0},Hf({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=On(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=On(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=On(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>On(e).format??null},{gt(e,t){return this.check(qa(e,t))},gte(e,t){return this.check(go(e,t))},min(e,t){return this.check(go(e,t))},lt(e,t){return this.check(ja(e,t))},lte(e,t){return this.check(mo(e,t))},max(e,t){return this.check(mo(e,t))},int(e){return this.check(k_(e))},safe(e){return this.check(k_(e))},positive(e){return this.check(qa(0,e))},nonnegative(e){return this.check(go(0,e))},negative(e){return this.check(ja(0,e))},nonpositive(e){return this.check(mo(0,e))},multipleOf(e,t){return this.check(Ya(e,t))},step(e,t){return this.check(Ya(e,t))},finite(){return this}}));function vt(e){return Og(W_,e)}var lw=ie("ZodNumberFormat",(e,t)=>{Pm.init(e,t),W_.init(e,t)});function k_(e){return Ug(lw,e)}var uw=ie("ZodBoolean",(e,t)=>{Lm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o_(e,n,i,r)});function vo(e){return Fg(uw,e)}var hw=ie("ZodUnknown",(e,t)=>{Nm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>c_(e,n,i,r)});function Fr(){return zg(hw)}var dw=ie("ZodNever",(e,t)=>{Dm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a_(e,n,i,r)});function fw(e){return kg(dw,e)}var pw=ie("ZodArray",(e,t)=>{nc(),Om.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f_(e,n,i,r),e.element=t.element},{min(e,t){return this.check(cs(e,t))},nonempty(e){return this.check(cs(1,e))},max(e,t){return this.check(Ka(e,t))},length(e,t){return this.check(Ja(e,t))},unwrap(){return this.element}});function wt(e,t){return Bg(pw,e,t)}var mw=ie("ZodObject",(e,t)=>{nc(),zm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p_(e,n,i,r),Xb(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return pn(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Sn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Sn(this._zod.def,{catchall:Fr()}))},loose(){return this.clone(Sn(this._zod.def,{catchall:Fr()}))},strict(){return this.clone(Sn(this._zod.def,{catchall:fw()}))},strip(){return this.clone(Sn(this._zod.def,{catchall:void 0}))},extend(e){return kb(this,e)},safeExtend(e){return Bb(this,e)},merge(e){return Gb(this,e)},pick(e){return Fb(this,e)},omit(e){return zb(this,e)},partial(...e){return zf(j_,this,e[0])},exactPartial(...e){return zf(q_,this,e[0],"exactPartial")},required(...e){return Hb(Y_,this,e[0])}});function qe(e,t){let n={type:"object",shape:e??{},...De(t)};return new mw(n)}var Z_=ie("ZodUnion",(e,t)=>{ql.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m_(e,n,i,r),e.options=t.options});function X_(e,t){return new Z_({type:"union",options:e,...De(t)})}var gw=ie("ZodDiscriminatedUnion",(e,t)=>{Z_.init(e,t),km.init(e,t)});function _w(e,t,n){return new gw({type:"union",options:t,discriminator:e,...De(n)})}var xw=ie("ZodIntersection",(e,t)=>{Bm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>g_(e,n,i,r)});function vw(e,t){return new xw({type:"intersection",left:e,right:t})}var B_=ie("ZodRecord",(e,t)=>{nc(),Gm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>__(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ic(e,t,n){if(!t||!t._zod)return new B_({type:"record",keyType:Fe(),valueType:e,...De(t)});return new B_({type:"record",keyType:e,valueType:t,...De(n)})}var yu=ie("ZodEnum",(e,t)=>{Hm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>l_(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new yu({...t,checks:[],...De(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new yu({...t,checks:[],...De(r),entries:s})}});function pn(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new yu({type:"enum",entries:n,...De(t)})}var yw=ie("ZodLiteral",(e,t)=>{Vm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u_(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function jt(e,t){return new yw({type:"literal",values:Array.isArray(e)?e:[e],...De(t)})}var bw=ie("ZodTransform",(e,t)=>{nc(),$m.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d_(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new co(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Or(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Or(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function Sw(e){return new bw({type:"transform",transform:e})}var j_=ie("ZodOptional",(e,t)=>{Yl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function G_(e){return new j_({type:"optional",innerType:e})}var q_=ie("ZodExactOptional",(e,t)=>{Wm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ww(e){return new q_({type:"optional",innerType:e})}var Mw=ie("ZodNullable",(e,t)=>{Zm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function H_(e){return new Mw({type:"nullable",innerType:e})}var Ew=ie("ZodDefault",(e,t)=>{Xm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>b_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Tw(e,t){return new Ew({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Cl(t)}})}var Aw=ie("ZodPrefault",(e,t)=>{jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>S_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Rw(e,t){return new Aw({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Cl(t)}})}var Y_=ie("ZodNonOptional",(e,t)=>{qm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Cw(e,t){return new Y_({type:"nonoptional",innerType:e,...De(t)})}var Iw=ie("ZodCatch",(e,t)=>{Ym.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Pw(e,t){return new Iw({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Vf(t)})}var Lw=ie("ZodPipe",(e,t)=>{Km.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M_(e,n,i,r),e.in=t.in,e.out=t.out});function V_(e,t){return new Lw({type:"pipe",in:e,out:t})}var Nw=ie("ZodReadonly",(e,t)=>{Jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>E_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Dw(e){return new Nw({type:"readonly",innerType:e})}var Ow=ie("ZodCustom",(e,t)=>{Qm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h_(e,n,i,r)});function Uw(e,t={}){return Gg(Ow,e,t)}function Fw(e,t){return Hg(e,t)}var rc={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var K_;(function(e){})(K_||(K_={}));var J_=["neutral","dark","light"];var Su=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),Q_=Object.freeze({neutral:Su("neutral",[170,177,188]),dark:Su("dark",[26,26,26]),light:Su("light",[223,227,232])});var _L=Q_.neutral.rgb,xL=Q_.neutral.hex;/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
-*/var Dt=Uint8Array,En=Uint16Array,Lu=Int32Array,ic=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),rc=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Tu=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s0=function(e,t){var n=new En(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Lu(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},o0=s0(ic,2),{b:a0,r:Au}=o0;a0[28]=258,Au[258]=28;var c0=s0(rc,0),{b:Uw,r:Q_}=c0,Ru=new En(32768);for(tt=0;tt<32768;++tt)di=(tt&43690)>>1|(tt&21845)<<1,di=(di&52428)>>2|(di&13107)<<2,di=(di&61680)>>4|(di&3855)<<4,Ru[tt]=((di&65280)>>8|(di&255)<<8)>>1;var di,tt,pi=function(e,t,n){var i=e.length,r=0,s=new En(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new En(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new En(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],h=o[e[r]-1]++<<u;for(var d=h|(1<<u)-1;h<=d;++h)a[Ru[h]>>c]=l}}else{a=new En(i);for(r=0;r<i;++r)if(e[r])a[r]=Ru[o[e[r]-1]++]>>15-e[r]}return a},tr=new Dt(288);for(tt=0;tt<144;++tt)tr[tt]=8;var tt;for(tt=144;tt<256;++tt)tr[tt]=9;var tt;for(tt=256;tt<280;++tt)tr[tt]=7;var tt;for(tt=280;tt<288;++tt)tr[tt]=8;var tt,vo=new Dt(32);for(tt=0;tt<32;++tt)vo[tt]=5;var tt,Fw=pi(tr,9,0),zw=pi(tr,9,1),kw=pi(vo,5,0),Bw=pi(vo,5,1),Su=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},$n=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},wu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Nu=function(e){return(e+7)/8|0},yo=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var Gw=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],mn=function(e,t,n){var i=Error(t||Gw[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,mn);if(!n)throw i;return i},Hw=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(ae){var ke=n.length;if(ae>ke){var Ce=new Dt(Math.max(ke*2,ae));Ce.set(n),n=Ce}},u=t.f||0,h=t.p||0,d=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=$n(e,h,1);var M=$n(e,h+1,3);if(h+=3,!M){var T=Nu(h)+4,v=e[T-4]|e[T-3]<<8,S=T+v;if(S>r){if(c)mn(0);break}if(a)l(d+v);n.set(e.subarray(T,S),d),t.b=d+=v,t.p=h=S*8,t.f=u;continue}else if(M==1)f=zw,m=Bw,_=9,p=5;else if(M==2){var E=$n(e,h,31)+257,R=$n(e,h+10,15)+4,x=E+$n(e,h+5,31)+1;h+=14;var w=new Dt(x),H=new Dt(19);for(var C=0;C<R;++C)H[Tu[C]]=$n(e,h+C*3,7);h+=R*3;var N=Su(H),ee=(1<<N)-1,P=pi(H,N,1);for(var C=0;C<x;){var Z=P[$n(e,h,ee)];h+=Z&15;var T=Z>>4;if(T<16)w[C++]=T;else{var G=0,k=0;if(T==16)k=3+$n(e,h,3),h+=2,G=w[C-1];else if(T==17)k=3+$n(e,h,7),h+=3;else if(T==18)k=11+$n(e,h,127),h+=7;while(k--)w[C++]=G}}var W=w.subarray(0,E),B=w.subarray(E);_=Su(W),p=Su(B),f=pi(W,_,1),m=pi(B,p,1)}else mn(1);if(h>g){if(c)mn(0);break}}if(a)l(d+131072);var Y=(1<<_)-1,K=(1<<p)-1,ge=h;for(;;ge=h){var G=f[wu(e,h)&Y],de=G>>4;if(h+=G&15,h>g){if(c)mn(0);break}if(!G)mn(2);if(de<256)n[d++]=de;else if(de==256){ge=h,f=null;break}else{var fe=de-254;if(de>264){var C=de-257,he=ic[C];fe=$n(e,h,(1<<he)-1)+a0[C],h+=he}var I=m[wu(e,h)&K],V=I>>4;if(!I)mn(3);h+=I&15;var B=Uw[V];if(V>3){var he=rc[V];B+=wu(e,h)&(1<<he)-1,h+=he}if(h>g){if(c)mn(0);break}if(a)l(d+131072);var q=d+fe;if(d<B){var se=s-B,ce=Math.min(B,q);if(se+d<0)mn(3);for(;d<ce;++d)n[d]=i[se+d]}for(;d<q;++d)n[d]=n[d-B]}}if(t.l=f,t.p=ge,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?yo(n,0,d):n.subarray(0,d)},Oi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},_o=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Mu=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:u0,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(S,E){return S.f-E.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,h=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var d=s[0].s;for(var i=1;i<r;++i)if(s[i].s>d)d=s[i].s;var f=new En(d+1),m=Cu(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(E,R){return f[R.s]-f[E.s]||E.f-R.f});for(;i<r;++i){var M=s[i].s;if(f[M]>t)_+=g-(1<<m-f[M]),f[M]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var v=s[i].s;if(f[v]==t)--f[v],++_}m=t}return{t:new Dt(f),l:m}},Cu=function(e,t,n){return e.s==-1?Math.max(Cu(e.l,t,n+1),Cu(e.r,t,n+1)):t[e.s]=n},e0=function(e){var t=e.length;while(t&&!e[--t]);var n=new En(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},xo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},l0=function(e,t,n){var i=n.length,r=Nu(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},t0=function(e,t,n,i,r,s,o,a,c,l,u){Oi(t,u++,n),++r[256];var h=Mu(r,15),{t:d,l:f}=h,m=Mu(s,15),{t:_,l:p}=m,g=e0(d),{c:M,n:T}=g,v=e0(_),{c:S,n:E}=v,R=new En(19);for(var x=0;x<M.length;++x)++R[M[x]&31];for(var x=0;x<S.length;++x)++R[S[x]&31];var w=Mu(R,7),{t:H,l:C}=w,N=19;for(;N>4&&!H[Tu[N-1]];--N);var ee=l+5<<3,P=xo(r,tr)+xo(s,vo)+o,Z=xo(r,d)+xo(s,_)+o+14+3*N+xo(R,H)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&ee<=P&&ee<=Z)return l0(t,u,e.subarray(c,c+l));var G,k,W,B;if(Oi(t,u,1+(Z<P)),u+=2,Z<P){G=pi(d,f,0),k=d,W=pi(_,p,0),B=_;var Y=pi(H,C,0);Oi(t,u,T-257),Oi(t,u+5,E-1),Oi(t,u+10,N-4),u+=14;for(var x=0;x<N;++x)Oi(t,u+3*x,H[Tu[x]]);u+=3*N;var K=[M,S];for(var ge=0;ge<2;++ge){var de=K[ge];for(var x=0;x<de.length;++x){var fe=de[x]&31;if(Oi(t,u,Y[fe]),u+=H[fe],fe>15)Oi(t,u,de[x]>>5&127),u+=de[x]>>12}}}else G=Fw,k=tr,W=kw,B=vo;for(var x=0;x<a;++x){var he=i[x];if(he>255){var fe=he>>18&31;if(_o(t,u,G[fe+257]),u+=k[fe+257],fe>7)Oi(t,u,he>>23&31),u+=ic[fe];var I=he&31;if(_o(t,u,W[I]),u+=B[I],I>3)_o(t,u,he>>5&8191),u+=rc[I]}else _o(t,u,G[he]),u+=k[he]}return _o(t,u,G[256]),u+k[256]},Vw=new Lu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),u0=new Dt(0),$w=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var h=Vw[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new En(32768),p=s.h||new En(m+1),g=Math.ceil(n/3),M=2*g,T=function(Ve){return(e[Ve]^e[Ve+1]<<g^e[Ve+2]<<M)&m},v=new Lu(25000),S=new En(288),E=new En(32),R=0,x=0,w=s.i||0,H=0,C=s.w||0,N=0;for(;w+2<o;++w){var ee=T(w),P=w&32767,Z=p[ee];if(_[P]=Z,p[ee]=P,C<=w){var G=o-w;if((R>7000||H>24576)&&(G>423||!l)){u=t0(e,c,0,v,S,E,x,H,N,w-N,u),H=R=x=0,N=w;for(var k=0;k<286;++k)S[k]=0;for(var k=0;k<30;++k)E[k]=0}var W=2,B=0,Y=f,K=P-Z&32767;if(G>2&&ee==T(w-K)){var ge=Math.min(d,G)-1,de=Math.min(32767,w),fe=Math.min(258,G);while(K<=de&&--Y&&P!=Z){if(e[w+W]==e[w+W-K]){var he=0;for(;he<fe&&e[w+he]==e[w+he-K];++he);if(he>W){if(W=he,B=K,he>ge)break;var I=Math.min(K,he-2),V=0;for(var k=0;k<I;++k){var q=w-K+k&32767,se=_[q],ce=q-se&32767;if(ce>V)V=ce,Z=q}}}P=Z,Z=_[P],K+=P-Z&32767}}if(B){v[H++]=268435456|Au[W]<<18|Q_[B];var ae=Au[W]&31,ke=Q_[B]&31;x+=ic[ae]+rc[ke],++S[257+ae],++E[ke],C=w+W,++R}else v[H++]=e[w],++S[e[w]]}}for(w=Math.max(w,C);w<o;++w)v[H++]=e[w],++S[e[w]];if(u=t0(e,c,l,v,S,E,x,H,N,w-N,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=w,s.w=C}else{for(var w=s.w||0;w<o+l;w+=65535){var Ce=w+65535;if(Ce>=o)c[u/8|0]=l,Ce=o;u=l0(c,u+1,e.subarray(w,Ce))}s.i=o}return yo(a,0,i+Nu(u)+r)},Ww=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Zw=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=Ww[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var Xw=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return $w(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},h0=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var fi=function(e,t){return e[t]|e[t+1]<<8},Wn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Eu=function(e,t){return Wn(e,t)+Wn(e,t+4)*4294967296},rn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function jw(e,t){return Xw(e,t||{},0,0)}function qw(e,t){return Hw(e,{i:2},t&&t.out,t&&t.dictionary)}var d0=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=h0(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],d0(s,o,n,i)}},n0=typeof TextEncoder<"u"&&new TextEncoder,Iu=typeof TextDecoder<"u"&&new TextDecoder,Yw=0;try{Iu.decode(u0,{stream:!0}),Yw=1}catch(e){}var Kw=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return{s:t,r:yo(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function i0(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(n0)return n0.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return yo(s,0,o)}function Jw(e,t){if(t){var n="";for(var i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}else if(Iu)return Iu.decode(e);else{var r=Kw(e),{s,r:n}=r;if(n.length)mn(8);return s}}var Qw=function(e,t){return t+30+fi(e,t+26)+fi(e,t+28)},eM=function(e,t,n){var i=fi(e,t+28),r=Jw(e.subarray(t+46,t+46+i),!(fi(e,t+8)&2048)),s=t+46+i,o=Wn(e,t+20),a=n&&o==4294967295?tM(e,s):[o,Wn(e,t+24),Wn(e,t+42)],c=a[0],l=a[1],u=a[2];return[fi(e,t+10),c,l,r,s+fi(e,t+30)+fi(e,t+32),u]},tM=function(e,t){for(;fi(e,t)!=1;t+=4+fi(e,t+2));return[Eu(e,t+12),Eu(e,t+4),Eu(e,t+20)]},Pu=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)mn(9);t+=i+4}return t},r0=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=Pu(l);if(rn(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var d=new Date(n.mtime==null?Date.now():n.mtime),f=d.getFullYear()-1980;if(f<0||f>119)mn(10);if(rn(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)rn(e,t,n.crc),rn(e,t+4,s<0?-s-2:s),rn(e,t+8,n.size);if(rn(e,t+12,c),rn(e,t+14,h),t+=16,o!=null)rn(e,t,u),rn(e,t+6,n.attrs),rn(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;rn(e,t,+m),rn(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},nM=function(e,t,n,i,r){rn(e,t,101010256),rn(e,t+8,n),rn(e,t+10,n),rn(e,t+12,i),rn(e,t+16,r)};function f0(e,t){if(!t)t={};var n={},i=[];d0(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,h=i0(o),d=h.length,f=l.comment,m=f&&i0(f),_=m&&m.length,p=Pu(l.extra);if(d>65535)mn(11);var g=u?jw(c,l):c,M=g.length,T=Zw();T.p(c),i.push(h0(l,{size:c.length,crc:T.d(),c:g,f:h,m,u:d!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+d+p+M,s+=76+2*(d+p)+(_||0)+M}var v=new Dt(s+22),S=r,E=s-r;for(var R=0;R<i.length;++R){var h=i[R];r0(v,h.o,h,h.f,h.u,h.c.length);var x=30+h.f.length+Pu(h.extra);v.set(h.c,h.o+x),r0(v,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+x+(h.m?h.m.length:0)}return nM(v,r,i.length,E,S),v}function p0(e,t){var n={},i=e.length-22;for(;Wn(e,i)!=101010256;--i)if(!i||e.length-i>65558)mn(13);var r=fi(e,i+8);if(!r)return{};var s=Wn(e,i+16),o=s==4294967295||r==65535;if(o){var a=Wn(e,i-12);if(o=Wn(e,a)==101075792,o)r=Wn(e,a+32),s=Wn(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=eM(e,s,o),h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=u[5],g=Qw(e,p);if(s=_,!c||c({name:m,size:d,originalSize:f,compression:h}))if(!h)n[m]=yo(e,g,g+d);else if(h==8)n[m]=qw(e.subarray(g,g+d),{out:new Dt(f)});else mn(14,"unknown compression type "+h)}return n}var Du=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function iM(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class Ou extends Error{diagnostic;constructor(e,t=iM(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var m0=1024,g0=4,_0=8,rM=6,x0=80,bo=256;class At extends Ou{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var v0=["solid","checker","stripes","gradient","bricks","noise"],y0=["normal","multiply","screen","overlay"],sM=new Set(["__proto__","prototype","constructor"]);function sc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new At(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new At(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new At(`${t} must not contain symbol keys.`);if(sM.has(i))throw new At(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new At(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new At(`${t}.${i} must be a plain JSON data field.`)}return e}function oM(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new At(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new At(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new At(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new At(`${t} must be a dense JSON array (missing index ${n}).`);return e}function nr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new At(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Zn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new At(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Fr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new At(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function S0(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new At(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Uu(e,t,n){return S0(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function aM(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>x0||n)throw new At(`${t} must be 1..${x0} visible characters.`);return e}function cM(e,t,n){if(e===void 0)return n;if(!Du.includes(e))throw new At(`${t} must be one of ${Du.join(", ")}, got ${JSON.stringify(e)}.`);return e}function b0(e,t){let i=(S0(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function lM(e,t){let n=e.blend??"normal";if(!y0.includes(n))throw new At(`${t}.blend ${JSON.stringify(n)} is not one of ${y0.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function uM(e,t){let n=`proceduralTexture.layers[${t}]`,i=sc(e,n),r=i.op;if(!v0.includes(r))throw new At(`${n}.op ${JSON.stringify(r)} is not one of ${v0.join(", ")}.`);let s=lM(i,n),o=Uu(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return nr(i,["op","color","blend","opacity"],n),{op:r,color:Zn(i.color,`${n}.color`),...a};case"checker":return nr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),squares:Fr(i.squares,`${n}.squares`,8,1,bo),...a};case"stripes":return nr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),count:Fr(i.count,`${n}.count`,8,1,bo),angleDeg:b0(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return nr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Zn(i.from,`${n}.from`),to:Zn(i.to,`${n}.to`),angleDeg:b0(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return nr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Zn(i.brick,`${n}.brick`),mortar:Zn(i.mortar,`${n}.mortar`),rows:Fr(i.rows,`${n}.rows`,8,1,bo),cols:Fr(i.cols,`${n}.cols`,4,1,bo),mortarWidth:Uu(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Uu(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return nr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),scale:Fr(i.scale,`${n}.scale`,8,1,bo),octaves:Fr(i.octaves,`${n}.octaves`,3,1,rM),seed:Fr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new At(`${n}.op is unsupported.`)}}function hM(e){let t=sc(e,"proceduralTexture");if(nr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new At(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function w0(e){let t=sc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?sc(hM(t),"proceduralTexture"):t;if(nr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new At(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<g0||i>m0||(i&i-1)!==0)throw new At(`proceduralTexture.size must be a power of two between ${g0} and ${m0}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new At("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=oM(r,"proceduralTexture.layers");if(s.length>_0)throw new At(`proceduralTexture: ${s.length} layers exceeds the maximum of ${_0}.`);let o=aM(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:cM(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(uM)}}var wL=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var jn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),E0=["baseColor","normal","metallicRoughness","emissive","occlusion"],dM={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var wo=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Mo=Fe().regex(/^sha256:[a-f0-9]{64}$/),ir=Fe().min(1).max(1000),M0=Fe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),T0=qe({id:wo,kind:pn(["external","procedural"]),provider:ir,creator:ir,assetId:ir.optional(),assetUrl:M0.optional(),accessedAt:Fe().datetime().optional(),license:qe({spdx:ir,url:M0,attribution:Fe().max(4000)}).strict(),originalFiles:wt(qe({name:Fe().min(1).max(200),sha256:Mo,bytes:vt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),A0=qe({operation:ir,tool:ir,version:ir,parameters:tc(Fe().max(100),Z_([Fe().max(2000),vt().finite(),go()])).optional()}).strict(),Xn=vt().int().min(0).max(16777215),So=vt().int().min(1).max(256),us={blend:pn(["normal","multiply","screen","overlay"]).default("normal"),opacity:vt().min(0).max(1).default(1)},R0=qe({schemaVersion:jt(2),size:vt().int().min(4).max(1024).default(256),usage:pn(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Fe().min(1).max(80).optional(),layers:wt(mw("op",[qe({op:jt("solid"),color:Xn,...us}).strict(),qe({op:jt("checker"),colorA:Xn,colorB:Xn,squares:So.default(8),...us}).strict(),qe({op:jt("stripes"),colorA:Xn,colorB:Xn,count:So.default(8),angleDeg:vt().min(-36000).max(36000).default(0),...us}).strict(),qe({op:jt("gradient"),from:Xn,to:Xn,angleDeg:vt().min(-36000).max(36000).default(0),...us}).strict(),qe({op:jt("bricks"),brick:Xn,mortar:Xn,rows:So.default(8),cols:So.default(4),mortarWidth:vt().min(0).max(1).default(0.06),stagger:vt().min(0).max(1).default(0.5),...us}).strict(),qe({op:jt("noise"),colorA:Xn,colorB:Xn,scale:So.default(8),octaves:vt().int().min(1).max(6).default(3),seed:vt().int().min(-2147483648).max(2147483647).default(0),...us}).strict()])).min(1).max(8)}).strict(),C0=qe({kind:jt("normal-from-height"),strength:vt().finite().positive().max(64)}).strict(),fM=qe({compiler:jt("kiln.procedural-texture.v2"),spec:R0,derive:C0.optional(),recipeHash:Mo,pixelHash:Mo,encoder:qe({name:jt("sharp"),version:ir}).strict()}).strict(),I0=qe({baseColor:vt().int().min(0).max(16777215).optional(),roughness:vt().min(0).max(1).default(1),metalness:vt().min(0).max(1).default(0),emissive:vt().int().min(0).max(16777215).optional(),emissiveIntensity:vt().min(0).max(64).default(1),alphaMode:pn(["opaque","mask","blend"]).default("opaque"),alphaCutoff:vt().min(0).max(1).default(0.5),doubleSided:go().default(!1)}).strict(),P0=qe({schemaVersion:jt(1),materialId:wo,revisionId:Mo,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30),tileable:go(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:I0,sources:wt(T0).min(1).max(20),maps:wt(qe({slot:pn(E0),file:pn(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Mo,bytes:vt().int().positive().max(jn.maxMapBytes),width:vt().int().positive().max(jn.maxMapEdge),height:vt().int().positive().max(jn.maxMapEdge),usage:pn(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:pn(["srgb","linear"]),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:wo,originalFile:Fe().min(1).max(200).optional(),transforms:wt(A0).max(30),procedural:fM.optional()}).strict()).min(1).max(5)}).strict(),AL=qe({materialId:wo,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30).optional(),tileable:go(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:I0.partial().optional(),sources:wt(T0).min(1).max(20),maps:wt(qe({slot:pn(E0),sourceId:wo,transforms:wt(A0).max(30),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),procedural:R0,derive:C0.optional()}).strict()).min(1).max(5)}).strict(),L0=qe({schemaVersion:jt(1),records:wt(qe({manifest:P0,files:tc(Fe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Fe().max(Math.ceil(jn.maxMapBytes/3)*4))}).strict()).max(jn.maxPayloadRecords)}).strict();function To(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");To(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Eo(e){To(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function N0(e){if(To(e),new TextEncoder().encode(JSON.stringify(e)).length>jn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=P0.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==dM[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Eo(r.procedural.spec)!==Eo(w0(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>jn.maxRecordBytes||i>jn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Un=67108864,Fu=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),pM=Fe().regex(/^sha256:[a-f0-9]{64}$/),D0=qe({version:jt("kiln.asset.v1"),assetId:Fu,revisionId:Fu,parentRevision:Fu.optional(),name:Fe().min(1).max(200),tags:wt(Fe().max(80)).max(30),createdAt:Fe().datetime(),description:Fe().max(4000).optional(),brief:Fe().max(8000).optional(),attribution:qe({model:Fe().max(200).optional(),harness:Fe().max(200).optional(),author:Fe().max(200).optional()}).optional(),editable:go(),files:tc(Fe(),qe({sha256:pM,bytes:vt().int().nonnegative().max(Un)})),build:qe({engine:Fe(),options:tc(Fe(),Ur()),warnings:wt(Fe()),integration:Ur().optional(),qa:Ur().optional(),dependencies:wt(Ur()).optional(),rebuild:pn(["engine-required","external-dependencies-required"])}).optional(),preview:qe({fidelity:Ur().optional(),error:Fe().optional(),backdrop:pn(K_).optional()}).optional()}),Ao="materials.kiln.json",O0=25165824;function U0(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=N0(c.manifest);return[`${l.materialId}/${l.revisionId}`,Eo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}To(e.materialResources);let r=L0.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Eo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>jn.maxPayloadBytes||o>jn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var mM=new Set(["asset.glb","source.kiln.js","preview.png"]);function oc(e){let t=D0.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!mM.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Un||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");zu(e.files["asset.glb"]),U0(e)}function zu(e){if(e.length<20||e.length>Un)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function ku(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){oc(i),U0(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>O0)throw Error("Asset material payload exceeds byte limit");t[r+Ao]=s}}for(let i of Object.values(t))n+=i.length;if(n>Un)throw Error("Bundle exceeds 64 MiB");return f0(t,{level:0})}function F0(e){if(e.length>Un+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=p0(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>Un||n>500||o.name.endsWith(`/${Ao}`)&&o.originalSize>O0||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(o.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[o,a]of Object.entries(i)){if(!o.endsWith("/manifest.json"))continue;if(a.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=D0.parse(JSON.parse(new TextDecoder().decode(a))),l=`${c.assetId}/${c.revisionId}/`;if(o!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(o);for(let h of Object.keys(c.files)){if(!i[l+h])throw Error("Bundle file missing");u.files[h]=i[l+h],s.add(l+h)}if(i[l+Ao])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Ao])),s.add(l+Ao);oc(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function z0(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Sx="186",hr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},dr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wx=0,hh=1,Mx=2;var ko=1,Ex=2,Cs=3,fr=0,cn=1,Bn=2,vi=0,Bo=1,dh=2,fh=3,ph=4,Tx=5;var Is=100,Ax=101,Rx=102,Cx=103,Ix=104,Px=200,Lx=201,Nx=202,Dx=203,Ox=204,Ux=205,Fx=206,zx=207,kx=208,Bx=209,Gx=210,Hx=211,Vx=212,$x=213,Wx=214,Zx=0,Xx=1,jx=2,mh=3,qx=4,Yx=5,Kx=6,Jx=7,Qx=0,ev=1,tv=2,ei=0,gh=1,_h=2,xh=3,Go=4,vh=5,yh=6,bh=7;var Ps=301,$r=302,Oc=303,Uc=304,Ho=306,Ls=1000,Ns=1001,Fc=1002,ti=1003,zc=1004;var Wr=1005;var Jt=1006,Ds=1007;var yi=1008;var ni=1009,nv=1010,iv=1011,Vo=1012,Sh=1013,pr=1014,Vi=1015,bi=1016,wh=1017,Mh=1018,Os=1020,rv=35902,sv=35899,ov=1021,av=1022,Si=1023,Zr=1026,Xr=1027,cv=1028,Eh=1029,jr=1030,Th=1031;var Ah=1033,kc=33776,Bc=33777,Gc=33778,Hc=33779,Rh=35840,Ch=35841,Ih=35842,Ph=35843,Lh=36196,Nh=37492,Dh=37496,Oh=37488,Uh=37489,Vc=37490,Fh=37491,zh=37808,kh=37809,Bh=37810,Gh=37811,Hh=37812,Vh=37813,$h=37814,Wh=37815,Zh=37816,Xh=37817,jh=37818,qh=37819,Yh=37820,Kh=37821,Jh=36492,Qh=36494,ed=36495,td=36283,nd=36284,$c=36285,id=36286;var rd=2300,Wc=2301;var sd=0,$o=1,Us=2;var od=0,lv=1,qr="",mr="srgb",Rn="srgb-linear",ad="linear",yt="srgb";var uv=512,hv=513,dv=514,Zc=515,fv=516,pv=517,Xc=518,mv=519;var cd="300 es",ld=2000;function gM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function _M(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ts(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function gv(){let e=Ts("canvas");return e.style.display="block",e}var k0={},As=null;function zo(...e){let t="THREE."+e.shift();if(As)As("log",t,...e);else console.log(t,...e)}function _v(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ue(...e){e=_v(e);let t="THREE."+e.shift();if(As)As("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function $e(...e){e=_v(e);let t="THREE."+e.shift();if(As)As("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Hr(...e){let t=e.join(" ");if(t in k0)return;k0[t]=!0,Ue(...e)}function xv(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var vv={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ii{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var on=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],B0=1234567,Uo=Math.PI/180,Vr=180/Math.PI;function Qn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(on[e&255]+on[e>>8&255]+on[e>>16&255]+on[e>>24&255]+"-"+on[t&255]+on[t>>8&255]+"-"+on[t>>16&15|64]+on[t>>24&255]+"-"+on[n&63|128]+on[n>>8&255]+"-"+on[n>>16&255]+on[n>>24&255]+on[i&255]+on[i>>8&255]+on[i>>16&255]+on[i>>24&255]).toLowerCase()}function Je(e,t,n){return Math.max(t,Math.min(n,e))}function ud(e,t){return(e%t+t)%t}function xM(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function vM(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Fo(e,t,n){return(1-n)*e+n*t}function yM(e,t,n,i){return Fo(e,t,1-Math.exp(-n*i))}function bM(e,t=1){return t-Math.abs(ud(e,t*2)-t)}function SM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function wM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function MM(e,t){return e+Math.floor(Math.random()*(t-e+1))}function EM(e,t){return e+Math.random()*(t-e)}function TM(e){return e*(0.5-Math.random())}function AM(e){if(e!==void 0)B0=e;let t=B0+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function RM(e){return e*Uo}function CM(e){return e*Vr}function IM(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function PM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function LM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function NM(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*h,c*d,a*l);break;case"YZY":e.set(c*d,a*u,c*h,a*l);break;case"ZXZ":e.set(c*h,c*d,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Jn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Wo={DEG2RAD:Uo,RAD2DEG:Vr,generateUUID:Qn,clamp:Je,euclideanModulo:ud,mapLinear:xM,inverseLerp:vM,lerp:Fo,damp:yM,pingpong:bM,smoothstep:SM,smootherstep:wM,randInt:MM,randFloat:EM,randFloatSpread:TM,seededRandom:AM,degToRad:RM,radToDeg:CM,isPowerOfTwo:IM,ceilPowerOfTwo:PM,floorPowerOfTwo:LM,setQuaternionFromProperEuler:NM,normalize:ft,denormalize:Jn};class Be{static{Be.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==h||c!==d||l!==f){let _=a*h+c*d+l*f+u*m;if(_<0)h=-h,d=-d,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),M=Math.sin(g);p=Math.sin(p*g)/M,o=Math.sin(o*g)/M,a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],h=r[s+1],d=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*d-c*h,e[t+1]=a*f+l*h+c*u-o*d,e[t+2]=c*f+l*d+o*h-a*u,e[t+3]=l*f-o*u-a*h-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),h=a(n/2),d=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"YXZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"ZXY":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"ZYX":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"YZX":this._x=h*l*u+c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u-h*d*f;break;case"XZY":this._x=h*l*u-c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u+h*d*f;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],h=n+o+u;if(h>0){let d=0.5/Math.sqrt(h+1);this._w=0.25/d,this._x=(l-a)*d,this._y=(r-c)*d,this._z=(s-i)*d}else if(n>o&&n>u){let d=2*Math.sqrt(1+n-o-u);this._w=(l-a)/d,this._x=0.25*d,this._y=(i+s)/d,this._z=(r+c)/d}else if(o>u){let d=2*Math.sqrt(1+o-n-u);this._w=(r-c)/d,this._x=(i+s)/d,this._y=0.25*d,this._z=(a+l)/d}else{let d=2*Math.sqrt(1+u-n-o);this._w=(s-i)/d,this._x=(r+c)/d,this._y=(a+l)/d,this._z=0.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{static{F.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(G0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(G0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Bu.copy(this).projectOnVector(e),this.sub(Bu)}reflect(e){return this.sub(Bu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Bu=new F,G0=new Yt;class We{static{We.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],h=n[2],d=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],M=i[4],T=i[7],v=i[2],S=i[5],E=i[8];return r[0]=s*m+o*g+a*v,r[3]=s*_+o*M+a*S,r[6]=s*p+o*T+a*E,r[1]=c*m+l*g+u*v,r[4]=c*_+l*M+u*S,r[7]=c*p+l*T+u*E,r[2]=h*m+d*g+f*v,r[5]=h*_+d*M+f*S,r[8]=h*p+d*T+f*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,h=o*a-l*r,d=c*r-s*a,f=t*u+n*h+i*d;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=h*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Hr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Gu.makeScale(e,t)),this}rotate(e){return Hr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Gu.makeRotation(-e)),this}translate(e,t){return Hr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Gu.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Gu=new We,H0=new We().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),V0=new We().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function DM(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Hi(r.r),r.g=Hi(r.g),r.b=Hi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=Es(r.r),r.g=Es(r.g),r.b=Es(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Hr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Hr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:H0,fromXYZ:V0,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:H0,fromXYZ:V0,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var Ke=DM();function Hi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Es(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var hs;class hd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(hs===void 0)hs=Ts("canvas");hs.width=e.width,hs.height=e.height;let i=hs.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=hs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Ts("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Hi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Hi(t[n]/255)*255);else t[n]=Hi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var OM=0;class Zo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:OM++}),this.uuid=Qn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Hu(i[s].image));else r.push(Hu(i[s]))}else r=Hu(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Hu(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return hd.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ue("Texture: Unable to serialize Texture."),{}}var UM=0,Vu=new F;class Ot extends ii{constructor(e=Ot.DEFAULT_IMAGE,t=Ot.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Ot.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:UM++}),this.uuid=Qn(),this.name="",this.source=new Zo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Be(0,0),this.repeat=new Be(1,1),this.center=new Be(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new We,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Vu).x}get height(){return this.source.getSize(Vu).y}get depth(){return this.source.getSize(Vu).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=300;Ot.DEFAULT_ANISOTROPY=1;class pt{static{pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-h)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+h)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+d+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let M=(c+1)/2,T=(d+1)/2,v=(p+1)/2,S=(l+h)/4,E=(u+m)/4,R=(f+_)/4;if(M>T&&M>v)if(M<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(M),i=S/n,r=E/n;else if(T>v)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=S/i,r=R/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=E/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(h-l)*(h-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(h-l)/g,this.w=Math.acos((c+d+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class dd extends ii{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Ot(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Zo(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Cn extends dd{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class jc extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class fd extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Xe{static{Xe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=h,p[3]=d,p[7]=f,p[11]=m,p[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Xe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/ds.setFromMatrixColumn(e,0).length(),r=1/ds.setFromMatrixColumn(e,1).length(),s=1/ds.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=d+f*c,t[5]=h-m*c,t[9]=-o*a,t[2]=m-h*c,t[6]=f+d*c,t[10]=s*a}else if(e.order==="YXZ"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h+m*o,t[4]=f*o-d,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=d*o-f,t[6]=m+h*o,t[10]=s*a}else if(e.order==="ZXY"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h-m*o,t[4]=-s*u,t[8]=f+d*o,t[1]=d+f*o,t[5]=s*l,t[9]=m-h*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-d,t[8]=h*c+m,t[1]=a*u,t[5]=m*c+h,t[9]=d*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-h*u,t[8]=f*u+d,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=d*u+f,t[10]=h-m*u}else if(e.order==="XZY"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=h*u+m,t[5]=s*l,t[9]=d*u-f,t[2]=f*u-d,t[6]=o*l,t[10]=m*u+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(FM,e,zM)}lookAt(e,t,n){let i=this.elements;if(Tn.subVectors(e,t),Tn.lengthSq()===0)Tn.z=1;if(Tn.normalize(),rr.crossVectors(n,Tn),rr.lengthSq()===0){if(Math.abs(n.z)===1)Tn.x+=0.0001;else Tn.z+=0.0001;Tn.normalize(),rr.crossVectors(n,Tn)}return rr.normalize(),ac.crossVectors(Tn,rr),i[0]=rr.x,i[4]=ac.x,i[8]=Tn.x,i[1]=rr.y,i[5]=ac.y,i[9]=Tn.y,i[2]=rr.z,i[6]=ac.z,i[10]=Tn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],M=n[7],T=n[11],v=n[15],S=i[0],E=i[4],R=i[8],x=i[12],w=i[1],H=i[5],C=i[9],N=i[13],ee=i[2],P=i[6],Z=i[10],G=i[14],k=i[3],W=i[7],B=i[11],Y=i[15];return r[0]=s*S+o*w+a*ee+c*k,r[4]=s*E+o*H+a*P+c*W,r[8]=s*R+o*C+a*Z+c*B,r[12]=s*x+o*N+a*G+c*Y,r[1]=l*S+u*w+h*ee+d*k,r[5]=l*E+u*H+h*P+d*W,r[9]=l*R+u*C+h*Z+d*B,r[13]=l*x+u*N+h*G+d*Y,r[2]=f*S+m*w+_*ee+p*k,r[6]=f*E+m*H+_*P+p*W,r[10]=f*R+m*C+_*Z+p*B,r[14]=f*x+m*N+_*G+p*Y,r[3]=g*S+M*w+T*ee+v*k,r[7]=g*E+M*H+T*P+v*W,r[11]=g*R+M*C+T*Z+v*B,r[15]=g*x+M*N+T*G+v*Y,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],h=e[10],d=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*d-c*h,M=o*d-c*u,T=o*h-a*u,v=s*d-c*l,S=s*h-a*l,E=s*u-o*l;return t*(m*g-_*M+p*T)-n*(f*g-_*v+p*S)+i*(f*M-m*v+p*E)-r*(f*T-m*S+_*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,M=t*a-i*s,T=t*c-r*s,v=n*a-i*o,S=n*c-r*o,E=i*c-r*a,R=l*m-u*f,x=l*_-h*f,w=l*p-d*f,H=u*_-h*m,C=u*p-d*m,N=h*p-d*_,ee=g*N-M*C+T*H+v*w-S*x+E*R;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let P=1/ee;return e[0]=(o*N-a*C+c*H)*P,e[1]=(i*C-n*N-r*H)*P,e[2]=(m*E-_*S+p*v)*P,e[3]=(h*S-u*E-d*v)*P,e[4]=(a*w-s*N-c*x)*P,e[5]=(t*N-i*w+r*x)*P,e[6]=(_*T-f*E-p*M)*P,e[7]=(l*E-h*T+d*M)*P,e[8]=(s*C-o*w+c*R)*P,e[9]=(n*w-t*C-r*R)*P,e[10]=(f*S-m*T+p*g)*P,e[11]=(u*T-l*S-d*g)*P,e[12]=(o*x-s*H-a*R)*P,e[13]=(t*H-n*x+i*R)*P,e[14]=(m*M-f*v-_*g)*P,e[15]=(l*v-u*M+h*g)*P,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,h=r*c,d=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,M=a*l,T=a*u,{x:v,y:S,z:E}=n;return i[0]=(1-(m+p))*v,i[1]=(d+T)*v,i[2]=(f-M)*v,i[3]=0,i[4]=(d-T)*S,i[5]=(1-(h+p))*S,i[6]=(_+g)*S,i[7]=0,i[8]=(f+M)*E,i[9]=(_-g)*E,i[10]=(1-(h+m))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=ds.set(i[0],i[1],i[2]).length(),o=ds.set(i[4],i[5],i[6]).length(),a=ds.set(i[8],i[9],i[10]).length();if(r<0)s=-s;qn.copy(this);let c=1/s,l=1/o,u=1/a;return qn.elements[0]*=c,qn.elements[1]*=c,qn.elements[2]*=c,qn.elements[4]*=l,qn.elements[5]*=l,qn.elements[6]*=l,qn.elements[8]*=u,qn.elements[9]*=u,qn.elements[10]*=u,t.setFromRotationMatrix(qn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),d=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=u,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var ds=new F,qn=new Xe,FM=new F(0,0,0),zM=new F(1,1,1),rr=new F,ac=new F,Tn=new F,$0=new Xe,W0=new Yt;class xi{constructor(e=0,t=0,n=0,i=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],h=i[6],d=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,d),this._z=Math.atan2(-s,r);else this._x=Math.atan2(h,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Je(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,d),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(Je(h,-1,1)),Math.abs(h)<0.9999999)this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(h,d),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Je(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,d);break;case"XZY":if(this._z=Math.asin(-Je(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(h,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,d),this._y=0;break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return $0.makeRotationFromQuaternion(e),this.setFromRotationMatrix($0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return W0.setFromEuler(this),this.setFromQuaternion(W0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xi.DEFAULT_ORDER="XYZ";class qc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var kM=0,Z0=new F,fs=new Yt,Ui=new Xe,cc=new F,Ro=new F,BM=new F,GM=new Yt,X0=new F(1,0,0),j0=new F(0,1,0),q0=new F(0,0,1),Y0={type:"added"},HM={type:"removed"},ps={type:"childadded",child:null},$u={type:"childremoved",child:null};class _t extends ii{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:kM++}),this.uuid=Qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();let e=new F,t=new xi,n=new Yt,i=new F(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Xe},normalMatrix:{value:new We}}),this.matrix=new Xe,this.matrixWorld=new Xe,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return fs.setFromAxisAngle(e,t),this.quaternion.multiply(fs),this}rotateOnWorldAxis(e,t){return fs.setFromAxisAngle(e,t),this.quaternion.premultiply(fs),this}rotateX(e){return this.rotateOnAxis(X0,e)}rotateY(e){return this.rotateOnAxis(j0,e)}rotateZ(e){return this.rotateOnAxis(q0,e)}translateOnAxis(e,t){return Z0.copy(e).applyQuaternion(this.quaternion),this.position.add(Z0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(X0,e)}translateY(e){return this.translateOnAxis(j0,e)}translateZ(e){return this.translateOnAxis(q0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ui.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)cc.copy(e);else cc.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Ui.lookAt(Ro,cc,this.up);else Ui.lookAt(cc,Ro,this.up);if(this.quaternion.setFromRotationMatrix(Ui),i)Ui.extractRotation(i.matrixWorld),fs.setFromRotationMatrix(Ui),this.quaternion.premultiply(fs.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return $e("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Y0),ps.child=e,this.dispatchEvent(ps),ps.child=null;else $e("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(HM),$u.child=e,this.dispatchEvent($u),$u.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Ui.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Ui.multiply(e.parent.matrixWorld);return e.applyMatrix4(Ui),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Y0),ps.child=e,this.dispatchEvent(ps),ps.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,e,BM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,GM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),h=s(e.skeletons),d=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(h.length>0)n.skeletons=h;if(d.length>0)n.animations=d;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}_t.DEFAULT_UP=new F(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class gi extends _t{constructor(){super();this.isGroup=!0,this.type="Group"}}var VM={type:"move"};class Xo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],h=l.position.distanceTo(u.position),d=0.02,f=0.005;if(c.inputState.pinching&&h>d+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&h<=d-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(VM)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new gi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var yv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},sr={h:0,s:0,l:0},lc={h:0,s:0,l:0};function Wu(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class He{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ke.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Ke.workingColorSpace){if(e=ud(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Wu(s,r,e+0.3333333333333333),this.g=Wu(s,r,e),this.b=Wu(s,r,e-0.3333333333333333)}return Ke.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ue("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=yv[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ue("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Hi(e.r),this.g=Hi(e.g),this.b=Hi(e.b),this}copyLinearToSRGB(e){return this.r=Es(e.r),this.g=Es(e.g),this.b=Es(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return Ke.workingToColorSpace(an.copy(this),e),Math.round(Je(an.r*255,0,255))*65536+Math.round(Je(an.g*255,0,255))*256+Math.round(Je(an.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(an.copy(this),t);let{r:n,g:i,b:r}=an,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e="srgb"){Ke.workingToColorSpace(an.copy(this),e);let{r:t,g:n,b:i}=an;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(sr),this.setHSL(sr.h+e,sr.s+t,sr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(sr),e.getHSL(lc);let n=Fo(sr.h,lc.h,t),i=Fo(sr.s,lc.s,t),r=Fo(sr.l,lc.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var an=new He;He.NAMES=yv;class Fs extends _t{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xi,this.environmentIntensity=1,this.environmentRotation=new xi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Yn=new F,Fi=new F,Zu=new F,zi=new F,ms=new F,gs=new F,K0=new F,Xu=new F,ju=new F,qu=new F,Yu=new pt,Ku=new pt,Ju=new pt;class kn{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Yn.subVectors(e,t),i.cross(Yn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Yn.subVectors(i,t),Fi.subVectors(n,t),Zu.subVectors(e,t);let s=Yn.dot(Yn),o=Yn.dot(Fi),a=Yn.dot(Zu),c=Fi.dot(Fi),l=Fi.dot(Zu),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let h=1/u,d=(c*a-o*l)*h,f=(s*l-o*a)*h;return r.set(1-d-f,f,d)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,zi)===null)return!1;return zi.x>=0&&zi.y>=0&&zi.x+zi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,zi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,zi.x),a.addScaledVector(s,zi.y),a.addScaledVector(o,zi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Yu.setScalar(0),Ku.setScalar(0),Ju.setScalar(0),Yu.fromBufferAttribute(e,t),Ku.fromBufferAttribute(e,n),Ju.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Yu,r.x),s.addScaledVector(Ku,r.y),s.addScaledVector(Ju,r.z),s}static isFrontFacing(e,t,n,i){return Yn.subVectors(n,t),Fi.subVectors(e,t),Yn.cross(Fi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Yn.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),Yn.cross(Fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return kn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;ms.subVectors(i,n),gs.subVectors(r,n),Xu.subVectors(e,n);let a=ms.dot(Xu),c=gs.dot(Xu);if(a<=0&&c<=0)return t.copy(n);ju.subVectors(e,i);let l=ms.dot(ju),u=gs.dot(ju);if(l>=0&&u<=l)return t.copy(i);let h=a*u-l*c;if(h<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ms,s);qu.subVectors(e,r);let d=ms.dot(qu),f=gs.dot(qu);if(f>=0&&d<=f)return t.copy(r);let m=d*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(gs,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return K0.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(K0,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(ms,s).addScaledVector(gs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Vt{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,Kn);else Kn.fromBufferAttribute(r,s);Kn.applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();uc.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();uc.copy(n.boundingBox)}uc.applyMatrix4(e.matrixWorld),this.union(uc)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Co),hc.subVectors(this.max,Co),_s.subVectors(e.a,Co),xs.subVectors(e.b,Co),vs.subVectors(e.c,Co),or.subVectors(xs,_s),ar.subVectors(vs,xs),zr.subVectors(_s,vs);let t=[0,-or.z,or.y,0,-ar.z,ar.y,0,-zr.z,zr.y,or.z,0,-or.x,ar.z,0,-ar.x,zr.z,0,-zr.x,-or.y,or.x,0,-ar.y,ar.x,0,-zr.y,zr.x,0];if(!Qu(t,_s,xs,vs,hc))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Qu(t,_s,xs,vs,hc))return!1;return dc.crossVectors(or,ar),t=[dc.x,dc.y,dc.z],Qu(t,_s,xs,vs,hc)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return ki[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ki[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ki[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ki[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ki[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ki[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ki[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ki[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ki),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var ki=[new F,new F,new F,new F,new F,new F,new F,new F],Kn=new F,uc=new Vt,_s=new F,xs=new F,vs=new F,or=new F,ar=new F,zr=new F,Co=new F,hc=new F,dc=new F,kr=new F;function Qu(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){kr.fromArray(e,s);let a=r.x*Math.abs(kr.x)+r.y*Math.abs(kr.y)+r.z*Math.abs(kr.z),c=t.dot(kr),l=n.dot(kr),u=i.dot(kr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Gt=new F,fc=new Be,$M=0;class Kt extends ii{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$M++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)fc.fromBufferAttribute(this,t),fc.applyMatrix3(e),this.setXY(t,fc.x,fc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix3(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Jn(t,this.array);return t}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Jn(t,this.array);return t}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Jn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Jn(t,this.array);return t}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Yc extends Kt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Kc extends Kt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vn extends Kt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var WM=new Vt,Io=new F,eh=new F;class In{constructor(e=new F,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else WM.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Io.subVectors(e,this.center);let t=Io.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Io,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else eh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Io.copy(e.center).add(eh)),this.expandByPoint(Io.copy(e.center).sub(eh));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var ZM=0,Fn=new Xe,th=new _t,ys=new F,An=new Vt,Po=new Vt,qt=new F;class ln extends ii{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ZM++}),this.uuid=Qn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((gM(e))?Kc:Yc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new We().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return th.lookAt(e),th.updateMatrix(),this.applyMatrix4(th.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new vn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ue("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Vt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$e("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(An.setFromBufferAttribute(r),this.morphTargetsRelative)qt.addVectors(this.boundingBox.min,An.min),this.boundingBox.expandByPoint(qt),qt.addVectors(this.boundingBox.max,An.max),this.boundingBox.expandByPoint(qt);else this.boundingBox.expandByPoint(An.min),this.boundingBox.expandByPoint(An.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))$e('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new In;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$e("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){let n=this.boundingSphere.center;if(An.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Po.setFromBufferAttribute(o),this.morphTargetsRelative)qt.addVectors(An.min,Po.min),An.expandByPoint(qt),qt.addVectors(An.max,Po.max),An.expandByPoint(qt);else An.expandByPoint(Po.min),An.expandByPoint(Po.max)}An.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)qt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(qt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(qt.fromBufferAttribute(o,c),a)ys.fromBufferAttribute(e,c),qt.add(ys);i=Math.max(i,n.distanceToSquared(qt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))$e('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){$e("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Kt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new F,a[R]=new F;let c=new F,l=new F,u=new F,h=new Be,d=new Be,f=new Be,m=new F,_=new F;function p(R,x,w){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,w),h.fromBufferAttribute(r,R),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,w),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let H=1/(d.x*f.y-f.x*d.y);if(!isFinite(H))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(H),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(H),o[R].add(m),o[x].add(m),o[w].add(m),a[R].add(_),a[x].add(_),a[w].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:H,count:C}=w;for(let N=H,ee=H+C;N<ee;N+=3)p(e.getX(N+0),e.getX(N+1),e.getX(N+2))}let M=new F,T=new F,v=new F,S=new F;function E(R){v.fromBufferAttribute(i,R),S.copy(v);let x=o[R];M.copy(x),M.sub(v.multiplyScalar(v.dot(x))).normalize(),T.crossVectors(S,x);let H=T.dot(a[R])<0?-1:1;s.setXYZW(R,M.x,M.y,M.z,H)}for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:H,count:C}=w;for(let N=H,ee=H+C;N<ee;N+=3)E(e.getX(N+0)),E(e.getX(N+1)),E(e.getX(N+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Kt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new F,r=new F,s=new F,o=new F,a=new F,c=new F,l=new F,u=new F;if(e)for(let h=0,d=e.count;h<d;h+=3){let f=e.getX(h+0),m=e.getX(h+1),_=e.getX(h+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(h+0,l.x,l.y,l.z),n.setXYZ(h+1,l.x,l.y,l.z),n.setXYZ(h+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)qt.fromBufferAttribute(e,t),qt.normalize(),e.setXYZ(t,qt.x,qt.y,qt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,h=new c.constructor(a.length*l),d=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)d=a[m]*o.data.stride+o.offset;else d=a[m]*l;for(let p=0;p<l;p++)h[f++]=c[d++]}return new Kt(h,l,u)}if(this.index===null)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new ln,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let h=c[l],d=e(h,n);a.push(d)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u];l.push(d.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class jo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var gn=new F;class zs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Jn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Jn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Jn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Jn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){zo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Kt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new zs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){zo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var nh=new F,XM=new F,jM=new We;class zn{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=nh.subVectors(n,t).cross(XM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(nh),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||jM.getNormalMatrix(e),i=this.coplanarPoint(nh).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var qM=0;class yn extends ii{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:qM++}),this.uuid=Qn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new He(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ue(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new He().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new zn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Be().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Be().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var Bi=new F,ih=new F,pc=new F,mc=new F;class gr{constructor(e=new F,t=new F(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Bi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Bi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Bi.copy(this.origin).addScaledVector(this.direction,t),Bi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){ih.copy(e).add(t).multiplyScalar(0.5),pc.copy(t).sub(e).normalize(),mc.copy(this.origin).sub(ih);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(pc),o=mc.dot(this.direction),a=-mc.dot(pc),c=mc.lengthSq(),l=Math.abs(1-s*s),u,h,d,f;if(l>0)if(u=s*a-o,h=s*o-a,f=r*l,u>=0)if(h>=-f)if(h<=f){let m=1/l;u*=m,h*=m,d=u*(u+s*h+2*o)+h*(s*u+h+2*a)+c}else h=r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else h=-r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else if(h<=-f)u=Math.max(0,-(-s*r+o)),h=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else if(h<=f)u=0,h=Math.min(Math.max(-r,-a),r),d=h*(h+2*a)+c;else u=Math.max(0,-(s*r+o)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else h=s>0?-r:r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(ih).addScaledVector(pc,h);return d}intersectSphere(e,t){if(e.radius<0)return null;Bi.subVectors(e.center,this.origin);let n=Bi.dot(this.direction),i=Bi.dot(Bi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;if(c>=0)n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c;else n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c;if(l>=0)r=(e.min.y-h.y)*l,s=(e.max.y-h.y)*l;else r=(e.max.y-h.y)*l,s=(e.min.y-h.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u;else o=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Bi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,h=e.y-s.y,d=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,M=n.z-s.z,T=Math.abs(a),v=Math.abs(c),S=Math.abs(l),E,R,x,w,H,C,N,ee,P,Z,G,k;if(T>=v&&T>=S)if(x=a,C=u,P=f,k=p,a>=0)E=c,R=l,w=h,H=d,N=m,ee=_,Z=g,G=M;else E=l,R=c,w=d,H=h,N=_,ee=m,Z=M,G=g;else if(v>=S)if(x=c,C=h,P=m,k=g,c>=0)E=l,R=a,w=d,H=u,N=_,ee=f,Z=M,G=p;else E=a,R=l,w=u,H=d,N=f,ee=_,Z=p,G=M;else if(x=l,C=d,P=_,k=M,l>=0)E=a,R=c,w=u,H=h,N=f,ee=m,Z=p,G=g;else E=c,R=a,w=h,H=u,N=m,ee=f,Z=g,G=p;if(x===0)return null;let W=E/x,B=R/x,Y=1/x,K=w-W*C,ge=H-B*C,de=N-W*P,fe=ee-B*P,he=Z-W*k,I=G-B*k,V=he*fe-I*de,q=K*I-ge*he,se=de*ge-fe*K;if(i){if(V<0||q<0||se<0)return null}else if((V<0||q<0||se<0)&&(V>0||q>0||se>0))return null;let ce=V+q+se;if(ce===0)return null;let ae=Y*(V*C+q*P+se*k);if(ce>0?ae<0:ae>0)return null;return this.at(ae/ce,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var J0=new Xe,Br=new gr,gc=new In,Q0=new F,_c=new F,xc=new F,vc=new F,rh=new F,yc=new F,ex=new F,bc=new F;class Mt extends _t{constructor(e=new ln,t=new wi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){yc.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(rh.fromBufferAttribute(u,e),s)yc.addScaledVector(rh,l);else yc.addScaledVector(rh.sub(t),l)}t.add(yc)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(gc.copy(n.boundingSphere),gc.applyMatrix4(r),Br.copy(e.ray).recast(e.near),gc.containsPoint(Br.origin)===!1){if(Br.intersectSphere(gc,Q0)===null)return;if(Br.origin.distanceToSquared(Q0)>(e.far-e.near)**2)return}if(J0.copy(r).invert(),Br.copy(e.ray).applyMatrix4(J0),n.boundingBox!==null){if(Br.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Br)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:h,drawRange:d}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=o.getX(T),E=o.getX(T+1),R=o.getX(T+2);if(i=Sc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),M=o.getX(_+1),T=o.getX(_+2);if(i=Sc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=T,E=T+1,R=T+2;if(i=Sc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=_,M=_+1,T=_+2;if(i=Sc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function YM(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;bc.copy(a),bc.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(bc);if(l<n.near||l>n.far)return null;return{distance:l,point:bc.clone(),object:e}}function Sc(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,_c),e.getVertexPosition(c,xc),e.getVertexPosition(l,vc);let u=YM(e,t,n,i,_c,xc,vc,ex);if(u){let h=new F;if(kn.getBarycoord(ex,_c,xc,vc,h),r)u.uv=kn.getInterpolatedAttribute(r,a,c,l,h,new Be);if(s)u.uv1=kn.getInterpolatedAttribute(s,a,c,l,h,new Be);if(o){if(u.normal=kn.getInterpolatedAttribute(o,a,c,l,h,new F),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let d={a,b:c,c:l,normal:new F,materialIndex:0};kn.getNormal(_c,xc,vc,d.normal),u.face=d,u.barycoord=h}return u}var Lo=new pt,tx=new pt,nx=new pt,KM=new pt,ix=new Xe,wc=new F,sh=new In,rx=new Xe,oh=new gr;class Jc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Xe,this.bindMatrixInverse=new Xe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Vt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,wc),this.boundingBox.expandByPoint(wc)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new In;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,wc),this.boundingSphere.expandByPoint(wc)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(sh.copy(this.boundingSphere),sh.applyMatrix4(i),e.ray.intersectsSphere(sh)===!1)return;if(rx.copy(i).invert(),oh.copy(e.ray).applyMatrix4(rx),this.boundingBox!==null){if(oh.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,oh)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ue("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(tx.fromBufferAttribute(i.attributes.skinIndex,e),nx.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Lo.copy(t),t.set(0,0,0,0);else Lo.set(...t,1),t.set(0,0,0);Lo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=nx.getComponent(r);if(s!==0){let o=tx.getComponent(r);ix.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(KM.copy(Lo).applyMatrix4(ix),s)}}if(t.isVector4)t.w=Lo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class qo extends _t{constructor(){super();this.isBone=!0,this.type="Bone"}}class Yo extends Ot{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,h){super(null,s,o,a,c,l,i,r,u,h);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var sx=new Xe,JM=new Xe;class Ko{constructor(e=[],t=[]){this.uuid=Qn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ue("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Xe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Xe;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:JM;sx.multiplyMatrices(o,t[r]),sx.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ko(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Yo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ue("Skeleton: No bone found with UUID:",r),s=new qo;this.bones.push(s),this.boneInverses.push(new Xe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class ur extends Kt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var bs=new Xe,ox=new Xe,Mc=[],ax=new Vt,QM=new Xe,No=new Mt,Do=new In;class ks extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ur(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,QM)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Vt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,bs),ax.copy(e.boundingBox).applyMatrix4(bs),this.boundingBox.union(ax)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new In;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,bs),Do.copy(e.boundingSphere).applyMatrix4(bs),this.boundingSphere.union(Do)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(No.geometry=this.geometry,No.material=this.material,No.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Do.copy(this.boundingSphere),Do.applyMatrix4(n),e.ray.intersectsSphere(Do)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,bs),ox.multiplyMatrices(n,bs),No.matrixWorld=ox,No.raycast(e,Mc);for(let s=0,o=Mc.length;s<o;s++){let a=Mc[s];a.instanceId=r,a.object=this,t.push(a)}Mc.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ur(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Yo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Gr=new In,eE=new Be(0.5,0.5),Ec=new F;class Jo{constructor(e=new zn,t=new zn,n=new zn,i=new zn,r=new zn,s=new zn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],M=r[13],T=r[14],v=r[15];if(i[0].setComponents(c-s,d-l,p-f,v-g).normalize(),i[1].setComponents(c+s,d+l,p+f,v+g).normalize(),i[2].setComponents(c+o,d+u,p+m,v+M).normalize(),i[3].setComponents(c-o,d-u,p-m,v-M).normalize(),n)i[4].setComponents(a,h,_,T).normalize(),i[5].setComponents(c-a,d-h,p-_,v-T).normalize();else if(i[4].setComponents(c-a,d-h,p-_,v-T).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,v+T).normalize();else if(t===2001)i[5].setComponents(a,h,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gr)}intersectsSprite(e){Gr.center.set(0,0,0);let t=eE.distanceTo(e.center);return Gr.radius=0.7071067811865476+t,Gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ec.x=i.normal.x>0?e.max.x:e.min.x,Ec.y=i.normal.y>0?e.max.y:e.min.y,Ec.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ec)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Qo extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Nc=new F,Dc=new F,cx=new Xe,Oo=new gr,Tc=new In,ah=new F,lx=new F;class _r extends _t{constructor(e=new ln,t=new Qo){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Nc.fromBufferAttribute(t,i-1),Dc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Nc.distanceTo(Dc);e.setAttribute("lineDistance",new vn(n,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Tc.copy(n.boundingSphere),Tc.applyMatrix4(i),Tc.radius+=r,e.ray.intersectsSphere(Tc)===!1)return;cx.copy(i).invert(),Oo.copy(e.ray).applyMatrix4(cx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),M=Ac(this,e,Oo,a,p,g,m);if(M)t.push(M)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=Ac(this,e,Oo,a,m,_,f-1);if(p)t.push(p)}}else{let d=Math.max(0,s.start),f=Math.min(h.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=Ac(this,e,Oo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ac(this,e,Oo,a,f-1,d,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Ac(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Nc.fromBufferAttribute(a,r),Dc.fromBufferAttribute(a,s),n.distanceSqToSegment(Nc,Dc,ah,lx)>i)return;ah.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ah);if(l<t.near||l>t.far)return;return{distance:l,point:lx.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var ux=new F,hx=new F;class Qc extends _r{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)ux.fromBufferAttribute(t,i),hx.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ux.distanceTo(hx);e.setAttribute("lineDistance",new vn(n,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class el extends _r{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ea extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new He(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var dx=new Xe,uh=new gr,Rc=new In,Cc=new F;class Bs extends _t{constructor(e=new ln,t=new ea){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Rc.copy(n.boundingSphere),Rc.applyMatrix4(i),Rc.radius+=r,e.ray.intersectsSphere(Rc)===!1)return;dx.copy(i).invert(),uh.copy(e.ray).applyMatrix4(dx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let h=Math.max(0,s.start),d=Math.min(c.count,s.start+s.count);for(let f=h,m=d;f<m;f++){let _=c.getX(f);Cc.fromBufferAttribute(u,_),fx(Cc,_,a,i,e,t,this)}}else{let h=Math.max(0,s.start),d=Math.min(u.count,s.start+s.count);for(let f=h,m=d;f<m;f++)Cc.fromBufferAttribute(u,f),fx(Cc,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function fx(e,t,n,i,r,s,o){let a=uh.distanceSqToPoint(e);if(a<n){let c=new F;uh.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class tl extends Ot{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Yr extends Ot{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:u};super(h,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Zo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class pd extends Yr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class nl extends Ot{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class xr extends ln{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],h=0,d=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new vn(c,3)),this.setAttribute("normal",new vn(l,3)),this.setAttribute("uv",new vn(u,2));function f(m,_,p,g,M,T,v,S,E,R,x){let w=T/E,H=v/R,C=T/2,N=v/2,ee=S/2,P=E+1,Z=R+1,G=0,k=0,W=new F;for(let B=0;B<Z;B++){let Y=B*H-N;for(let K=0;K<P;K++){let ge=K*w-C;W[m]=ge*g,W[_]=Y*M,W[p]=ee,c.push(W.x,W.y,W.z),W[m]=0,W[_]=0,W[p]=S>0?1:-1,l.push(W.x,W.y,W.z),u.push(K/E),u.push(1-B/R),G+=1}}for(let B=0;B<R;B++)for(let Y=0;Y<E;Y++){let K=h+Y+P*B,ge=h+Y+P*(B+1),de=h+(Y+1)+P*(B+1),fe=h+(Y+1)+P*B;a.push(K,ge,fe),a.push(ge,de,fe),k+=6}o.addGroup(d,k,x),d+=k,h+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ta extends ln{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,h=t/a,d=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*h-s;for(let M=0;M<c;M++){let T=M*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(M/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let M=g+c*p,T=g+c*(p+1),v=g+1+c*(p+1),S=g+1+c*p;d.push(M,T,S),d.push(T,v,S)}this.setIndex(d),this.setAttribute("position",new vn(f,3)),this.setAttribute("normal",new vn(m,3)),this.setAttribute("uv",new vn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ta(e.width,e.height,e.widthSegments,e.heightSegments)}}function Kr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(px(r))if(r.isRenderTargetTexture)Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(px(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function un(e){let t={};for(let n=0;n<e.length;n++){let i=Kr(e[n]);for(let r in i)t[r]=i[r]}return t}function px(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function tE(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function md(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return Ke.workingColorSpace}var bv={clone:Kr,merge:un},nE=`void main() {
+*/var Dt=Uint8Array,En=Uint16Array,Nu=Int32Array,sc=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),oc=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Au=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o0=function(e,t){var n=new En(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Nu(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},a0=o0(sc,2),{b:c0,r:Ru}=a0;c0[28]=258,Ru[258]=28;var l0=o0(oc,0),{b:zw,r:e0}=l0,Cu=new En(32768);for(tt=0;tt<32768;++tt)di=(tt&43690)>>1|(tt&21845)<<1,di=(di&52428)>>2|(di&13107)<<2,di=(di&61680)>>4|(di&3855)<<4,Cu[tt]=((di&65280)>>8|(di&255)<<8)>>1;var di,tt,pi=function(e,t,n){var i=e.length,r=0,s=new En(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new En(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new En(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],h=o[e[r]-1]++<<u;for(var d=h|(1<<u)-1;h<=d;++h)a[Cu[h]>>c]=l}}else{a=new En(i);for(r=0;r<i;++r)if(e[r])a[r]=Cu[o[e[r]-1]++]>>15-e[r]}return a},nr=new Dt(288);for(tt=0;tt<144;++tt)nr[tt]=8;var tt;for(tt=144;tt<256;++tt)nr[tt]=9;var tt;for(tt=256;tt<280;++tt)nr[tt]=7;var tt;for(tt=280;tt<288;++tt)nr[tt]=8;var tt,So=new Dt(32);for(tt=0;tt<32;++tt)So[tt]=5;var tt,kw=pi(nr,9,0),Bw=pi(nr,9,1),Gw=pi(So,5,0),Hw=pi(So,5,1),wu=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},$n=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Mu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Du=function(e){return(e+7)/8|0},wo=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var Vw=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],mn=function(e,t,n){var i=Error(t||Vw[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,mn);if(!n)throw i;return i},$w=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(ue){var $e=n.length;if(ue>$e){var Ce=new Dt(Math.max($e*2,ue));Ce.set(n),n=Ce}},u=t.f||0,h=t.p||0,d=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=$n(e,h,1);var M=$n(e,h+1,3);if(h+=3,!M){var T=Du(h)+4,v=e[T-4]|e[T-3]<<8,S=T+v;if(S>r){if(c)mn(0);break}if(a)l(d+v);n.set(e.subarray(T,S),d),t.b=d+=v,t.p=h=S*8,t.f=u;continue}else if(M==1)f=Bw,m=Hw,_=9,p=5;else if(M==2){var E=$n(e,h,31)+257,R=$n(e,h+10,15)+4,x=E+$n(e,h+5,31)+1;h+=14;var w=new Dt(x),G=new Dt(19);for(var C=0;C<R;++C)G[Au[C]]=$n(e,h+C*3,7);h+=R*3;var D=wu(G),ee=(1<<D)-1,L=pi(G,D,1);for(var C=0;C<x;){var W=L[$n(e,h,ee)];h+=W&15;var T=W>>4;if(T<16)w[C++]=T;else{var B=0,P=0;if(T==16)P=3+$n(e,h,3),h+=2,B=w[C-1];else if(T==17)P=3+$n(e,h,7),h+=3;else if(T==18)P=11+$n(e,h,127),h+=7;while(P--)w[C++]=B}}var J=w.subarray(0,E),H=w.subarray(E);_=wu(J),p=wu(H),f=pi(J,_,1),m=pi(H,p,1)}else mn(1);if(h>g){if(c)mn(0);break}}if(a)l(d+131072);var q=(1<<_)-1,Q=(1<<p)-1,ge=h;for(;;ge=h){var B=f[Mu(e,h)&q],he=B>>4;if(h+=B&15,h>g){if(c)mn(0);break}if(!B)mn(2);if(he<256)n[d++]=he;else if(he==256){ge=h,f=null;break}else{var de=he-254;if(he>264){var C=he-257,fe=sc[C];de=$n(e,h,(1<<fe)-1)+c0[C],h+=fe}var I=m[Mu(e,h)&Q],V=I>>4;if(!I)mn(3);h+=I&15;var H=zw[V];if(V>3){var fe=oc[V];H+=Mu(e,h)&(1<<fe)-1,h+=fe}if(h>g){if(c)mn(0);break}if(a)l(d+131072);var j=d+de;if(d<H){var re=s-H,oe=Math.min(H,j);if(re+d<0)mn(3);for(;d<oe;++d)n[d]=i[re+d]}for(;d<j;++d)n[d]=n[d-H]}}if(t.l=f,t.p=ge,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?wo(n,0,d):n.subarray(0,d)},Ui=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},yo=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Eu=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:h0,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(S,E){return S.f-E.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,h=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var d=s[0].s;for(var i=1;i<r;++i)if(s[i].s>d)d=s[i].s;var f=new En(d+1),m=Iu(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(E,R){return f[R.s]-f[E.s]||E.f-R.f});for(;i<r;++i){var M=s[i].s;if(f[M]>t)_+=g-(1<<m-f[M]),f[M]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var v=s[i].s;if(f[v]==t)--f[v],++_}m=t}return{t:new Dt(f),l:m}},Iu=function(e,t,n){return e.s==-1?Math.max(Iu(e.l,t,n+1),Iu(e.r,t,n+1)):t[e.s]=n},t0=function(e){var t=e.length;while(t&&!e[--t]);var n=new En(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},bo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},u0=function(e,t,n){var i=n.length,r=Du(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},n0=function(e,t,n,i,r,s,o,a,c,l,u){Ui(t,u++,n),++r[256];var h=Eu(r,15),{t:d,l:f}=h,m=Eu(s,15),{t:_,l:p}=m,g=t0(d),{c:M,n:T}=g,v=t0(_),{c:S,n:E}=v,R=new En(19);for(var x=0;x<M.length;++x)++R[M[x]&31];for(var x=0;x<S.length;++x)++R[S[x]&31];var w=Eu(R,7),{t:G,l:C}=w,D=19;for(;D>4&&!G[Au[D-1]];--D);var ee=l+5<<3,L=bo(r,nr)+bo(s,So)+o,W=bo(r,d)+bo(s,_)+o+14+3*D+bo(R,G)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&ee<=L&&ee<=W)return u0(t,u,e.subarray(c,c+l));var B,P,J,H;if(Ui(t,u,1+(W<L)),u+=2,W<L){B=pi(d,f,0),P=d,J=pi(_,p,0),H=_;var q=pi(G,C,0);Ui(t,u,T-257),Ui(t,u+5,E-1),Ui(t,u+10,D-4),u+=14;for(var x=0;x<D;++x)Ui(t,u+3*x,G[Au[x]]);u+=3*D;var Q=[M,S];for(var ge=0;ge<2;++ge){var he=Q[ge];for(var x=0;x<he.length;++x){var de=he[x]&31;if(Ui(t,u,q[de]),u+=G[de],de>15)Ui(t,u,he[x]>>5&127),u+=he[x]>>12}}}else B=kw,P=nr,J=Gw,H=So;for(var x=0;x<a;++x){var fe=i[x];if(fe>255){var de=fe>>18&31;if(yo(t,u,B[de+257]),u+=P[de+257],de>7)Ui(t,u,fe>>23&31),u+=sc[de];var I=fe&31;if(yo(t,u,J[I]),u+=H[I],I>3)yo(t,u,fe>>5&8191),u+=oc[I]}else yo(t,u,B[fe]),u+=P[fe]}return yo(t,u,B[256]),u+P[256]},Ww=new Nu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),h0=new Dt(0),Zw=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var h=Ww[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new En(32768),p=s.h||new En(m+1),g=Math.ceil(n/3),M=2*g,T=function(He){return(e[He]^e[He+1]<<g^e[He+2]<<M)&m},v=new Nu(25000),S=new En(288),E=new En(32),R=0,x=0,w=s.i||0,G=0,C=s.w||0,D=0;for(;w+2<o;++w){var ee=T(w),L=w&32767,W=p[ee];if(_[L]=W,p[ee]=L,C<=w){var B=o-w;if((R>7000||G>24576)&&(B>423||!l)){u=n0(e,c,0,v,S,E,x,G,D,w-D,u),G=R=x=0,D=w;for(var P=0;P<286;++P)S[P]=0;for(var P=0;P<30;++P)E[P]=0}var J=2,H=0,q=f,Q=L-W&32767;if(B>2&&ee==T(w-Q)){var ge=Math.min(d,B)-1,he=Math.min(32767,w),de=Math.min(258,B);while(Q<=he&&--q&&L!=W){if(e[w+J]==e[w+J-Q]){var fe=0;for(;fe<de&&e[w+fe]==e[w+fe-Q];++fe);if(fe>J){if(J=fe,H=Q,fe>ge)break;var I=Math.min(Q,fe-2),V=0;for(var P=0;P<I;++P){var j=w-Q+P&32767,re=_[j],oe=j-re&32767;if(oe>V)V=oe,W=j}}}L=W,W=_[L],Q+=L-W&32767}}if(H){v[G++]=268435456|Ru[J]<<18|e0[H];var ue=Ru[J]&31,$e=e0[H]&31;x+=sc[ue]+oc[$e],++S[257+ue],++E[$e],C=w+J,++R}else v[G++]=e[w],++S[e[w]]}}for(w=Math.max(w,C);w<o;++w)v[G++]=e[w],++S[e[w]];if(u=n0(e,c,l,v,S,E,x,G,D,w-D,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=w,s.w=C}else{for(var w=s.w||0;w<o+l;w+=65535){var Ce=w+65535;if(Ce>=o)c[u/8|0]=l,Ce=o;u=u0(c,u+1,e.subarray(w,Ce))}s.i=o}return wo(a,0,i+Du(u)+r)},Xw=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),jw=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=Xw[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var qw=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return Zw(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},d0=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var fi=function(e,t){return e[t]|e[t+1]<<8},Wn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Tu=function(e,t){return Wn(e,t)+Wn(e,t+4)*4294967296},rn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Yw(e,t){return qw(e,t||{},0,0)}function Kw(e,t){return $w(e,{i:2},t&&t.out,t&&t.dictionary)}var f0=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=d0(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],f0(s,o,n,i)}},i0=typeof TextEncoder<"u"&&new TextEncoder,Pu=typeof TextDecoder<"u"&&new TextDecoder,Jw=0;try{Pu.decode(h0,{stream:!0}),Jw=1}catch(e){}var Qw=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return{s:t,r:wo(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function r0(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(i0)return i0.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return wo(s,0,o)}function eM(e,t){if(t){var n="";for(var i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}else if(Pu)return Pu.decode(e);else{var r=Qw(e),{s,r:n}=r;if(n.length)mn(8);return s}}var tM=function(e,t){return t+30+fi(e,t+26)+fi(e,t+28)},nM=function(e,t,n){var i=fi(e,t+28),r=eM(e.subarray(t+46,t+46+i),!(fi(e,t+8)&2048)),s=t+46+i,o=Wn(e,t+20),a=n&&o==4294967295?iM(e,s):[o,Wn(e,t+24),Wn(e,t+42)],c=a[0],l=a[1],u=a[2];return[fi(e,t+10),c,l,r,s+fi(e,t+30)+fi(e,t+32),u]},iM=function(e,t){for(;fi(e,t)!=1;t+=4+fi(e,t+2));return[Tu(e,t+12),Tu(e,t+4),Tu(e,t+20)]},Lu=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)mn(9);t+=i+4}return t},s0=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=Lu(l);if(rn(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var d=new Date(n.mtime==null?Date.now():n.mtime),f=d.getFullYear()-1980;if(f<0||f>119)mn(10);if(rn(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)rn(e,t,n.crc),rn(e,t+4,s<0?-s-2:s),rn(e,t+8,n.size);if(rn(e,t+12,c),rn(e,t+14,h),t+=16,o!=null)rn(e,t,u),rn(e,t+6,n.attrs),rn(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;rn(e,t,+m),rn(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},rM=function(e,t,n,i,r){rn(e,t,101010256),rn(e,t+8,n),rn(e,t+10,n),rn(e,t+12,i),rn(e,t+16,r)};function p0(e,t){if(!t)t={};var n={},i=[];f0(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,h=r0(o),d=h.length,f=l.comment,m=f&&r0(f),_=m&&m.length,p=Lu(l.extra);if(d>65535)mn(11);var g=u?Yw(c,l):c,M=g.length,T=jw();T.p(c),i.push(d0(l,{size:c.length,crc:T.d(),c:g,f:h,m,u:d!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+d+p+M,s+=76+2*(d+p)+(_||0)+M}var v=new Dt(s+22),S=r,E=s-r;for(var R=0;R<i.length;++R){var h=i[R];s0(v,h.o,h,h.f,h.u,h.c.length);var x=30+h.f.length+Lu(h.extra);v.set(h.c,h.o+x),s0(v,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+x+(h.m?h.m.length:0)}return rM(v,r,i.length,E,S),v}function m0(e,t){var n={},i=e.length-22;for(;Wn(e,i)!=101010256;--i)if(!i||e.length-i>65558)mn(13);var r=fi(e,i+8);if(!r)return{};var s=Wn(e,i+16),o=s==4294967295||r==65535;if(o){var a=Wn(e,i-12);if(o=Wn(e,a)==101075792,o)r=Wn(e,a+32),s=Wn(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=nM(e,s,o),h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=u[5],g=tM(e,p);if(s=_,!c||c({name:m,size:d,originalSize:f,compression:h}))if(!h)n[m]=wo(e,g,g+d);else if(h==8)n[m]=Kw(e.subarray(g,g+d),{out:new Dt(f)});else mn(14,"unknown compression type "+h)}return n}var Ou=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function sM(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class Uu extends Error{diagnostic;constructor(e,t=sM(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var g0=1024,_0=4,x0=8,oM=6,v0=80,Mo=256;class At extends Uu{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var y0=["solid","checker","stripes","gradient","bricks","noise"],b0=["normal","multiply","screen","overlay"],aM=new Set(["__proto__","prototype","constructor"]);function ac(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new At(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new At(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new At(`${t} must not contain symbol keys.`);if(aM.has(i))throw new At(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new At(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new At(`${t}.${i} must be a plain JSON data field.`)}return e}function cM(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new At(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new At(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new At(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new At(`${t} must be a dense JSON array (missing index ${n}).`);return e}function ir(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new At(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Zn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new At(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function zr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new At(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function w0(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new At(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Fu(e,t,n){return w0(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function lM(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>v0||n)throw new At(`${t} must be 1..${v0} visible characters.`);return e}function uM(e,t,n){if(e===void 0)return n;if(!Ou.includes(e))throw new At(`${t} must be one of ${Ou.join(", ")}, got ${JSON.stringify(e)}.`);return e}function S0(e,t){let i=(w0(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function hM(e,t){let n=e.blend??"normal";if(!b0.includes(n))throw new At(`${t}.blend ${JSON.stringify(n)} is not one of ${b0.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function dM(e,t){let n=`proceduralTexture.layers[${t}]`,i=ac(e,n),r=i.op;if(!y0.includes(r))throw new At(`${n}.op ${JSON.stringify(r)} is not one of ${y0.join(", ")}.`);let s=hM(i,n),o=Fu(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return ir(i,["op","color","blend","opacity"],n),{op:r,color:Zn(i.color,`${n}.color`),...a};case"checker":return ir(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),squares:zr(i.squares,`${n}.squares`,8,1,Mo),...a};case"stripes":return ir(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),count:zr(i.count,`${n}.count`,8,1,Mo),angleDeg:S0(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return ir(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Zn(i.from,`${n}.from`),to:Zn(i.to,`${n}.to`),angleDeg:S0(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return ir(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Zn(i.brick,`${n}.brick`),mortar:Zn(i.mortar,`${n}.mortar`),rows:zr(i.rows,`${n}.rows`,8,1,Mo),cols:zr(i.cols,`${n}.cols`,4,1,Mo),mortarWidth:Fu(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Fu(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return ir(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),scale:zr(i.scale,`${n}.scale`,8,1,Mo),octaves:zr(i.octaves,`${n}.octaves`,3,1,oM),seed:zr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new At(`${n}.op is unsupported.`)}}function fM(e){let t=ac(e,"proceduralTexture");if(ir(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new At(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function M0(e){let t=ac(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?ac(fM(t),"proceduralTexture"):t;if(ir(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new At(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<_0||i>g0||(i&i-1)!==0)throw new At(`proceduralTexture.size must be a power of two between ${_0} and ${g0}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new At("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=cM(r,"proceduralTexture.layers");if(s.length>x0)throw new At(`proceduralTexture: ${s.length} layers exceeds the maximum of ${x0}.`);let o=lM(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:uM(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(dM)}}var EL=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var jn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),T0=["baseColor","normal","metallicRoughness","emissive","occlusion"],pM={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var To=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Ao=Fe().regex(/^sha256:[a-f0-9]{64}$/),rr=Fe().min(1).max(1000),E0=Fe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),A0=qe({id:To,kind:pn(["external","procedural"]),provider:rr,creator:rr,assetId:rr.optional(),assetUrl:E0.optional(),accessedAt:Fe().datetime().optional(),license:qe({spdx:rr,url:E0,attribution:Fe().max(4000)}).strict(),originalFiles:wt(qe({name:Fe().min(1).max(200),sha256:Ao,bytes:vt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),R0=qe({operation:rr,tool:rr,version:rr,parameters:ic(Fe().max(100),X_([Fe().max(2000),vt().finite(),vo()])).optional()}).strict(),Xn=vt().int().min(0).max(16777215),Eo=vt().int().min(1).max(256),hs={blend:pn(["normal","multiply","screen","overlay"]).default("normal"),opacity:vt().min(0).max(1).default(1)},C0=qe({schemaVersion:jt(2),size:vt().int().min(4).max(1024).default(256),usage:pn(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Fe().min(1).max(80).optional(),layers:wt(_w("op",[qe({op:jt("solid"),color:Xn,...hs}).strict(),qe({op:jt("checker"),colorA:Xn,colorB:Xn,squares:Eo.default(8),...hs}).strict(),qe({op:jt("stripes"),colorA:Xn,colorB:Xn,count:Eo.default(8),angleDeg:vt().min(-36000).max(36000).default(0),...hs}).strict(),qe({op:jt("gradient"),from:Xn,to:Xn,angleDeg:vt().min(-36000).max(36000).default(0),...hs}).strict(),qe({op:jt("bricks"),brick:Xn,mortar:Xn,rows:Eo.default(8),cols:Eo.default(4),mortarWidth:vt().min(0).max(1).default(0.06),stagger:vt().min(0).max(1).default(0.5),...hs}).strict(),qe({op:jt("noise"),colorA:Xn,colorB:Xn,scale:Eo.default(8),octaves:vt().int().min(1).max(6).default(3),seed:vt().int().min(-2147483648).max(2147483647).default(0),...hs}).strict()])).min(1).max(8)}).strict(),I0=qe({kind:jt("normal-from-height"),strength:vt().finite().positive().max(64)}).strict(),mM=qe({compiler:jt("kiln.procedural-texture.v2"),spec:C0,derive:I0.optional(),recipeHash:Ao,pixelHash:Ao,encoder:qe({name:jt("sharp"),version:rr}).strict()}).strict(),P0=qe({baseColor:vt().int().min(0).max(16777215).optional(),roughness:vt().min(0).max(1).default(1),metalness:vt().min(0).max(1).default(0),emissive:vt().int().min(0).max(16777215).optional(),emissiveIntensity:vt().min(0).max(64).default(1),alphaMode:pn(["opaque","mask","blend"]).default("opaque"),alphaCutoff:vt().min(0).max(1).default(0.5),doubleSided:vo().default(!1)}).strict(),L0=qe({schemaVersion:jt(1),materialId:To,revisionId:Ao,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30),tileable:vo(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:P0,sources:wt(A0).min(1).max(20),maps:wt(qe({slot:pn(T0),file:pn(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Ao,bytes:vt().int().positive().max(jn.maxMapBytes),width:vt().int().positive().max(jn.maxMapEdge),height:vt().int().positive().max(jn.maxMapEdge),usage:pn(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:pn(["srgb","linear"]),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:To,originalFile:Fe().min(1).max(200).optional(),transforms:wt(R0).max(30),procedural:mM.optional()}).strict()).min(1).max(5)}).strict(),CL=qe({materialId:To,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30).optional(),tileable:vo(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:P0.partial().optional(),sources:wt(A0).min(1).max(20),maps:wt(qe({slot:pn(T0),sourceId:To,transforms:wt(R0).max(30),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),procedural:C0,derive:I0.optional()}).strict()).min(1).max(5)}).strict(),N0=qe({schemaVersion:jt(1),records:wt(qe({manifest:L0,files:ic(Fe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Fe().max(Math.ceil(jn.maxMapBytes/3)*4))}).strict()).max(jn.maxPayloadRecords)}).strict();function Co(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Co(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Ro(e){Co(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function D0(e){if(Co(e),new TextEncoder().encode(JSON.stringify(e)).length>jn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=L0.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==pM[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Ro(r.procedural.spec)!==Ro(M0(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>jn.maxRecordBytes||i>jn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Un=67108864,zu=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),gM=Fe().regex(/^sha256:[a-f0-9]{64}$/),O0=qe({version:jt("kiln.asset.v1"),assetId:zu,revisionId:zu,parentRevision:zu.optional(),name:Fe().min(1).max(200),tags:wt(Fe().max(80)).max(30),createdAt:Fe().datetime(),description:Fe().max(4000).optional(),brief:Fe().max(8000).optional(),attribution:qe({model:Fe().max(200).optional(),harness:Fe().max(200).optional(),author:Fe().max(200).optional()}).optional(),editable:vo(),files:ic(Fe(),qe({sha256:gM,bytes:vt().int().nonnegative().max(Un)})),build:qe({engine:Fe(),options:ic(Fe(),Fr()),warnings:wt(Fe()),integration:Fr().optional(),qa:Fr().optional(),dependencies:wt(Fr()).optional(),rebuild:pn(["engine-required","external-dependencies-required"])}).optional(),preview:qe({fidelity:Fr().optional(),error:Fe().optional(),backdrop:pn(J_).optional()}).optional()}),Io="materials.kiln.json",U0=25165824;function F0(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=D0(c.manifest);return[`${l.materialId}/${l.revisionId}`,Ro(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Co(e.materialResources);let r=N0.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Ro(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>jn.maxPayloadBytes||o>jn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var _M=new Set(["asset.glb","source.kiln.js","preview.png"]);function cc(e){let t=O0.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!_M.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Un||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");ku(e.files["asset.glb"]),F0(e)}function ku(e){if(e.length<20||e.length>Un)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Bu(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){cc(i),F0(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>U0)throw Error("Asset material payload exceeds byte limit");t[r+Io]=s}}for(let i of Object.values(t))n+=i.length;if(n>Un)throw Error("Bundle exceeds 64 MiB");return p0(t,{level:0})}function z0(e){if(e.length>Un+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=m0(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>Un||n>500||o.name.endsWith(`/${Io}`)&&o.originalSize>U0||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(o.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[o,a]of Object.entries(i)){if(!o.endsWith("/manifest.json"))continue;if(a.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=O0.parse(JSON.parse(new TextDecoder().decode(a))),l=`${c.assetId}/${c.revisionId}/`;if(o!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(o);for(let h of Object.keys(c.files)){if(!i[l+h])throw Error("Bundle file missing");u.files[h]=i[l+h],s.add(l+h)}if(i[l+Io])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Io])),s.add(l+Io);cc(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function k0(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var wx="186",dr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},fr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Mx=0,dh=1,Ex=2;var Ho=1,Tx=2,Is=3,pr=0,cn=1,Bn=2,vi=0,Vo=1,fh=2,ph=3,mh=4,Ax=5;var Ps=100,Rx=101,Cx=102,Ix=103,Px=104,Lx=200,Nx=201,Dx=202,Ox=203,Ux=204,Fx=205,zx=206,kx=207,Bx=208,Gx=209,Hx=210,Vx=211,$x=212,Wx=213,Zx=214,Xx=0,jx=1,qx=2,gh=3,Yx=4,Kx=5,Jx=6,Qx=7,ev=0,tv=1,nv=2,ei=0,_h=1,xh=2,vh=3,$o=4,yh=5,bh=6,Sh=7;var Ls=301,Wr=302,Fc=303,zc=304,Wo=306,Ns=1000,Ds=1001,kc=1002,ti=1003,Bc=1004;var Zr=1005;var Jt=1006,Os=1007;var yi=1008;var ni=1009,iv=1010,rv=1011,Zo=1012,wh=1013,mr=1014,$i=1015,bi=1016,Mh=1017,Eh=1018,Us=1020,sv=35902,ov=35899,av=1021,cv=1022,Si=1023,Xr=1026,jr=1027,lv=1028,Th=1029,qr=1030,Ah=1031;var Rh=1033,Gc=33776,Hc=33777,Vc=33778,$c=33779,Ch=35840,Ih=35841,Ph=35842,Lh=35843,Nh=36196,Dh=37492,Oh=37496,Uh=37488,Fh=37489,Wc=37490,zh=37491,kh=37808,Bh=37809,Gh=37810,Hh=37811,Vh=37812,$h=37813,Wh=37814,Zh=37815,Xh=37816,jh=37817,qh=37818,Yh=37819,Kh=37820,Jh=37821,Qh=36492,ed=36494,td=36495,nd=36283,id=36284,Zc=36285,rd=36286;var sd=2300,Xc=2301;var od=0,Xo=1,Fs=2;var ad=0,uv=1,Yr="",gr="srgb",Rn="srgb-linear",cd="linear",yt="srgb";var hv=512,dv=513,fv=514,jc=515,pv=516,mv=517,qc=518,gv=519;var ld="300 es",ud=2000;function xM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function vM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function As(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function _v(){let e=As("canvas");return e.style.display="block",e}var B0={},Rs=null;function Go(...e){let t="THREE."+e.shift();if(Rs)Rs("log",t,...e);else console.log(t,...e)}function xv(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ue(...e){e=xv(e);let t="THREE."+e.shift();if(Rs)Rs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ve(...e){e=xv(e);let t="THREE."+e.shift();if(Rs)Rs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Vr(...e){let t=e.join(" ");if(t in B0)return;B0[t]=!0,Ue(...e)}function vv(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var yv={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ii{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var on=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],G0=1234567,ko=Math.PI/180,$r=180/Math.PI;function Qn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(on[e&255]+on[e>>8&255]+on[e>>16&255]+on[e>>24&255]+"-"+on[t&255]+on[t>>8&255]+"-"+on[t>>16&15|64]+on[t>>24&255]+"-"+on[n&63|128]+on[n>>8&255]+"-"+on[n>>16&255]+on[n>>24&255]+on[i&255]+on[i>>8&255]+on[i>>16&255]+on[i>>24&255]).toLowerCase()}function Je(e,t,n){return Math.max(t,Math.min(n,e))}function hd(e,t){return(e%t+t)%t}function yM(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function bM(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Bo(e,t,n){return(1-n)*e+n*t}function SM(e,t,n,i){return Bo(e,t,1-Math.exp(-n*i))}function wM(e,t=1){return t-Math.abs(hd(e,t*2)-t)}function MM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function EM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function TM(e,t){return e+Math.floor(Math.random()*(t-e+1))}function AM(e,t){return e+Math.random()*(t-e)}function RM(e){return e*(0.5-Math.random())}function CM(e){if(e!==void 0)G0=e;let t=G0+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function IM(e){return e*ko}function PM(e){return e*$r}function LM(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function NM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function DM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function OM(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*h,c*d,a*l);break;case"YZY":e.set(c*d,a*u,c*h,a*l);break;case"ZXZ":e.set(c*h,c*d,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Jn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var jo={DEG2RAD:ko,RAD2DEG:$r,generateUUID:Qn,clamp:Je,euclideanModulo:hd,mapLinear:yM,inverseLerp:bM,lerp:Bo,damp:SM,pingpong:wM,smoothstep:MM,smootherstep:EM,randInt:TM,randFloat:AM,randFloatSpread:RM,seededRandom:CM,degToRad:IM,radToDeg:PM,isPowerOfTwo:LM,ceilPowerOfTwo:NM,floorPowerOfTwo:DM,setQuaternionFromProperEuler:OM,normalize:ft,denormalize:Jn};class ke{static{ke.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==h||c!==d||l!==f){let _=a*h+c*d+l*f+u*m;if(_<0)h=-h,d=-d,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),M=Math.sin(g);p=Math.sin(p*g)/M,o=Math.sin(o*g)/M,a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],h=r[s+1],d=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*d-c*h,e[t+1]=a*f+l*h+c*u-o*d,e[t+2]=c*f+l*d+o*h-a*u,e[t+3]=l*f-o*u-a*h-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),h=a(n/2),d=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"YXZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"ZXY":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"ZYX":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"YZX":this._x=h*l*u+c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u-h*d*f;break;case"XZY":this._x=h*l*u-c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u+h*d*f;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],h=n+o+u;if(h>0){let d=0.5/Math.sqrt(h+1);this._w=0.25/d,this._x=(l-a)*d,this._y=(r-c)*d,this._z=(s-i)*d}else if(n>o&&n>u){let d=2*Math.sqrt(1+n-o-u);this._w=(l-a)/d,this._x=0.25*d,this._y=(i+s)/d,this._z=(r+c)/d}else if(o>u){let d=2*Math.sqrt(1+o-n-u);this._w=(r-c)/d,this._x=(i+s)/d,this._y=0.25*d,this._z=(a+l)/d}else{let d=2*Math.sqrt(1+u-n-o);this._w=(s-i)/d,this._x=(r+c)/d,this._y=(a+l)/d,this._z=0.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class z{static{z.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(H0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(H0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Gu.copy(this).projectOnVector(e),this.sub(Gu)}reflect(e){return this.sub(Gu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Gu=new z,H0=new Yt;class We{static{We.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],h=n[2],d=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],M=i[4],T=i[7],v=i[2],S=i[5],E=i[8];return r[0]=s*m+o*g+a*v,r[3]=s*_+o*M+a*S,r[6]=s*p+o*T+a*E,r[1]=c*m+l*g+u*v,r[4]=c*_+l*M+u*S,r[7]=c*p+l*T+u*E,r[2]=h*m+d*g+f*v,r[5]=h*_+d*M+f*S,r[8]=h*p+d*T+f*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,h=o*a-l*r,d=c*r-s*a,f=t*u+n*h+i*d;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=h*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Vr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Hu.makeScale(e,t)),this}rotate(e){return Vr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Hu.makeRotation(-e)),this}translate(e,t){return Vr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Hu.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Hu=new We,V0=new We().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),$0=new We().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function UM(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Vi(r.r),r.g=Vi(r.g),r.b=Vi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=Ts(r.r),r.g=Ts(r.g),r.b=Ts(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Vr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Vr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:V0,fromXYZ:$0,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:V0,fromXYZ:$0,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var Ke=UM();function Vi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Ts(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ds;class dd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(ds===void 0)ds=As("canvas");ds.width=e.width,ds.height=e.height;let i=ds.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ds}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=As("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Vi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Vi(t[n]/255)*255);else t[n]=Vi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var FM=0;class qo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:FM++}),this.uuid=Qn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Vu(i[s].image));else r.push(Vu(i[s]))}else r=Vu(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Vu(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return dd.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ue("Texture: Unable to serialize Texture."),{}}var zM=0,$u=new z;class Ot extends ii{constructor(e=Ot.DEFAULT_IMAGE,t=Ot.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Ot.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:zM++}),this.uuid=Qn(),this.name="",this.source=new qo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new We,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize($u).x}get height(){return this.source.getSize($u).y}get depth(){return this.source.getSize($u).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=300;Ot.DEFAULT_ANISOTROPY=1;class pt{static{pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-h)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+h)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+d+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let M=(c+1)/2,T=(d+1)/2,v=(p+1)/2,S=(l+h)/4,E=(u+m)/4,R=(f+_)/4;if(M>T&&M>v)if(M<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(M),i=S/n,r=E/n;else if(T>v)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=S/i,r=R/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=E/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(h-l)*(h-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(h-l)/g,this.w=Math.acos((c+d+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fd extends ii{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Ot(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new qo(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Cn extends fd{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Yc extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class pd extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Xe{static{Xe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=h,p[3]=d,p[7]=f,p[11]=m,p[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Xe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/fs.setFromMatrixColumn(e,0).length(),r=1/fs.setFromMatrixColumn(e,1).length(),s=1/fs.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=d+f*c,t[5]=h-m*c,t[9]=-o*a,t[2]=m-h*c,t[6]=f+d*c,t[10]=s*a}else if(e.order==="YXZ"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h+m*o,t[4]=f*o-d,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=d*o-f,t[6]=m+h*o,t[10]=s*a}else if(e.order==="ZXY"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h-m*o,t[4]=-s*u,t[8]=f+d*o,t[1]=d+f*o,t[5]=s*l,t[9]=m-h*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-d,t[8]=h*c+m,t[1]=a*u,t[5]=m*c+h,t[9]=d*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-h*u,t[8]=f*u+d,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=d*u+f,t[10]=h-m*u}else if(e.order==="XZY"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=h*u+m,t[5]=s*l,t[9]=d*u-f,t[2]=f*u-d,t[6]=o*l,t[10]=m*u+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kM,e,BM)}lookAt(e,t,n){let i=this.elements;if(Tn.subVectors(e,t),Tn.lengthSq()===0)Tn.z=1;if(Tn.normalize(),sr.crossVectors(n,Tn),sr.lengthSq()===0){if(Math.abs(n.z)===1)Tn.x+=0.0001;else Tn.z+=0.0001;Tn.normalize(),sr.crossVectors(n,Tn)}return sr.normalize(),lc.crossVectors(Tn,sr),i[0]=sr.x,i[4]=lc.x,i[8]=Tn.x,i[1]=sr.y,i[5]=lc.y,i[9]=Tn.y,i[2]=sr.z,i[6]=lc.z,i[10]=Tn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],M=n[7],T=n[11],v=n[15],S=i[0],E=i[4],R=i[8],x=i[12],w=i[1],G=i[5],C=i[9],D=i[13],ee=i[2],L=i[6],W=i[10],B=i[14],P=i[3],J=i[7],H=i[11],q=i[15];return r[0]=s*S+o*w+a*ee+c*P,r[4]=s*E+o*G+a*L+c*J,r[8]=s*R+o*C+a*W+c*H,r[12]=s*x+o*D+a*B+c*q,r[1]=l*S+u*w+h*ee+d*P,r[5]=l*E+u*G+h*L+d*J,r[9]=l*R+u*C+h*W+d*H,r[13]=l*x+u*D+h*B+d*q,r[2]=f*S+m*w+_*ee+p*P,r[6]=f*E+m*G+_*L+p*J,r[10]=f*R+m*C+_*W+p*H,r[14]=f*x+m*D+_*B+p*q,r[3]=g*S+M*w+T*ee+v*P,r[7]=g*E+M*G+T*L+v*J,r[11]=g*R+M*C+T*W+v*H,r[15]=g*x+M*D+T*B+v*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],h=e[10],d=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*d-c*h,M=o*d-c*u,T=o*h-a*u,v=s*d-c*l,S=s*h-a*l,E=s*u-o*l;return t*(m*g-_*M+p*T)-n*(f*g-_*v+p*S)+i*(f*M-m*v+p*E)-r*(f*T-m*S+_*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,M=t*a-i*s,T=t*c-r*s,v=n*a-i*o,S=n*c-r*o,E=i*c-r*a,R=l*m-u*f,x=l*_-h*f,w=l*p-d*f,G=u*_-h*m,C=u*p-d*m,D=h*p-d*_,ee=g*D-M*C+T*G+v*w-S*x+E*R;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let L=1/ee;return e[0]=(o*D-a*C+c*G)*L,e[1]=(i*C-n*D-r*G)*L,e[2]=(m*E-_*S+p*v)*L,e[3]=(h*S-u*E-d*v)*L,e[4]=(a*w-s*D-c*x)*L,e[5]=(t*D-i*w+r*x)*L,e[6]=(_*T-f*E-p*M)*L,e[7]=(l*E-h*T+d*M)*L,e[8]=(s*C-o*w+c*R)*L,e[9]=(n*w-t*C-r*R)*L,e[10]=(f*S-m*T+p*g)*L,e[11]=(u*T-l*S-d*g)*L,e[12]=(o*x-s*G-a*R)*L,e[13]=(t*G-n*x+i*R)*L,e[14]=(m*M-f*v-_*g)*L,e[15]=(l*v-u*M+h*g)*L,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,h=r*c,d=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,M=a*l,T=a*u,{x:v,y:S,z:E}=n;return i[0]=(1-(m+p))*v,i[1]=(d+T)*v,i[2]=(f-M)*v,i[3]=0,i[4]=(d-T)*S,i[5]=(1-(h+p))*S,i[6]=(_+g)*S,i[7]=0,i[8]=(f+M)*E,i[9]=(_-g)*E,i[10]=(1-(h+m))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=fs.set(i[0],i[1],i[2]).length(),o=fs.set(i[4],i[5],i[6]).length(),a=fs.set(i[8],i[9],i[10]).length();if(r<0)s=-s;qn.copy(this);let c=1/s,l=1/o,u=1/a;return qn.elements[0]*=c,qn.elements[1]*=c,qn.elements[2]*=c,qn.elements[4]*=l,qn.elements[5]*=l,qn.elements[6]*=l,qn.elements[8]*=u,qn.elements[9]*=u,qn.elements[10]*=u,t.setFromRotationMatrix(qn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),d=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=u,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var fs=new z,qn=new Xe,kM=new z(0,0,0),BM=new z(1,1,1),sr=new z,lc=new z,Tn=new z,W0=new Xe,Z0=new Yt;class xi{constructor(e=0,t=0,n=0,i=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],h=i[6],d=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,d),this._z=Math.atan2(-s,r);else this._x=Math.atan2(h,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Je(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,d),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(Je(h,-1,1)),Math.abs(h)<0.9999999)this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(h,d),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Je(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,d);break;case"XZY":if(this._z=Math.asin(-Je(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(h,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,d),this._y=0;break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return W0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(W0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Z0.setFromEuler(this),this.setFromQuaternion(Z0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xi.DEFAULT_ORDER="XYZ";class Kc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var GM=0,X0=new z,ps=new Yt,Fi=new Xe,uc=new z,Po=new z,HM=new z,VM=new Yt,j0=new z(1,0,0),q0=new z(0,1,0),Y0=new z(0,0,1),K0={type:"added"},$M={type:"removed"},ms={type:"childadded",child:null},Wu={type:"childremoved",child:null};class _t extends ii{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:GM++}),this.uuid=Qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();let e=new z,t=new xi,n=new Yt,i=new z(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Xe},normalMatrix:{value:new We}}),this.matrix=new Xe,this.matrixWorld=new Xe,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Kc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ps.setFromAxisAngle(e,t),this.quaternion.multiply(ps),this}rotateOnWorldAxis(e,t){return ps.setFromAxisAngle(e,t),this.quaternion.premultiply(ps),this}rotateX(e){return this.rotateOnAxis(j0,e)}rotateY(e){return this.rotateOnAxis(q0,e)}rotateZ(e){return this.rotateOnAxis(Y0,e)}translateOnAxis(e,t){return X0.copy(e).applyQuaternion(this.quaternion),this.position.add(X0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(j0,e)}translateY(e){return this.translateOnAxis(q0,e)}translateZ(e){return this.translateOnAxis(Y0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)uc.copy(e);else uc.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Po.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Fi.lookAt(Po,uc,this.up);else Fi.lookAt(uc,Po,this.up);if(this.quaternion.setFromRotationMatrix(Fi),i)Fi.extractRotation(i.matrixWorld),ps.setFromRotationMatrix(Fi),this.quaternion.premultiply(ps.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ve("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(K0),ms.child=e,this.dispatchEvent(ms),ms.child=null;else Ve("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent($M),Wu.child=e,this.dispatchEvent(Wu),Wu.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Fi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Fi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Fi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(K0),ms.child=e,this.dispatchEvent(ms),ms.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Po,e,HM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Po,VM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),h=s(e.skeletons),d=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(h.length>0)n.skeletons=h;if(d.length>0)n.animations=d;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}_t.DEFAULT_UP=new z(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class gi extends _t{constructor(){super();this.isGroup=!0,this.type="Group"}}var WM={type:"move"};class Yo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new z;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new z,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],h=l.position.distanceTo(u.position),d=0.02,f=0.005;if(c.inputState.pinching&&h>d+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&h<=d-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(WM)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new gi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var bv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},or={h:0,s:0,l:0},hc={h:0,s:0,l:0};function Zu(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Ge{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ke.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Ke.workingColorSpace){if(e=hd(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Zu(s,r,e+0.3333333333333333),this.g=Zu(s,r,e),this.b=Zu(s,r,e-0.3333333333333333)}return Ke.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ue("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=bv[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ue("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}copyLinearToSRGB(e){return this.r=Ts(e.r),this.g=Ts(e.g),this.b=Ts(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return Ke.workingToColorSpace(an.copy(this),e),Math.round(Je(an.r*255,0,255))*65536+Math.round(Je(an.g*255,0,255))*256+Math.round(Je(an.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(an.copy(this),t);let{r:n,g:i,b:r}=an,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e="srgb"){Ke.workingToColorSpace(an.copy(this),e);let{r:t,g:n,b:i}=an;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(or),this.setHSL(or.h+e,or.s+t,or.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(or),e.getHSL(hc);let n=Bo(or.h,hc.h,t),i=Bo(or.s,hc.s,t),r=Bo(or.l,hc.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var an=new Ge;Ge.NAMES=bv;class zs extends _t{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xi,this.environmentIntensity=1,this.environmentRotation=new xi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Yn=new z,zi=new z,Xu=new z,ki=new z,gs=new z,_s=new z,J0=new z,ju=new z,qu=new z,Yu=new z,Ku=new pt,Ju=new pt,Qu=new pt;class kn{constructor(e=new z,t=new z,n=new z){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Yn.subVectors(e,t),i.cross(Yn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Yn.subVectors(i,t),zi.subVectors(n,t),Xu.subVectors(e,t);let s=Yn.dot(Yn),o=Yn.dot(zi),a=Yn.dot(Xu),c=zi.dot(zi),l=zi.dot(Xu),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let h=1/u,d=(c*a-o*l)*h,f=(s*l-o*a)*h;return r.set(1-d-f,f,d)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,ki)===null)return!1;return ki.x>=0&&ki.y>=0&&ki.x+ki.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,ki)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,ki.x),a.addScaledVector(s,ki.y),a.addScaledVector(o,ki.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Ku.setScalar(0),Ju.setScalar(0),Qu.setScalar(0),Ku.fromBufferAttribute(e,t),Ju.fromBufferAttribute(e,n),Qu.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Ku,r.x),s.addScaledVector(Ju,r.y),s.addScaledVector(Qu,r.z),s}static isFrontFacing(e,t,n,i){return Yn.subVectors(n,t),zi.subVectors(e,t),Yn.cross(zi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Yn.subVectors(this.c,this.b),zi.subVectors(this.a,this.b),Yn.cross(zi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return kn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;gs.subVectors(i,n),_s.subVectors(r,n),ju.subVectors(e,n);let a=gs.dot(ju),c=_s.dot(ju);if(a<=0&&c<=0)return t.copy(n);qu.subVectors(e,i);let l=gs.dot(qu),u=_s.dot(qu);if(l>=0&&u<=l)return t.copy(i);let h=a*u-l*c;if(h<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(gs,s);Yu.subVectors(e,r);let d=gs.dot(Yu),f=_s.dot(Yu);if(f>=0&&d<=f)return t.copy(r);let m=d*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(_s,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return J0.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(J0,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(gs,s).addScaledVector(_s,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Vt{constructor(e=new z(1/0,1/0,1/0),t=new z(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,Kn);else Kn.fromBufferAttribute(r,s);Kn.applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();dc.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();dc.copy(n.boundingBox)}dc.applyMatrix4(e.matrixWorld),this.union(dc)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Lo),fc.subVectors(this.max,Lo),xs.subVectors(e.a,Lo),vs.subVectors(e.b,Lo),ys.subVectors(e.c,Lo),ar.subVectors(vs,xs),cr.subVectors(ys,vs),kr.subVectors(xs,ys);let t=[0,-ar.z,ar.y,0,-cr.z,cr.y,0,-kr.z,kr.y,ar.z,0,-ar.x,cr.z,0,-cr.x,kr.z,0,-kr.x,-ar.y,ar.x,0,-cr.y,cr.x,0,-kr.y,kr.x,0];if(!eh(t,xs,vs,ys,fc))return!1;if(t=[1,0,0,0,1,0,0,0,1],!eh(t,xs,vs,ys,fc))return!1;return pc.crossVectors(ar,cr),t=[pc.x,pc.y,pc.z],eh(t,xs,vs,ys,fc)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var Bi=[new z,new z,new z,new z,new z,new z,new z,new z],Kn=new z,dc=new Vt,xs=new z,vs=new z,ys=new z,ar=new z,cr=new z,kr=new z,Lo=new z,fc=new z,pc=new z,Br=new z;function eh(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Br.fromArray(e,s);let a=r.x*Math.abs(Br.x)+r.y*Math.abs(Br.y)+r.z*Math.abs(Br.z),c=t.dot(Br),l=n.dot(Br),u=i.dot(Br);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Gt=new z,mc=new ke,ZM=0;class Kt extends ii{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ZM++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)mc.fromBufferAttribute(this,t),mc.applyMatrix3(e),this.setXY(t,mc.x,mc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix3(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Jn(t,this.array);return t}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Jn(t,this.array);return t}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Jn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Jn(t,this.array);return t}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Jc extends Kt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Qc extends Kt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vn extends Kt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var XM=new Vt,No=new z,th=new z;class In{constructor(e=new z,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else XM.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;No.subVectors(e,this.center);let t=No.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(No,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else th.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(No.copy(e.center).add(th)),this.expandByPoint(No.copy(e.center).sub(th));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var jM=0,Fn=new Xe,nh=new _t,bs=new z,An=new Vt,Do=new Vt,qt=new z;class ln extends ii{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=Qn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((xM(e))?Qc:Jc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new We().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return nh.lookAt(e),nh.updateMatrix(),this.applyMatrix4(nh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(bs).negate(),this.translate(bs.x,bs.y,bs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new vn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ue("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Vt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new z(-1/0,-1/0,-1/0),new z(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(An.setFromBufferAttribute(r),this.morphTargetsRelative)qt.addVectors(this.boundingBox.min,An.min),this.boundingBox.expandByPoint(qt),qt.addVectors(this.boundingBox.max,An.max),this.boundingBox.expandByPoint(qt);else this.boundingBox.expandByPoint(An.min),this.boundingBox.expandByPoint(An.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ve('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new In;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new z,1/0);return}if(e){let n=this.boundingSphere.center;if(An.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Do.setFromBufferAttribute(o),this.morphTargetsRelative)qt.addVectors(An.min,Do.min),An.expandByPoint(qt),qt.addVectors(An.max,Do.max),An.expandByPoint(qt);else An.expandByPoint(Do.min),An.expandByPoint(Do.max)}An.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)qt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(qt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(qt.fromBufferAttribute(o,c),a)bs.fromBufferAttribute(e,c),qt.add(bs);i=Math.max(i,n.distanceToSquared(qt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ve('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ve("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Kt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new z,a[R]=new z;let c=new z,l=new z,u=new z,h=new ke,d=new ke,f=new ke,m=new z,_=new z;function p(R,x,w){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,w),h.fromBufferAttribute(r,R),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,w),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let G=1/(d.x*f.y-f.x*d.y);if(!isFinite(G))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(G),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(G),o[R].add(m),o[x].add(m),o[w].add(m),a[R].add(_),a[x].add(_),a[w].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:G,count:C}=w;for(let D=G,ee=G+C;D<ee;D+=3)p(e.getX(D+0),e.getX(D+1),e.getX(D+2))}let M=new z,T=new z,v=new z,S=new z;function E(R){v.fromBufferAttribute(i,R),S.copy(v);let x=o[R];M.copy(x),M.sub(v.multiplyScalar(v.dot(x))).normalize(),T.crossVectors(S,x);let G=T.dot(a[R])<0?-1:1;s.setXYZW(R,M.x,M.y,M.z,G)}for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:G,count:C}=w;for(let D=G,ee=G+C;D<ee;D+=3)E(e.getX(D+0)),E(e.getX(D+1)),E(e.getX(D+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Kt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new z,r=new z,s=new z,o=new z,a=new z,c=new z,l=new z,u=new z;if(e)for(let h=0,d=e.count;h<d;h+=3){let f=e.getX(h+0),m=e.getX(h+1),_=e.getX(h+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(h+0,l.x,l.y,l.z),n.setXYZ(h+1,l.x,l.y,l.z),n.setXYZ(h+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)qt.fromBufferAttribute(e,t),qt.normalize(),e.setXYZ(t,qt.x,qt.y,qt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,h=new c.constructor(a.length*l),d=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)d=a[m]*o.data.stride+o.offset;else d=a[m]*l;for(let p=0;p<l;p++)h[f++]=c[d++]}return new Kt(h,l,u)}if(this.index===null)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new ln,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let h=c[l],d=e(h,n);a.push(d)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u];l.push(d.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ko{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var gn=new z;class ks{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Jn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Jn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Jn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Jn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Go("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Kt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new ks(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Go("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var ih=new z,qM=new z,YM=new We;class zn{constructor(e=new z(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=ih.subVectors(n,t).cross(qM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(ih),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||YM.getNormalMatrix(e),i=this.coplanarPoint(ih).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var KM=0;class yn extends ii{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:KM++}),this.uuid=Qn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ge(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ue(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Ge().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new zn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new ke().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var Gi=new z,rh=new z,gc=new z,_c=new z;class _r{constructor(e=new z,t=new z(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Gi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Gi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Gi.copy(this.origin).addScaledVector(this.direction,t),Gi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){rh.copy(e).add(t).multiplyScalar(0.5),gc.copy(t).sub(e).normalize(),_c.copy(this.origin).sub(rh);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(gc),o=_c.dot(this.direction),a=-_c.dot(gc),c=_c.lengthSq(),l=Math.abs(1-s*s),u,h,d,f;if(l>0)if(u=s*a-o,h=s*o-a,f=r*l,u>=0)if(h>=-f)if(h<=f){let m=1/l;u*=m,h*=m,d=u*(u+s*h+2*o)+h*(s*u+h+2*a)+c}else h=r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else h=-r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else if(h<=-f)u=Math.max(0,-(-s*r+o)),h=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else if(h<=f)u=0,h=Math.min(Math.max(-r,-a),r),d=h*(h+2*a)+c;else u=Math.max(0,-(s*r+o)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else h=s>0?-r:r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(rh).addScaledVector(gc,h);return d}intersectSphere(e,t){if(e.radius<0)return null;Gi.subVectors(e.center,this.origin);let n=Gi.dot(this.direction),i=Gi.dot(Gi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;if(c>=0)n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c;else n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c;if(l>=0)r=(e.min.y-h.y)*l,s=(e.max.y-h.y)*l;else r=(e.max.y-h.y)*l,s=(e.min.y-h.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u;else o=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Gi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,h=e.y-s.y,d=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,M=n.z-s.z,T=Math.abs(a),v=Math.abs(c),S=Math.abs(l),E,R,x,w,G,C,D,ee,L,W,B,P;if(T>=v&&T>=S)if(x=a,C=u,L=f,P=p,a>=0)E=c,R=l,w=h,G=d,D=m,ee=_,W=g,B=M;else E=l,R=c,w=d,G=h,D=_,ee=m,W=M,B=g;else if(v>=S)if(x=c,C=h,L=m,P=g,c>=0)E=l,R=a,w=d,G=u,D=_,ee=f,W=M,B=p;else E=a,R=l,w=u,G=d,D=f,ee=_,W=p,B=M;else if(x=l,C=d,L=_,P=M,l>=0)E=a,R=c,w=u,G=h,D=f,ee=m,W=p,B=g;else E=c,R=a,w=h,G=u,D=m,ee=f,W=g,B=p;if(x===0)return null;let J=E/x,H=R/x,q=1/x,Q=w-J*C,ge=G-H*C,he=D-J*L,de=ee-H*L,fe=W-J*P,I=B-H*P,V=fe*de-I*he,j=Q*I-ge*fe,re=he*ge-de*Q;if(i){if(V<0||j<0||re<0)return null}else if((V<0||j<0||re<0)&&(V>0||j>0||re>0))return null;let oe=V+j+re;if(oe===0)return null;let ue=q*(V*C+j*L+re*P);if(oe>0?ue<0:ue>0)return null;return this.at(ue/oe,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Q0=new Xe,Gr=new _r,xc=new In,ex=new z,vc=new z,yc=new z,bc=new z,sh=new z,Sc=new z,tx=new z,wc=new z;class Mt extends _t{constructor(e=new ln,t=new wi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){Sc.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(sh.fromBufferAttribute(u,e),s)Sc.addScaledVector(sh,l);else Sc.addScaledVector(sh.sub(t),l)}t.add(Sc)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(xc.copy(n.boundingSphere),xc.applyMatrix4(r),Gr.copy(e.ray).recast(e.near),xc.containsPoint(Gr.origin)===!1){if(Gr.intersectSphere(xc,ex)===null)return;if(Gr.origin.distanceToSquared(ex)>(e.far-e.near)**2)return}if(Q0.copy(r).invert(),Gr.copy(e.ray).applyMatrix4(Q0),n.boundingBox!==null){if(Gr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Gr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:h,drawRange:d}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=o.getX(T),E=o.getX(T+1),R=o.getX(T+2);if(i=Mc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),M=o.getX(_+1),T=o.getX(_+2);if(i=Mc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=T,E=T+1,R=T+2;if(i=Mc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=_,M=_+1,T=_+2;if(i=Mc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function JM(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;wc.copy(a),wc.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(wc);if(l<n.near||l>n.far)return null;return{distance:l,point:wc.clone(),object:e}}function Mc(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,vc),e.getVertexPosition(c,yc),e.getVertexPosition(l,bc);let u=JM(e,t,n,i,vc,yc,bc,tx);if(u){let h=new z;if(kn.getBarycoord(tx,vc,yc,bc,h),r)u.uv=kn.getInterpolatedAttribute(r,a,c,l,h,new ke);if(s)u.uv1=kn.getInterpolatedAttribute(s,a,c,l,h,new ke);if(o){if(u.normal=kn.getInterpolatedAttribute(o,a,c,l,h,new z),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let d={a,b:c,c:l,normal:new z,materialIndex:0};kn.getNormal(vc,yc,bc,d.normal),u.face=d,u.barycoord=h}return u}var Oo=new pt,nx=new pt,ix=new pt,QM=new pt,rx=new Xe,Ec=new z,oh=new In,sx=new Xe,ah=new _r;class el extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Xe,this.bindMatrixInverse=new Xe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Vt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ec),this.boundingBox.expandByPoint(Ec)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new In;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ec),this.boundingSphere.expandByPoint(Ec)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(oh.copy(this.boundingSphere),oh.applyMatrix4(i),e.ray.intersectsSphere(oh)===!1)return;if(sx.copy(i).invert(),ah.copy(e.ray).applyMatrix4(sx),this.boundingBox!==null){if(ah.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,ah)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ue("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(nx.fromBufferAttribute(i.attributes.skinIndex,e),ix.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Oo.copy(t),t.set(0,0,0,0);else Oo.set(...t,1),t.set(0,0,0);Oo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=ix.getComponent(r);if(s!==0){let o=nx.getComponent(r);rx.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(QM.copy(Oo).applyMatrix4(rx),s)}}if(t.isVector4)t.w=Oo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Jo extends _t{constructor(){super();this.isBone=!0,this.type="Bone"}}class Qo extends Ot{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,h){super(null,s,o,a,c,l,i,r,u,h);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var ox=new Xe,eE=new Xe;class ea{constructor(e=[],t=[]){this.uuid=Qn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ue("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Xe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Xe;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:eE;ox.multiplyMatrices(o,t[r]),ox.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new ea(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Qo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ue("Skeleton: No bone found with UUID:",r),s=new Jo;this.bones.push(s),this.boneInverses.push(new Xe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class hr extends Kt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var Ss=new Xe,ax=new Xe,Tc=[],cx=new Vt,tE=new Xe,Uo=new Mt,Fo=new In;class Bs extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new hr(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tE)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Vt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ss),cx.copy(e.boundingBox).applyMatrix4(Ss),this.boundingBox.union(cx)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new In;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ss),Fo.copy(e.boundingSphere).applyMatrix4(Ss),this.boundingSphere.union(Fo)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Uo.geometry=this.geometry,Uo.material=this.material,Uo.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Fo.copy(this.boundingSphere),Fo.applyMatrix4(n),e.ray.intersectsSphere(Fo)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Ss),ax.multiplyMatrices(n,Ss),Uo.matrixWorld=ax,Uo.raycast(e,Tc);for(let s=0,o=Tc.length;s<o;s++){let a=Tc[s];a.instanceId=r,a.object=this,t.push(a)}Tc.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new hr(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Qo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Hr=new In,nE=new ke(0.5,0.5),Ac=new z;class ta{constructor(e=new zn,t=new zn,n=new zn,i=new zn,r=new zn,s=new zn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],M=r[13],T=r[14],v=r[15];if(i[0].setComponents(c-s,d-l,p-f,v-g).normalize(),i[1].setComponents(c+s,d+l,p+f,v+g).normalize(),i[2].setComponents(c+o,d+u,p+m,v+M).normalize(),i[3].setComponents(c-o,d-u,p-m,v-M).normalize(),n)i[4].setComponents(a,h,_,T).normalize(),i[5].setComponents(c-a,d-h,p-_,v-T).normalize();else if(i[4].setComponents(c-a,d-h,p-_,v-T).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,v+T).normalize();else if(t===2001)i[5].setComponents(a,h,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Hr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Hr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hr)}intersectsSprite(e){Hr.center.set(0,0,0);let t=nE.distanceTo(e.center);return Hr.radius=0.7071067811865476+t,Hr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ac.x=i.normal.x>0?e.max.x:e.min.x,Ac.y=i.normal.y>0?e.max.y:e.min.y,Ac.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ac)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class na extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Oc=new z,Uc=new z,lx=new Xe,zo=new _r,Rc=new In,ch=new z,ux=new z;class xr extends _t{constructor(e=new ln,t=new na){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Oc.fromBufferAttribute(t,i-1),Uc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Oc.distanceTo(Uc);e.setAttribute("lineDistance",new vn(n,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Rc.copy(n.boundingSphere),Rc.applyMatrix4(i),Rc.radius+=r,e.ray.intersectsSphere(Rc)===!1)return;lx.copy(i).invert(),zo.copy(e.ray).applyMatrix4(lx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),M=Cc(this,e,zo,a,p,g,m);if(M)t.push(M)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=Cc(this,e,zo,a,m,_,f-1);if(p)t.push(p)}}else{let d=Math.max(0,s.start),f=Math.min(h.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=Cc(this,e,zo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Cc(this,e,zo,a,f-1,d,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Cc(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Oc.fromBufferAttribute(a,r),Uc.fromBufferAttribute(a,s),n.distanceSqToSegment(Oc,Uc,ch,ux)>i)return;ch.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ch);if(l<t.near||l>t.far)return;return{distance:l,point:ux.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var hx=new z,dx=new z;class tl extends xr{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)hx.fromBufferAttribute(t,i),dx.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+hx.distanceTo(dx);e.setAttribute("lineDistance",new vn(n,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class nl extends xr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ia extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ge(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var fx=new Xe,hh=new _r,Ic=new In,Pc=new z;class Gs extends _t{constructor(e=new ln,t=new ia){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ic.copy(n.boundingSphere),Ic.applyMatrix4(i),Ic.radius+=r,e.ray.intersectsSphere(Ic)===!1)return;fx.copy(i).invert(),hh.copy(e.ray).applyMatrix4(fx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let h=Math.max(0,s.start),d=Math.min(c.count,s.start+s.count);for(let f=h,m=d;f<m;f++){let _=c.getX(f);Pc.fromBufferAttribute(u,_),px(Pc,_,a,i,e,t,this)}}else{let h=Math.max(0,s.start),d=Math.min(u.count,s.start+s.count);for(let f=h,m=d;f<m;f++)Pc.fromBufferAttribute(u,f),px(Pc,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function px(e,t,n,i,r,s,o){let a=hh.distanceSqToPoint(e);if(a<n){let c=new z;hh.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class il extends Ot{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Kr extends Ot{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:u};super(h,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class md extends Kr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class rl extends Ot{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class vr extends ln{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],h=0,d=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new vn(c,3)),this.setAttribute("normal",new vn(l,3)),this.setAttribute("uv",new vn(u,2));function f(m,_,p,g,M,T,v,S,E,R,x){let w=T/E,G=v/R,C=T/2,D=v/2,ee=S/2,L=E+1,W=R+1,B=0,P=0,J=new z;for(let H=0;H<W;H++){let q=H*G-D;for(let Q=0;Q<L;Q++){let ge=Q*w-C;J[m]=ge*g,J[_]=q*M,J[p]=ee,c.push(J.x,J.y,J.z),J[m]=0,J[_]=0,J[p]=S>0?1:-1,l.push(J.x,J.y,J.z),u.push(Q/E),u.push(1-H/R),B+=1}}for(let H=0;H<R;H++)for(let q=0;q<E;q++){let Q=h+q+L*H,ge=h+q+L*(H+1),he=h+(q+1)+L*(H+1),de=h+(q+1)+L*H;a.push(Q,ge,de),a.push(ge,he,de),P+=6}o.addGroup(d,P,x),d+=P,h+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ra extends ln{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,h=t/a,d=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*h-s;for(let M=0;M<c;M++){let T=M*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(M/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let M=g+c*p,T=g+c*(p+1),v=g+1+c*(p+1),S=g+1+c*p;d.push(M,T,S),d.push(T,v,S)}this.setIndex(d),this.setAttribute("position",new vn(f,3)),this.setAttribute("normal",new vn(m,3)),this.setAttribute("uv",new vn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ra(e.width,e.height,e.widthSegments,e.heightSegments)}}function Jr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(mx(r))if(r.isRenderTargetTexture)Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(mx(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function un(e){let t={};for(let n=0;n<e.length;n++){let i=Jr(e[n]);for(let r in i)t[r]=i[r]}return t}function mx(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function iE(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function gd(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return Ke.workingColorSpace}var Sv={clone:Jr,merge:un},rE=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,iE=`void main() {
+}`,sE=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Gn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=nE,this.fragmentShader=iE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Kr(e.uniforms),this.uniformsGroups=tE(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new He().setHex(i.value);break;case"v2":this.uniforms[n].value=new Be().fromArray(i.value);break;case"v3":this.uniforms[n].value=new F().fromArray(i.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new We().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Xe().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class gd extends Gn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class $i extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new He(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pn extends $i{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Be(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new He(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new He(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new He(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class il extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class _d extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class xd extends yn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function lr(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Lc(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function rE(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function mx(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function sE(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Wi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class vd extends Wi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-h*_+2*h*m-h*f,g=(1+h)*_+(-1.5-2*h)*m+(-0.5+h)*f+1,M=(-1-d)*_+(1.5+d)*m+0.5*f,T=d*_-d*m;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+g*s[c+v]+M*s[a+v]+T*s[u+v];return r}}class rl extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let h=0;h!==o;++h)r[h]=s[c+h]*u+s[a+h]*l;return r}}class yd extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class bd extends Wi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let h=o*2,d=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=d*h+f*2,g=u[p],M=u[p+1],T=e*h+f*2,v=l[T],S=l[T+1],E=aE(n,t,g,v,i);r[f]=Sv(E,m,M,S,_)}return r}}function Sv(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function oE(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function aE(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=Sv(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=oE(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Ln{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=lr(t,this.TimeBufferType),this.values=lr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:lr(e.times,Array),values:lr(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Lc(e.settings))n.settings={inTangents:lr(e.settings.inTangents,Array),outTangents:lr(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new yd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new rl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new bd(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ue("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Lc(this.settings))gx(this.settings.inTangents,e),gx(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)$e("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)$e("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){$e("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){$e("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(_M(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){$e("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,h=u-n,d=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[h+f]||m!==t[d+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,h=s*n;for(let d=0;d!==n;++d)t[h+d]=t[u+d]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Lc(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function gx(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Ln.prototype.ValueTypeName="";Ln.prototype.TimeBufferType=Float32Array;Ln.prototype.ValueBufferType=Float32Array;Ln.prototype.DefaultInterpolation=2301;class vr extends Ln{constructor(e,t,n){super(e,t,n)}}vr.prototype.ValueTypeName="bool";vr.prototype.ValueBufferType=Array;vr.prototype.DefaultInterpolation=2300;vr.prototype.InterpolantFactoryMethodLinear=void 0;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class sl extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}sl.prototype.ValueTypeName="color";class yr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}yr.prototype.ValueTypeName="number";class Sd extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Yt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class br extends Ln{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Sd(this.times,this.values,this.getValueSize(),e)}}br.prototype.ValueTypeName="quaternion";br.prototype.InterpolantFactoryMethodSmooth=void 0;class Sr extends Ln{constructor(e,t,n){super(e,t,n)}}Sr.prototype.ValueTypeName="string";Sr.prototype.ValueBufferType=Array;Sr.prototype.DefaultInterpolation=2300;Sr.prototype.InterpolantFactoryMethodLinear=void 0;Sr.prototype.InterpolantFactoryMethodSmooth=void 0;class Jr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}Jr.prototype.ValueTypeName="vector";class Rs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Qn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(lE(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Ln.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=rE(a);if(a=mx(a,1,l),c=mx(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new yr(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],h=i[u];if(!h)i[u]=h=[];h.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function cE(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yr;case"vector":case"vector2":case"vector3":case"vector4":return Jr;case"color":return sl;case"quaternion":return br;case"bool":case"boolean":return vr;case"string":return Sr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function lE(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=cE(e.type);if(e.times===void 0){let i=[],r=[];sE(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Lc(e.settings))n.settings={inTangents:lr(e.settings.inTangents,Float32Array),outTangents:lr(e.settings.outTangents,Float32Array)};return n}var _i={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(_x(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(_x(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function _x(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class na{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,h=c.length;u<h;u+=2){let d=c[u],f=c[u+1];if(d.global)d.lastIndex=0;if(d.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var wv=new na;class Zi{constructor(e){if(this.manager=e!==void 0?e:wv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Zi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Gi={};class Mv extends Error{constructor(e,t){super(e);this.response=t}}class ia extends Zi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=_i.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Gi[e]!==void 0){Gi[e].push({onLoad:t,onProgress:n,onError:i});return}Gi[e]=[],Gi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ue("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Gi[e],u=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=h?parseInt(h):0,f=d!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:M,value:T})=>{if(M)p.close();else{m+=T.byteLength;let v=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let S=0,E=l.length;S<E;S++){let R=l[S];if(R.onProgress)R.onProgress(v)}p.enqueue(T),g()}},(M)=>{p.error(M)})}}});return new Response(_)}else throw new Mv(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then((f)=>d.decode(f))}}}).then((c)=>{_i.add(`file:${e}`,c);let l=Gi[e];delete Gi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onLoad)d.onLoad(c)}}).catch((c)=>{let l=Gi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Gi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onError)d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Ss=new WeakMap;class wd extends Zi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Ss.get(s);if(u===void 0)u=[],Ss.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Ts("img");function a(){if(l(),t)t(this);let u=Ss.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}Ss.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);_i.remove(`image:${e}`);let h=Ss.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}Ss.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return _i.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class ol extends Zi{constructor(e){super(e)}load(e,t,n,i){let r=new Ot,s=new wd(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Gs extends _t{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new He(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class al extends Gs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new He(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ch=new Xe,xx=new F,vx=new F;class ra{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Be(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Xe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Jo,this._frameExtents=new Be(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;xx.setFromMatrixPosition(e.matrixWorld),t.position.copy(xx),vx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(vx),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ch.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ch,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ch)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Ic=new F,Pc=new Yt,mi=new F;class cl extends _t{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xe,this.projectionMatrix=new Xe,this.projectionMatrixInverse=new Xe,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Ic,Pc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ic,Pc,mi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ic,Pc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ic,Pc,mi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var cr=new F,yx=new Be,bx=new Be;class Ht extends cl{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=Vr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Uo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Vr*2*Math.atan(Math.tan(Uo*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){cr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(cr.x,cr.y).multiplyScalar(-e/cr.z),cr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(cr.x,cr.y).multiplyScalar(-e/cr.z)}getViewSize(e,t){return this.getViewBounds(e,yx,bx),t.subVectors(bx,yx)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Uo*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Ev extends ra{constructor(){super(new Ht(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Vr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class ll extends Gs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Ev}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class Tv extends ra{constructor(){super(new Ht(90,1,0.5,500));this.isPointLightShadow=!0}}class Hs extends Gs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Tv}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Qr extends cl{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class Av extends ra{constructor(){super(new Qr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Vs extends Gs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new Av}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class wr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var lh=new WeakMap;class ul extends Zi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ue("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ue("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(lh.has(s)===!0){if(i)i(lh.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(_i.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);lh.set(a,c),_i.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});_i.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var ws=-90,Ms=1;class Md extends _t{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ht(ws,Ms,e,t);i.layers=this.layers,this.add(i);let r=new Ht(ws,Ms,e,t);r.layers=this.layers,this.add(r);let s=new Ht(ws,Ms,e,t);s.layers=this.layers,this.add(s);let o=new Ht(ws,Ms,e,t);o.layers=this.layers,this.add(o);let a=new Ht(ws,Ms,e,t);a.layers=this.layers,this.add(a);let c=new Ht(ws,Ms,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,h,d),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Ed extends Ht{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Td{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Yt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Yt.multiplyQuaternionsFlat(e,s,e,t,e,n),Yt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Ad="\\[\\]\\.:\\/",uE=new RegExp("["+Ad+"]","g"),Rd="[^"+Ad+"]",hE="[^"+Ad.replace("\\.","")+"]",dE=/((?:WC+[\/:])*)/.source.replace("WC",Rd),fE=/(WCOD+)?/.source.replace("WCOD",hE),pE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rd),mE=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rd),gE=new RegExp("^"+dE+fE+pE+mE+"$"),_E=["material","materials","bones","map"];class Rv{constructor(e,t,n){let i=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ct{constructor(e,t,n){this.path=t,this.parsedPath=n||ct.parseTrackName(t),this.node=ct.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ct(e,t,n);else return new ct.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(uE,"")}static parseTrackName(e){let t=gE.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(_E.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ct.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ue("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){$e("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){$e("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){$e("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){$e("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){$e("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){$e("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){$e("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;$e("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){$e("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){$e("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ct.Composite=Rv;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Cd{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var xE=new Float32Array(1);class hl extends ii{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let h=i[u],d=h.name,f=l[d];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,d);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new Td(ct.create(n,d,m),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,h=(e._localRoot||this._root).uuid;if(delete u[h],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new rl(new Float32Array(2),new Float32Array(2),1,xE),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Rs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Cd(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Rs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class sa{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Je(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(Je(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Id{static{Id.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class dl extends ii{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Pd(e,t,n,i){let r=vE(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function vE(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ue("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Yv(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function yE(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,h=l.byteLength,d=e.createBuffer();e.bindBuffer(c,d),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,c,l){let{array:u,updateRanges:h}=c;if(e.bindBuffer(l,a),h.length===0)e.bufferSubData(l,0,u);else{h.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<h.length;f++){let m=h[d],_=h[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++d,h[d]=_}h.length=d+1;for(let f=0,m=h.length;f<m;f++){let _=h[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var bE=`#ifdef USE_ALPHAHASH
+}`;class Gn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rE,this.fragmentShader=sE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Jr(e.uniforms),this.uniformsGroups=iE(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ge().setHex(i.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new z().fromArray(i.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new We().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Xe().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class _d extends Gn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Wi extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ge(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pn extends Wi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ge(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ge(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ge(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class sl extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xd extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class vd extends yn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function ur(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Dc(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function oE(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function gx(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function aE(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Zi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class yd extends Zi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-h*_+2*h*m-h*f,g=(1+h)*_+(-1.5-2*h)*m+(-0.5+h)*f+1,M=(-1-d)*_+(1.5+d)*m+0.5*f,T=d*_-d*m;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+g*s[c+v]+M*s[a+v]+T*s[u+v];return r}}class ol extends Zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let h=0;h!==o;++h)r[h]=s[c+h]*u+s[a+h]*l;return r}}class bd extends Zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Sd extends Zi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let h=o*2,d=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=d*h+f*2,g=u[p],M=u[p+1],T=e*h+f*2,v=l[T],S=l[T+1],E=lE(n,t,g,v,i);r[f]=wv(E,m,M,S,_)}return r}}function wv(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function cE(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function lE(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=wv(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=cE(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Ln{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ur(t,this.TimeBufferType),this.values=ur(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ur(e.times,Array),values:ur(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Dc(e.settings))n.settings={inTangents:ur(e.settings.inTangents,Array),outTangents:ur(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new bd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ol(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new yd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Sd(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ue("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Dc(this.settings))_x(this.settings.inTangents,e),_x(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ve("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ve("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ve("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ve("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(vM(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ve("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,h=u-n,d=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[h+f]||m!==t[d+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,h=s*n;for(let d=0;d!==n;++d)t[h+d]=t[u+d]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Dc(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function _x(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Ln.prototype.ValueTypeName="";Ln.prototype.TimeBufferType=Float32Array;Ln.prototype.ValueBufferType=Float32Array;Ln.prototype.DefaultInterpolation=2301;class yr extends Ln{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="bool";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}al.prototype.ValueTypeName="color";class br extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}br.prototype.ValueTypeName="number";class wd extends Zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Yt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Sr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wd(this.times,this.values,this.getValueSize(),e)}}Sr.prototype.ValueTypeName="quaternion";Sr.prototype.InterpolantFactoryMethodSmooth=void 0;class wr extends Ln{constructor(e,t,n){super(e,t,n)}}wr.prototype.ValueTypeName="string";wr.prototype.ValueBufferType=Array;wr.prototype.DefaultInterpolation=2300;wr.prototype.InterpolantFactoryMethodLinear=void 0;wr.prototype.InterpolantFactoryMethodSmooth=void 0;class Qr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}Qr.prototype.ValueTypeName="vector";class Cs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Qn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(hE(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Ln.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=oE(a);if(a=gx(a,1,l),c=gx(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new br(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],h=i[u];if(!h)i[u]=h=[];h.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function uE(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return br;case"vector":case"vector2":case"vector3":case"vector4":return Qr;case"color":return al;case"quaternion":return Sr;case"bool":case"boolean":return yr;case"string":return wr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function hE(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=uE(e.type);if(e.times===void 0){let i=[],r=[];aE(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Dc(e.settings))n.settings={inTangents:ur(e.settings.inTangents,Float32Array),outTangents:ur(e.settings.outTangents,Float32Array)};return n}var _i={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(xx(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(xx(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function xx(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class sa{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,h=c.length;u<h;u+=2){let d=c[u],f=c[u+1];if(d.global)d.lastIndex=0;if(d.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var Mv=new sa;class Xi{constructor(e){if(this.manager=e!==void 0?e:Mv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Xi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Hi={};class Ev extends Error{constructor(e,t){super(e);this.response=t}}class oa extends Xi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=_i.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Hi[e]!==void 0){Hi[e].push({onLoad:t,onProgress:n,onError:i});return}Hi[e]=[],Hi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ue("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Hi[e],u=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=h?parseInt(h):0,f=d!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:M,value:T})=>{if(M)p.close();else{m+=T.byteLength;let v=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let S=0,E=l.length;S<E;S++){let R=l[S];if(R.onProgress)R.onProgress(v)}p.enqueue(T),g()}},(M)=>{p.error(M)})}}});return new Response(_)}else throw new Ev(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then((f)=>d.decode(f))}}}).then((c)=>{_i.add(`file:${e}`,c);let l=Hi[e];delete Hi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onLoad)d.onLoad(c)}}).catch((c)=>{let l=Hi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Hi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onError)d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var ws=new WeakMap;class Md extends Xi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=ws.get(s);if(u===void 0)u=[],ws.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=As("img");function a(){if(l(),t)t(this);let u=ws.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}ws.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);_i.remove(`image:${e}`);let h=ws.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}ws.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return _i.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Hs extends Xi{constructor(e){super(e)}load(e,t,n,i){let r=new Ot,s=new Md(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Vs extends _t{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ge(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class cl extends Vs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var lh=new Xe,vx=new z,yx=new z;class aa{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Xe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ta,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;vx.setFromMatrixPosition(e.matrixWorld),t.position.copy(vx),yx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yx),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){lh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(lh,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(lh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Lc=new z,Nc=new Yt,mi=new z;class ll extends _t{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xe,this.projectionMatrix=new Xe,this.projectionMatrixInverse=new Xe,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Lc,Nc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Lc,Nc,mi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Lc,Nc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Lc,Nc,mi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var lr=new z,bx=new ke,Sx=new ke;class Ht extends ll{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=$r*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ko*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return $r*2*Math.atan(Math.tan(ko*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){lr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(lr.x,lr.y).multiplyScalar(-e/lr.z),lr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(lr.x,lr.y).multiplyScalar(-e/lr.z)}getViewSize(e,t){return this.getViewBounds(e,bx,Sx),t.subVectors(Sx,bx)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ko*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Tv extends aa{constructor(){super(new Ht(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=$r*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class ul extends Vs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Tv}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class Av extends aa{constructor(){super(new Ht(90,1,0.5,500));this.isPointLightShadow=!0}}class $s extends Vs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Av}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class es extends ll{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class Rv extends aa{constructor(){super(new es(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Ws extends Vs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new Rv}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Mr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var uh=new WeakMap;class hl extends Xi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ue("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ue("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(uh.has(s)===!0){if(i)i(uh.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(_i.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);uh.set(a,c),_i.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});_i.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Ms=-90,Es=1;class Ed extends _t{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ht(Ms,Es,e,t);i.layers=this.layers,this.add(i);let r=new Ht(Ms,Es,e,t);r.layers=this.layers,this.add(r);let s=new Ht(Ms,Es,e,t);s.layers=this.layers,this.add(s);let o=new Ht(Ms,Es,e,t);o.layers=this.layers,this.add(o);let a=new Ht(Ms,Es,e,t);a.layers=this.layers,this.add(a);let c=new Ht(Ms,Es,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,h,d),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Td extends Ht{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ad{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Yt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Yt.multiplyQuaternionsFlat(e,s,e,t,e,n),Yt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Rd="\\[\\]\\.:\\/",dE=new RegExp("["+Rd+"]","g"),Cd="[^"+Rd+"]",fE="[^"+Rd.replace("\\.","")+"]",pE=/((?:WC+[\/:])*)/.source.replace("WC",Cd),mE=/(WCOD+)?/.source.replace("WCOD",fE),gE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cd),_E=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cd),xE=new RegExp("^"+pE+mE+gE+_E+"$"),vE=["material","materials","bones","map"];class Cv{constructor(e,t,n){let i=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ct{constructor(e,t,n){this.path=t,this.parsedPath=n||ct.parseTrackName(t),this.node=ct.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ct(e,t,n);else return new ct.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(dE,"")}static parseTrackName(e){let t=xE.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(vE.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ct.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ue("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ve("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ve("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ve("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ve("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ve("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ve("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ct.Composite=Cv;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Id{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var yE=new Float32Array(1);class dl extends ii{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let h=i[u],d=h.name,f=l[d];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,d);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new Ad(ct.create(n,d,m),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,h=(e._localRoot||this._root).uuid;if(delete u[h],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new ol(new Float32Array(2),new Float32Array(2),1,yE),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Cs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Id(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Cs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class ca{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Je(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(Je(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Pd{static{Pd.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class fl extends ii{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Ld(e,t,n,i){let r=bE(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function bE(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ue("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Kv(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function SE(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,h=l.byteLength,d=e.createBuffer();e.bindBuffer(c,d),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,c,l){let{array:u,updateRanges:h}=c;if(e.bindBuffer(l,a),h.length===0)e.bufferSubData(l,0,u);else{h.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<h.length;f++){let m=h[d],_=h[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++d,h[d]=_}h.length=d+1;for(let f=0,m=h.length;f<m;f++){let _=h[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var wE=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,SE=`#ifdef USE_ALPHAHASH
+#endif`,ME=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -100,20 +100,20 @@ version 0.8.2
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,wE=`#ifdef USE_ALPHAMAP
+#endif`,EE=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,ME=`#ifdef USE_ALPHAMAP
+#endif`,TE=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,EE=`#ifdef USE_ALPHATEST
+#endif`,AE=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
-#endif`,TE=`#ifdef USE_ALPHATEST
+#endif`,RE=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,AE=`#ifdef USE_AOMAP
+#endif`,CE=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
@@ -126,10 +126,10 @@ version 0.8.2
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,RE=`#ifdef USE_AOMAP
+#endif`,IE=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,CE=`#ifdef USE_BATCHING
+#endif`,PE=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
@@ -163,15 +163,15 @@ version 0.8.2
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
-#endif`,IE=`#ifdef USE_BATCHING
+#endif`,LE=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,PE=`vec3 transformed = vec3( position );
+#endif`,NE=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,LE=`vec3 objectNormal = vec3( normal );
+#endif`,DE=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,NE=`float G_BlinnPhong_Implicit( ) {
+#endif`,OE=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -185,7 +185,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
-} // validated`,DE=`#ifdef USE_IRIDESCENCE
+} // validated`,UE=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
}
return max( I, vec3( 0.0 ) );
}
-#endif`,OE=`#ifdef USE_BUMPMAP
+#endif`,FE=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
@@ -269,7 +269,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
-#endif`,UE=`#if NUM_CLIPPING_PLANES > 0
+#endif`,zE=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
@@ -315,20 +315,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
if ( clipped ) discard;
#endif
#endif
-#endif`,FE=`#if NUM_CLIPPING_PLANES > 0
+#endif`,kE=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,zE=`#if NUM_CLIPPING_PLANES > 0
+#endif`,BE=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,kE=`#if NUM_CLIPPING_PLANES > 0
+#endif`,GE=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,BE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,HE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,GE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,VE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,HE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,$E=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,VE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,WE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
@@ -341,7 +341,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
-#endif`,$E=`#define PI 3.141592653589793
+#endif`,ZE=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
@@ -412,7 +412,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
-} // validated`,WE=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,XE=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
@@ -505,7 +505,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
-#endif`,ZE=`vec3 transformedNormal = objectNormal;
+#endif`,jE=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
@@ -531,21 +531,21 @@ transformedNormal = normalMatrix * transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
-#endif`,XE=`#ifdef USE_DISPLACEMENTMAP
+#endif`,qE=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,jE=`#ifdef USE_DISPLACEMENTMAP
+#endif`,YE=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,qE=`#ifdef USE_EMISSIVEMAP
+#endif`,KE=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,YE=`#ifdef USE_EMISSIVEMAP
+#endif`,JE=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,KE="gl_FragColor = linearToOutputTexel( gl_FragColor );",JE=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,QE="gl_FragColor = linearToOutputTexel( gl_FragColor );",eT=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -553,7 +553,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
-}`,QE=`#ifdef USE_ENVMAP
+}`,tT=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
@@ -580,7 +580,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
-#endif`,eT=`#ifdef USE_ENVMAP
+#endif`,nT=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
@@ -588,7 +588,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
uniform sampler2D envMap;
#endif
-#endif`,tT=`#ifdef USE_ENVMAP
+#endif`,iT=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
@@ -599,7 +599,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
varying vec3 vReflect;
#endif
-#endif`,nT=`#ifdef USE_ENVMAP
+#endif`,rT=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
@@ -610,7 +610,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,iT=`#ifdef USE_ENVMAP
+#endif`,sT=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
@@ -627,18 +627,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,rT=`#ifdef USE_FOG
+#endif`,oT=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,sT=`#ifdef USE_FOG
+#endif`,aT=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,oT=`#ifdef USE_FOG
+#endif`,cT=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
-#endif`,aT=`#ifdef USE_FOG
+#endif`,lT=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
@@ -647,7 +647,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,cT=`#ifdef USE_GRADIENTMAP
+#endif`,uT=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -659,12 +659,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
-}`,lT=`#ifdef USE_LIGHTMAP
+}`,hT=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,uT=`LambertMaterial material;
+#endif`,dT=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,hT=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,fT=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
@@ -678,7 +678,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,dT=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pT=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
@@ -807,7 +807,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return irradiance;
}
#endif
-#include <lightprobes_pars_fragment>`,fT=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,mT=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -864,8 +864,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
}
#endif
#endif
-#endif`,pT=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,mT=`varying vec3 vViewPosition;
+#endif`,gT=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,_T=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
@@ -877,11 +877,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,gT=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xT=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,_T=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,vT=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
@@ -898,7 +898,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,xT=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,yT=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
@@ -991,7 +991,7 @@ material.roughness = min( material.roughness, 1.0 );
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
-#endif`,vT=`uniform sampler2D dfgLUT;
+#endif`,bT=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
@@ -1358,7 +1358,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
-}`,yT=`
+}`,ST=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1506,7 +1506,7 @@ IncidentLight directLight;
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,bT=`#if defined( RE_IndirectDiffuse )
+#endif`,wT=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1536,7 +1536,7 @@ IncidentLight directLight;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,ST=`#if defined( RE_IndirectDiffuse )
+#endif`,MT=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
@@ -1544,7 +1544,7 @@ IncidentLight directLight;
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,wT=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,ET=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1589,27 +1589,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,MT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,TT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,ET=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,AT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,TT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,RT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,AT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,CT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,RT=`#ifdef USE_MAP
+#endif`,IT=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,CT=`#ifdef USE_MAP
+#endif`,PT=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,IT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,LT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
@@ -1621,7 +1621,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,PT=`#if defined( USE_POINTS_UV )
+#endif`,NT=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1633,19 +1633,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,LT=`float metalnessFactor = metalness;
+#endif`,DT=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,NT=`#ifdef USE_METALNESSMAP
+#endif`,OT=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,DT=`#ifdef USE_INSTANCING_MORPH
+#endif`,UT=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
-#endif`,OT=`#if defined( USE_MORPHCOLORS )
+#endif`,FT=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
@@ -1654,12 +1654,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,UT=`#ifdef USE_MORPHNORMALS
+#endif`,zT=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
-#endif`,FT=`#ifdef USE_MORPHTARGETS
+#endif`,kT=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1673,12 +1673,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
-#endif`,zT=`#ifdef USE_MORPHTARGETS
+#endif`,BT=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
-#endif`,kT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,GT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
@@ -1719,7 +1719,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,HT=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
@@ -1737,19 +1737,19 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,GT=`#ifndef FLAT_SHADED
+#endif`,VT=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,HT=`#ifndef FLAT_SHADED
+#endif`,$T=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,VT=`#ifndef FLAT_SHADED
+#endif`,WT=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1758,7 +1758,7 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,$T=`#ifdef USE_NORMALMAP
+#endif`,ZT=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1780,13 +1780,13 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,WT=`#ifdef USE_CLEARCOAT
+#endif`,XT=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,ZT=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,jT=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,XT=`#ifdef USE_CLEARCOATMAP
+#endif`,qT=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1795,18 +1795,18 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,jT=`#ifdef USE_IRIDESCENCEMAP
+#endif`,YT=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,qT=`#ifdef OPAQUE
+#endif`,KT=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,YT=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JT=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1885,9 +1885,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
-}`,KT=`#ifdef PREMULTIPLIED_ALPHA
+}`,QT=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,JT=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,eA=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
@@ -1895,22 +1895,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,tA=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,eA=`#ifdef DITHERING
+#endif`,nA=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
-#endif`,tA=`float roughnessFactor = roughness;
+#endif`,iA=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,nA=`#ifdef USE_ROUGHNESSMAP
+#endif`,rA=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,iA=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,sA=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
@@ -2161,7 +2161,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
}
#endif
#endif
-#endif`,rA=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,oA=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
@@ -2206,7 +2206,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,sA=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
+#endif`,aA=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
@@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,oA=`float getShadowMask() {
+#endif`,cA=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2287,12 +2287,12 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,aA=`#ifdef USE_SKINNING
+}`,lA=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,cA=`#ifdef USE_SKINNING
+#endif`,uA=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2307,7 +2307,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,lA=`#ifdef USE_SKINNING
+#endif`,hA=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2315,7 +2315,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,uA=`#ifdef USE_SKINNING
+#endif`,dA=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2326,17 +2326,17 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,hA=`float specularStrength;
+#endif`,fA=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,dA=`#ifdef USE_SPECULARMAP
+#endif`,pA=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,fA=`#if defined( TONE_MAPPING )
+#endif`,mA=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,pA=`#ifndef saturate
+#endif`,gA=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
@@ -2433,7 +2433,7 @@ vec3 NeutralToneMapping( vec3 color ) {
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
-vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,_A=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2454,7 +2454,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,gA=`#ifdef USE_TRANSMISSION
+#endif`,xA=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2580,7 +2580,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
-#endif`,_A=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,vA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2650,7 +2650,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,xA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,yA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2744,7 +2744,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,vA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,bA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
@@ -2815,7 +2815,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var yA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`;var SA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
@@ -2824,12 +2824,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,bA=`varying vec2 vUv;
+#endif`,wA=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,SA=`uniform sampler2D t2D;
+}`,MA=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
@@ -2841,14 +2841,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,wA=`varying vec3 vWorldDirection;
+}`,EA=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,MA=`#ifdef ENVMAP_TYPE_CUBE
+}`,TA=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
@@ -2870,14 +2870,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,EA=`varying vec3 vWorldDirection;
+}`,AA=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,TA=`uniform samplerCube tCube;
+}`,RA=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
@@ -2887,7 +2887,7 @@ void main() {
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,AA=`#include <common>
+}`,CA=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
@@ -2914,7 +2914,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,RA=`#if DEPTH_PACKING == 3200
+}`,IA=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
@@ -2952,7 +2952,7 @@ void main() {
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,CA=`#define DISTANCE
+}`,PA=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
@@ -2979,7 +2979,7 @@ void main() {
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,IA=`#define DISTANCE
+}`,LA=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
@@ -3002,13 +3002,13 @@ void main() {
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
-}`,PA=`varying vec3 vWorldDirection;
+}`,NA=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,LA=`uniform sampler2D tEquirect;
+}`,DA=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
@@ -3017,7 +3017,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,NA=`uniform float scale;
+}`,OA=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
@@ -3039,7 +3039,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,DA=`uniform vec3 diffuse;
+}`,UA=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
@@ -3067,7 +3067,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,OA=`#include <common>
+}`,FA=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
@@ -3099,7 +3099,7 @@ void main() {
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,UA=`uniform vec3 diffuse;
+}`,zA=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
@@ -3147,7 +3147,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,FA=`#define LAMBERT
+}`,kA=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3186,7 +3186,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,zA=`#define LAMBERT
+}`,BA=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3244,7 +3244,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,kA=`#define MATCAP
+}`,GA=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3278,7 +3278,7 @@ void main() {
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,BA=`#define MATCAP
+}`,HA=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
@@ -3324,7 +3324,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,GA=`#define NORMAL
+}`,VA=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
@@ -3357,7 +3357,7 @@ void main() {
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,HA=`#define NORMAL
+}`,$A=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
@@ -3378,7 +3378,7 @@ void main() {
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,VA=`#define PHONG
+}`,WA=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3417,7 +3417,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,$A=`#define PHONG
+}`,ZA=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
@@ -3477,7 +3477,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,WA=`#define STANDARD
+}`,XA=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3520,7 +3520,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,ZA=`#define STANDARD
+}`,jA=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
@@ -3648,7 +3648,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,XA=`#define TOON
+}`,qA=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3685,7 +3685,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,jA=`#define TOON
+}`,YA=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3737,7 +3737,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,qA=`uniform float size;
+}`,KA=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
@@ -3768,7 +3768,7 @@ void main() {
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,YA=`uniform vec3 diffuse;
+}`,JA=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
@@ -3793,7 +3793,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,KA=`#include <common>
+}`,QA=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
@@ -3816,7 +3816,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,JA=`uniform vec3 color;
+}`,e1=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
@@ -3832,7 +3832,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,QA=`uniform float rotation;
+}`,t1=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
@@ -3856,7 +3856,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,e1=`uniform vec3 diffuse;
+}`,n1=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -3881,7 +3881,7 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,Ye={alphahash_fragment:bE,alphahash_pars_fragment:SE,alphamap_fragment:wE,alphamap_pars_fragment:ME,alphatest_fragment:EE,alphatest_pars_fragment:TE,aomap_fragment:AE,aomap_pars_fragment:RE,batching_pars_vertex:CE,batching_vertex:IE,begin_vertex:PE,beginnormal_vertex:LE,bsdfs:NE,iridescence_fragment:DE,bumpmap_pars_fragment:OE,clipping_planes_fragment:UE,clipping_planes_pars_fragment:FE,clipping_planes_pars_vertex:zE,clipping_planes_vertex:kE,color_fragment:BE,color_pars_fragment:GE,color_pars_vertex:HE,color_vertex:VE,common:$E,cube_uv_reflection_fragment:WE,defaultnormal_vertex:ZE,displacementmap_pars_vertex:XE,displacementmap_vertex:jE,emissivemap_fragment:qE,emissivemap_pars_fragment:YE,colorspace_fragment:KE,colorspace_pars_fragment:JE,envmap_fragment:QE,envmap_common_pars_fragment:eT,envmap_pars_fragment:tT,envmap_pars_vertex:nT,envmap_physical_pars_fragment:fT,envmap_vertex:iT,fog_vertex:rT,fog_pars_vertex:sT,fog_fragment:oT,fog_pars_fragment:aT,gradientmap_pars_fragment:cT,lightmap_pars_fragment:lT,lights_lambert_fragment:uT,lights_lambert_pars_fragment:hT,lights_pars_begin:dT,lights_toon_fragment:pT,lights_toon_pars_fragment:mT,lights_phong_fragment:gT,lights_phong_pars_fragment:_T,lights_physical_fragment:xT,lights_physical_pars_fragment:vT,lights_fragment_begin:yT,lights_fragment_maps:bT,lights_fragment_end:ST,lightprobes_pars_fragment:wT,logdepthbuf_fragment:MT,logdepthbuf_pars_fragment:ET,logdepthbuf_pars_vertex:TT,logdepthbuf_vertex:AT,map_fragment:RT,map_pars_fragment:CT,map_particle_fragment:IT,map_particle_pars_fragment:PT,metalnessmap_fragment:LT,metalnessmap_pars_fragment:NT,morphinstance_vertex:DT,morphcolor_vertex:OT,morphnormal_vertex:UT,morphtarget_pars_vertex:FT,morphtarget_vertex:zT,normal_fragment_begin:kT,normal_fragment_maps:BT,normal_pars_fragment:GT,normal_pars_vertex:HT,normal_vertex:VT,normalmap_pars_fragment:$T,clearcoat_normal_fragment_begin:WT,clearcoat_normal_fragment_maps:ZT,clearcoat_pars_fragment:XT,iridescence_pars_fragment:jT,opaque_fragment:qT,packing:YT,premultiplied_alpha_fragment:KT,project_vertex:JT,dithering_fragment:QT,dithering_pars_fragment:eA,roughnessmap_fragment:tA,roughnessmap_pars_fragment:nA,shadowmap_pars_fragment:iA,shadowmap_pars_vertex:rA,shadowmap_vertex:sA,shadowmask_pars_fragment:oA,skinbase_vertex:aA,skinning_pars_vertex:cA,skinning_vertex:lA,skinnormal_vertex:uA,specularmap_fragment:hA,specularmap_pars_fragment:dA,tonemapping_fragment:fA,tonemapping_pars_fragment:pA,transmission_fragment:mA,transmission_pars_fragment:gA,uv_pars_fragment:_A,uv_pars_vertex:xA,uv_vertex:vA,worldpos_vertex:yA,background_vert:bA,background_frag:SA,backgroundCube_vert:wA,backgroundCube_frag:MA,cube_vert:EA,cube_frag:TA,depth_vert:AA,depth_frag:RA,distance_vert:CA,distance_frag:IA,equirect_vert:PA,equirect_frag:LA,linedashed_vert:NA,linedashed_frag:DA,meshbasic_vert:OA,meshbasic_frag:UA,meshlambert_vert:FA,meshlambert_frag:zA,meshmatcap_vert:kA,meshmatcap_frag:BA,meshnormal_vert:GA,meshnormal_frag:HA,meshphong_vert:VA,meshphong_frag:$A,meshphysical_vert:WA,meshphysical_frag:ZA,meshtoon_vert:XA,meshtoon_frag:jA,points_vert:qA,points_frag:YA,shadow_vert:KA,shadow_frag:JA,sprite_vert:QA,sprite_frag:e1},be={common:{diffuse:{value:new He(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new We}},envmap:{envMap:{value:null},envMapRotation:{value:new We},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new We}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new We}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new We},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new We},normalScale:{value:new Be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new We},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new We}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new We}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new We}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new He(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new He(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0},uvTransform:{value:new We}},sprite:{diffuse:{value:new He(16777215)},opacity:{value:1},center:{value:new Be(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}}},Ei={basic:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new He(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new He(0)},specular:{value:new He(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:un([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new He(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:un([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new He(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:un([be.points,be.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:un([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:un([be.common,be.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:un([be.sprite,be.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new We},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new We}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:un([be.common,be.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:un([be.lights,be.fog,{color:{value:new He(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Ei.physical={uniforms:un([Ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new We},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new We},clearcoatNormalScale:{value:new Be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new We},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new We},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new We},sheen:{value:0},sheenColor:{value:new He(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new We},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new We},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new We},transmissionSamplerSize:{value:new Be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new We},attenuationDistance:{value:0},attenuationColor:{value:new He(0)},specularColor:{value:new He(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new We},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new We},anisotropyVector:{value:new Be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new We}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var fl={r:0,b:0,g:0},t1=new Xe,Kv=new We;Kv.set(-1,0,0,0,1,0,0,0,1);function n1(e,t,n,i,r,s){let o=new He(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(M){let T=M.isScene===!0?M.background:null;if(T&&T.isTexture){let v=M.backgroundBlurriness>0;T=t.get(T,v)}return T}function m(M){let T=!1,v=f(M);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),T=!0;let S=e.xr.getEnvironmentBlendMode();if(S==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(S==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(M,T){let v=f(T);if(v&&(v.isCubeTexture||v.mapping===Ho)){if(l===void 0)l=new Mt(new xr(1,1,1),new Gn({name:"BackgroundCubeMaterial",uniforms:Kr(Ei.backgroundCube.uniforms),vertexShader:Ei.backgroundCube.vertexShader,fragmentShader:Ei.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(t1.makeRotationFromEuler(T.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Kv);if(l.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,u!==v||h!==v.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new Mt(new ta(2,2),new Gn({name:"BackgroundMaterial",uniforms:Kr(Ei.background.uniforms),vertexShader:Ei.background.vertexShader,fragmentShader:Ei.background.fragmentShader,side:fr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||h!==v.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)}}function p(M,T){M.getRGB(fl,md(e)),n.buffers.color.setClear(fl.r,fl.g,fl.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(M,T=1){o.set(M),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,p(o,a)},render:m,addToRenderList:_,dispose:g}}function i1(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,N,ee,P,Z){let G=!1,k=h(C,P,ee,N);if(s!==k)s=k,l(s.object);if(G=f(C,P,ee,Z),G)m(C,P,ee,Z);if(Z!==null)t.update(Z,e.ELEMENT_ARRAY_BUFFER);if(G||o){if(o=!1,v(C,N,ee,P),Z!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(Z).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function h(C,N,ee,P){let Z=P.wireframe===!0,G=i[N.id];if(G===void 0)G={},i[N.id]=G;let k=C.isInstancedMesh===!0?C.id:0,W=G[k];if(W===void 0)W={},G[k]=W;let B=W[ee.id];if(B===void 0)B={},W[ee.id]=B;let Y=B[Z];if(Y===void 0)Y=d(c()),B[Z]=Y;return Y}function d(C){let N=[],ee=[],P=[];for(let Z=0;Z<n;Z++)N[Z]=0,ee[Z]=0,P[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:ee,attributeDivisors:P,object:C,attributes:{},index:null}}function f(C,N,ee,P){let Z=s.attributes,G=N.attributes,k=0,W=ee.getAttributes();for(let B in W)if(W[B].location>=0){let K=Z[B],ge=G[B];if(ge===void 0){if(B==="instanceMatrix"&&C.instanceMatrix)ge=C.instanceMatrix;if(B==="instanceColor"&&C.instanceColor)ge=C.instanceColor}if(K===void 0)return!0;if(K.attribute!==ge)return!0;if(ge&&K.data!==ge.data)return!0;k++}if(s.attributesNum!==k)return!0;if(s.index!==P)return!0;return!1}function m(C,N,ee,P){let Z={},G=N.attributes,k=0,W=ee.getAttributes();for(let B in W)if(W[B].location>=0){let K=G[B];if(K===void 0){if(B==="instanceMatrix"&&C.instanceMatrix)K=C.instanceMatrix;if(B==="instanceColor"&&C.instanceColor)K=C.instanceColor}let ge={};if(ge.attribute=K,K&&K.data)ge.data=K.data;Z[B]=ge,k++}s.attributes=Z,s.attributesNum=k,s.index=P}function _(){let C=s.newAttributes;for(let N=0,ee=C.length;N<ee;N++)C[N]=0}function p(C){g(C,0)}function g(C,N){let ee=s.newAttributes,P=s.enabledAttributes,Z=s.attributeDivisors;if(ee[C]=1,P[C]===0)e.enableVertexAttribArray(C),P[C]=1;if(Z[C]!==N)e.vertexAttribDivisor(C,N),Z[C]=N}function M(){let C=s.newAttributes,N=s.enabledAttributes;for(let ee=0,P=N.length;ee<P;ee++)if(N[ee]!==C[ee])e.disableVertexAttribArray(ee),N[ee]=0}function T(C,N,ee,P,Z,G,k){if(k===!0)e.vertexAttribIPointer(C,N,ee,Z,G);else e.vertexAttribPointer(C,N,ee,P,Z,G)}function v(C,N,ee,P){_();let Z=P.attributes,G=ee.getAttributes(),k=N.defaultAttributeValues;for(let W in G){let B=G[W];if(B.location>=0){let Y=Z[W];if(Y===void 0){if(W==="instanceMatrix"&&C.instanceMatrix)Y=C.instanceMatrix;if(W==="instanceColor"&&C.instanceColor)Y=C.instanceColor}if(Y!==void 0){let K=Y.normalized,ge=Y.itemSize,de=t.get(Y);if(de===void 0)continue;let{buffer:fe,type:he,bytesPerElement:I}=de,V=he===e.INT||he===e.UNSIGNED_INT||Y.gpuType===Sh;if(Y.isInterleavedBufferAttribute){let q=Y.data,se=q.stride,ce=Y.offset;if(q.isInstancedInterleavedBuffer){for(let ae=0;ae<B.locationSize;ae++)g(B.location+ae,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=q.meshPerAttribute*q.count}else for(let ae=0;ae<B.locationSize;ae++)p(B.location+ae);e.bindBuffer(e.ARRAY_BUFFER,fe);for(let ae=0;ae<B.locationSize;ae++)T(B.location+ae,ge/B.locationSize,he,K,se*I,(ce+ge/B.locationSize*ae)*I,V)}else{if(Y.isInstancedBufferAttribute){for(let q=0;q<B.locationSize;q++)g(B.location+q,Y.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=Y.meshPerAttribute*Y.count}else for(let q=0;q<B.locationSize;q++)p(B.location+q);e.bindBuffer(e.ARRAY_BUFFER,fe);for(let q=0;q<B.locationSize;q++)T(B.location+q,ge/B.locationSize,he,K,ge*I,ge/B.locationSize*q*I,V)}}else if(k!==void 0){let K=k[W];if(K!==void 0)switch(K.length){case 2:e.vertexAttrib2fv(B.location,K);break;case 3:e.vertexAttrib3fv(B.location,K);break;case 4:e.vertexAttrib4fv(B.location,K);break;default:e.vertexAttrib1fv(B.location,K)}}}}M()}function S(){w();for(let C in i){let N=i[C];for(let ee in N){let P=N[ee];for(let Z in P){let G=P[Z];for(let k in G)u(G[k].object),delete G[k];delete P[Z]}}delete i[C]}}function E(C){if(i[C.id]===void 0)return;let N=i[C.id];for(let ee in N){let P=N[ee];for(let Z in P){let G=P[Z];for(let k in G)u(G[k].object),delete G[k];delete P[Z]}}delete i[C.id]}function R(C){for(let N in i){let ee=i[N];for(let P in ee){let Z=ee[P];if(Z[C.id]===void 0)continue;let G=Z[C.id];for(let k in G)u(G[k].object),delete G[k];delete Z[C.id]}}}function x(C){for(let N in i){let ee=i[N],P=C.isInstancedMesh===!0?C.id:0,Z=ee[P];if(Z===void 0)continue;for(let G in Z){let k=Z[G];for(let W in k)u(k[W].object),delete k[W];delete Z[G]}if(delete ee[P],Object.keys(ee).length===0)delete i[N]}}function w(){if(H(),o=!0,s===r)return;s=r,l(s.object)}function H(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:w,resetDefaultState:H,dispose:S,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:M}}function r1(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let d=0;for(let f=0;f<u;f++)d+=l[f];n.update(d,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function s1(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==Si&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===bi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ni&&R!==Vi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ue("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let h=n.logarithmicDepthBuffer===!0,d=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&d===!1)Ue("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),M=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),S=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:M,maxVaryings:T,maxFragmentUniforms:v,maxSamples:S,samples:E}}function o1(e){let t=this,n=null,i=0,r=!1,s=!1,o=new zn,a=new We,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||i!==0||r;return r=d,i=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){n=u(h,d,0)},this.setState=function(h,d,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=h,g=e.get(h);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let M=s?0:i,T=M*4,v=g.clippingState||null;c.value=v,v=u(m,d,T,f);for(let S=0;S!==T;++S)v[S]=n[S];g.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=M}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(h,d,f,m){let _=h!==null?h.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,M=d.matrixWorldInverse;if(a.getNormalMatrix(M),p===null||p.length<g)p=new Float32Array(g);for(let T=0,v=f;T!==_;++T,v+=4)o.copy(h[T]).applyMatrix4(M,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Ws=4,a1=6,c1=20,l1=256,oa=new Qr,Cv=new He,Ld=null,Nd=0,Dd=0,Od=!1,u1=new F,es=new F;class ua{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=u1}=r;Ld=this._renderer.getRenderTarget(),Nd=this._renderer.getActiveCubeFace(),Dd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Lv(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Pv(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ld,Nd,Dd),this._renderer.xr.enabled=Od,e.scissorTest=!1,$s(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Ps||e.mapping===$r)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Ld=this._renderer.getRenderTarget(),Nd=this._renderer.getActiveCubeFace(),Dd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:bi,format:Si,colorSpace:Rn,depthBuffer:!1},i=Iv(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Iv(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=h1(r)),this._blurMaterial=f1(r,e,t),this._ggxMaterial=d1(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new ln,e);this._renderer.compile(t,oa)}_sceneToCubeUV(e,t,n,i,r){let a=new Ht(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:h,toneMapping:d}=u;if(u.getClearColor(Cv),u.toneMapping=ei,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new xr,new wi({name:"PMREM.Background",side:cn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(Cv),p=!0;for(let M=0;M<6;M++){let T=M%3;if(T===0)a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[M],r.y,r.z);else if(T===1)a.up.set(0,0,c[M]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[M],r.z);else a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[M]);let v=this._cubeSize;if($s(i,T*v,M>2?v:0,v,v),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=d,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Ps||e.mapping===$r;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Lv();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Pv();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;$s(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,oa)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),h=c*1.25,d=u*h,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Ws?n-f+Ws:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=d,a.mipInt.value=f-t,$s(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,oa),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,$s(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,oa)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Ws?i-this._lodMax+Ws:0),h=4*(this._cubeSize-l);$s(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,oa)}}function h1(e){let t=[],n=[],i=e,r=e-Ws+1+a1;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=6,d=6,f=3,m=new Float32Array(f*d*h),_=new Float32Array(f*d*h);for(let g=0;g<h;g++){let M=g%3*2/3-1,T=g>2?0:-1,v=[M,T,0,M+0.6666666666666666,T,0,M+0.6666666666666666,T+1,0,M,T,0,M+0.6666666666666666,T+1,0,M,T+1,0];m.set(v,f*d*g);for(let S=0;S<d;S++){let E=u[S*2]*2-1,R=u[S*2+1]*2-1;if(g===0)es.set(1,R,E);else if(g===1)es.set(-E,1,-R);else if(g===2)es.set(-E,R,1);else if(g===3)es.set(-1,R,-E);else if(g===4)es.set(-E,-1,R);else es.set(E,R,-1);es.toArray(_,(g*d+S)*f)}}let p=new ln;if(p.setAttribute("position",new Kt(m,f)),p.setAttribute("outputDirection",new Kt(_,f)),n.push(new Mt(p,null)),i>Ws)i--}return{lodMeshes:n,sizeLods:t}}function Iv(e,t,n){let i=new Cn(e,t,n);return i.texture.mapping=Ho,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function $s(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function d1(e,t,n){return new Gn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:l1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ml(),fragmentShader:`
+}`,Ye={alphahash_fragment:wE,alphahash_pars_fragment:ME,alphamap_fragment:EE,alphamap_pars_fragment:TE,alphatest_fragment:AE,alphatest_pars_fragment:RE,aomap_fragment:CE,aomap_pars_fragment:IE,batching_pars_vertex:PE,batching_vertex:LE,begin_vertex:NE,beginnormal_vertex:DE,bsdfs:OE,iridescence_fragment:UE,bumpmap_pars_fragment:FE,clipping_planes_fragment:zE,clipping_planes_pars_fragment:kE,clipping_planes_pars_vertex:BE,clipping_planes_vertex:GE,color_fragment:HE,color_pars_fragment:VE,color_pars_vertex:$E,color_vertex:WE,common:ZE,cube_uv_reflection_fragment:XE,defaultnormal_vertex:jE,displacementmap_pars_vertex:qE,displacementmap_vertex:YE,emissivemap_fragment:KE,emissivemap_pars_fragment:JE,colorspace_fragment:QE,colorspace_pars_fragment:eT,envmap_fragment:tT,envmap_common_pars_fragment:nT,envmap_pars_fragment:iT,envmap_pars_vertex:rT,envmap_physical_pars_fragment:mT,envmap_vertex:sT,fog_vertex:oT,fog_pars_vertex:aT,fog_fragment:cT,fog_pars_fragment:lT,gradientmap_pars_fragment:uT,lightmap_pars_fragment:hT,lights_lambert_fragment:dT,lights_lambert_pars_fragment:fT,lights_pars_begin:pT,lights_toon_fragment:gT,lights_toon_pars_fragment:_T,lights_phong_fragment:xT,lights_phong_pars_fragment:vT,lights_physical_fragment:yT,lights_physical_pars_fragment:bT,lights_fragment_begin:ST,lights_fragment_maps:wT,lights_fragment_end:MT,lightprobes_pars_fragment:ET,logdepthbuf_fragment:TT,logdepthbuf_pars_fragment:AT,logdepthbuf_pars_vertex:RT,logdepthbuf_vertex:CT,map_fragment:IT,map_pars_fragment:PT,map_particle_fragment:LT,map_particle_pars_fragment:NT,metalnessmap_fragment:DT,metalnessmap_pars_fragment:OT,morphinstance_vertex:UT,morphcolor_vertex:FT,morphnormal_vertex:zT,morphtarget_pars_vertex:kT,morphtarget_vertex:BT,normal_fragment_begin:GT,normal_fragment_maps:HT,normal_pars_fragment:VT,normal_pars_vertex:$T,normal_vertex:WT,normalmap_pars_fragment:ZT,clearcoat_normal_fragment_begin:XT,clearcoat_normal_fragment_maps:jT,clearcoat_pars_fragment:qT,iridescence_pars_fragment:YT,opaque_fragment:KT,packing:JT,premultiplied_alpha_fragment:QT,project_vertex:eA,dithering_fragment:tA,dithering_pars_fragment:nA,roughnessmap_fragment:iA,roughnessmap_pars_fragment:rA,shadowmap_pars_fragment:sA,shadowmap_pars_vertex:oA,shadowmap_vertex:aA,shadowmask_pars_fragment:cA,skinbase_vertex:lA,skinning_pars_vertex:uA,skinning_vertex:hA,skinnormal_vertex:dA,specularmap_fragment:fA,specularmap_pars_fragment:pA,tonemapping_fragment:mA,tonemapping_pars_fragment:gA,transmission_fragment:_A,transmission_pars_fragment:xA,uv_pars_fragment:vA,uv_pars_vertex:yA,uv_vertex:bA,worldpos_vertex:SA,background_vert:wA,background_frag:MA,backgroundCube_vert:EA,backgroundCube_frag:TA,cube_vert:AA,cube_frag:RA,depth_vert:CA,depth_frag:IA,distance_vert:PA,distance_frag:LA,equirect_vert:NA,equirect_frag:DA,linedashed_vert:OA,linedashed_frag:UA,meshbasic_vert:FA,meshbasic_frag:zA,meshlambert_vert:kA,meshlambert_frag:BA,meshmatcap_vert:GA,meshmatcap_frag:HA,meshnormal_vert:VA,meshnormal_frag:$A,meshphong_vert:WA,meshphong_frag:ZA,meshphysical_vert:XA,meshphysical_frag:jA,meshtoon_vert:qA,meshtoon_frag:YA,points_vert:KA,points_frag:JA,shadow_vert:QA,shadow_frag:e1,sprite_vert:t1,sprite_frag:n1},be={common:{diffuse:{value:new Ge(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new We}},envmap:{envMap:{value:null},envMapRotation:{value:new We},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new We}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new We}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new We},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new We},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new We},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new We}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new We}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new We}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Ge(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new z},probesMax:{value:new z},probesResolution:{value:new z}},points:{diffuse:{value:new Ge(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0},uvTransform:{value:new We}},sprite:{diffuse:{value:new Ge(16777215)},opacity:{value:1},center:{value:new ke(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}}},Ei={basic:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Ge(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Ge(0)},specular:{value:new Ge(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:un([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new Ge(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:un([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new Ge(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:un([be.points,be.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:un([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:un([be.common,be.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:un([be.sprite,be.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new We},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new We}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:un([be.common,be.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:un([be.lights,be.fog,{color:{value:new Ge(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Ei.physical={uniforms:un([Ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new We},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new We},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new We},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new We},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new We},sheen:{value:0},sheenColor:{value:new Ge(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new We},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new We},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new We},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new We},attenuationDistance:{value:0},attenuationColor:{value:new Ge(0)},specularColor:{value:new Ge(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new We},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new We},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new We}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var pl={r:0,b:0,g:0},i1=new Xe,Jv=new We;Jv.set(-1,0,0,0,1,0,0,0,1);function r1(e,t,n,i,r,s){let o=new Ge(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(M){let T=M.isScene===!0?M.background:null;if(T&&T.isTexture){let v=M.backgroundBlurriness>0;T=t.get(T,v)}return T}function m(M){let T=!1,v=f(M);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),T=!0;let S=e.xr.getEnvironmentBlendMode();if(S==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(S==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(M,T){let v=f(T);if(v&&(v.isCubeTexture||v.mapping===Wo)){if(l===void 0)l=new Mt(new vr(1,1,1),new Gn({name:"BackgroundCubeMaterial",uniforms:Jr(Ei.backgroundCube.uniforms),vertexShader:Ei.backgroundCube.vertexShader,fragmentShader:Ei.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(i1.makeRotationFromEuler(T.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Jv);if(l.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,u!==v||h!==v.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new Mt(new ra(2,2),new Gn({name:"BackgroundMaterial",uniforms:Jr(Ei.background.uniforms),vertexShader:Ei.background.vertexShader,fragmentShader:Ei.background.fragmentShader,side:pr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||h!==v.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)}}function p(M,T){M.getRGB(pl,gd(e)),n.buffers.color.setClear(pl.r,pl.g,pl.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(M,T=1){o.set(M),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,p(o,a)},render:m,addToRenderList:_,dispose:g}}function s1(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,D,ee,L,W){let B=!1,P=h(C,L,ee,D);if(s!==P)s=P,l(s.object);if(B=f(C,L,ee,W),B)m(C,L,ee,W);if(W!==null)t.update(W,e.ELEMENT_ARRAY_BUFFER);if(B||o){if(o=!1,v(C,D,ee,L),W!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(W).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function h(C,D,ee,L){let W=L.wireframe===!0,B=i[D.id];if(B===void 0)B={},i[D.id]=B;let P=C.isInstancedMesh===!0?C.id:0,J=B[P];if(J===void 0)J={},B[P]=J;let H=J[ee.id];if(H===void 0)H={},J[ee.id]=H;let q=H[W];if(q===void 0)q=d(c()),H[W]=q;return q}function d(C){let D=[],ee=[],L=[];for(let W=0;W<n;W++)D[W]=0,ee[W]=0,L[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:ee,attributeDivisors:L,object:C,attributes:{},index:null}}function f(C,D,ee,L){let W=s.attributes,B=D.attributes,P=0,J=ee.getAttributes();for(let H in J)if(J[H].location>=0){let Q=W[H],ge=B[H];if(ge===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)ge=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)ge=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==ge)return!0;if(ge&&Q.data!==ge.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==L)return!0;return!1}function m(C,D,ee,L){let W={},B=D.attributes,P=0,J=ee.getAttributes();for(let H in J)if(J[H].location>=0){let Q=B[H];if(Q===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let ge={};if(ge.attribute=Q,Q&&Q.data)ge.data=Q.data;W[H]=ge,P++}s.attributes=W,s.attributesNum=P,s.index=L}function _(){let C=s.newAttributes;for(let D=0,ee=C.length;D<ee;D++)C[D]=0}function p(C){g(C,0)}function g(C,D){let ee=s.newAttributes,L=s.enabledAttributes,W=s.attributeDivisors;if(ee[C]=1,L[C]===0)e.enableVertexAttribArray(C),L[C]=1;if(W[C]!==D)e.vertexAttribDivisor(C,D),W[C]=D}function M(){let C=s.newAttributes,D=s.enabledAttributes;for(let ee=0,L=D.length;ee<L;ee++)if(D[ee]!==C[ee])e.disableVertexAttribArray(ee),D[ee]=0}function T(C,D,ee,L,W,B,P){if(P===!0)e.vertexAttribIPointer(C,D,ee,W,B);else e.vertexAttribPointer(C,D,ee,L,W,B)}function v(C,D,ee,L){_();let W=L.attributes,B=ee.getAttributes(),P=D.defaultAttributeValues;for(let J in B){let H=B[J];if(H.location>=0){let q=W[J];if(q===void 0){if(J==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(J==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let Q=q.normalized,ge=q.itemSize,he=t.get(q);if(he===void 0)continue;let{buffer:de,type:fe,bytesPerElement:I}=he,V=fe===e.INT||fe===e.UNSIGNED_INT||q.gpuType===wh;if(q.isInterleavedBufferAttribute){let j=q.data,re=j.stride,oe=q.offset;if(j.isInstancedInterleavedBuffer){for(let ue=0;ue<H.locationSize;ue++)g(H.location+ue,j.meshPerAttribute);if(C.isInstancedMesh!==!0&&L._maxInstanceCount===void 0)L._maxInstanceCount=j.meshPerAttribute*j.count}else for(let ue=0;ue<H.locationSize;ue++)p(H.location+ue);e.bindBuffer(e.ARRAY_BUFFER,de);for(let ue=0;ue<H.locationSize;ue++)T(H.location+ue,ge/H.locationSize,fe,Q,re*I,(oe+ge/H.locationSize*ue)*I,V)}else{if(q.isInstancedBufferAttribute){for(let j=0;j<H.locationSize;j++)g(H.location+j,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&L._maxInstanceCount===void 0)L._maxInstanceCount=q.meshPerAttribute*q.count}else for(let j=0;j<H.locationSize;j++)p(H.location+j);e.bindBuffer(e.ARRAY_BUFFER,de);for(let j=0;j<H.locationSize;j++)T(H.location+j,ge/H.locationSize,fe,Q,ge*I,ge/H.locationSize*j*I,V)}}else if(P!==void 0){let Q=P[J];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(H.location,Q);break;case 3:e.vertexAttrib3fv(H.location,Q);break;case 4:e.vertexAttrib4fv(H.location,Q);break;default:e.vertexAttrib1fv(H.location,Q)}}}}M()}function S(){w();for(let C in i){let D=i[C];for(let ee in D){let L=D[ee];for(let W in L){let B=L[W];for(let P in B)u(B[P].object),delete B[P];delete L[W]}}delete i[C]}}function E(C){if(i[C.id]===void 0)return;let D=i[C.id];for(let ee in D){let L=D[ee];for(let W in L){let B=L[W];for(let P in B)u(B[P].object),delete B[P];delete L[W]}}delete i[C.id]}function R(C){for(let D in i){let ee=i[D];for(let L in ee){let W=ee[L];if(W[C.id]===void 0)continue;let B=W[C.id];for(let P in B)u(B[P].object),delete B[P];delete W[C.id]}}}function x(C){for(let D in i){let ee=i[D],L=C.isInstancedMesh===!0?C.id:0,W=ee[L];if(W===void 0)continue;for(let B in W){let P=W[B];for(let J in P)u(P[J].object),delete P[J];delete W[B]}if(delete ee[L],Object.keys(ee).length===0)delete i[D]}}function w(){if(G(),o=!0,s===r)return;s=r,l(s.object)}function G(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:w,resetDefaultState:G,dispose:S,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:M}}function o1(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let d=0;for(let f=0;f<u;f++)d+=l[f];n.update(d,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function a1(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==Si&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===bi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ni&&R!==$i&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ue("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let h=n.logarithmicDepthBuffer===!0,d=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&d===!1)Ue("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),M=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),S=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:M,maxVaryings:T,maxFragmentUniforms:v,maxSamples:S,samples:E}}function c1(e){let t=this,n=null,i=0,r=!1,s=!1,o=new zn,a=new We,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||i!==0||r;return r=d,i=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){n=u(h,d,0)},this.setState=function(h,d,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=h,g=e.get(h);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let M=s?0:i,T=M*4,v=g.clippingState||null;c.value=v,v=u(m,d,T,f);for(let S=0;S!==T;++S)v[S]=n[S];g.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=M}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(h,d,f,m){let _=h!==null?h.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,M=d.matrixWorldInverse;if(a.getNormalMatrix(M),p===null||p.length<g)p=new Float32Array(g);for(let T=0,v=f;T!==_;++T,v+=4)o.copy(h[T]).applyMatrix4(M,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Xs=4,l1=6,u1=20,h1=256,la=new es,Iv=new Ge,Nd=null,Dd=0,Od=0,Ud=!1,d1=new z,ts=new z;class fa{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=d1}=r;Nd=this._renderer.getRenderTarget(),Dd=this._renderer.getActiveCubeFace(),Od=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Nv(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Lv(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Nd,Dd,Od),this._renderer.xr.enabled=Ud,e.scissorTest=!1,Zs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Ls||e.mapping===Wr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Nd=this._renderer.getRenderTarget(),Dd=this._renderer.getActiveCubeFace(),Od=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:bi,format:Si,colorSpace:Rn,depthBuffer:!1},i=Pv(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Pv(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=f1(r)),this._blurMaterial=m1(r,e,t),this._ggxMaterial=p1(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new ln,e);this._renderer.compile(t,la)}_sceneToCubeUV(e,t,n,i,r){let a=new Ht(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:h,toneMapping:d}=u;if(u.getClearColor(Iv),u.toneMapping=ei,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new vr,new wi({name:"PMREM.Background",side:cn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(Iv),p=!0;for(let M=0;M<6;M++){let T=M%3;if(T===0)a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[M],r.y,r.z);else if(T===1)a.up.set(0,0,c[M]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[M],r.z);else a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[M]);let v=this._cubeSize;if(Zs(i,T*v,M>2?v:0,v,v),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=d,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Ls||e.mapping===Wr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Nv();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Lv();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;Zs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,la)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),h=c*1.25,d=u*h,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Xs?n-f+Xs:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=d,a.mipInt.value=f-t,Zs(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,la),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,Zs(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,la)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Xs?i-this._lodMax+Xs:0),h=4*(this._cubeSize-l);Zs(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,la)}}function f1(e){let t=[],n=[],i=e,r=e-Xs+1+l1;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=6,d=6,f=3,m=new Float32Array(f*d*h),_=new Float32Array(f*d*h);for(let g=0;g<h;g++){let M=g%3*2/3-1,T=g>2?0:-1,v=[M,T,0,M+0.6666666666666666,T,0,M+0.6666666666666666,T+1,0,M,T,0,M+0.6666666666666666,T+1,0,M,T+1,0];m.set(v,f*d*g);for(let S=0;S<d;S++){let E=u[S*2]*2-1,R=u[S*2+1]*2-1;if(g===0)ts.set(1,R,E);else if(g===1)ts.set(-E,1,-R);else if(g===2)ts.set(-E,R,1);else if(g===3)ts.set(-1,R,-E);else if(g===4)ts.set(-E,-1,R);else ts.set(E,R,-1);ts.toArray(_,(g*d+S)*f)}}let p=new ln;if(p.setAttribute("position",new Kt(m,f)),p.setAttribute("outputDirection",new Kt(_,f)),n.push(new Mt(p,null)),i>Xs)i--}return{lodMeshes:n,sizeLods:t}}function Pv(e,t,n){let i=new Cn(e,t,n);return i.texture.mapping=Wo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Zs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function p1(e,t,n){return new Gn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:h1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:gl(),fragmentShader:`
precision highp float;
precision highp int;
@@ -3985,7 +3985,7 @@ void main() {
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:vi,depthTest:!1,depthWrite:!1})}function f1(e,t,n){return new Gn({name:"SphericalGaussianBlur",defines:{SAMPLES:c1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:ml(),fragmentShader:`
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function m1(e,t,n){return new Gn({name:"SphericalGaussianBlur",defines:{SAMPLES:u1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:gl(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4045,7 +4045,7 @@ void main() {
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:vi,depthTest:!1,depthWrite:!1})}function Pv(){return new Gn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ml(),fragmentShader:`
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function Lv(){return new Gn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:gl(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4064,7 +4064,7 @@ void main() {
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:vi,depthTest:!1,depthWrite:!1})}function Lv(){return new Gn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ml(),fragmentShader:`
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function Nv(){return new Gn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:gl(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4080,7 +4080,7 @@ void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:vi,depthTest:!1,depthWrite:!1})}function ml(){return`
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function gl(){return`
precision mediump float;
precision mediump int;
@@ -4095,7 +4095,7 @@ void main() {
gl_Position = vec4( position, 1.0 );
}
- `}class Bd extends Cn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new tl(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
+ `}class Gd extends Cn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new il(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
@@ -4130,7 +4130,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new xr(5,5,5),r=new Gn({name:"CubemapFromEquirect",uniforms:Kr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:cn,blending:vi});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===yi)t.minFilter=Jt;return new Md(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function p1(e){let t=new WeakMap,n=new WeakMap,i=null;function r(d,f=!1){if(d===null||d===void 0)return null;if(f)return o(d);return s(d)}function s(d){if(d&&d.isTexture){let f=d.mapping;if(f===Oc||f===Uc)if(t.has(d)){let m=t.get(d).texture;return a(m,d.mapping)}else{let m=d.image;if(m&&m.height>0){let _=new Bd(m.height);return _.fromEquirectangularTexture(e,d),t.set(d,_),d.addEventListener("dispose",l),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,m=f===Oc||f===Uc,_=f===Ps||f===$r;if(m||_){let p=n.get(d),g=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g){if(i===null)i=new ua(e);return p=m?i.fromEquirectangular(d,p):i.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),p.texture}else if(p!==void 0)return p.texture;else{let M=d.image;if(m&&M&&M.height>0||_&&M&&c(M)){if(i===null)i=new ua(e);return p=m?i.fromEquirectangular(d):i.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),d.addEventListener("dispose",u),p.texture}else return null}}}return d}function a(d,f){if(f===Oc)d.mapping=Ps;else if(f===Uc)d.mapping=$r;return d}function c(d){let f=0,m=6;for(let _=0;_<m;_++)if(d[_]!==void 0)f++;return f===m}function l(d){let f=d.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(d){let f=d.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function h(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:h}}function m1(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Hr("WebGLRenderer: "+i+" extension not supported.");return r}}}function g1(e,t,n,i){let r={},s=new WeakMap;function o(h){let d=h.target;if(d.index!==null)t.remove(d.index);for(let m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete r[d.id];let f=s.get(d);if(f)t.remove(f),s.delete(d);if(i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0)delete d._maxInstanceCount;n.memory.geometries--}function a(h,d){if(r[d.id]===!0)return d;return d.addEventListener("dispose",o),r[d.id]=!0,n.memory.geometries++,d}function c(h){let d=h.attributes;for(let f in d)t.update(d[f],e.ARRAY_BUFFER)}function l(h){let d=[],f=h.index,m=h.attributes.position,_=0;if(m===void 0)return;if(f!==null){let M=f.array;_=f.version;for(let T=0,v=M.length;T<v;T+=3){let S=M[T+0],E=M[T+1],R=M[T+2];d.push(S,E,E,R,R,S)}}else{let M=m.array;_=m.version;for(let T=0,v=M.length/3-1;T<v;T+=3){let S=T+0,E=T+1,R=T+2;d.push(S,E,E,R,R,S)}}let p=new(m.count>=65535?Kc:Yc)(d,1);p.version=_;let g=s.get(h);if(g)t.remove(g);s.set(h,p)}function u(h){let d=s.get(h);if(d){let f=h.index;if(f!==null){if(d.version<f.version)l(h)}}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function _1(e,t,n){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,d){e.drawElements(i,d,s,h*o),n.update(d,i,1)}function l(h,d,f){if(f===0)return;e.drawElementsInstanced(i,d,s,h*o,f),n.update(d,i,f)}function u(h,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,h,0,f);let _=0;for(let p=0;p<f;p++)_+=d[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function x1(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:$e("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function v1(e,t,n){let i=new WeakMap,r=new pt;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=i.get(a);if(d===void 0||d.count!==h){let w=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",w)};if(d!==void 0)d.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],M=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let v=a.attributes.position.count*T,S=1;if(v>t.maxTextureSize)S=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let E=new Float32Array(v*S*4*h),R=new jc(E,v,S,h);R.type=Vi,R.needsUpdate=!0;let x=T*4;for(let H=0;H<h;H++){let C=p[H],N=g[H],ee=M[H],P=v*S*4*H;for(let Z=0;Z<C.count;Z++){let G=Z*x;if(f===!0)r.fromBufferAttribute(C,Z),E[P+G+0]=r.x,E[P+G+1]=r.y,E[P+G+2]=r.z,E[P+G+3]=0;if(m===!0)r.fromBufferAttribute(N,Z),E[P+G+4]=r.x,E[P+G+5]=r.y,E[P+G+6]=r.z,E[P+G+7]=0;if(_===!0)r.fromBufferAttribute(ee,Z),E[P+G+8]=r.x,E[P+G+9]=r.y,E[P+G+10]=r.z,E[P+G+11]=ee.itemSize===4?r.w:1}}d={count:h,texture:R,size:new Be(v,S)},i.set(a,d),a.addEventListener("dispose",w)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}return{update:s}}function y1(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,h=l.geometry,d=t.get(l,h);if(s.get(d)!==u)t.update(d),s.set(d,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return d}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var b1={[gh]:"LINEAR_TONE_MAPPING",[_h]:"REINHARD_TONE_MAPPING",[xh]:"CINEON_TONE_MAPPING",[Go]:"ACES_FILMIC_TONE_MAPPING",[yh]:"AGX_TONE_MAPPING",[bh]:"NEUTRAL_TONE_MAPPING",[vh]:"CUSTOM_TONE_MAPPING"};function S1(e,t,n,i,r,s){let o=new Cn(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new ln;l.setAttribute("position",new vn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new vn([0,2,0,0,2,0],2));let u=new gd({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `},i=new vr(5,5,5),r=new Gn({name:"CubemapFromEquirect",uniforms:Jr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:cn,blending:vi});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===yi)t.minFilter=Jt;return new Ed(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function g1(e){let t=new WeakMap,n=new WeakMap,i=null;function r(d,f=!1){if(d===null||d===void 0)return null;if(f)return o(d);return s(d)}function s(d){if(d&&d.isTexture){let f=d.mapping;if(f===Fc||f===zc)if(t.has(d)){let m=t.get(d).texture;return a(m,d.mapping)}else{let m=d.image;if(m&&m.height>0){let _=new Gd(m.height);return _.fromEquirectangularTexture(e,d),t.set(d,_),d.addEventListener("dispose",l),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,m=f===Fc||f===zc,_=f===Ls||f===Wr;if(m||_){let p=n.get(d),g=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g){if(i===null)i=new fa(e);return p=m?i.fromEquirectangular(d,p):i.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),p.texture}else if(p!==void 0)return p.texture;else{let M=d.image;if(m&&M&&M.height>0||_&&M&&c(M)){if(i===null)i=new fa(e);return p=m?i.fromEquirectangular(d):i.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),d.addEventListener("dispose",u),p.texture}else return null}}}return d}function a(d,f){if(f===Fc)d.mapping=Ls;else if(f===zc)d.mapping=Wr;return d}function c(d){let f=0,m=6;for(let _=0;_<m;_++)if(d[_]!==void 0)f++;return f===m}function l(d){let f=d.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(d){let f=d.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function h(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:h}}function _1(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Vr("WebGLRenderer: "+i+" extension not supported.");return r}}}function x1(e,t,n,i){let r={},s=new WeakMap;function o(h){let d=h.target;if(d.index!==null)t.remove(d.index);for(let m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete r[d.id];let f=s.get(d);if(f)t.remove(f),s.delete(d);if(i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0)delete d._maxInstanceCount;n.memory.geometries--}function a(h,d){if(r[d.id]===!0)return d;return d.addEventListener("dispose",o),r[d.id]=!0,n.memory.geometries++,d}function c(h){let d=h.attributes;for(let f in d)t.update(d[f],e.ARRAY_BUFFER)}function l(h){let d=[],f=h.index,m=h.attributes.position,_=0;if(m===void 0)return;if(f!==null){let M=f.array;_=f.version;for(let T=0,v=M.length;T<v;T+=3){let S=M[T+0],E=M[T+1],R=M[T+2];d.push(S,E,E,R,R,S)}}else{let M=m.array;_=m.version;for(let T=0,v=M.length/3-1;T<v;T+=3){let S=T+0,E=T+1,R=T+2;d.push(S,E,E,R,R,S)}}let p=new(m.count>=65535?Qc:Jc)(d,1);p.version=_;let g=s.get(h);if(g)t.remove(g);s.set(h,p)}function u(h){let d=s.get(h);if(d){let f=h.index;if(f!==null){if(d.version<f.version)l(h)}}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function v1(e,t,n){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,d){e.drawElements(i,d,s,h*o),n.update(d,i,1)}function l(h,d,f){if(f===0)return;e.drawElementsInstanced(i,d,s,h*o,f),n.update(d,i,f)}function u(h,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,h,0,f);let _=0;for(let p=0;p<f;p++)_+=d[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function y1(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ve("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function b1(e,t,n){let i=new WeakMap,r=new pt;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=i.get(a);if(d===void 0||d.count!==h){let w=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",w)};if(d!==void 0)d.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],M=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let v=a.attributes.position.count*T,S=1;if(v>t.maxTextureSize)S=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let E=new Float32Array(v*S*4*h),R=new Yc(E,v,S,h);R.type=$i,R.needsUpdate=!0;let x=T*4;for(let G=0;G<h;G++){let C=p[G],D=g[G],ee=M[G],L=v*S*4*G;for(let W=0;W<C.count;W++){let B=W*x;if(f===!0)r.fromBufferAttribute(C,W),E[L+B+0]=r.x,E[L+B+1]=r.y,E[L+B+2]=r.z,E[L+B+3]=0;if(m===!0)r.fromBufferAttribute(D,W),E[L+B+4]=r.x,E[L+B+5]=r.y,E[L+B+6]=r.z,E[L+B+7]=0;if(_===!0)r.fromBufferAttribute(ee,W),E[L+B+8]=r.x,E[L+B+9]=r.y,E[L+B+10]=r.z,E[L+B+11]=ee.itemSize===4?r.w:1}}d={count:h,texture:R,size:new ke(v,S)},i.set(a,d),a.addEventListener("dispose",w)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}return{update:s}}function S1(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,h=l.geometry,d=t.get(l,h);if(s.get(d)!==u)t.update(d),s.set(d,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return d}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var w1={[_h]:"LINEAR_TONE_MAPPING",[xh]:"REINHARD_TONE_MAPPING",[vh]:"CINEON_TONE_MAPPING",[$o]:"ACES_FILMIC_TONE_MAPPING",[bh]:"AGX_TONE_MAPPING",[Sh]:"NEUTRAL_TONE_MAPPING",[yh]:"CUSTOM_TONE_MAPPING"};function M1(e,t,n,i,r,s){let o=new Cn(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new ln;l.setAttribute("position",new vn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new vn([0,2,0,0,2,0],2));let u=new _d({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
@@ -4176,17 +4176,17 @@ void main() {
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
- }`,depthTest:!1,depthWrite:!1}),h=new Mt(l,u),d=new Qr(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,M=[],T=!1;this.setSize=function(v,S){if(o.setSize(v,S),a!==null)a.setSize(v,S);if(c!==null)c.setSize(v,S);for(let E=0;E<M.length;E++){let R=M[E];if(R.setSize)R.setSize(v,S)}},this.setEffects=function(v){M=v,T=M.length>0&&M[0].isRenderPass===!0;let{width:S,height:E}=o;if(M.length>0&&a===null)a=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1}),c=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<M.length;R++){let x=M[R];if(x.setSize)x.setSize(S,E)}},this.begin=function(v,S){if(_)return!1;if(v.toneMapping===ei&&M.length===0)return!1;if(g=S,S!==null){let{width:E,height:R}=S;if(o.width!==E||o.height!==R)this.setSize(E,R)}if(T===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=ei,!0},this.hasRenderPass=function(){return T},this.end=function(v,S){v.toneMapping=p,_=!0;let E=o,R=a;for(let x=0;x<M.length;x++){let w=M[x];if(w.enabled===!1)continue;if(w.render(v,R,E,S),w.needsSwap!==!1)E=R,R=R===a?c:a}if(f!==v.outputColorSpace||m!==v.toneMapping){if(f=v.outputColorSpace,m=v.toneMapping,u.defines={},Ke.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=b1[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,v.setRenderTarget(g),v.render(h,d),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Jv=new Ot,zd=new Yr(1,1),Qv=new jc,ey=new fd,ty=new tl,Nv=[],Dv=[],Ov=new Float32Array(16),Uv=new Float32Array(9),Fv=new Float32Array(4);function Zs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Nv[r];if(s===void 0)s=new Float32Array(r),Nv[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function $t(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Wt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function gl(e,t){let n=Dv[t];if(n===void 0)n=new Int32Array(t),Dv[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function w1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function M1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2fv(this.addr,t),Wt(n,t)}}function E1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if($t(n,t))return;e.uniform3fv(this.addr,t),Wt(n,t)}}function T1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4fv(this.addr,t),Wt(n,t)}}function A1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Fv.set(i),e.uniformMatrix2fv(this.addr,!1,Fv),Wt(n,i)}}function R1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Uv.set(i),e.uniformMatrix3fv(this.addr,!1,Uv),Wt(n,i)}}function C1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Ov.set(i),e.uniformMatrix4fv(this.addr,!1,Ov),Wt(n,i)}}function I1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function P1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2iv(this.addr,t),Wt(n,t)}}function L1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3iv(this.addr,t),Wt(n,t)}}function N1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4iv(this.addr,t),Wt(n,t)}}function D1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function O1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2uiv(this.addr,t),Wt(n,t)}}function U1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3uiv(this.addr,t),Wt(n,t)}}function F1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4uiv(this.addr,t),Wt(n,t)}}function z1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)zd.compareFunction=n.isReversedDepthBuffer()?Xc:Zc,s=zd;else s=Jv;n.setTexture2D(t||s,r)}function k1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||ey,r)}function B1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||ty,r)}function G1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||Qv,r)}function H1(e){switch(e){case 5126:return w1;case 35664:return M1;case 35665:return E1;case 35666:return T1;case 35674:return A1;case 35675:return R1;case 35676:return C1;case 5124:case 35670:return I1;case 35667:case 35671:return P1;case 35668:case 35672:return L1;case 35669:case 35673:return N1;case 5125:return D1;case 36294:return O1;case 36295:return U1;case 36296:return F1;case 35678:case 36198:case 36298:case 36306:case 35682:return z1;case 35679:case 36299:case 36307:return k1;case 35680:case 36300:case 36308:case 36293:return B1;case 36289:case 36303:case 36311:case 36292:return G1}}function V1(e,t){e.uniform1fv(this.addr,t)}function $1(e,t){let n=Zs(t,this.size,2);e.uniform2fv(this.addr,n)}function W1(e,t){let n=Zs(t,this.size,3);e.uniform3fv(this.addr,n)}function Z1(e,t){let n=Zs(t,this.size,4);e.uniform4fv(this.addr,n)}function X1(e,t){let n=Zs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function j1(e,t){let n=Zs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function q1(e,t){let n=Zs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Y1(e,t){e.uniform1iv(this.addr,t)}function K1(e,t){e.uniform2iv(this.addr,t)}function J1(e,t){e.uniform3iv(this.addr,t)}function Q1(e,t){e.uniform4iv(this.addr,t)}function eR(e,t){e.uniform1uiv(this.addr,t)}function tR(e,t){e.uniform2uiv(this.addr,t)}function nR(e,t){e.uniform3uiv(this.addr,t)}function iR(e,t){e.uniform4uiv(this.addr,t)}function rR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=zd;else o=Jv;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function sR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||ey,s[o])}function oR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||ty,s[o])}function aR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Qv,s[o])}function cR(e){switch(e){case 5126:return V1;case 35664:return $1;case 35665:return W1;case 35666:return Z1;case 35674:return X1;case 35675:return j1;case 35676:return q1;case 5124:case 35670:return Y1;case 35667:case 35671:return K1;case 35668:case 35672:return J1;case 35669:case 35673:return Q1;case 5125:return eR;case 36294:return tR;case 36295:return nR;case 36296:return iR;case 35678:case 36198:case 36298:case 36306:case 35682:return rR;case 35679:case 36299:case 36307:return sR;case 35680:case 36300:case 36308:case 36293:return oR;case 36289:case 36303:case 36311:case 36292:return aR}}class ny{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=H1(t.type)}}class iy{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=cR(t.type)}}class ry{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Ud=/(\w+)(\])?(\[|\.)?/g;function zv(e,t){e.seq.push(t),e.map[t.id]=t}function lR(e,t,n){let i=e.name,r=i.length;Ud.lastIndex=0;while(!0){let s=Ud.exec(i),o=Ud.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){zv(n,l===void 0?new ny(a,e,t):new iy(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new ry(a),zv(n,h);n=h}}}class la{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);lR(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function kv(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var uR=37297,hR=0;function dR(e,t){let n=e.split(`
+ }`,depthTest:!1,depthWrite:!1}),h=new Mt(l,u),d=new es(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,M=[],T=!1;this.setSize=function(v,S){if(o.setSize(v,S),a!==null)a.setSize(v,S);if(c!==null)c.setSize(v,S);for(let E=0;E<M.length;E++){let R=M[E];if(R.setSize)R.setSize(v,S)}},this.setEffects=function(v){M=v,T=M.length>0&&M[0].isRenderPass===!0;let{width:S,height:E}=o;if(M.length>0&&a===null)a=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1}),c=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<M.length;R++){let x=M[R];if(x.setSize)x.setSize(S,E)}},this.begin=function(v,S){if(_)return!1;if(v.toneMapping===ei&&M.length===0)return!1;if(g=S,S!==null){let{width:E,height:R}=S;if(o.width!==E||o.height!==R)this.setSize(E,R)}if(T===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=ei,!0},this.hasRenderPass=function(){return T},this.end=function(v,S){v.toneMapping=p,_=!0;let E=o,R=a;for(let x=0;x<M.length;x++){let w=M[x];if(w.enabled===!1)continue;if(w.render(v,R,E,S),w.needsSwap!==!1)E=R,R=R===a?c:a}if(f!==v.outputColorSpace||m!==v.toneMapping){if(f=v.outputColorSpace,m=v.toneMapping,u.defines={},Ke.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=w1[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,v.setRenderTarget(g),v.render(h,d),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Qv=new Ot,kd=new Kr(1,1),ey=new Yc,ty=new pd,ny=new il,Dv=[],Ov=[],Uv=new Float32Array(16),Fv=new Float32Array(9),zv=new Float32Array(4);function js(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Dv[r];if(s===void 0)s=new Float32Array(r),Dv[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function $t(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Wt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function _l(e,t){let n=Ov[t];if(n===void 0)n=new Int32Array(t),Ov[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function E1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function T1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2fv(this.addr,t),Wt(n,t)}}function A1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if($t(n,t))return;e.uniform3fv(this.addr,t),Wt(n,t)}}function R1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4fv(this.addr,t),Wt(n,t)}}function C1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;zv.set(i),e.uniformMatrix2fv(this.addr,!1,zv),Wt(n,i)}}function I1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Fv.set(i),e.uniformMatrix3fv(this.addr,!1,Fv),Wt(n,i)}}function P1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Uv.set(i),e.uniformMatrix4fv(this.addr,!1,Uv),Wt(n,i)}}function L1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function N1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2iv(this.addr,t),Wt(n,t)}}function D1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3iv(this.addr,t),Wt(n,t)}}function O1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4iv(this.addr,t),Wt(n,t)}}function U1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function F1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2uiv(this.addr,t),Wt(n,t)}}function z1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3uiv(this.addr,t),Wt(n,t)}}function k1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4uiv(this.addr,t),Wt(n,t)}}function B1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)kd.compareFunction=n.isReversedDepthBuffer()?qc:jc,s=kd;else s=Qv;n.setTexture2D(t||s,r)}function G1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||ty,r)}function H1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||ny,r)}function V1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||ey,r)}function $1(e){switch(e){case 5126:return E1;case 35664:return T1;case 35665:return A1;case 35666:return R1;case 35674:return C1;case 35675:return I1;case 35676:return P1;case 5124:case 35670:return L1;case 35667:case 35671:return N1;case 35668:case 35672:return D1;case 35669:case 35673:return O1;case 5125:return U1;case 36294:return F1;case 36295:return z1;case 36296:return k1;case 35678:case 36198:case 36298:case 36306:case 35682:return B1;case 35679:case 36299:case 36307:return G1;case 35680:case 36300:case 36308:case 36293:return H1;case 36289:case 36303:case 36311:case 36292:return V1}}function W1(e,t){e.uniform1fv(this.addr,t)}function Z1(e,t){let n=js(t,this.size,2);e.uniform2fv(this.addr,n)}function X1(e,t){let n=js(t,this.size,3);e.uniform3fv(this.addr,n)}function j1(e,t){let n=js(t,this.size,4);e.uniform4fv(this.addr,n)}function q1(e,t){let n=js(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Y1(e,t){let n=js(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function K1(e,t){let n=js(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function J1(e,t){e.uniform1iv(this.addr,t)}function Q1(e,t){e.uniform2iv(this.addr,t)}function eR(e,t){e.uniform3iv(this.addr,t)}function tR(e,t){e.uniform4iv(this.addr,t)}function nR(e,t){e.uniform1uiv(this.addr,t)}function iR(e,t){e.uniform2uiv(this.addr,t)}function rR(e,t){e.uniform3uiv(this.addr,t)}function sR(e,t){e.uniform4uiv(this.addr,t)}function oR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=kd;else o=Qv;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function aR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||ty,s[o])}function cR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||ny,s[o])}function lR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||ey,s[o])}function uR(e){switch(e){case 5126:return W1;case 35664:return Z1;case 35665:return X1;case 35666:return j1;case 35674:return q1;case 35675:return Y1;case 35676:return K1;case 5124:case 35670:return J1;case 35667:case 35671:return Q1;case 35668:case 35672:return eR;case 35669:case 35673:return tR;case 5125:return nR;case 36294:return iR;case 36295:return rR;case 36296:return sR;case 35678:case 36198:case 36298:case 36306:case 35682:return oR;case 35679:case 36299:case 36307:return aR;case 35680:case 36300:case 36308:case 36293:return cR;case 36289:case 36303:case 36311:case 36292:return lR}}class iy{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=$1(t.type)}}class ry{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=uR(t.type)}}class sy{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Fd=/(\w+)(\])?(\[|\.)?/g;function kv(e,t){e.seq.push(t),e.map[t.id]=t}function hR(e,t,n){let i=e.name,r=i.length;Fd.lastIndex=0;while(!0){let s=Fd.exec(i),o=Fd.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){kv(n,l===void 0?new iy(a,e,t):new ry(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new sy(a),kv(n,h);n=h}}}class da{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);hR(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Bv(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var dR=37297,fR=0;function pR(e,t){let n=e.split(`
`),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===t?">":" "} ${a}: ${n[o]}`)}return i.join(`
-`)}var Bv=new We;function fR(e){Ke._getMatrix(Bv,Ke.workingColorSpace,e);let t=`mat3( ${Bv.elements.map((n)=>n.toFixed(4))} )`;switch(Ke.getTransfer(e)){case ad:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Gv(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
+`)}var Gv=new We;function mR(e){Ke._getMatrix(Gv,Ke.workingColorSpace,e);let t=`mat3( ${Gv.elements.map((n)=>n.toFixed(4))} )`;switch(Ke.getTransfer(e)){case cd:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Hv(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
`+s+`
-`+dR(e.getShaderSource(t),a)}else return s}function pR(e,t){let n=fR(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var mR={[gh]:"Linear",[_h]:"Reinhard",[xh]:"Cineon",[Go]:"ACESFilmic",[yh]:"AgX",[bh]:"Neutral",[vh]:"Custom"};function gR(e,t){let n=mR[t];if(n===void 0)return Ue("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var pl=new F;function _R(){Ke.getLuminanceCoefficients(pl);let e=pl.x.toFixed(4),t=pl.y.toFixed(4),n=pl.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function xR(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ca).join(`
-`)}function vR(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
-`)}function yR(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function ca(e){return e!==""}function Hv(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Vv(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var bR=/^[ \t]*#include +<([\w\d./]+)>/gm;function kd(e){return e.replace(bR,wR)}var SR=new Map;function wR(e,t){let n=Ye[t];if(n===void 0){let i=SR.get(t);if(i!==void 0)n=Ye[i],Ue('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return kd(n)}var MR=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function $v(e){return e.replace(MR,ER)}function ER(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Wv(e){let t=`precision ${e.precision} float;
+`+pR(e.getShaderSource(t),a)}else return s}function gR(e,t){let n=mR(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}var _R={[_h]:"Linear",[xh]:"Reinhard",[vh]:"Cineon",[$o]:"ACESFilmic",[bh]:"AgX",[Sh]:"Neutral",[yh]:"Custom"};function xR(e,t){let n=_R[t];if(n===void 0)return Ue("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var ml=new z;function vR(){Ke.getLuminanceCoefficients(ml);let e=ml.x.toFixed(4),t=ml.y.toFixed(4),n=ml.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function yR(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ha).join(`
+`)}function bR(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
+`)}function SR(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function ha(e){return e!==""}function Vv(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function $v(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var wR=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bd(e){return e.replace(wR,ER)}var MR=new Map;function ER(e,t){let n=Ye[t];if(n===void 0){let i=MR.get(t);if(i!==void 0)n=Ye[i],Ue('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Bd(n)}var TR=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Wv(e){return e.replace(TR,AR)}function AR(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Zv(e){let t=`precision ${e.precision} float;
precision ${e.precision} int;
precision ${e.precision} sampler2D;
precision ${e.precision} samplerCube;
@@ -4206,30 +4206,30 @@ void main() {
`;if(e.precision==="highp")t+=`
#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
-#define LOW_PRECISION`;return t}var TR={[ko]:"SHADOWMAP_TYPE_PCF",[Cs]:"SHADOWMAP_TYPE_VSM"};function AR(e){return TR[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var RR={[Ps]:"ENVMAP_TYPE_CUBE",[$r]:"ENVMAP_TYPE_CUBE",[Ho]:"ENVMAP_TYPE_CUBE_UV"};function CR(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return RR[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var IR={[$r]:"ENVMAP_MODE_REFRACTION"};function PR(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return IR[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var LR={[Qx]:"ENVMAP_BLENDING_MULTIPLY",[ev]:"ENVMAP_BLENDING_MIX",[tv]:"ENVMAP_BLENDING_ADD"};function NR(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return LR[e.combine]||"ENVMAP_BLENDING_NONE"}function DR(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function OR(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=AR(n),l=CR(n),u=PR(n),h=NR(n),d=DR(n),f=xR(n),m=vR(s),_=r.createProgram(),p,g,M=n.glslVersion?"#version "+n.glslVersion+`
-`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ca).join(`
+#define LOW_PRECISION`;return t}var RR={[Ho]:"SHADOWMAP_TYPE_PCF",[Is]:"SHADOWMAP_TYPE_VSM"};function CR(e){return RR[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var IR={[Ls]:"ENVMAP_TYPE_CUBE",[Wr]:"ENVMAP_TYPE_CUBE",[Wo]:"ENVMAP_TYPE_CUBE_UV"};function PR(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return IR[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var LR={[Wr]:"ENVMAP_MODE_REFRACTION"};function NR(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return LR[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var DR={[ev]:"ENVMAP_BLENDING_MULTIPLY",[tv]:"ENVMAP_BLENDING_MIX",[nv]:"ENVMAP_BLENDING_ADD"};function OR(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return DR[e.combine]||"ENVMAP_BLENDING_NONE"}function UR(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function FR(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=CR(n),l=PR(n),u=NR(n),h=OR(n),d=UR(n),f=yR(n),m=bR(s),_=r.createProgram(),p,g,M=n.glslVersion?"#version "+n.glslVersion+`
+`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ha).join(`
`),p.length>0)p+=`
-`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ca).join(`
+`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ha).join(`
`),g.length>0)g+=`
-`}else p=[Wv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
-`].filter(ca).join(`
-`),g=[Wv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ei?"#define TONE_MAPPING":"",n.toneMapping!==ei?Ye.tonemapping_pars_fragment:"",n.toneMapping!==ei?gR("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,pR("linearToOutputTexel",n.outputColorSpace),_R(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
-`].filter(ca).join(`
-`);if(o=kd(o),o=Hv(o,n),o=Vv(o,n),a=kd(a),a=Hv(a,n),a=Vv(a,n),o=$v(o),a=$v(a),n.isRawShaderMaterial!==!0)M=`#version 300 es
+`}else p=[Zv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
+`].filter(ha).join(`
+`),g=[Zv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ei?"#define TONE_MAPPING":"",n.toneMapping!==ei?Ye.tonemapping_pars_fragment:"",n.toneMapping!==ei?xR("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,gR("linearToOutputTexel",n.outputColorSpace),vR(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`].filter(ha).join(`
+`);if(o=Bd(o),o=Vv(o,n),o=$v(o,n),a=Bd(a),a=Vv(a,n),a=$v(a,n),o=Wv(o),a=Wv(a),n.isRawShaderMaterial!==!0)M=`#version 300 es
`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+p,g=["#define varying in",n.glslVersion===cd?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===cd?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
+`+p,g=["#define varying in",n.glslVersion===ld?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ld?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+g;let T=M+p+o,v=M+g+a,S=kv(r,r.VERTEX_SHADER,T),E=kv(r,r.FRAGMENT_SHADER,v);if(r.attachShader(_,S),r.attachShader(_,E),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let N=r.getProgramInfoLog(_)||"",ee=r.getShaderInfoLog(S)||"",P=r.getShaderInfoLog(E)||"",Z=N.trim(),G=ee.trim(),k=P.trim(),W=!0,B=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(W=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,S,E);else{let Y=Gv(r,S,"vertex"),K=Gv(r,E,"fragment");$e("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
+`+g;let T=M+p+o,v=M+g+a,S=Bv(r,r.VERTEX_SHADER,T),E=Bv(r,r.FRAGMENT_SHADER,v);if(r.attachShader(_,S),r.attachShader(_,E),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let D=r.getProgramInfoLog(_)||"",ee=r.getShaderInfoLog(S)||"",L=r.getShaderInfoLog(E)||"",W=D.trim(),B=ee.trim(),P=L.trim(),J=!0,H=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(J=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,S,E);else{let q=Hv(r,S,"vertex"),Q=Hv(r,E,"fragment");Ve("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
Material Name: `+C.name+`
Material Type: `+C.type+`
-Program Info Log: `+Z+`
-`+Y+`
-`+K)}else if(Z!=="")Ue("WebGLProgram: Program Info Log:",Z);else if(G===""||k==="")B=!1;if(B)C.diagnostics={runnable:W,programLog:Z,vertexShader:{log:G,prefix:p},fragmentShader:{log:k,prefix:g}}}r.deleteShader(S),r.deleteShader(E),x=new la(r,_),w=yR(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let w;this.getAttributes=function(){if(w===void 0)R(this);return w};let H=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(H===!1)H=r.getProgramParameter(_,uR);return H},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=hR++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=E,this}var UR=0;class sy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new oy(e),t.set(e,n);return n}}class oy{constructor(e){this.id=UR++,this.code=e,this.usedTimes=0}}function FR(e){return e===jr||e===Vc||e===$c}function zR(e,t,n,i,r,s){let o=new qc,a=new sy,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:h,precision:d}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,w,H,C,N,ee){let P=C.fog,Z=N.geometry,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,W=t.get(x.envMap||G,k),B=!!W&&W.mapping===Ho?W.image.height:null,Y=f[x.type];if(x.precision!==null){if(d=i.getMaxPrecision(x.precision),d!==x.precision)Ue("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead.")}let K=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ge=K!==void 0?K.length:0,de=0;if(Z.morphAttributes.position!==void 0)de=1;if(Z.morphAttributes.normal!==void 0)de=2;if(Z.morphAttributes.color!==void 0)de=3;let fe,he,I,V;if(Y){let bt=Ei[Y];fe=bt.vertexShader,he=bt.fragmentShader}else{fe=x.vertexShader,he=x.fragmentShader;let bt=a.getVertexShaderStage(x),ht=a.getFragmentShaderStage(x);a.update(x,bt,ht),I=bt.id,V=ht.id}let q=e.getRenderTarget(),se=e.state.buffers.depth.getReversed(),ce=N.isInstancedMesh===!0,ae=N.isBatchedMesh===!0,ke=!!x.map,Ce=!!x.matcap,Ve=!!W,rt=!!x.aoMap,nt=!!x.lightMap,Rt=!!x.bumpMap&&x.wireframe===!1,it=!!x.normalMap,tn=!!x.displacementMap,Ut=!!x.emissiveMap,It=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ut=x.clearcoat>0,Pt=x.dispersion>0,A=x.retroreflectivity>0,y=x.iridescence>0,O=x.sheen>0,J=x.transmission>0,ue=_n&&!!x.anisotropyMap,me=ut&&!!x.clearcoatMap,ve=ut&&!!x.clearcoatNormalMap,te=ut&&!!x.clearcoatRoughnessMap,re=y&&!!x.iridescenceMap,Ee=y&&!!x.iridescenceThicknessMap,Oe=O&&!!x.sheenColorMap,ye=O&&!!x.sheenRoughnessMap,pe=!!x.specularMap,ze=!!x.specularColorMap,Ge=!!x.specularIntensityMap,ot=J&&!!x.transmissionMap,z=J&&!!x.thicknessMap,_e=!!x.gradientMap,ne=!!x.alphaMap,xe=x.alphaTest>0,Te=!!x.alphaHash,le=!!x.extensions,Se=ei;if(x.toneMapped){if(q===null||q.isXRRenderTarget===!0)Se=e.toneMapping}let Ze={shaderID:Y,shaderType:x.type,shaderName:x.name,vertexShader:fe,fragmentShader:he,defines:x.defines,customVertexShaderID:I,customFragmentShaderID:V,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:ae,batchingColor:ae&&N._colorsTexture!==null,instancing:ce,instancingColor:ce&&N.instanceColor!==null,instancingMorph:ce&&N.morphTexture!==null,outputColorSpace:q===null?e.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:Ke.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:ke,matcap:Ce,envMap:Ve,envMapMode:Ve&&W.mapping,envMapCubeUVHeight:B,aoMap:rt,lightMap:nt,bumpMap:Rt,normalMap:it,displacementMap:tn,emissiveMap:Ut,normalMapObjectSpace:it&&x.normalMapType===lv,normalMapTangentSpace:it&&x.normalMapType===od,packedNormalMap:it&&x.normalMapType===od&&FR(x.normalMap.format),metalnessMap:It,roughnessMap:D,anisotropy:_n,anisotropyMap:ue,clearcoat:ut,clearcoatMap:me,clearcoatNormalMap:ve,clearcoatRoughnessMap:te,dispersion:Pt,retroreflection:A,iridescence:y,iridescenceMap:re,iridescenceThicknessMap:Ee,sheen:O,sheenColorMap:Oe,sheenRoughnessMap:ye,specularMap:pe,specularColorMap:ze,specularIntensityMap:Ge,transmission:J,transmissionMap:ot,thicknessMap:z,gradientMap:_e,opaque:x.transparent===!1&&x.blending===Bo&&x.alphaToCoverage===!1,alphaMap:ne,alphaTest:xe,alphaHash:Te,combine:x.combine,mapUv:ke&&m(x.map.channel),aoMapUv:rt&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Rt&&m(x.bumpMap.channel),normalMapUv:it&&m(x.normalMap.channel),displacementMapUv:tn&&m(x.displacementMap.channel),emissiveMapUv:Ut&&m(x.emissiveMap.channel),metalnessMapUv:It&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ue&&m(x.anisotropyMap.channel),clearcoatMapUv:me&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:ve&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:ye&&m(x.sheenRoughnessMap.channel),specularMapUv:pe&&m(x.specularMap.channel),specularColorMapUv:ze&&m(x.specularColorMap.channel),specularIntensityMapUv:Ge&&m(x.specularIntensityMap.channel),transmissionMapUv:ot&&m(x.transmissionMap.channel),thicknessMapUv:z&&m(x.thicknessMap.channel),alphaMapUv:ne&&m(x.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(it||_n),vertexNormals:!!Z.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!Z.attributes.uv&&(ke||ne),fog:!!P,useFog:x.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||Z.attributes.normal===void 0&&it===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:se,skinning:N.isSkinnedMesh===!0,hasPositionAttribute:Z.attributes.position!==void 0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:de,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&H.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,decodeVideoTexture:ke&&x.map.isVideoTexture===!0&&Ke.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:Ut&&x.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Bn,flipSided:x.side===cn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:le&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(le&&x.extensions.multiDraw===!0||ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Ze.vertexUv1s=c.has(1),Ze.vertexUv2s=c.has(2),Ze.vertexUv3s=c.has(3),c.clear(),Ze}function p(x){let w=[];if(x.shaderID)w.push(x.shaderID);else w.push(x.customVertexShaderID),w.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let H in x.defines)w.push(H),w.push(x.defines[H]);if(x.isRawShaderMaterial===!1)g(w,x),M(w,x),w.push(e.outputColorSpace);return w.push(x.customProgramCacheKey),w.join()}function g(x,w){x.push(w.precision),x.push(w.outputColorSpace),x.push(w.envMapMode),x.push(w.envMapCubeUVHeight),x.push(w.mapUv),x.push(w.alphaMapUv),x.push(w.lightMapUv),x.push(w.aoMapUv),x.push(w.bumpMapUv),x.push(w.normalMapUv),x.push(w.displacementMapUv),x.push(w.emissiveMapUv),x.push(w.metalnessMapUv),x.push(w.roughnessMapUv),x.push(w.anisotropyMapUv),x.push(w.clearcoatMapUv),x.push(w.clearcoatNormalMapUv),x.push(w.clearcoatRoughnessMapUv),x.push(w.iridescenceMapUv),x.push(w.iridescenceThicknessMapUv),x.push(w.sheenColorMapUv),x.push(w.sheenRoughnessMapUv),x.push(w.specularMapUv),x.push(w.specularColorMapUv),x.push(w.specularIntensityMapUv),x.push(w.transmissionMapUv),x.push(w.thicknessMapUv),x.push(w.combine),x.push(w.fogExp2),x.push(w.sizeAttenuation),x.push(w.morphTargetsCount),x.push(w.morphAttributeCount),x.push(w.numSunLights),x.push(w.numDirLights),x.push(w.numPointLights),x.push(w.numSpotLights),x.push(w.numSpotLightMaps),x.push(w.numHemiLights),x.push(w.numRectAreaLights),x.push(w.numSunLightShadows),x.push(w.numDirLightShadows),x.push(w.numPointLightShadows),x.push(w.numSpotLightShadows),x.push(w.numSpotLightShadowsWithMaps),x.push(w.numLightProbes),x.push(w.shadowMapType),x.push(w.toneMapping),x.push(w.numClippingPlanes),x.push(w.numClipIntersection),x.push(w.depthPacking)}function M(x,w){if(o.disableAll(),w.instancing)o.enable(0);if(w.instancingColor)o.enable(1);if(w.instancingMorph)o.enable(2);if(w.matcap)o.enable(3);if(w.envMap)o.enable(4);if(w.normalMapObjectSpace)o.enable(5);if(w.normalMapTangentSpace)o.enable(6);if(w.clearcoat)o.enable(7);if(w.iridescence)o.enable(8);if(w.alphaTest)o.enable(9);if(w.vertexColors)o.enable(10);if(w.vertexAlphas)o.enable(11);if(w.vertexUv1s)o.enable(12);if(w.vertexUv2s)o.enable(13);if(w.vertexUv3s)o.enable(14);if(w.vertexTangents)o.enable(15);if(w.anisotropy)o.enable(16);if(w.alphaHash)o.enable(17);if(w.batching)o.enable(18);if(w.dispersion)o.enable(19);if(w.retroreflection)o.enable(24);if(w.batchingColor)o.enable(20);if(w.gradientMap)o.enable(21);if(w.packedNormalMap)o.enable(22);if(w.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),w.fog)o.enable(0);if(w.useFog)o.enable(1);if(w.flatShading)o.enable(2);if(w.logarithmicDepthBuffer)o.enable(3);if(w.reversedDepthBuffer)o.enable(4);if(w.skinning)o.enable(5);if(w.morphTargets)o.enable(6);if(w.morphNormals)o.enable(7);if(w.morphColors)o.enable(8);if(w.premultipliedAlpha)o.enable(9);if(w.shadowMapEnabled)o.enable(10);if(w.doubleSided)o.enable(11);if(w.flipSided)o.enable(12);if(w.useDepthPacking)o.enable(13);if(w.dithering)o.enable(14);if(w.transmission)o.enable(15);if(w.sheen)o.enable(16);if(w.opaque)o.enable(17);if(w.pointsUvs)o.enable(18);if(w.decodeVideoTexture)o.enable(19);if(w.decodeVideoTextureEmissive)o.enable(20);if(w.alphaToCoverage)o.enable(21);if(w.numLightProbeGrids>0)o.enable(22);if(w.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let w=f[x.type],H;if(w){let C=Ei[w];H=bv.clone(C.uniforms)}else H=x.uniforms;return H}function v(x,w){let H=u.get(w);if(H!==void 0)++H.usedTimes;else H=new OR(e,w,x,r),l.push(H),u.set(w,H);return H}function S(x){if(--x.usedTimes===0){let w=l.indexOf(x);l[w]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function E(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:v,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:R}}function kR(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function BR(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Zv(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Xv(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(d){let f=0;if(d.isInstancedMesh)f+=2;if(d.isSkinnedMesh)f+=1;return f}function a(d,f,m,_,p,g){let M=e[t];if(M===void 0)M={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=M;else M.id=d.id,M.object=d,M.geometry=f,M.material=m,M.materialVariant=o(d),M.groupOrder=_,M.renderOrder=d.renderOrder,M.z=p,M.group=g;return t++,M}function c(d,f,m,_,p,g,M){if(M.reversedDepth===!0)p=-p;let T=a(d,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(d,f,m,_,p,g){let M=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(M);else if(m.transparent===!0)r.unshift(M);else n.unshift(M)}function u(d,f){if(n.length>1)n.sort(d||BR);if(i.length>1)i.sort(f||Zv);if(r.length>1)r.sort(f||Zv)}function h(){for(let d=t,f=e.length;d<f;d++){let m=e[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:h,sort:u}}function GR(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Xv,e.set(i,[o]);else if(r>=s.length)o=new Xv,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function HR(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new F,color:new He};break;case"SpotLight":n={position:new F,direction:new F,color:new He,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new F,color:new He,distance:0,decay:0};break;case"HemisphereLight":n={direction:new F,skyColor:new He,groundColor:new He};break;case"RectAreaLight":n={color:new He,position:new F,halfWidth:new F,halfHeight:new F};break}return e[t.id]=n,n}}}function VR(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var $R=0;function WR(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function ZR(e){let t=new HR,n=VR(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new F);let r=new F,s=new Xe,o=new Xe;function a(l){let u=0,h=0,d=0;for(let N=0;N<9;N++)i.probe[N].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,M=0,T=0,v=0,S=0,E=0,R=0,x=0,w=0,H=0;l.sort(WR);for(let N=0,ee=l.length;N<ee;N++){let P=l[N],{color:Z,intensity:G,distance:k}=P,W=null;if(P.shadow&&P.shadow.map)if(P.shadow.map.texture.format===jr)W=P.shadow.map.texture;else W=P.shadow.map.depthTexture||P.shadow.map.texture;if(P.isAmbientLight)u+=Z.r*G,h+=Z.g*G,d+=Z.b*G;else if(P.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(P.sh.coefficients[B],G);H++}else if(P.isSunLight){let B=t.get(P);if(B.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let Y=P.shadow,K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize.copy(Y.mapSize).multiply(Y.getFrameExtents()),i.sunShadow[m]=K,i.sunShadowMap[m]=W;let ge=Y.getViewportCount();for(let de=0;de<ge;de++)i.sunShadowMatrix[_+de]=Y.getMatrix(de),i.sunShadowCascade[_+de]=Y._cascadeData[de];_+=ge,m++}i.sun[f]=B,f++}else if(P.isDirectionalLight){let B=t.get(P);if(B.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let Y=P.shadow,K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize=Y.mapSize,i.directionalShadow[p]=K,i.directionalShadowMap[p]=W,i.directionalShadowMatrix[p]=P.shadow.matrix,S++}i.directional[p]=B,p++}else if(P.isSpotLight){let B=t.get(P);B.position.setFromMatrixPosition(P.matrixWorld),B.color.copy(Z).multiplyScalar(G),B.distance=k,B.coneCos=Math.cos(P.angle),B.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),B.decay=P.decay,i.spot[M]=B;let Y=P.shadow;if(P.map){if(i.spotLightMap[x]=P.map,x++,Y.updateMatrices(P),P.castShadow)w++}if(i.spotLightMatrix[M]=Y.matrix,P.castShadow){let K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize=Y.mapSize,i.spotShadow[M]=K,i.spotShadowMap[M]=W,R++}M++}else if(P.isRectAreaLight){let B=t.get(P);B.color.copy(Z).multiplyScalar(G),B.halfWidth.set(P.width*0.5,0,0),B.halfHeight.set(0,P.height*0.5,0),i.rectArea[T]=B,T++}else if(P.isPointLight){let B=t.get(P);if(B.color.copy(P.color).multiplyScalar(P.intensity),B.distance=P.distance,B.decay=P.decay,P.castShadow){let Y=P.shadow,K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize=Y.mapSize,K.shadowCameraNear=Y.camera.near,K.shadowCameraFar=Y.camera.far,i.pointShadow[g]=K,i.pointShadowMap[g]=W,i.pointShadowMatrix[g]=P.shadow.matrix,E++}i.point[g]=B,g++}else if(P.isHemisphereLight){let B=t.get(P);B.skyColor.copy(P.color).multiplyScalar(G),B.groundColor.copy(P.groundColor).multiplyScalar(G),i.hemi[v]=B,v++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=be.LTC_FLOAT_1,i.rectAreaLTC2=be.LTC_FLOAT_2;else i.rectAreaLTC1=be.LTC_HALF_1,i.rectAreaLTC2=be.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==M||C.rectAreaLength!==T||C.hemiLength!==v||C.numSunShadows!==m||C.numDirectionalShadows!==S||C.numPointShadows!==E||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==H)i.sun.length=f,i.directional.length=p,i.spot.length=M,i.rectArea.length=T,i.point.length=g,i.hemi.length=v,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.directionalShadowMatrix.length=S,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-w,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=H,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=M,C.rectAreaLength=T,C.hemiLength=v,C.numSunShadows=m,C.numDirectionalShadows=S,C.numPointShadows=E,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=H,i.version=$R++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let M=0,T=l.length;M<T;M++){let v=l[M];if(v.isSunLight){let S=i.sun[h];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),h++}else if(v.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),d++}else if(v.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),m++}else if(v.isRectAreaLight){let S=i.rectArea[_];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),S.halfWidth.set(v.width*0.5,0,0),S.halfHeight.set(0,v.height*0.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),_++}else if(v.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),f++}else if(v.isHemisphereLight){let S=i.hemi[p];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function jv(e){let t=new ZR(e),n=[],i=[],r=[];function s(d){h.camera=d,n.length=0,i.length=0,r.length=0}function o(d){n.push(d)}function a(d){i.push(d)}function c(d){r.push(d)}function l(){t.setup(n)}function u(d){t.setupView(n,d)}let h={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:h,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function XR(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new jv(e),t.set(r,[a]);else if(s>=o.length)a=new jv(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var jR=`void main() {
+Program Info Log: `+W+`
+`+q+`
+`+Q)}else if(W!=="")Ue("WebGLProgram: Program Info Log:",W);else if(B===""||P==="")H=!1;if(H)C.diagnostics={runnable:J,programLog:W,vertexShader:{log:B,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(S),r.deleteShader(E),x=new da(r,_),w=SR(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let w;this.getAttributes=function(){if(w===void 0)R(this);return w};let G=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(G===!1)G=r.getProgramParameter(_,dR);return G},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=fR++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=E,this}var zR=0;class oy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new ay(e),t.set(e,n);return n}}class ay{constructor(e){this.id=zR++,this.code=e,this.usedTimes=0}}function kR(e){return e===qr||e===Wc||e===Zc}function BR(e,t,n,i,r,s){let o=new Kc,a=new oy,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:h,precision:d}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,w,G,C,D,ee){let L=C.fog,W=D.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,J=t.get(x.envMap||B,P),H=!!J&&J.mapping===Wo?J.image.height:null,q=f[x.type];if(x.precision!==null){if(d=i.getMaxPrecision(x.precision),d!==x.precision)Ue("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead.")}let Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,ge=Q!==void 0?Q.length:0,he=0;if(W.morphAttributes.position!==void 0)he=1;if(W.morphAttributes.normal!==void 0)he=2;if(W.morphAttributes.color!==void 0)he=3;let de,fe,I,V;if(q){let bt=Ei[q];de=bt.vertexShader,fe=bt.fragmentShader}else{de=x.vertexShader,fe=x.fragmentShader;let bt=a.getVertexShaderStage(x),ht=a.getFragmentShaderStage(x);a.update(x,bt,ht),I=bt.id,V=ht.id}let j=e.getRenderTarget(),re=e.state.buffers.depth.getReversed(),oe=D.isInstancedMesh===!0,ue=D.isBatchedMesh===!0,$e=!!x.map,Ce=!!x.matcap,He=!!J,rt=!!x.aoMap,nt=!!x.lightMap,Rt=!!x.bumpMap&&x.wireframe===!1,it=!!x.normalMap,tn=!!x.displacementMap,Ut=!!x.emissiveMap,It=!!x.metalnessMap,O=!!x.roughnessMap,_n=x.anisotropy>0,ut=x.clearcoat>0,Pt=x.dispersion>0,A=x.retroreflectivity>0,y=x.iridescence>0,U=x.sheen>0,Y=x.transmission>0,le=_n&&!!x.anisotropyMap,me=ut&&!!x.clearcoatMap,ve=ut&&!!x.clearcoatNormalMap,te=ut&&!!x.clearcoatRoughnessMap,se=y&&!!x.iridescenceMap,Ee=y&&!!x.iridescenceThicknessMap,Oe=U&&!!x.sheenColorMap,ye=U&&!!x.sheenRoughnessMap,pe=!!x.specularMap,ze=!!x.specularColorMap,Be=!!x.specularIntensityMap,ot=Y&&!!x.transmissionMap,k=Y&&!!x.thicknessMap,_e=!!x.gradientMap,ne=!!x.alphaMap,xe=x.alphaTest>0,Te=!!x.alphaHash,ce=!!x.extensions,Se=ei;if(x.toneMapped){if(j===null||j.isXRRenderTarget===!0)Se=e.toneMapping}let Ze={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:de,fragmentShader:fe,defines:x.defines,customVertexShaderID:I,customFragmentShaderID:V,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:ue,batchingColor:ue&&D._colorsTexture!==null,instancing:oe,instancingColor:oe&&D.instanceColor!==null,instancingMorph:oe&&D.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Ke.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:$e,matcap:Ce,envMap:He,envMapMode:He&&J.mapping,envMapCubeUVHeight:H,aoMap:rt,lightMap:nt,bumpMap:Rt,normalMap:it,displacementMap:tn,emissiveMap:Ut,normalMapObjectSpace:it&&x.normalMapType===uv,normalMapTangentSpace:it&&x.normalMapType===ad,packedNormalMap:it&&x.normalMapType===ad&&kR(x.normalMap.format),metalnessMap:It,roughnessMap:O,anisotropy:_n,anisotropyMap:le,clearcoat:ut,clearcoatMap:me,clearcoatNormalMap:ve,clearcoatRoughnessMap:te,dispersion:Pt,retroreflection:A,iridescence:y,iridescenceMap:se,iridescenceThicknessMap:Ee,sheen:U,sheenColorMap:Oe,sheenRoughnessMap:ye,specularMap:pe,specularColorMap:ze,specularIntensityMap:Be,transmission:Y,transmissionMap:ot,thicknessMap:k,gradientMap:_e,opaque:x.transparent===!1&&x.blending===Vo&&x.alphaToCoverage===!1,alphaMap:ne,alphaTest:xe,alphaHash:Te,combine:x.combine,mapUv:$e&&m(x.map.channel),aoMapUv:rt&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Rt&&m(x.bumpMap.channel),normalMapUv:it&&m(x.normalMap.channel),displacementMapUv:tn&&m(x.displacementMap.channel),emissiveMapUv:Ut&&m(x.emissiveMap.channel),metalnessMapUv:It&&m(x.metalnessMap.channel),roughnessMapUv:O&&m(x.roughnessMap.channel),anisotropyMapUv:le&&m(x.anisotropyMap.channel),clearcoatMapUv:me&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:ve&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:se&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:ye&&m(x.sheenRoughnessMap.channel),specularMapUv:pe&&m(x.specularMap.channel),specularColorMapUv:ze&&m(x.specularColorMap.channel),specularIntensityMapUv:Be&&m(x.specularIntensityMap.channel),transmissionMapUv:ot&&m(x.transmissionMap.channel),thicknessMapUv:k&&m(x.thicknessMap.channel),alphaMapUv:ne&&m(x.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(it||_n),vertexNormals:!!W.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!W.attributes.uv&&($e||ne),fog:!!L,useFog:x.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||W.attributes.normal===void 0&&it===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:re,skinning:D.isSkinnedMesh===!0,hasPositionAttribute:W.attributes.position!==void 0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:he,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&G.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,decodeVideoTexture:$e&&x.map.isVideoTexture===!0&&Ke.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:Ut&&x.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Bn,flipSided:x.side===cn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ce&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ce&&x.extensions.multiDraw===!0||ue)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Ze.vertexUv1s=c.has(1),Ze.vertexUv2s=c.has(2),Ze.vertexUv3s=c.has(3),c.clear(),Ze}function p(x){let w=[];if(x.shaderID)w.push(x.shaderID);else w.push(x.customVertexShaderID),w.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let G in x.defines)w.push(G),w.push(x.defines[G]);if(x.isRawShaderMaterial===!1)g(w,x),M(w,x),w.push(e.outputColorSpace);return w.push(x.customProgramCacheKey),w.join()}function g(x,w){x.push(w.precision),x.push(w.outputColorSpace),x.push(w.envMapMode),x.push(w.envMapCubeUVHeight),x.push(w.mapUv),x.push(w.alphaMapUv),x.push(w.lightMapUv),x.push(w.aoMapUv),x.push(w.bumpMapUv),x.push(w.normalMapUv),x.push(w.displacementMapUv),x.push(w.emissiveMapUv),x.push(w.metalnessMapUv),x.push(w.roughnessMapUv),x.push(w.anisotropyMapUv),x.push(w.clearcoatMapUv),x.push(w.clearcoatNormalMapUv),x.push(w.clearcoatRoughnessMapUv),x.push(w.iridescenceMapUv),x.push(w.iridescenceThicknessMapUv),x.push(w.sheenColorMapUv),x.push(w.sheenRoughnessMapUv),x.push(w.specularMapUv),x.push(w.specularColorMapUv),x.push(w.specularIntensityMapUv),x.push(w.transmissionMapUv),x.push(w.thicknessMapUv),x.push(w.combine),x.push(w.fogExp2),x.push(w.sizeAttenuation),x.push(w.morphTargetsCount),x.push(w.morphAttributeCount),x.push(w.numSunLights),x.push(w.numDirLights),x.push(w.numPointLights),x.push(w.numSpotLights),x.push(w.numSpotLightMaps),x.push(w.numHemiLights),x.push(w.numRectAreaLights),x.push(w.numSunLightShadows),x.push(w.numDirLightShadows),x.push(w.numPointLightShadows),x.push(w.numSpotLightShadows),x.push(w.numSpotLightShadowsWithMaps),x.push(w.numLightProbes),x.push(w.shadowMapType),x.push(w.toneMapping),x.push(w.numClippingPlanes),x.push(w.numClipIntersection),x.push(w.depthPacking)}function M(x,w){if(o.disableAll(),w.instancing)o.enable(0);if(w.instancingColor)o.enable(1);if(w.instancingMorph)o.enable(2);if(w.matcap)o.enable(3);if(w.envMap)o.enable(4);if(w.normalMapObjectSpace)o.enable(5);if(w.normalMapTangentSpace)o.enable(6);if(w.clearcoat)o.enable(7);if(w.iridescence)o.enable(8);if(w.alphaTest)o.enable(9);if(w.vertexColors)o.enable(10);if(w.vertexAlphas)o.enable(11);if(w.vertexUv1s)o.enable(12);if(w.vertexUv2s)o.enable(13);if(w.vertexUv3s)o.enable(14);if(w.vertexTangents)o.enable(15);if(w.anisotropy)o.enable(16);if(w.alphaHash)o.enable(17);if(w.batching)o.enable(18);if(w.dispersion)o.enable(19);if(w.retroreflection)o.enable(24);if(w.batchingColor)o.enable(20);if(w.gradientMap)o.enable(21);if(w.packedNormalMap)o.enable(22);if(w.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),w.fog)o.enable(0);if(w.useFog)o.enable(1);if(w.flatShading)o.enable(2);if(w.logarithmicDepthBuffer)o.enable(3);if(w.reversedDepthBuffer)o.enable(4);if(w.skinning)o.enable(5);if(w.morphTargets)o.enable(6);if(w.morphNormals)o.enable(7);if(w.morphColors)o.enable(8);if(w.premultipliedAlpha)o.enable(9);if(w.shadowMapEnabled)o.enable(10);if(w.doubleSided)o.enable(11);if(w.flipSided)o.enable(12);if(w.useDepthPacking)o.enable(13);if(w.dithering)o.enable(14);if(w.transmission)o.enable(15);if(w.sheen)o.enable(16);if(w.opaque)o.enable(17);if(w.pointsUvs)o.enable(18);if(w.decodeVideoTexture)o.enable(19);if(w.decodeVideoTextureEmissive)o.enable(20);if(w.alphaToCoverage)o.enable(21);if(w.numLightProbeGrids>0)o.enable(22);if(w.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let w=f[x.type],G;if(w){let C=Ei[w];G=Sv.clone(C.uniforms)}else G=x.uniforms;return G}function v(x,w){let G=u.get(w);if(G!==void 0)++G.usedTimes;else G=new FR(e,w,x,r),l.push(G),u.set(w,G);return G}function S(x){if(--x.usedTimes===0){let w=l.indexOf(x);l[w]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function E(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:v,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:R}}function GR(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function HR(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Xv(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function jv(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(d){let f=0;if(d.isInstancedMesh)f+=2;if(d.isSkinnedMesh)f+=1;return f}function a(d,f,m,_,p,g){let M=e[t];if(M===void 0)M={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=M;else M.id=d.id,M.object=d,M.geometry=f,M.material=m,M.materialVariant=o(d),M.groupOrder=_,M.renderOrder=d.renderOrder,M.z=p,M.group=g;return t++,M}function c(d,f,m,_,p,g,M){if(M.reversedDepth===!0)p=-p;let T=a(d,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(d,f,m,_,p,g){let M=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(M);else if(m.transparent===!0)r.unshift(M);else n.unshift(M)}function u(d,f){if(n.length>1)n.sort(d||HR);if(i.length>1)i.sort(f||Xv);if(r.length>1)r.sort(f||Xv)}function h(){for(let d=t,f=e.length;d<f;d++){let m=e[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:h,sort:u}}function VR(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new jv,e.set(i,[o]);else if(r>=s.length)o=new jv,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function $R(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new z,color:new Ge};break;case"SpotLight":n={position:new z,direction:new z,color:new Ge,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new z,color:new Ge,distance:0,decay:0};break;case"HemisphereLight":n={direction:new z,skyColor:new Ge,groundColor:new Ge};break;case"RectAreaLight":n={color:new Ge,position:new z,halfWidth:new z,halfHeight:new z};break}return e[t.id]=n,n}}}function WR(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var ZR=0;function XR(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function jR(e){let t=new $R,n=WR(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new z);let r=new z,s=new Xe,o=new Xe;function a(l){let u=0,h=0,d=0;for(let D=0;D<9;D++)i.probe[D].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,M=0,T=0,v=0,S=0,E=0,R=0,x=0,w=0,G=0;l.sort(XR);for(let D=0,ee=l.length;D<ee;D++){let L=l[D],{color:W,intensity:B,distance:P}=L,J=null;if(L.shadow&&L.shadow.map)if(L.shadow.map.texture.format===qr)J=L.shadow.map.texture;else J=L.shadow.map.depthTexture||L.shadow.map.texture;if(L.isAmbientLight)u+=W.r*B,h+=W.g*B,d+=W.b*B;else if(L.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(L.sh.coefficients[H],B);G++}else if(L.isSunLight){let H=t.get(L);if(H.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){let q=L.shadow,Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=Q,i.sunShadowMap[m]=J;let ge=q.getViewportCount();for(let he=0;he<ge;he++)i.sunShadowMatrix[_+he]=q.getMatrix(he),i.sunShadowCascade[_+he]=q._cascadeData[he];_+=ge,m++}i.sun[f]=H,f++}else if(L.isDirectionalLight){let H=t.get(L);if(H.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){let q=L.shadow,Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=J,i.directionalShadowMatrix[p]=L.shadow.matrix,S++}i.directional[p]=H,p++}else if(L.isSpotLight){let H=t.get(L);H.position.setFromMatrixPosition(L.matrixWorld),H.color.copy(W).multiplyScalar(B),H.distance=P,H.coneCos=Math.cos(L.angle),H.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),H.decay=L.decay,i.spot[M]=H;let q=L.shadow;if(L.map){if(i.spotLightMap[x]=L.map,x++,q.updateMatrices(L),L.castShadow)w++}if(i.spotLightMatrix[M]=q.matrix,L.castShadow){let Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[M]=Q,i.spotShadowMap[M]=J,R++}M++}else if(L.isRectAreaLight){let H=t.get(L);H.color.copy(W).multiplyScalar(B),H.halfWidth.set(L.width*0.5,0,0),H.halfHeight.set(0,L.height*0.5,0),i.rectArea[T]=H,T++}else if(L.isPointLight){let H=t.get(L);if(H.color.copy(L.color).multiplyScalar(L.intensity),H.distance=L.distance,H.decay=L.decay,L.castShadow){let q=L.shadow,Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,i.pointShadow[g]=Q,i.pointShadowMap[g]=J,i.pointShadowMatrix[g]=L.shadow.matrix,E++}i.point[g]=H,g++}else if(L.isHemisphereLight){let H=t.get(L);H.skyColor.copy(L.color).multiplyScalar(B),H.groundColor.copy(L.groundColor).multiplyScalar(B),i.hemi[v]=H,v++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=be.LTC_FLOAT_1,i.rectAreaLTC2=be.LTC_FLOAT_2;else i.rectAreaLTC1=be.LTC_HALF_1,i.rectAreaLTC2=be.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==M||C.rectAreaLength!==T||C.hemiLength!==v||C.numSunShadows!==m||C.numDirectionalShadows!==S||C.numPointShadows!==E||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==G)i.sun.length=f,i.directional.length=p,i.spot.length=M,i.rectArea.length=T,i.point.length=g,i.hemi.length=v,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.directionalShadowMatrix.length=S,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-w,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=G,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=M,C.rectAreaLength=T,C.hemiLength=v,C.numSunShadows=m,C.numDirectionalShadows=S,C.numPointShadows=E,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=G,i.version=ZR++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let M=0,T=l.length;M<T;M++){let v=l[M];if(v.isSunLight){let S=i.sun[h];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),h++}else if(v.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),d++}else if(v.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),m++}else if(v.isRectAreaLight){let S=i.rectArea[_];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),S.halfWidth.set(v.width*0.5,0,0),S.halfHeight.set(0,v.height*0.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),_++}else if(v.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),f++}else if(v.isHemisphereLight){let S=i.hemi[p];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function qv(e){let t=new jR(e),n=[],i=[],r=[];function s(d){h.camera=d,n.length=0,i.length=0,r.length=0}function o(d){n.push(d)}function a(d){i.push(d)}function c(d){r.push(d)}function l(){t.setup(n)}function u(d){t.setupView(n,d)}let h={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:h,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function qR(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new qv(e),t.set(r,[a]);else if(s>=o.length)a=new qv(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var YR=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,qR=`uniform sampler2D shadow_pass;
+}`,KR=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
@@ -4254,12 +4254,12 @@ void main() {
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
-}`,YR=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],KR=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],qv=new Xe,aa=new F,Fd=new F;function JR(e,t,n){let i=new Jo,r=new Be,s=new Be,o=new pt,a=new _d,c=new xd,l={},u=n.maxTextureSize,h={[fr]:cn,[cn]:fr,[Bn]:Bn},d=new Gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Be},radius:{value:4}},vertexShader:jR,fragmentShader:qR}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new ln;m.setAttribute("position",new Kt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ko;let g=this.type;this.render=function(E,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(E.length===0)return;if(this.type===Ex)Ue("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=ko;let w=e.getRenderTarget(),H=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),N=e.state;if(N.setBlending(vi),N.buffers.depth.getReversed()===!0)N.buffers.color.setClear(0,0,0,0);else N.buffers.color.setClear(1,1,1,1);N.buffers.depth.setTest(!0),N.setScissorTest(!1);let ee=g!==this.type;if(ee)R.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((Z)=>Z.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,Z=E.length;P<Z;P++){let G=E[P],k=G.shadow;if(k===void 0){Ue("WebGLShadowMap:",G,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);let W=k.getFrameExtents();if(r.multiply(W),s.copy(k.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/W.x),r.x=s.x*W.x,k.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/W.y),r.y=s.y*W.y,k.mapSize.y=s.y}let B=e.state.buffers.depth.getReversed();if(k.camera._reversedDepth=B,k.map===null||ee===!0){if(k.map!==null){if(k.map.depthTexture!==null)k.map.depthTexture.dispose(),k.map.depthTexture=null;k.map.dispose()}if(this.type===Cs){if(G.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new Cn(r.x,r.y,{format:jr,type:bi,minFilter:Jt,magFilter:Jt,generateMipmaps:!1}),k.map.texture.name=G.name+".shadowMap",k.map.depthTexture=new Yr(r.x,r.y,Vi),k.map.depthTexture.name=G.name+".shadowMapDepth",k.map.depthTexture.format=Zr,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=ti,k.map.depthTexture.magFilter=ti}else{if(G.isPointLight)k.map=new Bd(r.x),k.map.depthTexture=new pd(r.x,pr);else k.map=new Cn(r.x,r.y),k.map.depthTexture=new Yr(r.x,r.y,pr);if(k.map.depthTexture.name=G.name+".shadowMap",k.map.depthTexture.format=Zr,this.type===ko)k.map.depthTexture.compareFunction=B?Xc:Zc,k.map.depthTexture.minFilter=Jt,k.map.depthTexture.magFilter=Jt;else k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=ti,k.map.depthTexture.magFilter=ti}k.camera.updateProjectionMatrix()}if(k.map.isWebGLCubeRenderTarget!==!0&&(k.map.width!==r.x||k.map.height!==r.y))k.map.setSize(r.x,r.y);let Y=k.map.isWebGLCubeRenderTarget?6:k.getViewportCount();if(G.isPointLight!==!0)k.updateMatrices(G,x);for(let K=0;K<Y;K++){let ge=k.getCamera(K);if(G.isPointLight){let{camera:de,matrix:fe}=k,he=G.distance||de.far;if(he!==de.far)de.far=he,de.updateProjectionMatrix();aa.setFromMatrixPosition(G.matrixWorld),de.position.copy(aa),Fd.copy(de.position),Fd.add(YR[K]),de.up.copy(KR[K]),de.lookAt(Fd),de.updateMatrixWorld(),fe.makeTranslation(-aa.x,-aa.y,-aa.z),qv.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),k._frustum.setFromProjectionMatrix(qv,de.coordinateSystem,de.reversedDepth)}if(k.map.isWebGLCubeRenderTarget)e.setRenderTarget(k.map,K),e.clear();else{if(K===0)e.setRenderTarget(k.map),e.clear();let de=k.getViewport(K);o.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),N.viewport(o)}i=k.getFrustum(K),v(R,x,ge,G,this.type)}if(k.isPointLightShadow!==!0&&this.type===Cs)M(k,x);k.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(w,H,C)};function M(E,R){let x=t.update(_);if(d.defines.VSM_SAMPLES!==E.blurSamples)d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new Cn(r.x,r.y,{format:jr,type:bi});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value.set(E.map.width,E.map.height),d.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(E,R,x,w){let H=null,C=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(C!==void 0)H=C;else if(H=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let N=H.uuid,ee=R.uuid,P=l[N];if(P===void 0)P={},l[N]=P;let Z=P[ee];if(Z===void 0)Z=H.clone(),P[ee]=Z,R.addEventListener("dispose",S);H=Z}if(H.visible=R.visible,H.wireframe=R.wireframe,w===Cs)H.side=R.shadowSide!==null?R.shadowSide:R.side;else H.side=R.shadowSide!==null?R.shadowSide:h[R.side];if(H.alphaMap=R.alphaMap,H.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,H.map=R.map,H.clipShadows=R.clipShadows,H.clippingPlanes=R.clippingPlanes,H.clipIntersection=R.clipIntersection,H.displacementMap=R.displacementMap,H.displacementScale=R.displacementScale,H.displacementBias=R.displacementBias,H.wireframeLinewidth=R.wireframeLinewidth,H.linewidth=R.linewidth,x.isPointLight===!0&&H.isMeshDistanceMaterial===!0){let N=e.properties.get(H);N.light=x}return H}function v(E,R,x,w,H){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&H===Cs)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);let ee=t.update(E),P=E.material;if(Array.isArray(P)){let Z=ee.groups;for(let G=0,k=Z.length;G<k;G++){let W=Z[G],B=P[W.materialIndex];if(B&&B.visible){let Y=T(E,B,w,H);E.onBeforeShadow(e,E,R,x,ee,Y,W),e.renderBufferDirect(x,null,ee,Y,E,W),E.onAfterShadow(e,E,R,x,ee,Y,W)}}}else if(P.visible){let Z=T(E,P,w,H);E.onBeforeShadow(e,E,R,x,ee,Z,null),e.renderBufferDirect(x,null,ee,Z,E,null),E.onAfterShadow(e,E,R,x,ee,Z,null)}}}let N=E.children;for(let ee=0,P=N.length;ee<P;ee++)v(N[ee],R,x,w,H)}function S(E){E.target.removeEventListener("dispose",S);for(let x in l){let w=l[x],H=E.target.uuid;if(H in w)w[H].dispose(),delete w[H]}}}function QR(e,t){function n(){let z=!1,_e=new pt,ne=null,xe=new pt(0,0,0,0);return{setMask:function(Te){if(ne!==Te&&!z)e.colorMask(Te,Te,Te,Te),ne=Te},setLocked:function(Te){z=Te},setClear:function(Te,le,Se,Ze,bt){if(bt===!0)Te*=Ze,le*=Ze,Se*=Ze;if(_e.set(Te,le,Se,Ze),xe.equals(_e)===!1)e.clearColor(Te,le,Se,Ze),xe.copy(_e)},reset:function(){z=!1,ne=null,xe.set(-1,0,0,0)}}}function i(){let z=!1,_e=!1,ne=null,xe=null,Te=null;return{setReversed:function(le){if(_e!==le){let Se=t.get("EXT_clip_control");if(le)Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.ZERO_TO_ONE_EXT);else Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.NEGATIVE_ONE_TO_ONE_EXT);_e=le;let Ze=Te;Te=null,this.setClear(Ze)}},getReversed:function(){return _e},setTest:function(le){if(le)q(e.DEPTH_TEST);else se(e.DEPTH_TEST)},setMask:function(le){if(ne!==le&&!z)e.depthMask(le),ne=le},setFunc:function(le){if(_e)le=vv[le];if(xe!==le){switch(le){case Zx:e.depthFunc(e.NEVER);break;case Xx:e.depthFunc(e.ALWAYS);break;case jx:e.depthFunc(e.LESS);break;case mh:e.depthFunc(e.LEQUAL);break;case qx:e.depthFunc(e.EQUAL);break;case Yx:e.depthFunc(e.GEQUAL);break;case Kx:e.depthFunc(e.GREATER);break;case Jx:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=le}},setLocked:function(le){z=le},setClear:function(le){if(Te!==le){if(Te=le,_e)le=1-le;e.clearDepth(le)}},reset:function(){z=!1,ne=null,xe=null,Te=null,_e=!1}}}function r(){let z=!1,_e=null,ne=null,xe=null,Te=null,le=null,Se=null,Ze=null,bt=null;return{setTest:function(ht){if(!z)if(ht)q(e.STENCIL_TEST);else se(e.STENCIL_TEST)},setMask:function(ht){if(_e!==ht&&!z)e.stencilMask(ht),_e=ht},setFunc:function(ht,oi,Pi){if(ne!==ht||xe!==oi||Te!==Pi)e.stencilFunc(ht,oi,Pi),ne=ht,xe=oi,Te=Pi},setOp:function(ht,oi,Pi){if(le!==ht||Se!==oi||Ze!==Pi)e.stencilOp(ht,oi,Pi),le=ht,Se=oi,Ze=Pi},setLocked:function(ht){z=ht},setClear:function(ht){if(bt!==ht)e.clearStencil(ht),bt=ht},reset:function(){z=!1,_e=null,ne=null,xe=null,Te=null,le=null,Se=null,Ze=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new He(0,0,0),w=0,H=!1,C=null,N=null,ee=null,P=null,Z=null,G=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),k=!1,W=0,B=e.getParameter(e.VERSION);if(B.indexOf("WebGL")!==-1)W=parseFloat(/^WebGL (\d)/.exec(B)[1]),k=W>=1;else if(B.indexOf("OpenGL ES")!==-1)W=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),k=W>=2;let Y=null,K={},ge=e.getParameter(e.SCISSOR_BOX),de=e.getParameter(e.VIEWPORT),fe=new pt().fromArray(ge),he=new pt().fromArray(de);function I(z,_e,ne,xe){let Te=new Uint8Array(4),le=e.createTexture();e.bindTexture(z,le),e.texParameteri(z,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(z,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Se=0;Se<ne;Se++)if(z===e.TEXTURE_3D||z===e.TEXTURE_2D_ARRAY)e.texImage3D(_e,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Te);else e.texImage2D(_e+Se,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Te);return le}let V={};V[e.TEXTURE_2D]=I(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=I(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=I(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=I(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),q(e.DEPTH_TEST),o.setFunc(mh),Rt(!1),it(hh),q(e.CULL_FACE),rt(vi);function q(z){if(u[z]!==!0)e.enable(z),u[z]=!0}function se(z){if(u[z]!==!1)e.disable(z),u[z]=!1}function ce(z,_e){if(d[z]!==_e){if(e.bindFramebuffer(z,_e),d[z]=_e,z===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=_e;if(z===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=_e;return!0}return!1}function ae(z,_e){let ne=m,xe=!1;if(z){if(ne=f.get(_e),ne===void 0)ne=[],f.set(_e,ne);let Te=z.textures;if(ne.length!==Te.length||ne[0]!==e.COLOR_ATTACHMENT0){for(let le=0,Se=Te.length;le<Se;le++)ne[le]=e.COLOR_ATTACHMENT0+le;ne.length=Te.length,xe=!0}}else if(ne[0]!==e.BACK)ne[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(ne)}function ke(z){if(_!==z)return e.useProgram(z),_=z,!0;return!1}let Ce={[Is]:e.FUNC_ADD,[Ax]:e.FUNC_SUBTRACT,[Rx]:e.FUNC_REVERSE_SUBTRACT};Ce[Cx]=e.MIN,Ce[Ix]=e.MAX;let Ve={[Px]:e.ZERO,[Lx]:e.ONE,[Nx]:e.SRC_COLOR,[Ox]:e.SRC_ALPHA,[Gx]:e.SRC_ALPHA_SATURATE,[kx]:e.DST_COLOR,[Fx]:e.DST_ALPHA,[Dx]:e.ONE_MINUS_SRC_COLOR,[Ux]:e.ONE_MINUS_SRC_ALPHA,[Bx]:e.ONE_MINUS_DST_COLOR,[zx]:e.ONE_MINUS_DST_ALPHA,[Hx]:e.CONSTANT_COLOR,[Vx]:e.ONE_MINUS_CONSTANT_COLOR,[$x]:e.CONSTANT_ALPHA,[Wx]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(z,_e,ne,xe,Te,le,Se,Ze,bt,ht){if(z===vi){if(p===!0)se(e.BLEND),p=!1;return}if(p===!1)q(e.BLEND),p=!0;if(z!==Tx){if(z!==g||ht!==H){if(M!==Is||S!==Is)e.blendEquation(e.FUNC_ADD),M=Is,S=Is;if(ht)switch(z){case Bo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dh:e.blendFunc(e.ONE,e.ONE);break;case fh:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case ph:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:$e("WebGLState: Invalid blending: ",z);break}else switch(z){case Bo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dh:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case fh:$e("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ph:$e("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:$e("WebGLState: Invalid blending: ",z);break}T=null,v=null,E=null,R=null,x.set(0,0,0),w=0,g=z,H=ht}return}if(Te=Te||_e,le=le||ne,Se=Se||xe,_e!==M||Te!==S)e.blendEquationSeparate(Ce[_e],Ce[Te]),M=_e,S=Te;if(ne!==T||xe!==v||le!==E||Se!==R)e.blendFuncSeparate(Ve[ne],Ve[xe],Ve[le],Ve[Se]),T=ne,v=xe,E=le,R=Se;if(Ze.equals(x)===!1||bt!==w)e.blendColor(Ze.r,Ze.g,Ze.b,bt),x.copy(Ze),w=bt;g=z,H=!1}function nt(z,_e){z.side===Bn?se(e.CULL_FACE):q(e.CULL_FACE);let ne=z.side===cn;if(_e)ne=!ne;Rt(ne),z.blending===Bo&&z.transparent===!1?rt(vi):rt(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),o.setFunc(z.depthFunc),o.setTest(z.depthTest),o.setMask(z.depthWrite),s.setMask(z.colorWrite);let xe=z.stencilWrite;if(a.setTest(xe),xe)a.setMask(z.stencilWriteMask),a.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),a.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass);Ut(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?q(e.SAMPLE_ALPHA_TO_COVERAGE):se(e.SAMPLE_ALPHA_TO_COVERAGE)}function Rt(z){if(C!==z){if(z)e.frontFace(e.CW);else e.frontFace(e.CCW);C=z}}function it(z){if(z!==wx){if(q(e.CULL_FACE),z!==N)if(z===hh)e.cullFace(e.BACK);else if(z===Mx)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else se(e.CULL_FACE);N=z}function tn(z){if(z!==ee){if(k)e.lineWidth(z);ee=z}}function Ut(z,_e,ne){if(z){if(q(e.POLYGON_OFFSET_FILL),P!==_e||Z!==ne){if(P=_e,Z=ne,o.getReversed())_e=-_e;e.polygonOffset(_e,ne)}}else se(e.POLYGON_OFFSET_FILL)}function It(z){if(z)q(e.SCISSOR_TEST);else se(e.SCISSOR_TEST)}function D(z){if(z===void 0)z=e.TEXTURE0+G-1;if(Y!==z)e.activeTexture(z),Y=z}function _n(z,_e,ne){if(ne===void 0)if(Y===null)ne=e.TEXTURE0+G-1;else ne=Y;let xe=K[ne];if(xe===void 0)xe={type:void 0,texture:void 0},K[ne]=xe;if(xe.type!==z||xe.texture!==_e){if(Y!==ne)e.activeTexture(ne),Y=ne;e.bindTexture(z,_e||V[z]),xe.type=z,xe.texture=_e}}function ut(){let z=K[Y];if(z!==void 0&&z.type!==void 0)e.bindTexture(z.type,null),z.type=void 0,z.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function A(){try{e.compressedTexImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function y(){try{e.texSubImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function O(){try{e.texSubImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function J(){try{e.compressedTexSubImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function ue(){try{e.compressedTexSubImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function me(){try{e.texStorage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function ve(){try{e.texStorage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function te(){try{e.texImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function re(){try{e.texImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function Ee(z){if(h[z]!==void 0)return h[z];else return e.getParameter(z)}function Oe(z,_e){if(h[z]!==_e)e.pixelStorei(z,_e),h[z]=_e}function ye(z){if(fe.equals(z)===!1)e.scissor(z.x,z.y,z.z,z.w),fe.copy(z)}function pe(z){if(he.equals(z)===!1)e.viewport(z.x,z.y,z.z,z.w),he.copy(z)}function ze(z,_e){let ne=l.get(_e);if(ne===void 0)ne=new WeakMap,l.set(_e,ne);let xe=ne.get(z);if(xe===void 0)xe=e.getUniformBlockIndex(_e,z.name),ne.set(z,xe)}function Ge(z,_e){let xe=l.get(_e).get(z);if(c.get(_e)!==xe)e.uniformBlockBinding(_e,xe,z.__bindingPointIndex),c.set(_e,xe)}function ot(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},h={},Y=null,K={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new He(0,0,0),w=0,H=!1,C=null,N=null,ee=null,P=null,Z=null,fe.set(0,0,e.canvas.width,e.canvas.height),he.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:q,disable:se,bindFramebuffer:ce,drawBuffers:ae,useProgram:ke,setBlending:rt,setMaterial:nt,setFlipSided:Rt,setCullFace:it,setLineWidth:tn,setPolygonOffset:Ut,setScissorTest:It,activeTexture:D,bindTexture:_n,unbindTexture:ut,compressedTexImage2D:Pt,compressedTexImage3D:A,texImage2D:te,texImage3D:re,pixelStorei:Oe,getParameter:Ee,updateUBOMapping:ze,uniformBlockBinding:Ge,texStorage2D:me,texStorage3D:ve,texSubImage2D:y,texSubImage3D:O,compressedTexSubImage2D:J,compressedTexSubImage3D:ue,scissor:ye,viewport:pe,reset:ot}}function eC(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Be,u=new WeakMap,h=new Set,d,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function _(A,y){return m?new OffscreenCanvas(A,y):Ts("canvas")}function p(A,y,O){let J=1,ue=Pt(A);if(ue.width>O||ue.height>O)J=O/Math.max(ue.width,ue.height);if(J<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let me=Math.floor(J*ue.width),ve=Math.floor(J*ue.height);if(d===void 0)d=_(me,ve);let te=y?_(me,ve):d;return te.width=me,te.height=ve,te.getContext("2d").drawImage(A,0,0,me,ve),Ue("WebGLRenderer: Texture has been resized from ("+ue.width+"x"+ue.height+") to ("+me+"x"+ve+")."),te}else{if("data"in A)Ue("WebGLRenderer: Image in DataTexture is too big ("+ue.width+"x"+ue.height+").");return A}return A}function g(A){return A.generateMipmaps}function M(A){e.generateMipmap(A)}function T(A){if(A.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(A.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(A,y,O,J,ue,me=!1){if(A!==null){if(e[A]!==void 0)return e[A];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let ve;if(J){if(ve=t.get("EXT_texture_norm16"),!ve)Ue("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let te=y;if(y===e.RED){if(O===e.FLOAT)te=e.R32F;if(O===e.HALF_FLOAT)te=e.R16F;if(O===e.UNSIGNED_BYTE)te=e.R8;if(O===e.UNSIGNED_SHORT&&ve)te=ve.R16_EXT;if(O===e.SHORT&&ve)te=ve.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.R8UI;if(O===e.UNSIGNED_SHORT)te=e.R16UI;if(O===e.UNSIGNED_INT)te=e.R32UI;if(O===e.BYTE)te=e.R8I;if(O===e.SHORT)te=e.R16I;if(O===e.INT)te=e.R32I}if(y===e.RG){if(O===e.FLOAT)te=e.RG32F;if(O===e.HALF_FLOAT)te=e.RG16F;if(O===e.UNSIGNED_BYTE)te=e.RG8;if(O===e.UNSIGNED_SHORT&&ve)te=ve.RG16_EXT;if(O===e.SHORT&&ve)te=ve.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.RG8UI;if(O===e.UNSIGNED_SHORT)te=e.RG16UI;if(O===e.UNSIGNED_INT)te=e.RG32UI;if(O===e.BYTE)te=e.RG8I;if(O===e.SHORT)te=e.RG16I;if(O===e.INT)te=e.RG32I}if(y===e.RGB_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.RGB8UI;if(O===e.UNSIGNED_SHORT)te=e.RGB16UI;if(O===e.UNSIGNED_INT)te=e.RGB32UI;if(O===e.BYTE)te=e.RGB8I;if(O===e.SHORT)te=e.RGB16I;if(O===e.INT)te=e.RGB32I}if(y===e.RGBA_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.RGBA8UI;if(O===e.UNSIGNED_SHORT)te=e.RGBA16UI;if(O===e.UNSIGNED_INT)te=e.RGBA32UI;if(O===e.BYTE)te=e.RGBA8I;if(O===e.SHORT)te=e.RGBA16I;if(O===e.INT)te=e.RGBA32I}if(y===e.RGB){if(O===e.UNSIGNED_SHORT&&ve)te=ve.RGB16_EXT;if(O===e.SHORT&&ve)te=ve.RGB16_SNORM_EXT;if(O===e.UNSIGNED_INT_5_9_9_9_REV)te=e.RGB9_E5;if(O===e.UNSIGNED_INT_10F_11F_11F_REV)te=e.R11F_G11F_B10F}if(y===e.RGBA){let re=me?ad:Ke.getTransfer(ue);if(O===e.FLOAT)te=e.RGBA32F;if(O===e.HALF_FLOAT)te=e.RGBA16F;if(O===e.UNSIGNED_BYTE)te=re===yt?e.SRGB8_ALPHA8:e.RGBA8;if(O===e.UNSIGNED_SHORT&&ve)te=ve.RGBA16_EXT;if(O===e.SHORT&&ve)te=ve.RGBA16_SNORM_EXT;if(O===e.UNSIGNED_SHORT_4_4_4_4)te=e.RGBA4;if(O===e.UNSIGNED_SHORT_5_5_5_1)te=e.RGB5_A1}if(te===e.R16F||te===e.R32F||te===e.RG16F||te===e.RG32F||te===e.RGBA16F||te===e.RGBA32F)t.get("EXT_color_buffer_float");return te}function S(A,y){let O;if(A){if(y===null||y===pr||y===Os)O=e.DEPTH24_STENCIL8;else if(y===Vi)O=e.DEPTH32F_STENCIL8;else if(y===Vo)O=e.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===pr||y===Os)O=e.DEPTH_COMPONENT24;else if(y===Vi)O=e.DEPTH_COMPONENT32F;else if(y===Vo)O=e.DEPTH_COMPONENT16;return O}function E(A,y){if(g(A)===!0||A.isFramebufferTexture&&A.minFilter!==ti&&A.minFilter!==Jt)return Math.log2(Math.max(y.width,y.height))+1;else if(A.mipmaps!==void 0&&A.mipmaps.length>0)return A.mipmaps.length;else if(A.isCompressedTexture&&Array.isArray(A.image))return y.mipmaps.length;else return 1}function R(A){let y=A.target;if(y.removeEventListener("dispose",R),w(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)h.delete(y)}function x(A){let y=A.target;y.removeEventListener("dispose",x),C(y)}function w(A){let y=i.get(A);if(y.__webglInit===void 0)return;let O=A.source,J=f.get(O);if(J){let ue=J[y.__cacheKey];if(ue.usedTimes--,ue.usedTimes===0)H(A);if(Object.keys(J).length===0)f.delete(O)}i.remove(A)}function H(A){let y=i.get(A);e.deleteTexture(y.__webglTexture);let O=A.source,J=f.get(O);delete J[y.__cacheKey],o.memory.textures--}function C(A){let y=i.get(A);if(A.depthTexture)A.depthTexture.dispose(),i.remove(A.depthTexture);if(A.isWebGLCubeRenderTarget)for(let J=0;J<6;J++){if(Array.isArray(y.__webglFramebuffer[J]))for(let ue=0;ue<y.__webglFramebuffer[J].length;ue++)e.deleteFramebuffer(y.__webglFramebuffer[J][ue]);else e.deleteFramebuffer(y.__webglFramebuffer[J]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[J])}else{if(Array.isArray(y.__webglFramebuffer))for(let J=0;J<y.__webglFramebuffer.length;J++)e.deleteFramebuffer(y.__webglFramebuffer[J]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let J=0;J<y.__webglColorRenderbuffer.length;J++)if(y.__webglColorRenderbuffer[J])e.deleteRenderbuffer(y.__webglColorRenderbuffer[J])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let O=A.textures;for(let J=0,ue=O.length;J<ue;J++){let me=i.get(O[J]);if(me.__webglTexture)e.deleteTexture(me.__webglTexture),o.memory.textures--;i.remove(O[J])}i.remove(A)}let N=0;function ee(){N=0}function P(){return N}function Z(A){N=A}function G(){let A=N;if(A>=r.maxTextures)Ue("WebGLTextures: Trying to use "+(A+1)+" texture units while this GPU supports only "+r.maxTextures);return N+=1,A}function k(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function W(A,y){let O=i.get(A);if(A.isVideoTexture)_n(A);if(A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&O.__version!==A.version){let J=A.image;if(J===null)Ue("WebGLRenderer: Texture marked for update but no image data found.");else if(J.complete===!1)Ue("WebGLRenderer: Texture marked for update but image is incomplete");else{se(O,A,y);return}}else if(A.isExternalTexture)O.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,O.__webglTexture,e.TEXTURE0+y)}function B(A,y){let O=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){se(O,A,y);return}else if(A.isExternalTexture)O.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,O.__webglTexture,e.TEXTURE0+y)}function Y(A,y){let O=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){se(O,A,y);return}n.bindTexture(e.TEXTURE_3D,O.__webglTexture,e.TEXTURE0+y)}function K(A,y){let O=i.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&O.__version!==A.version){ce(O,A,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,O.__webglTexture,e.TEXTURE0+y)}let ge={[Ls]:e.REPEAT,[Ns]:e.CLAMP_TO_EDGE,[Fc]:e.MIRRORED_REPEAT},de={[ti]:e.NEAREST,[zc]:e.NEAREST_MIPMAP_NEAREST,[Wr]:e.NEAREST_MIPMAP_LINEAR,[Jt]:e.LINEAR,[Ds]:e.LINEAR_MIPMAP_NEAREST,[yi]:e.LINEAR_MIPMAP_LINEAR},fe={[uv]:e.NEVER,[mv]:e.ALWAYS,[hv]:e.LESS,[Zc]:e.LEQUAL,[dv]:e.EQUAL,[Xc]:e.GEQUAL,[fv]:e.GREATER,[pv]:e.NOTEQUAL};function he(A,y){if(y.type===Vi&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===Jt||y.magFilter===Ds||y.magFilter===Wr||y.magFilter===yi||y.minFilter===Jt||y.minFilter===Ds||y.minFilter===Wr||y.minFilter===yi))Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(A,e.TEXTURE_WRAP_S,ge[y.wrapS]),e.texParameteri(A,e.TEXTURE_WRAP_T,ge[y.wrapT]),A===e.TEXTURE_3D||A===e.TEXTURE_2D_ARRAY)e.texParameteri(A,e.TEXTURE_WRAP_R,ge[y.wrapR]);if(e.texParameteri(A,e.TEXTURE_MAG_FILTER,de[y.magFilter]),e.texParameteri(A,e.TEXTURE_MIN_FILTER,de[y.minFilter]),y.compareFunction)e.texParameteri(A,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(A,e.TEXTURE_COMPARE_FUNC,fe[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===ti)return;if(y.minFilter!==Wr&&y.minFilter!==yi)return;if(y.type===Vi&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let O=t.get("EXT_texture_filter_anisotropic");e.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function I(A,y){let O=!1;if(A.__webglInit===void 0)A.__webglInit=!0,y.addEventListener("dispose",R);let J=y.source,ue=f.get(J);if(ue===void 0)ue={},f.set(J,ue);let me=k(y);if(me!==A.__cacheKey){if(ue[me]===void 0)ue[me]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,O=!0;ue[me].usedTimes++;let ve=ue[A.__cacheKey];if(ve!==void 0){if(ue[A.__cacheKey].usedTimes--,ve.usedTimes===0)H(y)}A.__cacheKey=me,A.__webglTexture=ue[me].texture}return O}function V(A,y,O){return Math.floor(Math.floor(A/O)/y)}function q(A,y,O,J){let me=A.updateRanges;if(me.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,O,J,y.data);else{me.sort((Oe,ye)=>Oe.start-ye.start);let ve=0;for(let Oe=1;Oe<me.length;Oe++){let ye=me[ve],pe=me[Oe],ze=ye.start+ye.count,Ge=V(pe.start,y.width,4),ot=V(ye.start,y.width,4);if(pe.start<=ze+1&&Ge===ot&&V(pe.start+pe.count-1,y.width,4)===Ge)ye.count=Math.max(ye.count,pe.start+pe.count-ye.start);else++ve,me[ve]=pe}me.length=ve+1;let te=n.getParameter(e.UNPACK_ROW_LENGTH),re=n.getParameter(e.UNPACK_SKIP_PIXELS),Ee=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Oe=0,ye=me.length;Oe<ye;Oe++){let pe=me[Oe],ze=Math.floor(pe.start/4),Ge=Math.ceil(pe.count/4),ot=ze%y.width,z=Math.floor(ze/y.width),_e=Ge,ne=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,ot),n.pixelStorei(e.UNPACK_SKIP_ROWS,z),n.texSubImage2D(e.TEXTURE_2D,0,ot,z,_e,1,O,J,y.data)}A.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,te),n.pixelStorei(e.UNPACK_SKIP_PIXELS,re),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ee)}}function se(A,y,O){let J=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)J=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)J=e.TEXTURE_3D;let ue=I(A,y),me=y.source;n.bindTexture(J,A.__webglTexture,e.TEXTURE0+O);let ve=i.get(me);if(me.version!==ve.__version||ue===!0){if(n.activeTexture(e.TEXTURE0+O),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let ne=Ke.getPrimaries(Ke.workingColorSpace),xe=y.colorSpace===qr?null:Ke.getPrimaries(y.colorSpace),Te=y.colorSpace===qr||ne===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let re=p(y.image,!1,r.maxTextureSize);re=ut(y,re);let Ee=s.convert(y.format,y.colorSpace),Oe=s.convert(y.type),ye=v(y.internalFormat,Ee,Oe,y.normalized,y.colorSpace,y.isVideoTexture);he(J,y);let pe,ze=y.mipmaps,Ge=y.isVideoTexture!==!0,ot=ve.__version===void 0||ue===!0,z=me.dataReady,_e=E(y,re);if(y.isDepthTexture){if(ye=S(y.format===Xr,y.type),ot)if(Ge)n.texStorage2D(e.TEXTURE_2D,1,ye,re.width,re.height);else n.texImage2D(e.TEXTURE_2D,0,ye,re.width,re.height,0,Ee,Oe,null)}else if(y.isDataTexture)if(ze.length>0){if(Ge&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Ge){if(z)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data);y.generateMipmaps=!1}else if(Ge){if(ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,re.width,re.height);if(z)q(y,re,Ee,Oe)}else n.texImage2D(e.TEXTURE_2D,0,ye,re.width,re.height,0,Ee,Oe,re.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(Ge&&ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,ze[0].width,ze[0].height,re.depth);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Ge){if(z)if(y.layerUpdates.size>0){let Te=Pd(pe.width,pe.height,y.format,y.type);for(let le of y.layerUpdates){let Se=pe.data.subarray(le*Te/pe.data.BYTES_PER_ELEMENT,(le+1)*Te/pe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,le,pe.width,pe.height,1,Ee,Se)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,re.depth,Ee,pe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,re.depth,0,pe.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Ge){if(z)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,re.depth,Ee,Oe,pe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,re.depth,0,Ee,Oe,pe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(Ge&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Ge){if(z)n.compressedTexSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,pe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,pe.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Ge){if(z)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data)}else if(y.isDataArrayTexture)if(Ge){if(ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,re.width,re.height,re.depth);if(z)if(y.layerUpdates.size>0){let ne=Pd(re.width,re.height,y.format,y.type);for(let xe of y.layerUpdates){let Te=re.data.subarray(xe*ne/re.data.BYTES_PER_ELEMENT,(xe+1)*ne/re.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,re.width,re.height,1,Ee,Oe,Te)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,Ee,Oe,re.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ye,re.width,re.height,re.depth,0,Ee,Oe,re.data);else if(y.isData3DTexture)if(Ge){if(ot)n.texStorage3D(e.TEXTURE_3D,_e,ye,re.width,re.height,re.depth);if(z)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,Ee,Oe,re.data)}else n.texImage3D(e.TEXTURE_3D,0,ye,re.width,re.height,re.depth,0,Ee,Oe,re.data);else if(y.isFramebufferTexture){if(ot)if(Ge)n.texStorage2D(e.TEXTURE_2D,_e,ye,re.width,re.height);else{let ne=re.width,xe=re.height;for(let Te=0;Te<_e;Te++)n.texImage2D(e.TEXTURE_2D,Te,ye,ne,xe,0,Ee,Oe,null),ne>>=1,xe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let ne=e.canvas;if(!ne.hasAttribute("layoutsubtree"))ne.setAttribute("layoutsubtree","true");if(re.parentNode!==ne){ne.appendChild(re),h.add(y),ne.onpaint=(xe)=>{let Te=xe.changedElements;for(let le of h)if(Te.includes(le.image))le.needsUpdate=!0},ne.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,re);else{let{RGBA:Te,RGBA:le,UNSIGNED_BYTE:Se}=e;e.texElementImage2D(e.TEXTURE_2D,0,Te,le,Se,re)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(ze.length>0){if(Ge&&ot){let ne=Pt(ze[0]);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Ge){if(z)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,Ee,Oe,pe)}else n.texImage2D(e.TEXTURE_2D,ne,ye,Ee,Oe,pe);y.generateMipmaps=!1}else if(Ge){if(ot){let ne=Pt(re);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}if(z)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ee,Oe,re)}else n.texImage2D(e.TEXTURE_2D,0,ye,Ee,Oe,re);if(g(y))M(J);if(ve.__version=me.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function ce(A,y,O){if(y.image.length!==6)return;let J=I(A,y),ue=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,A.__webglTexture,e.TEXTURE0+O);let me=i.get(ue);if(ue.version!==me.__version||J===!0){n.activeTexture(e.TEXTURE0+O);let ve=Ke.getPrimaries(Ke.workingColorSpace),te=y.colorSpace===qr?null:Ke.getPrimaries(y.colorSpace),re=y.colorSpace===qr||ve===te?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,re);let Ee=y.isCompressedTexture||y.image[0].isCompressedTexture,Oe=y.image[0]&&y.image[0].isDataTexture,ye=[];for(let le=0;le<6;le++){if(!Ee&&!Oe)ye[le]=p(y.image[le],!0,r.maxCubemapSize);else ye[le]=Oe?y.image[le].image:y.image[le];ye[le]=ut(y,ye[le])}let pe=ye[0],ze=s.convert(y.format,y.colorSpace),Ge=s.convert(y.type),ot=v(y.internalFormat,ze,Ge,y.normalized,y.colorSpace),z=y.isVideoTexture!==!0,_e=me.__version===void 0||J===!0,ne=ue.dataReady,xe=E(y,pe);he(e.TEXTURE_CUBE_MAP,y);let Te;if(Ee){if(z&&_e)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,pe.width,pe.height);for(let le=0;le<6;le++){Te=ye[le].mipmaps;for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(y.format!==Si)if(ze!==null)if(z){if(ne)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,0,0,Ze.width,Ze.height,ze,Ze.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,ot,Ze.width,Ze.height,0,Ze.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,0,0,Ze.width,Ze.height,ze,Ge,Ze.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,ot,Ze.width,Ze.height,0,ze,Ge,Ze.data)}}}else{if(Te=y.mipmaps,z&&_e){if(Te.length>0)xe++;let le=Pt(ye[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,le.width,le.height)}for(let le=0;le<6;le++)if(Oe){if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,ye[le].width,ye[le].height,ze,Ge,ye[le].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ot,ye[le].width,ye[le].height,0,ze,Ge,ye[le].data);for(let Se=0;Se<Te.length;Se++){let bt=Te[Se].image[le].image;if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,0,0,bt.width,bt.height,ze,Ge,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,ot,bt.width,bt.height,0,ze,Ge,bt.data)}}else{if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,ze,Ge,ye[le])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ot,ze,Ge,ye[le]);for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,0,0,ze,Ge,Ze.image[le])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,ot,ze,Ge,Ze.image[le])}}}if(g(y))M(e.TEXTURE_CUBE_MAP);if(me.__version=ue.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function ae(A,y,O,J,ue,me){let ve=s.convert(O.format,O.colorSpace),te=s.convert(O.type),re=v(O.internalFormat,ve,te,O.normalized,O.colorSpace),Ee=i.get(y),Oe=i.get(O);if(Oe.__renderTarget=y,!Ee.__hasExternalTextures){let ye=Math.max(1,y.width>>me),pe=Math.max(1,y.height>>me);if(ue===e.TEXTURE_3D||ue===e.TEXTURE_2D_ARRAY)n.texImage3D(ue,me,re,ye,pe,y.depth,0,ve,te,null);else n.texImage2D(ue,me,re,ye,pe,0,ve,te,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,A),D(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,ue,Oe.__webglTexture,0,It(y));else if(ue===e.TEXTURE_2D||ue>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ue<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,J,ue,Oe.__webglTexture,me);n.bindFramebuffer(e.FRAMEBUFFER,null)}function ke(A,y,O){if(e.bindRenderbuffer(e.RENDERBUFFER,A),y.depthBuffer){let J=y.depthTexture,ue=J&&J.isDepthTexture?J.type:null,me=S(y.stencilBuffer,ue),ve=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),me,y.width,y.height);else if(O)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),me,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,me,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,A)}else{let J=y.textures;for(let ue=0;ue<J.length;ue++){let me=J[ue],ve=s.convert(me.format,me.colorSpace),te=s.convert(me.type),re=v(me.internalFormat,ve,te,me.normalized,me.colorSpace);if(D(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),re,y.width,y.height);else if(O)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),re,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,re,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ce(A,y,O){let J=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,A),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ue=i.get(y.depthTexture);if(ue.__renderTarget=y,!ue.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(J){if(ue.__webglInit===void 0)ue.__webglInit=!0,y.depthTexture.addEventListener("dispose",R);if(ue.__webglTexture===void 0){ue.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ue.__webglTexture),he(e.TEXTURE_CUBE_MAP,y.depthTexture);let Ee=s.convert(y.depthTexture.format),Oe=s.convert(y.depthTexture.type),ye;if(y.depthTexture.format===Zr)ye=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Xr)ye=e.DEPTH24_STENCIL8;for(let pe=0;pe<6;pe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,ye,y.width,y.height,0,Ee,Oe,null)}}else W(y.depthTexture,0);let me=ue.__webglTexture,ve=It(y),te=J?e.TEXTURE_CUBE_MAP_POSITIVE_X+O:e.TEXTURE_2D,re=y.depthTexture.format===Xr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Zr)if(D(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,re,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,re,te,me,0);else if(y.depthTexture.format===Xr)if(D(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,re,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,re,te,me,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ve(A){let y=i.get(A),O=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let J=A.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(J){let ue=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,J.removeEventListener("dispose",ue)};J.addEventListener("dispose",ue),y.__depthDisposeCallback=ue}y.__boundDepthTexture=J}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(O)for(let J=0;J<6;J++)Ce(y.__webglFramebuffer[J],A,J);else{let J=A.texture.mipmaps;if(J&&J.length>0)Ce(y.__webglFramebuffer[0],A,0);else Ce(y.__webglFramebuffer,A,0)}else if(O){y.__webglDepthbuffer=[];for(let J=0;J<6;J++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[J]),y.__webglDepthbuffer[J]===void 0)y.__webglDepthbuffer[J]=e.createRenderbuffer(),ke(y.__webglDepthbuffer[J],A,!1);else{let ue=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer[J];e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,me)}}else{let J=A.texture.mipmaps;if(J&&J.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),ke(y.__webglDepthbuffer,A,!1);else{let ue=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,me)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function rt(A,y,O){let J=i.get(A);if(y!==void 0)ae(J.__webglFramebuffer,A,A.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(O!==void 0)Ve(A)}function nt(A){let y=A.texture,O=i.get(A),J=i.get(y);A.addEventListener("dispose",x);let ue=A.textures,me=A.isWebGLCubeRenderTarget===!0,ve=ue.length>1;if(!ve){if(J.__webglTexture===void 0)J.__webglTexture=e.createTexture();J.__version=y.version,o.memory.textures++}if(me){O.__webglFramebuffer=[];for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer[te]=[];for(let re=0;re<y.mipmaps.length;re++)O.__webglFramebuffer[te][re]=e.createFramebuffer()}else O.__webglFramebuffer[te]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer=[];for(let te=0;te<y.mipmaps.length;te++)O.__webglFramebuffer[te]=e.createFramebuffer()}else O.__webglFramebuffer=e.createFramebuffer();if(ve)for(let te=0,re=ue.length;te<re;te++){let Ee=i.get(ue[te]);if(Ee.__webglTexture===void 0)Ee.__webglTexture=e.createTexture(),o.memory.textures++}if(A.samples>0&&D(A)===!1){O.__webglMultisampledFramebuffer=e.createFramebuffer(),O.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let te=0;te<ue.length;te++){let re=ue[te];O.__webglColorRenderbuffer[te]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,O.__webglColorRenderbuffer[te]);let Ee=s.convert(re.format,re.colorSpace),Oe=s.convert(re.type),ye=v(re.internalFormat,Ee,Oe,re.normalized,re.colorSpace,A.isXRRenderTarget===!0),pe=It(A);e.renderbufferStorageMultisample(e.RENDERBUFFER,pe,ye,A.width,A.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+te,e.RENDERBUFFER,O.__webglColorRenderbuffer[te])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),A.depthBuffer)O.__webglDepthRenderbuffer=e.createRenderbuffer(),ke(O.__webglDepthRenderbuffer,A,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(me){n.bindTexture(e.TEXTURE_CUBE_MAP,J.__webglTexture),he(e.TEXTURE_CUBE_MAP,y);for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0)for(let re=0;re<y.mipmaps.length;re++)ae(O.__webglFramebuffer[te][re],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,re);else ae(O.__webglFramebuffer[te],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,0);if(g(y))M(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let te=0,re=ue.length;te<re;te++){let Ee=ue[te],Oe=i.get(Ee),ye=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)ye=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ye,Oe.__webglTexture),he(ye,Ee),ae(O.__webglFramebuffer,A,Ee,e.COLOR_ATTACHMENT0+te,ye,0),g(Ee))M(ye)}n.unbindTexture()}else{let te=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)te=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(te,J.__webglTexture),he(te,y),y.mipmaps&&y.mipmaps.length>0)for(let re=0;re<y.mipmaps.length;re++)ae(O.__webglFramebuffer[re],A,y,e.COLOR_ATTACHMENT0,te,re);else ae(O.__webglFramebuffer,A,y,e.COLOR_ATTACHMENT0,te,0);if(g(y))M(te);n.unbindTexture()}if(A.depthBuffer)Ve(A)}function Rt(A){let y=A.textures;for(let O=0,J=y.length;O<J;O++){let ue=y[O];if(g(ue)){let me=T(A),ve=i.get(ue).__webglTexture;n.bindTexture(me,ve),M(me),n.unbindTexture()}}}let it=[],tn=[];function Ut(A){if(A.samples>0){if(D(A)===!1){let{textures:y,width:O,height:J}=A,ue=e.COLOR_BUFFER_BIT,me=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(A),te=y.length>1;if(te)for(let Ee=0;Ee<y.length;Ee++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let re=A.texture.mipmaps;if(re&&re.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ee=0;Ee<y.length;Ee++){if(A.resolveDepthBuffer){if(A.depthBuffer)ue|=e.DEPTH_BUFFER_BIT;if(A.stencilBuffer&&A.resolveStencilBuffer)ue|=e.STENCIL_BUFFER_BIT}if(te){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Oe,0)}if(e.blitFramebuffer(0,0,O,J,0,0,O,J,ue,e.NEAREST),c===!0){if(it.length=0,tn.length=0,it.push(e.COLOR_ATTACHMENT0+Ee),A.depthBuffer&&A.storeMultisampledDepthBuffer===!1)it.push(me),tn.push(me),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,tn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,it)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),te)for(let Ee=0;Ee<y.length;Ee++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,Oe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&c){let y=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function It(A){return Math.min(r.maxSamples,A.samples)}function D(A){let y=i.get(A);return A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function _n(A){let y=o.render.frame;if(u.get(A)!==y)u.set(A,y),A.update()}function ut(A,y){let{colorSpace:O,format:J,type:ue}=A;if(A.isCompressedTexture===!0||A.isVideoTexture===!0)return y;if(O!==Rn&&O!==qr)if(Ke.getTransfer(O)===yt){if(J!==Si||ue!==ni)Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else $e("WebGLTextures: Unsupported texture color space:",O);return y}function Pt(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement)l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height;else if(typeof VideoFrame<"u"&&A instanceof VideoFrame)l.width=A.displayWidth,l.height=A.displayHeight;else l.width=A.width,l.height=A.height;return l}this.allocateTextureUnit=G,this.resetTextureUnits=ee,this.getTextureUnits=P,this.setTextureUnits=Z,this.setTexture2D=W,this.setTexture2DArray=B,this.setTexture3D=Y,this.setTextureCube=K,this.rebindTextures=rt,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=Ve,this.setupFrameBufferTexture=ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function tC(e,t){function n(i,r=qr){let s,o=Ke.getTransfer(r);if(i===ni)return e.UNSIGNED_BYTE;if(i===wh)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Mh)return e.UNSIGNED_SHORT_5_5_5_1;if(i===rv)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===sv)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===nv)return e.BYTE;if(i===iv)return e.SHORT;if(i===Vo)return e.UNSIGNED_SHORT;if(i===Sh)return e.INT;if(i===pr)return e.UNSIGNED_INT;if(i===Vi)return e.FLOAT;if(i===bi)return e.HALF_FLOAT;if(i===ov)return e.ALPHA;if(i===av)return e.RGB;if(i===Si)return e.RGBA;if(i===Zr)return e.DEPTH_COMPONENT;if(i===Xr)return e.DEPTH_STENCIL;if(i===cv)return e.RED;if(i===Eh)return e.RED_INTEGER;if(i===jr)return e.RG;if(i===Th)return e.RG_INTEGER;if(i===Ah)return e.RGBA_INTEGER;if(i===kc||i===Bc||i===Gc||i===Hc)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===kc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Bc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===kc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Bc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Hc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Rh||i===Ch||i===Ih||i===Ph)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Rh)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ch)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ph)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Lh||i===Nh||i===Dh||i===Oh||i===Uh||i===Vc||i===Fh)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Lh||i===Nh)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Dh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Oh)return s.COMPRESSED_R11_EAC;if(i===Uh)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Vc)return s.COMPRESSED_RG11_EAC;if(i===Fh)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===zh||i===kh||i===Bh||i===Gh||i===Hh||i===Vh||i===$h||i===Wh||i===Zh||i===Xh||i===jh||i===qh||i===Yh||i===Kh)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Bh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Gh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Hh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Vh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===$h)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Wh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Xh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===qh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Yh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Jh||i===Qh||i===ed)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Jh)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Qh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ed)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===td||i===nd||i===$c||i===id)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===td)return s.COMPRESSED_RED_RGTC1_EXT;if(i===nd)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===$c)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===id)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Os)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var nC=`
+}`,JR=[new z(1,0,0),new z(-1,0,0),new z(0,1,0),new z(0,-1,0),new z(0,0,1),new z(0,0,-1)],QR=[new z(0,-1,0),new z(0,-1,0),new z(0,0,1),new z(0,0,-1),new z(0,-1,0),new z(0,-1,0)],Yv=new Xe,ua=new z,zd=new z;function eC(e,t,n){let i=new ta,r=new ke,s=new ke,o=new pt,a=new xd,c=new vd,l={},u=n.maxTextureSize,h={[pr]:cn,[cn]:pr,[Bn]:Bn},d=new Gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:YR,fragmentShader:KR}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new ln;m.setAttribute("position",new Kt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ho;let g=this.type;this.render=function(E,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(E.length===0)return;if(this.type===Tx)Ue("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ho;let w=e.getRenderTarget(),G=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),D=e.state;if(D.setBlending(vi),D.buffers.depth.getReversed()===!0)D.buffers.color.setClear(0,0,0,0);else D.buffers.color.setClear(1,1,1,1);D.buffers.depth.setTest(!0),D.setScissorTest(!1);let ee=g!==this.type;if(ee)R.traverse(function(L){if(L.material)if(Array.isArray(L.material))L.material.forEach((W)=>W.needsUpdate=!0);else L.material.needsUpdate=!0});for(let L=0,W=E.length;L<W;L++){let B=E[L],P=B.shadow;if(P===void 0){Ue("WebGLShadowMap:",B,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let J=P.getFrameExtents();if(r.multiply(J),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/J.x),r.x=s.x*J.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/J.y),r.y=s.y*J.y,P.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=H,P.map===null||ee===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Is){if(B.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new Cn(r.x,r.y,{format:qr,type:bi,minFilter:Jt,magFilter:Jt,generateMipmaps:!1}),P.map.texture.name=B.name+".shadowMap",P.map.depthTexture=new Kr(r.x,r.y,$i),P.map.depthTexture.name=B.name+".shadowMapDepth",P.map.depthTexture.format=Xr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=ti,P.map.depthTexture.magFilter=ti}else{if(B.isPointLight)P.map=new Gd(r.x),P.map.depthTexture=new md(r.x,mr);else P.map=new Cn(r.x,r.y),P.map.depthTexture=new Kr(r.x,r.y,mr);if(P.map.depthTexture.name=B.name+".shadowMap",P.map.depthTexture.format=Xr,this.type===Ho)P.map.depthTexture.compareFunction=H?qc:jc,P.map.depthTexture.minFilter=Jt,P.map.depthTexture.magFilter=Jt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=ti,P.map.depthTexture.magFilter=ti}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(B.isPointLight!==!0)P.updateMatrices(B,x);for(let Q=0;Q<q;Q++){let ge=P.getCamera(Q);if(B.isPointLight){let{camera:he,matrix:de}=P,fe=B.distance||he.far;if(fe!==he.far)he.far=fe,he.updateProjectionMatrix();ua.setFromMatrixPosition(B.matrixWorld),he.position.copy(ua),zd.copy(he.position),zd.add(JR[Q]),he.up.copy(QR[Q]),he.lookAt(zd),he.updateMatrixWorld(),de.makeTranslation(-ua.x,-ua.y,-ua.z),Yv.multiplyMatrices(he.projectionMatrix,he.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Yv,he.coordinateSystem,he.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let he=P.getViewport(Q);o.set(s.x*he.x,s.y*he.y,s.x*he.z,s.y*he.w),D.viewport(o)}i=P.getFrustum(Q),v(R,x,ge,B,this.type)}if(P.isPointLightShadow!==!0&&this.type===Is)M(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(w,G,C)};function M(E,R){let x=t.update(_);if(d.defines.VSM_SAMPLES!==E.blurSamples)d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new Cn(r.x,r.y,{format:qr,type:bi});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value.set(E.map.width,E.map.height),d.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(E,R,x,w){let G=null,C=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(C!==void 0)G=C;else if(G=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let D=G.uuid,ee=R.uuid,L=l[D];if(L===void 0)L={},l[D]=L;let W=L[ee];if(W===void 0)W=G.clone(),L[ee]=W,R.addEventListener("dispose",S);G=W}if(G.visible=R.visible,G.wireframe=R.wireframe,w===Is)G.side=R.shadowSide!==null?R.shadowSide:R.side;else G.side=R.shadowSide!==null?R.shadowSide:h[R.side];if(G.alphaMap=R.alphaMap,G.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,G.map=R.map,G.clipShadows=R.clipShadows,G.clippingPlanes=R.clippingPlanes,G.clipIntersection=R.clipIntersection,G.displacementMap=R.displacementMap,G.displacementScale=R.displacementScale,G.displacementBias=R.displacementBias,G.wireframeLinewidth=R.wireframeLinewidth,G.linewidth=R.linewidth,x.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let D=e.properties.get(G);D.light=x}return G}function v(E,R,x,w,G){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&G===Is)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);let ee=t.update(E),L=E.material;if(Array.isArray(L)){let W=ee.groups;for(let B=0,P=W.length;B<P;B++){let J=W[B],H=L[J.materialIndex];if(H&&H.visible){let q=T(E,H,w,G);E.onBeforeShadow(e,E,R,x,ee,q,J),e.renderBufferDirect(x,null,ee,q,E,J),E.onAfterShadow(e,E,R,x,ee,q,J)}}}else if(L.visible){let W=T(E,L,w,G);E.onBeforeShadow(e,E,R,x,ee,W,null),e.renderBufferDirect(x,null,ee,W,E,null),E.onAfterShadow(e,E,R,x,ee,W,null)}}}let D=E.children;for(let ee=0,L=D.length;ee<L;ee++)v(D[ee],R,x,w,G)}function S(E){E.target.removeEventListener("dispose",S);for(let x in l){let w=l[x],G=E.target.uuid;if(G in w)w[G].dispose(),delete w[G]}}}function tC(e,t){function n(){let k=!1,_e=new pt,ne=null,xe=new pt(0,0,0,0);return{setMask:function(Te){if(ne!==Te&&!k)e.colorMask(Te,Te,Te,Te),ne=Te},setLocked:function(Te){k=Te},setClear:function(Te,ce,Se,Ze,bt){if(bt===!0)Te*=Ze,ce*=Ze,Se*=Ze;if(_e.set(Te,ce,Se,Ze),xe.equals(_e)===!1)e.clearColor(Te,ce,Se,Ze),xe.copy(_e)},reset:function(){k=!1,ne=null,xe.set(-1,0,0,0)}}}function i(){let k=!1,_e=!1,ne=null,xe=null,Te=null;return{setReversed:function(ce){if(_e!==ce){let Se=t.get("EXT_clip_control");if(ce)Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.ZERO_TO_ONE_EXT);else Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.NEGATIVE_ONE_TO_ONE_EXT);_e=ce;let Ze=Te;Te=null,this.setClear(Ze)}},getReversed:function(){return _e},setTest:function(ce){if(ce)j(e.DEPTH_TEST);else re(e.DEPTH_TEST)},setMask:function(ce){if(ne!==ce&&!k)e.depthMask(ce),ne=ce},setFunc:function(ce){if(_e)ce=yv[ce];if(xe!==ce){switch(ce){case Xx:e.depthFunc(e.NEVER);break;case jx:e.depthFunc(e.ALWAYS);break;case qx:e.depthFunc(e.LESS);break;case gh:e.depthFunc(e.LEQUAL);break;case Yx:e.depthFunc(e.EQUAL);break;case Kx:e.depthFunc(e.GEQUAL);break;case Jx:e.depthFunc(e.GREATER);break;case Qx:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=ce}},setLocked:function(ce){k=ce},setClear:function(ce){if(Te!==ce){if(Te=ce,_e)ce=1-ce;e.clearDepth(ce)}},reset:function(){k=!1,ne=null,xe=null,Te=null,_e=!1}}}function r(){let k=!1,_e=null,ne=null,xe=null,Te=null,ce=null,Se=null,Ze=null,bt=null;return{setTest:function(ht){if(!k)if(ht)j(e.STENCIL_TEST);else re(e.STENCIL_TEST)},setMask:function(ht){if(_e!==ht&&!k)e.stencilMask(ht),_e=ht},setFunc:function(ht,oi,Li){if(ne!==ht||xe!==oi||Te!==Li)e.stencilFunc(ht,oi,Li),ne=ht,xe=oi,Te=Li},setOp:function(ht,oi,Li){if(ce!==ht||Se!==oi||Ze!==Li)e.stencilOp(ht,oi,Li),ce=ht,Se=oi,Ze=Li},setLocked:function(ht){k=ht},setClear:function(ht){if(bt!==ht)e.clearStencil(ht),bt=ht},reset:function(){k=!1,_e=null,ne=null,xe=null,Te=null,ce=null,Se=null,Ze=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new Ge(0,0,0),w=0,G=!1,C=null,D=null,ee=null,L=null,W=null,B=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,J=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)J=parseFloat(/^WebGL (\d)/.exec(H)[1]),P=J>=1;else if(H.indexOf("OpenGL ES")!==-1)J=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),P=J>=2;let q=null,Q={},ge=e.getParameter(e.SCISSOR_BOX),he=e.getParameter(e.VIEWPORT),de=new pt().fromArray(ge),fe=new pt().fromArray(he);function I(k,_e,ne,xe){let Te=new Uint8Array(4),ce=e.createTexture();e.bindTexture(k,ce),e.texParameteri(k,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(k,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Se=0;Se<ne;Se++)if(k===e.TEXTURE_3D||k===e.TEXTURE_2D_ARRAY)e.texImage3D(_e,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Te);else e.texImage2D(_e+Se,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Te);return ce}let V={};V[e.TEXTURE_2D]=I(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=I(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=I(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=I(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),j(e.DEPTH_TEST),o.setFunc(gh),Rt(!1),it(dh),j(e.CULL_FACE),rt(vi);function j(k){if(u[k]!==!0)e.enable(k),u[k]=!0}function re(k){if(u[k]!==!1)e.disable(k),u[k]=!1}function oe(k,_e){if(d[k]!==_e){if(e.bindFramebuffer(k,_e),d[k]=_e,k===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=_e;if(k===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=_e;return!0}return!1}function ue(k,_e){let ne=m,xe=!1;if(k){if(ne=f.get(_e),ne===void 0)ne=[],f.set(_e,ne);let Te=k.textures;if(ne.length!==Te.length||ne[0]!==e.COLOR_ATTACHMENT0){for(let ce=0,Se=Te.length;ce<Se;ce++)ne[ce]=e.COLOR_ATTACHMENT0+ce;ne.length=Te.length,xe=!0}}else if(ne[0]!==e.BACK)ne[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(ne)}function $e(k){if(_!==k)return e.useProgram(k),_=k,!0;return!1}let Ce={[Ps]:e.FUNC_ADD,[Rx]:e.FUNC_SUBTRACT,[Cx]:e.FUNC_REVERSE_SUBTRACT};Ce[Ix]=e.MIN,Ce[Px]=e.MAX;let He={[Lx]:e.ZERO,[Nx]:e.ONE,[Dx]:e.SRC_COLOR,[Ux]:e.SRC_ALPHA,[Hx]:e.SRC_ALPHA_SATURATE,[Bx]:e.DST_COLOR,[zx]:e.DST_ALPHA,[Ox]:e.ONE_MINUS_SRC_COLOR,[Fx]:e.ONE_MINUS_SRC_ALPHA,[Gx]:e.ONE_MINUS_DST_COLOR,[kx]:e.ONE_MINUS_DST_ALPHA,[Vx]:e.CONSTANT_COLOR,[$x]:e.ONE_MINUS_CONSTANT_COLOR,[Wx]:e.CONSTANT_ALPHA,[Zx]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(k,_e,ne,xe,Te,ce,Se,Ze,bt,ht){if(k===vi){if(p===!0)re(e.BLEND),p=!1;return}if(p===!1)j(e.BLEND),p=!0;if(k!==Ax){if(k!==g||ht!==G){if(M!==Ps||S!==Ps)e.blendEquation(e.FUNC_ADD),M=Ps,S=Ps;if(ht)switch(k){case Vo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case fh:e.blendFunc(e.ONE,e.ONE);break;case ph:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case mh:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ve("WebGLState: Invalid blending: ",k);break}else switch(k){case Vo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case fh:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case ph:Ve("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case mh:Ve("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ve("WebGLState: Invalid blending: ",k);break}T=null,v=null,E=null,R=null,x.set(0,0,0),w=0,g=k,G=ht}return}if(Te=Te||_e,ce=ce||ne,Se=Se||xe,_e!==M||Te!==S)e.blendEquationSeparate(Ce[_e],Ce[Te]),M=_e,S=Te;if(ne!==T||xe!==v||ce!==E||Se!==R)e.blendFuncSeparate(He[ne],He[xe],He[ce],He[Se]),T=ne,v=xe,E=ce,R=Se;if(Ze.equals(x)===!1||bt!==w)e.blendColor(Ze.r,Ze.g,Ze.b,bt),x.copy(Ze),w=bt;g=k,G=!1}function nt(k,_e){k.side===Bn?re(e.CULL_FACE):j(e.CULL_FACE);let ne=k.side===cn;if(_e)ne=!ne;Rt(ne),k.blending===Vo&&k.transparent===!1?rt(vi):rt(k.blending,k.blendEquation,k.blendSrc,k.blendDst,k.blendEquationAlpha,k.blendSrcAlpha,k.blendDstAlpha,k.blendColor,k.blendAlpha,k.premultipliedAlpha),o.setFunc(k.depthFunc),o.setTest(k.depthTest),o.setMask(k.depthWrite),s.setMask(k.colorWrite);let xe=k.stencilWrite;if(a.setTest(xe),xe)a.setMask(k.stencilWriteMask),a.setFunc(k.stencilFunc,k.stencilRef,k.stencilFuncMask),a.setOp(k.stencilFail,k.stencilZFail,k.stencilZPass);Ut(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits),k.alphaToCoverage===!0?j(e.SAMPLE_ALPHA_TO_COVERAGE):re(e.SAMPLE_ALPHA_TO_COVERAGE)}function Rt(k){if(C!==k){if(k)e.frontFace(e.CW);else e.frontFace(e.CCW);C=k}}function it(k){if(k!==Mx){if(j(e.CULL_FACE),k!==D)if(k===dh)e.cullFace(e.BACK);else if(k===Ex)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else re(e.CULL_FACE);D=k}function tn(k){if(k!==ee){if(P)e.lineWidth(k);ee=k}}function Ut(k,_e,ne){if(k){if(j(e.POLYGON_OFFSET_FILL),L!==_e||W!==ne){if(L=_e,W=ne,o.getReversed())_e=-_e;e.polygonOffset(_e,ne)}}else re(e.POLYGON_OFFSET_FILL)}function It(k){if(k)j(e.SCISSOR_TEST);else re(e.SCISSOR_TEST)}function O(k){if(k===void 0)k=e.TEXTURE0+B-1;if(q!==k)e.activeTexture(k),q=k}function _n(k,_e,ne){if(ne===void 0)if(q===null)ne=e.TEXTURE0+B-1;else ne=q;let xe=Q[ne];if(xe===void 0)xe={type:void 0,texture:void 0},Q[ne]=xe;if(xe.type!==k||xe.texture!==_e){if(q!==ne)e.activeTexture(ne),q=ne;e.bindTexture(k,_e||V[k]),xe.type=k,xe.texture=_e}}function ut(){let k=Q[q];if(k!==void 0&&k.type!==void 0)e.bindTexture(k.type,null),k.type=void 0,k.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function A(){try{e.compressedTexImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function y(){try{e.texSubImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function U(){try{e.texSubImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function Y(){try{e.compressedTexSubImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function le(){try{e.compressedTexSubImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function me(){try{e.texStorage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function ve(){try{e.texStorage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function te(){try{e.texImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function se(){try{e.texImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function Ee(k){if(h[k]!==void 0)return h[k];else return e.getParameter(k)}function Oe(k,_e){if(h[k]!==_e)e.pixelStorei(k,_e),h[k]=_e}function ye(k){if(de.equals(k)===!1)e.scissor(k.x,k.y,k.z,k.w),de.copy(k)}function pe(k){if(fe.equals(k)===!1)e.viewport(k.x,k.y,k.z,k.w),fe.copy(k)}function ze(k,_e){let ne=l.get(_e);if(ne===void 0)ne=new WeakMap,l.set(_e,ne);let xe=ne.get(k);if(xe===void 0)xe=e.getUniformBlockIndex(_e,k.name),ne.set(k,xe)}function Be(k,_e){let xe=l.get(_e).get(k);if(c.get(_e)!==xe)e.uniformBlockBinding(_e,xe,k.__bindingPointIndex),c.set(_e,xe)}function ot(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},h={},q=null,Q={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new Ge(0,0,0),w=0,G=!1,C=null,D=null,ee=null,L=null,W=null,de.set(0,0,e.canvas.width,e.canvas.height),fe.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:j,disable:re,bindFramebuffer:oe,drawBuffers:ue,useProgram:$e,setBlending:rt,setMaterial:nt,setFlipSided:Rt,setCullFace:it,setLineWidth:tn,setPolygonOffset:Ut,setScissorTest:It,activeTexture:O,bindTexture:_n,unbindTexture:ut,compressedTexImage2D:Pt,compressedTexImage3D:A,texImage2D:te,texImage3D:se,pixelStorei:Oe,getParameter:Ee,updateUBOMapping:ze,uniformBlockBinding:Be,texStorage2D:me,texStorage3D:ve,texSubImage2D:y,texSubImage3D:U,compressedTexSubImage2D:Y,compressedTexSubImage3D:le,scissor:ye,viewport:pe,reset:ot}}function nC(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new ke,u=new WeakMap,h=new Set,d,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function _(A,y){return m?new OffscreenCanvas(A,y):As("canvas")}function p(A,y,U){let Y=1,le=Pt(A);if(le.width>U||le.height>U)Y=U/Math.max(le.width,le.height);if(Y<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let me=Math.floor(Y*le.width),ve=Math.floor(Y*le.height);if(d===void 0)d=_(me,ve);let te=y?_(me,ve):d;return te.width=me,te.height=ve,te.getContext("2d").drawImage(A,0,0,me,ve),Ue("WebGLRenderer: Texture has been resized from ("+le.width+"x"+le.height+") to ("+me+"x"+ve+")."),te}else{if("data"in A)Ue("WebGLRenderer: Image in DataTexture is too big ("+le.width+"x"+le.height+").");return A}return A}function g(A){return A.generateMipmaps}function M(A){e.generateMipmap(A)}function T(A){if(A.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(A.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(A,y,U,Y,le,me=!1){if(A!==null){if(e[A]!==void 0)return e[A];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let ve;if(Y){if(ve=t.get("EXT_texture_norm16"),!ve)Ue("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let te=y;if(y===e.RED){if(U===e.FLOAT)te=e.R32F;if(U===e.HALF_FLOAT)te=e.R16F;if(U===e.UNSIGNED_BYTE)te=e.R8;if(U===e.UNSIGNED_SHORT&&ve)te=ve.R16_EXT;if(U===e.SHORT&&ve)te=ve.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.R8UI;if(U===e.UNSIGNED_SHORT)te=e.R16UI;if(U===e.UNSIGNED_INT)te=e.R32UI;if(U===e.BYTE)te=e.R8I;if(U===e.SHORT)te=e.R16I;if(U===e.INT)te=e.R32I}if(y===e.RG){if(U===e.FLOAT)te=e.RG32F;if(U===e.HALF_FLOAT)te=e.RG16F;if(U===e.UNSIGNED_BYTE)te=e.RG8;if(U===e.UNSIGNED_SHORT&&ve)te=ve.RG16_EXT;if(U===e.SHORT&&ve)te=ve.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.RG8UI;if(U===e.UNSIGNED_SHORT)te=e.RG16UI;if(U===e.UNSIGNED_INT)te=e.RG32UI;if(U===e.BYTE)te=e.RG8I;if(U===e.SHORT)te=e.RG16I;if(U===e.INT)te=e.RG32I}if(y===e.RGB_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.RGB8UI;if(U===e.UNSIGNED_SHORT)te=e.RGB16UI;if(U===e.UNSIGNED_INT)te=e.RGB32UI;if(U===e.BYTE)te=e.RGB8I;if(U===e.SHORT)te=e.RGB16I;if(U===e.INT)te=e.RGB32I}if(y===e.RGBA_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.RGBA8UI;if(U===e.UNSIGNED_SHORT)te=e.RGBA16UI;if(U===e.UNSIGNED_INT)te=e.RGBA32UI;if(U===e.BYTE)te=e.RGBA8I;if(U===e.SHORT)te=e.RGBA16I;if(U===e.INT)te=e.RGBA32I}if(y===e.RGB){if(U===e.UNSIGNED_SHORT&&ve)te=ve.RGB16_EXT;if(U===e.SHORT&&ve)te=ve.RGB16_SNORM_EXT;if(U===e.UNSIGNED_INT_5_9_9_9_REV)te=e.RGB9_E5;if(U===e.UNSIGNED_INT_10F_11F_11F_REV)te=e.R11F_G11F_B10F}if(y===e.RGBA){let se=me?cd:Ke.getTransfer(le);if(U===e.FLOAT)te=e.RGBA32F;if(U===e.HALF_FLOAT)te=e.RGBA16F;if(U===e.UNSIGNED_BYTE)te=se===yt?e.SRGB8_ALPHA8:e.RGBA8;if(U===e.UNSIGNED_SHORT&&ve)te=ve.RGBA16_EXT;if(U===e.SHORT&&ve)te=ve.RGBA16_SNORM_EXT;if(U===e.UNSIGNED_SHORT_4_4_4_4)te=e.RGBA4;if(U===e.UNSIGNED_SHORT_5_5_5_1)te=e.RGB5_A1}if(te===e.R16F||te===e.R32F||te===e.RG16F||te===e.RG32F||te===e.RGBA16F||te===e.RGBA32F)t.get("EXT_color_buffer_float");return te}function S(A,y){let U;if(A){if(y===null||y===mr||y===Us)U=e.DEPTH24_STENCIL8;else if(y===$i)U=e.DEPTH32F_STENCIL8;else if(y===Zo)U=e.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===mr||y===Us)U=e.DEPTH_COMPONENT24;else if(y===$i)U=e.DEPTH_COMPONENT32F;else if(y===Zo)U=e.DEPTH_COMPONENT16;return U}function E(A,y){if(g(A)===!0||A.isFramebufferTexture&&A.minFilter!==ti&&A.minFilter!==Jt)return Math.log2(Math.max(y.width,y.height))+1;else if(A.mipmaps!==void 0&&A.mipmaps.length>0)return A.mipmaps.length;else if(A.isCompressedTexture&&Array.isArray(A.image))return y.mipmaps.length;else return 1}function R(A){let y=A.target;if(y.removeEventListener("dispose",R),w(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)h.delete(y)}function x(A){let y=A.target;y.removeEventListener("dispose",x),C(y)}function w(A){let y=i.get(A);if(y.__webglInit===void 0)return;let U=A.source,Y=f.get(U);if(Y){let le=Y[y.__cacheKey];if(le.usedTimes--,le.usedTimes===0)G(A);if(Object.keys(Y).length===0)f.delete(U)}i.remove(A)}function G(A){let y=i.get(A);e.deleteTexture(y.__webglTexture);let U=A.source,Y=f.get(U);delete Y[y.__cacheKey],o.memory.textures--}function C(A){let y=i.get(A);if(A.depthTexture)A.depthTexture.dispose(),i.remove(A.depthTexture);if(A.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(y.__webglFramebuffer[Y]))for(let le=0;le<y.__webglFramebuffer[Y].length;le++)e.deleteFramebuffer(y.__webglFramebuffer[Y][le]);else e.deleteFramebuffer(y.__webglFramebuffer[Y]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[Y])}else{if(Array.isArray(y.__webglFramebuffer))for(let Y=0;Y<y.__webglFramebuffer.length;Y++)e.deleteFramebuffer(y.__webglFramebuffer[Y]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let Y=0;Y<y.__webglColorRenderbuffer.length;Y++)if(y.__webglColorRenderbuffer[Y])e.deleteRenderbuffer(y.__webglColorRenderbuffer[Y])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let U=A.textures;for(let Y=0,le=U.length;Y<le;Y++){let me=i.get(U[Y]);if(me.__webglTexture)e.deleteTexture(me.__webglTexture),o.memory.textures--;i.remove(U[Y])}i.remove(A)}let D=0;function ee(){D=0}function L(){return D}function W(A){D=A}function B(){let A=D;if(A>=r.maxTextures)Ue("WebGLTextures: Trying to use "+(A+1)+" texture units while this GPU supports only "+r.maxTextures);return D+=1,A}function P(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function J(A,y){let U=i.get(A);if(A.isVideoTexture)_n(A);if(A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&U.__version!==A.version){let Y=A.image;if(Y===null)Ue("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Ue("WebGLRenderer: Texture marked for update but image is incomplete");else{re(U,A,y);return}}else if(A.isExternalTexture)U.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,U.__webglTexture,e.TEXTURE0+y)}function H(A,y){let U=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){re(U,A,y);return}else if(A.isExternalTexture)U.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,U.__webglTexture,e.TEXTURE0+y)}function q(A,y){let U=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){re(U,A,y);return}n.bindTexture(e.TEXTURE_3D,U.__webglTexture,e.TEXTURE0+y)}function Q(A,y){let U=i.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&U.__version!==A.version){oe(U,A,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,U.__webglTexture,e.TEXTURE0+y)}let ge={[Ns]:e.REPEAT,[Ds]:e.CLAMP_TO_EDGE,[kc]:e.MIRRORED_REPEAT},he={[ti]:e.NEAREST,[Bc]:e.NEAREST_MIPMAP_NEAREST,[Zr]:e.NEAREST_MIPMAP_LINEAR,[Jt]:e.LINEAR,[Os]:e.LINEAR_MIPMAP_NEAREST,[yi]:e.LINEAR_MIPMAP_LINEAR},de={[hv]:e.NEVER,[gv]:e.ALWAYS,[dv]:e.LESS,[jc]:e.LEQUAL,[fv]:e.EQUAL,[qc]:e.GEQUAL,[pv]:e.GREATER,[mv]:e.NOTEQUAL};function fe(A,y){if(y.type===$i&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===Jt||y.magFilter===Os||y.magFilter===Zr||y.magFilter===yi||y.minFilter===Jt||y.minFilter===Os||y.minFilter===Zr||y.minFilter===yi))Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(A,e.TEXTURE_WRAP_S,ge[y.wrapS]),e.texParameteri(A,e.TEXTURE_WRAP_T,ge[y.wrapT]),A===e.TEXTURE_3D||A===e.TEXTURE_2D_ARRAY)e.texParameteri(A,e.TEXTURE_WRAP_R,ge[y.wrapR]);if(e.texParameteri(A,e.TEXTURE_MAG_FILTER,he[y.magFilter]),e.texParameteri(A,e.TEXTURE_MIN_FILTER,he[y.minFilter]),y.compareFunction)e.texParameteri(A,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(A,e.TEXTURE_COMPARE_FUNC,de[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===ti)return;if(y.minFilter!==Zr&&y.minFilter!==yi)return;if(y.type===$i&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let U=t.get("EXT_texture_filter_anisotropic");e.texParameterf(A,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function I(A,y){let U=!1;if(A.__webglInit===void 0)A.__webglInit=!0,y.addEventListener("dispose",R);let Y=y.source,le=f.get(Y);if(le===void 0)le={},f.set(Y,le);let me=P(y);if(me!==A.__cacheKey){if(le[me]===void 0)le[me]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,U=!0;le[me].usedTimes++;let ve=le[A.__cacheKey];if(ve!==void 0){if(le[A.__cacheKey].usedTimes--,ve.usedTimes===0)G(y)}A.__cacheKey=me,A.__webglTexture=le[me].texture}return U}function V(A,y,U){return Math.floor(Math.floor(A/U)/y)}function j(A,y,U,Y){let me=A.updateRanges;if(me.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,U,Y,y.data);else{me.sort((Oe,ye)=>Oe.start-ye.start);let ve=0;for(let Oe=1;Oe<me.length;Oe++){let ye=me[ve],pe=me[Oe],ze=ye.start+ye.count,Be=V(pe.start,y.width,4),ot=V(ye.start,y.width,4);if(pe.start<=ze+1&&Be===ot&&V(pe.start+pe.count-1,y.width,4)===Be)ye.count=Math.max(ye.count,pe.start+pe.count-ye.start);else++ve,me[ve]=pe}me.length=ve+1;let te=n.getParameter(e.UNPACK_ROW_LENGTH),se=n.getParameter(e.UNPACK_SKIP_PIXELS),Ee=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Oe=0,ye=me.length;Oe<ye;Oe++){let pe=me[Oe],ze=Math.floor(pe.start/4),Be=Math.ceil(pe.count/4),ot=ze%y.width,k=Math.floor(ze/y.width),_e=Be,ne=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,ot),n.pixelStorei(e.UNPACK_SKIP_ROWS,k),n.texSubImage2D(e.TEXTURE_2D,0,ot,k,_e,1,U,Y,y.data)}A.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,te),n.pixelStorei(e.UNPACK_SKIP_PIXELS,se),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ee)}}function re(A,y,U){let Y=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)Y=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)Y=e.TEXTURE_3D;let le=I(A,y),me=y.source;n.bindTexture(Y,A.__webglTexture,e.TEXTURE0+U);let ve=i.get(me);if(me.version!==ve.__version||le===!0){if(n.activeTexture(e.TEXTURE0+U),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let ne=Ke.getPrimaries(Ke.workingColorSpace),xe=y.colorSpace===Yr?null:Ke.getPrimaries(y.colorSpace),Te=y.colorSpace===Yr||ne===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let se=p(y.image,!1,r.maxTextureSize);se=ut(y,se);let Ee=s.convert(y.format,y.colorSpace),Oe=s.convert(y.type),ye=v(y.internalFormat,Ee,Oe,y.normalized,y.colorSpace,y.isVideoTexture);fe(Y,y);let pe,ze=y.mipmaps,Be=y.isVideoTexture!==!0,ot=ve.__version===void 0||le===!0,k=me.dataReady,_e=E(y,se);if(y.isDepthTexture){if(ye=S(y.format===jr,y.type),ot)if(Be)n.texStorage2D(e.TEXTURE_2D,1,ye,se.width,se.height);else n.texImage2D(e.TEXTURE_2D,0,ye,se.width,se.height,0,Ee,Oe,null)}else if(y.isDataTexture)if(ze.length>0){if(Be&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Be){if(k)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data);y.generateMipmaps=!1}else if(Be){if(ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,se.width,se.height);if(k)j(y,se,Ee,Oe)}else n.texImage2D(e.TEXTURE_2D,0,ye,se.width,se.height,0,Ee,Oe,se.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(Be&&ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,ze[0].width,ze[0].height,se.depth);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Be){if(k)if(y.layerUpdates.size>0){let Te=Ld(pe.width,pe.height,y.format,y.type);for(let ce of y.layerUpdates){let Se=pe.data.subarray(ce*Te/pe.data.BYTES_PER_ELEMENT,(ce+1)*Te/pe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,ce,pe.width,pe.height,1,Ee,Se)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,se.depth,Ee,pe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,se.depth,0,pe.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Be){if(k)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,se.depth,Ee,Oe,pe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,se.depth,0,Ee,Oe,pe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(Be&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Be){if(k)n.compressedTexSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,pe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,pe.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Be){if(k)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data)}else if(y.isDataArrayTexture)if(Be){if(ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,se.width,se.height,se.depth);if(k)if(y.layerUpdates.size>0){let ne=Ld(se.width,se.height,y.format,y.type);for(let xe of y.layerUpdates){let Te=se.data.subarray(xe*ne/se.data.BYTES_PER_ELEMENT,(xe+1)*ne/se.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,se.width,se.height,1,Ee,Oe,Te)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,se.width,se.height,se.depth,Ee,Oe,se.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ye,se.width,se.height,se.depth,0,Ee,Oe,se.data);else if(y.isData3DTexture)if(Be){if(ot)n.texStorage3D(e.TEXTURE_3D,_e,ye,se.width,se.height,se.depth);if(k)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,se.width,se.height,se.depth,Ee,Oe,se.data)}else n.texImage3D(e.TEXTURE_3D,0,ye,se.width,se.height,se.depth,0,Ee,Oe,se.data);else if(y.isFramebufferTexture){if(ot)if(Be)n.texStorage2D(e.TEXTURE_2D,_e,ye,se.width,se.height);else{let ne=se.width,xe=se.height;for(let Te=0;Te<_e;Te++)n.texImage2D(e.TEXTURE_2D,Te,ye,ne,xe,0,Ee,Oe,null),ne>>=1,xe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let ne=e.canvas;if(!ne.hasAttribute("layoutsubtree"))ne.setAttribute("layoutsubtree","true");if(se.parentNode!==ne){ne.appendChild(se),h.add(y),ne.onpaint=(xe)=>{let Te=xe.changedElements;for(let ce of h)if(Te.includes(ce.image))ce.needsUpdate=!0},ne.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,se);else{let{RGBA:Te,RGBA:ce,UNSIGNED_BYTE:Se}=e;e.texElementImage2D(e.TEXTURE_2D,0,Te,ce,Se,se)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(ze.length>0){if(Be&&ot){let ne=Pt(ze[0]);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Be){if(k)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,Ee,Oe,pe)}else n.texImage2D(e.TEXTURE_2D,ne,ye,Ee,Oe,pe);y.generateMipmaps=!1}else if(Be){if(ot){let ne=Pt(se);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}if(k)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ee,Oe,se)}else n.texImage2D(e.TEXTURE_2D,0,ye,Ee,Oe,se);if(g(y))M(Y);if(ve.__version=me.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function oe(A,y,U){if(y.image.length!==6)return;let Y=I(A,y),le=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,A.__webglTexture,e.TEXTURE0+U);let me=i.get(le);if(le.version!==me.__version||Y===!0){n.activeTexture(e.TEXTURE0+U);let ve=Ke.getPrimaries(Ke.workingColorSpace),te=y.colorSpace===Yr?null:Ke.getPrimaries(y.colorSpace),se=y.colorSpace===Yr||ve===te?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,se);let Ee=y.isCompressedTexture||y.image[0].isCompressedTexture,Oe=y.image[0]&&y.image[0].isDataTexture,ye=[];for(let ce=0;ce<6;ce++){if(!Ee&&!Oe)ye[ce]=p(y.image[ce],!0,r.maxCubemapSize);else ye[ce]=Oe?y.image[ce].image:y.image[ce];ye[ce]=ut(y,ye[ce])}let pe=ye[0],ze=s.convert(y.format,y.colorSpace),Be=s.convert(y.type),ot=v(y.internalFormat,ze,Be,y.normalized,y.colorSpace),k=y.isVideoTexture!==!0,_e=me.__version===void 0||Y===!0,ne=le.dataReady,xe=E(y,pe);fe(e.TEXTURE_CUBE_MAP,y);let Te;if(Ee){if(k&&_e)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,pe.width,pe.height);for(let ce=0;ce<6;ce++){Te=ye[ce].mipmaps;for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(y.format!==Si)if(ze!==null)if(k){if(ne)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,0,0,Ze.width,Ze.height,ze,Ze.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,ot,Ze.width,Ze.height,0,Ze.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,0,0,Ze.width,Ze.height,ze,Be,Ze.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,ot,Ze.width,Ze.height,0,ze,Be,Ze.data)}}}else{if(Te=y.mipmaps,k&&_e){if(Te.length>0)xe++;let ce=Pt(ye[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(Oe){if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ye[ce].width,ye[ce].height,ze,Be,ye[ce].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ot,ye[ce].width,ye[ce].height,0,ze,Be,ye[ce].data);for(let Se=0;Se<Te.length;Se++){let bt=Te[Se].image[ce].image;if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,0,0,bt.width,bt.height,ze,Be,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,ot,bt.width,bt.height,0,ze,Be,bt.data)}}else{if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ze,Be,ye[ce])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ot,ze,Be,ye[ce]);for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,0,0,ze,Be,Ze.image[ce])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,ot,ze,Be,Ze.image[ce])}}}if(g(y))M(e.TEXTURE_CUBE_MAP);if(me.__version=le.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function ue(A,y,U,Y,le,me){let ve=s.convert(U.format,U.colorSpace),te=s.convert(U.type),se=v(U.internalFormat,ve,te,U.normalized,U.colorSpace),Ee=i.get(y),Oe=i.get(U);if(Oe.__renderTarget=y,!Ee.__hasExternalTextures){let ye=Math.max(1,y.width>>me),pe=Math.max(1,y.height>>me);if(le===e.TEXTURE_3D||le===e.TEXTURE_2D_ARRAY)n.texImage3D(le,me,se,ye,pe,y.depth,0,ve,te,null);else n.texImage2D(le,me,se,ye,pe,0,ve,te,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,A),O(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Y,le,Oe.__webglTexture,0,It(y));else if(le===e.TEXTURE_2D||le>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&le<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,Y,le,Oe.__webglTexture,me);n.bindFramebuffer(e.FRAMEBUFFER,null)}function $e(A,y,U){if(e.bindRenderbuffer(e.RENDERBUFFER,A),y.depthBuffer){let Y=y.depthTexture,le=Y&&Y.isDepthTexture?Y.type:null,me=S(y.stencilBuffer,le),ve=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(O(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),me,y.width,y.height);else if(U)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),me,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,me,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,A)}else{let Y=y.textures;for(let le=0;le<Y.length;le++){let me=Y[le],ve=s.convert(me.format,me.colorSpace),te=s.convert(me.type),se=v(me.internalFormat,ve,te,me.normalized,me.colorSpace);if(O(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),se,y.width,y.height);else if(U)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),se,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,se,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ce(A,y,U){let Y=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,A),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let le=i.get(y.depthTexture);if(le.__renderTarget=y,!le.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(Y){if(le.__webglInit===void 0)le.__webglInit=!0,y.depthTexture.addEventListener("dispose",R);if(le.__webglTexture===void 0){le.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,le.__webglTexture),fe(e.TEXTURE_CUBE_MAP,y.depthTexture);let Ee=s.convert(y.depthTexture.format),Oe=s.convert(y.depthTexture.type),ye;if(y.depthTexture.format===Xr)ye=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===jr)ye=e.DEPTH24_STENCIL8;for(let pe=0;pe<6;pe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,ye,y.width,y.height,0,Ee,Oe,null)}}else J(y.depthTexture,0);let me=le.__webglTexture,ve=It(y),te=Y?e.TEXTURE_CUBE_MAP_POSITIVE_X+U:e.TEXTURE_2D,se=y.depthTexture.format===jr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Xr)if(O(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,se,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,se,te,me,0);else if(y.depthTexture.format===jr)if(O(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,se,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,se,te,me,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function He(A){let y=i.get(A),U=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let Y=A.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(Y){let le=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,Y.removeEventListener("dispose",le)};Y.addEventListener("dispose",le),y.__depthDisposeCallback=le}y.__boundDepthTexture=Y}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(U)for(let Y=0;Y<6;Y++)Ce(y.__webglFramebuffer[Y],A,Y);else{let Y=A.texture.mipmaps;if(Y&&Y.length>0)Ce(y.__webglFramebuffer[0],A,0);else Ce(y.__webglFramebuffer,A,0)}else if(U){y.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[Y]),y.__webglDepthbuffer[Y]===void 0)y.__webglDepthbuffer[Y]=e.createRenderbuffer(),$e(y.__webglDepthbuffer[Y],A,!1);else{let le=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer[Y];e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,le,e.RENDERBUFFER,me)}}else{let Y=A.texture.mipmaps;if(Y&&Y.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),$e(y.__webglDepthbuffer,A,!1);else{let le=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,le,e.RENDERBUFFER,me)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function rt(A,y,U){let Y=i.get(A);if(y!==void 0)ue(Y.__webglFramebuffer,A,A.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(U!==void 0)He(A)}function nt(A){let y=A.texture,U=i.get(A),Y=i.get(y);A.addEventListener("dispose",x);let le=A.textures,me=A.isWebGLCubeRenderTarget===!0,ve=le.length>1;if(!ve){if(Y.__webglTexture===void 0)Y.__webglTexture=e.createTexture();Y.__version=y.version,o.memory.textures++}if(me){U.__webglFramebuffer=[];for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0){U.__webglFramebuffer[te]=[];for(let se=0;se<y.mipmaps.length;se++)U.__webglFramebuffer[te][se]=e.createFramebuffer()}else U.__webglFramebuffer[te]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){U.__webglFramebuffer=[];for(let te=0;te<y.mipmaps.length;te++)U.__webglFramebuffer[te]=e.createFramebuffer()}else U.__webglFramebuffer=e.createFramebuffer();if(ve)for(let te=0,se=le.length;te<se;te++){let Ee=i.get(le[te]);if(Ee.__webglTexture===void 0)Ee.__webglTexture=e.createTexture(),o.memory.textures++}if(A.samples>0&&O(A)===!1){U.__webglMultisampledFramebuffer=e.createFramebuffer(),U.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let te=0;te<le.length;te++){let se=le[te];U.__webglColorRenderbuffer[te]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,U.__webglColorRenderbuffer[te]);let Ee=s.convert(se.format,se.colorSpace),Oe=s.convert(se.type),ye=v(se.internalFormat,Ee,Oe,se.normalized,se.colorSpace,A.isXRRenderTarget===!0),pe=It(A);e.renderbufferStorageMultisample(e.RENDERBUFFER,pe,ye,A.width,A.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+te,e.RENDERBUFFER,U.__webglColorRenderbuffer[te])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),A.depthBuffer)U.__webglDepthRenderbuffer=e.createRenderbuffer(),$e(U.__webglDepthRenderbuffer,A,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(me){n.bindTexture(e.TEXTURE_CUBE_MAP,Y.__webglTexture),fe(e.TEXTURE_CUBE_MAP,y);for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0)for(let se=0;se<y.mipmaps.length;se++)ue(U.__webglFramebuffer[te][se],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,se);else ue(U.__webglFramebuffer[te],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,0);if(g(y))M(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let te=0,se=le.length;te<se;te++){let Ee=le[te],Oe=i.get(Ee),ye=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)ye=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ye,Oe.__webglTexture),fe(ye,Ee),ue(U.__webglFramebuffer,A,Ee,e.COLOR_ATTACHMENT0+te,ye,0),g(Ee))M(ye)}n.unbindTexture()}else{let te=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)te=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(te,Y.__webglTexture),fe(te,y),y.mipmaps&&y.mipmaps.length>0)for(let se=0;se<y.mipmaps.length;se++)ue(U.__webglFramebuffer[se],A,y,e.COLOR_ATTACHMENT0,te,se);else ue(U.__webglFramebuffer,A,y,e.COLOR_ATTACHMENT0,te,0);if(g(y))M(te);n.unbindTexture()}if(A.depthBuffer)He(A)}function Rt(A){let y=A.textures;for(let U=0,Y=y.length;U<Y;U++){let le=y[U];if(g(le)){let me=T(A),ve=i.get(le).__webglTexture;n.bindTexture(me,ve),M(me),n.unbindTexture()}}}let it=[],tn=[];function Ut(A){if(A.samples>0){if(O(A)===!1){let{textures:y,width:U,height:Y}=A,le=e.COLOR_BUFFER_BIT,me=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(A),te=y.length>1;if(te)for(let Ee=0;Ee<y.length;Ee++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let se=A.texture.mipmaps;if(se&&se.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ee=0;Ee<y.length;Ee++){if(A.resolveDepthBuffer){if(A.depthBuffer)le|=e.DEPTH_BUFFER_BIT;if(A.stencilBuffer&&A.resolveStencilBuffer)le|=e.STENCIL_BUFFER_BIT}if(te){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Oe,0)}if(e.blitFramebuffer(0,0,U,Y,0,0,U,Y,le,e.NEAREST),c===!0){if(it.length=0,tn.length=0,it.push(e.COLOR_ATTACHMENT0+Ee),A.depthBuffer&&A.storeMultisampledDepthBuffer===!1)it.push(me),tn.push(me),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,tn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,it)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),te)for(let Ee=0;Ee<y.length;Ee++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,Oe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&c){let y=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function It(A){return Math.min(r.maxSamples,A.samples)}function O(A){let y=i.get(A);return A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function _n(A){let y=o.render.frame;if(u.get(A)!==y)u.set(A,y),A.update()}function ut(A,y){let{colorSpace:U,format:Y,type:le}=A;if(A.isCompressedTexture===!0||A.isVideoTexture===!0)return y;if(U!==Rn&&U!==Yr)if(Ke.getTransfer(U)===yt){if(Y!==Si||le!==ni)Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ve("WebGLTextures: Unsupported texture color space:",U);return y}function Pt(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement)l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height;else if(typeof VideoFrame<"u"&&A instanceof VideoFrame)l.width=A.displayWidth,l.height=A.displayHeight;else l.width=A.width,l.height=A.height;return l}this.allocateTextureUnit=B,this.resetTextureUnits=ee,this.getTextureUnits=L,this.setTextureUnits=W,this.setTexture2D=J,this.setTexture2DArray=H,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=rt,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=He,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=O,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function iC(e,t){function n(i,r=Yr){let s,o=Ke.getTransfer(r);if(i===ni)return e.UNSIGNED_BYTE;if(i===Mh)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Eh)return e.UNSIGNED_SHORT_5_5_5_1;if(i===sv)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===ov)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===iv)return e.BYTE;if(i===rv)return e.SHORT;if(i===Zo)return e.UNSIGNED_SHORT;if(i===wh)return e.INT;if(i===mr)return e.UNSIGNED_INT;if(i===$i)return e.FLOAT;if(i===bi)return e.HALF_FLOAT;if(i===av)return e.ALPHA;if(i===cv)return e.RGB;if(i===Si)return e.RGBA;if(i===Xr)return e.DEPTH_COMPONENT;if(i===jr)return e.DEPTH_STENCIL;if(i===lv)return e.RED;if(i===Th)return e.RED_INTEGER;if(i===qr)return e.RG;if(i===Ah)return e.RG_INTEGER;if(i===Rh)return e.RGBA_INTEGER;if(i===Gc||i===Hc||i===Vc||i===$c)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Gc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Vc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===$c)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Gc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Vc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===$c)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ch||i===Ih||i===Ph||i===Lh)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ch)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ph)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Lh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nh||i===Dh||i===Oh||i===Uh||i===Fh||i===Wc||i===zh)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Nh||i===Dh)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Oh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Uh)return s.COMPRESSED_R11_EAC;if(i===Fh)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Wc)return s.COMPRESSED_RG11_EAC;if(i===zh)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===kh||i===Bh||i===Gh||i===Hh||i===Vh||i===$h||i===Wh||i===Zh||i===Xh||i===jh||i===qh||i===Yh||i===Kh||i===Jh)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Bh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Hh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Vh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$h)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Wh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Xh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===qh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Yh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Qh||i===ed||i===td)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Qh)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ed)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===td)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===nd||i===id||i===Zc||i===rd)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===nd)return s.COMPRESSED_RED_RGTC1_EXT;if(i===id)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===rd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Us)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var rC=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,iC=`
+}`,sC=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4278,4 +4278,4 @@ void main() {
}
-}`;class ay{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new nl(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Gn({vertexShader:nC,fragmentShader:iC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new ta(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cy extends ii{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,h=null,d=null,f=null,m=typeof XRWebGLBinding<"u",_=new ay,p={},g=t.getContextAttributes(),M=null,T=null,v=[],S=[],E=new Be,R=null,x=null,w=new Ht;w.viewport=new pt;let H=new Ht;H.viewport=new pt;let C=[w,H],N=new Ed,ee=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(I){let V=v[I];if(V===void 0)V=new Xo,v[I]=V;return V.getTargetRaySpace()},this.getControllerGrip=function(I){let V=v[I];if(V===void 0)V=new Xo,v[I]=V;return V.getGripSpace()},this.getHand=function(I){let V=v[I];if(V===void 0)V=new Xo,v[I]=V;return V.getHandSpace()};function Z(I){let V=S.indexOf(I.inputSource);if(V===-1)return;let q=v[V];if(q!==void 0)q.update(I.inputSource,I.frame,c||s),q.dispatchEvent({type:I.type,data:I.inputSource})}function G(){i.removeEventListener("select",Z),i.removeEventListener("selectstart",Z),i.removeEventListener("selectend",Z),i.removeEventListener("squeeze",Z),i.removeEventListener("squeezestart",Z),i.removeEventListener("squeezeend",Z),i.removeEventListener("end",G),i.removeEventListener("inputsourceschange",k);for(let I=0;I<v.length;I++){let V=S[I];if(V===null)continue;S[I]=null,v[I].disconnect(V)}ee=null,P=null,_.reset();for(let I in p)delete p[I];if(e.setRenderTarget(M),d=null,h=null,u=null,i=null,T=null,he.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(E.width,E.height,!1),x!==null){let I=x.camera;I.fov=x.fov,I.zoom=x.zoom,I.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(I){if(r=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(I){if(o=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(I){c=I},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(I){if(i=I,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",Z),i.addEventListener("selectstart",Z),i.addEventListener("selectend",Z),i.addEventListener("squeeze",Z),i.addEventListener("squeezestart",Z),i.addEventListener("squeezeend",Z),i.addEventListener("end",G),i.addEventListener("inputsourceschange",k),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(E),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let q={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,q),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),T=new Cn(d.framebufferWidth,d.framebufferHeight,{format:Si,type:ni,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let q=null,se=null,ce=null;if(g.depth)ce=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,q=g.stencil?Xr:Zr,se=g.stencil?Os:pr;let ae={colorFormat:t.RGBA8,depthFormat:ce,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(ae),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),T=new Cn(h.textureWidth,h.textureHeight,{format:Si,type:ni,depthTexture:new Yr(h.textureWidth,h.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),he.setContext(i),he.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function k(I){for(let V=0;V<I.removed.length;V++){let q=I.removed[V],se=S.indexOf(q);if(se>=0)S[se]=null,v[se].disconnect(q)}for(let V=0;V<I.added.length;V++){let q=I.added[V],se=S.indexOf(q);if(se===-1){for(let ae=0;ae<v.length;ae++)if(ae>=S.length){S.push(q),se=ae;break}else if(S[ae]===null){S[ae]=q,se=ae;break}if(se===-1)break}let ce=v[se];if(ce)ce.connect(q)}}let W=new F,B=new F;function Y(I,V,q){W.setFromMatrixPosition(V.matrixWorld),B.setFromMatrixPosition(q.matrixWorld);let se=W.distanceTo(B),ce=V.projectionMatrix.elements,ae=q.projectionMatrix.elements,ke=ce[14]/(ce[10]-1),Ce=ce[14]/(ce[10]+1),Ve=(ce[9]+1)/ce[5],rt=(ce[9]-1)/ce[5],nt=(ce[8]-1)/ce[0],Rt=(ae[8]+1)/ae[0],it=ke*nt,tn=ke*Rt,Ut=se/(-nt+Rt),It=Ut*-nt;if(V.matrixWorld.decompose(I.position,I.quaternion,I.scale),I.translateX(It),I.translateZ(Ut),I.matrixWorld.compose(I.position,I.quaternion,I.scale),I.matrixWorldInverse.copy(I.matrixWorld).invert(),ce[10]===-1)I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse);else{let D=ke+Ut,_n=Ce+Ut,ut=it-It,Pt=tn+(se-It),A=Ve*Ce/_n*D,y=rt*Ce/_n*D;I.projectionMatrix.makePerspective(ut,Pt,A,y,D,_n),I.projectionMatrixInverse.copy(I.projectionMatrix).invert()}}function K(I,V){if(V===null)I.matrixWorld.copy(I.matrix);else I.matrixWorld.multiplyMatrices(V.matrixWorld,I.matrix);I.matrixWorldInverse.copy(I.matrixWorld).invert()}this.updateCamera=function(I){if(i===null)return;let{near:V,far:q}=I;if(_.texture!==null){if(_.depthNear>0)V=_.depthNear;if(_.depthFar>0)q=_.depthFar}if(N.near=H.near=w.near=V,N.far=H.far=w.far=q,ee!==N.near||P!==N.far)i.updateRenderState({depthNear:N.near,depthFar:N.far}),ee=N.near,P=N.far;N.layers.mask=I.layers.mask|6,w.layers.mask=N.layers.mask&-5,H.layers.mask=N.layers.mask&-3;let se=I.parent,ce=N.cameras;K(N,se);for(let ae=0;ae<ce.length;ae++)K(ce[ae],se);if(ce.length===2)Y(N,w,H);else N.projectionMatrix.copy(w.projectionMatrix);if(x===null&&I.isPerspectiveCamera)x={camera:I,fov:I.fov,zoom:I.zoom};ge(I,N,se)};function ge(I,V,q){if(q===null)I.matrix.copy(V.matrixWorld);else I.matrix.copy(q.matrixWorld),I.matrix.invert(),I.matrix.multiply(V.matrixWorld);if(I.matrix.decompose(I.position,I.quaternion,I.scale),I.updateMatrixWorld(!0),I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse),I.isPerspectiveCamera)I.fov=Vr*2*Math.atan(1/I.projectionMatrix.elements[5]),I.zoom=1}this.getCamera=function(){return N},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(I){if(a=I,h!==null)h.fixedFoveation=I;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=I},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(N)},this.getCameraTexture=function(I){return p[I]};let de=null;function fe(I,V){if(l=V.getViewerPose(c||s),f=V,l!==null){let q=l.views;if(d!==null)e.setRenderTargetFramebuffer(T,d.framebuffer),e.setRenderTarget(T);let se=!1;if(q.length!==N.cameras.length)N.cameras.length=0,se=!0;for(let Ce=0;Ce<q.length;Ce++){let Ve=q[Ce],rt=null;if(d!==null)rt=d.getViewport(Ve);else{let Rt=u.getViewSubImage(h,Ve);if(rt=Rt.viewport,Ce===0)e.setRenderTargetTextures(T,Rt.colorTexture,Rt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ce];if(nt===void 0)nt=new Ht,nt.layers.enable(Ce),nt.viewport=new pt,C[Ce]=nt;if(nt.matrix.fromArray(Ve.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Ve.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(rt.x,rt.y,rt.width,rt.height),Ce===0)N.matrix.copy(nt.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);if(se===!0)N.cameras.push(nt)}let ce=i.enabledFeatures;if(ce&&ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ce=u.getDepthInformation(q[0]);if(Ce&&Ce.isValid&&Ce.texture)_.init(Ce,i.renderState)}if(ce&&ce.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ce=0;Ce<q.length;Ce++){let Ve=q[Ce].camera;if(Ve){let rt=p[Ve];if(!rt)rt=new nl,p[Ve]=rt;let nt=u.getCameraImage(Ve);rt.sourceTexture=nt}}}}for(let q=0;q<v.length;q++){let se=S[q],ce=v[q];if(se!==null&&ce!==void 0)ce.update(se,V,c||s)}if(de)de(I,V);if(V.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:V});f=null}let he=new Yv;he.setAnimationLoop(fe),this.setAnimationLoop=function(I){de=I},this.dispose=function(){}}}var rC=new Xe,ly=new We;ly.set(-1,0,0,0,1,0,0,0,1);function sC(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,md(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,M,T,v){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),h(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),d(p,g),g.isMeshPhysicalMaterial)f(p,g,v)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,M,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===cn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===cn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let M=t.get(g),{envMap:T,envMapRotation:v}=M;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(rC.makeRotationFromEuler(v)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(ly);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,M,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*M,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function h(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function d(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,M){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=M.texture,p.transmissionSamplerSize.value.set(M.width,M.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let M=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(M.matrixWorld),p.nearDistance.value=M.shadow.camera.near,p.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function oC(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,S){let E=S.program;i.uniformBlockBinding(v,E)}function l(v,S){let E=r[v.id];if(E===void 0)p(v),E=u(v),r[v.id]=E,v.addEventListener("dispose",M);let R=S.program;i.updateUBOMapping(v,R);let x=t.render.frame;if(s[v.id]!==x)d(v),s[v.id]=x}function u(v){let S=h();v.__bindingPointIndex=S;let E=e.createBuffer(),{__size:R,usage:x}=v;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,S,E),E}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return $e("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let S=r[v.id],{uniforms:E,__cache:R}=v;e.bindBuffer(e.UNIFORM_BUFFER,S);for(let x=0,w=E.length;x<w;x++){let H=E[x];if(Array.isArray(H))for(let C=0,N=H.length;C<N;C++)f(H[C],x,C,R);else f(H,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(v,S,E,R){if(_(v,S,E,R)===!0){let{__offset:x,value:w}=v;if(Array.isArray(w)){let H=0;for(let C=0;C<w.length;C++){let N=w[C],ee=g(N);if(m(N,v.__data,H),typeof N!=="number"&&typeof N!=="boolean"&&!N.isMatrix3&&!ArrayBuffer.isView(N))H+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else m(w,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,v.__data)}}function m(v,S,E){if(typeof v==="number"||typeof v==="boolean")S[0]=v;else if(v.isMatrix3)S[0]=v.elements[0],S[1]=v.elements[1],S[2]=v.elements[2],S[3]=0,S[4]=v.elements[3],S[5]=v.elements[4],S[6]=v.elements[5],S[7]=0,S[8]=v.elements[6],S[9]=v.elements[7],S[10]=v.elements[8],S[11]=0;else if(ArrayBuffer.isView(v))S.set(new v.constructor(v.buffer,v.byteOffset,S.length));else v.toArray(S,E)}function _(v,S,E,R){let x=v.value,w=S+"_"+E;if(R[w]===void 0){if(typeof x==="number"||typeof x==="boolean")R[w]=x;else if(ArrayBuffer.isView(x))R[w]=x.slice();else R[w]=x.clone();return!0}else{let H=R[w];if(typeof x==="number"||typeof x==="boolean"){if(H!==x)return R[w]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(H.equals(x)===!1)return H.copy(x),!0}return!1}function p(v){let S=v.uniforms,E=0,R=16;for(let w=0,H=S.length;w<H;w++){let C=Array.isArray(S[w])?S[w]:[S[w]];for(let N=0,ee=C.length;N<ee;N++){let P=C[N],Z=Array.isArray(P.value)?P.value:[P.value];for(let G=0,k=Z.length;G<k;G++){let W=Z[G],B=g(W),Y=E%R,K=Y%B.boundary,ge=Y+K;if(E+=K,ge!==0&&R-ge<B.storage)E+=R-ge;P.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=E,E+=B.storage}}}let x=E%R;if(x>0)E+=R-x;return v.__size=E,v.__cache={},this}function g(v){let S={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")S.boundary=4,S.storage=4;else if(v.isVector2)S.boundary=8,S.storage=8;else if(v.isVector3||v.isColor)S.boundary=16,S.storage=12;else if(v.isVector4)S.boundary=16,S.storage=16;else if(v.isMatrix3)S.boundary=48,S.storage=48;else if(v.isMatrix4)S.boundary=64,S.storage=64;else if(v.isTexture)Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))S.boundary=16,S.storage=v.byteLength;else Ue("WebGLRenderer: Unsupported uniform value type.",v);return S}function M(v){let S=v.target;S.removeEventListener("dispose",M);let E=o.indexOf(S.__bindingPointIndex);o.splice(E,1),e.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function T(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var aC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Mi=null;function cC(){if(Mi===null)Mi=new Yo(aC,16,16,jr,bi),Mi.name="DFG_LUT",Mi.minFilter=Jt,Mi.magFilter=Jt,Mi.wrapS=Ns,Mi.wrapT=Ns,Mi.generateMipmaps=!1,Mi.needsUpdate=!0;return Mi}class Gd{constructor(e={}){let{canvas:t=gv(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=ni}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=d,_=new Set([Ah,Th,Eh]),p=new Set([ni,pr,Vo,Os,wh,Mh]),g=new Uint32Array(4),M=new Int32Array(4),T=new F,v=null,S=null,E=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ei,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,H=!1,C=null,N=null,ee=null,P=null;this._outputColorSpace=mr;let Z=0,G=0,k=null,W=-1,B=null,Y=new pt,K=new pt,ge=null,de=new He(0),fe=0,{width:he,height:I}=t,V=1,q=null,se=null,ce=new pt(0,0,he,I),ae=new pt(0,0,he,I),ke=!1,Ce=new Jo,Ve=!1,rt=!1,nt=new Xe,Rt=new F,it=new pt,tn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ut=!1;function It(){return k===null?V:1}let D=n;function _n(b,U){return t.getContext(b,U)}let ut,Pt,A,y,O,J,ue,me,ve,te,re,Ee,Oe,ye,pe,ze,Ge,ot,z,_e,ne,xe,Te;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${Sx}`);if(t.addEventListener("webglcontextlost",Ze,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",ht,!1),D===null){if(D=_n("webgl2",b),D===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}le()}catch(b){throw t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),$e("WebGLRenderer: "+b.message),b}function le(){if(ut=new m1(D),ut.init(),ne=new tC(D,ut),Pt=new s1(D,ut,e,ne),A=new QR(D,ut),Pt.reversedDepthBuffer&&h)A.buffers.depth.setReversed(!0);N=D.createFramebuffer(),ee=D.createFramebuffer(),P=D.createFramebuffer(),y=new x1(D),O=new kR,J=new eC(D,ut,A,O,Pt,ne,y),ue=new p1(w),me=new yE(D),xe=new i1(D,me),ve=new g1(D,me,y,xe),te=new y1(D,ve,me,xe,y),ot=new v1(D,Pt,J),pe=new o1(O),re=new zR(w,ue,ut,Pt,xe,pe),Ee=new sC(w,O),Oe=new GR,ye=new XR(ut),Ge=new n1(w,ue,A,te,f,a),ze=new JR(w,te,Pt),Te=new oC(D,y,Pt,A),z=new r1(D,ut,y),_e=new _1(D,ut,y),y.programs=re.programs,w.capabilities=Pt,w.extensions=ut,w.properties=O,w.renderLists=Oe,w.shadowMap=ze,w.state=A,w.info=y}if(m!==ni)x=new S1(m,t.width,t.height,o,i,r);let Se=new cy(w,D);this.xr=Se,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ut.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ut.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(b){if(b===void 0)return;V=b,this.setSize(he,I,!1)},this.getSize=function(b){return b.set(he,I)},this.setSize=function(b,U,Q=!0){if(Se.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}if(he=b,I=U,t.width=Math.floor(b*V),t.height=Math.floor(U*V),Q===!0)t.style.width=b+"px",t.style.height=U+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,U)},this.getDrawingBufferSize=function(b){return b.set(he*V,I*V).floor()},this.setDrawingBufferSize=function(b,U,Q){he=b,I=U,V=Q,t.width=Math.floor(b*Q),t.height=Math.floor(U*Q),this.setViewport(0,0,b,U)},this.setEffects=function(b){if(m===ni){$e("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let U=0;U<b.length;U++)if(b[U].isOutputPass===!0){Ue("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(Y)},this.getViewport=function(b){return b.copy(ce)},this.setViewport=function(b,U,Q,X){if(b.isVector4)ce.set(b.x,b.y,b.z,b.w);else ce.set(b,U,Q,X);A.viewport(Y.copy(ce).multiplyScalar(V).round())},this.getScissor=function(b){return b.copy(ae)},this.setScissor=function(b,U,Q,X){if(b.isVector4)ae.set(b.x,b.y,b.z,b.w);else ae.set(b,U,Q,X);A.scissor(K.copy(ae).multiplyScalar(V).round())},this.getScissorTest=function(){return ke},this.setScissorTest=function(b){A.setScissorTest(ke=b)},this.setOpaqueSort=function(b){q=b},this.setTransparentSort=function(b){se=b},this.getClearColor=function(b){return b.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor(...arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha(...arguments)},this.clear=function(b=!0,U=!0,Q=!0){let X=0;if(b){let j=!1;if(k!==null){let Me=k.texture.format;j=_.has(Me)}if(j){let Me=k.texture.type,Re=p.has(Me),we=Ge.getClearColor(),Ie=Ge.getClearAlpha(),{r:Ne,g:je,b:et}=we;if(Re)g[0]=Ne,g[1]=je,g[2]=et,g[3]=Ie,D.clearBufferuiv(D.COLOR,0,g);else M[0]=Ne,M[1]=je,M[2]=et,M[3]=Ie,D.clearBufferiv(D.COLOR,0,M)}else X|=D.COLOR_BUFFER_BIT}if(U)X|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(Q)X|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(X!==0)D.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),Ge.dispose(),Oe.dispose(),ye.dispose(),O.dispose(),ue.dispose(),te.dispose(),xe.dispose(),Te.dispose(),re.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",_f),Se.removeEventListener("sessionend",xf),Pr.stop()};function Ze(b){b.preventDefault(),zo("WebGLRenderer: Context Lost."),H=!0}function bt(){zo("WebGLRenderer: Context Restored."),H=!1;let b=y.autoReset,U=ze.enabled,Q=ze.autoUpdate,X=ze.needsUpdate,j=ze.type;le(),y.autoReset=b,ze.enabled=U,ze.autoUpdate=Q,ze.needsUpdate=X,ze.type=j}function ht(b){$e("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let U=b.target;U.removeEventListener("dispose",oi),Pi(U)}function Pi(b){Rb(b),O.remove(b)}function Rb(b){let U=O.get(b).programs;if(U!==void 0){if(U.forEach(function(Q){re.releaseProgram(Q)}),b.isShaderMaterial)re.releaseShaderCache(b)}}this.renderBufferDirect=function(b,U,Q,X,j,Me){if(U===null)U=tn;let Re=j.isMesh&&j.matrixWorld.determinantAffine()<0,we=Pb(b,U,Q,X,j);A.setMaterial(X,Re);let Ie=Q.index,Ne=1;if(X.wireframe===!0){if(Ie=ve.getWireframeAttribute(Q),Ie===void 0)return;Ne=2}let je=Q.drawRange,et=Q.attributes.position,Pe=je.start*Ne,dt=(je.start+je.count)*Ne;if(Me!==null)Pe=Math.max(Pe,Me.start*Ne),dt=Math.min(dt,(Me.start+Me.count)*Ne);if(Ie!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,Ie.count);else if(et!==void 0&&et!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,et.count);let Bt=dt-Pe;if(Bt<0||Bt===1/0)return;xe.setup(j,X,we,Q,Ie);let Et,xt=z;if(Ie!==null)Et=me.get(Ie),xt=_e,xt.setIndex(Et);if(j.isMesh)if(X.wireframe===!0)A.setLineWidth(X.wireframeLinewidth*It()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(j.isLine){let sn=X.linewidth;if(sn===void 0)sn=1;if(A.setLineWidth(sn*It()),j.isLineSegments)xt.setMode(D.LINES);else if(j.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(j.isPoints)xt.setMode(D.POINTS);else if(j.isSprite)xt.setMode(D.TRIANGLES);if(j.isBatchedMesh)if(!ut.get("WEBGL_multi_draw")){let{_multiDrawStarts:sn,_multiDrawCounts:Ae,_multiDrawCount:dn}=j,st=Ie?me.get(Ie).bytesPerElement:1,Nn=O.get(X).currentProgram.getUniforms();for(let ai=0;ai<dn;ai++)Nn.setValue(D,"_gl_DrawID",ai),xt.render(sn[ai]/st,Ae[ai])}else xt.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else if(j.isInstancedMesh)xt.renderInstances(Pe,Bt,j.count);else if(Q.isInstancedBufferGeometry){let sn=Q._maxInstanceCount!==void 0?Q._maxInstanceCount:1/0,Ae=Math.min(Q.instanceCount,sn);xt.renderInstances(Pe,Bt,Ae)}else xt.render(Pe,Bt)};function gf(b,U,Q,X){if(C!==null&&b.isNodeMaterial)C.setObject(X,b);if(Ve===!0)pe.setState(b,Q,!1);if(b.transparent===!0&&b.side===Bn&&b.forceSinglePass===!1)b.side=cn,b.needsUpdate=!0,Ma(b,U,X),b.side=fr,b.needsUpdate=!0,Ma(b,U,X),b.side=Bn;else Ma(b,U,X)}this.compile=function(b,U,Q=null){if(Q===null)Q=b;if(C!==null)C.renderStart(b,U,Q);if(S=ye.get(Q),S.init(U),R.push(S),Q.traverseVisible(function(j){if(j.isLight&&j.layers.test(U.layers)){if(S.pushLight(j),j.castShadow)S.pushShadow(j)}}),b!==Q)b.traverseVisible(function(j){if(j.isLight&&j.layers.test(U.layers)){if(S.pushLight(j),j.castShadow)S.pushShadow(j)}});if(S.setupLights(),C!==null)C.updateLights(S.state.lightsArray);if(rt=this.localClippingEnabled,Ve=pe.init(this.clippingPlanes,rt),Ve===!0)pe.setGlobalState(this.clippingPlanes,U);if(C!==null)ze.render(S.state.shadowsArray,Q,U);let X=new Set;if(b.traverse(function(j){if(!(j.isMesh||j.isPoints||j.isLine||j.isSprite))return;let Me=j.material;if(Me)if(Array.isArray(Me))for(let Re=0;Re<Me.length;Re++){let we=Me[Re];gf(we,Q,U,j),X.add(we)}else gf(Me,Q,U,j),X.add(Me)}),S=R.pop(),C!==null)C.renderEnd();return X},this.compileAsync=function(b,U,Q=null){let X=this.compile(b,U,Q);return new Promise((j)=>{function Me(){if(X.forEach(function(Re){let Ie=O.get(Re).currentProgram;if(Ie===void 0||Ie.isReady())X.delete(Re)}),X.size===0){j(b);return}setTimeout(Me,10)}if(ut.get("KHR_parallel_shader_compile")!==null)Me();else setTimeout(Me,10)})};let wl=null;function Cb(b){if(wl)wl(b)}function _f(){Pr.stop()}function xf(){Pr.start()}let Pr=new Yv;if(Pr.setAnimationLoop(Cb),typeof self<"u")Pr.setContext(self);this.setAnimationLoop=function(b){wl=b,Se.setAnimationLoop(b),b===null?Pr.stop():Pr.start()},Se.addEventListener("sessionstart",_f),Se.addEventListener("sessionend",xf),this.render=function(b,U){if(U!==void 0&&U.isCamera!==!0){$e("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(H===!0)return;if(C!==null)C.renderStart(b,U);let Q=Se.enabled===!0&&Se.isPresenting===!0,X=x!==null&&(k===null||Q)&&x.begin(w,k);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(U.parent===null&&U.matrixWorldAutoUpdate===!0)U.updateMatrixWorld();if(Se.enabled===!0&&Se.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(Se.cameraAutoUpdate===!0)Se.updateCamera(U);U=Se.getCamera()}if(b.isScene===!0)b.onBeforeRender(w,b,U,k);if(S=ye.get(b,R.length),S.init(U),S.state.textureUnits=J.getTextureUnits(),R.push(S),nt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ce.setFromProjectionMatrix(nt,ld,U.reversedDepth),rt=this.localClippingEnabled,Ve=pe.init(this.clippingPlanes,rt),v=Oe.get(b,E.length),v.init(),E.push(v),Se.enabled===!0&&Se.isPresenting===!0){let Re=w.xr.getDepthSensingMesh();if(Re!==null)Ml(Re,U,-1/0,w.sortObjects)}if(Ml(b,U,0,w.sortObjects),v.finish(),C!==null)C.updateLights(S.state.lightsArray);if(w.sortObjects===!0)v.sort(q,se);if(Ut=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Ut)Ge.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ve===!0)pe.beginShadows();let j=S.state.shadowsArray;if(ze.render(j,b,U),Ve===!0)pe.endShadows();if((X&&x.hasRenderPass())===!1){let Re=v.opaque,we=v.transmissive;if(S.setupLights(),U.isArrayCamera){let Ie=U.cameras;if(we.length>0)for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];yf(Re,we,b,et)}if(Ut)Ge.render(b);for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];vf(v,b,et,et.viewport)}}else{if(we.length>0)yf(Re,we,b,U);if(Ut)Ge.render(b);vf(v,b,U)}}if(k!==null&&G===0)J.updateMultisampleRenderTarget(k),J.updateRenderTargetMipmap(k);if(X)x.end(w);if(b.isScene===!0)b.onAfterRender(w,b,U);if(xe.resetDefaultState(),W=-1,B=null,R.pop(),R.length>0){if(S=R[R.length-1],J.setTextureUnits(S.state.textureUnits),Ve===!0)pe.setGlobalState(w.clippingPlanes,S.state.camera)}else S=null;if(E.pop(),E.length>0)v=E[E.length-1];else v=null;if(C!==null)C.renderEnd()};function Ml(b,U,Q,X){if(b.visible===!1)return;if(b.layers.test(U.layers)){if(b.isGroup)Q=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(U)}else if(b.isLightProbeGrid)S.pushLightProbeGrid(b);else if(b.isLight){if(S.pushLight(b),b.castShadow)S.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ce)){if(X)it.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Re=te.update(b),we=b.material;if(we.visible)v.push(b,Re,we,Q,it.z,null,U)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ce)){let Re=te.update(b),we=b.material;if(X){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();it.copy(b.boundingSphere.center)}else{if(Re.boundingSphere===null)Re.computeBoundingSphere();it.copy(Re.boundingSphere.center)}it.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(we)){let Ie=Re.groups;for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne],Pe=we[et.materialIndex];if(Pe&&Pe.visible)v.push(b,Re,Pe,Q,it.z,et,U)}}else if(we.visible)v.push(b,Re,we,Q,it.z,null,U)}}}let Me=b.children;for(let Re=0,we=Me.length;Re<we;Re++)Ml(Me[Re],U,Q,X)}function vf(b,U,Q,X){let{opaque:j,transmissive:Me,transparent:Re}=b;if(S.setupLightsView(Q),Ve===!0)pe.setGlobalState(w.clippingPlanes,Q);if(X)A.viewport(Y.copy(X));if(j.length>0)wa(j,U,Q);if(Me.length>0)wa(Me,U,Q);if(Re.length>0)wa(Re,U,Q);A.buffers.depth.setTest(!0),A.buffers.depth.setMask(!0),A.buffers.color.setMask(!0),A.setPolygonOffset(!1)}function yf(b,U,Q,X){if((Q.isScene===!0?Q.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[X.id]===void 0){let Pe=ut.has("EXT_color_buffer_half_float")||ut.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[X.id]=new Cn(1,1,{generateMipmaps:!0,type:Pe?bi:ni,minFilter:yi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ke.workingColorSpace})}let Me=S.state.transmissionRenderTarget[X.id],Re=X.viewport||Y;Me.setSize(Re.z*w.transmissionResolutionScale,Re.w*w.transmissionResolutionScale);let we=w.getRenderTarget(),Ie=w.getActiveCubeFace(),Ne=w.getActiveMipmapLevel();if(w.setRenderTarget(Me),w.getClearColor(de),fe=w.getClearAlpha(),fe<1)w.setClearColor(16777215,0.5);if(w.clear(),Ut)Ge.render(Q);let je=w.toneMapping;w.toneMapping=ei;let et=X.viewport;if(X.viewport!==void 0)X.viewport=void 0;if(S.setupLightsView(X),Ve===!0)pe.setGlobalState(w.clippingPlanes,X);if(wa(b,Q,X),J.updateMultisampleRenderTarget(Me),J.updateRenderTargetMipmap(Me),ut.has("WEBGL_multisampled_render_to_texture")===!1){let Pe=!1;for(let dt=0,Bt=U.length;dt<Bt;dt++){let Et=U[dt],{object:xt,geometry:sn,material:Ae,group:dn}=Et;if(Ae.side===Bn&&xt.layers.test(X.layers)){let st=Ae.side;Ae.side=cn,Ae.needsUpdate=!0,bf(xt,Q,X,sn,Ae,dn),Ae.side=st,Ae.needsUpdate=!0,Pe=!0}}if(Pe===!0)J.updateMultisampleRenderTarget(Me),J.updateRenderTargetMipmap(Me)}if(w.setRenderTarget(we,Ie,Ne),w.setClearColor(de,fe),et!==void 0)X.viewport=et;w.toneMapping=je}function wa(b,U,Q){let X=U.isScene===!0?U.overrideMaterial:null;for(let j=0,Me=b.length;j<Me;j++){let Re=b[j],{object:we,geometry:Ie,group:Ne}=Re,je=Re.material;if(je.allowOverride===!0&&X!==null)je=X;if(we.layers.test(Q.layers))bf(we,U,Q,Ie,je,Ne)}}function bf(b,U,Q,X,j,Me){if(C!==null&&j.isNodeMaterial)C.setObject(b,j);if(b.onBeforeRender(w,U,Q,X,j,Me),b.modelViewMatrix.multiplyMatrices(Q.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),j.onBeforeRender(w,U,Q,X,b,Me),j.transparent===!0&&j.side===Bn&&j.forceSinglePass===!1)j.side=cn,j.needsUpdate=!0,w.renderBufferDirect(Q,U,X,j,b,Me),j.side=fr,j.needsUpdate=!0,w.renderBufferDirect(Q,U,X,j,b,Me),j.side=Bn;else w.renderBufferDirect(Q,U,X,j,b,Me);b.onAfterRender(w,U,Q,X,j,Me)}function Ma(b,U,Q){if(U.isScene!==!0)U=tn;let X=O.get(b),j=S.state.lights,Me=S.state.shadowsArray,Re=j.state.version,we=re.getParameters(b,j.state,Me,U,Q,S.state.lightProbeGridArray),Ie=re.getProgramCacheKey(we),Ne=X.programs;X.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?U.environment:null,X.fog=U.fog;let je=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(X.envMap=ue.get(b.envMap||X.environment,je),X.envMapRotation=X.environment!==null&&b.envMap===null?U.environmentRotation:b.envMapRotation,Ne===void 0)b.addEventListener("dispose",oi),Ne=new Map,X.programs=Ne;let et=Ne.get(Ie);if(et!==void 0){if(X.currentProgram===et&&X.lightsStateVersion===Re)return wf(b,we),et}else{if(we.uniforms=re.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,Q,we);b.onBeforeCompile(we,w),et=re.acquireProgram(we,Ie),Ne.set(Ie,et),X.uniforms=we.uniforms}let Pe=X.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Pe.clippingPlanes=pe.uniform;if(wf(b,we),X.needsLights=Nb(b),X.lightsStateVersion=Re,X.needsLights)Pe.ambientLightColor.value=j.state.ambient,Pe.lightProbe.value=j.state.probe,Pe.sunLights.value=j.state.sun,Pe.sunLightShadows.value=j.state.sunShadow,Pe.directionalLights.value=j.state.directional,Pe.directionalLightShadows.value=j.state.directionalShadow,Pe.spotLights.value=j.state.spot,Pe.spotLightShadows.value=j.state.spotShadow,Pe.rectAreaLights.value=j.state.rectArea,Pe.ltc_1.value=j.state.rectAreaLTC1,Pe.ltc_2.value=j.state.rectAreaLTC2,Pe.pointLights.value=j.state.point,Pe.pointLightShadows.value=j.state.pointShadow,Pe.hemisphereLights.value=j.state.hemi,Pe.sunShadowMatrix.value=j.state.sunShadowMatrix,Pe.sunShadowCascade.value=j.state.sunShadowCascade,Pe.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Pe.spotLightMatrix.value=j.state.spotLightMatrix,Pe.spotLightMap.value=j.state.spotLightMap,Pe.pointShadowMatrix.value=j.state.pointShadowMatrix;return X.lightProbeGrid=S.state.lightProbeGridArray.length>0,X.currentProgram=et,X.uniformsList=null,et}function Sf(b){if(b.uniformsList===null){let U=b.currentProgram.getUniforms();b.uniformsList=la.seqWithValue(U.seq,b.uniforms)}return b.uniformsList}function wf(b,U){let Q=O.get(b);Q.outputColorSpace=U.outputColorSpace,Q.batching=U.batching,Q.batchingColor=U.batchingColor,Q.instancing=U.instancing,Q.instancingColor=U.instancingColor,Q.instancingMorph=U.instancingMorph,Q.skinning=U.skinning,Q.morphTargets=U.morphTargets,Q.morphNormals=U.morphNormals,Q.morphColors=U.morphColors,Q.morphTargetsCount=U.morphTargetsCount,Q.numClippingPlanes=U.numClippingPlanes,Q.numIntersection=U.numClipIntersection,Q.vertexAlphas=U.vertexAlphas,Q.vertexTangents=U.vertexTangents,Q.toneMapping=U.toneMapping}function Ib(b,U){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(U.matrixWorld);for(let Q=0,X=b.length;Q<X;Q++){let j=b[Q];if(j.texture!==null&&j.boundingBox.containsPoint(T))return j}return null}function Pb(b,U,Q,X,j){if(U.isScene!==!0)U=tn;J.resetTextureUnits();let Me=U.fog,Re=X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial?U.environment:null,we=k===null?w.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Ke.workingColorSpace,Ie=X.isMeshStandardMaterial||X.isMeshLambertMaterial&&!X.envMap||X.isMeshPhongMaterial&&!X.envMap,Ne=ue.get(X.envMap||Re,Ie),je=X.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,et=!!Q.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),Pe=!!Q.morphAttributes.position,dt=!!Q.morphAttributes.normal,Bt=!!Q.morphAttributes.color,Et=ei;if(X.toneMapped){if(k===null||k.isXRRenderTarget===!0)Et=w.toneMapping}let xt=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,sn=xt!==void 0?xt.length:0,Ae=O.get(X),dn=S.state.lights;if(Ve===!0){if(rt===!0||b!==B){let St=b===B&&X.id===W;pe.setState(X,b,St)}}let st=!1;if(X.version===Ae.__version){if(Ae.needsLights&&Ae.lightsStateVersion!==dn.state.version)st=!0;else if(Ae.outputColorSpace!==we)st=!0;else if(j.isBatchedMesh&&Ae.batching===!1)st=!0;else if(!j.isBatchedMesh&&Ae.batching===!0)st=!0;else if(j.isBatchedMesh&&Ae.batchingColor===!0&&j._colorsTexture===null)st=!0;else if(j.isBatchedMesh&&Ae.batchingColor===!1&&j._colorsTexture!==null)st=!0;else if(j.isInstancedMesh&&Ae.instancing===!1)st=!0;else if(!j.isInstancedMesh&&Ae.instancing===!0)st=!0;else if(j.isSkinnedMesh&&Ae.skinning===!1)st=!0;else if(!j.isSkinnedMesh&&Ae.skinning===!0)st=!0;else if(j.isInstancedMesh&&Ae.instancingColor===!0&&j.instanceColor===null)st=!0;else if(j.isInstancedMesh&&Ae.instancingColor===!1&&j.instanceColor!==null)st=!0;else if(j.isInstancedMesh&&Ae.instancingMorph===!0&&j.morphTexture===null)st=!0;else if(j.isInstancedMesh&&Ae.instancingMorph===!1&&j.morphTexture!==null)st=!0;else if(Ae.envMap!==Ne)st=!0;else if(X.fog===!0&&Ae.fog!==Me)st=!0;else if(Ae.numClippingPlanes!==void 0&&(Ae.numClippingPlanes!==pe.numPlanes||Ae.numIntersection!==pe.numIntersection))st=!0;else if(Ae.vertexAlphas!==je)st=!0;else if(Ae.vertexTangents!==et)st=!0;else if(Ae.morphTargets!==Pe)st=!0;else if(Ae.morphNormals!==dt)st=!0;else if(Ae.morphColors!==Bt)st=!0;else if(Ae.toneMapping!==Et)st=!0;else if(Ae.morphTargetsCount!==sn)st=!0;else if(!!Ae.lightProbeGrid!==S.state.lightProbeGridArray.length>0)st=!0}else st=!0,Ae.__version=X.version;let Nn=Ae.currentProgram;if(st===!0){if(Nn=Ma(X,U,j),C&&X.isNodeMaterial)C.onUpdateProgram(X,Nn,Ae)}let ai=!1,ji=!1,rs=!1,gt=Nn.getUniforms(),Ft=Ae.uniforms;if(A.useProgram(Nn.program))ai=!0,ji=!0,rs=!0;if(X.id!==W)W=X.id,ji=!0;if(Ae.needsLights){let St=Ib(S.state.lightProbeGridArray,j);if(Ae.lightProbeGrid!==St)Ae.lightProbeGrid=St,ji=!0}if(ai||B!==b){if(A.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();gt.setValue(D,"projectionMatrix",b.projectionMatrix),gt.setValue(D,"viewMatrix",b.matrixWorldInverse);let Yi=gt.map.cameraPosition;if(Yi!==void 0)Yi.setValue(D,Rt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)gt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)gt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(B!==b)B=b,ji=!0,rs=!0}if(Ae.needsLights){if(dn.state.sunShadowMap.length>0)gt.setValue(D,"sunShadowMap",dn.state.sunShadowMap,J);if(dn.state.directionalShadowMap.length>0)gt.setValue(D,"directionalShadowMap",dn.state.directionalShadowMap,J);if(dn.state.spotShadowMap.length>0)gt.setValue(D,"spotShadowMap",dn.state.spotShadowMap,J);if(dn.state.pointShadowMap.length>0)gt.setValue(D,"pointShadowMap",dn.state.pointShadowMap,J)}if(j.isSkinnedMesh){gt.setOptional(D,j,"bindMatrix"),gt.setOptional(D,j,"bindMatrixInverse");let St=j.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();gt.setValue(D,"boneTexture",St.boneTexture,J)}}if(j.isBatchedMesh){if(gt.setOptional(D,j,"batchingTexture"),gt.setValue(D,"batchingTexture",j._matricesTexture,J),gt.setOptional(D,j,"batchingIdTexture"),gt.setValue(D,"batchingIdTexture",j._indirectTexture,J),gt.setOptional(D,j,"batchingColorTexture"),j._colorsTexture!==null)gt.setValue(D,"batchingColorTexture",j._colorsTexture,J)}let qi=Q.morphAttributes;if(qi.position!==void 0||qi.normal!==void 0||qi.color!==void 0)ot.update(j,Q,Nn);if(ji||Ae.receiveShadow!==j.receiveShadow)Ae.receiveShadow=j.receiveShadow,gt.setValue(D,"receiveShadow",j.receiveShadow);if((X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial)&&X.envMap===null&&U.environment!==null)Ft.envMapIntensity.value=U.environmentIntensity;if(Ft.dfgLUT!==void 0)Ft.dfgLUT.value=cC();if(ji){if(gt.setValue(D,"toneMappingExposure",w.toneMappingExposure),Ae.needsLights)Lb(Ft,rs);if(Me&&X.fog===!0)Ee.refreshFogUniforms(Ft,Me);if(Ee.refreshMaterialUniforms(Ft,X,V,I,S.state.transmissionRenderTarget[b.id]),Ae.needsLights&&Ae.lightProbeGrid){let St=Ae.lightProbeGrid;Ft.probesSH.value=St.texture,Ft.probesMin.value.copy(St.boundingBox.min),Ft.probesMax.value.copy(St.boundingBox.max),Ft.probesResolution.value.copy(St.resolution)}la.upload(D,Sf(Ae),Ft,J)}if(X.isShaderMaterial&&X.uniformsNeedUpdate===!0)la.upload(D,Sf(Ae),Ft,J),X.uniformsNeedUpdate=!1;if(X.isSpriteMaterial)gt.setValue(D,"center",j.center);if(gt.setValue(D,"modelViewMatrix",j.modelViewMatrix),gt.setValue(D,"normalMatrix",j.normalMatrix),gt.setValue(D,"modelMatrix",j.matrixWorld),X.uniformsGroups!==void 0){let St=X.uniformsGroups;for(let Yi=0,ss=St.length;Yi<ss;Yi++){let Ef=St[Yi];Te.update(Ef,Nn),Te.bind(Ef,Nn)}}return Nn}function Lb(b,U){b.ambientLightColor.needsUpdate=U,b.lightProbe.needsUpdate=U,b.sunLights.needsUpdate=U,b.sunLightShadows.needsUpdate=U,b.directionalLights.needsUpdate=U,b.directionalLightShadows.needsUpdate=U,b.pointLights.needsUpdate=U,b.pointLightShadows.needsUpdate=U,b.spotLights.needsUpdate=U,b.spotLightShadows.needsUpdate=U,b.rectAreaLights.needsUpdate=U,b.hemisphereLights.needsUpdate=U}function Nb(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(b,U,Q){let X=O.get(b);if(X.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1)X.__useRenderToTexture=!1;O.get(b.texture).__webglTexture=U,O.get(b.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:Q,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,U){let Q=O.get(b);Q.__webglFramebuffer=U,Q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(b,U=0,Q=0){k=b,Z=U,G=Q;let X=null,j=!1,Me=!1;if(b){let we=O.get(b);if(we.__useDefaultFramebuffer!==void 0){A.bindFramebuffer(D.FRAMEBUFFER,we.__webglFramebuffer),Y.copy(b.viewport),K.copy(b.scissor),ge=b.scissorTest,A.viewport(Y),A.scissor(K),A.setScissorTest(ge),W=-1;return}else if(we.__webglFramebuffer===void 0)J.setupRenderTarget(b);else if(we.__hasExternalTextures)J.rebindTextures(b,O.get(b.texture).__webglTexture,O.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let je=b.depthTexture;if(we.__boundDepthTexture!==je){if(je!==null&&O.has(je)&&(b.width!==je.image.width||b.height!==je.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(b)}}let Ie=b.texture;if(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)Me=!0;let Ne=O.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Ne[U]))X=Ne[U][Q];else X=Ne[U];j=!0}else if(b.samples>0&&J.useMultisampledRTT(b)===!1)X=O.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Ne))X=Ne[Q];else X=Ne;Y.copy(b.viewport),K.copy(b.scissor),ge=b.scissorTest}else Y.copy(ce).multiplyScalar(V).floor(),K.copy(ae).multiplyScalar(V).floor(),ge=ke;if(Q!==0)X=N;if(A.bindFramebuffer(D.FRAMEBUFFER,X))A.drawBuffers(b,X);if(A.viewport(Y),A.scissor(K),A.setScissorTest(ge),j){let we=O.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+U,we.__webglTexture,Q)}else if(Me){let we=U;for(let Ie=0;Ie<b.textures.length;Ie++){let Ne=O.get(b.textures[Ie]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Ie,Ne.__webglTexture,Q,we)}}else if(b!==null&&Q!==0){let we=O.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,we.__webglTexture,Q)}W=-1};function Mf(b){let U=O.get(b);if(U.__readFormat!==b.format||U.__readType!==b.type)U.__readFormat=b.format,U.__readType=b.type,U.__formatReadable=Pt.textureFormatReadable(b.format),U.__typeReadable=Pt.textureTypeReadable(b.type);return U}if(this.readRenderTargetPixels=function(b,U,Q,X,j,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget)){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=O.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie){A.bindFramebuffer(D.FRAMEBUFFER,Ie);try{let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+we);let Pe=Mf(Ne);if(Pe.__formatReadable===!1){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Pe.__typeReadable===!1){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(U>=0&&U<=b.width-X&&(Q>=0&&Q<=b.height-j))D.readPixels(U,Q,X,j,ne.convert(je),ne.convert(et),Me)}finally{let Ne=k!==null?O.get(k).__webglFramebuffer:null;A.bindFramebuffer(D.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(b,U,Q,X,j,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ie=O.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie)if(U>=0&&U<=b.width-X&&(Q>=0&&Q<=b.height-j)){A.bindFramebuffer(D.FRAMEBUFFER,Ie);let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+we);let Pe=Mf(Ne);if(Pe.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Pe.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let dt=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,dt),D.bufferData(D.PIXEL_PACK_BUFFER,Me.byteLength,D.STREAM_READ),D.readPixels(U,Q,X,j,ne.convert(je),ne.convert(et),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Bt=k!==null?O.get(k).__webglFramebuffer:null;A.bindFramebuffer(D.FRAMEBUFFER,Bt);let Et=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await xv(D,Et,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,dt),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,Me),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(dt),D.deleteSync(Et),Me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,U=null,Q=0){let X=Math.pow(2,-Q),j=Math.floor(b.image.width*X),Me=Math.floor(b.image.height*X),Re=U!==null?U.x:0,we=U!==null?U.y:0;J.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,Q,0,0,Re,we,j,Me),A.unbindTexture()},this.copyTextureToTexture=function(b,U,Q=null,X=null,j=0,Me=0){let Re,we,Ie,Ne,je,et,Pe,dt,Bt,Et=b.isCompressedTexture?b.mipmaps[Me]:b.image;if(Q!==null)Re=Q.max.x-Q.min.x,we=Q.max.y-Q.min.y,Ie=Q.isBox3?Q.max.z-Q.min.z:1,Ne=Q.min.x,je=Q.min.y,et=Q.isBox3?Q.min.z:0;else{let Ft=Math.pow(2,-j);if(Re=Math.floor(Et.width*Ft),we=Math.floor(Et.height*Ft),b.isDataArrayTexture)Ie=Et.depth;else if(b.isData3DTexture)Ie=Math.floor(Et.depth*Ft);else Ie=1;Ne=0,je=0,et=0}if(X!==null)Pe=X.x,dt=X.y,Bt=X.z;else Pe=0,dt=0,Bt=0;let xt=ne.convert(U.format),sn=ne.convert(U.type),Ae;if(U.isData3DTexture)J.setTexture3D(U,0),Ae=D.TEXTURE_3D;else if(U.isDataArrayTexture||U.isCompressedArrayTexture)J.setTexture2DArray(U,0),Ae=D.TEXTURE_2D_ARRAY;else J.setTexture2D(U,0),Ae=D.TEXTURE_2D;A.activeTexture(D.TEXTURE0),A.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,U.flipY),A.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),A.pixelStorei(D.UNPACK_ALIGNMENT,U.unpackAlignment);let dn=A.getParameter(D.UNPACK_ROW_LENGTH),st=A.getParameter(D.UNPACK_IMAGE_HEIGHT),Nn=A.getParameter(D.UNPACK_SKIP_PIXELS),ai=A.getParameter(D.UNPACK_SKIP_ROWS),ji=A.getParameter(D.UNPACK_SKIP_IMAGES);A.pixelStorei(D.UNPACK_ROW_LENGTH,Et.width),A.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Et.height),A.pixelStorei(D.UNPACK_SKIP_PIXELS,Ne),A.pixelStorei(D.UNPACK_SKIP_ROWS,je),A.pixelStorei(D.UNPACK_SKIP_IMAGES,et);let rs=b.isDataArrayTexture||b.isData3DTexture,gt=U.isDataArrayTexture||U.isData3DTexture;if(b.isDepthTexture){let Ft=O.get(b),qi=O.get(U),St=O.get(Ft.__renderTarget),Yi=O.get(qi.__renderTarget);A.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,Yi.__webglFramebuffer);for(let ss=0;ss<Ie;ss++){if(rs)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,O.get(b).__webglTexture,j,et+ss),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,O.get(U).__webglTexture,Me,Bt+ss);D.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,D.DEPTH_BUFFER_BIT,D.NEAREST)}A.bindFramebuffer(D.READ_FRAMEBUFFER,null),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(j!==0||b.isRenderTargetTexture||O.has(b)){let Ft=O.get(b),qi=O.get(U);A.bindFramebuffer(D.READ_FRAMEBUFFER,ee),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,P);for(let St=0;St<Ie;St++){if(rs)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ft.__webglTexture,j,et+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ft.__webglTexture,j);if(gt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,qi.__webglTexture,Me,Bt+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,qi.__webglTexture,Me);if(j!==0)D.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,D.COLOR_BUFFER_BIT,D.NEAREST);else if(gt)D.copyTexSubImage3D(Ae,Me,Pe,dt,Bt+St,Ne,je,Re,we);else D.copyTexSubImage2D(Ae,Me,Pe,dt,Ne,je,Re,we)}A.bindFramebuffer(D.READ_FRAMEBUFFER,null),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(gt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et.data);else if(U.isCompressedArrayTexture)D.compressedTexSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,Et.data);else D.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,Me,Pe,dt,Et.width,Et.height,xt,Et.data);else D.texSubImage2D(D.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et);if(A.pixelStorei(D.UNPACK_ROW_LENGTH,dn),A.pixelStorei(D.UNPACK_IMAGE_HEIGHT,st),A.pixelStorei(D.UNPACK_SKIP_PIXELS,Nn),A.pixelStorei(D.UNPACK_SKIP_ROWS,ai),A.pixelStorei(D.UNPACK_SKIP_IMAGES,ji),Me===0&&U.generateMipmaps)D.generateMipmap(Ae);A.unbindTexture()},this.initRenderTarget=function(b){if(O.get(b).__webglFramebuffer===void 0)J.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)J.setTextureCube(b,0);else if(b.isData3DTexture)J.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)J.setTexture2DArray(b,0);else J.setTexture2D(b,0);A.unbindTexture()},this.resetState=function(){Z=0,G=0,k=null,A.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ld}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}}function Hd(e,t){if(t===sd)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Us||t===$o){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Us)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function hy(e){let t=new Map,n=new Map,i=e.clone();return dy(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function dy(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)dy(e.children[i],t.children[i],n)}class qd extends Zi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new yy(t)}),this.register(function(t){return new by(t)}),this.register(function(t){return new Iy(t)}),this.register(function(t){return new Py(t)}),this.register(function(t){return new Ly(t)}),this.register(function(t){return new wy(t)}),this.register(function(t){return new My(t)}),this.register(function(t){return new Ey(t)}),this.register(function(t){return new Ty(t)}),this.register(function(t){return new vy(t)}),this.register(function(t){return new Ay(t)}),this.register(function(t){return new Sy(t)}),this.register(function(t){return new Cy(t)}),this.register(function(t){return new Ry(t)}),this.register(function(t){return new _y(t)}),this.register(function(t){return new Zd(t,Qe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Zd(t,Qe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ny(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=wr.extractUrlBase(e);s=wr.resolveURL(c,this.path)}else s=wr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new ia(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Dy){try{s[Qe.KHR_BINARY_GLTF]=new Oy(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Qe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new By(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(u){case Qe.KHR_MATERIALS_UNLIT:s[u]=new xy;break;case Qe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Uy(r,this.dracoLoader);break;case Qe.KHR_TEXTURE_TRANSFORM:s[u]=new Fy;break;case Qe.KHR_MESH_QUANTIZATION:s[u]=new zy;break;default:if(h.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function lC(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function kt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Qe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class _y{constructor(e){this.parser=e,this.name=Qe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new He(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Rn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Vs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Hs(l),c.distance=u;break;case"spot":c=new ll(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),Ti(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class xy{constructor(){this.name=Qe.KHR_MATERIALS_UNLIT}getMaterialType(){return wi}extendParams(e,t,n){let i=[];e.color=new He(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Rn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,mr))}return Promise.all(i)}}class vy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class yy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Be(r,r)}}return Promise.all(i)}}class by{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Sy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class wy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SHEEN}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new He(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Rn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,mr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class My{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class Ey{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_VOLUME}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new He().setRGB(r[0],r[1],r[2],Rn),Promise.all(i)}}class Ty{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IOR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class Ay{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new He().setRGB(r[0],r[1],r[2],Rn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,mr));return Promise.all(i)}}class Ry{constructor(e){this.parser=e,this.name=Qe.EXT_MATERIALS_BUMP}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Cy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Iy{constructor(e){this.parser=e,this.name=Qe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Py{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Ly{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Zd{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,h=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,h,i.mode,i.filter).then(function(d){return d.buffer});else return s.ready.then(function(){let d=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(d),l,u,h,i.mode,i.filter),d})})}else return null}}class Ny{constructor(e){this.name=Qe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Hn.TRIANGLES&&c.mode!==Hn.TRIANGLE_STRIP&&c.mode!==Hn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],h=c[0].count,d=[];for(let f of u){let m=new Xe,_=new F,p=new Yt,g=new F(1,1,1),M=new ks(f.geometry,f.material,h);for(let v=0;v<h;v++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)g.fromBufferAttribute(a.SCALE,v);M.setMatrixAt(v,m.compose(_,p,g))}let T=null;for(let v in a)if(v==="_COLOR_0"){let S=a[v];M.instanceColor=new ur(S.array,S.itemSize,S.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(T===null){let E=M.geometry;T=new ln,T.name=E.name;for(let R in E.attributes)T.setAttribute(R,E.attributes[R]);for(let R in E.morphAttributes)T.morphAttributes[R]=E.morphAttributes[R];if(E.index!==null)T.setIndex(E.index);T.morphTargetsRelative=E.morphTargetsRelative;for(let R of E.groups)T.addGroup(R.start,R.count,R.materialIndex);if(E.boundingBox!==null)T.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)T.boundingSphere=E.boundingSphere.clone();T.drawRange.start=E.drawRange.start,T.drawRange.count=E.drawRange.count,T.userData=Object.assign({},E.userData),M.geometry=T}let S=a[v];T.setAttribute(v,new ur(S.array,S.itemSize,S.normalized))}_t.prototype.copy.call(M,f),this.parser.assignFinalMaterial(M),d.push(M)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var Dy="glTF",ha=12,fy={JSON:1313821514,BIN:5130562};class Oy{constructor(e){this.name=Qe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,ha),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Dy)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-ha,r=new DataView(e,ha),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===fy.JSON){let c=new Uint8Array(e,ha+s,o);this.content=n.decode(c)}else if(a===fy.BIN){let c=ha+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Uy{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Qe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Xd[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Xd[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=Xs[h.componentType];c[u]=d.name,a[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,h){i.decodeDracoFile(l,function(d){for(let f in d.attributes){let m=d.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(d)},o,c,Rn,h)})})}}class Fy{constructor(){this.name=Qe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class zy{constructor(){this.name=Qe.KHR_MESH_QUANTIZATION}}class Yd extends Wi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,h=u*u,d=h*u,f=e*c,m=f-c,_=-2*d+3*h,p=d-h,g=1-_,M=p-h+u;for(let T=0;T!==o;T++){let v=s[m+T+o],S=s[m+T+a]*l,E=s[f+T+o],R=s[f+T]*l;r[T]=g*v+M*S+_*E+p*R}return r}}var uC=new Yt;class ky extends Yd{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return uC.fromArray(r).normalize().toArray(r),r}}var Hn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Xs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},py={9728:ti,9729:Jt,9984:zc,9985:Ds,9986:Wr,9987:yi},my={33071:Ns,33648:Fc,10497:Ls},Vd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Xd={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Mr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},hC={CUBICSPLINE:void 0,LINEAR:Wc,STEP:rd},$d={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function dC(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:fr});return e.DefaultMaterial}function ts(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function Ti(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function fC(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0)i=!0;if(h.NORMAL!==void 0)r=!0;if(h.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(i){let d=h.POSITION!==void 0?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=h;if(s)e.morphAttributes.color=d;return e.morphTargetsRelative=!0,e})}function pC(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function mC(e){let t,n=e.extensions&&e.extensions[Qe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Wd(n.attributes);else t=e.indices+":"+Wd(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Wd(e.targets[i]);return t}function Wd(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function jd(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function gC(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var _C=new Xe;class By{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new lC,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new ol(this.options.manager);else this.textureLoader=new ul(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ia(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return ts(r,o,i),Ti(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Qe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(wr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Vd[i.type],o=Xs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Kt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Vd[i.type],c=Xs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,h=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(d&&d!==u){let p=Math.floor(h/d),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,M=t.cache.get(g);if(!M)m=new c(o,p*d,i.count*d/l),M=new jo(m,d/l),t.cache.add(g,M);_=new zs(M,a,h%d/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,h,i.count*a);_=new Kt(m,a,f)}if(i.sparse!==void 0){let p=Vd.SCALAR,g=Xs[i.sparse.indices.componentType],M=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,v=new g(s[1],M,i.sparse.count*p),S=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new Kt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let E=0,R=v.length;E<R;E++){let x=v[E];if(_.setX(x,S[E*a]),a>=2)_.setY(x,S[E*a+1]);if(a>=3)_.setZ(x,S[E*a+2]);if(a>=4)_.setW(x,S[E*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let h=(r.samplers||{})[s.sampler]||{};return l.magFilter=py[h.magFilter]||Jt,l.minFilter=py[h.minFilter]||yi,l.wrapS=my[h.wrapS]||Ls,l.wrapT=my[h.wrapT]||Ls,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==ti&&l.minFilter!==Jt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let h=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(h),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(h,d){let f=h;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Ot(m);_.needsUpdate=!0,h(_)};t.load(wr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return Ti(u,s),u.userData.mimeType=s.mimeType||gC(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Qe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Qe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Qe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ea,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Qo,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return $i}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Qe.KHR_MATERIALS_UNLIT]){let u=i[Qe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new He(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],Rn),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,mr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Bn;let l=r.alphaMode||$d.OPAQUE;if(l===$d.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===$d.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Be(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==wi){let u=r.emissiveFactor;o.emissive=new He().setRGB(u[0],u[1],u[2],Rn)}if(r.emissiveTexture!==void 0&&s!==wi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,mr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(Ti(u,r),t.associations.set(u,{materials:e}),r.extensions)ts(i,u,r);return u})}createUniqueName(e){let t=ct.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return gy(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=mC(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[Qe.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=gy(new ln,c,t);if(c.mode===Hn.TRIANGLE_STRIP)h=h.then((d)=>Hd(d,$o));else if(c.mode===Hn.TRIANGLE_FAN)h=h.then((d)=>Hd(d,Us));i[l]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?dC(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let d=0,f=l.length;d<f;d++){let m=l[d],_=s[d],p,g=c[d];if(_.mode===Hn.TRIANGLES||_.mode===Hn.TRIANGLE_STRIP||_.mode===Hn.TRIANGLE_FAN||_.mode===void 0){let M=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(M&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=M&&T?new Jc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Hn.LINES)p=new Qc(m,g);else if(_.mode===Hn.LINE_STRIP)p=new _r(m,g);else if(_.mode===Hn.LINE_LOOP)p=new el(m,g);else if(_.mode===Hn.POINTS)p=new Bs(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)pC(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),Ti(p,r),_.extensions)ts(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let d=0,f=u.length;d<f;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1){if(r.extensions)ts(i,u[0],r);return u[0]}let h=new gi;if(r.extensions)ts(i,h,r);t.associations.set(h,{meshes:e});for(let d=0,f=u.length;d<f;d++)h.add(u[d]);return h})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ht(Wo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Qr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return Ti(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let h=new Xe;if(r!==null)h.fromArray(r.array,c*16);a.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ko(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,h=i.channels.length;u<h;u++){let d=i.channels[u],f=i.samplers[d.sampler],m=d.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let M=0,T=h.length;M<T;M++){let v=h[M],S=d[M],E=f[M],R=m[M],x=_[M];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let w=n._createAnimationTracks(v,S,E,R,x);if(w)for(let H=0;H<w.length;H++)p.push(w[H])}let g=new Rs(r,void 0,p);return Ti(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],h=c[2];if(h!==null)l.traverse(function(d){if(!d.isSkinnedMesh)return;d.bind(h,_C)});for(let d=0,f=u.length;d<f;d++)l.add(u[d]);if(l.userData.pivot!==void 0&&u.length>0){let d=l.userData.pivot,f=u[0];l.pivot=new F().fromArray(d),l.position.x-=d[0],l.position.y-=d[1],l.position.z-=d[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new qo;else if(c.length>1)l=new gi;else if(c.length===1)l=c[0];else l=new _t;if(l!==c[0])for(let u=0,h=c.length;u<h;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(Ti(l,r),r.extensions)ts(n,l,r);if(r.matrix!==void 0){let u=new Xe;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new gi;if(n.name)r.name=i.createUniqueName(n.name);if(Ti(r,n),n.extensions)ts(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let h=a[l];if(h.parent!==null)r.add(hy(h));else r.add(h)}let c=(l)=>{let u=new Map;for(let[h,d]of i.associations)if(h instanceof yn||h instanceof Ot)u.set(h,d);return l.traverse((h)=>{let d=i.associations.get(h);if(d!=null)u.set(h,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(d){if(d.morphTargetInfluences)a.push(d.name?d.name:d.uuid)}if(Mr[r.path]===Mr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Mr[r.path]){case Mr.weights:l=yr;break;case Mr.rotation:l=br;break;case Mr.translation:case Mr.scale:l=Jr;break;default:switch(n.itemSize){case 1:l=yr;break;case 2:case 3:default:l=Jr;break}break}let u=i.interpolation!==void 0?hC[i.interpolation]:Wc,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+Mr[r.path],t.array,h,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=jd(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof br?ky:Yd)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function xC(e,t,n){let i=t.attributes,r=new Vt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new F(c[0],c[1],c[2]),new F(l[0],l[1],l[2])),a.normalized){let u=jd(Xs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new F,c=new F;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=n.json.accessors[h.POSITION],{min:f,max:m}=d;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){let _=jd(Xs[d.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new In;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function gy(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Xd[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(Ke.workingColorSpace!==Rn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ke.workingColorSpace}" not supported.`);return Ti(e,t),xC(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?fC(e,t.targets,n):e})}var Gy={type:"change"},Jd={type:"start"},Vy={type:"end"},_l=new gr,Hy=new zn,vC=Math.cos(70*Wo.DEG2RAD),Zt=new F,bn=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Kd=0.000001;class Qd extends dl{constructor(e,t=null){super(e,t);if(this.state=mt.NONE,this.target=new F,this.cursor=new F,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:hr.ROTATE,MIDDLE:hr.DOLLY,RIGHT:hr.PAN},this.touches={ONE:dr.ROTATE,TWO:dr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new F,this._lastQuaternion=new Yt,this._lastTargetPosition=new F,this._quat=new Yt().setFromUnitVectors(e.up,new F(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new sa,this._sphericalDelta=new sa,this._scale=1,this._panOffset=new F,this._rotateStart=new Be,this._rotateEnd=new Be,this._rotateDelta=new Be,this._panStart=new Be,this._panEnd=new Be,this._panDelta=new Be,this._dollyStart=new Be,this._dollyEnd=new Be,this._dollyDelta=new Be,this._dollyDirection=new F,this._mouse=new Be,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=bC.bind(this),this._onPointerDown=yC.bind(this),this._onPointerUp=SC.bind(this),this._onContextMenu=CC.bind(this),this._onMouseWheel=EC.bind(this),this._onKeyDown=TC.bind(this),this._onTouchStart=AC.bind(this),this._onTouchMove=RC.bind(this),this._onMouseDown=wC.bind(this),this._onMouseMove=MC.bind(this),this._interceptControlDown=IC.bind(this),this._interceptControlUp=PC.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=mt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Gy),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Zt.copy(t).sub(this.target),Zt.applyQuaternion(this._quat),this._spherical.setFromVector3(Zt),this.autoRotate&&this.state===mt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=bn;else if(n>Math.PI)n-=bn;if(i<-Math.PI)i+=bn;else if(i>Math.PI)i-=bn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Zt.setFromSpherical(this._spherical),Zt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Zt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Zt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new F(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new F(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(_l.origin.copy(this.object.position),_l.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_l.direction))<vC)this.object.lookAt(this.target);else Hy.setFromNormalAndCoplanarPoint(this.object.up,this.target),_l.intersectPlane(Hy,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Kd||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Kd||this._lastTargetPosition.distanceToSquared(this.target)>Kd)return this.dispatchEvent(Gy),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return bn/60*this.autoRotateSpeed*e;else return bn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Zt.setFromMatrixColumn(t,0),Zt.multiplyScalar(-e),this._panOffset.add(Zt)}_panUp(e,t){if(this.screenSpacePanning===!0)Zt.setFromMatrixColumn(t,1);else Zt.setFromMatrixColumn(t,0),Zt.crossVectors(this.object.up,Zt);Zt.multiplyScalar(e),this._panOffset.add(Zt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Zt.copy(i).sub(this.target);let r=Zt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Be,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function yC(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function bC(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function SC(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Vy),this.state=mt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function wC(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case hr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=mt.DOLLY;break;case hr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}break;case hr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent(Jd)}function MC(e){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function EC(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE)return;e.preventDefault(),this.dispatchEvent(Jd),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Vy)}function TC(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function AC(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case dr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=mt.TOUCH_ROTATE;break;case dr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case dr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=mt.TOUCH_DOLLY_PAN;break;case dr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent(Jd)}function RC(e){switch(this._trackPointer(e),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=mt.NONE}}function CC(e){if(this.enabled===!1)return;e.preventDefault()}function IC(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function PC(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class ef extends Fs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new xr;e.deleteAttribute("uv");let t=new $i({side:cn}),n=new $i,i=new Hs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ks(e,n,6),o=new _t;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,js(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,js(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,js(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,js(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let h=new Mt(e,js(20));h.position.set(3.235,11.486,-12.541),h.scale.set(2.5,2,0.1),this.add(h);let d=new Mt(e,js(100));d.position.set(0,20,0),d.scale.set(1,0.1,1),this.add(d)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function js(e){return new il({color:0,emissive:16777215,emissiveIntensity:e})}function $y(e,t,n=40,i=[e]){let r=e.getCenter(new F),s=Math.max(e.getSize(new F).length()/2,0.01),o=new F(1,0.65,1.25).normalize(),a=new F().crossVectors(new F(0,1,0),o).normalize(),c=new F().crossVectors(o,a),l=[];for(let M of i.length?i:[e])for(let T of[M.min.x,M.max.x])for(let v of[M.min.y,M.max.y])for(let S of[M.min.z,M.max.z])l.push(new F(T,v,S));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let M of l){let T=M.clone().sub(r),v=T.dot(a),S=T.dot(c);u=Math.min(u,v),h=Math.max(h,v),d=Math.min(d,S),f=Math.max(f,S)}r.addScaledVector(a,(u+h)/2),r.addScaledVector(c,(d+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let M of l){let T=M.clone().sub(r),v=T.dot(o);p=Math.max(p,v+Math.abs(T.dot(a))*1.12/_,v+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function tf(e,t){return{position:e.position.clone(),target:t.clone()}}function nf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new F).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new F))+r*20,10),e.updateProjectionMatrix()}function Wy(e,t,n){let i=e.getWorldDirection(new F);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new F(0,1,0)),s=new F;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function Zy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function Xy(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function jy(e,t,n){if(t())return e;n(e);return}function xl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function vl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Vt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Vt,i=new Vt,r=new F;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Vt().setFromObject(e,!0):n}function da(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function qy(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let h=l.parent;while(h&&!i.has(h))h=h.parent;if(h)continue;let d=[l];for(let m of u)d.push(await e.parser.getDependency("node",m));xl(e,d.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:d})}if(r.length===0)return;let s=da(e.scene)-r.reduce((c,l)=>c+rf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,h)=>u+rf(h,l),0));return{chains:r,triangles:a}}var Yy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function rf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return da(Yy(e,t))}function Ky(e,t){let n=Yy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Jy(e,t){for(let n of e.chains)Ky(n,t)}function Qy(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Ky(i,n),!0}function eb(e,t){if(!e)return;return{triangles:da(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>rf(n,r))}))}}function fa(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function sf(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function pa(e){let t=new Gd({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Go,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Fs,i=new Ht(40,1,0.01,1000),r=new Qd(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(W)=>{if(!o||!c.has(W.code))return;W.preventDefault(),s.add(W.code)},u=(W)=>s.delete(W.code),h=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",h);let d=new ua(t),f=new ef,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new Vs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new al(14806490,5065021,1.7));let p,g,M,T=[],v=!0,S=performance.now(),E=0,R=0,x=!1,w,H,C,N=(W)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(W)),C=void 0},ee=(W)=>{let B=t.getContext(),Y=B.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:W-C.started,frameMs:Zy(C.samples),...H===void 0?{}:{loadToFirstFrameMs:H},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(B.getParameter(B.VERSION)),vendor:String(B.getParameter(B.VENDOR)),renderer:String(B.getParameter(B.RENDERER)),browser:navigator.userAgent,...Y?{unmaskedVendor:String(B.getParameter(Y.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(B.getParameter(Y.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},P=(W)=>{let B=new Set,Y=new Set,K=new Set;W.traverse((ge)=>{let de=ge;if(!de.isMesh)return;B.add(de.geometry);for(let fe of Array.isArray(de.material)?de.material:[de.material]){Y.add(fe);for(let he of Object.values(fe))if(he instanceof Ot)K.add(he)}});for(let ge of[...B,...Y,...K])ge.dispose()},Z=()=>{if(!p)return;let W=vl(p),B=[];p.traverseVisible((fe)=>{if(fe instanceof Mt||fe instanceof _r||fe instanceof Bs){let he=new Vt().setFromObject(fe,!0);if(!he.isEmpty())B.push(he)}});let{center:Y,radius:K,distance:ge,position:de}=$y(W,i.aspect,i.fov,B);if(r.target.copy(Y),i.position.copy(de),i.near=Math.max(K/1000,0.0001),i.far=ge+K*100,r.minDistance=K*0.1,r.maxDistance=K*80,a=Math.max(K*0.35,0.01),o)r.minDistance=K*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:W,clientHeight:B}=e;if(!W||!B)return;t.setSize(W,B),i.aspect=W/B,i.updateProjectionMatrix()});G.observe(e);let k=(W)=>{if(x)return;let B=Math.min((W-S)/1000,0.1);if(S=W,e.clientWidth&&e.clientHeight){if(v)M?.update(B);if(o&&s.size){let Y=Wy(i,s,B*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(Y),r.target.add(Y)}if(r.update(),t.render(n,i),w!==void 0)H=performance.now()-w,w=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(W-C.previous);if(C.previous=W,W-C.started>=C.duration&&C.samples.length){let Y=ee(W);clearTimeout(C.timeout),C.resolve(Y),C=void 0}}}else s.clear(),N("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(k)};return E=requestAnimationFrame(k),{async load(W,B={}){let Y=performance.now(),K=++R;N("The artifact changed during measurement. Measure the new revision again."),zu(W);let ge=new na;ge.setURLModifier((ae)=>{if(!ae.startsWith("blob:")&&!ae.startsWith("data:"))throw Error("External model resources are not loaded");return ae});let de=await new qd(ge).parseAsync(Uint8Array.from(W).buffer,"");xl(de,[de.scene]);let fe=await qy(de),he=jy(de,()=>!x&&K===R&&B.isCurrent?.()!==!1,(ae)=>{P(ae.scene);for(let ke of fa(fe))P(ke)});if(!he)return;let I=p&&B.preserveView?tf(i,r.target):void 0;if(p){M?.stopAllAction(),M?.uncacheRoot(p),n.remove(p),P(p);for(let ae of fa(g))P(ae)}p=he.scene,g=fe,w=Y,H=void 0,n.add(p),T=he.animations,M=new hl(p),v=!0;let{clientWidth:V,clientHeight:q}=e;if(t.setSize(V,q),i.aspect=V&&q?V/q:i.aspect,Z(),I)nf(i,r.target,I,vl(p)),r.update();let se=0,ce=new Set;return p.traverseVisible((ae)=>{let ke=ae;if(!ke.isMesh)return;se++;for(let Ce of Array.isArray(ke.material)?ke.material:[ke.material])ce.add(Ce)}),B.onCommit?.(),{triangles:da(p),meshes:se,materials:ce.size,clips:T.map((ae)=>ae.name),...g?{levels:g.triangles}:{}}},level(W){if(N("The level of detail changed. Measure the displayed combination again."),g)Jy(g,W)},partLevel(W,B){if(N("The level of detail changed. Measure the displayed combination again."),g)Qy(g,W,B)},lod(){return p?eb(g,p):void 0},reset:Z,cancelMeasurement:N,measure(W=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(W)||W<1000||W>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((B,Y)=>{C={started:performance.now(),previous:0,duration:W,samples:[],resolve:B,reject:Y,timeout:setTimeout(()=>N("Measurement was interrupted or the browser stopped delivering frames."),W+2000)}})},view(){return tf(i,r.target)},setView(W){if(!p)return;nf(i,r.target,W,vl(p)),r.update()},navigation(W){if(o=W==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(W){for(let B of p?[p,...fa(g)]:[])B.traverse((Y)=>{let K=Y;if(K.isMesh){for(let ge of Array.isArray(K.material)?K.material:[K.material])if("wireframe"in ge)ge.wireframe=W}})},lighting(W){t.toneMappingExposure=W==="bright"?1.65:W==="soft"?0.85:1.15,_.intensity=W==="soft"?0.8:2.4},clip(W){if(M?.stopAllAction(),T[W])M?.clipAction(T[W]).play()},pause(W){v=!W},dispose(){if(N("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(E),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)P(p);for(let W of fa(g))P(W);m.dispose(),t.dispose(),e.replaceChildren()}}}var oe=(e)=>document.getElementById(e);function L(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function hn(e){let t=oe("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function Xt(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function qs(e,t){let n=L("div",void 0,"empty");return n.append(L("b",e),L("p",t)),n}function ri(e,t){try{localStorage.setItem(e,t)}catch{}}function Er(e){try{return localStorage.getItem(e)}catch{return null}}function Qt(e){return e?e.slice(0,15):"Unspecified"}function Ys(e,t){let n=L("details",void 0,"record-details");return n.append(L("summary",e),L("pre",JSON.stringify(t,null,2))),n}function ma(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...sf(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let o=L("p","","lod-total");o.setAttribute("role","status"),t.append(o);let a=new Map;if(r.chains.length>1){let l=L("details",void 0,"lod-parts");l.append(L("summary","Per-part levels")),l.append(L("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=L("div",void 0,"lod-part-fields"),h=new Set(r.chains.filter((d,f,m)=>m.findIndex((_)=>_.label===d.label)!==f).map((d)=>d.label));for(let[d,f]of r.chains.entries()){let m=h.has(f.label)?`${f.label} (part ${d+1})`:f.label,_=L("label",m,"inline-field"),p=L("select");p.setAttribute("aria-label",`${m} level of detail`),p.append(...sf(f.triangles).map((g,M)=>new Option(g,String(M)))),p.onchange=()=>{n.partLevel(f.id,Number(p.value)),c(),i?.()},a.set(f.id,p),_.append(p),u.append(_)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((h,d)=>l.chains.every((f)=>f.level===Math.min(d,f.triangles.length-1)));e.value=u<0?"mixed":String(u),o.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let h of l.chains){let d=a.get(h.id);if(d)d.value=String(h.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var tb=/^[a-z][a-z0-9_-]{0,79}$/u,LC=/^r_[a-z0-9_-]{1,77}$/u;function nb(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!tb.test(n)||!tb.test(i)||!LC.test(r))return;return{collection:n,assetId:i,revisionId:r}}var ib=new TextEncoder,NC=new TextDecoder,Ks=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),of=(e,t)=>Object.hasOwn(e,t);async function rb(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function DC(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}async function sb(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");oc(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";DC(r);for(let[M,T]of Object.entries(e.files))if(await rb(T)!==e.manifest.files[M].sha256)throw Error(`Asset integrity mismatch: ${M}`);let s=new DataView(i.buffer,i.byteOffset,i.byteLength),o=12;while(o<i.length){if(o+8>i.length)throw Error("Invalid GLB chunk header");let M=s.getUint32(o,!0);if(M%4||o+8+M>i.length)throw Error("Invalid GLB chunk length");o+=8+M}let a=20+s.getUint32(12,!0),c=JSON.parse(NC.decode(i.subarray(20,a)));if(!Ks(c)||!Ks(c.asset)||c.asset.version!=="2.0")throw Error("Invalid glTF asset");let l=c.asset;if(of(l,"extras")&&!Ks(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(of(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let h=[];if(c.scenes!==void 0&&!Array.isArray(c.scenes))throw Error("Invalid glTF scenes");for(let[M,T]of(c.scenes??[]).entries()){if(!Ks(T)||!Ks(T.extras)||!of(T.extras,"kilnReviewClipsV1"))continue;let v=T.extras.kilnReviewClipsV1;if(!Ks(v)||v.version!==1&&v.version!==2||!Array.isArray(v.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");h.push({index:M,kilnReviewClipsV1:v}),delete T.extras.kilnReviewClipsV1}let d={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:h},f=ib.encode(JSON.stringify(d));l.extras={...u,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",metadata:{uri:r,sha256:await rb(f)}}};let m=ib.encode(JSON.stringify(c)),_=Math.ceil(m.length/4)*4,p=new Uint8Array(20+_+i.length-a);if(p.length>Un||f.length>Un)throw Error("Runtime export exceeds 64 MiB");p.set(i.subarray(0,20));let g=new DataView(p.buffer);return g.setUint32(8,p.length,!0),g.setUint32(12,_,!0),p.fill(32,20,20+_),p.set(m,20),p.set(i.subarray(a),20+_),{profile:n,glb:p,metadata:{name:r,bytes:f}}}var si=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),af=Fe().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),cb=Fe().regex(/^sha256:[a-f0-9]{64}$/),Js=Fe().max(4000),lb=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),ob=qe({collectionId:si,assetId:si,revisionId:si}).strict(),ab=qe({style:Js.default(""),scale:Fe().max(1000).default(""),palette:wt(qe({role:Fe().min(1).max(100),color:Fe().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:wt(qe({role:Fe().min(1).max(100),description:Js.default(""),resourceId:lb.optional()}).strict()).max(128).default([]),conventions:wt(Fe().max(1000)).max(100).default([]),exceptions:wt(Fe().max(1000)).max(100).default([])}).strict(),OC=qe({resourceId:lb,revisionId:Fe().min(1).max(200),sha256:cb,role:Fe().max(100).optional()}).strict(),UC=wt(OC).max(512),Ai={name:Fe().trim().min(1).max(200),brief:Fe().max(16000).default(""),design:ab.default(()=>ab.parse({})),inventory:wt(qe({id:si,name:Fe().trim().min(1).max(200),kind:pn(["asset","environment"]).default("asset"),brief:Js.default(""),references:wt(si).max(64).default([]),asset:ob.optional()}).strict()).max(1000).default([]),deliveryProfiles:wt(qe({id:si,target:pn(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:Js.default(""),performanceIntent:Fe().max(1000).default(""),constraints:wt(Fe().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:UC.default([]),references:wt(qe({id:si,title:Fe().min(1).max(200),uri:Fe().min(1).max(2048),description:Js.default(""),sha256:cb.optional()}).strict()).max(256).default([]),reviews:wt(qe({id:si,inventoryId:si,projectRevisionId:af,asset:ob,reviewer:Fe().trim().min(1).max(200),verdict:pn(["comment","changes-requested","accepted"]),notes:Js}).strict()).max(2000).default([])};function ub(e,t){let n=(o,a)=>{if(new Set(o).size!==o.length)t.addIssue({code:nc.custom,path:[a],message:"Duplicate identity"})};n(e.inventory.map((o)=>o.id),"inventory"),n(e.references.map((o)=>o.id),"references"),n(e.deliveryProfiles.map((o)=>o.id),"deliveryProfiles"),n(e.materialDependencies.map((o)=>o.resourceId),"materialDependencies"),n(e.reviews.map((o)=>o.id),"reviews"),n(e.design.palette.map((o)=>o.role),"design.palette"),n(e.design.materialRoles.map((o)=>o.role),"design.materialRoles");let i=new Set(e.references.map((o)=>o.id)),r=new Set(e.inventory.map((o)=>o.id)),s=new Set(e.materialDependencies.map((o)=>o.resourceId));for(let o of e.inventory)if(n(o.references,`inventory.${o.id}.references`),o.references.some((a)=>!i.has(a)))t.addIssue({code:nc.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((o)=>!r.has(o.inventoryId)))t.addIssue({code:nc.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((o)=>o.resourceId&&!s.has(o.resourceId)))t.addIssue({code:nc.custom,path:["design"],message:"Material role requires a locked resource"})}var hb=qe({projectId:si.optional(),...Ai}).strict().superRefine(ub),OO=qe({name:Ai.name.optional(),brief:Ai.brief.removeDefault().optional(),design:Ai.design.removeDefault().optional(),inventory:Ai.inventory.removeDefault().optional(),deliveryProfiles:Ai.deliveryProfiles.removeDefault().optional(),materialDependencies:Ai.materialDependencies.removeDefault().optional(),references:Ai.references.removeDefault().optional(),reviews:Ai.reviews.removeDefault().optional()}).strict(),UO=qe({version:jt("kiln.project.v1"),projectId:si,revisionId:af,parentRevision:af.optional(),createdAt:Fe().datetime(),...Ai}).strict().superRefine(ub);function db(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function fb(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return hb.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function pb(e){let t=[],n=Er("kiln.project")??"",i,r=()=>{let c=oe("project-list");c.replaceChildren();for(let T of t){let v=L("button",void 0,T.projectId===n?"active":"");if(v.append(L("strong",T.name),L("small",`${T.inventory.length} inventory items · ${T.materialDependencies.length} resources`)),T.projectId===n)v.setAttribute("aria-current","true");v.onclick=()=>{n=T.projectId,ri("kiln.project",n),r()},c.append(v)}let l=t.find((T)=>T.projectId===n),u=oe("project-detail");if(u.replaceChildren(),!l){u.append(qs("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let h=L("div",void 0,"project-summary"),d=L("div");d.append(L("h2",l.name),L("p",l.brief||"Add a brief to describe what this project should deliver."));let f=L("button","Edit project","secondary");f.onclick=()=>o(l),h.append(d,f),u.append(h);let m=L("p",`${l.projectId} · ${Qt(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(m);let _=L("div",void 0,"project-metrics");for(let[T,v]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let S=L("div");S.append(L("strong",String(T)),L("span",String(v))),_.append(S)}u.append(_);let p=L("div",void 0,"profile-grid");for(let[T,v]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let S=L("div");S.append(L("span",T,"label"),L("p",v)),p.append(S)}u.append(p);let g=L("div",void 0,"palette");for(let T of l.design.palette){let v=L("div",void 0,"swatch"),S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("viewBox","0 0 24 24"),S.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",T.color),S.append(E);let R=L("span",T.role);R.append(L("small",T.color)),v.append(S,R),g.append(v)}if(g.childElementCount)u.append(g);for(let[T,v]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!v.length)continue;u.append(L("h3",T));let S=L("ul",void 0,"subtle");for(let E of v)S.append(L("li",E));u.append(S)}if(u.append(L("h3","Inventory")),!l.inventory.length)u.append(L("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let T=L("div",void 0,"table-wrap"),v=L("table"),S=L("thead"),E=L("tr");for(let x of["Item","Kind","Saved revision","Review"])E.append(L("th",x));S.append(E),v.append(S);let R=L("tbody");for(let x of l.inventory){let w=L("tr"),H=L("td",x.name);H.append(L("small",x.brief));let C=L("td"),N=L("td");if(x.asset){let ee=L("button",Qt(x.asset.revisionId),"secondary");ee.onclick=()=>e.openAsset(x.asset),C.append(ee);let P=[...l.reviews].reverse().find((G)=>G.inventoryId===x.id&&G.asset.revisionId===x.asset.revisionId&&G.asset.assetId===x.asset.assetId&&G.asset.collectionId===x.asset.collectionId);N.append(L("small",P?`${P.verdict} · ${P.reviewer}`:"Unreviewed"));let Z=L("button","Record review","secondary");Z.onclick=()=>a(l,x),N.append(Z)}else C.textContent="Not linked",N.textContent="No saved revision";w.append(H,L("td",x.kind),C,N),R.append(w)}v.append(R),T.append(v),u.append(T)}if(l.design.materialRoles.length){u.append(L("h3","Material roles"));for(let T of l.design.materialRoles)u.append(L("p",`${T.role}: ${T.description||"No description"}${T.resourceId?` · ${T.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(L("h3","Delivery intent"));for(let T of l.deliveryProfiles){if(u.append(L("p",`${T.target} · ${T.description||T.id}`,"subtle")),T.performanceIntent)u.append(L("p",T.performanceIntent,"subtle"));for(let v of T.constraints)u.append(L("p",v,"subtle"))}u.append(L("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(L("h3","Reference records"));for(let T of l.references){let v=L("p",`${T.title}: ${T.uri}`,"subtle");if(T.description)v.append(L("small",` · ${T.description}`));u.append(v)}}u.append(L("h3","Project downloads"));let M=L("div",void 0,"downloads");for(let T of["editable","runtime"]){let v=L("a",T==="editable"?"Download editable project bundle":"Download runtime project bundle"),S=new URLSearchParams({profile:T,revision:l.revisionId});v.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${S}`,v.download=`${l.projectId}-${T}.zip`,M.append(v)}M.append(L("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(M),u.append(Ys("Exact project configuration and review records",l))},s=async()=>{let c=await Xt("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function o(c){i=c,oe("project-editor-title").textContent=c?"Edit project":"New project",oe("project-name").value=c?.name??"",oe("project-brief").value=c?.brief??"",oe("project-style").value=c?.design.style??"",oe("project-scale").value=c?.design.scale??"",oe("project-config").value=JSON.stringify(db(c??{name:""}),null,2),oe("project-save-status").textContent="",oe("project-editor").showModal(),oe("project-name").focus()}function a(c,l){if(!l.asset)return;let u=L("dialog"),h=L("form"),d=L("div",void 0,"editor-content"),f=L("h2",`Review ${l.name}`);f.id="review-dialog-title",u.setAttribute("aria-labelledby",f.id),d.append(f,L("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),L("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let m=L("input");m.required=!0,m.value=Er("kiln.reviewer")??"",m.maxLength=200;let _=L("label","Reviewer","field");_.append(m);let p=L("select");for(let[R,x]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])p.append(new Option(x,R));let g=L("label","Assessment","field");g.append(p);let M=L("textarea");M.rows=4,M.maxLength=4000;let T=L("label","Notes","field");T.append(M);let v=L("p");v.setAttribute("role","status");let S=L("button","Save review");S.type="submit";let E=L("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),d.append(_,g,T,v,S,E),h.append(d),u.append(h),document.body.append(u),u.addEventListener("close",()=>u.remove()),h.onsubmit=async(R)=>{R.preventDefault(),S.disabled=!0,v.textContent="Saving review…";try{await Xt(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:m.value.trim(),verdict:p.value,notes:M.value}]}}}),ri("kiln.reviewer",m.value.trim()),u.close(),await s()}catch(x){v.textContent=x instanceof Error?x.message:String(x)}finally{S.disabled=!1}},u.showModal(),m.focus()}return oe("new-project").onclick=()=>o(),oe("close-project-editor").onclick=()=>oe("project-editor").close(),oe("project-form").onsubmit=async(c)=>{c.preventDefault();let l=oe("save-project");l.disabled=!0,oe("project-save-status").textContent="Saving revision…";try{let u=fb(oe("project-config").value,{name:oe("project-name").value,brief:oe("project-brief").value,style:oe("project-style").value,scale:oe("project-scale").value});n=(await Xt(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,ri("kiln.project",n),oe("project-editor").close(),hn("Project revision saved."),await s()}catch(u){oe("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}function mb(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function gb(e){let t=[],n=[],i=[],r=oe("materials-project"),s=L("button","Create from preset");oe("materials-refresh").before(s);let o=L("dialog");o.setAttribute("aria-labelledby","material-preset-heading");let a=L("form"),c=L("div",void 0,"detail-top"),l=L("h2","Create a material resource");l.id="material-preset-heading";let u=L("button","Cancel","secondary");u.type="button",u.onclick=()=>o.close(),c.append(l,u);let h=L("div",void 0,"editor-content");h.append(L("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function d(C,N){let ee=L("label",C,"field");return ee.append(N),h.append(ee),N}let f=d("Preset",L("select")),m=L("p",void 0,"subtle");h.append(m);let _=d("Seed",L("input"));_.type="number",_.step="1",_.required=!0,_.min="-2147483648",_.max="2147483647",_.value="0";let p=d("Map size",L("select"));for(let C of[64,128,256,512])p.append(new Option(`${C} × ${C}`,String(C)));p.value="256";let g=d("Creator",L("input"));g.required=!0,g.maxLength=1000;let M=d("License identifier",L("input"));M.required=!0,M.placeholder="For example, CC0-1.0";let T=d("License URL",L("input"));T.type="url",T.required=!0;let v=d("Attribution text",L("textarea"));v.rows=2;let S=L("p");S.setAttribute("role","status");let E=L("button","Create resource");E.type="submit",h.append(S,E),a.append(c,h),o.append(a),document.body.append(o);let R=()=>{let C=i.find((N)=>N.id===f.value);m.textContent=C?`${C.description} Repeat scale: ${C.physicalSizeMeters.width} × ${C.physicalSizeMeters.height} m.`:""};f.onchange=R,s.onclick=async()=>{s.disabled=!0;try{i=(await Xt("/api/material-presets")).presets,f.replaceChildren(...i.map((C)=>new Option(C.name,C.id))),R(),S.textContent="",E.disabled=!i.length,o.showModal()}catch(C){hn(C)}finally{s.disabled=!1}},a.onsubmit=async(C)=>{C.preventDefault(),E.disabled=!0,S.textContent="Creating immutable material resource…";try{let N=mb({presetId:f.value,seed:_.value,size:p.value,creator:g.value,spdx:M.value,url:T.value,attribution:v.value}),ee=await Xt("/api/materials/preset",{method:"POST",body:N});await H(),o.close(),hn(`${ee.material.name} created at ${ee.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(N){S.textContent=N instanceof Error?N.message:String(N)}finally{E.disabled=!1}};let x=(C)=>`/api/materials/${encodeURIComponent(C.materialId)}/${encodeURIComponent(C.revisionId)}`;function w(){let C=n.find((G)=>G.projectId===r.value),N=oe("material-dependencies");if(N.replaceChildren(),C)if(N.append(L("h2",`${C.name}: locked resources`)),!C.materialDependencies.length)N.append(L("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let G=L("table"),k=L("thead"),W=L("tr"),B=L("tbody");for(let K of["Resource / role","Exact revision","Local availability"])W.append(L("th",K));k.append(W),G.append(k);for(let K of C.materialDependencies){let ge=t.find((he)=>he.materialId===K.resourceId&&he.revisionId===K.revisionId),de=L("tr"),fe=L("td",K.resourceId);fe.append(L("small",K.role??C.design.materialRoles.filter((he)=>he.resourceId===K.resourceId).map((he)=>he.role).join(", "))),de.append(fe,L("td",K.revisionId,"mono"),L("td",ge&&ge.revisionId===K.sha256?"Exact local record available":ge?"Dependency hash differs":"Not in local catalog")),B.append(de)}G.append(B);let Y=L("div",void 0,"table-wrap");Y.append(G),N.append(Y)}let ee=oe("material-list");ee.replaceChildren();let P=oe("material-search").value.trim().toLowerCase(),Z=t.filter((G)=>`${G.name} ${G.materialId} ${G.tags.join(" ")} ${G.sources.map((k)=>k.provider).join(" ")}`.toLowerCase().includes(P));if(oe("material-count").textContent=`${Z.length} material revision${Z.length===1?"":"s"}`,!Z.length){ee.append(qs(P?"No matching materials":"Your material catalog starts here",P?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let G of Z){let k=L("article",void 0,"material-card"),W=G.maps.find((fe)=>fe.slot==="baseColor")??G.maps[0];if(W){let fe=L("img");fe.src=`${x(G)}/${encodeURIComponent(W.file)}`,fe.alt=`${G.name}: ${W.slot} map, not a shaded material preview`,fe.loading="lazy",fe.className="material-map",k.append(fe,L("p",`${W.slot} map · unshaded`,"subtle"))}k.append(L("h3",G.name),L("p",G.tags.join(" · "),"subtle"));let B=L("dl"),Y=(fe,he)=>B.append(L("dt",fe),L("dd",he));Y("Revision",G.revisionId),Y("Physical scale",G.physicalSizeMeters?`${G.physicalSizeMeters.width} × ${G.physicalSizeMeters.height} m`:"Not specified"),Y("Tiling",G.tileable?"Declared tileable":"Not declared tileable"),Y("Maps",G.maps.map((fe)=>`${fe.slot} ${fe.width}×${fe.height} (${fe.colorSpace})`).join(" · ")),Y("Surface factors",`Roughness ×${G.parameters.roughness} · Metalness ×${G.parameters.metalness}${G.maps.some((fe)=>fe.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),k.append(B);for(let fe of G.sources){let he=L("p",`${fe.provider} · ${fe.creator} · ${fe.kind}`,"subtle"),I=L("a",fe.license.spdx);if(I.href=fe.license.url,I.target="_blank",I.rel="noreferrer",he.append(document.createTextNode(" · "),I),fe.assetUrl){let V=L("a","Source");V.href=fe.assetUrl,V.target="_blank",V.rel="noreferrer",he.append(document.createTextNode(" · "),V)}if(k.append(he),fe.license.attribution)k.append(L("p",fe.license.attribution,"subtle"))}let K=L("div",void 0,"material-map-links");for(let fe of G.maps){let he=L("a",fe.slot);he.href=`${x(G)}/${encodeURIComponent(fe.file)}`,he.target="_blank",he.rel="noopener",K.append(he)}k.append(K);let ge=C?.materialDependencies.find((fe)=>fe.resourceId===G.materialId),de=L("button",ge?.revisionId===G.revisionId?"Locked to project":ge?"Use this revision":"Add to project","secondary");if(de.disabled=!C||ge?.revisionId===G.revisionId,!C)de.title="Select a project to add a material dependency";de.onclick=async()=>{if(!C)return;de.disabled=!0;try{let fe=C.materialDependencies.filter((he)=>he.resourceId!==G.materialId);fe.push({resourceId:G.materialId,revisionId:G.revisionId,sha256:G.revisionId,...ge?.role?{role:ge.role}:{}}),await Xt(`/api/projects/${encodeURIComponent(C.projectId)}`,{method:"PATCH",body:{expectedRevision:C.revisionId,patch:{materialDependencies:fe}}}),hn(`${G.name} is locked to ${C.name} at this exact revision.`),await e()}catch(fe){hn(fe),de.disabled=!1}},k.append(de,Ys("Map recipes, transformations and provenance",G)),ee.append(k)}}let H=async()=>{t=(await Xt("/api/materials")).materials,w()};return oe("material-search").oninput=w,r.onchange=w,oe("materials-refresh").onclick=()=>void H().catch(hn),{refresh:H,projects(C){n=C;let N=r.value;r.replaceChildren(new Option("All materials",""));for(let ee of n)r.append(new Option(ee.name,ee.projectId));if(n.some((ee)=>ee.projectId===N))r.value=N;w()}}}function cf(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var _b=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function ga(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(_b),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),o=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&_b(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),a=s?.artifact?s:s?i.filter((c)=>c.artifact&&o(c)).at(-1)??(o(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:a,pinned:r(e.pinned)}}function lf(e,t){return ga({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Tr(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function xb(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Tr(e,Tr(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function yl(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(L("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(L("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let o=await Xy(()=>s.measure(3000),i),a=L("div",void 0,"evidence-card");a.append(L("h3","Exploratory browser measurement"),L("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),L("strong",`p50 ${o.frameMs.p50.toFixed(1)} ms · p95 ${o.frameMs.p95.toFixed(1)} ms`),L("p",`${o.frameMs.samples} frame intervals · ${(o.windowMs/1000).toFixed(2)} s · ${o.drawCalls} draws · ${o.triangles.toLocaleString()} rendered triangles`),L("p",`${o.geometryObjects} geometry objects · ${o.textureObjects} texture objects. These counts are not GPU memory bytes.`),L("p",`GLB parse to first frame submission: ${o.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),L("p",`${o.viewport.cssWidth}×${o.viewport.cssHeight} CSS pixels · DPR ${o.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Ys("Exact measurement receipt and limitations",o);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(o,null,2)],{type:"application/json"}));let l=L("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",a.append(c,l),t.replaceChildren(a)}catch(o){t.replaceChildren(L("p",o instanceof Error?o.message:String(o),"subtle"))}finally{e.disabled=!1}}}function uf(e,t,n,i){let r=e.inventory.find((o)=>o.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((o)=>{if(o.id!==t)return o;let{asset:a,...c}=o;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function _a(e,t,n,i){e.replaceChildren(L("h3","Project membership"));let{projects:r}=await Xt("/api/projects");if(!e.isConnected)return;let s=L("div");e.append(s);let o=L("p");o.setAttribute("role","status");let a=()=>_a(e,t,n,i);for(let _ of r)for(let p of _.inventory){if(!p.asset||p.asset.collectionId!==t.collectionId||p.asset.assetId!==t.assetId)continue;let g=L("div",void 0,"membership-row");g.append(L("span",`${_.name} / ${p.name} · ${Qt(p.asset.revisionId)}${p.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let M=L("button","Remove membership","secondary");M.onclick=async()=>{M.disabled=!0;try{await Xt(`/api/projects/${encodeURIComponent(_.projectId)}`,{method:"PATCH",body:{expectedRevision:_.revisionId,patch:uf(_,p.id,null,n)}}),await i(),await a()}catch(T){o.textContent=`${T instanceof Error?T.message:T} Reopen membership to load the current project.`,M.disabled=!1}},g.append(M),s.append(g)}if(!s.childElementCount)s.append(L("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(L("p","Create a named project in Projects to organize related assets."));return}let c=L("form"),l=L("select"),u=L("select"),h=L("label","Project","field"),d=L("label","Inventory item","field");h.append(l),d.append(u);for(let _ of r)l.append(new Option(_.name,_.projectId));let f=()=>{let _=r.find((g)=>g.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let g of _.inventory)u.append(new Option(`${g.name}${g.asset?" (replace linked revision)":""}`,g.id));let p=_.inventory.find((g)=>g.asset?.collectionId===t.collectionId&&g.asset.assetId===t.assetId);if(p)u.value=p.id};l.onchange=f,f();let m=L("button","Link this exact revision");m.type="submit",c.append(h,d,L("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),m,o),c.onsubmit=async(_)=>{_.preventDefault(),m.disabled=!0;let p=r.find((M)=>M.projectId===l.value),g=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await Xt(`/api/projects/${encodeURIComponent(p.projectId)}`,{method:"PATCH",body:{expectedRevision:p.revisionId,patch:uf(p,g,t,n)}}),await i(),await a()}catch(M){o.textContent=`${M instanceof Error?M.message:M} Reopen membership to load the current project.`,m.disabled=!1}},s.append(c)}function vb(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,o=0,a,c,l,u,h,d,f,m=0,_=0,p=!1,g=!1,M=oe("live-project"),T=oe("live-source"),v=(I)=>T.value?`${I}${I.includes("?")?"&":"?"}source=${encodeURIComponent(T.value)}`:I,S=oe("live-run"),E=oe("live-work"),R=()=>`kiln.live.selection.${T.value}.${M.value}.${E.value}.${S.value}`,x=()=>`kiln.live.pin.${T.value}`,w=()=>t.filter((I)=>(!S.value||I.sessionId===S.value)&&(!E.value||(E.value==="ungrouped"?!I.workId:I.workId===E.value))),H=(I,V)=>{let q=oe("live-connection");q.textContent=I?"Connected":"Reconnecting",q.className=`pill ${I?"connected":"warning"}`,oe("connection-status").textContent=V};function C(){let I=E.value,V=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(E.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...V.map((ce)=>new Option(ce,ce))),I==="ungrouped"||V.includes(I))E.value=I;let q=S.value,se=[...new Set(t.map((ce)=>ce.sessionId))];S.replaceChildren(new Option("All runs",""));for(let ce of se){let ae=t.find((ke)=>ke.sessionId===ce);S.append(new Option(`${ae.transport} · ${Qt(ce)}`,ce))}if(se.includes(q))S.value=q}function N(){let I=oe("live-timeline"),V=I.scrollTop,q=I.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(I.replaceChildren(),!e.operations.length){I.append(qs("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let se of[...e.operations].reverse()){let ce=L("button",void 0,`timeline-item ${se.status}${e.selected?.operationId===se.operationId?" selected":""}${se.pinned?" pinned":""}`);ce.dataset.operation=se.operationId;let ae=L("span",void 0,"timeline-meta");if(ae.append(L("span",se.transport.toUpperCase()),L("time",new Date(se.startedAt).toLocaleTimeString())),ce.append(ae,L("strong",se.tool.replace(/^kiln_/,"")),L("small",`${se.status} · ${se.artifact?"artifact available":"no artifact"}`),L("small",se.workId?`Item ${se.workId}`:`Ungrouped · run ${Qt(se.sessionId)}`)),ce.setAttribute("aria-label",`${se.tool}, ${se.status}, ${new Date(se.startedAt).toLocaleString()}`),e.selected?.operationId===se.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=lf(e,se.operationId),ri(R(),se.operationId),Y()},I.append(ce),q===se.operationId)ce.focus({preventScroll:!0})}I.scrollTop=V}function ee(I){let V=L("div",void 0,"evidence-card");V.append(L("h3","Capture fidelity"));let q=I.viewFidelity,se=q&&typeof q==="object"?q:void 0;if(V.append(L("strong",se?String(se.delivered??"Reported"):"No capture receipt yet")),V.append(L("p",se?.materialFaithful===!0?"Material-faithful capture reported.":se?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),se?.degradeReason)V.append(L("p",String(se.degradeReason)));if(se?.rendererId)V.append(L("p",`Renderer: ${String(se.rendererId)}`,"mono"));if(se?.inputGlbSha256)V.append(L("p",`Capture input: ${String(se.inputGlbSha256)}`,"mono"));if(se)V.append(L("p",se.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return V}function P(){let I=oe("live-evidence"),V=oe("live-downloads");I.replaceChildren(),V.replaceChildren();let q=e.displayed;if(!q?.artifact)return;let se=L("div",void 0,"evidence-card");if(se.append(L("h3","Selected observed artifact"),L("strong",`${(q.artifact.bytes/1024).toFixed(0)} KB GLB`),L("p",q.artifact.sha256,"mono"),L("p",`Source: ${q.programRef??"See authored source download"}`,"mono")),I.append(se,ee(q)),q.captures.length)for(let ce of q.captures){let ae=L("div",void 0,"evidence-card");ae.append(L("h3",ce.name));let ke=q.viewFidelity&&typeof q.viewFidelity==="object"?q.viewFidelity:void 0;ae.append(L("p",ke?.materialFaithful===!0?`Recorded capture · ${String(ke.delivered??"material-faithful")}`:`Recorded capture · ${String(ke?.delivered??"fidelity unreported")}. Materials are not verified.`,ke?.materialFaithful===!0?"subtle":"warning"));let Ce=L("a"),Ve=L("img");Ve.src=ce.url,Ve.alt=`Recorded ${ce.name} for ${q.tool}`,Ve.loading="lazy",Ce.href=ce.url,Ce.target="_blank",Ce.rel="noopener",Ce.append(Ve),ae.append(Ce,L("p",ce.sha256,"mono")),I.append(ae)}else{let ce=L("div",void 0,"evidence-card");ce.append(L("h3","Recorded captures"),L("p",q.status==="evaluated"||q.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),I.append(ce)}for(let[ce,ae,ke]of[[q.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(q.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let Ce=L("a",ae);Ce.href=ce,Ce.download=ke,V.append(Ce)}V.append(L("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function Z(){let I=Tr(e.displayed,l);oe("pin-build").disabled=!I,de.disabled=I?.status!=="complete"}function G(){if(h&&l)oe("live-stage-label").textContent=cf(h,Qt(l.operationId),a?.lod())}function k(){if(d&&u)oe("compare-stage-label").textContent=`Pinned · ${cf(d,Qt(u.operationId),c?.lod())}`}async function W(I){if(oe("live-panel").hidden)return;let V=++m;if(!Tr(I,l))a?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!I?.artifact){oe("live-performance").replaceChildren(),a?.dispose(),a=void 0,l=void 0,h=void 0,oe("live-level-field").hidden=!0,oe("live-lod").replaceChildren(),oe("live-lod").hidden=!0,oe("live-stage-status").textContent="No completed artifact available for this run.",oe("live-stage-label").textContent="Current",Z();return}if(l?.artifact?.sha256===I.artifact.sha256){l=I,oe("live-stage-status").textContent="",G(),Z();return}oe("live-stage-status").textContent=`Loading ${Qt(I.operationId)}…${l?` Previous artifact ${Qt(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let q=await fetch(I.artifact.url);if(!q.ok)throw Error("This retained artifact is no longer available");let se=new Uint8Array(await q.arrayBuffer());if(V!==m)return;a??=pa(oe("live-stage"));let ce=await a.load(se,{isCurrent:()=>V===m,onCommit:()=>{l=I},preserveView:l?.projectId===I.projectId&&(l?.sessionId===I.sessionId||e.following)});if(!ce||V!==m)return;oe("live-performance").replaceChildren(),l=I,h=ce,Z();let ae=oe("live-level");if(oe("live-level-field").hidden=!ce.levels,ma(ae,oe("live-lod"),a,(ke)=>{if(ke!==void 0)c?.level(ke),f?.refresh(),k();G()}),a.wire(p),a.navigation(oe("live-navigation").value),oe("live-stage-status").textContent="",G(),c)c.setView(a.view())}catch(q){if(V!==m)return;oe("live-stage-status").textContent=`${q instanceof Error?q.message:q}.${l?` Previous artifact ${Qt(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,Z()}}async function B(I){if(oe("live-panel").hidden)return;let V=++_;if(oe("compare-viewport").hidden=!I?.artifact,oe("review-viewports").classList.toggle("comparing",!!I?.artifact),!I?.artifact){c?.dispose(),c=void 0,u=void 0,d=void 0,f=void 0,oe("compare-lod").replaceChildren(),oe("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===I.artifact.sha256){u=I,k(),oe("compare-stage-status").textContent="";return}if(!u)oe("compare-stage-label").textContent="Comparison";oe("compare-stage-status").textContent=`Loading pinned ${Qt(I.operationId)}…`;try{let q=await fetch(I.artifact.url);if(!q.ok)throw Error("Pinned artifact unavailable");let se=new Uint8Array(await q.arrayBuffer());if(V!==_)return;c??=pa(oe("compare-stage"));let ce=await c.load(se,{preserveView:!0,isCurrent:()=>V===_,onCommit:()=>{u=I}});if(!ce||V!==_)return;if(u=I,d=ce,a)c.setView(a.view());let ae=Number(oe("live-level").value||0);c.level(Number.isFinite(ae)?ae:0),oe("compare-level-field").hidden=!ce.levels,f=ma(oe("compare-level"),oe("compare-lod"),c,k),k(),c.wire(p),c.navigation(oe("live-navigation").value),oe("compare-stage-status").textContent=""}catch(q){if(V===_)oe("compare-stage-status").textContent=`${q instanceof Error?q.message:String(q)}.${u?` Previous comparison ${Qt(u.operationId)} remains visible.`:""}`}}function Y(){N();let I=e.selected,V=e.displayed,q=oe("follow-latest");q.textContent=e.following?"Following latest":"Follow latest",q.setAttribute("aria-pressed",String(e.following));let se=oe("live-current-summary");if(se.replaceChildren(),I){se.append(L("h2",I.tool.replace(/^kiln_/,"")),L("p",`${I.status} · ${I.transport} · Run ${Qt(I.sessionId)} · ${new Date(I.updatedAt).toLocaleString()}`));let ke=L("div",void 0,"tags");if(I.projectId)ke.append(L("span",I.projectId,"tag"));for(let Ce of I.phases)ke.append(L("span",Ce.phase,"tag"));se.append(ke)}else se.append(L("h2","No build selected"),L("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=I&&"observationIssues"in I&&Array.isArray(I.observationIssues)?I.observationIssues.map(String):[],ae=[I?.error,...ce,I&&V&&I.operationId!==V.operationId?`Current ${I.status} operation has no retained artifact. Showing the last successful artifact ${Qt(V.operationId)} from run ${Qt(V.sessionId)}.`:"",I&&!e.operations.some((ke)=>ke.operationId===I.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);oe("live-failure").textContent=ae.join(" "),oe("live-failure").hidden=!ae.length,Z(),oe("clear-pin").hidden=!e.pinned,oe("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,oe("live-record").textContent=JSON.stringify({selected:I,displayedArtifactOperation:V?.operationId,pinnedOperation:e.pinned?.operationId},null,2),P(),W(V),B(e.pinned)}async function K(){if(r)return;r=!0;let I=i;try{let V=new URLSearchParams;if(M.value)V.set("project",M.value);if(n)V.set("cursor",n);let q=await Xt(v(`/api/live?${V}`));if(I!==i)return;if(o=0,H(!0,"Connected · checks every 2 seconds"),n=q.cursor,oe("live-history-note").textContent=`Up to ${q.retention.maxOperations} operations`,oe("live-history-issues").textContent=q.observationIssues?.join(" ")??"",oe("live-history-issues").hidden=!q.observationIssues?.length,!q.unchanged){if(t=q.operations,C(),e=ga(e,w()),!g){g=!0;let se=Er(R());if(se&&e.operations.some((ae)=>ae.operationId===se))e=lf(e,se);let ce=Er(x());e.pinned=t.find((ae)=>ae.operationId===ce&&ae.pinned)??[...t].reverse().find((ae)=>ae.pinned&&ae.artifact)}Y()}}catch(V){o++,H(!1,`Connection lost. Retrying; retained views remain available. ${V instanceof Error?V.message:V}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void K(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(o,4)))}}M.onchange=()=>{i++,n="",t=[],g=!1,S.replaceChildren(new Option("All runs","")),E.value="",e={following:!0,crossRunContinuity:!0,operations:[]},Y(),K()},T.onchange=()=>{M.value="",e.pinned=void 0,M.dispatchEvent(new Event("change"))},Xt("/api/live-sources").then(({sources:I})=>{T.replaceChildren(...I.map((V)=>new Option(V.label,V.id)))}).catch(hn),S.onchange=()=>{e=ga({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!S.value},w()),Y()},E.onchange=()=>S.dispatchEvent(new Event("change")),oe("follow-latest").onclick=()=>{e=ga({...e,following:!e.following},w()),ri(R(),e.following?"":e.selected?.operationId??""),Y()},oe("live-refresh").onclick=()=>{n="",K(),Y()},oe("pin-build").onclick=async()=>{let I=Tr(e.displayed,l);if(!I?.artifact)return;let V=oe("pin-build");V.disabled=!0;try{await Xt(v(`/api/live/${encodeURIComponent(I.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...I,pinned:!0},ri(x(),I.operationId),n="",Y(),K()}catch(q){hn(q),Z()}},oe("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await Xt(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,ri(x(),""),n="",Y(),K()}catch(I){hn(I)}},oe("live-frame").onclick=()=>{if(a?.reset(),a)c?.setView(a.view())},oe("live-wire").onclick=()=>{p=!p,a?.wire(p),c?.wire(p),oe("live-wire").setAttribute("aria-pressed",String(p))};let ge=L("button","Match comparison camera","secondary");ge.onclick=()=>{if(a)c?.setView(a.view())},oe("live-frame").parentElement?.append(ge);let de=L("button","Save exact artifact");de.disabled=!0,oe("live-frame").parentElement?.prepend(de);let fe=L("button","Measure 3 s","secondary"),he=L("div");return he.id="live-performance",oe("live-evidence").after(he),oe("live-frame").parentElement?.append(fe),yl(fe,he,()=>a,()=>Tr(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),de.onclick=()=>{let I=Tr(e.displayed,l);if(I?.status!=="complete")return;let V=L("dialog"),q=L("form"),se=L("div",void 0,"editor-content"),ce=L("h2","Save reviewed artifact");ce.id="save-review-title",V.setAttribute("aria-labelledby",ce.id),se.append(ce,L("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),L("p",`${I.operationId} · revision ${I.revision}`,"mono"),L("p",I.artifact.sha256,"mono"));let ae=L("input");ae.required=!0,ae.maxLength=200,ae.value="";let ke=L("label","Asset name","field");ke.append(ae);let Ce=L("p");Ce.setAttribute("role","status");let Ve=L("button","Save exact artifact");Ve.type="submit";let rt=L("button","Cancel","secondary");rt.type="button",rt.onclick=()=>V.close(),se.append(ke,Ce,Ve,rt),q.append(se),V.append(q),document.body.append(V),V.addEventListener("close",()=>V.remove()),q.onsubmit=async(nt)=>{nt.preventDefault(),Ve.disabled=!0,Ce.textContent="Saving retained bytes…";try{let Rt=xb(I,ae.value,l,e.displayed),it=await Xt(v(Rt.path),{method:"POST",body:Rt.body});Ce.replaceChildren(L("span",`Saved ${it.asset.assetId} / ${it.asset.revisionId}. `));let tn=L("a","Open saved revision"),Ut=new URLSearchParams({collection:it.collection,asset:it.asset.assetId,revision:it.asset.revisionId});tn.href=`/?${Ut}`,Ce.append(tn);let It=L("div");se.append(It),_a(It,{collectionId:it.collection,assetId:it.asset.assetId,revisionId:it.asset.revisionId},it.asset.name,async()=>{}).catch((D)=>{It.textContent=`Asset saved; membership unavailable: ${D instanceof Error?D.message:D}. Open the saved asset in Library to link it.`}),ae.disabled=!0,Ve.textContent="Saved",rt.textContent="Close"}catch(Rt){Ce.textContent=Rt instanceof Error?Rt.message:String(Rt),Ve.disabled=!1}},V.showModal(),ae.focus()},oe("live-navigation").onchange=(I)=>{let V=I.target.value;a?.navigation(V),c?.navigation(V),oe("live-navigation-help").textContent=V==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",K()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)K()}),K(),{activate:Y,projects(I){let V=M.value;M.replaceChildren(new Option("All work",""));for(let q of I)M.append(new Option(q.name,q.projectId));if(I.some((q)=>q.projectId===V))M.value=V}}}var hf=["projects","live","library","materials"];function yb(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";return t&&hf.some((i)=>i===t)?t:"library"}function bb(e,t=()=>{}){let n=hf;function i(c){if(!n.includes(c))return;for(let l of n)oe(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(ri("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(hn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);oe("open-files").onclick=()=>oe("open").click();let r=vb(),s=gb(()=>o.refresh()),o=pb({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(yb(location.search,Er("kiln.section"))),o.refresh().catch(hn),s.refresh().catch(hn);let a=!1;return window.setInterval(async()=>{if(document.hidden||a||oe("project-editor").open)return;a=!0;try{await o.refresh()}catch{}finally{a=!1}},5000),{library:()=>i("library"),refreshProjects:o.refresh}}var Ri=(e)=>`${e.collection}/${e.manifest.assetId}`;function Sb(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((o)=>o.asset?[`${o.asset.collectionId}/${o.asset.assetId}`]:[])));return e.filter((s)=>!r.has(Ri(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${Ri(r)}/${r.manifest.revisionId}`))}var Le=(e)=>document.getElementById(e),lt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},ba=[],ya=[],Ir=[],ns=[],bl="",Rr,Ci,en,Ar=0,wb=0,xa=!1,va=!1,Cr=new Set,mf=[],Mb=[],Xi=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,ff=(e)=>{Le("status").textContent=e},Ii=(e)=>ff(e instanceof Error?e.message:String(e)),is=(e,t,n=mf)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function pf(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function df(e,t){if(e.local){let i=e.local.files[t];if(!i)throw Error("File unavailable");return i}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${Xi(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function FC(e,t){if(e.local){if(t==="editable.zip")return is(ku([e.local]),"application/zip");return is(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return is(e.loose,"model/gltf-binary");return`/files/${Xi(e)}/${t}?download`}function Eb(e,t){try{localStorage.setItem(e,t)}catch{}}function zC(e){try{return localStorage.getItem(e)}catch{return null}}function kC(){let e=Le("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...ba,...ns.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=lt("button",t.label,bl===t.id?"active":"");n.onclick=()=>void Qs(t.id).catch(Ii),e.append(n)}}async function Qs(e,t=!0){if(t)Ab.library();let n=++wb;bl=e,Cr.clear(),kC(),ff("");let i=e==="all"?await(async()=>{let r=await pf("/api/library");if(r.errors.length)ff(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?ns:(await pf(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==wb)return;Ir=i,Eb("kiln.collection",e),Le("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":ba.find((r)=>r.id===e)?.label??e,Le("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",Sl()}function BC(){let e=new Map;for(let t of Sb(Ir,ya,Le("library-project").value)){let n=Ri(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===zC(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function Sl(){for(let i of Mb.splice(0))URL.revokeObjectURL(i);let e=Le("cards");e.replaceChildren();let t=Le("search").value.toLowerCase(),n=BC().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Le("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Le("export-selection").disabled=!Cr.size,!n.length){let i=lt("div",void 0,"empty");if(i.append(lt("b",t?"No matching assets":"Your next idea belongs here."),lt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(lt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=lt("article",void 0,"card"),o=lt("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void Sa(i).catch(Ii);let a=lt("div",void 0,"thumb");if(r.files["preview.png"]){let m=lt("img");m.loading="lazy",m.alt=r.name,m.src=i.local?is(i.local.files["preview.png"],"image/png",Mb):`/files/${Xi(i)}/preview.png`,m.onerror=()=>{m.remove(),a.textContent="◇"},a.append(m)}else a.textContent="◇";let c=lt("div",void 0,"card-content");c.append(lt("span",r.name,"card-title"));let l=Ir.filter((m)=>Ri(m)===Ri(i)),u=new Set(l.map((m)=>m.manifest.parentRevision)),h=l.filter((m)=>!u.has(m.manifest.revisionId));c.append(lt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${h.length>1?` · ${h.length} branches`:""}`,"card-meta"));let d=lt("div",void 0,"tags");for(let m of r.tags)d.append(lt("span",m,"tag"));c.append(d),c.append(lt("small",ba.find((m)=>m.id===i.collection)?.label??i.collection,"card-meta"));let f=ya.filter((m)=>m.inventory.some((_)=>_.asset&&_.asset.collectionId===i.collection&&_.asset.assetId===r.assetId));if(c.append(lt("small",f.length?f.map((m)=>m.name).join(" · "):"No project membership","card-meta")),o.append(a,c),s.append(o),!i.loose){let m=lt("input");m.type="checkbox",m.className="selection",m.checked=Cr.has(Xi(i)),m.setAttribute("aria-label",`Select ${r.name}`),m.onchange=()=>{if(m.checked)Cr.add(Xi(i));else Cr.delete(Xi(i));Le("export-selection").disabled=!Cr.size},s.append(m)}e.append(s)}}async function Sa(e){let t=++Ar;Rr=e,Ci=void 0,en?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Le("library-performance").replaceChildren(),Eb(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let l of mf.splice(0))URL.revokeObjectURL(l);let n=Le("detail");if(!n.open)n.showModal();Le("asset-name").textContent=e.manifest.name;let i=Le("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let l=lt("div");i.append(l),_a(l,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,Ab.refreshProjects).catch(Ii)}let r=Le("revisions");r.replaceChildren();for(let l of Ir.filter((u)=>Ri(u)===Ri(e))){let u=lt("option",`${new Date(l.manifest.createdAt).toLocaleString()} · ${l.manifest.description||l.manifest.revisionId.slice(0,10)}`);u.value=l.manifest.revisionId,u.selected=l.manifest.revisionId===e.manifest.revisionId,r.append(u)}r.onchange=()=>{let l=Ir.find((u)=>Ri(u)===Ri(e)&&u.manifest.revisionId===r.value);if(l)Sa(l).catch(Ii)},Le("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Le("asset-attribution");s.replaceChildren();for(let l of z0(e.manifest)){let u=lt("div");u.append(lt("span",l.label),lt("strong",l.value)),s.append(u)}s.hidden=!s.childElementCount,Le("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Le("downloads");o.replaceChildren();for(let[l,u]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let h=lt("a",u);h.href=FC(e,l),h.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${l==="asset.glb"?".glb":l==="source.kiln.js"?".kiln.js":".zip"}`,o.append(h)}if(!e.loose){let l=lt("button","Runtime GLB"),u=lt("span");u.setAttribute("role","status"),l.onclick=async()=>{l.disabled=!0,u.textContent="Preparing runtime download…";try{let h=e.local?await sb(e.local,{profile:"runtime"}):void 0,[d,f]=h?.profile==="runtime"?[h.glb,h.metadata.bytes]:await Promise.all([df(e,"runtime.glb"),df(e,"runtime.kiln-metadata.json")]);if(t!==Ar)return;let m=lt("a","Runtime GLB");m.href=is(d,"model/gltf-binary"),m.download="runtime.glb";let _=lt("a","Runtime metadata");_.href=is(f,"application/json"),_.download="runtime.kiln-metadata.json",l.replaceWith(m,_),u.textContent="Keep the companion metadata for traceability.",m.click()}catch(h){if(t!==Ar)return;u.textContent=`Runtime export unavailable: ${h instanceof Error?h.message:h}`,l.disabled=!1}},o.append(l,u),o.append(lt("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Le("refine").disabled=!e.manifest.editable,Le("asset-stats").replaceChildren(),Le("stage-status").textContent="Loading saved GLB…",xa=!1,va=!1,Le("wire").setAttribute("aria-pressed","false"),Le("play").textContent="Pause";let a=Le("animation");a.replaceChildren(new Option("Rest pose","")),Le("play").disabled=!0;let c=Le("level");c.replaceChildren(),c.hidden=!0,Le("library-lod").replaceChildren(),Le("library-lod").hidden=!0;try{en??=pa(Le("stage"));let l=await df(e,"asset.glb");if(t!==Ar)return;let u=await en.load(l,{isCurrent:()=>t===Ar,onCommit:()=>{Ci=e}});if(!u||t!==Ar)return;Ci=e,en.wire(!1),en.navigation(Le("library-navigation").value),en.lighting(Le("lighting").value),ma(c,Le("library-lod"),en);for(let[h,d]of[...u.levels?u.levels.map((f,m)=>[f.toLocaleString(),`LOD${m} triangles`]):[[u.triangles.toLocaleString(),"triangles"]],[u.meshes,u.levels?"LOD0 meshes":"meshes"],[u.materials,u.levels?"LOD0 materials":"materials"],[`${(l.length/1024).toFixed(0)} KB`,"GLB"]]){let f=lt("div");f.append(lt("strong",String(h)),lt("span",String(d))),Le("asset-stats").append(f)}for(let h=0;h<u.clips.length;h++)a.append(new Option(u.clips[h],String(h)));Le("stage-status").textContent=""}catch(l){if(t===Ar)en?.dispose(),en=void 0,Le("stage-status").textContent=`3D preview unavailable: ${l instanceof Error?l.message:l}. Downloads remain available.`}}async function Tb(e){for(let t of e){if(t.bytes.length>Un)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of F0(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((o)=>o.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!ns.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))ns.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;ns.push({collection:"opened-files",loose:t.bytes,manifest:{version:"kiln.asset.v1",assetId:n,revisionId:`r_${n}`,name:t.name.replace(/\.glb$/i,""),tags:[],createdAt:new Date().toISOString(),editable:!1,files:{}}})}}await Qs("opened-files")}Le("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Un))throw Error("File exceeds 64 MiB");await Tb(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Ii(t)}};Le("refresh").onclick=()=>void Qs(bl).catch(Ii);Le("search").oninput=Sl;Le("library-project").onchange=()=>void Qs("all").catch(Ii);Le("close-detail").onclick=()=>Le("detail").close();Le("detail").addEventListener("close",()=>{Ar++,Ci=void 0,en?.dispose(),en=void 0;for(let e of mf.splice(0))URL.revokeObjectURL(e);Sl()});Le("frame").onclick=()=>en?.reset();Le("wire").onclick=()=>{xa=!xa,en?.wire(xa),Le("wire").setAttribute("aria-pressed",String(xa))};Le("lighting").onchange=(e)=>en?.lighting(e.target.value);Le("library-navigation").onchange=(e)=>{let t=e.target.value;en?.navigation(t),Le("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Le("animation").onchange=(e)=>{let t=e.target.value;en?.clip(t===""?-1:Number(t)),Le("play").disabled=t===""};Le("play").onclick=()=>{va=!va,en?.pause(va),Le("play").textContent=va?"Play":"Pause"};Le("refine").onclick=async()=>{if(!Rr)return;let e=Rr.manifest,t=Rr.local?`Import the downloaded editable bundle using kiln import <bundle.zip>. Restore asset ${e.assetId}, revision ${e.revisionId}, using kiln_assets action=restore. Read its source with kiln_source, refine it with kiln_edit, review the result, and save a child revision with kiln_save. Requested change: `:`Use kiln_assets with action=restore, collection=${Rr.collection}, assetId=${e.assetId}, revisionId=${e.revisionId}. Read the returned programRef with kiln_source, refine it with kiln_edit, review the result, and save with kiln_save using assetId=${e.assetId}, parentRevision=${e.revisionId}, collection=${Rr.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Le("refine").textContent="Instructions copied"}catch{Le("provenance").textContent=t,Le("provenance").parentElement?.setAttribute("open","")}};Le("export-selection").onclick=()=>{try{let e=lt("a");if(bl==="opened-files")e.href=is(ku(Ir.filter((t)=>Cr.has(Xi(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Cr)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Ii(e)}};async function GC(){ba=(await pf("/api/collections")).collections;let e=nb(location.search);if(await Qs(ba.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Ir.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Sa(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await Tb([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),ns.length===1)await Sa(ns[0])}}var Ab=bb((e)=>{(async()=>{await Qs(e.collectionId);let t=Ir.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Sa(t)})().catch(Ii)},(e)=>{ya=e;let t=Le("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of ya)t.append(new Option(i.name,i.projectId));if(n==="standalone"||ya.some((i)=>i.projectId===n))t.value=n;Sl()});yl(Le("measure-library"),Le("library-performance"),()=>en,()=>Ci&&Rr&&Xi(Ci)===Xi(Rr)?{collection:Ci.collection,assetId:Ci.manifest.assetId,revisionId:Ci.manifest.revisionId,glbSha256:Ci.manifest.files["asset.glb"]?.sha256}:void 0);GC().catch(Ii);
+}`;class cy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new rl(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Gn({vertexShader:rC,fragmentShader:sC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new ra(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class ly extends ii{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,h=null,d=null,f=null,m=typeof XRWebGLBinding<"u",_=new cy,p={},g=t.getContextAttributes(),M=null,T=null,v=[],S=[],E=new ke,R=null,x=null,w=new Ht;w.viewport=new pt;let G=new Ht;G.viewport=new pt;let C=[w,G],D=new Td,ee=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(I){let V=v[I];if(V===void 0)V=new Yo,v[I]=V;return V.getTargetRaySpace()},this.getControllerGrip=function(I){let V=v[I];if(V===void 0)V=new Yo,v[I]=V;return V.getGripSpace()},this.getHand=function(I){let V=v[I];if(V===void 0)V=new Yo,v[I]=V;return V.getHandSpace()};function W(I){let V=S.indexOf(I.inputSource);if(V===-1)return;let j=v[V];if(j!==void 0)j.update(I.inputSource,I.frame,c||s),j.dispatchEvent({type:I.type,data:I.inputSource})}function B(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",B),i.removeEventListener("inputsourceschange",P);for(let I=0;I<v.length;I++){let V=S[I];if(V===null)continue;S[I]=null,v[I].disconnect(V)}ee=null,L=null,_.reset();for(let I in p)delete p[I];if(e.setRenderTarget(M),d=null,h=null,u=null,i=null,T=null,fe.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(E.width,E.height,!1),x!==null){let I=x.camera;I.fov=x.fov,I.zoom=x.zoom,I.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(I){if(r=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(I){if(o=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(I){c=I},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(I){if(i=I,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",B),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(E),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let j={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,j),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),T=new Cn(d.framebufferWidth,d.framebufferHeight,{format:Si,type:ni,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let j=null,re=null,oe=null;if(g.depth)oe=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,j=g.stencil?jr:Xr,re=g.stencil?Us:mr;let ue={colorFormat:t.RGBA8,depthFormat:oe,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(ue),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),T=new Cn(h.textureWidth,h.textureHeight,{format:Si,type:ni,depthTexture:new Kr(h.textureWidth,h.textureHeight,re,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),fe.setContext(i),fe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(I){for(let V=0;V<I.removed.length;V++){let j=I.removed[V],re=S.indexOf(j);if(re>=0)S[re]=null,v[re].disconnect(j)}for(let V=0;V<I.added.length;V++){let j=I.added[V],re=S.indexOf(j);if(re===-1){for(let ue=0;ue<v.length;ue++)if(ue>=S.length){S.push(j),re=ue;break}else if(S[ue]===null){S[ue]=j,re=ue;break}if(re===-1)break}let oe=v[re];if(oe)oe.connect(j)}}let J=new z,H=new z;function q(I,V,j){J.setFromMatrixPosition(V.matrixWorld),H.setFromMatrixPosition(j.matrixWorld);let re=J.distanceTo(H),oe=V.projectionMatrix.elements,ue=j.projectionMatrix.elements,$e=oe[14]/(oe[10]-1),Ce=oe[14]/(oe[10]+1),He=(oe[9]+1)/oe[5],rt=(oe[9]-1)/oe[5],nt=(oe[8]-1)/oe[0],Rt=(ue[8]+1)/ue[0],it=$e*nt,tn=$e*Rt,Ut=re/(-nt+Rt),It=Ut*-nt;if(V.matrixWorld.decompose(I.position,I.quaternion,I.scale),I.translateX(It),I.translateZ(Ut),I.matrixWorld.compose(I.position,I.quaternion,I.scale),I.matrixWorldInverse.copy(I.matrixWorld).invert(),oe[10]===-1)I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse);else{let O=$e+Ut,_n=Ce+Ut,ut=it-It,Pt=tn+(re-It),A=He*Ce/_n*O,y=rt*Ce/_n*O;I.projectionMatrix.makePerspective(ut,Pt,A,y,O,_n),I.projectionMatrixInverse.copy(I.projectionMatrix).invert()}}function Q(I,V){if(V===null)I.matrixWorld.copy(I.matrix);else I.matrixWorld.multiplyMatrices(V.matrixWorld,I.matrix);I.matrixWorldInverse.copy(I.matrixWorld).invert()}this.updateCamera=function(I){if(i===null)return;let{near:V,far:j}=I;if(_.texture!==null){if(_.depthNear>0)V=_.depthNear;if(_.depthFar>0)j=_.depthFar}if(D.near=G.near=w.near=V,D.far=G.far=w.far=j,ee!==D.near||L!==D.far)i.updateRenderState({depthNear:D.near,depthFar:D.far}),ee=D.near,L=D.far;D.layers.mask=I.layers.mask|6,w.layers.mask=D.layers.mask&-5,G.layers.mask=D.layers.mask&-3;let re=I.parent,oe=D.cameras;Q(D,re);for(let ue=0;ue<oe.length;ue++)Q(oe[ue],re);if(oe.length===2)q(D,w,G);else D.projectionMatrix.copy(w.projectionMatrix);if(x===null&&I.isPerspectiveCamera)x={camera:I,fov:I.fov,zoom:I.zoom};ge(I,D,re)};function ge(I,V,j){if(j===null)I.matrix.copy(V.matrixWorld);else I.matrix.copy(j.matrixWorld),I.matrix.invert(),I.matrix.multiply(V.matrixWorld);if(I.matrix.decompose(I.position,I.quaternion,I.scale),I.updateMatrixWorld(!0),I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse),I.isPerspectiveCamera)I.fov=$r*2*Math.atan(1/I.projectionMatrix.elements[5]),I.zoom=1}this.getCamera=function(){return D},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(I){if(a=I,h!==null)h.fixedFoveation=I;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=I},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(D)},this.getCameraTexture=function(I){return p[I]};let he=null;function de(I,V){if(l=V.getViewerPose(c||s),f=V,l!==null){let j=l.views;if(d!==null)e.setRenderTargetFramebuffer(T,d.framebuffer),e.setRenderTarget(T);let re=!1;if(j.length!==D.cameras.length)D.cameras.length=0,re=!0;for(let Ce=0;Ce<j.length;Ce++){let He=j[Ce],rt=null;if(d!==null)rt=d.getViewport(He);else{let Rt=u.getViewSubImage(h,He);if(rt=Rt.viewport,Ce===0)e.setRenderTargetTextures(T,Rt.colorTexture,Rt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ce];if(nt===void 0)nt=new Ht,nt.layers.enable(Ce),nt.viewport=new pt,C[Ce]=nt;if(nt.matrix.fromArray(He.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(He.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(rt.x,rt.y,rt.width,rt.height),Ce===0)D.matrix.copy(nt.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale);if(re===!0)D.cameras.push(nt)}let oe=i.enabledFeatures;if(oe&&oe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ce=u.getDepthInformation(j[0]);if(Ce&&Ce.isValid&&Ce.texture)_.init(Ce,i.renderState)}if(oe&&oe.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ce=0;Ce<j.length;Ce++){let He=j[Ce].camera;if(He){let rt=p[He];if(!rt)rt=new rl,p[He]=rt;let nt=u.getCameraImage(He);rt.sourceTexture=nt}}}}for(let j=0;j<v.length;j++){let re=S[j],oe=v[j];if(re!==null&&oe!==void 0)oe.update(re,V,c||s)}if(he)he(I,V);if(V.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:V});f=null}let fe=new Kv;fe.setAnimationLoop(de),this.setAnimationLoop=function(I){he=I},this.dispose=function(){}}}var oC=new Xe,uy=new We;uy.set(-1,0,0,0,1,0,0,0,1);function aC(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,gd(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,M,T,v){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),h(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),d(p,g),g.isMeshPhysicalMaterial)f(p,g,v)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,M,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===cn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===cn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let M=t.get(g),{envMap:T,envMapRotation:v}=M;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(oC.makeRotationFromEuler(v)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(uy);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,M,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*M,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function h(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function d(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,M){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=M.texture,p.transmissionSamplerSize.value.set(M.width,M.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let M=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(M.matrixWorld),p.nearDistance.value=M.shadow.camera.near,p.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function cC(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,S){let E=S.program;i.uniformBlockBinding(v,E)}function l(v,S){let E=r[v.id];if(E===void 0)p(v),E=u(v),r[v.id]=E,v.addEventListener("dispose",M);let R=S.program;i.updateUBOMapping(v,R);let x=t.render.frame;if(s[v.id]!==x)d(v),s[v.id]=x}function u(v){let S=h();v.__bindingPointIndex=S;let E=e.createBuffer(),{__size:R,usage:x}=v;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,S,E),E}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ve("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let S=r[v.id],{uniforms:E,__cache:R}=v;e.bindBuffer(e.UNIFORM_BUFFER,S);for(let x=0,w=E.length;x<w;x++){let G=E[x];if(Array.isArray(G))for(let C=0,D=G.length;C<D;C++)f(G[C],x,C,R);else f(G,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(v,S,E,R){if(_(v,S,E,R)===!0){let{__offset:x,value:w}=v;if(Array.isArray(w)){let G=0;for(let C=0;C<w.length;C++){let D=w[C],ee=g(D);if(m(D,v.__data,G),typeof D!=="number"&&typeof D!=="boolean"&&!D.isMatrix3&&!ArrayBuffer.isView(D))G+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else m(w,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,v.__data)}}function m(v,S,E){if(typeof v==="number"||typeof v==="boolean")S[0]=v;else if(v.isMatrix3)S[0]=v.elements[0],S[1]=v.elements[1],S[2]=v.elements[2],S[3]=0,S[4]=v.elements[3],S[5]=v.elements[4],S[6]=v.elements[5],S[7]=0,S[8]=v.elements[6],S[9]=v.elements[7],S[10]=v.elements[8],S[11]=0;else if(ArrayBuffer.isView(v))S.set(new v.constructor(v.buffer,v.byteOffset,S.length));else v.toArray(S,E)}function _(v,S,E,R){let x=v.value,w=S+"_"+E;if(R[w]===void 0){if(typeof x==="number"||typeof x==="boolean")R[w]=x;else if(ArrayBuffer.isView(x))R[w]=x.slice();else R[w]=x.clone();return!0}else{let G=R[w];if(typeof x==="number"||typeof x==="boolean"){if(G!==x)return R[w]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(G.equals(x)===!1)return G.copy(x),!0}return!1}function p(v){let S=v.uniforms,E=0,R=16;for(let w=0,G=S.length;w<G;w++){let C=Array.isArray(S[w])?S[w]:[S[w]];for(let D=0,ee=C.length;D<ee;D++){let L=C[D],W=Array.isArray(L.value)?L.value:[L.value];for(let B=0,P=W.length;B<P;B++){let J=W[B],H=g(J),q=E%R,Q=q%H.boundary,ge=q+Q;if(E+=Q,ge!==0&&R-ge<H.storage)E+=R-ge;L.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=E,E+=H.storage}}}let x=E%R;if(x>0)E+=R-x;return v.__size=E,v.__cache={},this}function g(v){let S={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")S.boundary=4,S.storage=4;else if(v.isVector2)S.boundary=8,S.storage=8;else if(v.isVector3||v.isColor)S.boundary=16,S.storage=12;else if(v.isVector4)S.boundary=16,S.storage=16;else if(v.isMatrix3)S.boundary=48,S.storage=48;else if(v.isMatrix4)S.boundary=64,S.storage=64;else if(v.isTexture)Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))S.boundary=16,S.storage=v.byteLength;else Ue("WebGLRenderer: Unsupported uniform value type.",v);return S}function M(v){let S=v.target;S.removeEventListener("dispose",M);let E=o.indexOf(S.__bindingPointIndex);o.splice(E,1),e.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function T(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var lC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Mi=null;function uC(){if(Mi===null)Mi=new Qo(lC,16,16,qr,bi),Mi.name="DFG_LUT",Mi.minFilter=Jt,Mi.magFilter=Jt,Mi.wrapS=Ds,Mi.wrapT=Ds,Mi.generateMipmaps=!1,Mi.needsUpdate=!0;return Mi}class Hd{constructor(e={}){let{canvas:t=_v(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=ni}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=d,_=new Set([Rh,Ah,Th]),p=new Set([ni,mr,Zo,Us,Mh,Eh]),g=new Uint32Array(4),M=new Int32Array(4),T=new z,v=null,S=null,E=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ei,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,G=!1,C=null,D=null,ee=null,L=null;this._outputColorSpace=gr;let W=0,B=0,P=null,J=-1,H=null,q=new pt,Q=new pt,ge=null,he=new Ge(0),de=0,{width:fe,height:I}=t,V=1,j=null,re=null,oe=new pt(0,0,fe,I),ue=new pt(0,0,fe,I),$e=!1,Ce=new ta,He=!1,rt=!1,nt=new Xe,Rt=new z,it=new pt,tn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ut=!1;function It(){return P===null?V:1}let O=n;function _n(b,F){return t.getContext(b,F)}let ut,Pt,A,y,U,Y,le,me,ve,te,se,Ee,Oe,ye,pe,ze,Be,ot,k,_e,ne,xe,Te;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${wx}`);if(t.addEventListener("webglcontextlost",Ze,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",ht,!1),O===null){if(O=_n("webgl2",b),O===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ce()}catch(b){throw t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),Ve("WebGLRenderer: "+b.message),b}function ce(){if(ut=new _1(O),ut.init(),ne=new iC(O,ut),Pt=new a1(O,ut,e,ne),A=new tC(O,ut),Pt.reversedDepthBuffer&&h)A.buffers.depth.setReversed(!0);D=O.createFramebuffer(),ee=O.createFramebuffer(),L=O.createFramebuffer(),y=new y1(O),U=new GR,Y=new nC(O,ut,A,U,Pt,ne,y),le=new g1(w),me=new SE(O),xe=new s1(O,me),ve=new x1(O,me,y,xe),te=new S1(O,ve,me,xe,y),ot=new b1(O,Pt,Y),pe=new c1(U),se=new BR(w,le,ut,Pt,xe,pe),Ee=new aC(w,U),Oe=new VR,ye=new qR(ut),Be=new r1(w,le,A,te,f,a),ze=new eC(w,te,Pt),Te=new cC(O,y,Pt,A),k=new o1(O,ut,y),_e=new v1(O,ut,y),y.programs=se.programs,w.capabilities=Pt,w.extensions=ut,w.properties=U,w.renderLists=Oe,w.shadowMap=ze,w.state=A,w.info=y}if(m!==ni)x=new M1(m,t.width,t.height,o,i,r);let Se=new ly(w,O);this.xr=Se,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){let b=ut.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ut.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(b){if(b===void 0)return;V=b,this.setSize(fe,I,!1)},this.getSize=function(b){return b.set(fe,I)},this.setSize=function(b,F,K=!0){if(Se.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}if(fe=b,I=F,t.width=Math.floor(b*V),t.height=Math.floor(F*V),K===!0)t.style.width=b+"px",t.style.height=F+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,F)},this.getDrawingBufferSize=function(b){return b.set(fe*V,I*V).floor()},this.setDrawingBufferSize=function(b,F,K){fe=b,I=F,V=K,t.width=Math.floor(b*K),t.height=Math.floor(F*K),this.setViewport(0,0,b,F)},this.setEffects=function(b){if(m===ni){Ve("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let F=0;F<b.length;F++)if(b[F].isOutputPass===!0){Ue("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(oe)},this.setViewport=function(b,F,K,Z){if(b.isVector4)oe.set(b.x,b.y,b.z,b.w);else oe.set(b,F,K,Z);A.viewport(q.copy(oe).multiplyScalar(V).round())},this.getScissor=function(b){return b.copy(ue)},this.setScissor=function(b,F,K,Z){if(b.isVector4)ue.set(b.x,b.y,b.z,b.w);else ue.set(b,F,K,Z);A.scissor(Q.copy(ue).multiplyScalar(V).round())},this.getScissorTest=function(){return $e},this.setScissorTest=function(b){A.setScissorTest($e=b)},this.setOpaqueSort=function(b){j=b},this.setTransparentSort=function(b){re=b},this.getClearColor=function(b){return b.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(b=!0,F=!0,K=!0){let Z=0;if(b){let X=!1;if(P!==null){let Me=P.texture.format;X=_.has(Me)}if(X){let Me=P.texture.type,Re=p.has(Me),we=Be.getClearColor(),Ie=Be.getClearAlpha(),{r:Ne,g:je,b:et}=we;if(Re)g[0]=Ne,g[1]=je,g[2]=et,g[3]=Ie,O.clearBufferuiv(O.COLOR,0,g);else M[0]=Ne,M[1]=je,M[2]=et,M[3]=Ie,O.clearBufferiv(O.COLOR,0,M)}else Z|=O.COLOR_BUFFER_BIT}if(F)Z|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(K)Z|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)O.clear(Z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),Be.dispose(),Oe.dispose(),ye.dispose(),U.dispose(),le.dispose(),te.dispose(),xe.dispose(),Te.dispose(),se.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",xf),Se.removeEventListener("sessionend",vf),Lr.stop()};function Ze(b){b.preventDefault(),Go("WebGLRenderer: Context Lost."),G=!0}function bt(){Go("WebGLRenderer: Context Restored."),G=!1;let b=y.autoReset,F=ze.enabled,K=ze.autoUpdate,Z=ze.needsUpdate,X=ze.type;ce(),y.autoReset=b,ze.enabled=F,ze.autoUpdate=K,ze.needsUpdate=Z,ze.type=X}function ht(b){Ve("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let F=b.target;F.removeEventListener("dispose",oi),Li(F)}function Li(b){Ib(b),U.remove(b)}function Ib(b){let F=U.get(b).programs;if(F!==void 0){if(F.forEach(function(K){se.releaseProgram(K)}),b.isShaderMaterial)se.releaseShaderCache(b)}}this.renderBufferDirect=function(b,F,K,Z,X,Me){if(F===null)F=tn;let Re=X.isMesh&&X.matrixWorld.determinantAffine()<0,we=Nb(b,F,K,Z,X);A.setMaterial(Z,Re);let Ie=K.index,Ne=1;if(Z.wireframe===!0){if(Ie=ve.getWireframeAttribute(K),Ie===void 0)return;Ne=2}let je=K.drawRange,et=K.attributes.position,Pe=je.start*Ne,dt=(je.start+je.count)*Ne;if(Me!==null)Pe=Math.max(Pe,Me.start*Ne),dt=Math.min(dt,(Me.start+Me.count)*Ne);if(Ie!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,Ie.count);else if(et!==void 0&&et!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,et.count);let Bt=dt-Pe;if(Bt<0||Bt===1/0)return;xe.setup(X,Z,we,K,Ie);let Et,xt=k;if(Ie!==null)Et=me.get(Ie),xt=_e,xt.setIndex(Et);if(X.isMesh)if(Z.wireframe===!0)A.setLineWidth(Z.wireframeLinewidth*It()),xt.setMode(O.LINES);else xt.setMode(O.TRIANGLES);else if(X.isLine){let sn=Z.linewidth;if(sn===void 0)sn=1;if(A.setLineWidth(sn*It()),X.isLineSegments)xt.setMode(O.LINES);else if(X.isLineLoop)xt.setMode(O.LINE_LOOP);else xt.setMode(O.LINE_STRIP)}else if(X.isPoints)xt.setMode(O.POINTS);else if(X.isSprite)xt.setMode(O.TRIANGLES);if(X.isBatchedMesh)if(!ut.get("WEBGL_multi_draw")){let{_multiDrawStarts:sn,_multiDrawCounts:Ae,_multiDrawCount:dn}=X,st=Ie?me.get(Ie).bytesPerElement:1,Nn=U.get(Z).currentProgram.getUniforms();for(let ai=0;ai<dn;ai++)Nn.setValue(O,"_gl_DrawID",ai),xt.render(sn[ai]/st,Ae[ai])}else xt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else if(X.isInstancedMesh)xt.renderInstances(Pe,Bt,X.count);else if(K.isInstancedBufferGeometry){let sn=K._maxInstanceCount!==void 0?K._maxInstanceCount:1/0,Ae=Math.min(K.instanceCount,sn);xt.renderInstances(Pe,Bt,Ae)}else xt.render(Pe,Bt)};function _f(b,F,K,Z){if(C!==null&&b.isNodeMaterial)C.setObject(Z,b);if(He===!0)pe.setState(b,K,!1);if(b.transparent===!0&&b.side===Bn&&b.forceSinglePass===!1)b.side=cn,b.needsUpdate=!0,Ta(b,F,Z),b.side=pr,b.needsUpdate=!0,Ta(b,F,Z),b.side=Bn;else Ta(b,F,Z)}this.compile=function(b,F,K=null){if(K===null)K=b;if(C!==null)C.renderStart(b,F,K);if(S=ye.get(K),S.init(F),R.push(S),K.traverseVisible(function(X){if(X.isLight&&X.layers.test(F.layers)){if(S.pushLight(X),X.castShadow)S.pushShadow(X)}}),b!==K)b.traverseVisible(function(X){if(X.isLight&&X.layers.test(F.layers)){if(S.pushLight(X),X.castShadow)S.pushShadow(X)}});if(S.setupLights(),C!==null)C.updateLights(S.state.lightsArray);if(rt=this.localClippingEnabled,He=pe.init(this.clippingPlanes,rt),He===!0)pe.setGlobalState(this.clippingPlanes,F);if(C!==null)ze.render(S.state.shadowsArray,K,F);let Z=new Set;if(b.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;let Me=X.material;if(Me)if(Array.isArray(Me))for(let Re=0;Re<Me.length;Re++){let we=Me[Re];_f(we,K,F,X),Z.add(we)}else _f(Me,K,F,X),Z.add(Me)}),S=R.pop(),C!==null)C.renderEnd();return Z},this.compileAsync=function(b,F,K=null){let Z=this.compile(b,F,K);return new Promise((X)=>{function Me(){if(Z.forEach(function(Re){let Ie=U.get(Re).currentProgram;if(Ie===void 0||Ie.isReady())Z.delete(Re)}),Z.size===0){X(b);return}setTimeout(Me,10)}if(ut.get("KHR_parallel_shader_compile")!==null)Me();else setTimeout(Me,10)})};let Ml=null;function Pb(b){if(Ml)Ml(b)}function xf(){Lr.stop()}function vf(){Lr.start()}let Lr=new Kv;if(Lr.setAnimationLoop(Pb),typeof self<"u")Lr.setContext(self);this.setAnimationLoop=function(b){Ml=b,Se.setAnimationLoop(b),b===null?Lr.stop():Lr.start()},Se.addEventListener("sessionstart",xf),Se.addEventListener("sessionend",vf),this.render=function(b,F){if(F!==void 0&&F.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;if(C!==null)C.renderStart(b,F);let K=Se.enabled===!0&&Se.isPresenting===!0,Z=x!==null&&(P===null||K)&&x.begin(w,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(F.parent===null&&F.matrixWorldAutoUpdate===!0)F.updateMatrixWorld();if(Se.enabled===!0&&Se.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(Se.cameraAutoUpdate===!0)Se.updateCamera(F);F=Se.getCamera()}if(b.isScene===!0)b.onBeforeRender(w,b,F,P);if(S=ye.get(b,R.length),S.init(F),S.state.textureUnits=Y.getTextureUnits(),R.push(S),nt.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Ce.setFromProjectionMatrix(nt,ud,F.reversedDepth),rt=this.localClippingEnabled,He=pe.init(this.clippingPlanes,rt),v=Oe.get(b,E.length),v.init(),E.push(v),Se.enabled===!0&&Se.isPresenting===!0){let Re=w.xr.getDepthSensingMesh();if(Re!==null)El(Re,F,-1/0,w.sortObjects)}if(El(b,F,0,w.sortObjects),v.finish(),C!==null)C.updateLights(S.state.lightsArray);if(w.sortObjects===!0)v.sort(j,re);if(Ut=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Ut)Be.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(He===!0)pe.beginShadows();let X=S.state.shadowsArray;if(ze.render(X,b,F),He===!0)pe.endShadows();if((Z&&x.hasRenderPass())===!1){let Re=v.opaque,we=v.transmissive;if(S.setupLights(),F.isArrayCamera){let Ie=F.cameras;if(we.length>0)for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];bf(Re,we,b,et)}if(Ut)Be.render(b);for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];yf(v,b,et,et.viewport)}}else{if(we.length>0)bf(Re,we,b,F);if(Ut)Be.render(b);yf(v,b,F)}}if(P!==null&&B===0)Y.updateMultisampleRenderTarget(P),Y.updateRenderTargetMipmap(P);if(Z)x.end(w);if(b.isScene===!0)b.onAfterRender(w,b,F);if(xe.resetDefaultState(),J=-1,H=null,R.pop(),R.length>0){if(S=R[R.length-1],Y.setTextureUnits(S.state.textureUnits),He===!0)pe.setGlobalState(w.clippingPlanes,S.state.camera)}else S=null;if(E.pop(),E.length>0)v=E[E.length-1];else v=null;if(C!==null)C.renderEnd()};function El(b,F,K,Z){if(b.visible===!1)return;if(b.layers.test(F.layers)){if(b.isGroup)K=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(F)}else if(b.isLightProbeGrid)S.pushLightProbeGrid(b);else if(b.isLight){if(S.pushLight(b),b.castShadow)S.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ce)){if(Z)it.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Re=te.update(b),we=b.material;if(we.visible)v.push(b,Re,we,K,it.z,null,F)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ce)){let Re=te.update(b),we=b.material;if(Z){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();it.copy(b.boundingSphere.center)}else{if(Re.boundingSphere===null)Re.computeBoundingSphere();it.copy(Re.boundingSphere.center)}it.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(we)){let Ie=Re.groups;for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne],Pe=we[et.materialIndex];if(Pe&&Pe.visible)v.push(b,Re,Pe,K,it.z,et,F)}}else if(we.visible)v.push(b,Re,we,K,it.z,null,F)}}}let Me=b.children;for(let Re=0,we=Me.length;Re<we;Re++)El(Me[Re],F,K,Z)}function yf(b,F,K,Z){let{opaque:X,transmissive:Me,transparent:Re}=b;if(S.setupLightsView(K),He===!0)pe.setGlobalState(w.clippingPlanes,K);if(Z)A.viewport(q.copy(Z));if(X.length>0)Ea(X,F,K);if(Me.length>0)Ea(Me,F,K);if(Re.length>0)Ea(Re,F,K);A.buffers.depth.setTest(!0),A.buffers.depth.setMask(!0),A.buffers.color.setMask(!0),A.setPolygonOffset(!1)}function bf(b,F,K,Z){if((K.isScene===!0?K.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Z.id]===void 0){let Pe=ut.has("EXT_color_buffer_half_float")||ut.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Z.id]=new Cn(1,1,{generateMipmaps:!0,type:Pe?bi:ni,minFilter:yi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ke.workingColorSpace})}let Me=S.state.transmissionRenderTarget[Z.id],Re=Z.viewport||q;Me.setSize(Re.z*w.transmissionResolutionScale,Re.w*w.transmissionResolutionScale);let we=w.getRenderTarget(),Ie=w.getActiveCubeFace(),Ne=w.getActiveMipmapLevel();if(w.setRenderTarget(Me),w.getClearColor(he),de=w.getClearAlpha(),de<1)w.setClearColor(16777215,0.5);if(w.clear(),Ut)Be.render(K);let je=w.toneMapping;w.toneMapping=ei;let et=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(S.setupLightsView(Z),He===!0)pe.setGlobalState(w.clippingPlanes,Z);if(Ea(b,K,Z),Y.updateMultisampleRenderTarget(Me),Y.updateRenderTargetMipmap(Me),ut.has("WEBGL_multisampled_render_to_texture")===!1){let Pe=!1;for(let dt=0,Bt=F.length;dt<Bt;dt++){let Et=F[dt],{object:xt,geometry:sn,material:Ae,group:dn}=Et;if(Ae.side===Bn&&xt.layers.test(Z.layers)){let st=Ae.side;Ae.side=cn,Ae.needsUpdate=!0,Sf(xt,K,Z,sn,Ae,dn),Ae.side=st,Ae.needsUpdate=!0,Pe=!0}}if(Pe===!0)Y.updateMultisampleRenderTarget(Me),Y.updateRenderTargetMipmap(Me)}if(w.setRenderTarget(we,Ie,Ne),w.setClearColor(he,de),et!==void 0)Z.viewport=et;w.toneMapping=je}function Ea(b,F,K){let Z=F.isScene===!0?F.overrideMaterial:null;for(let X=0,Me=b.length;X<Me;X++){let Re=b[X],{object:we,geometry:Ie,group:Ne}=Re,je=Re.material;if(je.allowOverride===!0&&Z!==null)je=Z;if(we.layers.test(K.layers))Sf(we,F,K,Ie,je,Ne)}}function Sf(b,F,K,Z,X,Me){if(C!==null&&X.isNodeMaterial)C.setObject(b,X);if(b.onBeforeRender(w,F,K,Z,X,Me),b.modelViewMatrix.multiplyMatrices(K.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),X.onBeforeRender(w,F,K,Z,b,Me),X.transparent===!0&&X.side===Bn&&X.forceSinglePass===!1)X.side=cn,X.needsUpdate=!0,w.renderBufferDirect(K,F,Z,X,b,Me),X.side=pr,X.needsUpdate=!0,w.renderBufferDirect(K,F,Z,X,b,Me),X.side=Bn;else w.renderBufferDirect(K,F,Z,X,b,Me);b.onAfterRender(w,F,K,Z,X,Me)}function Ta(b,F,K){if(F.isScene!==!0)F=tn;let Z=U.get(b),X=S.state.lights,Me=S.state.shadowsArray,Re=X.state.version,we=se.getParameters(b,X.state,Me,F,K,S.state.lightProbeGridArray),Ie=se.getProgramCacheKey(we),Ne=Z.programs;Z.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?F.environment:null,Z.fog=F.fog;let je=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(Z.envMap=le.get(b.envMap||Z.environment,je),Z.envMapRotation=Z.environment!==null&&b.envMap===null?F.environmentRotation:b.envMapRotation,Ne===void 0)b.addEventListener("dispose",oi),Ne=new Map,Z.programs=Ne;let et=Ne.get(Ie);if(et!==void 0){if(Z.currentProgram===et&&Z.lightsStateVersion===Re)return Mf(b,we),et}else{if(we.uniforms=se.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,K,we);b.onBeforeCompile(we,w),et=se.acquireProgram(we,Ie),Ne.set(Ie,et),Z.uniforms=we.uniforms}let Pe=Z.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Pe.clippingPlanes=pe.uniform;if(Mf(b,we),Z.needsLights=Ob(b),Z.lightsStateVersion=Re,Z.needsLights)Pe.ambientLightColor.value=X.state.ambient,Pe.lightProbe.value=X.state.probe,Pe.sunLights.value=X.state.sun,Pe.sunLightShadows.value=X.state.sunShadow,Pe.directionalLights.value=X.state.directional,Pe.directionalLightShadows.value=X.state.directionalShadow,Pe.spotLights.value=X.state.spot,Pe.spotLightShadows.value=X.state.spotShadow,Pe.rectAreaLights.value=X.state.rectArea,Pe.ltc_1.value=X.state.rectAreaLTC1,Pe.ltc_2.value=X.state.rectAreaLTC2,Pe.pointLights.value=X.state.point,Pe.pointLightShadows.value=X.state.pointShadow,Pe.hemisphereLights.value=X.state.hemi,Pe.sunShadowMatrix.value=X.state.sunShadowMatrix,Pe.sunShadowCascade.value=X.state.sunShadowCascade,Pe.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Pe.spotLightMatrix.value=X.state.spotLightMatrix,Pe.spotLightMap.value=X.state.spotLightMap,Pe.pointShadowMatrix.value=X.state.pointShadowMatrix;return Z.lightProbeGrid=S.state.lightProbeGridArray.length>0,Z.currentProgram=et,Z.uniformsList=null,et}function wf(b){if(b.uniformsList===null){let F=b.currentProgram.getUniforms();b.uniformsList=da.seqWithValue(F.seq,b.uniforms)}return b.uniformsList}function Mf(b,F){let K=U.get(b);K.outputColorSpace=F.outputColorSpace,K.batching=F.batching,K.batchingColor=F.batchingColor,K.instancing=F.instancing,K.instancingColor=F.instancingColor,K.instancingMorph=F.instancingMorph,K.skinning=F.skinning,K.morphTargets=F.morphTargets,K.morphNormals=F.morphNormals,K.morphColors=F.morphColors,K.morphTargetsCount=F.morphTargetsCount,K.numClippingPlanes=F.numClippingPlanes,K.numIntersection=F.numClipIntersection,K.vertexAlphas=F.vertexAlphas,K.vertexTangents=F.vertexTangents,K.toneMapping=F.toneMapping}function Lb(b,F){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(F.matrixWorld);for(let K=0,Z=b.length;K<Z;K++){let X=b[K];if(X.texture!==null&&X.boundingBox.containsPoint(T))return X}return null}function Nb(b,F,K,Z,X){if(F.isScene!==!0)F=tn;Y.resetTextureUnits();let Me=F.fog,Re=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?F.environment:null,we=P===null?w.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:Ke.workingColorSpace,Ie=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,Ne=le.get(Z.envMap||Re,Ie),je=Z.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,et=!!K.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),Pe=!!K.morphAttributes.position,dt=!!K.morphAttributes.normal,Bt=!!K.morphAttributes.color,Et=ei;if(Z.toneMapped){if(P===null||P.isXRRenderTarget===!0)Et=w.toneMapping}let xt=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,sn=xt!==void 0?xt.length:0,Ae=U.get(Z),dn=S.state.lights;if(He===!0){if(rt===!0||b!==H){let St=b===H&&Z.id===J;pe.setState(Z,b,St)}}let st=!1;if(Z.version===Ae.__version){if(Ae.needsLights&&Ae.lightsStateVersion!==dn.state.version)st=!0;else if(Ae.outputColorSpace!==we)st=!0;else if(X.isBatchedMesh&&Ae.batching===!1)st=!0;else if(!X.isBatchedMesh&&Ae.batching===!0)st=!0;else if(X.isBatchedMesh&&Ae.batchingColor===!0&&X._colorsTexture===null)st=!0;else if(X.isBatchedMesh&&Ae.batchingColor===!1&&X._colorsTexture!==null)st=!0;else if(X.isInstancedMesh&&Ae.instancing===!1)st=!0;else if(!X.isInstancedMesh&&Ae.instancing===!0)st=!0;else if(X.isSkinnedMesh&&Ae.skinning===!1)st=!0;else if(!X.isSkinnedMesh&&Ae.skinning===!0)st=!0;else if(X.isInstancedMesh&&Ae.instancingColor===!0&&X.instanceColor===null)st=!0;else if(X.isInstancedMesh&&Ae.instancingColor===!1&&X.instanceColor!==null)st=!0;else if(X.isInstancedMesh&&Ae.instancingMorph===!0&&X.morphTexture===null)st=!0;else if(X.isInstancedMesh&&Ae.instancingMorph===!1&&X.morphTexture!==null)st=!0;else if(Ae.envMap!==Ne)st=!0;else if(Z.fog===!0&&Ae.fog!==Me)st=!0;else if(Ae.numClippingPlanes!==void 0&&(Ae.numClippingPlanes!==pe.numPlanes||Ae.numIntersection!==pe.numIntersection))st=!0;else if(Ae.vertexAlphas!==je)st=!0;else if(Ae.vertexTangents!==et)st=!0;else if(Ae.morphTargets!==Pe)st=!0;else if(Ae.morphNormals!==dt)st=!0;else if(Ae.morphColors!==Bt)st=!0;else if(Ae.toneMapping!==Et)st=!0;else if(Ae.morphTargetsCount!==sn)st=!0;else if(!!Ae.lightProbeGrid!==S.state.lightProbeGridArray.length>0)st=!0}else st=!0,Ae.__version=Z.version;let Nn=Ae.currentProgram;if(st===!0){if(Nn=Ta(Z,F,X),C&&Z.isNodeMaterial)C.onUpdateProgram(Z,Nn,Ae)}let ai=!1,qi=!1,ss=!1,gt=Nn.getUniforms(),Ft=Ae.uniforms;if(A.useProgram(Nn.program))ai=!0,qi=!0,ss=!0;if(Z.id!==J)J=Z.id,qi=!0;if(Ae.needsLights){let St=Lb(S.state.lightProbeGridArray,X);if(Ae.lightProbeGrid!==St)Ae.lightProbeGrid=St,qi=!0}if(ai||H!==b){if(A.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();gt.setValue(O,"projectionMatrix",b.projectionMatrix),gt.setValue(O,"viewMatrix",b.matrixWorldInverse);let Ki=gt.map.cameraPosition;if(Ki!==void 0)Ki.setValue(O,Rt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)gt.setValue(O,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)gt.setValue(O,"isOrthographic",b.isOrthographicCamera===!0);if(H!==b)H=b,qi=!0,ss=!0}if(Ae.needsLights){if(dn.state.sunShadowMap.length>0)gt.setValue(O,"sunShadowMap",dn.state.sunShadowMap,Y);if(dn.state.directionalShadowMap.length>0)gt.setValue(O,"directionalShadowMap",dn.state.directionalShadowMap,Y);if(dn.state.spotShadowMap.length>0)gt.setValue(O,"spotShadowMap",dn.state.spotShadowMap,Y);if(dn.state.pointShadowMap.length>0)gt.setValue(O,"pointShadowMap",dn.state.pointShadowMap,Y)}if(X.isSkinnedMesh){gt.setOptional(O,X,"bindMatrix"),gt.setOptional(O,X,"bindMatrixInverse");let St=X.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();gt.setValue(O,"boneTexture",St.boneTexture,Y)}}if(X.isBatchedMesh){if(gt.setOptional(O,X,"batchingTexture"),gt.setValue(O,"batchingTexture",X._matricesTexture,Y),gt.setOptional(O,X,"batchingIdTexture"),gt.setValue(O,"batchingIdTexture",X._indirectTexture,Y),gt.setOptional(O,X,"batchingColorTexture"),X._colorsTexture!==null)gt.setValue(O,"batchingColorTexture",X._colorsTexture,Y)}let Yi=K.morphAttributes;if(Yi.position!==void 0||Yi.normal!==void 0||Yi.color!==void 0)ot.update(X,K,Nn);if(qi||Ae.receiveShadow!==X.receiveShadow)Ae.receiveShadow=X.receiveShadow,gt.setValue(O,"receiveShadow",X.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&F.environment!==null)Ft.envMapIntensity.value=F.environmentIntensity;if(Ft.dfgLUT!==void 0)Ft.dfgLUT.value=uC();if(qi){if(gt.setValue(O,"toneMappingExposure",w.toneMappingExposure),Ae.needsLights)Db(Ft,ss);if(Me&&Z.fog===!0)Ee.refreshFogUniforms(Ft,Me);if(Ee.refreshMaterialUniforms(Ft,Z,V,I,S.state.transmissionRenderTarget[b.id]),Ae.needsLights&&Ae.lightProbeGrid){let St=Ae.lightProbeGrid;Ft.probesSH.value=St.texture,Ft.probesMin.value.copy(St.boundingBox.min),Ft.probesMax.value.copy(St.boundingBox.max),Ft.probesResolution.value.copy(St.resolution)}da.upload(O,wf(Ae),Ft,Y)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)da.upload(O,wf(Ae),Ft,Y),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)gt.setValue(O,"center",X.center);if(gt.setValue(O,"modelViewMatrix",X.modelViewMatrix),gt.setValue(O,"normalMatrix",X.normalMatrix),gt.setValue(O,"modelMatrix",X.matrixWorld),Z.uniformsGroups!==void 0){let St=Z.uniformsGroups;for(let Ki=0,os=St.length;Ki<os;Ki++){let Tf=St[Ki];Te.update(Tf,Nn),Te.bind(Tf,Nn)}}return Nn}function Db(b,F){b.ambientLightColor.needsUpdate=F,b.lightProbe.needsUpdate=F,b.sunLights.needsUpdate=F,b.sunLightShadows.needsUpdate=F,b.directionalLights.needsUpdate=F,b.directionalLightShadows.needsUpdate=F,b.pointLights.needsUpdate=F,b.pointLightShadows.needsUpdate=F,b.spotLights.needsUpdate=F,b.spotLightShadows.needsUpdate=F,b.rectAreaLights.needsUpdate=F,b.hemisphereLights.needsUpdate=F}function Ob(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,F,K){let Z=U.get(b);if(Z.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;U.get(b.texture).__webglTexture=F,U.get(b.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:K,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,F){let K=U.get(b);K.__webglFramebuffer=F,K.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(b,F=0,K=0){P=b,W=F,B=K;let Z=null,X=!1,Me=!1;if(b){let we=U.get(b);if(we.__useDefaultFramebuffer!==void 0){A.bindFramebuffer(O.FRAMEBUFFER,we.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),ge=b.scissorTest,A.viewport(q),A.scissor(Q),A.setScissorTest(ge),J=-1;return}else if(we.__webglFramebuffer===void 0)Y.setupRenderTarget(b);else if(we.__hasExternalTextures)Y.rebindTextures(b,U.get(b.texture).__webglTexture,U.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let je=b.depthTexture;if(we.__boundDepthTexture!==je){if(je!==null&&U.has(je)&&(b.width!==je.image.width||b.height!==je.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(b)}}let Ie=b.texture;if(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)Me=!0;let Ne=U.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Ne[F]))Z=Ne[F][K];else Z=Ne[F];X=!0}else if(b.samples>0&&Y.useMultisampledRTT(b)===!1)Z=U.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Ne))Z=Ne[K];else Z=Ne;q.copy(b.viewport),Q.copy(b.scissor),ge=b.scissorTest}else q.copy(oe).multiplyScalar(V).floor(),Q.copy(ue).multiplyScalar(V).floor(),ge=$e;if(K!==0)Z=D;if(A.bindFramebuffer(O.FRAMEBUFFER,Z))A.drawBuffers(b,Z);if(A.viewport(q),A.scissor(Q),A.setScissorTest(ge),X){let we=U.get(b.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+F,we.__webglTexture,K)}else if(Me){let we=F;for(let Ie=0;Ie<b.textures.length;Ie++){let Ne=U.get(b.textures[Ie]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Ie,Ne.__webglTexture,K,we)}}else if(b!==null&&K!==0){let we=U.get(b.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,we.__webglTexture,K)}J=-1};function Ef(b){let F=U.get(b);if(F.__readFormat!==b.format||F.__readType!==b.type)F.__readFormat=b.format,F.__readType=b.type,F.__formatReadable=Pt.textureFormatReadable(b.format),F.__typeReadable=Pt.textureTypeReadable(b.type);return F}if(this.readRenderTargetPixels=function(b,F,K,Z,X,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=U.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie){A.bindFramebuffer(O.FRAMEBUFFER,Ie);try{let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)O.readBuffer(O.COLOR_ATTACHMENT0+we);let Pe=Ef(Ne);if(Pe.__formatReadable===!1){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Pe.__typeReadable===!1){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(F>=0&&F<=b.width-Z&&(K>=0&&K<=b.height-X))O.readPixels(F,K,Z,X,ne.convert(je),ne.convert(et),Me)}finally{let Ne=P!==null?U.get(P).__webglFramebuffer:null;A.bindFramebuffer(O.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(b,F,K,Z,X,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ie=U.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie)if(F>=0&&F<=b.width-Z&&(K>=0&&K<=b.height-X)){A.bindFramebuffer(O.FRAMEBUFFER,Ie);let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)O.readBuffer(O.COLOR_ATTACHMENT0+we);let Pe=Ef(Ne);if(Pe.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Pe.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let dt=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,dt),O.bufferData(O.PIXEL_PACK_BUFFER,Me.byteLength,O.STREAM_READ),O.readPixels(F,K,Z,X,ne.convert(je),ne.convert(et),0),O.bindBuffer(O.PIXEL_PACK_BUFFER,null);let Bt=P!==null?U.get(P).__webglFramebuffer:null;A.bindFramebuffer(O.FRAMEBUFFER,Bt);let Et=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await vv(O,Et,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,dt),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,Me),O.bindBuffer(O.PIXEL_PACK_BUFFER,null),O.deleteBuffer(dt),O.deleteSync(Et),Me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,F=null,K=0){let Z=Math.pow(2,-K),X=Math.floor(b.image.width*Z),Me=Math.floor(b.image.height*Z),Re=F!==null?F.x:0,we=F!==null?F.y:0;Y.setTexture2D(b,0),O.copyTexSubImage2D(O.TEXTURE_2D,K,0,0,Re,we,X,Me),A.unbindTexture()},this.copyTextureToTexture=function(b,F,K=null,Z=null,X=0,Me=0){let Re,we,Ie,Ne,je,et,Pe,dt,Bt,Et=b.isCompressedTexture?b.mipmaps[Me]:b.image;if(K!==null)Re=K.max.x-K.min.x,we=K.max.y-K.min.y,Ie=K.isBox3?K.max.z-K.min.z:1,Ne=K.min.x,je=K.min.y,et=K.isBox3?K.min.z:0;else{let Ft=Math.pow(2,-X);if(Re=Math.floor(Et.width*Ft),we=Math.floor(Et.height*Ft),b.isDataArrayTexture)Ie=Et.depth;else if(b.isData3DTexture)Ie=Math.floor(Et.depth*Ft);else Ie=1;Ne=0,je=0,et=0}if(Z!==null)Pe=Z.x,dt=Z.y,Bt=Z.z;else Pe=0,dt=0,Bt=0;let xt=ne.convert(F.format),sn=ne.convert(F.type),Ae;if(F.isData3DTexture)Y.setTexture3D(F,0),Ae=O.TEXTURE_3D;else if(F.isDataArrayTexture||F.isCompressedArrayTexture)Y.setTexture2DArray(F,0),Ae=O.TEXTURE_2D_ARRAY;else Y.setTexture2D(F,0),Ae=O.TEXTURE_2D;A.activeTexture(O.TEXTURE0),A.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,F.flipY),A.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),A.pixelStorei(O.UNPACK_ALIGNMENT,F.unpackAlignment);let dn=A.getParameter(O.UNPACK_ROW_LENGTH),st=A.getParameter(O.UNPACK_IMAGE_HEIGHT),Nn=A.getParameter(O.UNPACK_SKIP_PIXELS),ai=A.getParameter(O.UNPACK_SKIP_ROWS),qi=A.getParameter(O.UNPACK_SKIP_IMAGES);A.pixelStorei(O.UNPACK_ROW_LENGTH,Et.width),A.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Et.height),A.pixelStorei(O.UNPACK_SKIP_PIXELS,Ne),A.pixelStorei(O.UNPACK_SKIP_ROWS,je),A.pixelStorei(O.UNPACK_SKIP_IMAGES,et);let ss=b.isDataArrayTexture||b.isData3DTexture,gt=F.isDataArrayTexture||F.isData3DTexture;if(b.isDepthTexture){let Ft=U.get(b),Yi=U.get(F),St=U.get(Ft.__renderTarget),Ki=U.get(Yi.__renderTarget);A.bindFramebuffer(O.READ_FRAMEBUFFER,St.__webglFramebuffer),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,Ki.__webglFramebuffer);for(let os=0;os<Ie;os++){if(ss)O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,U.get(b).__webglTexture,X,et+os),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,U.get(F).__webglTexture,Me,Bt+os);O.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,O.DEPTH_BUFFER_BIT,O.NEAREST)}A.bindFramebuffer(O.READ_FRAMEBUFFER,null),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(X!==0||b.isRenderTargetTexture||U.has(b)){let Ft=U.get(b),Yi=U.get(F);A.bindFramebuffer(O.READ_FRAMEBUFFER,ee),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,L);for(let St=0;St<Ie;St++){if(ss)O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Ft.__webglTexture,X,et+St);else O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Ft.__webglTexture,X);if(gt)O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Yi.__webglTexture,Me,Bt+St);else O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Yi.__webglTexture,Me);if(X!==0)O.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,O.COLOR_BUFFER_BIT,O.NEAREST);else if(gt)O.copyTexSubImage3D(Ae,Me,Pe,dt,Bt+St,Ne,je,Re,we);else O.copyTexSubImage2D(Ae,Me,Pe,dt,Ne,je,Re,we)}A.bindFramebuffer(O.READ_FRAMEBUFFER,null),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(gt)if(b.isDataTexture||b.isData3DTexture)O.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et.data);else if(F.isCompressedArrayTexture)O.compressedTexSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,Et.data);else O.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et);else if(b.isDataTexture)O.texSubImage2D(O.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et.data);else if(b.isCompressedTexture)O.compressedTexSubImage2D(O.TEXTURE_2D,Me,Pe,dt,Et.width,Et.height,xt,Et.data);else O.texSubImage2D(O.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et);if(A.pixelStorei(O.UNPACK_ROW_LENGTH,dn),A.pixelStorei(O.UNPACK_IMAGE_HEIGHT,st),A.pixelStorei(O.UNPACK_SKIP_PIXELS,Nn),A.pixelStorei(O.UNPACK_SKIP_ROWS,ai),A.pixelStorei(O.UNPACK_SKIP_IMAGES,qi),Me===0&&F.generateMipmaps)O.generateMipmap(Ae);A.unbindTexture()},this.initRenderTarget=function(b){if(U.get(b).__webglFramebuffer===void 0)Y.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)Y.setTextureCube(b,0);else if(b.isData3DTexture)Y.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)Y.setTexture2DArray(b,0);else Y.setTexture2D(b,0);A.unbindTexture()},this.resetState=function(){W=0,B=0,P=null,A.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ud}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}}var dy={type:"change"},$d={type:"start"},py={type:"end"},xl=new _r,fy=new zn,hC=Math.cos(70*jo.DEG2RAD),Zt=new z,bn=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Vd=0.000001;class Wd extends fl{constructor(e,t=null){super(e,t);if(this.state=mt.NONE,this.target=new z,this.cursor=new z,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:dr.ROTATE,MIDDLE:dr.DOLLY,RIGHT:dr.PAN},this.touches={ONE:fr.ROTATE,TWO:fr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new z,this._lastQuaternion=new Yt,this._lastTargetPosition=new z,this._quat=new Yt().setFromUnitVectors(e.up,new z(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new ca,this._sphericalDelta=new ca,this._scale=1,this._panOffset=new z,this._rotateStart=new ke,this._rotateEnd=new ke,this._rotateDelta=new ke,this._panStart=new ke,this._panEnd=new ke,this._panDelta=new ke,this._dollyStart=new ke,this._dollyEnd=new ke,this._dollyDelta=new ke,this._dollyDirection=new z,this._mouse=new ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=fC.bind(this),this._onPointerDown=dC.bind(this),this._onPointerUp=pC.bind(this),this._onContextMenu=bC.bind(this),this._onMouseWheel=_C.bind(this),this._onKeyDown=xC.bind(this),this._onTouchStart=vC.bind(this),this._onTouchMove=yC.bind(this),this._onMouseDown=mC.bind(this),this._onMouseMove=gC.bind(this),this._interceptControlDown=SC.bind(this),this._interceptControlUp=wC.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=mt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(dy),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Zt.copy(t).sub(this.target),Zt.applyQuaternion(this._quat),this._spherical.setFromVector3(Zt),this.autoRotate&&this.state===mt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=bn;else if(n>Math.PI)n-=bn;if(i<-Math.PI)i+=bn;else if(i>Math.PI)i-=bn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Zt.setFromSpherical(this._spherical),Zt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Zt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Zt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new z(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new z(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(xl.origin.copy(this.object.position),xl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(xl.direction))<hC)this.object.lookAt(this.target);else fy.setFromNormalAndCoplanarPoint(this.object.up,this.target),xl.intersectPlane(fy,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Vd||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Vd||this._lastTargetPosition.distanceToSquared(this.target)>Vd)return this.dispatchEvent(dy),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return bn/60*this.autoRotateSpeed*e;else return bn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Zt.setFromMatrixColumn(t,0),Zt.multiplyScalar(-e),this._panOffset.add(Zt)}_panUp(e,t){if(this.screenSpacePanning===!0)Zt.setFromMatrixColumn(t,1);else Zt.setFromMatrixColumn(t,0),Zt.crossVectors(this.object.up,Zt);Zt.multiplyScalar(e),this._panOffset.add(Zt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Zt.copy(i).sub(this.target);let r=Zt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new ke,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function dC(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function fC(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function pC(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(py),this.state=mt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function mC(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case dr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=mt.DOLLY;break;case dr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}break;case dr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent($d)}function gC(e){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function _C(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE)return;e.preventDefault(),this.dispatchEvent($d),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(py)}function xC(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function vC(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case fr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=mt.TOUCH_ROTATE;break;case fr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case fr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=mt.TOUCH_DOLLY_PAN;break;case fr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent($d)}function yC(e){switch(this._trackPointer(e),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=mt.NONE}}function bC(e){if(this.enabled===!1)return;e.preventDefault()}function SC(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function wC(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Zd extends zs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new vr;e.deleteAttribute("uv");let t=new Wi({side:cn}),n=new Wi,i=new $s(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new Bs(e,n,6),o=new _t;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,qs(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,qs(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,qs(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,qs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let h=new Mt(e,qs(20));h.position.set(3.235,11.486,-12.541),h.scale.set(2.5,2,0.1),this.add(h);let d=new Mt(e,qs(100));d.position.set(0,20,0),d.scale.set(1,0.1,1),this.add(d)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function qs(e){return new sl({color:0,emissive:16777215,emissiveIntensity:e})}function Xd(e,t){if(t===od)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Fs||t===Xo){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Fs)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function my(e){let t=new Map,n=new Map,i=e.clone();return gy(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function gy(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)gy(e.children[i],t.children[i],n)}class ef extends Xi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new My(t)}),this.register(function(t){return new Ey(t)}),this.register(function(t){return new Dy(t)}),this.register(function(t){return new Oy(t)}),this.register(function(t){return new Uy(t)}),this.register(function(t){return new Ay(t)}),this.register(function(t){return new Ry(t)}),this.register(function(t){return new Cy(t)}),this.register(function(t){return new Iy(t)}),this.register(function(t){return new wy(t)}),this.register(function(t){return new Py(t)}),this.register(function(t){return new Ty(t)}),this.register(function(t){return new Ny(t)}),this.register(function(t){return new Ly(t)}),this.register(function(t){return new by(t)}),this.register(function(t){return new Kd(t,Qe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Kd(t,Qe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Fy(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=Mr.extractUrlBase(e);s=Mr.resolveURL(c,this.path)}else s=Mr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new oa(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===zy){try{s[Qe.KHR_BINARY_GLTF]=new ky(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Qe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new $y(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(u){case Qe.KHR_MATERIALS_UNLIT:s[u]=new Sy;break;case Qe.KHR_DRACO_MESH_COMPRESSION:s[u]=new By(r,this.dracoLoader);break;case Qe.KHR_TEXTURE_TRANSFORM:s[u]=new Gy;break;case Qe.KHR_MESH_QUANTIZATION:s[u]=new Hy;break;default:if(h.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function MC(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function kt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Qe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class by{constructor(e){this.parser=e,this.name=Qe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Ge(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Rn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Ws(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new $s(l),c.distance=u;break;case"spot":c=new ul(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),Ti(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class Sy{constructor(){this.name=Qe.KHR_MATERIALS_UNLIT}getMaterialType(){return wi}extendParams(e,t,n){let i=[];e.color=new Ge(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Rn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,gr))}return Promise.all(i)}}class wy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class My{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ke(r,r)}}return Promise.all(i)}}class Ey{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Ty{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class Ay{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SHEEN}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Ge(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Rn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,gr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Ry{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class Cy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_VOLUME}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ge().setRGB(r[0],r[1],r[2],Rn),Promise.all(i)}}class Iy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IOR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class Py{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Ge().setRGB(r[0],r[1],r[2],Rn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,gr));return Promise.all(i)}}class Ly{constructor(e){this.parser=e,this.name=Qe.EXT_MATERIALS_BUMP}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Ny{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Dy{constructor(e){this.parser=e,this.name=Qe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Oy{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Uy{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Kd{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,h=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,h,i.mode,i.filter).then(function(d){return d.buffer});else return s.ready.then(function(){let d=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(d),l,u,h,i.mode,i.filter),d})})}else return null}}class Fy{constructor(e){this.name=Qe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Hn.TRIANGLES&&c.mode!==Hn.TRIANGLE_STRIP&&c.mode!==Hn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],h=c[0].count,d=[];for(let f of u){let m=new Xe,_=new z,p=new Yt,g=new z(1,1,1),M=new Bs(f.geometry,f.material,h);for(let v=0;v<h;v++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)g.fromBufferAttribute(a.SCALE,v);M.setMatrixAt(v,m.compose(_,p,g))}let T=null;for(let v in a)if(v==="_COLOR_0"){let S=a[v];M.instanceColor=new hr(S.array,S.itemSize,S.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(T===null){let E=M.geometry;T=new ln,T.name=E.name;for(let R in E.attributes)T.setAttribute(R,E.attributes[R]);for(let R in E.morphAttributes)T.morphAttributes[R]=E.morphAttributes[R];if(E.index!==null)T.setIndex(E.index);T.morphTargetsRelative=E.morphTargetsRelative;for(let R of E.groups)T.addGroup(R.start,R.count,R.materialIndex);if(E.boundingBox!==null)T.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)T.boundingSphere=E.boundingSphere.clone();T.drawRange.start=E.drawRange.start,T.drawRange.count=E.drawRange.count,T.userData=Object.assign({},E.userData),M.geometry=T}let S=a[v];T.setAttribute(v,new hr(S.array,S.itemSize,S.normalized))}_t.prototype.copy.call(M,f),this.parser.assignFinalMaterial(M),d.push(M)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var zy="glTF",pa=12,_y={JSON:1313821514,BIN:5130562};class ky{constructor(e){this.name=Qe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,pa),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==zy)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-pa,r=new DataView(e,pa),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===_y.JSON){let c=new Uint8Array(e,pa+s,o);this.content=n.decode(c)}else if(a===_y.BIN){let c=pa+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class By{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Qe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Jd[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Jd[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=Ys[h.componentType];c[u]=d.name,a[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,h){i.decodeDracoFile(l,function(d){for(let f in d.attributes){let m=d.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(d)},o,c,Rn,h)})})}}class Gy{constructor(){this.name=Qe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Hy{constructor(){this.name=Qe.KHR_MESH_QUANTIZATION}}class tf extends Zi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,h=u*u,d=h*u,f=e*c,m=f-c,_=-2*d+3*h,p=d-h,g=1-_,M=p-h+u;for(let T=0;T!==o;T++){let v=s[m+T+o],S=s[m+T+a]*l,E=s[f+T+o],R=s[f+T]*l;r[T]=g*v+M*S+_*E+p*R}return r}}var EC=new Yt;class Vy extends tf{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return EC.fromArray(r).normalize().toArray(r),r}}var Hn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ys={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},xy={9728:ti,9729:Jt,9984:Bc,9985:Os,9986:Zr,9987:yi},vy={33071:Ds,33648:kc,10497:Ns},jd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Jd={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Er={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},TC={CUBICSPLINE:void 0,LINEAR:Xc,STEP:sd},qd={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function AC(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Wi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:pr});return e.DefaultMaterial}function ns(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function Ti(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function RC(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0)i=!0;if(h.NORMAL!==void 0)r=!0;if(h.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(i){let d=h.POSITION!==void 0?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=h;if(s)e.morphAttributes.color=d;return e.morphTargetsRelative=!0,e})}function CC(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function IC(e){let t,n=e.extensions&&e.extensions[Qe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Yd(n.attributes);else t=e.indices+":"+Yd(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Yd(e.targets[i]);return t}function Yd(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Qd(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function PC(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var LC=new Xe;class $y{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new MC,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Hs(this.options.manager);else this.textureLoader=new hl(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oa(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return ns(r,o,i),Ti(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Qe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(Mr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=jd[i.type],o=Ys[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Kt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=jd[i.type],c=Ys[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,h=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(d&&d!==u){let p=Math.floor(h/d),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,M=t.cache.get(g);if(!M)m=new c(o,p*d,i.count*d/l),M=new Ko(m,d/l),t.cache.add(g,M);_=new ks(M,a,h%d/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,h,i.count*a);_=new Kt(m,a,f)}if(i.sparse!==void 0){let p=jd.SCALAR,g=Ys[i.sparse.indices.componentType],M=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,v=new g(s[1],M,i.sparse.count*p),S=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new Kt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let E=0,R=v.length;E<R;E++){let x=v[E];if(_.setX(x,S[E*a]),a>=2)_.setY(x,S[E*a+1]);if(a>=3)_.setZ(x,S[E*a+2]);if(a>=4)_.setW(x,S[E*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let h=(r.samplers||{})[s.sampler]||{};return l.magFilter=xy[h.magFilter]||Jt,l.minFilter=xy[h.minFilter]||yi,l.wrapS=vy[h.wrapS]||Ns,l.wrapT=vy[h.wrapT]||Ns,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==ti&&l.minFilter!==Jt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let h=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(h),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(h,d){let f=h;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Ot(m);_.needsUpdate=!0,h(_)};t.load(Mr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return Ti(u,s),u.userData.mimeType=s.mimeType||PC(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Qe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Qe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Qe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ia,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new na,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Wi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Qe.KHR_MATERIALS_UNLIT]){let u=i[Qe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Ge(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],Rn),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,gr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Bn;let l=r.alphaMode||qd.OPAQUE;if(l===qd.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===qd.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new ke(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==wi){let u=r.emissiveFactor;o.emissive=new Ge().setRGB(u[0],u[1],u[2],Rn)}if(r.emissiveTexture!==void 0&&s!==wi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,gr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(Ti(u,r),t.associations.set(u,{materials:e}),r.extensions)ns(i,u,r);return u})}createUniqueName(e){let t=ct.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return yy(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=IC(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[Qe.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=yy(new ln,c,t);if(c.mode===Hn.TRIANGLE_STRIP)h=h.then((d)=>Xd(d,Xo));else if(c.mode===Hn.TRIANGLE_FAN)h=h.then((d)=>Xd(d,Fs));i[l]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?AC(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let d=0,f=l.length;d<f;d++){let m=l[d],_=s[d],p,g=c[d];if(_.mode===Hn.TRIANGLES||_.mode===Hn.TRIANGLE_STRIP||_.mode===Hn.TRIANGLE_FAN||_.mode===void 0){let M=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(M&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=M&&T?new el(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Hn.LINES)p=new tl(m,g);else if(_.mode===Hn.LINE_STRIP)p=new xr(m,g);else if(_.mode===Hn.LINE_LOOP)p=new nl(m,g);else if(_.mode===Hn.POINTS)p=new Gs(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)CC(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),Ti(p,r),_.extensions)ns(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let d=0,f=u.length;d<f;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1){if(r.extensions)ns(i,u[0],r);return u[0]}let h=new gi;if(r.extensions)ns(i,h,r);t.associations.set(h,{meshes:e});for(let d=0,f=u.length;d<f;d++)h.add(u[d]);return h})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ht(jo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new es(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return Ti(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let h=new Xe;if(r!==null)h.fromArray(r.array,c*16);a.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new ea(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,h=i.channels.length;u<h;u++){let d=i.channels[u],f=i.samplers[d.sampler],m=d.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let M=0,T=h.length;M<T;M++){let v=h[M],S=d[M],E=f[M],R=m[M],x=_[M];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let w=n._createAnimationTracks(v,S,E,R,x);if(w)for(let G=0;G<w.length;G++)p.push(w[G])}let g=new Cs(r,void 0,p);return Ti(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],h=c[2];if(h!==null)l.traverse(function(d){if(!d.isSkinnedMesh)return;d.bind(h,LC)});for(let d=0,f=u.length;d<f;d++)l.add(u[d]);if(l.userData.pivot!==void 0&&u.length>0){let d=l.userData.pivot,f=u[0];l.pivot=new z().fromArray(d),l.position.x-=d[0],l.position.y-=d[1],l.position.z-=d[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Jo;else if(c.length>1)l=new gi;else if(c.length===1)l=c[0];else l=new _t;if(l!==c[0])for(let u=0,h=c.length;u<h;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(Ti(l,r),r.extensions)ns(n,l,r);if(r.matrix!==void 0){let u=new Xe;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new gi;if(n.name)r.name=i.createUniqueName(n.name);if(Ti(r,n),n.extensions)ns(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let h=a[l];if(h.parent!==null)r.add(my(h));else r.add(h)}let c=(l)=>{let u=new Map;for(let[h,d]of i.associations)if(h instanceof yn||h instanceof Ot)u.set(h,d);return l.traverse((h)=>{let d=i.associations.get(h);if(d!=null)u.set(h,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(d){if(d.morphTargetInfluences)a.push(d.name?d.name:d.uuid)}if(Er[r.path]===Er.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Er[r.path]){case Er.weights:l=br;break;case Er.rotation:l=Sr;break;case Er.translation:case Er.scale:l=Qr;break;default:switch(n.itemSize){case 1:l=br;break;case 2:case 3:default:l=Qr;break}break}let u=i.interpolation!==void 0?TC[i.interpolation]:Xc,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+Er[r.path],t.array,h,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Qd(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof Sr?Vy:tf)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function NC(e,t,n){let i=t.attributes,r=new Vt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new z(c[0],c[1],c[2]),new z(l[0],l[1],l[2])),a.normalized){let u=Qd(Ys[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new z,c=new z;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=n.json.accessors[h.POSITION],{min:f,max:m}=d;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){let _=Qd(Ys[d.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new In;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function yy(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Jd[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(Ke.workingColorSpace!==Rn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ke.workingColorSpace}" not supported.`);return Ti(e,t),NC(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?RC(e,t.targets,n):e})}function Ai(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Ot)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Wy(e){ku(e);let t=new sa,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Hs(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new ef(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Ai(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function Zy(e,t,n=40,i=[e]){let r=e.getCenter(new z),s=Math.max(e.getSize(new z).length()/2,0.01),o=new z(1,0.65,1.25).normalize(),a=new z().crossVectors(new z(0,1,0),o).normalize(),c=new z().crossVectors(o,a),l=[];for(let M of i.length?i:[e])for(let T of[M.min.x,M.max.x])for(let v of[M.min.y,M.max.y])for(let S of[M.min.z,M.max.z])l.push(new z(T,v,S));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let M of l){let T=M.clone().sub(r),v=T.dot(a),S=T.dot(c);u=Math.min(u,v),h=Math.max(h,v),d=Math.min(d,S),f=Math.max(f,S)}r.addScaledVector(a,(u+h)/2),r.addScaledVector(c,(d+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let M of l){let T=M.clone().sub(r),v=T.dot(o);p=Math.max(p,v+Math.abs(T.dot(a))*1.12/_,v+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function nf(e,t){return{position:e.position.clone(),target:t.clone()}}function rf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new z).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new z))+r*20,10),e.updateProjectionMatrix()}function Xy(e,t,n){let i=e.getWorldDirection(new z);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new z(0,1,0)),s=new z;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function jy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function qy(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function Yy(e,t,n){if(t())return e;n(e);return}function vl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function yl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Vt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Vt,i=new Vt,r=new z;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Vt().setFromObject(e,!0):n}function ma(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Ky(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let h=l.parent;while(h&&!i.has(h))h=h.parent;if(h)continue;let d=[l];for(let m of u)d.push(await e.parser.getDependency("node",m));vl(e,d.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:d})}if(r.length===0)return;let s=ma(e.scene)-r.reduce((c,l)=>c+sf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,h)=>u+sf(h,l),0));return{chains:r,triangles:a}}var Jy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function sf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return ma(Jy(e,t))}function Qy(e,t){let n=Jy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function eb(e,t){for(let n of e.chains)Qy(n,t)}function tb(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Qy(i,n),!0}function nb(e,t){if(!e)return;return{triangles:ma(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>sf(n,r))}))}}function Ks(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function of(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function ga(e){let t=new Hd({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=$o,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new zs,i=new Ht(40,1,0.01,1000),r=new Wd(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),h=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",h);let d=new fa(t),f=new Zd,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new Ws(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new cl(14806490,5065021,1.7));let p,g,M,T=[],v=!0,S=performance.now(),E=0,R=0,x=!1,w,G,C,D=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},ee=(P)=>{let J=t.getContext(),H=J.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:jy(C.samples),...G===void 0?{}:{loadToFirstFrameMs:G},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(J.getParameter(J.VERSION)),vendor:String(J.getParameter(J.VENDOR)),renderer:String(J.getParameter(J.RENDERER)),browser:navigator.userAgent,...H?{unmaskedVendor:String(J.getParameter(H.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(J.getParameter(H.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},L=()=>{if(!p)return;let P=yl(p),J=[];p.traverseVisible((he)=>{if(he instanceof Mt||he instanceof xr||he instanceof Gs){let de=new Vt().setFromObject(he,!0);if(!de.isEmpty())J.push(de)}});let{center:H,radius:q,distance:Q,position:ge}=Zy(P,i.aspect,i.fov,J);if(r.target.copy(H),i.position.copy(ge),i.near=Math.max(q/1000,0.0001),i.far=Q+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},W=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:J}=e;if(!P||!J)return;t.setSize(P,J),i.aspect=P/J,i.updateProjectionMatrix()});W.observe(e);let B=(P)=>{if(x)return;let J=Math.min((P-S)/1000,0.1);if(S=P,e.clientWidth&&e.clientHeight){if(v)M?.update(J);if(o&&s.size){let H=Xy(i,s,J*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(H),r.target.add(H)}if(r.update(),t.render(n,i),w!==void 0)G=performance.now()-w,w=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let H=ee(P);clearTimeout(C.timeout),C.resolve(H),C=void 0}}}else s.clear(),D("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(B)};return E=requestAnimationFrame(B),{async load(P,J={}){let H=performance.now(),q=++R;D("The artifact changed during measurement. Measure the new revision again.");let Q=await Wy(P);vl(Q,[Q.scene]);let ge=await Ky(Q);try{Q.assertTexturesLoaded()}catch(re){Ai(Q.scene);for(let oe of Ks(ge))Ai(oe);throw re}let he=Yy(Q,()=>!x&&q===R&&J.isCurrent?.()!==!1,(re)=>{Ai(re.scene);for(let oe of Ks(ge))Ai(oe)});if(!he)return;let de=p&&J.preserveView?nf(i,r.target):void 0;if(p){M?.stopAllAction(),M?.uncacheRoot(p),n.remove(p),Ai(p);for(let re of Ks(g))Ai(re)}p=he.scene,g=ge,w=H,G=void 0,n.add(p),T=he.animations,M=new dl(p),v=!0;let{clientWidth:fe,clientHeight:I}=e;if(t.setSize(fe,I),i.aspect=fe&&I?fe/I:i.aspect,L(),de)rf(i,r.target,de,yl(p)),r.update();let V=0,j=new Set;return p.traverseVisible((re)=>{let oe=re;if(!oe.isMesh)return;V++;for(let ue of Array.isArray(oe.material)?oe.material:[oe.material])j.add(ue)}),J.onCommit?.(),{triangles:ma(p),meshes:V,materials:j.size,clips:T.map((re)=>re.name),...g?{levels:g.triangles}:{}}},level(P){if(D("The level of detail changed. Measure the displayed combination again."),g)eb(g,P)},partLevel(P,J){if(D("The level of detail changed. Measure the displayed combination again."),g)tb(g,P,J)},lod(){return p?nb(g,p):void 0},reset:L,cancelMeasurement:D,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((J,H)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:J,reject:H,timeout:setTimeout(()=>D("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return nf(i,r.target)},setView(P){if(!p)return;rf(i,r.target,P,yl(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let J of p?[p,...Ks(g)]:[])J.traverse((H)=>{let q=H;if(q.isMesh){for(let Q of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in Q)Q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(M?.stopAllAction(),T[P])M?.clipAction(T[P]).play()},pause(P){v=!P},dispose(){if(D("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(E),W.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)Ai(p);for(let P of Ks(g))Ai(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var ae=(e)=>document.getElementById(e);function N(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function hn(e){let t=ae("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function Xt(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function Js(e,t){let n=N("div",void 0,"empty");return n.append(N("b",e),N("p",t)),n}function ri(e,t){try{localStorage.setItem(e,t)}catch{}}function Tr(e){try{return localStorage.getItem(e)}catch{return null}}function Qt(e){return e?e.slice(0,15):"Unspecified"}function Qs(e,t){let n=N("details",void 0,"record-details");return n.append(N("summary",e),N("pre",JSON.stringify(t,null,2))),n}function _a(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...of(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let o=N("p","","lod-total");o.setAttribute("role","status"),t.append(o);let a=new Map;if(r.chains.length>1){let l=N("details",void 0,"lod-parts");l.append(N("summary","Per-part levels")),l.append(N("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=N("div",void 0,"lod-part-fields"),h=new Set(r.chains.filter((d,f,m)=>m.findIndex((_)=>_.label===d.label)!==f).map((d)=>d.label));for(let[d,f]of r.chains.entries()){let m=h.has(f.label)?`${f.label} (part ${d+1})`:f.label,_=N("label",m,"inline-field"),p=N("select");p.setAttribute("aria-label",`${m} level of detail`),p.append(...of(f.triangles).map((g,M)=>new Option(g,String(M)))),p.onchange=()=>{n.partLevel(f.id,Number(p.value)),c(),i?.()},a.set(f.id,p),_.append(p),u.append(_)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((h,d)=>l.chains.every((f)=>f.level===Math.min(d,f.triangles.length-1)));e.value=u<0?"mixed":String(u),o.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let h of l.chains){let d=a.get(h.id);if(d)d.value=String(h.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var ib=/^[a-z][a-z0-9_-]{0,79}$/u,DC=/^r_[a-z0-9_-]{1,77}$/u;function rb(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!ib.test(n)||!ib.test(i)||!DC.test(r))return;return{collection:n,assetId:i,revisionId:r}}var sb=new TextEncoder,OC=new TextDecoder,eo=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),af=(e,t)=>Object.hasOwn(e,t);async function ob(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function UC(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}async function ab(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");cc(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";UC(r);for(let[M,T]of Object.entries(e.files))if(await ob(T)!==e.manifest.files[M].sha256)throw Error(`Asset integrity mismatch: ${M}`);let s=new DataView(i.buffer,i.byteOffset,i.byteLength),o=12;while(o<i.length){if(o+8>i.length)throw Error("Invalid GLB chunk header");let M=s.getUint32(o,!0);if(M%4||o+8+M>i.length)throw Error("Invalid GLB chunk length");o+=8+M}let a=20+s.getUint32(12,!0),c=JSON.parse(OC.decode(i.subarray(20,a)));if(!eo(c)||!eo(c.asset)||c.asset.version!=="2.0")throw Error("Invalid glTF asset");let l=c.asset;if(af(l,"extras")&&!eo(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(af(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let h=[];if(c.scenes!==void 0&&!Array.isArray(c.scenes))throw Error("Invalid glTF scenes");for(let[M,T]of(c.scenes??[]).entries()){if(!eo(T)||!eo(T.extras)||!af(T.extras,"kilnReviewClipsV1"))continue;let v=T.extras.kilnReviewClipsV1;if(!eo(v)||v.version!==1&&v.version!==2||!Array.isArray(v.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");h.push({index:M,kilnReviewClipsV1:v}),delete T.extras.kilnReviewClipsV1}let d={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:h},f=sb.encode(JSON.stringify(d));l.extras={...u,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",metadata:{uri:r,sha256:await ob(f)}}};let m=sb.encode(JSON.stringify(c)),_=Math.ceil(m.length/4)*4,p=new Uint8Array(20+_+i.length-a);if(p.length>Un||f.length>Un)throw Error("Runtime export exceeds 64 MiB");p.set(i.subarray(0,20));let g=new DataView(p.buffer);return g.setUint32(8,p.length,!0),g.setUint32(12,_,!0),p.fill(32,20,20+_),p.set(m,20),p.set(i.subarray(a),20+_),{profile:n,glb:p,metadata:{name:r,bytes:f}}}var si=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),cf=Fe().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),ub=Fe().regex(/^sha256:[a-f0-9]{64}$/),to=Fe().max(4000),hb=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),cb=qe({collectionId:si,assetId:si,revisionId:si}).strict(),lb=qe({style:to.default(""),scale:Fe().max(1000).default(""),palette:wt(qe({role:Fe().min(1).max(100),color:Fe().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:wt(qe({role:Fe().min(1).max(100),description:to.default(""),resourceId:hb.optional()}).strict()).max(128).default([]),conventions:wt(Fe().max(1000)).max(100).default([]),exceptions:wt(Fe().max(1000)).max(100).default([])}).strict(),FC=qe({resourceId:hb,revisionId:Fe().min(1).max(200),sha256:ub,role:Fe().max(100).optional()}).strict(),zC=wt(FC).max(512),Ri={name:Fe().trim().min(1).max(200),brief:Fe().max(16000).default(""),design:lb.default(()=>lb.parse({})),inventory:wt(qe({id:si,name:Fe().trim().min(1).max(200),kind:pn(["asset","environment"]).default("asset"),brief:to.default(""),references:wt(si).max(64).default([]),asset:cb.optional()}).strict()).max(1000).default([]),deliveryProfiles:wt(qe({id:si,target:pn(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:to.default(""),performanceIntent:Fe().max(1000).default(""),constraints:wt(Fe().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:zC.default([]),references:wt(qe({id:si,title:Fe().min(1).max(200),uri:Fe().min(1).max(2048),description:to.default(""),sha256:ub.optional()}).strict()).max(256).default([]),reviews:wt(qe({id:si,inventoryId:si,projectRevisionId:cf,asset:cb,reviewer:Fe().trim().min(1).max(200),verdict:pn(["comment","changes-requested","accepted"]),notes:to}).strict()).max(2000).default([])};function db(e,t){let n=(o,a)=>{if(new Set(o).size!==o.length)t.addIssue({code:rc.custom,path:[a],message:"Duplicate identity"})};n(e.inventory.map((o)=>o.id),"inventory"),n(e.references.map((o)=>o.id),"references"),n(e.deliveryProfiles.map((o)=>o.id),"deliveryProfiles"),n(e.materialDependencies.map((o)=>o.resourceId),"materialDependencies"),n(e.reviews.map((o)=>o.id),"reviews"),n(e.design.palette.map((o)=>o.role),"design.palette"),n(e.design.materialRoles.map((o)=>o.role),"design.materialRoles");let i=new Set(e.references.map((o)=>o.id)),r=new Set(e.inventory.map((o)=>o.id)),s=new Set(e.materialDependencies.map((o)=>o.resourceId));for(let o of e.inventory)if(n(o.references,`inventory.${o.id}.references`),o.references.some((a)=>!i.has(a)))t.addIssue({code:rc.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((o)=>!r.has(o.inventoryId)))t.addIssue({code:rc.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((o)=>o.resourceId&&!s.has(o.resourceId)))t.addIssue({code:rc.custom,path:["design"],message:"Material role requires a locked resource"})}var fb=qe({projectId:si.optional(),...Ri}).strict().superRefine(db),BO=qe({name:Ri.name.optional(),brief:Ri.brief.removeDefault().optional(),design:Ri.design.removeDefault().optional(),inventory:Ri.inventory.removeDefault().optional(),deliveryProfiles:Ri.deliveryProfiles.removeDefault().optional(),materialDependencies:Ri.materialDependencies.removeDefault().optional(),references:Ri.references.removeDefault().optional(),reviews:Ri.reviews.removeDefault().optional()}).strict(),GO=qe({version:jt("kiln.project.v1"),projectId:si,revisionId:cf,parentRevision:cf.optional(),createdAt:Fe().datetime(),...Ri}).strict().superRefine(db);function pb(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function mb(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return fb.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function gb(e){let t=[],n=Tr("kiln.project")??"",i,r=()=>{let c=ae("project-list");c.replaceChildren();for(let T of t){let v=N("button",void 0,T.projectId===n?"active":"");if(v.append(N("strong",T.name),N("small",`${T.inventory.length} inventory items · ${T.materialDependencies.length} resources`)),T.projectId===n)v.setAttribute("aria-current","true");v.onclick=()=>{n=T.projectId,ri("kiln.project",n),r()},c.append(v)}let l=t.find((T)=>T.projectId===n),u=ae("project-detail");if(u.replaceChildren(),!l){u.append(Js("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let h=N("div",void 0,"project-summary"),d=N("div");d.append(N("h2",l.name),N("p",l.brief||"Add a brief to describe what this project should deliver."));let f=N("button","Edit project","secondary");f.onclick=()=>o(l),h.append(d,f),u.append(h);let m=N("p",`${l.projectId} · ${Qt(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(m);let _=N("div",void 0,"project-metrics");for(let[T,v]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let S=N("div");S.append(N("strong",String(T)),N("span",String(v))),_.append(S)}u.append(_);let p=N("div",void 0,"profile-grid");for(let[T,v]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let S=N("div");S.append(N("span",T,"label"),N("p",v)),p.append(S)}u.append(p);let g=N("div",void 0,"palette");for(let T of l.design.palette){let v=N("div",void 0,"swatch"),S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("viewBox","0 0 24 24"),S.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",T.color),S.append(E);let R=N("span",T.role);R.append(N("small",T.color)),v.append(S,R),g.append(v)}if(g.childElementCount)u.append(g);for(let[T,v]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!v.length)continue;u.append(N("h3",T));let S=N("ul",void 0,"subtle");for(let E of v)S.append(N("li",E));u.append(S)}if(u.append(N("h3","Inventory")),!l.inventory.length)u.append(N("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let T=N("div",void 0,"table-wrap"),v=N("table"),S=N("thead"),E=N("tr");for(let x of["Item","Kind","Saved revision","Review"])E.append(N("th",x));S.append(E),v.append(S);let R=N("tbody");for(let x of l.inventory){let w=N("tr"),G=N("td",x.name);G.append(N("small",x.brief));let C=N("td"),D=N("td");if(x.asset){let ee=N("button",Qt(x.asset.revisionId),"secondary");ee.onclick=()=>e.openAsset(x.asset),C.append(ee);let L=[...l.reviews].reverse().find((B)=>B.inventoryId===x.id&&B.asset.revisionId===x.asset.revisionId&&B.asset.assetId===x.asset.assetId&&B.asset.collectionId===x.asset.collectionId);D.append(N("small",L?`${L.verdict} · ${L.reviewer}`:"Unreviewed"));let W=N("button","Record review","secondary");W.onclick=()=>a(l,x),D.append(W)}else C.textContent="Not linked",D.textContent="No saved revision";w.append(G,N("td",x.kind),C,D),R.append(w)}v.append(R),T.append(v),u.append(T)}if(l.design.materialRoles.length){u.append(N("h3","Material roles"));for(let T of l.design.materialRoles)u.append(N("p",`${T.role}: ${T.description||"No description"}${T.resourceId?` · ${T.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(N("h3","Delivery intent"));for(let T of l.deliveryProfiles){if(u.append(N("p",`${T.target} · ${T.description||T.id}`,"subtle")),T.performanceIntent)u.append(N("p",T.performanceIntent,"subtle"));for(let v of T.constraints)u.append(N("p",v,"subtle"))}u.append(N("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(N("h3","Reference records"));for(let T of l.references){let v=N("p",`${T.title}: ${T.uri}`,"subtle");if(T.description)v.append(N("small",` · ${T.description}`));u.append(v)}}u.append(N("h3","Project downloads"));let M=N("div",void 0,"downloads");for(let T of["editable","runtime"]){let v=N("a",T==="editable"?"Download editable project bundle":"Download runtime project bundle"),S=new URLSearchParams({profile:T,revision:l.revisionId});v.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${S}`,v.download=`${l.projectId}-${T}.zip`,M.append(v)}M.append(N("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(M),u.append(Qs("Exact project configuration and review records",l))},s=async()=>{let c=await Xt("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function o(c){i=c,ae("project-editor-title").textContent=c?"Edit project":"New project",ae("project-name").value=c?.name??"",ae("project-brief").value=c?.brief??"",ae("project-style").value=c?.design.style??"",ae("project-scale").value=c?.design.scale??"",ae("project-config").value=JSON.stringify(pb(c??{name:""}),null,2),ae("project-save-status").textContent="",ae("project-editor").showModal(),ae("project-name").focus()}function a(c,l){if(!l.asset)return;let u=N("dialog"),h=N("form"),d=N("div",void 0,"editor-content"),f=N("h2",`Review ${l.name}`);f.id="review-dialog-title",u.setAttribute("aria-labelledby",f.id),d.append(f,N("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),N("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let m=N("input");m.required=!0,m.value=Tr("kiln.reviewer")??"",m.maxLength=200;let _=N("label","Reviewer","field");_.append(m);let p=N("select");for(let[R,x]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])p.append(new Option(x,R));let g=N("label","Assessment","field");g.append(p);let M=N("textarea");M.rows=4,M.maxLength=4000;let T=N("label","Notes","field");T.append(M);let v=N("p");v.setAttribute("role","status");let S=N("button","Save review");S.type="submit";let E=N("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),d.append(_,g,T,v,S,E),h.append(d),u.append(h),document.body.append(u),u.addEventListener("close",()=>u.remove()),h.onsubmit=async(R)=>{R.preventDefault(),S.disabled=!0,v.textContent="Saving review…";try{await Xt(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:m.value.trim(),verdict:p.value,notes:M.value}]}}}),ri("kiln.reviewer",m.value.trim()),u.close(),await s()}catch(x){v.textContent=x instanceof Error?x.message:String(x)}finally{S.disabled=!1}},u.showModal(),m.focus()}return ae("new-project").onclick=()=>o(),ae("close-project-editor").onclick=()=>ae("project-editor").close(),ae("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ae("save-project");l.disabled=!0,ae("project-save-status").textContent="Saving revision…";try{let u=mb(ae("project-config").value,{name:ae("project-name").value,brief:ae("project-brief").value,style:ae("project-style").value,scale:ae("project-scale").value});n=(await Xt(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,ri("kiln.project",n),ae("project-editor").close(),hn("Project revision saved."),await s()}catch(u){ae("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}function _b(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function xb(e){let t=[],n=[],i=[],r=ae("materials-project"),s=N("button","Create from preset");ae("materials-refresh").before(s);let o=N("dialog");o.setAttribute("aria-labelledby","material-preset-heading");let a=N("form"),c=N("div",void 0,"detail-top"),l=N("h2","Create a material resource");l.id="material-preset-heading";let u=N("button","Cancel","secondary");u.type="button",u.onclick=()=>o.close(),c.append(l,u);let h=N("div",void 0,"editor-content");h.append(N("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function d(C,D){let ee=N("label",C,"field");return ee.append(D),h.append(ee),D}let f=d("Preset",N("select")),m=N("p",void 0,"subtle");h.append(m);let _=d("Seed",N("input"));_.type="number",_.step="1",_.required=!0,_.min="-2147483648",_.max="2147483647",_.value="0";let p=d("Map size",N("select"));for(let C of[64,128,256,512])p.append(new Option(`${C} × ${C}`,String(C)));p.value="256";let g=d("Creator",N("input"));g.required=!0,g.maxLength=1000;let M=d("License identifier",N("input"));M.required=!0,M.placeholder="For example, CC0-1.0";let T=d("License URL",N("input"));T.type="url",T.required=!0;let v=d("Attribution text",N("textarea"));v.rows=2;let S=N("p");S.setAttribute("role","status");let E=N("button","Create resource");E.type="submit",h.append(S,E),a.append(c,h),o.append(a),document.body.append(o);let R=()=>{let C=i.find((D)=>D.id===f.value);m.textContent=C?`${C.description} Repeat scale: ${C.physicalSizeMeters.width} × ${C.physicalSizeMeters.height} m.`:""};f.onchange=R,s.onclick=async()=>{s.disabled=!0;try{i=(await Xt("/api/material-presets")).presets,f.replaceChildren(...i.map((C)=>new Option(C.name,C.id))),R(),S.textContent="",E.disabled=!i.length,o.showModal()}catch(C){hn(C)}finally{s.disabled=!1}},a.onsubmit=async(C)=>{C.preventDefault(),E.disabled=!0,S.textContent="Creating immutable material resource…";try{let D=_b({presetId:f.value,seed:_.value,size:p.value,creator:g.value,spdx:M.value,url:T.value,attribution:v.value}),ee=await Xt("/api/materials/preset",{method:"POST",body:D});await G(),o.close(),hn(`${ee.material.name} created at ${ee.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(D){S.textContent=D instanceof Error?D.message:String(D)}finally{E.disabled=!1}};let x=(C)=>`/api/materials/${encodeURIComponent(C.materialId)}/${encodeURIComponent(C.revisionId)}`;function w(){let C=n.find((B)=>B.projectId===r.value),D=ae("material-dependencies");if(D.replaceChildren(),C)if(D.append(N("h2",`${C.name}: locked resources`)),!C.materialDependencies.length)D.append(N("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let B=N("table"),P=N("thead"),J=N("tr"),H=N("tbody");for(let Q of["Resource / role","Exact revision","Local availability"])J.append(N("th",Q));P.append(J),B.append(P);for(let Q of C.materialDependencies){let ge=t.find((fe)=>fe.materialId===Q.resourceId&&fe.revisionId===Q.revisionId),he=N("tr"),de=N("td",Q.resourceId);de.append(N("small",Q.role??C.design.materialRoles.filter((fe)=>fe.resourceId===Q.resourceId).map((fe)=>fe.role).join(", "))),he.append(de,N("td",Q.revisionId,"mono"),N("td",ge&&ge.revisionId===Q.sha256?"Exact local record available":ge?"Dependency hash differs":"Not in local catalog")),H.append(he)}B.append(H);let q=N("div",void 0,"table-wrap");q.append(B),D.append(q)}let ee=ae("material-list");ee.replaceChildren();let L=ae("material-search").value.trim().toLowerCase(),W=t.filter((B)=>`${B.name} ${B.materialId} ${B.tags.join(" ")} ${B.sources.map((P)=>P.provider).join(" ")}`.toLowerCase().includes(L));if(ae("material-count").textContent=`${W.length} material revision${W.length===1?"":"s"}`,!W.length){ee.append(Js(L?"No matching materials":"Your material catalog starts here",L?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let B of W){let P=N("article",void 0,"material-card"),J=B.maps.find((de)=>de.slot==="baseColor")??B.maps[0];if(J){let de=N("img");de.src=`${x(B)}/${encodeURIComponent(J.file)}`,de.alt=`${B.name}: ${J.slot} map, not a shaded material preview`,de.loading="lazy",de.className="material-map",P.append(de,N("p",`${J.slot} map · unshaded`,"subtle"))}P.append(N("h3",B.name),N("p",B.tags.join(" · "),"subtle"));let H=N("dl"),q=(de,fe)=>H.append(N("dt",de),N("dd",fe));q("Revision",B.revisionId),q("Physical scale",B.physicalSizeMeters?`${B.physicalSizeMeters.width} × ${B.physicalSizeMeters.height} m`:"Not specified"),q("Tiling",B.tileable?"Declared tileable":"Not declared tileable"),q("Maps",B.maps.map((de)=>`${de.slot} ${de.width}×${de.height} (${de.colorSpace})`).join(" · ")),q("Surface factors",`Roughness ×${B.parameters.roughness} · Metalness ×${B.parameters.metalness}${B.maps.some((de)=>de.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),P.append(H);for(let de of B.sources){let fe=N("p",`${de.provider} · ${de.creator} · ${de.kind}`,"subtle"),I=N("a",de.license.spdx);if(I.href=de.license.url,I.target="_blank",I.rel="noreferrer",fe.append(document.createTextNode(" · "),I),de.assetUrl){let V=N("a","Source");V.href=de.assetUrl,V.target="_blank",V.rel="noreferrer",fe.append(document.createTextNode(" · "),V)}if(P.append(fe),de.license.attribution)P.append(N("p",de.license.attribution,"subtle"))}let Q=N("div",void 0,"material-map-links");for(let de of B.maps){let fe=N("a",de.slot);fe.href=`${x(B)}/${encodeURIComponent(de.file)}`,fe.target="_blank",fe.rel="noopener",Q.append(fe)}P.append(Q);let ge=C?.materialDependencies.find((de)=>de.resourceId===B.materialId),he=N("button",ge?.revisionId===B.revisionId?"Locked to project":ge?"Use this revision":"Add to project","secondary");if(he.disabled=!C||ge?.revisionId===B.revisionId,!C)he.title="Select a project to add a material dependency";he.onclick=async()=>{if(!C)return;he.disabled=!0;try{let de=C.materialDependencies.filter((fe)=>fe.resourceId!==B.materialId);de.push({resourceId:B.materialId,revisionId:B.revisionId,sha256:B.revisionId,...ge?.role?{role:ge.role}:{}}),await Xt(`/api/projects/${encodeURIComponent(C.projectId)}`,{method:"PATCH",body:{expectedRevision:C.revisionId,patch:{materialDependencies:de}}}),hn(`${B.name} is locked to ${C.name} at this exact revision.`),await e()}catch(de){hn(de),he.disabled=!1}},P.append(he,Qs("Map recipes, transformations and provenance",B)),ee.append(P)}}let G=async()=>{t=(await Xt("/api/materials")).materials,w()};return ae("material-search").oninput=w,r.onchange=w,ae("materials-refresh").onclick=()=>void G().catch(hn),{refresh:G,projects(C){n=C;let D=r.value;r.replaceChildren(new Option("All materials",""));for(let ee of n)r.append(new Option(ee.name,ee.projectId));if(n.some((ee)=>ee.projectId===D))r.value=D;w()}}}function lf(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var vb=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function xa(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(vb),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),o=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&vb(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),a=s?.artifact?s:s?i.filter((c)=>c.artifact&&o(c)).at(-1)??(o(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:a,pinned:r(e.pinned)}}function uf(e,t){return xa({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Ar(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function yb(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Ar(e,Ar(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function bl(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(N("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(N("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let o=await qy(()=>s.measure(3000),i),a=N("div",void 0,"evidence-card");a.append(N("h3","Exploratory browser measurement"),N("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),N("strong",`p50 ${o.frameMs.p50.toFixed(1)} ms · p95 ${o.frameMs.p95.toFixed(1)} ms`),N("p",`${o.frameMs.samples} frame intervals · ${(o.windowMs/1000).toFixed(2)} s · ${o.drawCalls} draws · ${o.triangles.toLocaleString()} rendered triangles`),N("p",`${o.geometryObjects} geometry objects · ${o.textureObjects} texture objects. These counts are not GPU memory bytes.`),N("p",`GLB parse to first frame submission: ${o.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),N("p",`${o.viewport.cssWidth}×${o.viewport.cssHeight} CSS pixels · DPR ${o.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Qs("Exact measurement receipt and limitations",o);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(o,null,2)],{type:"application/json"}));let l=N("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",a.append(c,l),t.replaceChildren(a)}catch(o){t.replaceChildren(N("p",o instanceof Error?o.message:String(o),"subtle"))}finally{e.disabled=!1}}}function hf(e,t,n,i){let r=e.inventory.find((o)=>o.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((o)=>{if(o.id!==t)return o;let{asset:a,...c}=o;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function va(e,t,n,i){e.replaceChildren(N("h3","Project membership"));let{projects:r}=await Xt("/api/projects");if(!e.isConnected)return;let s=N("div");e.append(s);let o=N("p");o.setAttribute("role","status");let a=()=>va(e,t,n,i);for(let _ of r)for(let p of _.inventory){if(!p.asset||p.asset.collectionId!==t.collectionId||p.asset.assetId!==t.assetId)continue;let g=N("div",void 0,"membership-row");g.append(N("span",`${_.name} / ${p.name} · ${Qt(p.asset.revisionId)}${p.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let M=N("button","Remove membership","secondary");M.onclick=async()=>{M.disabled=!0;try{await Xt(`/api/projects/${encodeURIComponent(_.projectId)}`,{method:"PATCH",body:{expectedRevision:_.revisionId,patch:hf(_,p.id,null,n)}}),await i(),await a()}catch(T){o.textContent=`${T instanceof Error?T.message:T} Reopen membership to load the current project.`,M.disabled=!1}},g.append(M),s.append(g)}if(!s.childElementCount)s.append(N("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(N("p","Create a named project in Projects to organize related assets."));return}let c=N("form"),l=N("select"),u=N("select"),h=N("label","Project","field"),d=N("label","Inventory item","field");h.append(l),d.append(u);for(let _ of r)l.append(new Option(_.name,_.projectId));let f=()=>{let _=r.find((g)=>g.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let g of _.inventory)u.append(new Option(`${g.name}${g.asset?" (replace linked revision)":""}`,g.id));let p=_.inventory.find((g)=>g.asset?.collectionId===t.collectionId&&g.asset.assetId===t.assetId);if(p)u.value=p.id};l.onchange=f,f();let m=N("button","Link this exact revision");m.type="submit",c.append(h,d,N("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),m,o),c.onsubmit=async(_)=>{_.preventDefault(),m.disabled=!0;let p=r.find((M)=>M.projectId===l.value),g=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await Xt(`/api/projects/${encodeURIComponent(p.projectId)}`,{method:"PATCH",body:{expectedRevision:p.revisionId,patch:hf(p,g,t,n)}}),await i(),await a()}catch(M){o.textContent=`${M instanceof Error?M.message:M} Reopen membership to load the current project.`,m.disabled=!1}},s.append(c)}function bb(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,o=0,a,c,l,u,h,d,f,m=0,_=0,p=!1,g=!1,M=ae("live-project"),T=ae("live-source"),v=(I)=>T.value?`${I}${I.includes("?")?"&":"?"}source=${encodeURIComponent(T.value)}`:I,S=ae("live-run"),E=ae("live-work"),R=()=>`kiln.live.selection.${T.value}.${M.value}.${E.value}.${S.value}`,x=()=>`kiln.live.pin.${T.value}`,w=()=>t.filter((I)=>(!S.value||I.sessionId===S.value)&&(!E.value||(E.value==="ungrouped"?!I.workId:I.workId===E.value))),G=(I,V)=>{let j=ae("live-connection");j.textContent=I?"Connected":"Reconnecting",j.className=`pill ${I?"connected":"warning"}`,ae("connection-status").textContent=V};function C(){let I=E.value,V=[...new Set(t.flatMap((oe)=>oe.workId?[oe.workId]:[]))];if(E.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...V.map((oe)=>new Option(oe,oe))),I==="ungrouped"||V.includes(I))E.value=I;let j=S.value,re=[...new Set(t.map((oe)=>oe.sessionId))];S.replaceChildren(new Option("All runs",""));for(let oe of re){let ue=t.find(($e)=>$e.sessionId===oe);S.append(new Option(`${ue.transport} · ${Qt(oe)}`,oe))}if(re.includes(j))S.value=j}function D(){let I=ae("live-timeline"),V=I.scrollTop,j=I.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(I.replaceChildren(),!e.operations.length){I.append(Js("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let re of[...e.operations].reverse()){let oe=N("button",void 0,`timeline-item ${re.status}${e.selected?.operationId===re.operationId?" selected":""}${re.pinned?" pinned":""}`);oe.dataset.operation=re.operationId;let ue=N("span",void 0,"timeline-meta");if(ue.append(N("span",re.transport.toUpperCase()),N("time",new Date(re.startedAt).toLocaleTimeString())),oe.append(ue,N("strong",re.tool.replace(/^kiln_/,"")),N("small",`${re.status} · ${re.artifact?"artifact available":"no artifact"}`),N("small",re.workId?`Item ${re.workId}`:`Ungrouped · run ${Qt(re.sessionId)}`)),oe.setAttribute("aria-label",`${re.tool}, ${re.status}, ${new Date(re.startedAt).toLocaleString()}`),e.selected?.operationId===re.operationId)oe.setAttribute("aria-current","true");if(oe.onclick=()=>{e=uf(e,re.operationId),ri(R(),re.operationId),q()},I.append(oe),j===re.operationId)oe.focus({preventScroll:!0})}I.scrollTop=V}function ee(I){let V=N("div",void 0,"evidence-card");V.append(N("h3","Capture fidelity"));let j=I.viewFidelity,re=j&&typeof j==="object"?j:void 0;if(V.append(N("strong",re?String(re.delivered??"Reported"):"No capture receipt yet")),V.append(N("p",re?.materialFaithful===!0?"Material-faithful capture reported.":re?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),re?.degradeReason)V.append(N("p",String(re.degradeReason)));if(re?.rendererId)V.append(N("p",`Renderer: ${String(re.rendererId)}`,"mono"));if(re?.inputGlbSha256)V.append(N("p",`Capture input: ${String(re.inputGlbSha256)}`,"mono"));if(re)V.append(N("p",re.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return V}function L(){let I=ae("live-evidence"),V=ae("live-downloads");I.replaceChildren(),V.replaceChildren();let j=e.displayed;if(!j?.artifact)return;let re=N("div",void 0,"evidence-card");if(re.append(N("h3","Selected observed artifact"),N("strong",`${(j.artifact.bytes/1024).toFixed(0)} KB GLB`),N("p",j.artifact.sha256,"mono"),N("p",`Source: ${j.programRef??"See authored source download"}`,"mono")),I.append(re,ee(j)),j.captures.length)for(let oe of j.captures){let ue=N("div",void 0,"evidence-card");ue.append(N("h3",oe.name));let $e=j.viewFidelity&&typeof j.viewFidelity==="object"?j.viewFidelity:void 0;ue.append(N("p",$e?.materialFaithful===!0?`Recorded capture · ${String($e.delivered??"material-faithful")}`:`Recorded capture · ${String($e?.delivered??"fidelity unreported")}. Materials are not verified.`,$e?.materialFaithful===!0?"subtle":"warning"));let Ce=N("a"),He=N("img");He.src=oe.url,He.alt=`Recorded ${oe.name} for ${j.tool}`,He.loading="lazy",Ce.href=oe.url,Ce.target="_blank",Ce.rel="noopener",Ce.append(He),ue.append(Ce,N("p",oe.sha256,"mono")),I.append(ue)}else{let oe=N("div",void 0,"evidence-card");oe.append(N("h3","Recorded captures"),N("p",j.status==="evaluated"||j.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),I.append(oe)}for(let[oe,ue,$e]of[[j.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(j.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let Ce=N("a",ue);Ce.href=oe,Ce.download=$e,V.append(Ce)}V.append(N("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function W(){let I=Ar(e.displayed,l);ae("pin-build").disabled=!I,he.disabled=I?.status!=="complete"}function B(){if(h&&l)ae("live-stage-label").textContent=lf(h,Qt(l.operationId),a?.lod())}function P(){if(d&&u)ae("compare-stage-label").textContent=`Pinned · ${lf(d,Qt(u.operationId),c?.lod())}`}async function J(I){if(ae("live-panel").hidden)return;let V=++m;if(!Ar(I,l))a?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!I?.artifact){ae("live-performance").replaceChildren(),a?.dispose(),a=void 0,l=void 0,h=void 0,ae("live-level-field").hidden=!0,ae("live-lod").replaceChildren(),ae("live-lod").hidden=!0,ae("live-stage-status").textContent="No completed artifact available for this run.",ae("live-stage-label").textContent="Current",W();return}if(l?.artifact?.sha256===I.artifact.sha256){l=I,ae("live-stage-status").textContent="",B(),W();return}ae("live-stage-status").textContent=`Loading ${Qt(I.operationId)}…${l?` Previous artifact ${Qt(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let j=await fetch(I.artifact.url);if(!j.ok)throw Error("This retained artifact is no longer available");let re=new Uint8Array(await j.arrayBuffer());if(V!==m)return;a??=ga(ae("live-stage"));let oe=await a.load(re,{isCurrent:()=>V===m,onCommit:()=>{l=I},preserveView:l?.projectId===I.projectId&&(l?.sessionId===I.sessionId||e.following)});if(!oe||V!==m)return;ae("live-performance").replaceChildren(),l=I,h=oe,W();let ue=ae("live-level");if(ae("live-level-field").hidden=!oe.levels,_a(ue,ae("live-lod"),a,($e)=>{if($e!==void 0)c?.level($e),f?.refresh(),P();B()}),a.wire(p),a.navigation(ae("live-navigation").value),ae("live-stage-status").textContent="",B(),c)c.setView(a.view())}catch(j){if(V!==m)return;ae("live-stage-status").textContent=`${j instanceof Error?j.message:j}.${l?` Previous artifact ${Qt(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,W()}}async function H(I){if(ae("live-panel").hidden)return;let V=++_;if(ae("compare-viewport").hidden=!I?.artifact,ae("review-viewports").classList.toggle("comparing",!!I?.artifact),!I?.artifact){c?.dispose(),c=void 0,u=void 0,d=void 0,f=void 0,ae("compare-lod").replaceChildren(),ae("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===I.artifact.sha256){u=I,P(),ae("compare-stage-status").textContent="";return}if(!u)ae("compare-stage-label").textContent="Comparison";ae("compare-stage-status").textContent=`Loading pinned ${Qt(I.operationId)}…`;try{let j=await fetch(I.artifact.url);if(!j.ok)throw Error("Pinned artifact unavailable");let re=new Uint8Array(await j.arrayBuffer());if(V!==_)return;c??=ga(ae("compare-stage"));let oe=await c.load(re,{preserveView:!0,isCurrent:()=>V===_,onCommit:()=>{u=I}});if(!oe||V!==_)return;if(u=I,d=oe,a)c.setView(a.view());let ue=Number(ae("live-level").value||0);c.level(Number.isFinite(ue)?ue:0),ae("compare-level-field").hidden=!oe.levels,f=_a(ae("compare-level"),ae("compare-lod"),c,P),P(),c.wire(p),c.navigation(ae("live-navigation").value),ae("compare-stage-status").textContent=""}catch(j){if(V===_)ae("compare-stage-status").textContent=`${j instanceof Error?j.message:String(j)}.${u?` Previous comparison ${Qt(u.operationId)} remains visible.`:""}`}}function q(){D();let I=e.selected,V=e.displayed,j=ae("follow-latest");j.textContent=e.following?"Following latest":"Follow latest",j.setAttribute("aria-pressed",String(e.following));let re=ae("live-current-summary");if(re.replaceChildren(),I){re.append(N("h2",I.tool.replace(/^kiln_/,"")),N("p",`${I.status} · ${I.transport} · Run ${Qt(I.sessionId)} · ${new Date(I.updatedAt).toLocaleString()}`));let $e=N("div",void 0,"tags");if(I.projectId)$e.append(N("span",I.projectId,"tag"));for(let Ce of I.phases)$e.append(N("span",Ce.phase,"tag"));re.append($e)}else re.append(N("h2","No build selected"),N("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let oe=I&&"observationIssues"in I&&Array.isArray(I.observationIssues)?I.observationIssues.map(String):[],ue=[I?.error,...oe,I&&V&&I.operationId!==V.operationId?`Current ${I.status} operation has no retained artifact. Showing the last successful artifact ${Qt(V.operationId)} from run ${Qt(V.sessionId)}.`:"",I&&!e.operations.some(($e)=>$e.operationId===I.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ae("live-failure").textContent=ue.join(" "),ae("live-failure").hidden=!ue.length,W(),ae("clear-pin").hidden=!e.pinned,ae("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ae("live-record").textContent=JSON.stringify({selected:I,displayedArtifactOperation:V?.operationId,pinnedOperation:e.pinned?.operationId},null,2),L(),J(V),H(e.pinned)}async function Q(){if(r)return;r=!0;let I=i;try{let V=new URLSearchParams;if(M.value)V.set("project",M.value);if(n)V.set("cursor",n);let j=await Xt(v(`/api/live?${V}`));if(I!==i)return;if(o=0,G(!0,"Connected · checks every 2 seconds"),n=j.cursor,ae("live-history-note").textContent=`Up to ${j.retention.maxOperations} operations`,ae("live-history-issues").textContent=j.observationIssues?.join(" ")??"",ae("live-history-issues").hidden=!j.observationIssues?.length,!j.unchanged){if(t=j.operations,C(),e=xa(e,w()),!g){g=!0;let re=Tr(R());if(re&&e.operations.some((ue)=>ue.operationId===re))e=uf(e,re);let oe=Tr(x());e.pinned=t.find((ue)=>ue.operationId===oe&&ue.pinned)??[...t].reverse().find((ue)=>ue.pinned&&ue.artifact)}q()}}catch(V){o++,G(!1,`Connection lost. Retrying; retained views remain available. ${V instanceof Error?V.message:V}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void Q(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(o,4)))}}M.onchange=()=>{i++,n="",t=[],g=!1,S.replaceChildren(new Option("All runs","")),E.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),Q()},T.onchange=()=>{M.value="",e.pinned=void 0,M.dispatchEvent(new Event("change"))},Xt("/api/live-sources").then(({sources:I})=>{T.replaceChildren(...I.map((V)=>new Option(V.label,V.id)))}).catch(hn),S.onchange=()=>{e=xa({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!S.value},w()),q()},E.onchange=()=>S.dispatchEvent(new Event("change")),ae("follow-latest").onclick=()=>{e=xa({...e,following:!e.following},w()),ri(R(),e.following?"":e.selected?.operationId??""),q()},ae("live-refresh").onclick=()=>{n="",Q(),q()},ae("pin-build").onclick=async()=>{let I=Ar(e.displayed,l);if(!I?.artifact)return;let V=ae("pin-build");V.disabled=!0;try{await Xt(v(`/api/live/${encodeURIComponent(I.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...I,pinned:!0},ri(x(),I.operationId),n="",q(),Q()}catch(j){hn(j),W()}},ae("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await Xt(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,ri(x(),""),n="",q(),Q()}catch(I){hn(I)}},ae("live-frame").onclick=()=>{if(a?.reset(),a)c?.setView(a.view())},ae("live-wire").onclick=()=>{p=!p,a?.wire(p),c?.wire(p),ae("live-wire").setAttribute("aria-pressed",String(p))};let ge=N("button","Match comparison camera","secondary");ge.onclick=()=>{if(a)c?.setView(a.view())},ae("live-frame").parentElement?.append(ge);let he=N("button","Save exact artifact");he.disabled=!0,ae("live-frame").parentElement?.prepend(he);let de=N("button","Measure 3 s","secondary"),fe=N("div");return fe.id="live-performance",ae("live-evidence").after(fe),ae("live-frame").parentElement?.append(de),bl(de,fe,()=>a,()=>Ar(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),he.onclick=()=>{let I=Ar(e.displayed,l);if(I?.status!=="complete")return;let V=N("dialog"),j=N("form"),re=N("div",void 0,"editor-content"),oe=N("h2","Save reviewed artifact");oe.id="save-review-title",V.setAttribute("aria-labelledby",oe.id),re.append(oe,N("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),N("p",`${I.operationId} · revision ${I.revision}`,"mono"),N("p",I.artifact.sha256,"mono"));let ue=N("input");ue.required=!0,ue.maxLength=200,ue.value="";let $e=N("label","Asset name","field");$e.append(ue);let Ce=N("p");Ce.setAttribute("role","status");let He=N("button","Save exact artifact");He.type="submit";let rt=N("button","Cancel","secondary");rt.type="button",rt.onclick=()=>V.close(),re.append($e,Ce,He,rt),j.append(re),V.append(j),document.body.append(V),V.addEventListener("close",()=>V.remove()),j.onsubmit=async(nt)=>{nt.preventDefault(),He.disabled=!0,Ce.textContent="Saving retained bytes…";try{let Rt=yb(I,ue.value,l,e.displayed),it=await Xt(v(Rt.path),{method:"POST",body:Rt.body});Ce.replaceChildren(N("span",`Saved ${it.asset.assetId} / ${it.asset.revisionId}. `));let tn=N("a","Open saved revision"),Ut=new URLSearchParams({collection:it.collection,asset:it.asset.assetId,revision:it.asset.revisionId});tn.href=`/?${Ut}`,Ce.append(tn);let It=N("div");re.append(It),va(It,{collectionId:it.collection,assetId:it.asset.assetId,revisionId:it.asset.revisionId},it.asset.name,async()=>{}).catch((O)=>{It.textContent=`Asset saved; membership unavailable: ${O instanceof Error?O.message:O}. Open the saved asset in Library to link it.`}),ue.disabled=!0,He.textContent="Saved",rt.textContent="Close"}catch(Rt){Ce.textContent=Rt instanceof Error?Rt.message:String(Rt),He.disabled=!1}},V.showModal(),ue.focus()},ae("live-navigation").onchange=(I)=>{let V=I.target.value;a?.navigation(V),c?.navigation(V),ae("live-navigation-help").textContent=V==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",Q()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)Q()}),Q(),{activate:q,projects(I){let V=M.value;M.replaceChildren(new Option("All work",""));for(let j of I)M.append(new Option(j.name,j.projectId));if(I.some((j)=>j.projectId===V))M.value=V}}}var df=["projects","live","library","materials"];function Sb(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";return t&&df.some((i)=>i===t)?t:"library"}function wb(e,t=()=>{}){let n=df;function i(c){if(!n.includes(c))return;for(let l of n)ae(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(ri("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(hn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ae("open-files").onclick=()=>ae("open").click();let r=bb(),s=xb(()=>o.refresh()),o=gb({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(Sb(location.search,Tr("kiln.section"))),o.refresh().catch(hn),s.refresh().catch(hn);let a=!1;return window.setInterval(async()=>{if(document.hidden||a||ae("project-editor").open)return;a=!0;try{await o.refresh()}catch{}finally{a=!1}},5000),{library:()=>i("library"),refreshProjects:o.refresh}}var Ci=(e)=>`${e.collection}/${e.manifest.assetId}`;function Mb(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((o)=>o.asset?[`${o.asset.collectionId}/${o.asset.assetId}`]:[])));return e.filter((s)=>!r.has(Ci(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${Ci(r)}/${r.manifest.revisionId}`))}var Le=(e)=>document.getElementById(e),lt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},wa=[],Sa=[],Pr=[],is=[],Sl="",Cr,Ii,en,Rr=0,Eb=0,ya=!1,ba=!1,Ir=new Set,gf=[],Tb=[],ji=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,pf=(e)=>{Le("status").textContent=e},Pi=(e)=>pf(e instanceof Error?e.message:String(e)),rs=(e,t,n=gf)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function mf(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function ff(e,t){if(e.local){let i=e.local.files[t];if(!i)throw Error("File unavailable");return i}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${ji(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function kC(e,t){if(e.local){if(t==="editable.zip")return rs(Bu([e.local]),"application/zip");return rs(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return rs(e.loose,"model/gltf-binary");return`/files/${ji(e)}/${t}?download`}function Ab(e,t){try{localStorage.setItem(e,t)}catch{}}function BC(e){try{return localStorage.getItem(e)}catch{return null}}function GC(){let e=Le("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...wa,...is.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=lt("button",t.label,Sl===t.id?"active":"");n.onclick=()=>void no(t.id).catch(Pi),e.append(n)}}async function no(e,t=!0){if(t)Cb.library();let n=++Eb;Sl=e,Ir.clear(),GC(),pf("");let i=e==="all"?await(async()=>{let r=await mf("/api/library");if(r.errors.length)pf(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?is:(await mf(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==Eb)return;Pr=i,Ab("kiln.collection",e),Le("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":wa.find((r)=>r.id===e)?.label??e,Le("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",wl()}function HC(){let e=new Map;for(let t of Mb(Pr,Sa,Le("library-project").value)){let n=Ci(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===BC(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function wl(){for(let i of Tb.splice(0))URL.revokeObjectURL(i);let e=Le("cards");e.replaceChildren();let t=Le("search").value.toLowerCase(),n=HC().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Le("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Le("export-selection").disabled=!Ir.size,!n.length){let i=lt("div",void 0,"empty");if(i.append(lt("b",t?"No matching assets":"Your next idea belongs here."),lt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(lt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=lt("article",void 0,"card"),o=lt("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void Ma(i).catch(Pi);let a=lt("div",void 0,"thumb");if(r.files["preview.png"]){let m=lt("img");m.loading="lazy",m.alt=r.name,m.src=i.local?rs(i.local.files["preview.png"],"image/png",Tb):`/files/${ji(i)}/preview.png`,m.onerror=()=>{m.remove(),a.textContent="◇"},a.append(m)}else a.textContent="◇";let c=lt("div",void 0,"card-content");c.append(lt("span",r.name,"card-title"));let l=Pr.filter((m)=>Ci(m)===Ci(i)),u=new Set(l.map((m)=>m.manifest.parentRevision)),h=l.filter((m)=>!u.has(m.manifest.revisionId));c.append(lt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${h.length>1?` · ${h.length} branches`:""}`,"card-meta"));let d=lt("div",void 0,"tags");for(let m of r.tags)d.append(lt("span",m,"tag"));c.append(d),c.append(lt("small",wa.find((m)=>m.id===i.collection)?.label??i.collection,"card-meta"));let f=Sa.filter((m)=>m.inventory.some((_)=>_.asset&&_.asset.collectionId===i.collection&&_.asset.assetId===r.assetId));if(c.append(lt("small",f.length?f.map((m)=>m.name).join(" · "):"No project membership","card-meta")),o.append(a,c),s.append(o),!i.loose){let m=lt("input");m.type="checkbox",m.className="selection",m.checked=Ir.has(ji(i)),m.setAttribute("aria-label",`Select ${r.name}`),m.onchange=()=>{if(m.checked)Ir.add(ji(i));else Ir.delete(ji(i));Le("export-selection").disabled=!Ir.size},s.append(m)}e.append(s)}}async function Ma(e){let t=++Rr;Cr=e,Ii=void 0,en?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Le("library-performance").replaceChildren(),Ab(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let l of gf.splice(0))URL.revokeObjectURL(l);let n=Le("detail");if(!n.open)n.showModal();Le("asset-name").textContent=e.manifest.name;let i=Le("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let l=lt("div");i.append(l),va(l,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,Cb.refreshProjects).catch(Pi)}let r=Le("revisions");r.replaceChildren();for(let l of Pr.filter((u)=>Ci(u)===Ci(e))){let u=lt("option",`${new Date(l.manifest.createdAt).toLocaleString()} · ${l.manifest.description||l.manifest.revisionId.slice(0,10)}`);u.value=l.manifest.revisionId,u.selected=l.manifest.revisionId===e.manifest.revisionId,r.append(u)}r.onchange=()=>{let l=Pr.find((u)=>Ci(u)===Ci(e)&&u.manifest.revisionId===r.value);if(l)Ma(l).catch(Pi)},Le("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Le("asset-attribution");s.replaceChildren();for(let l of k0(e.manifest)){let u=lt("div");u.append(lt("span",l.label),lt("strong",l.value)),s.append(u)}s.hidden=!s.childElementCount,Le("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Le("downloads");o.replaceChildren();for(let[l,u]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let h=lt("a",u);h.href=kC(e,l),h.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${l==="asset.glb"?".glb":l==="source.kiln.js"?".kiln.js":".zip"}`,o.append(h)}if(!e.loose){let l=lt("button","Runtime GLB"),u=lt("span");u.setAttribute("role","status"),l.onclick=async()=>{l.disabled=!0,u.textContent="Preparing runtime download…";try{let h=e.local?await ab(e.local,{profile:"runtime"}):void 0,[d,f]=h?.profile==="runtime"?[h.glb,h.metadata.bytes]:await Promise.all([ff(e,"runtime.glb"),ff(e,"runtime.kiln-metadata.json")]);if(t!==Rr)return;let m=lt("a","Runtime GLB");m.href=rs(d,"model/gltf-binary"),m.download="runtime.glb";let _=lt("a","Runtime metadata");_.href=rs(f,"application/json"),_.download="runtime.kiln-metadata.json",l.replaceWith(m,_),u.textContent="Keep the companion metadata for traceability.",m.click()}catch(h){if(t!==Rr)return;u.textContent=`Runtime export unavailable: ${h instanceof Error?h.message:h}`,l.disabled=!1}},o.append(l,u),o.append(lt("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Le("refine").disabled=!e.manifest.editable,Le("asset-stats").replaceChildren(),Le("stage-status").textContent="Loading saved GLB…",ya=!1,ba=!1,Le("wire").setAttribute("aria-pressed","false"),Le("play").textContent="Pause";let a=Le("animation");a.replaceChildren(new Option("Rest pose","")),Le("play").disabled=!0;let c=Le("level");c.replaceChildren(),c.hidden=!0,Le("library-lod").replaceChildren(),Le("library-lod").hidden=!0;try{en??=ga(Le("stage"));let l=await ff(e,"asset.glb");if(t!==Rr)return;let u=await en.load(l,{isCurrent:()=>t===Rr,onCommit:()=>{Ii=e}});if(!u||t!==Rr)return;Ii=e,en.wire(!1),en.navigation(Le("library-navigation").value),en.lighting(Le("lighting").value),_a(c,Le("library-lod"),en);for(let[h,d]of[...u.levels?u.levels.map((f,m)=>[f.toLocaleString(),`LOD${m} triangles`]):[[u.triangles.toLocaleString(),"triangles"]],[u.meshes,u.levels?"LOD0 meshes":"meshes"],[u.materials,u.levels?"LOD0 materials":"materials"],[`${(l.length/1024).toFixed(0)} KB`,"GLB"]]){let f=lt("div");f.append(lt("strong",String(h)),lt("span",String(d))),Le("asset-stats").append(f)}for(let h=0;h<u.clips.length;h++)a.append(new Option(u.clips[h],String(h)));Le("stage-status").textContent=""}catch(l){if(t===Rr)en?.dispose(),en=void 0,Le("stage-status").textContent=`3D preview unavailable: ${l instanceof Error?l.message:l}. Downloads remain available.`}}async function Rb(e){for(let t of e){if(t.bytes.length>Un)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of z0(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((o)=>o.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!is.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))is.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;is.push({collection:"opened-files",loose:t.bytes,manifest:{version:"kiln.asset.v1",assetId:n,revisionId:`r_${n}`,name:t.name.replace(/\.glb$/i,""),tags:[],createdAt:new Date().toISOString(),editable:!1,files:{}}})}}await no("opened-files")}Le("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Un))throw Error("File exceeds 64 MiB");await Rb(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Pi(t)}};Le("refresh").onclick=()=>void no(Sl).catch(Pi);Le("search").oninput=wl;Le("library-project").onchange=()=>void no("all").catch(Pi);Le("close-detail").onclick=()=>Le("detail").close();Le("detail").addEventListener("close",()=>{Rr++,Ii=void 0,en?.dispose(),en=void 0;for(let e of gf.splice(0))URL.revokeObjectURL(e);wl()});Le("frame").onclick=()=>en?.reset();Le("wire").onclick=()=>{ya=!ya,en?.wire(ya),Le("wire").setAttribute("aria-pressed",String(ya))};Le("lighting").onchange=(e)=>en?.lighting(e.target.value);Le("library-navigation").onchange=(e)=>{let t=e.target.value;en?.navigation(t),Le("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Le("animation").onchange=(e)=>{let t=e.target.value;en?.clip(t===""?-1:Number(t)),Le("play").disabled=t===""};Le("play").onclick=()=>{ba=!ba,en?.pause(ba),Le("play").textContent=ba?"Play":"Pause"};Le("refine").onclick=async()=>{if(!Cr)return;let e=Cr.manifest,t=Cr.local?`Import the downloaded editable bundle using kiln import <bundle.zip>. Restore asset ${e.assetId}, revision ${e.revisionId}, using kiln_assets action=restore. Read its source with kiln_source, refine it with kiln_edit, review the result, and save a child revision with kiln_save. Requested change: `:`Use kiln_assets with action=restore, collection=${Cr.collection}, assetId=${e.assetId}, revisionId=${e.revisionId}. Read the returned programRef with kiln_source, refine it with kiln_edit, review the result, and save with kiln_save using assetId=${e.assetId}, parentRevision=${e.revisionId}, collection=${Cr.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Le("refine").textContent="Instructions copied"}catch{Le("provenance").textContent=t,Le("provenance").parentElement?.setAttribute("open","")}};Le("export-selection").onclick=()=>{try{let e=lt("a");if(Sl==="opened-files")e.href=rs(Bu(Pr.filter((t)=>Ir.has(ji(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Ir)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Pi(e)}};async function VC(){wa=(await mf("/api/collections")).collections;let e=rb(location.search);if(await no(wa.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Pr.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Ma(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await Rb([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),is.length===1)await Ma(is[0])}}var Cb=wb((e)=>{(async()=>{await no(e.collectionId);let t=Pr.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Ma(t)})().catch(Pi)},(e)=>{Sa=e;let t=Le("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of Sa)t.append(new Option(i.name,i.projectId));if(n==="standalone"||Sa.some((i)=>i.projectId===n))t.value=n;wl()});bl(Le("measure-library"),Le("library-performance"),()=>en,()=>Ii&&Cr&&ji(Ii)===ji(Cr)?{collection:Ii.collection,assetId:Ii.manifest.assetId,revisionId:Ii.manifest.revisionId,glbSha256:Ii.manifest.files["asset.glb"]?.sha256}:void 0);VC().catch(Pi);
diff --git a/dist/viewer/chat.html b/dist/viewer/chat.html
index d1f007aa..ddc597a3 100644
--- a/dist/viewer/chat.html
+++ b/dist/viewer/chat.html
@@ -122,13 +122,13 @@
</div>
<p id="status" role="status">Loading asset from Kiln…</p>
<script type="module">
- var fd="186",Wi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Zi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dd=0,fl=1,pd=2;var ks=1,md=2,is=3,Xi=0,Qt=1,Cn=2,ii=0,Bs=1,dl=2,pl=3,ml=4,gd=5;var rs=100,_d=101,xd=102,yd=103,vd=104,bd=200,Sd=201,Md=202,wd=203,Ed=204,Td=205,Ad=206,Rd=207,Cd=208,Pd=209,Id=210,Ld=211,Nd=212,Dd=213,Od=214,Ud=0,Fd=1,zd=2,gl=3,kd=4,Bd=5,Gd=6,Hd=7,Vd=0,$d=1,Wd=2,Gn=0,_l=1,xl=2,yl=3,Gs=4,vl=5,bl=6,Sl=7;var ss=301,yr=302,xa=303,ya=304,Hs=306,os=1000,as=1001,va=1002,Hn=1003,ba=1004;var vr=1005;var $t=1006,cs=1007;var ri=1008;var Vn=1009,Zd=1010,Xd=1011,Vs=1012,Ml=1013,qi=1014,Ai=1015,si=1016,wl=1017,El=1018,ls=1020,qd=35902,jd=35899,Yd=1021,Kd=1022,oi=1023,br=1026,Sr=1027,Jd=1028,Tl=1029,Mr=1030,Al=1031;var Rl=1033,Sa=33776,Ma=33777,wa=33778,Ea=33779,Cl=35840,Pl=35841,Il=35842,Ll=35843,Nl=36196,Dl=37492,Ol=37496,Ul=37488,Fl=37489,Ta=37490,zl=37491,kl=37808,Bl=37809,Gl=37810,Hl=37811,Vl=37812,$l=37813,Wl=37814,Zl=37815,Xl=37816,ql=37817,jl=37818,Yl=37819,Kl=37820,Jl=37821,Ql=36492,eu=36494,tu=36495,nu=36283,iu=36284,Aa=36285,ru=36286;var su=2300,Ra=2301;var ou=0,$s=1,us=2;var au=0,Qd=1,wr="",ji="srgb",gn="srgb-linear",cu="linear",pt="srgb";var ep=512,tp=513,np=514,Ca=515,ip=516,rp=517,Pa=518,sp=519;var lu="300 es",uu=2000;function xv(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function yv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function es(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function op(){let e=es("canvas");return e.style.display="block",e}var Cf={},ts=null;function zs(...e){let t="THREE."+e.shift();if(ts)ts("log",t,...e);else console.log(t,...e)}function ap(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Pe(...e){e=ap(e);let t="THREE."+e.shift();if(ts)ts("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Fe(...e){e=ap(e);let t="THREE."+e.shift();if(ts)ts("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function _r(...e){let t=e.join(" ");if(t in Cf)return;Cf[t]=!0,Pe(...e)}function cp(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var lp={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class $n{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var Kt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Pf=1234567,Us=Math.PI/180,xr=180/Math.PI;function Bn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Kt[e&255]+Kt[e>>8&255]+Kt[e>>16&255]+Kt[e>>24&255]+"-"+Kt[t&255]+Kt[t>>8&255]+"-"+Kt[t>>16&15|64]+Kt[t>>24&255]+"-"+Kt[n&63|128]+Kt[n>>8&255]+"-"+Kt[n>>16&255]+Kt[n>>24&255]+Kt[i&255]+Kt[i>>8&255]+Kt[i>>16&255]+Kt[i>>24&255]).toLowerCase()}function We(e,t,n){return Math.max(t,Math.min(n,e))}function hu(e,t){return(e%t+t)%t}function vv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function bv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Fs(e,t,n){return(1-n)*e+n*t}function Sv(e,t,n,i){return Fs(e,t,1-Math.exp(-n*i))}function Mv(e,t=1){return t-Math.abs(hu(e,t*2)-t)}function wv(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Ev(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Tv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Av(e,t){return e+Math.random()*(t-e)}function Rv(e){return e*(0.5-Math.random())}function Cv(e){if(e!==void 0)Pf=e;let t=Pf+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Pv(e){return e*Us}function Iv(e){return e*xr}function Lv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Nv(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Dv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ov(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Pe("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function kn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function at(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Ws={DEG2RAD:Us,RAD2DEG:xr,generateUUID:Bn,clamp:We,euclideanModulo:hu,mapLinear:vv,inverseLerp:bv,lerp:Fs,damp:Sv,pingpong:Mv,smoothstep:wv,smootherstep:Ev,randInt:Tv,randFloat:Av,randFloatSpread:Rv,seededRandom:Cv,degToRad:Pv,radToDeg:Iv,isPowerOfTwo:Lv,ceilPowerOfTwo:Nv,floorPowerOfTwo:Dv,setQuaternionFromProperEuler:Ov,normalize:at,denormalize:kn};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ht{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Pe("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{static{D.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(If.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(If.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Gc.copy(this).projectOnVector(e),this.sub(Gc)}reflect(e){return this.sub(Gc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Gc=new D,If=new Ht;class ke{static{ke.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],v=i[2],M=i[5],T=i[8];return r[0]=s*g+o*m+a*v,r[3]=s*x+o*E+a*M,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*v,r[4]=c*x+l*E+u*M,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*v,r[5]=f*x+h*E+d*M,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return _r("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Hc.makeScale(e,t)),this}rotate(e){return _r("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Hc.makeRotation(-e)),this}translate(e,t){return _r("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Hc.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Hc=new ke,Lf=new ke().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Nf=new ke().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Uv(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Ti(r.r),r.g=Ti(r.g),r.b=Ti(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=Qr(r.r),r.g=Qr(r.g),r.b=Qr(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return _r("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return _r("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Lf,fromXYZ:Nf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Lf,fromXYZ:Nf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=Uv();function Ti(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Qr(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var kr;class fu{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(kr===void 0)kr=es("canvas");kr.width=e.width,kr.height=e.height;let i=kr.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=kr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=es("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Ti(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Ti(t[n]/255)*255);else t[n]=Ti(t[n]);return{data:t,width:e.width,height:e.height}}else return Pe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Fv=0;class Zs{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Fv++}),this.uuid=Bn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Vc(i[s].image));else r.push(Vc(i[s]))}else r=Vc(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Vc(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return fu.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Pe("Texture: Unable to serialize Texture."),{}}var zv=0,$c=new D;class At extends $n{constructor(e=At.DEFAULT_IMAGE,t=At.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=At.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:zv++}),this.uuid=Bn(),this.name="",this.source=new Zs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize($c).x}get height(){return this.source.getSize($c).y}get depth(){return this.source.getSize($c).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Pe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Pe(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=300;At.DEFAULT_ANISOTROPY=1;class ct{static{ct.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,v=(p+1)/2,M=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>v)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=M/n,r=T/n;else if(R>v)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=M/i,r=A/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class du extends $n{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new At(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Zs(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends du{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Ia extends At{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class pu extends At{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Br.setFromMatrixColumn(e,0).length(),r=1/Br.setFromMatrixColumn(e,1).length(),s=1/Br.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kv,e,Bv)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),zi.crossVectors(n,pn),zi.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),zi.crossVectors(n,pn)}return zi.normalize(),$o.crossVectors(pn,zi),i[0]=zi.x,i[4]=$o.x,i[8]=pn.x,i[1]=zi.y,i[5]=$o.y,i[9]=pn.y,i[2]=zi.z,i[6]=$o.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],v=n[15],M=i[0],T=i[4],A=i[8],_=i[12],S=i[1],k=i[5],C=i[9],U=i[13],ee=i[2],P=i[6],V=i[10],j=i[14],z=i[3],H=i[7],F=i[11],q=i[15];return r[0]=s*M+o*S+a*ee+c*z,r[4]=s*T+o*k+a*P+c*H,r[8]=s*A+o*C+a*V+c*F,r[12]=s*_+o*U+a*j+c*q,r[1]=l*M+u*S+f*ee+h*z,r[5]=l*T+u*k+f*P+h*H,r[9]=l*A+u*C+f*V+h*F,r[13]=l*_+u*U+f*j+h*q,r[2]=d*M+g*S+x*ee+p*z,r[6]=d*T+g*k+x*P+p*H,r[10]=d*A+g*C+x*V+p*F,r[14]=d*_+g*U+x*j+p*q,r[3]=m*M+E*S+R*ee+v*z,r[7]=m*T+E*k+R*P+v*H,r[11]=m*A+E*C+R*V+v*F,r[15]=m*_+E*U+R*j+v*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,v=s*h-c*l,M=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*v+p*M)+i*(d*E-g*v+p*T)-r*(d*R-g*M+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,v=n*a-i*o,M=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,S=l*p-h*d,k=u*x-f*g,C=u*p-h*g,U=f*p-h*x,ee=m*U-E*C+R*k+v*S-M*_+T*A;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let P=1/ee;return e[0]=(o*U-a*C+c*k)*P,e[1]=(i*C-n*U-r*k)*P,e[2]=(g*T-x*M+p*v)*P,e[3]=(f*M-u*T-h*v)*P,e[4]=(a*S-s*U-c*_)*P,e[5]=(t*U-i*S+r*_)*P,e[6]=(x*R-d*T-p*E)*P,e[7]=(l*T-f*R+h*E)*P,e[8]=(s*C-o*S+c*A)*P,e[9]=(n*S-t*C-r*A)*P,e[10]=(d*M-g*R+p*m)*P,e[11]=(u*R-l*M-h*m)*P,e[12]=(o*_-s*k-a*A)*P,e[13]=(t*k-n*_+i*A)*P,e[14]=(g*E-d*v-x*m)*P,e[15]=(l*v-u*E+f*m)*P,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:v,y:M,z:T}=n;return i[0]=(1-(g+p))*v,i[1]=(h+R)*v,i[2]=(d-E)*v,i[3]=0,i[4]=(h-R)*M,i[5]=(1-(f+p))*M,i[6]=(x+m)*M,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Br.set(i[0],i[1],i[2]).length(),o=Br.set(i[4],i[5],i[6]).length(),a=Br.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Un.copy(this);let c=1/s,l=1/o,u=1/a;return Un.elements[0]*=c,Un.elements[1]*=c,Un.elements[2]*=c,Un.elements[4]*=l,Un.elements[5]*=l,Un.elements[6]*=l,Un.elements[8]*=u,Un.elements[9]*=u,Un.elements[10]*=u,t.setFromRotationMatrix(Un),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Br=new D,Un=new Ge,kv=new D(0,0,0),Bv=new D(1,1,1),zi=new D,$o=new D,pn=new D,Df=new Ge,Of=new Ht;class ni{constructor(e=0,t=0,n=0,i=ni.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(We(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-We(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(We(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-We(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(We(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-We(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Pe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Df.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Df,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Of.setFromEuler(this),this.setFromQuaternion(Of,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ni.DEFAULT_ORDER="XYZ";class La{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var Gv=0,Uf=new D,Gr=new Ht,vi=new Ge,Wo=new D,Rs=new D,Hv=new D,Vv=new Ht,Ff=new D(1,0,0),zf=new D(0,1,0),kf=new D(0,0,1),Bf={type:"added"},$v={type:"removed"},Hr={type:"childadded",child:null},Wc={type:"childremoved",child:null};class ht extends $n{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gv++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ht.DEFAULT_UP.clone();let e=new D,t=new ni,n=new Ht,i=new D(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ge},normalMatrix:{value:new ke}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ht.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new La,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Gr.setFromAxisAngle(e,t),this.quaternion.multiply(Gr),this}rotateOnWorldAxis(e,t){return Gr.setFromAxisAngle(e,t),this.quaternion.premultiply(Gr),this}rotateX(e){return this.rotateOnAxis(Ff,e)}rotateY(e){return this.rotateOnAxis(zf,e)}rotateZ(e){return this.rotateOnAxis(kf,e)}translateOnAxis(e,t){return Uf.copy(e).applyQuaternion(this.quaternion),this.position.add(Uf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ff,e)}translateY(e){return this.translateOnAxis(zf,e)}translateZ(e){return this.translateOnAxis(kf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(vi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Wo.copy(e);else Wo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Rs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)vi.lookAt(Rs,Wo,this.up);else vi.lookAt(Wo,Rs,this.up);if(this.quaternion.setFromRotationMatrix(vi),i)vi.extractRotation(i.matrixWorld),Gr.setFromRotationMatrix(vi),this.quaternion.premultiply(Gr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Fe("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Bf),Hr.child=e,this.dispatchEvent(Hr),Hr.child=null;else Fe("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent($v),Wc.child=e,this.dispatchEvent(Wc),Wc.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),vi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),vi.multiply(e.parent.matrixWorld);return e.applyMatrix4(vi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Bf),Hr.child=e,this.dispatchEvent(Hr),Hr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rs,e,Hv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rs,Vv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ht.DEFAULT_UP=new D(0,1,0);ht.DEFAULT_MATRIX_AUTO_UPDATE=!0;ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ei extends ht{constructor(){super();this.isGroup=!0,this.type="Group"}}var Wv={type:"move"};class Xs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ei,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Wv)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var up={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ki={h:0,s:0,l:0},Zo={h:0,s:0,l:0};function Zc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Ue{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=hu(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Zc(s,r,e+0.3333333333333333),this.g=Zc(s,r,e),this.b=Zc(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Pe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Pe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Pe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=up[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Pe("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ti(e.r),this.g=Ti(e.g),this.b=Ti(e.b),this}copyLinearToSRGB(e){return this.r=Qr(e.r),this.g=Qr(e.g),this.b=Qr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(Jt.copy(this),e),Math.round(We(Jt.r*255,0,255))*65536+Math.round(We(Jt.g*255,0,255))*256+Math.round(We(Jt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(Jt.copy(this),t);let{r:n,g:i,b:r}=Jt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(Jt.copy(this),t),e.r=Jt.r,e.g=Jt.g,e.b=Jt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(Jt.copy(this),e);let{r:t,g:n,b:i}=Jt;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ki),this.setHSL(ki.h+e,ki.s+t,ki.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ki),e.getHSL(Zo);let n=Fs(ki.h,Zo.h,t),i=Fs(ki.s,Zo.s,t),r=Fs(ki.l,Zo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var Jt=new Ue;Ue.NAMES=up;class hs extends ht{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Fn=new D,bi=new D,Xc=new D,Si=new D,Vr=new D,$r=new D,Gf=new D,qc=new D,jc=new D,Yc=new D,Kc=new ct,Jc=new ct,Qc=new ct;class Rn{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Fn.subVectors(e,t),i.cross(Fn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Fn.subVectors(i,t),bi.subVectors(n,t),Xc.subVectors(e,t);let s=Fn.dot(Fn),o=Fn.dot(bi),a=Fn.dot(Xc),c=bi.dot(bi),l=bi.dot(Xc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Si)===null)return!1;return Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Si)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Si.x),a.addScaledVector(s,Si.y),a.addScaledVector(o,Si.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Kc.setScalar(0),Jc.setScalar(0),Qc.setScalar(0),Kc.fromBufferAttribute(e,t),Jc.fromBufferAttribute(e,n),Qc.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Kc,r.x),s.addScaledVector(Jc,r.y),s.addScaledVector(Qc,r.z),s}static isFrontFacing(e,t,n,i){return Fn.subVectors(n,t),bi.subVectors(e,t),Fn.cross(bi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fn.subVectors(this.c,this.b),bi.subVectors(this.a,this.b),Fn.cross(bi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Rn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Rn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Rn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Rn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Rn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;Vr.subVectors(i,n),$r.subVectors(r,n),qc.subVectors(e,n);let a=Vr.dot(qc),c=$r.dot(qc);if(a<=0&&c<=0)return t.copy(n);jc.subVectors(e,i);let l=Vr.dot(jc),u=$r.dot(jc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Vr,s);Yc.subVectors(e,r);let h=Vr.dot(Yc),d=$r.dot(Yc);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector($r,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return Gf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(Gf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Vr,s).addScaledVector($r,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ft{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(zn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(zn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=zn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,zn);else zn.fromBufferAttribute(r,s);zn.applyMatrix4(e.matrixWorld),this.expandByPoint(zn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Xo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Xo.copy(n.boundingBox)}Xo.applyMatrix4(e.matrixWorld),this.union(Xo)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,zn),zn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Cs),qo.subVectors(this.max,Cs),Wr.subVectors(e.a,Cs),Zr.subVectors(e.b,Cs),Xr.subVectors(e.c,Cs),Bi.subVectors(Zr,Wr),Gi.subVectors(Xr,Zr),dr.subVectors(Wr,Xr);let t=[0,-Bi.z,Bi.y,0,-Gi.z,Gi.y,0,-dr.z,dr.y,Bi.z,0,-Bi.x,Gi.z,0,-Gi.x,dr.z,0,-dr.x,-Bi.y,Bi.x,0,-Gi.y,Gi.x,0,-dr.y,dr.x,0];if(!el(t,Wr,Zr,Xr,qo))return!1;if(t=[1,0,0,0,1,0,0,0,1],!el(t,Wr,Zr,Xr,qo))return!1;return jo.crossVectors(Bi,Gi),t=[jo.x,jo.y,jo.z],el(t,Wr,Zr,Xr,qo)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(zn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Mi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var Mi=[new D,new D,new D,new D,new D,new D,new D,new D],zn=new D,Xo=new Ft,Wr=new D,Zr=new D,Xr=new D,Bi=new D,Gi=new D,dr=new D,Cs=new D,qo=new D,jo=new D,pr=new D;function el(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){pr.fromArray(e,s);let a=r.x*Math.abs(pr.x)+r.y*Math.abs(pr.y)+r.z*Math.abs(pr.z),c=t.dot(pr),l=n.dot(pr),u=i.dot(pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Nt=new D,Yo=new Ne,Zv=0;class Vt extends $n{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Zv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Yo.fromBufferAttribute(this,t),Yo.applyMatrix3(e),this.setXY(t,Yo.x,Yo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix3(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=kn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=at(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=kn(t,this.array);return t}setX(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=kn(t,this.array);return t}setY(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=kn(t,this.array);return t}setZ(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=kn(t,this.array);return t}setW(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=at(t,this.array),n=at(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array),r=at(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Na extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Da extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class un extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Xv=new Ft,Ps=new D,tl=new D;class xn{constructor(e=new D,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else Xv.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ps.subVectors(e,this.center);let t=Ps.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ps,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else tl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ps.copy(e.center).add(tl)),this.expandByPoint(Ps.copy(e.center).sub(tl));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var qv=0,Tn=new Ge,nl=new ht,qr=new D,mn=new Ft,Is=new Ft,Gt=new D;class en extends $n{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qv++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((xv(e))?Da:Na)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ke().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Tn.makeRotationFromQuaternion(e),this.applyMatrix4(Tn),this}rotateX(e){return Tn.makeRotationX(e),this.applyMatrix4(Tn),this}rotateY(e){return Tn.makeRotationY(e),this.applyMatrix4(Tn),this}rotateZ(e){return Tn.makeRotationZ(e),this.applyMatrix4(Tn),this}translate(e,t,n){return Tn.makeTranslation(e,t,n),this.applyMatrix4(Tn),this}scale(e,t,n){return Tn.makeScale(e,t,n),this.applyMatrix4(Tn),this}lookAt(e){return nl.lookAt(e),nl.updateMatrix(),this.applyMatrix4(nl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qr).negate(),this.translate(qr.x,qr.y,qr.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new un(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Pe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ft;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(mn.setFromBufferAttribute(r),this.morphTargetsRelative)Gt.addVectors(this.boundingBox.min,mn.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,mn.max),this.boundingBox.expandByPoint(Gt);else this.boundingBox.expandByPoint(mn.min),this.boundingBox.expandByPoint(mn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Fe('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){let n=this.boundingSphere.center;if(mn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Is.setFromBufferAttribute(o),this.morphTargetsRelative)Gt.addVectors(mn.min,Is.min),mn.expandByPoint(Gt),Gt.addVectors(mn.max,Is.max),mn.expandByPoint(Gt);else mn.expandByPoint(Is.min),mn.expandByPoint(Is.max)}mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Gt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Gt.fromBufferAttribute(o,c),a)qr.fromBufferAttribute(e,c),Gt.add(qr);i=Math.max(i,n.distanceToSquared(Gt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Fe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Fe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new D,a[A]=new D;let c=new D,l=new D,u=new D,f=new Ne,h=new Ne,d=new Ne,g=new D,x=new D;function p(A,_,S){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,S),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,S),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let k=1/(h.x*d.y-d.x*h.y);if(!isFinite(k))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(k),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(k),o[A].add(g),o[_].add(g),o[S].add(g),a[A].add(x),a[_].add(x),a[S].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:k,count:C}=S;for(let U=k,ee=k+C;U<ee;U+=3)p(e.getX(U+0),e.getX(U+1),e.getX(U+2))}let E=new D,R=new D,v=new D,M=new D;function T(A){v.fromBufferAttribute(i,A),M.copy(v);let _=o[A];E.copy(_),E.sub(v.multiplyScalar(v.dot(_))).normalize(),R.crossVectors(M,_);let k=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,k)}for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:k,count:C}=S;for(let U=k,ee=k+C;U<ee;U+=3)T(e.getX(U+0)),T(e.getX(U+1)),T(e.getX(U+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new D,r=new D,s=new D,o=new D,a=new D,c=new D,l=new D,u=new D;if(e)for(let f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Vt(f,l,u)}if(this.index===null)return Pe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new en,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class qs{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Bn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Bn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Bn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var sn=new D;class fs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyMatrix4(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyNormalMatrix(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.transformDirection(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=kn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=at(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=kn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=kn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=kn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=kn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=at(t,this.array),n=at(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array),r=at(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){zs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Vt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new fs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){zs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var il=new D,jv=new D,Yv=new ke;class An{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=il.subVectors(n,t).cross(jv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(il),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Yv.getNormalMatrix(e),i=this.coplanarPoint(il).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var Kv=0;class hn extends $n{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Kv++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ue(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Pe(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Pe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Ue().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new An().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var wi=new D,rl=new D,Ko=new D,Jo=new D;class Yi{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,wi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=wi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return wi.copy(this.origin).addScaledVector(this.direction,t),wi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){rl.copy(e).add(t).multiplyScalar(0.5),Ko.copy(t).sub(e).normalize(),Jo.copy(this.origin).sub(rl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ko),o=Jo.dot(this.direction),a=-Jo.dot(Ko),c=Jo.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(rl).addScaledVector(Ko,f);return h}intersectSphere(e,t){if(e.radius<0)return null;wi.subVectors(e.center,this.origin);let n=wi.dot(this.direction),i=wi.dot(wi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,wi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),v=Math.abs(c),M=Math.abs(l),T,A,_,S,k,C,U,ee,P,V,j,z;if(R>=v&&R>=M)if(_=a,C=u,P=d,z=p,a>=0)T=c,A=l,S=f,k=h,U=g,ee=x,V=m,j=E;else T=l,A=c,S=h,k=f,U=x,ee=g,V=E,j=m;else if(v>=M)if(_=c,C=f,P=g,z=m,c>=0)T=l,A=a,S=h,k=u,U=x,ee=d,V=E,j=p;else T=a,A=l,S=u,k=h,U=d,ee=x,V=p,j=E;else if(_=l,C=h,P=x,z=E,l>=0)T=a,A=c,S=u,k=f,U=d,ee=g,V=p,j=m;else T=c,A=a,S=f,k=u,U=g,ee=d,V=m,j=p;if(_===0)return null;let H=T/_,F=A/_,q=1/_,K=S-H*C,xe=k-F*C,ce=U-H*P,De=ee-F*P,ye=V-H*z,X=j-F*z,re=ye*De-X*ce,se=K*X-xe*ye,Te=ce*xe-De*K;if(i){if(re<0||se<0||Te<0)return null}else if((re<0||se<0||Te<0)&&(re>0||se>0||Te>0))return null;let Ie=re+se+Te;if(Ie===0)return null;let _e=q*(re*C+se*P+Te*z);if(Ie>0?_e<0:_e>0)return null;return this.at(_e/Ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ai extends hn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Hf=new Ge,mr=new Yi,Qo=new xn,Vf=new D,ea=new D,ta=new D,na=new D,sl=new D,ia=new D,$f=new D,ra=new D;class xt extends ht{constructor(e=new en,t=new ai){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){ia.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(sl.fromBufferAttribute(u,e),s)ia.addScaledVector(sl,l);else ia.addScaledVector(sl.sub(t),l)}t.add(ia)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Qo.copy(n.boundingSphere),Qo.applyMatrix4(r),mr.copy(e.ray).recast(e.near),Qo.containsPoint(mr.origin)===!1){if(mr.intersectSphere(Qo,Vf)===null)return;if(mr.origin.distanceToSquared(Vf)>(e.far-e.near)**2)return}if(Hf.copy(r).invert(),mr.copy(e.ray).applyMatrix4(Hf),n.boundingBox!==null){if(mr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,mr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=sa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=sa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=R,T=R+1,A=R+2;if(i=sa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=sa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function Jv(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;ra.copy(a),ra.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(ra);if(l<n.near||l>n.far)return null;return{distance:l,point:ra.clone(),object:e}}function sa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,ea),e.getVertexPosition(c,ta),e.getVertexPosition(l,na);let u=Jv(e,t,n,i,ea,ta,na,$f);if(u){let f=new D;if(Rn.getBarycoord($f,ea,ta,na,f),r)u.uv=Rn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Rn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Rn.getInterpolatedAttribute(o,a,c,l,f,new D),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new D,materialIndex:0};Rn.getNormal(ea,ta,na,h.normal),u.face=h,u.barycoord=f}return u}var Ls=new ct,Wf=new ct,Zf=new ct,Qv=new ct,Xf=new Ge,oa=new D,ol=new xn,qf=new Ge,al=new Yi;class Oa extends xt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Ft;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,oa),this.boundingBox.expandByPoint(oa)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,oa),this.boundingSphere.expandByPoint(oa)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(ol.copy(this.boundingSphere),ol.applyMatrix4(i),e.ray.intersectsSphere(ol)===!1)return;if(qf.copy(i).invert(),al.copy(e.ray).applyMatrix4(qf),this.boundingBox!==null){if(al.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,al)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ct,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Pe("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Wf.fromBufferAttribute(i.attributes.skinIndex,e),Zf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Ls.copy(t),t.set(0,0,0,0);else Ls.set(...t,1),t.set(0,0,0);Ls.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Zf.getComponent(r);if(s!==0){let o=Wf.getComponent(r);Xf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Qv.copy(Ls).applyMatrix4(Xf),s)}}if(t.isVector4)t.w=Ls.w;return t.applyMatrix4(this.bindMatrixInverse)}}class js extends ht{constructor(){super();this.isBone=!0,this.type="Bone"}}class Ys extends At{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var jf=new Ge,eb=new Ge;class Ks{constructor(e=[],t=[]){this.uuid=Bn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Pe("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:eb;jf.multiplyMatrices(o,t[r]),jf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ks(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Ys(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Pe("Skeleton: No bone found with UUID:",r),s=new js;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class $i extends Vt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var jr=new Ge,Yf=new Ge,aa=[],Kf=new Ft,tb=new Ge,Ns=new xt,Ds=new xn;class ds extends xt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new $i(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tb)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Ft;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,jr),Kf.copy(e.boundingBox).applyMatrix4(jr),this.boundingBox.union(Kf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,jr),Ds.copy(e.boundingSphere).applyMatrix4(jr),this.boundingSphere.union(Ds)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Ns.geometry=this.geometry,Ns.material=this.material,Ns.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Ds.copy(this.boundingSphere),Ds.applyMatrix4(n),e.ray.intersectsSphere(Ds)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,jr),Yf.multiplyMatrices(n,jr),Ns.matrixWorld=Yf,Ns.raycast(e,aa);for(let s=0,o=aa.length;s<o;s++){let a=aa[s];a.instanceId=r,a.object=this,t.push(a)}aa.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new $i(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Ys(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var gr=new xn,nb=new Ne(0.5,0.5),ca=new D;class Js{constructor(e=new An,t=new An,n=new An,i=new An,r=new An,s=new An){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],v=r[15];if(i[0].setComponents(c-s,h-l,p-d,v-m).normalize(),i[1].setComponents(c+s,h+l,p+d,v+m).normalize(),i[2].setComponents(c+o,h+u,p+g,v+E).normalize(),i[3].setComponents(c-o,h-u,p-g,v-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,v-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,v-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,v+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gr)}intersectsSprite(e){gr.center.set(0,0,0);let t=nb.distanceTo(e.center);return gr.radius=0.7071067811865476+t,gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(gr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(ca.x=i.normal.x>0?e.max.x:e.min.x,ca.y=i.normal.y>0?e.max.y:e.min.y,ca.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ca)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Qs extends hn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ue(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ga=new D,_a=new D,Jf=new Ge,Os=new Yi,la=new xn,cl=new D,Qf=new D;class Ki extends ht{constructor(e=new en,t=new Qs){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)ga.fromBufferAttribute(t,i-1),_a.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ga.distanceTo(_a);e.setAttribute("lineDistance",new un(n,1))}else Pe("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(la.copy(n.boundingSphere),la.applyMatrix4(i),la.radius+=r,e.ray.intersectsSphere(la)===!1)return;Jf.copy(i).invert(),Os.copy(e.ray).applyMatrix4(Jf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=ua(this,e,Os,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=ua(this,e,Os,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=ua(this,e,Os,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=ua(this,e,Os,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ua(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ga.fromBufferAttribute(a,r),_a.fromBufferAttribute(a,s),n.distanceSqToSegment(ga,_a,cl,Qf)>i)return;cl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(cl);if(l<t.near||l>t.far)return;return{distance:l,point:Qf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var ed=new D,td=new D;class Ua extends Ki{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)ed.fromBufferAttribute(t,i),td.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ed.distanceTo(td);e.setAttribute("lineDistance",new un(n,1))}else Pe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Fa extends Ki{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class eo extends hn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var nd=new Ge,hl=new Yi,ha=new xn,fa=new D;class ps extends ht{constructor(e=new en,t=new eo){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(ha.copy(n.boundingSphere),ha.applyMatrix4(i),ha.radius+=r,e.ray.intersectsSphere(ha)===!1)return;nd.copy(i).invert(),hl.copy(e.ray).applyMatrix4(nd);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);fa.fromBufferAttribute(u,x),id(fa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)fa.fromBufferAttribute(u,d),id(fa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function id(e,t,n,i,r,s,o){let a=hl.distanceSqToPoint(e);if(a<n){let c=new D;hl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class za extends At{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Er extends At{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Zs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class mu extends Er{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class ka extends At{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ji extends en{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new un(c,3)),this.setAttribute("normal",new un(l,3)),this.setAttribute("uv",new un(u,2));function d(g,x,p,m,E,R,v,M,T,A,_){let S=R/T,k=v/A,C=R/2,U=v/2,ee=M/2,P=T+1,V=A+1,j=0,z=0,H=new D;for(let F=0;F<V;F++){let q=F*k-U;for(let K=0;K<P;K++){let xe=K*S-C;H[g]=xe*m,H[x]=q*E,H[p]=ee,c.push(H.x,H.y,H.z),H[g]=0,H[x]=0,H[p]=M>0?1:-1,l.push(H.x,H.y,H.z),u.push(K/T),u.push(1-F/A),j+=1}}for(let F=0;F<A;F++)for(let q=0;q<T;q++){let K=f+q+P*F,xe=f+q+P*(F+1),ce=f+(q+1)+P*(F+1),De=f+(q+1)+P*F;a.push(K,xe,De),a.push(xe,ce,De),z+=6}o.addGroup(h,z,_),h+=z,f+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ji(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class to extends en{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),v=m+1+c*(p+1),M=m+1+c*p;h.push(E,R,M),h.push(R,v,M)}this.setIndex(h),this.setAttribute("position",new un(d,3)),this.setAttribute("normal",new un(g,3)),this.setAttribute("uv",new un(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new to(e.width,e.height,e.widthSegments,e.heightSegments)}}function Tr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(rd(r))if(r.isRenderTargetTexture)Pe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(rd(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function tn(e){let t={};for(let n=0;n<e.length;n++){let i=Tr(e[n]);for(let r in i)t[r]=i[r]}return t}function rd(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function ib(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function gu(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var hp={clone:Tr,merge:tn},rb=`void main() {
+ var dd="186",Zi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Xi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},pd=0,dl=1,md=2;var Vs=1,gd=2,ss=3,qi=0,Qt=1,Pn=2,ii=0,$s=1,pl=2,ml=3,gl=4,_d=5;var os=100,xd=101,yd=102,vd=103,bd=104,Sd=200,Md=201,wd=202,Ed=203,Td=204,Ad=205,Rd=206,Cd=207,Pd=208,Id=209,Ld=210,Nd=211,Dd=212,Od=213,Ud=214,Fd=0,zd=1,kd=2,_l=3,Bd=4,Gd=5,Hd=6,Vd=7,$d=0,Wd=1,Zd=2,Hn=0,xl=1,yl=2,vl=3,Ws=4,bl=5,Sl=6,Ml=7;var as=301,vr=302,va=303,ba=304,Zs=306,cs=1000,ls=1001,Sa=1002,Vn=1003,Ma=1004;var br=1005;var $t=1006,us=1007;var ri=1008;var $n=1009,Xd=1010,qd=1011,Xs=1012,wl=1013,ji=1014,Ri=1015,si=1016,El=1017,Tl=1018,hs=1020,jd=35902,Yd=35899,Kd=1021,Jd=1022,oi=1023,Sr=1026,Mr=1027,Qd=1028,Al=1029,wr=1030,Rl=1031;var Cl=1033,wa=33776,Ea=33777,Ta=33778,Aa=33779,Pl=35840,Il=35841,Ll=35842,Nl=35843,Dl=36196,Ol=37492,Ul=37496,Fl=37488,zl=37489,Ra=37490,kl=37491,Bl=37808,Gl=37809,Hl=37810,Vl=37811,$l=37812,Wl=37813,Zl=37814,Xl=37815,ql=37816,jl=37817,Yl=37818,Kl=37819,Jl=37820,Ql=37821,eu=36492,tu=36494,nu=36495,iu=36283,ru=36284,Ca=36285,su=36286;var ou=2300,Pa=2301;var au=0,qs=1,fs=2;var cu=0,ep=1,Er="",Yi="srgb",gn="srgb-linear",lu="linear",dt="srgb";var tp=512,np=513,ip=514,Ia=515,rp=516,sp=517,La=518,op=519;var uu="300 es",hu=2000;function vv(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function bv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ns(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ap(){let e=ns("canvas");return e.style.display="block",e}var Pf={},is=null;function Hs(...e){let t="THREE."+e.shift();if(is)is("log",t,...e);else console.log(t,...e)}function cp(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ie(...e){e=cp(e);let t="THREE."+e.shift();if(is)is("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=cp(e);let t="THREE."+e.shift();if(is)is("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function xr(...e){let t=e.join(" ");if(t in Pf)return;Pf[t]=!0,Ie(...e)}function lp(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var up={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Wn{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var Kt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],If=1234567,Bs=Math.PI/180,yr=180/Math.PI;function Gn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Kt[e&255]+Kt[e>>8&255]+Kt[e>>16&255]+Kt[e>>24&255]+"-"+Kt[t&255]+Kt[t>>8&255]+"-"+Kt[t>>16&15|64]+Kt[t>>24&255]+"-"+Kt[n&63|128]+Kt[n>>8&255]+"-"+Kt[n>>16&255]+Kt[n>>24&255]+Kt[i&255]+Kt[i>>8&255]+Kt[i>>16&255]+Kt[i>>24&255]).toLowerCase()}function We(e,t,n){return Math.max(t,Math.min(n,e))}function fu(e,t){return(e%t+t)%t}function Sv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Mv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Gs(e,t,n){return(1-n)*e+n*t}function wv(e,t,n,i){return Gs(e,t,1-Math.exp(-n*i))}function Ev(e,t=1){return t-Math.abs(fu(e,t*2)-t)}function Tv(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Av(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Rv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Cv(e,t){return e+Math.random()*(t-e)}function Pv(e){return e*(0.5-Math.random())}function Iv(e){if(e!==void 0)If=e;let t=If+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Lv(e){return e*Bs}function Nv(e){return e*yr}function Dv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Ov(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Uv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Fv(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Bn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ot(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var js={DEG2RAD:Bs,RAD2DEG:yr,generateUUID:Gn,clamp:We,euclideanModulo:fu,mapLinear:Sv,inverseLerp:Mv,lerp:Gs,damp:wv,pingpong:Ev,smoothstep:Tv,smootherstep:Av,randInt:Rv,randFloat:Cv,randFloatSpread:Pv,seededRandom:Iv,degToRad:Lv,radToDeg:Nv,isPowerOfTwo:Dv,ceilPowerOfTwo:Ov,floorPowerOfTwo:Uv,setQuaternionFromProperEuler:Fv,normalize:ot,denormalize:Bn};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ht{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{static{O.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Lf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Lf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hc.copy(this).projectOnVector(e),this.sub(Hc)}reflect(e){return this.sub(Hc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Hc=new O,Lf=new Ht;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],v=i[2],M=i[5],T=i[8];return r[0]=s*g+o*m+a*v,r[3]=s*x+o*E+a*M,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*v,r[4]=c*x+l*E+u*M,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*v,r[5]=f*x+h*E+d*M,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return xr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Vc.makeScale(e,t)),this}rotate(e){return xr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Vc.makeRotation(-e)),this}translate(e,t){return xr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Vc.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Vc=new ze,Nf=new ze().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Df=new ze().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function zv(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Ai(r.r),r.g=Ai(r.g),r.b=Ai(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ts(r.r),r.g=ts(r.g),r.b=ts(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Nf,fromXYZ:Df,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Nf,fromXYZ:Df,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=zv();function Ai(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ts(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Gr;class du{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(Gr===void 0)Gr=ns("canvas");Gr.width=e.width,Gr.height=e.height;let i=Gr.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Gr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=ns("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Ai(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Ai(t[n]/255)*255);else t[n]=Ai(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var kv=0;class Ys{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:kv++}),this.uuid=Gn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push($c(i[s].image));else r.push($c(i[s]))}else r=$c(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function $c(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return du.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ie("Texture: Unable to serialize Texture."),{}}var Bv=0,Wc=new O;class At extends Wn{constructor(e=At.DEFAULT_IMAGE,t=At.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=At.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Bv++}),this.uuid=Gn(),this.name="",this.source=new Ys(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Wc).x}get height(){return this.source.getSize(Wc).y}get depth(){return this.source.getSize(Wc).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=300;At.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,v=(p+1)/2,M=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>v)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=M/n,r=T/n;else if(R>v)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=M/i,r=A/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class pu extends Wn{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new At(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Ys(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends pu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Na extends At{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mu extends At{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Hr.setFromMatrixColumn(e,0).length(),r=1/Hr.setFromMatrixColumn(e,1).length(),s=1/Hr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Gv,e,Hv)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),ki.crossVectors(n,pn),ki.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),ki.crossVectors(n,pn)}return ki.normalize(),Zo.crossVectors(pn,ki),i[0]=ki.x,i[4]=Zo.x,i[8]=pn.x,i[1]=ki.y,i[5]=Zo.y,i[9]=pn.y,i[2]=ki.z,i[6]=Zo.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],v=n[15],M=i[0],T=i[4],A=i[8],_=i[12],S=i[1],z=i[5],P=i[9],F=i[13],ee=i[2],I=i[6],H=i[10],q=i[14],C=i[3],X=i[7],k=i[11],Y=i[15];return r[0]=s*M+o*S+a*ee+c*C,r[4]=s*T+o*z+a*I+c*X,r[8]=s*A+o*P+a*H+c*k,r[12]=s*_+o*F+a*q+c*Y,r[1]=l*M+u*S+f*ee+h*C,r[5]=l*T+u*z+f*I+h*X,r[9]=l*A+u*P+f*H+h*k,r[13]=l*_+u*F+f*q+h*Y,r[2]=d*M+g*S+x*ee+p*C,r[6]=d*T+g*z+x*I+p*X,r[10]=d*A+g*P+x*H+p*k,r[14]=d*_+g*F+x*q+p*Y,r[3]=m*M+E*S+R*ee+v*C,r[7]=m*T+E*z+R*I+v*X,r[11]=m*A+E*P+R*H+v*k,r[15]=m*_+E*F+R*q+v*Y,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,v=s*h-c*l,M=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*v+p*M)+i*(d*E-g*v+p*T)-r*(d*R-g*M+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,v=n*a-i*o,M=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,S=l*p-h*d,z=u*x-f*g,P=u*p-h*g,F=f*p-h*x,ee=m*F-E*P+R*z+v*S-M*_+T*A;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/ee;return e[0]=(o*F-a*P+c*z)*I,e[1]=(i*P-n*F-r*z)*I,e[2]=(g*T-x*M+p*v)*I,e[3]=(f*M-u*T-h*v)*I,e[4]=(a*S-s*F-c*_)*I,e[5]=(t*F-i*S+r*_)*I,e[6]=(x*R-d*T-p*E)*I,e[7]=(l*T-f*R+h*E)*I,e[8]=(s*P-o*S+c*A)*I,e[9]=(n*S-t*P-r*A)*I,e[10]=(d*M-g*R+p*m)*I,e[11]=(u*R-l*M-h*m)*I,e[12]=(o*_-s*z-a*A)*I,e[13]=(t*z-n*_+i*A)*I,e[14]=(g*E-d*v-x*m)*I,e[15]=(l*v-u*E+f*m)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:v,y:M,z:T}=n;return i[0]=(1-(g+p))*v,i[1]=(h+R)*v,i[2]=(d-E)*v,i[3]=0,i[4]=(h-R)*M,i[5]=(1-(f+p))*M,i[6]=(x+m)*M,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Hr.set(i[0],i[1],i[2]).length(),o=Hr.set(i[4],i[5],i[6]).length(),a=Hr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Fn.copy(this);let c=1/s,l=1/o,u=1/a;return Fn.elements[0]*=c,Fn.elements[1]*=c,Fn.elements[2]*=c,Fn.elements[4]*=l,Fn.elements[5]*=l,Fn.elements[6]*=l,Fn.elements[8]*=u,Fn.elements[9]*=u,Fn.elements[10]*=u,t.setFromRotationMatrix(Fn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Hr=new O,Fn=new Ge,Gv=new O(0,0,0),Hv=new O(1,1,1),ki=new O,Zo=new O,pn=new O,Of=new Ge,Uf=new Ht;class ni{constructor(e=0,t=0,n=0,i=ni.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(We(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-We(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(We(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-We(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(We(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-We(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Of.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Of,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Uf.setFromEuler(this),this.setFromQuaternion(Uf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ni.DEFAULT_ORDER="XYZ";class Da{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var Vv=0,Ff=new O,Vr=new Ht,bi=new Ge,Xo=new O,Ls=new O,$v=new O,Wv=new Ht,zf=new O(1,0,0),kf=new O(0,1,0),Bf=new O(0,0,1),Gf={type:"added"},Zv={type:"removed"},$r={type:"childadded",child:null},Zc={type:"childremoved",child:null};class ut extends Wn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Vv++}),this.uuid=Gn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();let e=new O,t=new ni,n=new Ht,i=new O(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ge},normalMatrix:{value:new ze}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Da,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Vr.setFromAxisAngle(e,t),this.quaternion.multiply(Vr),this}rotateOnWorldAxis(e,t){return Vr.setFromAxisAngle(e,t),this.quaternion.premultiply(Vr),this}rotateX(e){return this.rotateOnAxis(zf,e)}rotateY(e){return this.rotateOnAxis(kf,e)}rotateZ(e){return this.rotateOnAxis(Bf,e)}translateOnAxis(e,t){return Ff.copy(e).applyQuaternion(this.quaternion),this.position.add(Ff.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(zf,e)}translateY(e){return this.translateOnAxis(kf,e)}translateZ(e){return this.translateOnAxis(Bf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(bi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Xo.copy(e);else Xo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)bi.lookAt(Ls,Xo,this.up);else bi.lookAt(Xo,Ls,this.up);if(this.quaternion.setFromRotationMatrix(bi),i)bi.extractRotation(i.matrixWorld),Vr.setFromRotationMatrix(bi),this.quaternion.premultiply(Vr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Gf),$r.child=e,this.dispatchEvent($r),$r.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Zv),Zc.child=e,this.dispatchEvent(Zc),Zc.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),bi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),bi.multiply(e.parent.matrixWorld);return e.applyMatrix4(bi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Gf),$r.child=e,this.dispatchEvent($r),$r.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,e,$v),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,Wv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ut.DEFAULT_UP=new O(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ei extends ut{constructor(){super();this.isGroup=!0,this.type="Group"}}var Xv={type:"move"};class Ks{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ei,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Xv)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var hp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Bi={h:0,s:0,l:0},qo={h:0,s:0,l:0};function Xc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=fu(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Xc(s,r,e+0.3333333333333333),this.g=Xc(s,r,e),this.b=Xc(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ie("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=hp[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ie("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ai(e.r),this.g=Ai(e.g),this.b=Ai(e.b),this}copyLinearToSRGB(e){return this.r=ts(e.r),this.g=ts(e.g),this.b=ts(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(Jt.copy(this),e),Math.round(We(Jt.r*255,0,255))*65536+Math.round(We(Jt.g*255,0,255))*256+Math.round(We(Jt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(Jt.copy(this),t);let{r:n,g:i,b:r}=Jt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(Jt.copy(this),t),e.r=Jt.r,e.g=Jt.g,e.b=Jt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(Jt.copy(this),e);let{r:t,g:n,b:i}=Jt;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Bi),this.setHSL(Bi.h+e,Bi.s+t,Bi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Bi),e.getHSL(qo);let n=Gs(Bi.h,qo.h,t),i=Gs(Bi.s,qo.s,t),r=Gs(Bi.l,qo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var Jt=new Oe;Oe.NAMES=hp;class ds extends ut{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var zn=new O,Si=new O,qc=new O,Mi=new O,Wr=new O,Zr=new O,Hf=new O,jc=new O,Yc=new O,Kc=new O,Jc=new at,Qc=new at,el=new at;class Cn{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zn.subVectors(e,t),i.cross(zn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){zn.subVectors(i,t),Si.subVectors(n,t),qc.subVectors(e,t);let s=zn.dot(zn),o=zn.dot(Si),a=zn.dot(qc),c=Si.dot(Si),l=Si.dot(qc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Mi)===null)return!1;return Mi.x>=0&&Mi.y>=0&&Mi.x+Mi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Mi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Mi.x),a.addScaledVector(s,Mi.y),a.addScaledVector(o,Mi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Jc.setScalar(0),Qc.setScalar(0),el.setScalar(0),Jc.fromBufferAttribute(e,t),Qc.fromBufferAttribute(e,n),el.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Jc,r.x),s.addScaledVector(Qc,r.y),s.addScaledVector(el,r.z),s}static isFrontFacing(e,t,n,i){return zn.subVectors(n,t),Si.subVectors(e,t),zn.cross(Si).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zn.subVectors(this.c,this.b),Si.subVectors(this.a,this.b),zn.cross(Si).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Cn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Cn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Cn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Cn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Cn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;Wr.subVectors(i,n),Zr.subVectors(r,n),jc.subVectors(e,n);let a=Wr.dot(jc),c=Zr.dot(jc);if(a<=0&&c<=0)return t.copy(n);Yc.subVectors(e,i);let l=Wr.dot(Yc),u=Zr.dot(Yc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Wr,s);Kc.subVectors(e,r);let h=Wr.dot(Kc),d=Zr.dot(Kc);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Zr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return Hf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(Hf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Wr,s).addScaledVector(Zr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ft{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,kn);else kn.fromBufferAttribute(r,s);kn.applyMatrix4(e.matrixWorld),this.expandByPoint(kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();jo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();jo.copy(n.boundingBox)}jo.applyMatrix4(e.matrixWorld),this.union(jo)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,kn),kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ns),Yo.subVectors(this.max,Ns),Xr.subVectors(e.a,Ns),qr.subVectors(e.b,Ns),jr.subVectors(e.c,Ns),Gi.subVectors(qr,Xr),Hi.subVectors(jr,qr),pr.subVectors(Xr,jr);let t=[0,-Gi.z,Gi.y,0,-Hi.z,Hi.y,0,-pr.z,pr.y,Gi.z,0,-Gi.x,Hi.z,0,-Hi.x,pr.z,0,-pr.x,-Gi.y,Gi.x,0,-Hi.y,Hi.x,0,-pr.y,pr.x,0];if(!tl(t,Xr,qr,jr,Yo))return!1;if(t=[1,0,0,0,1,0,0,0,1],!tl(t,Xr,qr,jr,Yo))return!1;return Ko.crossVectors(Gi,Hi),t=[Ko.x,Ko.y,Ko.z],tl(t,Xr,qr,jr,Yo)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var wi=[new O,new O,new O,new O,new O,new O,new O,new O],kn=new O,jo=new Ft,Xr=new O,qr=new O,jr=new O,Gi=new O,Hi=new O,pr=new O,Ns=new O,Yo=new O,Ko=new O,mr=new O;function tl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){mr.fromArray(e,s);let a=r.x*Math.abs(mr.x)+r.y*Math.abs(mr.y)+r.z*Math.abs(mr.z),c=t.dot(mr),l=n.dot(mr),u=i.dot(mr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Nt=new O,Jo=new Ne,qv=0;class Vt extends Wn{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:qv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Jo.fromBufferAttribute(this,t),Jo.applyMatrix3(e),this.setXY(t,Jo.x,Jo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix3(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Bn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Bn(t,this.array);return t}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Bn(t,this.array);return t}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Bn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Bn(t,this.array);return t}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Oa extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ua extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class un extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var jv=new Ft,Ds=new O,nl=new O;class xn{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else jv.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ds.subVectors(e,this.center);let t=Ds.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ds,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else nl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ds.copy(e.center).add(nl)),this.expandByPoint(Ds.copy(e.center).sub(nl));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var Yv=0,An=new Ge,il=new ut,Yr=new O,mn=new Ft,Os=new Ft,Gt=new O;class en extends Wn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yv++}),this.uuid=Gn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((vv(e))?Ua:Oa)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return An.makeRotationFromQuaternion(e),this.applyMatrix4(An),this}rotateX(e){return An.makeRotationX(e),this.applyMatrix4(An),this}rotateY(e){return An.makeRotationY(e),this.applyMatrix4(An),this}rotateZ(e){return An.makeRotationZ(e),this.applyMatrix4(An),this}translate(e,t,n){return An.makeTranslation(e,t,n),this.applyMatrix4(An),this}scale(e,t,n){return An.makeScale(e,t,n),this.applyMatrix4(An),this}lookAt(e){return il.lookAt(e),il.updateMatrix(),this.applyMatrix4(il.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yr).negate(),this.translate(Yr.x,Yr.y,Yr.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new un(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ie("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ft;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(mn.setFromBufferAttribute(r),this.morphTargetsRelative)Gt.addVectors(this.boundingBox.min,mn.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,mn.max),this.boundingBox.expandByPoint(Gt);else this.boundingBox.expandByPoint(mn.min),this.boundingBox.expandByPoint(mn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if(mn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Os.setFromBufferAttribute(o),this.morphTargetsRelative)Gt.addVectors(mn.min,Os.min),mn.expandByPoint(Gt),Gt.addVectors(mn.max,Os.max),mn.expandByPoint(Gt);else mn.expandByPoint(Os.min),mn.expandByPoint(Os.max)}mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Gt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Gt.fromBufferAttribute(o,c),a)Yr.fromBufferAttribute(e,c),Gt.add(Yr);i=Math.max(i,n.distanceToSquared(Gt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new O,a[A]=new O;let c=new O,l=new O,u=new O,f=new Ne,h=new Ne,d=new Ne,g=new O,x=new O;function p(A,_,S){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,S),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,S),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let z=1/(h.x*d.y-d.x*h.y);if(!isFinite(z))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(z),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(z),o[A].add(g),o[_].add(g),o[S].add(g),a[A].add(x),a[_].add(x),a[S].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:z,count:P}=S;for(let F=z,ee=z+P;F<ee;F+=3)p(e.getX(F+0),e.getX(F+1),e.getX(F+2))}let E=new O,R=new O,v=new O,M=new O;function T(A){v.fromBufferAttribute(i,A),M.copy(v);let _=o[A];E.copy(_),E.sub(v.multiplyScalar(v.dot(_))).normalize(),R.crossVectors(M,_);let z=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,z)}for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:z,count:P}=S;for(let F=z,ee=z+P;F<ee;F+=3)T(e.getX(F+0)),T(e.getX(F+1)),T(e.getX(F+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new O,r=new O,s=new O,o=new O,a=new O,c=new O,l=new O,u=new O;if(e)for(let f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Vt(f,l,u)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new en,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Js{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Gn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Gn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Gn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var sn=new O;class ps{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyMatrix4(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyNormalMatrix(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.transformDirection(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Bn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Bn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Bn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Bn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Bn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Hs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Vt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new ps(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Hs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var rl=new O,Kv=new O,Jv=new ze;class Rn{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=rl.subVectors(n,t).cross(Kv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(rl),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Jv.getNormalMatrix(e),i=this.coplanarPoint(rl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var Qv=0;class hn extends Wn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Qv++}),this.uuid=Gn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Rn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var Ei=new O,sl=new O,Qo=new O,ea=new O;class Ki{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ei)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ei.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Ei.copy(this.origin).addScaledVector(this.direction,t),Ei.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){sl.copy(e).add(t).multiplyScalar(0.5),Qo.copy(t).sub(e).normalize(),ea.copy(this.origin).sub(sl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Qo),o=ea.dot(this.direction),a=-ea.dot(Qo),c=ea.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(sl).addScaledVector(Qo,f);return h}intersectSphere(e,t){if(e.radius<0)return null;Ei.subVectors(e.center,this.origin);let n=Ei.dot(this.direction),i=Ei.dot(Ei)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ei)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),v=Math.abs(c),M=Math.abs(l),T,A,_,S,z,P,F,ee,I,H,q,C;if(R>=v&&R>=M)if(_=a,P=u,I=d,C=p,a>=0)T=c,A=l,S=f,z=h,F=g,ee=x,H=m,q=E;else T=l,A=c,S=h,z=f,F=x,ee=g,H=E,q=m;else if(v>=M)if(_=c,P=f,I=g,C=m,c>=0)T=l,A=a,S=h,z=u,F=x,ee=d,H=E,q=p;else T=a,A=l,S=u,z=h,F=d,ee=x,H=p,q=E;else if(_=l,P=h,I=x,C=E,l>=0)T=a,A=c,S=u,z=f,F=d,ee=g,H=p,q=m;else T=c,A=a,S=f,z=u,F=g,ee=d,H=m,q=p;if(_===0)return null;let X=T/_,k=A/_,Y=1/_,Q=S-X*P,Se=z-k*P,ue=F-X*I,Fe=ee-k*I,Me=H-X*C,Z=q-k*C,re=Me*Fe-Z*ue,se=Q*Z-Se*Me,xe=ue*Se-Fe*Q;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let we=re+se+xe;if(we===0)return null;let Ee=Y*(re*P+se*I+xe*C);if(we>0?Ee<0:Ee>0)return null;return this.at(Ee/we,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ai extends hn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Vf=new Ge,gr=new Ki,ta=new xn,$f=new O,na=new O,ia=new O,ra=new O,ol=new O,sa=new O,Wf=new O,oa=new O;class _t extends ut{constructor(e=new en,t=new ai){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){sa.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(ol.fromBufferAttribute(u,e),s)sa.addScaledVector(ol,l);else sa.addScaledVector(ol.sub(t),l)}t.add(sa)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(ta.copy(n.boundingSphere),ta.applyMatrix4(r),gr.copy(e.ray).recast(e.near),ta.containsPoint(gr.origin)===!1){if(gr.intersectSphere(ta,$f)===null)return;if(gr.origin.distanceToSquared($f)>(e.far-e.near)**2)return}if(Vf.copy(r).invert(),gr.copy(e.ray).applyMatrix4(Vf),n.boundingBox!==null){if(gr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,gr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=aa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=aa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=R,T=R+1,A=R+2;if(i=aa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=aa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function eb(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;oa.copy(a),oa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(oa);if(l<n.near||l>n.far)return null;return{distance:l,point:oa.clone(),object:e}}function aa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,na),e.getVertexPosition(c,ia),e.getVertexPosition(l,ra);let u=eb(e,t,n,i,na,ia,ra,Wf);if(u){let f=new O;if(Cn.getBarycoord(Wf,na,ia,ra,f),r)u.uv=Cn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Cn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Cn.getInterpolatedAttribute(o,a,c,l,f,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new O,materialIndex:0};Cn.getNormal(na,ia,ra,h.normal),u.face=h,u.barycoord=f}return u}var Us=new at,Zf=new at,Xf=new at,tb=new at,qf=new Ge,ca=new O,al=new xn,jf=new Ge,cl=new Ki;class Fa extends _t{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Ft;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ca),this.boundingBox.expandByPoint(ca)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ca),this.boundingSphere.expandByPoint(ca)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(al.copy(this.boundingSphere),al.applyMatrix4(i),e.ray.intersectsSphere(al)===!1)return;if(jf.copy(i).invert(),cl.copy(e.ray).applyMatrix4(jf),this.boundingBox!==null){if(cl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,cl)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new at,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ie("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Zf.fromBufferAttribute(i.attributes.skinIndex,e),Xf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Us.copy(t),t.set(0,0,0,0);else Us.set(...t,1),t.set(0,0,0);Us.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Xf.getComponent(r);if(s!==0){let o=Zf.getComponent(r);qf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(tb.copy(Us).applyMatrix4(qf),s)}}if(t.isVector4)t.w=Us.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Qs extends ut{constructor(){super();this.isBone=!0,this.type="Bone"}}class eo extends At{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var Yf=new Ge,nb=new Ge;class to{constructor(e=[],t=[]){this.uuid=Gn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ie("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:nb;Yf.multiplyMatrices(o,t[r]),Yf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new to(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new eo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ie("Skeleton: No bone found with UUID:",r),s=new Qs;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class Wi extends Vt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var Kr=new Ge,Kf=new Ge,la=[],Jf=new Ft,ib=new Ge,Fs=new _t,zs=new xn;class ms extends _t{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Wi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,ib)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Ft;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Kr),Jf.copy(e.boundingBox).applyMatrix4(Kr),this.boundingBox.union(Jf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Kr),zs.copy(e.boundingSphere).applyMatrix4(Kr),this.boundingSphere.union(zs)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Fs.geometry=this.geometry,Fs.material=this.material,Fs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(zs.copy(this.boundingSphere),zs.applyMatrix4(n),e.ray.intersectsSphere(zs)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Kr),Kf.multiplyMatrices(n,Kr),Fs.matrixWorld=Kf,Fs.raycast(e,la);for(let s=0,o=la.length;s<o;s++){let a=la[s];a.instanceId=r,a.object=this,t.push(a)}la.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Wi(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new eo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var _r=new xn,rb=new Ne(0.5,0.5),ua=new O;class no{constructor(e=new Rn,t=new Rn,n=new Rn,i=new Rn,r=new Rn,s=new Rn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],v=r[15];if(i[0].setComponents(c-s,h-l,p-d,v-m).normalize(),i[1].setComponents(c+s,h+l,p+d,v+m).normalize(),i[2].setComponents(c+o,h+u,p+g,v+E).normalize(),i[3].setComponents(c-o,h-u,p-g,v-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,v-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,v-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,v+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();_r.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();_r.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_r)}intersectsSprite(e){_r.center.set(0,0,0);let t=rb.distanceTo(e.center);return _r.radius=0.7071067811865476+t,_r.applyMatrix4(e.matrixWorld),this.intersectsSphere(_r)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(ua.x=i.normal.x>0?e.max.x:e.min.x,ua.y=i.normal.y>0?e.max.y:e.min.y,ua.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ua)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class io extends hn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var xa=new O,ya=new O,Qf=new Ge,ks=new Ki,ha=new xn,ll=new O,ed=new O;class Ji extends ut{constructor(e=new en,t=new io){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)xa.fromBufferAttribute(t,i-1),ya.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=xa.distanceTo(ya);e.setAttribute("lineDistance",new un(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(ha.copy(n.boundingSphere),ha.applyMatrix4(i),ha.radius+=r,e.ray.intersectsSphere(ha)===!1)return;Qf.copy(i).invert(),ks.copy(e.ray).applyMatrix4(Qf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=fa(this,e,ks,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=fa(this,e,ks,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=fa(this,e,ks,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=fa(this,e,ks,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function fa(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(xa.fromBufferAttribute(a,r),ya.fromBufferAttribute(a,s),n.distanceSqToSegment(xa,ya,ll,ed)>i)return;ll.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ll);if(l<t.near||l>t.far)return;return{distance:l,point:ed.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var td=new O,nd=new O;class za extends Ji{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)td.fromBufferAttribute(t,i),nd.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+td.distanceTo(nd);e.setAttribute("lineDistance",new un(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ka extends Ji{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ro extends hn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var id=new Ge,fl=new Ki,da=new xn,pa=new O;class gs extends ut{constructor(e=new en,t=new ro){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(da.copy(n.boundingSphere),da.applyMatrix4(i),da.radius+=r,e.ray.intersectsSphere(da)===!1)return;id.copy(i).invert(),fl.copy(e.ray).applyMatrix4(id);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);pa.fromBufferAttribute(u,x),rd(pa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)pa.fromBufferAttribute(u,d),rd(pa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function rd(e,t,n,i,r,s,o){let a=fl.distanceSqToPoint(e);if(a<n){let c=new O;fl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class Ba extends At{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Tr extends At{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ys(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class gu extends Tr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Ga extends At{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Qi extends en{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new un(c,3)),this.setAttribute("normal",new un(l,3)),this.setAttribute("uv",new un(u,2));function d(g,x,p,m,E,R,v,M,T,A,_){let S=R/T,z=v/A,P=R/2,F=v/2,ee=M/2,I=T+1,H=A+1,q=0,C=0,X=new O;for(let k=0;k<H;k++){let Y=k*z-F;for(let Q=0;Q<I;Q++){let Se=Q*S-P;X[g]=Se*m,X[x]=Y*E,X[p]=ee,c.push(X.x,X.y,X.z),X[g]=0,X[x]=0,X[p]=M>0?1:-1,l.push(X.x,X.y,X.z),u.push(Q/T),u.push(1-k/A),q+=1}}for(let k=0;k<A;k++)for(let Y=0;Y<T;Y++){let Q=f+Y+I*k,Se=f+Y+I*(k+1),ue=f+(Y+1)+I*(k+1),Fe=f+(Y+1)+I*k;a.push(Q,Se,Fe),a.push(Se,ue,Fe),C+=6}o.addGroup(h,C,_),h+=C,f+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class so extends en{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),v=m+1+c*(p+1),M=m+1+c*p;h.push(E,R,M),h.push(R,v,M)}this.setIndex(h),this.setAttribute("position",new un(d,3)),this.setAttribute("normal",new un(g,3)),this.setAttribute("uv",new un(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new so(e.width,e.height,e.widthSegments,e.heightSegments)}}function Ar(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(sd(r))if(r.isRenderTargetTexture)Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(sd(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function tn(e){let t={};for(let n=0;n<e.length;n++){let i=Ar(e[n]);for(let r in i)t[r]=i[r]}return t}function sd(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function sb(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function _u(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var fp={clone:Ar,merge:tn},ob=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,sb=`void main() {
+}`,ab=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Pn extends hn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rb,this.fragmentShader=sb,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Tr(e.uniforms),this.uniformsGroups=ib(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ue().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new D().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ct().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ke().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class _u extends Pn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ri extends hn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ue(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yn extends Ri{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return We(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ue(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Ba extends hn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xu extends hn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class yu extends hn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Vi(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function ma(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function ob(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function sd(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function ab(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Ci{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class vu extends Ci{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+m*s[c+v]+E*s[a+v]+R*s[u+v];return r}}class Ga extends Ci{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class bu extends Ci{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Su extends Ci{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,v=l[R],M=l[R+1],T=lb(n,t,m,v,i);r[d]=fp(T,g,E,M,x)}return r}}function fp(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function cb(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function lb(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=fp(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=cb(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class vn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Vi(t,this.TimeBufferType),this.values=Vi(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Vi(e.times,Array),values:Vi(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(ma(e.settings))n.settings={inTangents:Vi(e.settings.inTangents,Array),outTangents:Vi(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new bu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ga(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Su(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Pe("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(ma(this.settings))od(this.settings.inTangents,e),od(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Fe("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Fe("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Fe("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Fe("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(yv(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Fe("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,ma(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function od(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=2301;class Qi extends vn{constructor(e,t,n){super(e,t,n)}}Qi.prototype.ValueTypeName="bool";Qi.prototype.ValueBufferType=Array;Qi.prototype.DefaultInterpolation=2300;Qi.prototype.InterpolantFactoryMethodLinear=void 0;Qi.prototype.InterpolantFactoryMethodSmooth=void 0;class Ha extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Ha.prototype.ValueTypeName="color";class er extends vn{constructor(e,t,n,i){super(e,t,n,i)}}er.prototype.ValueTypeName="number";class Mu extends Ci{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Ht.slerpFlat(r,0,s,c-o,s,c,a);return r}}class tr extends vn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Mu(this.times,this.values,this.getValueSize(),e)}}tr.prototype.ValueTypeName="quaternion";tr.prototype.InterpolantFactoryMethodSmooth=void 0;class nr extends vn{constructor(e,t,n){super(e,t,n)}}nr.prototype.ValueTypeName="string";nr.prototype.ValueBufferType=Array;nr.prototype.DefaultInterpolation=2300;nr.prototype.InterpolantFactoryMethodLinear=void 0;nr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ar extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Ar.prototype.ValueTypeName="vector";class ns{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Bn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(hb(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=ob(a);if(a=sd(a,1,l),c=sd(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new er(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function ub(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return er;case"vector":case"vector2":case"vector3":case"vector4":return Ar;case"color":return Ha;case"quaternion":return tr;case"bool":case"boolean":return Qi;case"string":return nr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function hb(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ub(e.type);if(e.times===void 0){let i=[],r=[];ab(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(ma(e.settings))n.settings={inTangents:Vi(e.settings.inTangents,Float32Array),outTangents:Vi(e.settings.outTangents,Float32Array)};return n}var ti={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(ad(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(ad(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function ad(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class no{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var dp=new no;class Pi{constructor(e){if(this.manager=e!==void 0?e:dp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Pi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ei={};class pp extends Error{constructor(e,t){super(e);this.response=t}}class io extends Pi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ti.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Ei[e]!==void 0){Ei[e].push({onLoad:t,onProgress:n,onError:i});return}Ei[e]=[],Ei[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Pe("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Ei[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let v=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let M=0,T=l.length;M<T;M++){let A=l[M];if(A.onProgress)A.onProgress(v)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new pp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ti.add(`file:${e}`,c);let l=Ei[e];delete Ei[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Ei[e];if(l===void 0)throw this.manager.itemError(e),c;delete Ei[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Yr=new WeakMap;class wu extends Pi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Yr.get(s);if(u===void 0)u=[],Yr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=es("img");function a(){if(l(),t)t(this);let u=Yr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Yr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ti.remove(`image:${e}`);let f=Yr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Yr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ti.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Va extends Pi{constructor(e){super(e)}load(e,t,n,i){let r=new At,s=new wu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class ms extends ht{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ue(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class $a extends ms{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ue(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ll=new Ge,cd=new D,ld=new D;class ro{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Js,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;cd.setFromMatrixPosition(e.matrixWorld),t.position.copy(cd),ld.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ld),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ll.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ll,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ll)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var da=new D,pa=new Ht,Qn=new D;class Wa extends ht{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(da,pa,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(da,pa,Qn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(da,pa,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(da,pa,Qn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Hi=new D,ud=new Ne,hd=new Ne;class Ut extends Wa{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=xr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Us*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return xr*2*Math.atan(Math.tan(Us*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Hi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Hi.x,Hi.y).multiplyScalar(-e/Hi.z),Hi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Hi.x,Hi.y).multiplyScalar(-e/Hi.z)}getViewSize(e,t){return this.getViewBounds(e,ud,hd),t.subVectors(hd,ud)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Us*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class mp extends ro{constructor(){super(new Ut(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=xr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Za extends ms{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new mp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class gp extends ro{constructor(){super(new Ut(90,1,0.5,500));this.isPointLightShadow=!0}}class gs extends ms{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new gp}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Rr extends Wa{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class _p extends ro{constructor(){super(new Rr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class _s extends ms{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.shadow=new _p}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class ir{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var ul=new WeakMap;class Xa extends Pi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Pe("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Pe("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(ul.has(s)===!0){if(i)i(ul.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ti.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);ul.set(a,c),ti.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ti.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Kr=-90,Jr=1;class Eu extends ht{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ut(Kr,Jr,e,t);i.layers=this.layers,this.add(i);let r=new Ut(Kr,Jr,e,t);r.layers=this.layers,this.add(r);let s=new Ut(Kr,Jr,e,t);s.layers=this.layers,this.add(s);let o=new Ut(Kr,Jr,e,t);o.layers=this.layers,this.add(o);let a=new Ut(Kr,Jr,e,t);a.layers=this.layers,this.add(a);let c=new Ut(Kr,Jr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Tu extends Ut{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Au{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Ht.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ht.multiplyQuaternionsFlat(e,s,e,t,e,n),Ht.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Ru="\\[\\]\\.:\\/",fb=new RegExp("["+Ru+"]","g"),Cu="[^"+Ru+"]",db="[^"+Ru.replace("\\.","")+"]",pb=/((?:WC+[\/:])*)/.source.replace("WC",Cu),mb=/(WCOD+)?/.source.replace("WCOD",db),gb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cu),_b=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cu),xb=new RegExp("^"+pb+mb+gb+_b+"$"),yb=["material","materials","bones","map"];class xp{constructor(e,t,n){let i=n||tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class tt{constructor(e,t,n){this.path=t,this.parsedPath=n||tt.parseTrackName(t),this.node=tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new tt(e,t,n);else return new tt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fb,"")}static parseTrackName(e){let t=xb.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(yb.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=tt.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Pe("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Fe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Fe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Fe("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}tt.Composite=xp;tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};tt.prototype.GetterByBindingType=[tt.prototype._getValue_direct,tt.prototype._getValue_array,tt.prototype._getValue_arrayElement,tt.prototype._getValue_toArray];tt.prototype.SetterByBindingTypeAndVersioning=[[tt.prototype._setValue_direct,tt.prototype._setValue_direct_setNeedsUpdate,tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[tt.prototype._setValue_array,tt.prototype._setValue_array_setNeedsUpdate,tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[tt.prototype._setValue_arrayElement,tt.prototype._setValue_arrayElement_setNeedsUpdate,tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[tt.prototype._setValue_fromArray,tt.prototype._setValue_fromArray_setNeedsUpdate,tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Pu{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var vb=new Float32Array(1);class qa extends $n{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Au(tt.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Ga(new Float32Array(2),new Float32Array(2),1,vb),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?ns.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Pu(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?ns.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class so{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=We(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(We(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Iu{static{Iu.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class ja extends $n{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Lu(e,t,n,i){let r=bb(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function bb(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Pe("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Bp(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function Sb(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var Mb=`#ifdef USE_ALPHAHASH
+}`;class In extends hn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ob,this.fragmentShader=ab,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ar(e.uniforms),this.uniformsGroups=sb(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new at().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class xu extends In{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ci extends hn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yn extends Ci{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return We(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Ha extends hn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yu extends hn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class vu extends hn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function $i(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function _a(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function cb(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function od(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function lb(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Pi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class bu extends Pi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+m*s[c+v]+E*s[a+v]+R*s[u+v];return r}}class Va extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class Su extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Mu extends Pi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,v=l[R],M=l[R+1],T=hb(n,t,m,v,i);r[d]=dp(T,g,E,M,x)}return r}}function dp(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function ub(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function hb(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=dp(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=ub(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class vn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=$i(t,this.TimeBufferType),this.values=$i(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:$i(e.times,Array),values:$i(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(_a(e.settings))n.settings={inTangents:$i(e.settings.inTangents,Array),outTangents:$i(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Va(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new bu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Mu(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(_a(this.settings))ad(this.settings.inTangents,e),ad(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(bv(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,_a(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function ad(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=2301;class er extends vn{constructor(e,t,n){super(e,t,n)}}er.prototype.ValueTypeName="bool";er.prototype.ValueBufferType=Array;er.prototype.DefaultInterpolation=2300;er.prototype.InterpolantFactoryMethodLinear=void 0;er.prototype.InterpolantFactoryMethodSmooth=void 0;class $a extends vn{constructor(e,t,n,i){super(e,t,n,i)}}$a.prototype.ValueTypeName="color";class tr extends vn{constructor(e,t,n,i){super(e,t,n,i)}}tr.prototype.ValueTypeName="number";class wu extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Ht.slerpFlat(r,0,s,c-o,s,c,a);return r}}class nr extends vn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wu(this.times,this.values,this.getValueSize(),e)}}nr.prototype.ValueTypeName="quaternion";nr.prototype.InterpolantFactoryMethodSmooth=void 0;class ir extends vn{constructor(e,t,n){super(e,t,n)}}ir.prototype.ValueTypeName="string";ir.prototype.ValueBufferType=Array;ir.prototype.DefaultInterpolation=2300;ir.prototype.InterpolantFactoryMethodLinear=void 0;ir.prototype.InterpolantFactoryMethodSmooth=void 0;class Rr extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Rr.prototype.ValueTypeName="vector";class rs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Gn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(db(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=cb(a);if(a=od(a,1,l),c=od(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new tr(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function fb(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return tr;case"vector":case"vector2":case"vector3":case"vector4":return Rr;case"color":return $a;case"quaternion":return nr;case"bool":case"boolean":return er;case"string":return ir}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function db(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=fb(e.type);if(e.times===void 0){let i=[],r=[];lb(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(_a(e.settings))n.settings={inTangents:$i(e.settings.inTangents,Float32Array),outTangents:$i(e.settings.outTangents,Float32Array)};return n}var ti={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(cd(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(cd(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function cd(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class oo{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var pp=new oo;class Ii{constructor(e){if(this.manager=e!==void 0?e:pp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ii.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ti={};class mp extends Error{constructor(e,t){super(e);this.response=t}}class ao extends Ii{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ti.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Ti[e]!==void 0){Ti[e].push({onLoad:t,onProgress:n,onError:i});return}Ti[e]=[],Ti[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ie("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Ti[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let v=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let M=0,T=l.length;M<T;M++){let A=l[M];if(A.onProgress)A.onProgress(v)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new mp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ti.add(`file:${e}`,c);let l=Ti[e];delete Ti[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Ti[e];if(l===void 0)throw this.manager.itemError(e),c;delete Ti[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Jr=new WeakMap;class Eu extends Ii{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Jr.get(s);if(u===void 0)u=[],Jr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=ns("img");function a(){if(l(),t)t(this);let u=Jr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Jr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ti.remove(`image:${e}`);let f=Jr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Jr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ti.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class _s extends Ii{constructor(e){super(e)}load(e,t,n,i){let r=new At,s=new Eu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class xs extends ut{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Wa extends xs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ul=new Ge,ld=new O,ud=new O;class co{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ld.setFromMatrixPosition(e.matrixWorld),t.position.copy(ld),ud.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ud),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ul.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ul,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ul)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var ma=new O,ga=new Ht,Qn=new O;class Za extends ut{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(ma,ga,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ma,ga,Qn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ma,ga,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ma,ga,Qn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Vi=new O,hd=new Ne,fd=new Ne;class Ut extends Za{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=yr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Bs*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return yr*2*Math.atan(Math.tan(Bs*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Vi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z),Vi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z)}getViewSize(e,t){return this.getViewBounds(e,hd,fd),t.subVectors(fd,hd)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Bs*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class gp extends co{constructor(){super(new Ut(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=yr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Xa extends xs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new gp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class _p extends co{constructor(){super(new Ut(90,1,0.5,500));this.isPointLightShadow=!0}}class ys extends xs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new _p}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Cr extends Za{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class xp extends co{constructor(){super(new Cr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class vs extends xs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new xp}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class rr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var hl=new WeakMap;class qa extends Ii{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ie("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ie("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(hl.has(s)===!0){if(i)i(hl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ti.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);hl.set(a,c),ti.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ti.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Qr=-90,es=1;class Tu extends ut{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ut(Qr,es,e,t);i.layers=this.layers,this.add(i);let r=new Ut(Qr,es,e,t);r.layers=this.layers,this.add(r);let s=new Ut(Qr,es,e,t);s.layers=this.layers,this.add(s);let o=new Ut(Qr,es,e,t);o.layers=this.layers,this.add(o);let a=new Ut(Qr,es,e,t);a.layers=this.layers,this.add(a);let c=new Ut(Qr,es,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Au extends Ut{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ru{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Ht.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ht.multiplyQuaternionsFlat(e,s,e,t,e,n),Ht.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Cu="\\[\\]\\.:\\/",pb=new RegExp("["+Cu+"]","g"),Pu="[^"+Cu+"]",mb="[^"+Cu.replace("\\.","")+"]",gb=/((?:WC+[\/:])*)/.source.replace("WC",Pu),_b=/(WCOD+)?/.source.replace("WCOD",mb),xb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Pu),yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Pu),vb=new RegExp("^"+gb+_b+xb+yb+"$"),bb=["material","materials","bones","map"];class yp{constructor(e,t,n){let i=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new et(e,t,n);else return new et.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(pb,"")}static parseTrackName(e){let t=vb.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(bb.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=et.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=yp;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Iu{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var Sb=new Float32Array(1);class ja extends Wn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Ru(et.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Va(new Float32Array(2),new Float32Array(2),1,Sb),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?rs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Iu(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?rs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class lo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=We(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(We(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Lu{static{Lu.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class Ya extends Wn{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Nu(e,t,n,i){let r=Mb(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Mb(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ie("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Gp(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function wb(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var Eb=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,wb=`#ifdef USE_ALPHAHASH
+#endif`,Tb=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -163,20 +163,20 @@
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,Eb=`#ifdef USE_ALPHAMAP
+#endif`,Ab=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,Tb=`#ifdef USE_ALPHAMAP
+#endif`,Rb=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,Ab=`#ifdef USE_ALPHATEST
+#endif`,Cb=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
-#endif`,Rb=`#ifdef USE_ALPHATEST
+#endif`,Pb=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,Cb=`#ifdef USE_AOMAP
+#endif`,Ib=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
@@ -189,10 +189,10 @@
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,Pb=`#ifdef USE_AOMAP
+#endif`,Lb=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,Ib=`#ifdef USE_BATCHING
+#endif`,Nb=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
@@ -226,15 +226,15 @@
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
-#endif`,Lb=`#ifdef USE_BATCHING
+#endif`,Db=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,Nb=`vec3 transformed = vec3( position );
+#endif`,Ob=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,Db=`vec3 objectNormal = vec3( normal );
+#endif`,Ub=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,Ob=`float G_BlinnPhong_Implicit( ) {
+#endif`,Fb=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
-} // validated`,Ub=`#ifdef USE_IRIDESCENCE
+} // validated`,zb=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
@@ -311,7 +311,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
}
return max( I, vec3( 0.0 ) );
}
-#endif`,Fb=`#ifdef USE_BUMPMAP
+#endif`,kb=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
@@ -332,7 +332,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
-#endif`,zb=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Bb=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
@@ -378,20 +378,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
if ( clipped ) discard;
#endif
#endif
-#endif`,kb=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Gb=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,Bb=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Hb=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,Gb=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Vb=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,Hb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,$b=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,Vb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,Wb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,$b=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,Zb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,Wb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,Xb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
@@ -404,7 +404,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
-#endif`,Zb=`#define PI 3.141592653589793
+#endif`,qb=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
@@ -475,7 +475,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
-} // validated`,Xb=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,jb=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
@@ -568,7 +568,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
-#endif`,qb=`vec3 transformedNormal = objectNormal;
+#endif`,Yb=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
@@ -594,21 +594,21 @@ transformedNormal = normalMatrix * transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
-#endif`,jb=`#ifdef USE_DISPLACEMENTMAP
+#endif`,Kb=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,Yb=`#ifdef USE_DISPLACEMENTMAP
+#endif`,Jb=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,Kb=`#ifdef USE_EMISSIVEMAP
+#endif`,Qb=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,Jb=`#ifdef USE_EMISSIVEMAP
+#endif`,eS=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,Qb="gl_FragColor = linearToOutputTexel( gl_FragColor );",eS=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,tS="gl_FragColor = linearToOutputTexel( gl_FragColor );",nS=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -616,7 +616,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
-}`,tS=`#ifdef USE_ENVMAP
+}`,iS=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
@@ -643,7 +643,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
-#endif`,nS=`#ifdef USE_ENVMAP
+#endif`,rS=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
@@ -651,7 +651,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
uniform sampler2D envMap;
#endif
-#endif`,iS=`#ifdef USE_ENVMAP
+#endif`,sS=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
@@ -662,7 +662,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
varying vec3 vReflect;
#endif
-#endif`,rS=`#ifdef USE_ENVMAP
+#endif`,oS=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
@@ -673,7 +673,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,sS=`#ifdef USE_ENVMAP
+#endif`,aS=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
@@ -690,18 +690,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,oS=`#ifdef USE_FOG
+#endif`,cS=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,aS=`#ifdef USE_FOG
+#endif`,lS=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,cS=`#ifdef USE_FOG
+#endif`,uS=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
-#endif`,lS=`#ifdef USE_FOG
+#endif`,hS=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
@@ -710,7 +710,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,uS=`#ifdef USE_GRADIENTMAP
+#endif`,fS=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -722,12 +722,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
-}`,hS=`#ifdef USE_LIGHTMAP
+}`,dS=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,fS=`LambertMaterial material;
+#endif`,pS=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,dS=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,mS=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
@@ -741,7 +741,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pS=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,gS=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
@@ -870,7 +870,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return irradiance;
}
#endif
-#include <lightprobes_pars_fragment>`,mS=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,_S=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -927,8 +927,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
}
#endif
#endif
-#endif`,gS=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,_S=`varying vec3 vViewPosition;
+#endif`,xS=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,yS=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
@@ -940,11 +940,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xS=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,vS=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,yS=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,bS=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
@@ -961,7 +961,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,vS=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,SS=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
@@ -1054,7 +1054,7 @@ material.roughness = min( material.roughness, 1.0 );
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
-#endif`,bS=`uniform sampler2D dfgLUT;
+#endif`,MS=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
@@ -1421,7 +1421,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
-}`,SS=`
+}`,wS=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1569,7 +1569,7 @@ IncidentLight directLight;
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,MS=`#if defined( RE_IndirectDiffuse )
+#endif`,ES=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1599,7 +1599,7 @@ IncidentLight directLight;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,wS=`#if defined( RE_IndirectDiffuse )
+#endif`,TS=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
@@ -1607,7 +1607,7 @@ IncidentLight directLight;
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,ES=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,AS=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1652,27 +1652,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,TS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,RS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,AS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,CS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,RS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,PS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,CS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,IS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,PS=`#ifdef USE_MAP
+#endif`,LS=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,IS=`#ifdef USE_MAP
+#endif`,NS=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,LS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,DS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
@@ -1684,7 +1684,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,NS=`#if defined( USE_POINTS_UV )
+#endif`,OS=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1696,19 +1696,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,DS=`float metalnessFactor = metalness;
+#endif`,US=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,OS=`#ifdef USE_METALNESSMAP
+#endif`,FS=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,US=`#ifdef USE_INSTANCING_MORPH
+#endif`,zS=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
-#endif`,FS=`#if defined( USE_MORPHCOLORS )
+#endif`,kS=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
@@ -1717,12 +1717,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,zS=`#ifdef USE_MORPHNORMALS
+#endif`,BS=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
-#endif`,kS=`#ifdef USE_MORPHTARGETS
+#endif`,GS=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1736,12 +1736,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
-#endif`,BS=`#ifdef USE_MORPHTARGETS
+#endif`,HS=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
-#endif`,GS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,VS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
@@ -1782,7 +1782,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
@@ -1800,19 +1800,19 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,VS=`#ifndef FLAT_SHADED
+#endif`,WS=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,$S=`#ifndef FLAT_SHADED
+#endif`,ZS=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,WS=`#ifndef FLAT_SHADED
+#endif`,XS=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,ZS=`#ifdef USE_NORMALMAP
+#endif`,qS=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1843,13 +1843,13 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,XS=`#ifdef USE_CLEARCOAT
+#endif`,jS=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,qS=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,YS=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,jS=`#ifdef USE_CLEARCOATMAP
+#endif`,KS=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,YS=`#ifdef USE_IRIDESCENCEMAP
+#endif`,JS=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,KS=`#ifdef OPAQUE
+#endif`,QS=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JS=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eM=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1948,9 +1948,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
-}`,QS=`#ifdef PREMULTIPLIED_ALPHA
+}`,tM=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,eM=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,nM=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
@@ -1958,22 +1958,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,nM=`#ifdef DITHERING
+#endif`,rM=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
-#endif`,iM=`float roughnessFactor = roughness;
+#endif`,sM=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,rM=`#ifdef USE_ROUGHNESSMAP
+#endif`,oM=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,sM=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,aM=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
@@ -2224,7 +2224,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
}
#endif
#endif
-#endif`,oM=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,cM=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
@@ -2269,7 +2269,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,aM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
+#endif`,lM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
@@ -2309,7 +2309,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,cM=`float getShadowMask() {
+#endif`,uM=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,lM=`#ifdef USE_SKINNING
+}`,hM=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,uM=`#ifdef USE_SKINNING
+#endif`,fM=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,hM=`#ifdef USE_SKINNING
+#endif`,dM=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2378,7 +2378,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,fM=`#ifdef USE_SKINNING
+#endif`,pM=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,dM=`float specularStrength;
+#endif`,mM=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,pM=`#ifdef USE_SPECULARMAP
+#endif`,gM=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,mM=`#if defined( TONE_MAPPING )
+#endif`,_M=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,gM=`#ifndef saturate
+#endif`,xM=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
@@ -2496,7 +2496,7 @@ vec3 NeutralToneMapping( vec3 color ) {
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
-vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,xM=`#ifdef USE_TRANSMISSION
+#endif`,vM=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
-#endif`,yM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,bM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,vM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,SM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,bM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,MM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
@@ -2878,7 +2878,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var SM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`;var wM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
@@ -2887,12 +2887,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,MM=`varying vec2 vUv;
+#endif`,EM=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,wM=`uniform sampler2D t2D;
+}`,TM=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
@@ -2904,14 +2904,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,EM=`varying vec3 vWorldDirection;
+}`,AM=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,TM=`#ifdef ENVMAP_TYPE_CUBE
+}`,RM=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
@@ -2933,14 +2933,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,AM=`varying vec3 vWorldDirection;
+}`,CM=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,RM=`uniform samplerCube tCube;
+}`,PM=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
@@ -2950,7 +2950,7 @@ void main() {
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,CM=`#include <common>
+}`,IM=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
@@ -2977,7 +2977,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,PM=`#if DEPTH_PACKING == 3200
+}`,LM=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
@@ -3015,7 +3015,7 @@ void main() {
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,IM=`#define DISTANCE
+}`,NM=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3042,7 +3042,7 @@ void main() {
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,LM=`#define DISTANCE
+}`,DM=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
@@ -3065,13 +3065,13 @@ void main() {
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
-}`,NM=`varying vec3 vWorldDirection;
+}`,OM=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,DM=`uniform sampler2D tEquirect;
+}`,UM=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
@@ -3080,7 +3080,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,OM=`uniform float scale;
+}`,FM=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
@@ -3102,7 +3102,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,UM=`uniform vec3 diffuse;
+}`,zM=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
@@ -3130,7 +3130,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,FM=`#include <common>
+}`,kM=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
@@ -3162,7 +3162,7 @@ void main() {
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,zM=`uniform vec3 diffuse;
+}`,BM=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
@@ -3210,7 +3210,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,kM=`#define LAMBERT
+}`,GM=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3249,7 +3249,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,BM=`#define LAMBERT
+}`,HM=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3307,7 +3307,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,GM=`#define MATCAP
+}`,VM=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3341,7 +3341,7 @@ void main() {
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,HM=`#define MATCAP
+}`,$M=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
@@ -3387,7 +3387,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,VM=`#define NORMAL
+}`,WM=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
@@ -3420,7 +3420,7 @@ void main() {
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,$M=`#define NORMAL
+}`,ZM=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
@@ -3441,7 +3441,7 @@ void main() {
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,WM=`#define PHONG
+}`,XM=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3480,7 +3480,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,ZM=`#define PHONG
+}`,qM=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
@@ -3540,7 +3540,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,XM=`#define STANDARD
+}`,jM=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3583,7 +3583,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,qM=`#define STANDARD
+}`,YM=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
@@ -3711,7 +3711,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,jM=`#define TOON
+}`,KM=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3748,7 +3748,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,YM=`#define TOON
+}`,JM=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3800,7 +3800,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,KM=`uniform float size;
+}`,QM=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
@@ -3831,7 +3831,7 @@ void main() {
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,JM=`uniform vec3 diffuse;
+}`,ew=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
@@ -3856,7 +3856,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,QM=`#include <common>
+}`,tw=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
@@ -3879,7 +3879,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,ew=`uniform vec3 color;
+}`,nw=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
@@ -3895,7 +3895,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,tw=`uniform float rotation;
+}`,iw=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
@@ -3919,7 +3919,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,nw=`uniform vec3 diffuse;
+}`,rw=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -3944,7 +3944,7 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,Ve={alphahash_fragment:Mb,alphahash_pars_fragment:wb,alphamap_fragment:Eb,alphamap_pars_fragment:Tb,alphatest_fragment:Ab,alphatest_pars_fragment:Rb,aomap_fragment:Cb,aomap_pars_fragment:Pb,batching_pars_vertex:Ib,batching_vertex:Lb,begin_vertex:Nb,beginnormal_vertex:Db,bsdfs:Ob,iridescence_fragment:Ub,bumpmap_pars_fragment:Fb,clipping_planes_fragment:zb,clipping_planes_pars_fragment:kb,clipping_planes_pars_vertex:Bb,clipping_planes_vertex:Gb,color_fragment:Hb,color_pars_fragment:Vb,color_pars_vertex:$b,color_vertex:Wb,common:Zb,cube_uv_reflection_fragment:Xb,defaultnormal_vertex:qb,displacementmap_pars_vertex:jb,displacementmap_vertex:Yb,emissivemap_fragment:Kb,emissivemap_pars_fragment:Jb,colorspace_fragment:Qb,colorspace_pars_fragment:eS,envmap_fragment:tS,envmap_common_pars_fragment:nS,envmap_pars_fragment:iS,envmap_pars_vertex:rS,envmap_physical_pars_fragment:mS,envmap_vertex:sS,fog_vertex:oS,fog_pars_vertex:aS,fog_fragment:cS,fog_pars_fragment:lS,gradientmap_pars_fragment:uS,lightmap_pars_fragment:hS,lights_lambert_fragment:fS,lights_lambert_pars_fragment:dS,lights_pars_begin:pS,lights_toon_fragment:gS,lights_toon_pars_fragment:_S,lights_phong_fragment:xS,lights_phong_pars_fragment:yS,lights_physical_fragment:vS,lights_physical_pars_fragment:bS,lights_fragment_begin:SS,lights_fragment_maps:MS,lights_fragment_end:wS,lightprobes_pars_fragment:ES,logdepthbuf_fragment:TS,logdepthbuf_pars_fragment:AS,logdepthbuf_pars_vertex:RS,logdepthbuf_vertex:CS,map_fragment:PS,map_pars_fragment:IS,map_particle_fragment:LS,map_particle_pars_fragment:NS,metalnessmap_fragment:DS,metalnessmap_pars_fragment:OS,morphinstance_vertex:US,morphcolor_vertex:FS,morphnormal_vertex:zS,morphtarget_pars_vertex:kS,morphtarget_vertex:BS,normal_fragment_begin:GS,normal_fragment_maps:HS,normal_pars_fragment:VS,normal_pars_vertex:$S,normal_vertex:WS,normalmap_pars_fragment:ZS,clearcoat_normal_fragment_begin:XS,clearcoat_normal_fragment_maps:qS,clearcoat_pars_fragment:jS,iridescence_pars_fragment:YS,opaque_fragment:KS,packing:JS,premultiplied_alpha_fragment:QS,project_vertex:eM,dithering_fragment:tM,dithering_pars_fragment:nM,roughnessmap_fragment:iM,roughnessmap_pars_fragment:rM,shadowmap_pars_fragment:sM,shadowmap_pars_vertex:oM,shadowmap_vertex:aM,shadowmask_pars_fragment:cM,skinbase_vertex:lM,skinning_pars_vertex:uM,skinning_vertex:hM,skinnormal_vertex:fM,specularmap_fragment:dM,specularmap_pars_fragment:pM,tonemapping_fragment:mM,tonemapping_pars_fragment:gM,transmission_fragment:_M,transmission_pars_fragment:xM,uv_pars_fragment:yM,uv_pars_vertex:vM,uv_vertex:bM,worldpos_vertex:SM,background_vert:MM,background_frag:wM,backgroundCube_vert:EM,backgroundCube_frag:TM,cube_vert:AM,cube_frag:RM,depth_vert:CM,depth_frag:PM,distance_vert:IM,distance_frag:LM,equirect_vert:NM,equirect_frag:DM,linedashed_vert:OM,linedashed_frag:UM,meshbasic_vert:FM,meshbasic_frag:zM,meshlambert_vert:kM,meshlambert_frag:BM,meshmatcap_vert:GM,meshmatcap_frag:HM,meshnormal_vert:VM,meshnormal_frag:$M,meshphong_vert:WM,meshphong_frag:ZM,meshphysical_vert:XM,meshphysical_frag:qM,meshtoon_vert:jM,meshtoon_frag:YM,points_vert:KM,points_frag:JM,shadow_vert:QM,shadow_frag:ew,sprite_vert:tw,sprite_frag:nw},de={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},li={basic:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Ue(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:tn([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:tn([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:tn([de.points,de.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:tn([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:tn([de.common,de.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:tn([de.sprite,de.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:tn([de.common,de.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:tn([de.lights,de.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};li.physical={uniforms:tn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Ya={r:0,b:0,g:0},iw=new Ge,Gp=new ke;Gp.set(-1,0,0,0,1,0,0,0,1);function rw(e,t,n,i,r,s){let o=new Ue(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let v=E.backgroundBlurriness>0;R=t.get(R,v)}return R}function g(E){let R=!1,v=d(E);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),R=!0;let M=e.xr.getEnvironmentBlendMode();if(M==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(M==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let v=d(R);if(v&&(v.isCubeTexture||v.mapping===Hs)){if(l===void 0)l=new xt(new Ji(1,1,1),new Pn({name:"BackgroundCubeMaterial",uniforms:Tr(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(iw.makeRotationFromEuler(R.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Gp);if(l.material.toneMapped=$e.getTransfer(v.colorSpace)!==pt,u!==v||f!==v.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new xt(new to(2,2),new Pn({name:"BackgroundMaterial",uniforms:Tr(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:Xi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(v.colorSpace)!==pt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||f!==v.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Ya,gu(e)),n.buffers.color.setClear(Ya.r,Ya.g,Ya.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function sw(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,U,ee,P,V){let j=!1,z=f(C,P,ee,U);if(s!==z)s=z,l(s.object);if(j=d(C,P,ee,V),j)g(C,P,ee,V);if(V!==null)t.update(V,e.ELEMENT_ARRAY_BUFFER);if(j||o){if(o=!1,v(C,U,ee,P),V!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(V).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function f(C,U,ee,P){let V=P.wireframe===!0,j=i[U.id];if(j===void 0)j={},i[U.id]=j;let z=C.isInstancedMesh===!0?C.id:0,H=j[z];if(H===void 0)H={},j[z]=H;let F=H[ee.id];if(F===void 0)F={},H[ee.id]=F;let q=F[V];if(q===void 0)q=h(c()),F[V]=q;return q}function h(C){let U=[],ee=[],P=[];for(let V=0;V<n;V++)U[V]=0,ee[V]=0,P[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:ee,attributeDivisors:P,object:C,attributes:{},index:null}}function d(C,U,ee,P){let V=s.attributes,j=U.attributes,z=0,H=ee.getAttributes();for(let F in H)if(H[F].location>=0){let K=V[F],xe=j[F];if(xe===void 0){if(F==="instanceMatrix"&&C.instanceMatrix)xe=C.instanceMatrix;if(F==="instanceColor"&&C.instanceColor)xe=C.instanceColor}if(K===void 0)return!0;if(K.attribute!==xe)return!0;if(xe&&K.data!==xe.data)return!0;z++}if(s.attributesNum!==z)return!0;if(s.index!==P)return!0;return!1}function g(C,U,ee,P){let V={},j=U.attributes,z=0,H=ee.getAttributes();for(let F in H)if(H[F].location>=0){let K=j[F];if(K===void 0){if(F==="instanceMatrix"&&C.instanceMatrix)K=C.instanceMatrix;if(F==="instanceColor"&&C.instanceColor)K=C.instanceColor}let xe={};if(xe.attribute=K,K&&K.data)xe.data=K.data;V[F]=xe,z++}s.attributes=V,s.attributesNum=z,s.index=P}function x(){let C=s.newAttributes;for(let U=0,ee=C.length;U<ee;U++)C[U]=0}function p(C){m(C,0)}function m(C,U){let ee=s.newAttributes,P=s.enabledAttributes,V=s.attributeDivisors;if(ee[C]=1,P[C]===0)e.enableVertexAttribArray(C),P[C]=1;if(V[C]!==U)e.vertexAttribDivisor(C,U),V[C]=U}function E(){let C=s.newAttributes,U=s.enabledAttributes;for(let ee=0,P=U.length;ee<P;ee++)if(U[ee]!==C[ee])e.disableVertexAttribArray(ee),U[ee]=0}function R(C,U,ee,P,V,j,z){if(z===!0)e.vertexAttribIPointer(C,U,ee,V,j);else e.vertexAttribPointer(C,U,ee,P,V,j)}function v(C,U,ee,P){x();let V=P.attributes,j=ee.getAttributes(),z=U.defaultAttributeValues;for(let H in j){let F=j[H];if(F.location>=0){let q=V[H];if(q===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let K=q.normalized,xe=q.itemSize,ce=t.get(q);if(ce===void 0)continue;let{buffer:De,type:ye,bytesPerElement:X}=ce,re=ye===e.INT||ye===e.UNSIGNED_INT||q.gpuType===Ml;if(q.isInterleavedBufferAttribute){let se=q.data,Te=se.stride,Ie=q.offset;if(se.isInstancedInterleavedBuffer){for(let _e=0;_e<F.locationSize;_e++)m(F.location+_e,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=se.meshPerAttribute*se.count}else for(let _e=0;_e<F.locationSize;_e++)p(F.location+_e);e.bindBuffer(e.ARRAY_BUFFER,De);for(let _e=0;_e<F.locationSize;_e++)R(F.location+_e,xe/F.locationSize,ye,K,Te*X,(Ie+xe/F.locationSize*_e)*X,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<F.locationSize;se++)m(F.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<F.locationSize;se++)p(F.location+se);e.bindBuffer(e.ARRAY_BUFFER,De);for(let se=0;se<F.locationSize;se++)R(F.location+se,xe/F.locationSize,ye,K,xe*X,xe/F.locationSize*se*X,re)}}else if(z!==void 0){let K=z[H];if(K!==void 0)switch(K.length){case 2:e.vertexAttrib2fv(F.location,K);break;case 3:e.vertexAttrib3fv(F.location,K);break;case 4:e.vertexAttrib4fv(F.location,K);break;default:e.vertexAttrib1fv(F.location,K)}}}}E()}function M(){S();for(let C in i){let U=i[C];for(let ee in U){let P=U[ee];for(let V in P){let j=P[V];for(let z in j)u(j[z].object),delete j[z];delete P[V]}}delete i[C]}}function T(C){if(i[C.id]===void 0)return;let U=i[C.id];for(let ee in U){let P=U[ee];for(let V in P){let j=P[V];for(let z in j)u(j[z].object),delete j[z];delete P[V]}}delete i[C.id]}function A(C){for(let U in i){let ee=i[U];for(let P in ee){let V=ee[P];if(V[C.id]===void 0)continue;let j=V[C.id];for(let z in j)u(j[z].object),delete j[z];delete V[C.id]}}}function _(C){for(let U in i){let ee=i[U],P=C.isInstancedMesh===!0?C.id:0,V=ee[P];if(V===void 0)continue;for(let j in V){let z=V[j];for(let H in z)u(z[H].object),delete z[H];delete V[j]}if(delete ee[P],Object.keys(ee).length===0)delete i[U]}}function S(){if(k(),o=!0,s===r)return;s=r,l(s.object)}function k(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:S,resetDefaultState:k,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function ow(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function aw(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==oi&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===si&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==Vn&&A!==Ai&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Pe("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Pe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),M=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:v,maxSamples:M,samples:T}}function cw(e){let t=this,n=null,i=0,r=!1,s=!1,o=new An,a=new ke,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,v=m.clippingState||null;c.value=v,v=u(g,h,R,d);for(let M=0;M!==R;++M)v[M]=n[M];m.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,v=d;R!==x;++R,v+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var ys=4,lw=6,uw=20,hw=256,oo=new Rr,yp=new Ue,Nu=null,Du=0,Ou=0,Uu=!1,fw=new D,Cr=new D;class uo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=fw}=r;Nu=this._renderer.getRenderTarget(),Du=this._renderer.getActiveCubeFace(),Ou=this._renderer.getActiveMipmapLevel(),Uu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Sp(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=bp(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Nu,Du,Ou),this._renderer.xr.enabled=Uu,e.scissorTest=!1,xs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ss||e.mapping===yr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Nu=this._renderer.getRenderTarget(),Du=this._renderer.getActiveCubeFace(),Ou=this._renderer.getActiveMipmapLevel(),Uu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:$t,minFilter:$t,generateMipmaps:!1,type:si,format:oi,colorSpace:gn,depthBuffer:!1},i=vp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=vp(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=dw(r)),this._blurMaterial=mw(r,e,t),this._ggxMaterial=pw(r,e,t)}return i}_compileMaterial(e){let t=new xt(new en,e);this._renderer.compile(t,oo)}_sceneToCubeUV(e,t,n,i,r){let a=new Ut(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(yp),u.toneMapping=Gn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new xt(new Ji,new ai({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(yp),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let v=this._cubeSize;if(xs(i,R*v,E>2?v:0,v,v),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ss||e.mapping===yr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Sp();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=bp();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;xs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,oo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-ys?n-d+ys:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,xs(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,oo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,xs(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,oo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-ys?i-this._lodMax+ys:0),f=4*(this._cubeSize-l);xs(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,oo)}}function dw(e){let t=[],n=[],i=e,r=e-ys+1+lw;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,v=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(v,d*h*m);for(let M=0;M<h;M++){let T=u[M*2]*2-1,A=u[M*2+1]*2-1;if(m===0)Cr.set(1,A,T);else if(m===1)Cr.set(-T,1,-A);else if(m===2)Cr.set(-T,A,1);else if(m===3)Cr.set(-1,A,-T);else if(m===4)Cr.set(-T,-1,A);else Cr.set(T,A,-1);Cr.toArray(x,(m*h+M)*d)}}let p=new en;if(p.setAttribute("position",new Vt(g,d)),p.setAttribute("outputDirection",new Vt(x,d)),n.push(new xt(p,null)),i>ys)i--}return{lodMeshes:n,sizeLods:t}}function vp(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=Hs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function pw(e,t,n){return new Pn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:hw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ja(),fragmentShader:`
+}`,Ve={alphahash_fragment:Eb,alphahash_pars_fragment:Tb,alphamap_fragment:Ab,alphamap_pars_fragment:Rb,alphatest_fragment:Cb,alphatest_pars_fragment:Pb,aomap_fragment:Ib,aomap_pars_fragment:Lb,batching_pars_vertex:Nb,batching_vertex:Db,begin_vertex:Ob,beginnormal_vertex:Ub,bsdfs:Fb,iridescence_fragment:zb,bumpmap_pars_fragment:kb,clipping_planes_fragment:Bb,clipping_planes_pars_fragment:Gb,clipping_planes_pars_vertex:Hb,clipping_planes_vertex:Vb,color_fragment:$b,color_pars_fragment:Wb,color_pars_vertex:Zb,color_vertex:Xb,common:qb,cube_uv_reflection_fragment:jb,defaultnormal_vertex:Yb,displacementmap_pars_vertex:Kb,displacementmap_vertex:Jb,emissivemap_fragment:Qb,emissivemap_pars_fragment:eS,colorspace_fragment:tS,colorspace_pars_fragment:nS,envmap_fragment:iS,envmap_common_pars_fragment:rS,envmap_pars_fragment:sS,envmap_pars_vertex:oS,envmap_physical_pars_fragment:_S,envmap_vertex:aS,fog_vertex:cS,fog_pars_vertex:lS,fog_fragment:uS,fog_pars_fragment:hS,gradientmap_pars_fragment:fS,lightmap_pars_fragment:dS,lights_lambert_fragment:pS,lights_lambert_pars_fragment:mS,lights_pars_begin:gS,lights_toon_fragment:xS,lights_toon_pars_fragment:yS,lights_phong_fragment:vS,lights_phong_pars_fragment:bS,lights_physical_fragment:SS,lights_physical_pars_fragment:MS,lights_fragment_begin:wS,lights_fragment_maps:ES,lights_fragment_end:TS,lightprobes_pars_fragment:AS,logdepthbuf_fragment:RS,logdepthbuf_pars_fragment:CS,logdepthbuf_pars_vertex:PS,logdepthbuf_vertex:IS,map_fragment:LS,map_pars_fragment:NS,map_particle_fragment:DS,map_particle_pars_fragment:OS,metalnessmap_fragment:US,metalnessmap_pars_fragment:FS,morphinstance_vertex:zS,morphcolor_vertex:kS,morphnormal_vertex:BS,morphtarget_pars_vertex:GS,morphtarget_vertex:HS,normal_fragment_begin:VS,normal_fragment_maps:$S,normal_pars_fragment:WS,normal_pars_vertex:ZS,normal_vertex:XS,normalmap_pars_fragment:qS,clearcoat_normal_fragment_begin:jS,clearcoat_normal_fragment_maps:YS,clearcoat_pars_fragment:KS,iridescence_pars_fragment:JS,opaque_fragment:QS,packing:eM,premultiplied_alpha_fragment:tM,project_vertex:nM,dithering_fragment:iM,dithering_pars_fragment:rM,roughnessmap_fragment:sM,roughnessmap_pars_fragment:oM,shadowmap_pars_fragment:aM,shadowmap_pars_vertex:cM,shadowmap_vertex:lM,shadowmask_pars_fragment:uM,skinbase_vertex:hM,skinning_pars_vertex:fM,skinning_vertex:dM,skinnormal_vertex:pM,specularmap_fragment:mM,specularmap_pars_fragment:gM,tonemapping_fragment:_M,tonemapping_pars_fragment:xM,transmission_fragment:yM,transmission_pars_fragment:vM,uv_pars_fragment:bM,uv_pars_vertex:SM,uv_vertex:MM,worldpos_vertex:wM,background_vert:EM,background_frag:TM,backgroundCube_vert:AM,backgroundCube_frag:RM,cube_vert:CM,cube_frag:PM,depth_vert:IM,depth_frag:LM,distance_vert:NM,distance_frag:DM,equirect_vert:OM,equirect_frag:UM,linedashed_vert:FM,linedashed_frag:zM,meshbasic_vert:kM,meshbasic_frag:BM,meshlambert_vert:GM,meshlambert_frag:HM,meshmatcap_vert:VM,meshmatcap_frag:$M,meshnormal_vert:WM,meshnormal_frag:ZM,meshphong_vert:XM,meshphong_frag:qM,meshphysical_vert:jM,meshphysical_frag:YM,meshtoon_vert:KM,meshtoon_frag:JM,points_vert:QM,points_frag:ew,shadow_vert:tw,shadow_frag:nw,sprite_vert:iw,sprite_frag:rw},de={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},li={basic:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:tn([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:tn([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:tn([de.points,de.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:tn([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:tn([de.common,de.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:tn([de.sprite,de.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:tn([de.common,de.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:tn([de.lights,de.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};li.physical={uniforms:tn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Ka={r:0,b:0,g:0},sw=new Ge,Hp=new ze;Hp.set(-1,0,0,0,1,0,0,0,1);function ow(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let v=E.backgroundBlurriness>0;R=t.get(R,v)}return R}function g(E){let R=!1,v=d(E);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),R=!0;let M=e.xr.getEnvironmentBlendMode();if(M==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(M==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let v=d(R);if(v&&(v.isCubeTexture||v.mapping===Zs)){if(l===void 0)l=new _t(new Qi(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:Ar(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(sw.makeRotationFromEuler(R.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Hp);if(l.material.toneMapped=$e.getTransfer(v.colorSpace)!==dt,u!==v||f!==v.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new _t(new so(2,2),new In({name:"BackgroundMaterial",uniforms:Ar(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:qi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(v.colorSpace)!==dt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||f!==v.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Ka,_u(e)),n.buffers.color.setClear(Ka.r,Ka.g,Ka.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function aw(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(P,F,ee,I,H){let q=!1,C=f(P,I,ee,F);if(s!==C)s=C,l(s.object);if(q=d(P,I,ee,H),q)g(P,I,ee,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(q||o){if(o=!1,v(P,F,ee,I),H!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(H).buffer)}}function c(){return e.createVertexArray()}function l(P){return e.bindVertexArray(P)}function u(P){return e.deleteVertexArray(P)}function f(P,F,ee,I){let H=I.wireframe===!0,q=i[F.id];if(q===void 0)q={},i[F.id]=q;let C=P.isInstancedMesh===!0?P.id:0,X=q[C];if(X===void 0)X={},q[C]=X;let k=X[ee.id];if(k===void 0)k={},X[ee.id]=k;let Y=k[H];if(Y===void 0)Y=h(c()),k[H]=Y;return Y}function h(P){let F=[],ee=[],I=[];for(let H=0;H<n;H++)F[H]=0,ee[H]=0,I[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:ee,attributeDivisors:I,object:P,attributes:{},index:null}}function d(P,F,ee,I){let H=s.attributes,q=F.attributes,C=0,X=ee.getAttributes();for(let k in X)if(X[k].location>=0){let Q=H[k],Se=q[k];if(Se===void 0){if(k==="instanceMatrix"&&P.instanceMatrix)Se=P.instanceMatrix;if(k==="instanceColor"&&P.instanceColor)Se=P.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Se)return!0;if(Se&&Q.data!==Se.data)return!0;C++}if(s.attributesNum!==C)return!0;if(s.index!==I)return!0;return!1}function g(P,F,ee,I){let H={},q=F.attributes,C=0,X=ee.getAttributes();for(let k in X)if(X[k].location>=0){let Q=q[k];if(Q===void 0){if(k==="instanceMatrix"&&P.instanceMatrix)Q=P.instanceMatrix;if(k==="instanceColor"&&P.instanceColor)Q=P.instanceColor}let Se={};if(Se.attribute=Q,Q&&Q.data)Se.data=Q.data;H[k]=Se,C++}s.attributes=H,s.attributesNum=C,s.index=I}function x(){let P=s.newAttributes;for(let F=0,ee=P.length;F<ee;F++)P[F]=0}function p(P){m(P,0)}function m(P,F){let ee=s.newAttributes,I=s.enabledAttributes,H=s.attributeDivisors;if(ee[P]=1,I[P]===0)e.enableVertexAttribArray(P),I[P]=1;if(H[P]!==F)e.vertexAttribDivisor(P,F),H[P]=F}function E(){let P=s.newAttributes,F=s.enabledAttributes;for(let ee=0,I=F.length;ee<I;ee++)if(F[ee]!==P[ee])e.disableVertexAttribArray(ee),F[ee]=0}function R(P,F,ee,I,H,q,C){if(C===!0)e.vertexAttribIPointer(P,F,ee,H,q);else e.vertexAttribPointer(P,F,ee,I,H,q)}function v(P,F,ee,I){x();let H=I.attributes,q=ee.getAttributes(),C=F.defaultAttributeValues;for(let X in q){let k=q[X];if(k.location>=0){let Y=H[X];if(Y===void 0){if(X==="instanceMatrix"&&P.instanceMatrix)Y=P.instanceMatrix;if(X==="instanceColor"&&P.instanceColor)Y=P.instanceColor}if(Y!==void 0){let Q=Y.normalized,Se=Y.itemSize,ue=t.get(Y);if(ue===void 0)continue;let{buffer:Fe,type:Me,bytesPerElement:Z}=ue,re=Me===e.INT||Me===e.UNSIGNED_INT||Y.gpuType===wl;if(Y.isInterleavedBufferAttribute){let se=Y.data,xe=se.stride,we=Y.offset;if(se.isInstancedInterleavedBuffer){for(let Ee=0;Ee<k.locationSize;Ee++)m(k.location+Ee,se.meshPerAttribute);if(P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ee=0;Ee<k.locationSize;Ee++)p(k.location+Ee);e.bindBuffer(e.ARRAY_BUFFER,Fe);for(let Ee=0;Ee<k.locationSize;Ee++)R(k.location+Ee,Se/k.locationSize,Me,Q,xe*Z,(we+Se/k.locationSize*Ee)*Z,re)}else{if(Y.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)m(k.location+se,Y.meshPerAttribute);if(P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=Y.meshPerAttribute*Y.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Fe);for(let se=0;se<k.locationSize;se++)R(k.location+se,Se/k.locationSize,Me,Q,Se*Z,Se/k.locationSize*se*Z,re)}}else if(C!==void 0){let Q=C[X];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(k.location,Q);break;case 3:e.vertexAttrib3fv(k.location,Q);break;case 4:e.vertexAttrib4fv(k.location,Q);break;default:e.vertexAttrib1fv(k.location,Q)}}}}E()}function M(){S();for(let P in i){let F=i[P];for(let ee in F){let I=F[ee];for(let H in I){let q=I[H];for(let C in q)u(q[C].object),delete q[C];delete I[H]}}delete i[P]}}function T(P){if(i[P.id]===void 0)return;let F=i[P.id];for(let ee in F){let I=F[ee];for(let H in I){let q=I[H];for(let C in q)u(q[C].object),delete q[C];delete I[H]}}delete i[P.id]}function A(P){for(let F in i){let ee=i[F];for(let I in ee){let H=ee[I];if(H[P.id]===void 0)continue;let q=H[P.id];for(let C in q)u(q[C].object),delete q[C];delete H[P.id]}}}function _(P){for(let F in i){let ee=i[F],I=P.isInstancedMesh===!0?P.id:0,H=ee[I];if(H===void 0)continue;for(let q in H){let C=H[q];for(let X in C)u(C[X].object),delete C[X];delete H[q]}if(delete ee[I],Object.keys(ee).length===0)delete i[F]}}function S(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:S,resetDefaultState:z,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function cw(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function lw(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==oi&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===si&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==$n&&A!==Ri&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ie("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),M=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:v,maxSamples:M,samples:T}}function uw(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Rn,a=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,v=m.clippingState||null;c.value=v,v=u(g,h,R,d);for(let M=0;M!==R;++M)v[M]=n[M];m.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,v=d;R!==x;++R,v+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var Ss=4,hw=6,fw=20,dw=256,uo=new Cr,vp=new Oe,Du=null,Ou=0,Uu=0,Fu=!1,pw=new O,Pr=new O;class mo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=pw}=r;Du=this._renderer.getRenderTarget(),Ou=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Mp(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Sp(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Du,Ou,Uu),this._renderer.xr.enabled=Fu,e.scissorTest=!1,bs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===as||e.mapping===vr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Du=this._renderer.getRenderTarget(),Ou=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:$t,minFilter:$t,generateMipmaps:!1,type:si,format:oi,colorSpace:gn,depthBuffer:!1},i=bp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=bp(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=mw(r)),this._blurMaterial=_w(r,e,t),this._ggxMaterial=gw(r,e,t)}return i}_compileMaterial(e){let t=new _t(new en,e);this._renderer.compile(t,uo)}_sceneToCubeUV(e,t,n,i,r){let a=new Ut(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(vp),u.toneMapping=Hn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new _t(new Qi,new ai({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(vp),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let v=this._cubeSize;if(bs(i,R*v,E>2?v:0,v,v),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===as||e.mapping===vr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Mp();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Sp();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;bs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,uo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-Ss?n-d+Ss:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,bs(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,uo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,bs(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,uo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Ss?i-this._lodMax+Ss:0),f=4*(this._cubeSize-l);bs(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,uo)}}function mw(e){let t=[],n=[],i=e,r=e-Ss+1+hw;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,v=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(v,d*h*m);for(let M=0;M<h;M++){let T=u[M*2]*2-1,A=u[M*2+1]*2-1;if(m===0)Pr.set(1,A,T);else if(m===1)Pr.set(-T,1,-A);else if(m===2)Pr.set(-T,A,1);else if(m===3)Pr.set(-1,A,-T);else if(m===4)Pr.set(-T,-1,A);else Pr.set(T,A,-1);Pr.toArray(x,(m*h+M)*d)}}let p=new en;if(p.setAttribute("position",new Vt(g,d)),p.setAttribute("outputDirection",new Vt(x,d)),n.push(new _t(p,null)),i>Ss)i--}return{lodMeshes:n,sizeLods:t}}function bp(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=Zs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function bs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function gw(e,t,n){return new In({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:dw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Qa(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4048,7 +4048,7 @@ void main() {
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:ii,depthTest:!1,depthWrite:!1})}function mw(e,t,n){return new Pn({name:"SphericalGaussianBlur",defines:{SAMPLES:uw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Ja(),fragmentShader:`
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function _w(e,t,n){return new In({name:"SphericalGaussianBlur",defines:{SAMPLES:fw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Qa(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:ii,depthTest:!1,depthWrite:!1})}function bp(){return new Pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ja(),fragmentShader:`
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Sp(){return new In({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Qa(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4127,7 +4127,7 @@ void main() {
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Sp(){return new Pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ja(),fragmentShader:`
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Mp(){return new In({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Qa(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4143,7 +4143,7 @@ void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Ja(){return`
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Qa(){return`
precision mediump float;
precision mediump int;
@@ -4158,7 +4158,7 @@ void main() {
gl_Position = vec4( position, 1.0 );
}
- `}class Gu extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new za(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
+ `}class Hu extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Ba(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
@@ -4193,7 +4193,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new Ji(5,5,5),r=new Pn({name:"CubemapFromEquirect",uniforms:Tr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Qt,blending:ii});r.uniforms.tEquirect.value=t;let s=new xt(i,r),o=t.minFilter;if(t.minFilter===ri)t.minFilter=$t;return new Eu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function gw(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===xa||d===ya)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new Gu(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===xa||d===ya,x=d===ss||d===yr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new uo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new uo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===xa)h.mapping=ss;else if(d===ya)h.mapping=yr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function _w(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)_r("WebGLRenderer: "+i+" extension not supported.");return r}}}function xw(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,v=E.length;R<v;R+=3){let M=E[R+0],T=E[R+1],A=E[R+2];h.push(M,T,T,A,A,M)}}else{let E=g.array;x=g.version;for(let R=0,v=E.length/3-1;R<v;R+=3){let M=R+0,T=R+1,A=R+2;h.push(M,T,T,A,A,M)}}let p=new(g.count>=65535?Da:Na)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function yw(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function vw(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Fe("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function bw(e,t,n){let i=new WeakMap,r=new ct;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let S=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",S)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let v=a.attributes.position.count*R,M=1;if(v>t.maxTextureSize)M=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let T=new Float32Array(v*M*4*f),A=new Ia(T,v,M,f);A.type=Ai,A.needsUpdate=!0;let _=R*4;for(let k=0;k<f;k++){let C=p[k],U=m[k],ee=E[k],P=v*M*4*k;for(let V=0;V<C.count;V++){let j=V*_;if(d===!0)r.fromBufferAttribute(C,V),T[P+j+0]=r.x,T[P+j+1]=r.y,T[P+j+2]=r.z,T[P+j+3]=0;if(g===!0)r.fromBufferAttribute(U,V),T[P+j+4]=r.x,T[P+j+5]=r.y,T[P+j+6]=r.z,T[P+j+7]=0;if(x===!0)r.fromBufferAttribute(ee,V),T[P+j+8]=r.x,T[P+j+9]=r.y,T[P+j+10]=r.z,T[P+j+11]=ee.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(v,M)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function Sw(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var Mw={[_l]:"LINEAR_TONE_MAPPING",[xl]:"REINHARD_TONE_MAPPING",[yl]:"CINEON_TONE_MAPPING",[Gs]:"ACES_FILMIC_TONE_MAPPING",[bl]:"AGX_TONE_MAPPING",[Sl]:"NEUTRAL_TONE_MAPPING",[vl]:"CUSTOM_TONE_MAPPING"};function ww(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new en;l.setAttribute("position",new un([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new un([0,2,0,0,2,0],2));let u=new _u({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `},i=new Qi(5,5,5),r=new In({name:"CubemapFromEquirect",uniforms:Ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Qt,blending:ii});r.uniforms.tEquirect.value=t;let s=new _t(i,r),o=t.minFilter;if(t.minFilter===ri)t.minFilter=$t;return new Tu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function xw(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===va||d===ba)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new Hu(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===va||d===ba,x=d===as||d===vr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new mo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new mo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===va)h.mapping=as;else if(d===ba)h.mapping=vr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function yw(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)xr("WebGLRenderer: "+i+" extension not supported.");return r}}}function vw(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,v=E.length;R<v;R+=3){let M=E[R+0],T=E[R+1],A=E[R+2];h.push(M,T,T,A,A,M)}}else{let E=g.array;x=g.version;for(let R=0,v=E.length/3-1;R<v;R+=3){let M=R+0,T=R+1,A=R+2;h.push(M,T,T,A,A,M)}}let p=new(g.count>=65535?Ua:Oa)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function bw(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Sw(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function Mw(e,t,n){let i=new WeakMap,r=new at;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let S=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",S)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let v=a.attributes.position.count*R,M=1;if(v>t.maxTextureSize)M=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let T=new Float32Array(v*M*4*f),A=new Na(T,v,M,f);A.type=Ri,A.needsUpdate=!0;let _=R*4;for(let z=0;z<f;z++){let P=p[z],F=m[z],ee=E[z],I=v*M*4*z;for(let H=0;H<P.count;H++){let q=H*_;if(d===!0)r.fromBufferAttribute(P,H),T[I+q+0]=r.x,T[I+q+1]=r.y,T[I+q+2]=r.z,T[I+q+3]=0;if(g===!0)r.fromBufferAttribute(F,H),T[I+q+4]=r.x,T[I+q+5]=r.y,T[I+q+6]=r.z,T[I+q+7]=0;if(x===!0)r.fromBufferAttribute(ee,H),T[I+q+8]=r.x,T[I+q+9]=r.y,T[I+q+10]=r.z,T[I+q+11]=ee.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(v,M)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function ww(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var Ew={[xl]:"LINEAR_TONE_MAPPING",[yl]:"REINHARD_TONE_MAPPING",[vl]:"CINEON_TONE_MAPPING",[Ws]:"ACES_FILMIC_TONE_MAPPING",[Sl]:"AGX_TONE_MAPPING",[Ml]:"NEUTRAL_TONE_MAPPING",[bl]:"CUSTOM_TONE_MAPPING"};function Tw(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new en;l.setAttribute("position",new un([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new un([0,2,0,0,2,0],2));let u=new xu({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
@@ -4239,17 +4239,17 @@ void main() {
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
- }`,depthTest:!1,depthWrite:!1}),f=new xt(l,u),h=new Rr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(v,M){if(o.setSize(v,M),a!==null)a.setSize(v,M);if(c!==null)c.setSize(v,M);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(v,M)}},this.setEffects=function(v){E=v,R=E.length>0&&E[0].isRenderPass===!0;let{width:M,height:T}=o;if(E.length>0&&a===null)a=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1}),c=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(M,T)}},this.begin=function(v,M){if(x)return!1;if(v.toneMapping===Gn&&E.length===0)return!1;if(m=M,M!==null){let{width:T,height:A}=M;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=Gn,!0},this.hasRenderPass=function(){return R},this.end=function(v,M){v.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let S=E[_];if(S.enabled===!1)continue;if(S.render(v,A,T,M),S.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==v.outputColorSpace||g!==v.toneMapping){if(d=v.outputColorSpace,g=v.toneMapping,u.defines={},$e.getTransfer(d)===pt)u.defines.SRGB_TRANSFER="";let _=Mw[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,v.setRenderTarget(m),v.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Hp=new At,ku=new Er(1,1),Vp=new Ia,$p=new pu,Wp=new za,Mp=[],wp=[],Ep=new Float32Array(16),Tp=new Float32Array(9),Ap=new Float32Array(4);function vs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Mp[r];if(s===void 0)s=new Float32Array(r),Mp[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function kt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Qa(e,t){let n=wp[t];if(n===void 0)n=new Int32Array(t),wp[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Ew(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Tw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2fv(this.addr,t),kt(n,t)}}function Aw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(zt(n,t))return;e.uniform3fv(this.addr,t),kt(n,t)}}function Rw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4fv(this.addr,t),kt(n,t)}}function Cw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ap.set(i),e.uniformMatrix2fv(this.addr,!1,Ap),kt(n,i)}}function Pw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Tp.set(i),e.uniformMatrix3fv(this.addr,!1,Tp),kt(n,i)}}function Iw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ep.set(i),e.uniformMatrix4fv(this.addr,!1,Ep),kt(n,i)}}function Lw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Nw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2iv(this.addr,t),kt(n,t)}}function Dw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3iv(this.addr,t),kt(n,t)}}function Ow(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4iv(this.addr,t),kt(n,t)}}function Uw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function Fw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2uiv(this.addr,t),kt(n,t)}}function zw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3uiv(this.addr,t),kt(n,t)}}function kw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4uiv(this.addr,t),kt(n,t)}}function Bw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)ku.compareFunction=n.isReversedDepthBuffer()?Pa:Ca,s=ku;else s=Hp;n.setTexture2D(t||s,r)}function Gw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||$p,r)}function Hw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Wp,r)}function Vw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||Vp,r)}function $w(e){switch(e){case 5126:return Ew;case 35664:return Tw;case 35665:return Aw;case 35666:return Rw;case 35674:return Cw;case 35675:return Pw;case 35676:return Iw;case 5124:case 35670:return Lw;case 35667:case 35671:return Nw;case 35668:case 35672:return Dw;case 35669:case 35673:return Ow;case 5125:return Uw;case 36294:return Fw;case 36295:return zw;case 36296:return kw;case 35678:case 36198:case 36298:case 36306:case 35682:return Bw;case 35679:case 36299:case 36307:return Gw;case 35680:case 36300:case 36308:case 36293:return Hw;case 36289:case 36303:case 36311:case 36292:return Vw}}function Ww(e,t){e.uniform1fv(this.addr,t)}function Zw(e,t){let n=vs(t,this.size,2);e.uniform2fv(this.addr,n)}function Xw(e,t){let n=vs(t,this.size,3);e.uniform3fv(this.addr,n)}function qw(e,t){let n=vs(t,this.size,4);e.uniform4fv(this.addr,n)}function jw(e,t){let n=vs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Yw(e,t){let n=vs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Kw(e,t){let n=vs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Jw(e,t){e.uniform1iv(this.addr,t)}function Qw(e,t){e.uniform2iv(this.addr,t)}function eE(e,t){e.uniform3iv(this.addr,t)}function tE(e,t){e.uniform4iv(this.addr,t)}function nE(e,t){e.uniform1uiv(this.addr,t)}function iE(e,t){e.uniform2uiv(this.addr,t)}function rE(e,t){e.uniform3uiv(this.addr,t)}function sE(e,t){e.uniform4uiv(this.addr,t)}function oE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=ku;else o=Hp;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function aE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||$p,s[o])}function cE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Wp,s[o])}function lE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Vp,s[o])}function uE(e){switch(e){case 5126:return Ww;case 35664:return Zw;case 35665:return Xw;case 35666:return qw;case 35674:return jw;case 35675:return Yw;case 35676:return Kw;case 5124:case 35670:return Jw;case 35667:case 35671:return Qw;case 35668:case 35672:return eE;case 35669:case 35673:return tE;case 5125:return nE;case 36294:return iE;case 36295:return rE;case 36296:return sE;case 35678:case 36198:case 36298:case 36306:case 35682:return oE;case 35679:case 36299:case 36307:return aE;case 35680:case 36300:case 36308:case 36293:return cE;case 36289:case 36303:case 36311:case 36292:return lE}}class Zp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=$w(t.type)}}class Xp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=uE(t.type)}}class qp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Fu=/(\w+)(\])?(\[|\.)?/g;function Rp(e,t){e.seq.push(t),e.map[t.id]=t}function hE(e,t,n){let i=e.name,r=i.length;Fu.lastIndex=0;while(!0){let s=Fu.exec(i),o=Fu.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Rp(n,l===void 0?new Zp(a,e,t):new Xp(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new qp(a),Rp(n,f);n=f}}}class lo{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);hE(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Cp(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var fE=37297,dE=0;function pE(e,t){let n=e.split(`
+ }`,depthTest:!1,depthWrite:!1}),f=new _t(l,u),h=new Cr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(v,M){if(o.setSize(v,M),a!==null)a.setSize(v,M);if(c!==null)c.setSize(v,M);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(v,M)}},this.setEffects=function(v){E=v,R=E.length>0&&E[0].isRenderPass===!0;let{width:M,height:T}=o;if(E.length>0&&a===null)a=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1}),c=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(M,T)}},this.begin=function(v,M){if(x)return!1;if(v.toneMapping===Hn&&E.length===0)return!1;if(m=M,M!==null){let{width:T,height:A}=M;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=Hn,!0},this.hasRenderPass=function(){return R},this.end=function(v,M){v.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let S=E[_];if(S.enabled===!1)continue;if(S.render(v,A,T,M),S.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==v.outputColorSpace||g!==v.toneMapping){if(d=v.outputColorSpace,g=v.toneMapping,u.defines={},$e.getTransfer(d)===dt)u.defines.SRGB_TRANSFER="";let _=Ew[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,v.setRenderTarget(m),v.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Vp=new At,Bu=new Tr(1,1),$p=new Na,Wp=new mu,Zp=new Ba,wp=[],Ep=[],Tp=new Float32Array(16),Ap=new Float32Array(9),Rp=new Float32Array(4);function Ms(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=wp[r];if(s===void 0)s=new Float32Array(r),wp[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function kt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function ec(e,t){let n=Ep[t];if(n===void 0)n=new Int32Array(t),Ep[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Aw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Rw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2fv(this.addr,t),kt(n,t)}}function Cw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(zt(n,t))return;e.uniform3fv(this.addr,t),kt(n,t)}}function Pw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4fv(this.addr,t),kt(n,t)}}function Iw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Rp.set(i),e.uniformMatrix2fv(this.addr,!1,Rp),kt(n,i)}}function Lw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ap.set(i),e.uniformMatrix3fv(this.addr,!1,Ap),kt(n,i)}}function Nw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Tp.set(i),e.uniformMatrix4fv(this.addr,!1,Tp),kt(n,i)}}function Dw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Ow(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2iv(this.addr,t),kt(n,t)}}function Uw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3iv(this.addr,t),kt(n,t)}}function Fw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4iv(this.addr,t),kt(n,t)}}function zw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function kw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2uiv(this.addr,t),kt(n,t)}}function Bw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3uiv(this.addr,t),kt(n,t)}}function Gw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4uiv(this.addr,t),kt(n,t)}}function Hw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Bu.compareFunction=n.isReversedDepthBuffer()?La:Ia,s=Bu;else s=Vp;n.setTexture2D(t||s,r)}function Vw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||Wp,r)}function $w(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Zp,r)}function Ww(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||$p,r)}function Zw(e){switch(e){case 5126:return Aw;case 35664:return Rw;case 35665:return Cw;case 35666:return Pw;case 35674:return Iw;case 35675:return Lw;case 35676:return Nw;case 5124:case 35670:return Dw;case 35667:case 35671:return Ow;case 35668:case 35672:return Uw;case 35669:case 35673:return Fw;case 5125:return zw;case 36294:return kw;case 36295:return Bw;case 36296:return Gw;case 35678:case 36198:case 36298:case 36306:case 35682:return Hw;case 35679:case 36299:case 36307:return Vw;case 35680:case 36300:case 36308:case 36293:return $w;case 36289:case 36303:case 36311:case 36292:return Ww}}function Xw(e,t){e.uniform1fv(this.addr,t)}function qw(e,t){let n=Ms(t,this.size,2);e.uniform2fv(this.addr,n)}function jw(e,t){let n=Ms(t,this.size,3);e.uniform3fv(this.addr,n)}function Yw(e,t){let n=Ms(t,this.size,4);e.uniform4fv(this.addr,n)}function Kw(e,t){let n=Ms(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Jw(e,t){let n=Ms(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Qw(e,t){let n=Ms(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function eE(e,t){e.uniform1iv(this.addr,t)}function tE(e,t){e.uniform2iv(this.addr,t)}function nE(e,t){e.uniform3iv(this.addr,t)}function iE(e,t){e.uniform4iv(this.addr,t)}function rE(e,t){e.uniform1uiv(this.addr,t)}function sE(e,t){e.uniform2uiv(this.addr,t)}function oE(e,t){e.uniform3uiv(this.addr,t)}function aE(e,t){e.uniform4uiv(this.addr,t)}function cE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Bu;else o=Vp;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function lE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Wp,s[o])}function uE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Zp,s[o])}function hE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||$p,s[o])}function fE(e){switch(e){case 5126:return Xw;case 35664:return qw;case 35665:return jw;case 35666:return Yw;case 35674:return Kw;case 35675:return Jw;case 35676:return Qw;case 5124:case 35670:return eE;case 35667:case 35671:return tE;case 35668:case 35672:return nE;case 35669:case 35673:return iE;case 5125:return rE;case 36294:return sE;case 36295:return oE;case 36296:return aE;case 35678:case 36198:case 36298:case 36306:case 35682:return cE;case 35679:case 36299:case 36307:return lE;case 35680:case 36300:case 36308:case 36293:return uE;case 36289:case 36303:case 36311:case 36292:return hE}}class Xp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Zw(t.type)}}class qp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=fE(t.type)}}class jp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var zu=/(\w+)(\])?(\[|\.)?/g;function Cp(e,t){e.seq.push(t),e.map[t.id]=t}function dE(e,t,n){let i=e.name,r=i.length;zu.lastIndex=0;while(!0){let s=zu.exec(i),o=zu.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Cp(n,l===void 0?new Xp(a,e,t):new qp(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new jp(a),Cp(n,f);n=f}}}class po{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);dE(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Pp(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var pE=37297,mE=0;function gE(e,t){let n=e.split(`
`),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===t?">":" "} ${a}: ${n[o]}`)}return i.join(`
-`)}var Pp=new ke;function mE(e){$e._getMatrix(Pp,$e.workingColorSpace,e);let t=`mat3( ${Pp.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case cu:return[t,"LinearTransferOETF"];case pt:return[t,"sRGBTransferOETF"];default:return Pe("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Ip(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
+`)}var Ip=new ze;function _E(e){$e._getMatrix(Ip,$e.workingColorSpace,e);let t=`mat3( ${Ip.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case lu:return[t,"LinearTransferOETF"];case dt:return[t,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Lp(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
`+s+`
-`+pE(e.getShaderSource(t),a)}else return s}function gE(e,t){let n=mE(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var _E={[_l]:"Linear",[xl]:"Reinhard",[yl]:"Cineon",[Gs]:"ACESFilmic",[bl]:"AgX",[Sl]:"Neutral",[vl]:"Custom"};function xE(e,t){let n=_E[t];if(n===void 0)return Pe("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ka=new D;function yE(){$e.getLuminanceCoefficients(Ka);let e=Ka.x.toFixed(4),t=Ka.y.toFixed(4),n=Ka.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function vE(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(co).join(`
-`)}function bE(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
-`)}function SE(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function co(e){return e!==""}function Lp(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Np(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var ME=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bu(e){return e.replace(ME,EE)}var wE=new Map;function EE(e,t){let n=Ve[t];if(n===void 0){let i=wE.get(t);if(i!==void 0)n=Ve[i],Pe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Bu(n)}var TE=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Dp(e){return e.replace(TE,AE)}function AE(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Op(e){let t=`precision ${e.precision} float;
+`+gE(e.getShaderSource(t),a)}else return s}function xE(e,t){let n=_E(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}var yE={[xl]:"Linear",[yl]:"Reinhard",[vl]:"Cineon",[Ws]:"ACESFilmic",[Sl]:"AgX",[Ml]:"Neutral",[bl]:"Custom"};function vE(e,t){let n=yE[t];if(n===void 0)return Ie("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ja=new O;function bE(){$e.getLuminanceCoefficients(Ja);let e=Ja.x.toFixed(4),t=Ja.y.toFixed(4),n=Ja.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function SE(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(fo).join(`
+`)}function ME(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
+`)}function wE(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function fo(e){return e!==""}function Np(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Dp(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var EE=/^[ \t]*#include +<([\w\d./]+)>/gm;function Gu(e){return e.replace(EE,AE)}var TE=new Map;function AE(e,t){let n=Ve[t];if(n===void 0){let i=TE.get(t);if(i!==void 0)n=Ve[i],Ie('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Gu(n)}var RE=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Op(e){return e.replace(RE,CE)}function CE(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Up(e){let t=`precision ${e.precision} float;
precision ${e.precision} int;
precision ${e.precision} sampler2D;
precision ${e.precision} samplerCube;
@@ -4269,30 +4269,30 @@ void main() {
`;if(e.precision==="highp")t+=`
#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
-#define LOW_PRECISION`;return t}var RE={[ks]:"SHADOWMAP_TYPE_PCF",[is]:"SHADOWMAP_TYPE_VSM"};function CE(e){return RE[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var PE={[ss]:"ENVMAP_TYPE_CUBE",[yr]:"ENVMAP_TYPE_CUBE",[Hs]:"ENVMAP_TYPE_CUBE_UV"};function IE(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return PE[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var LE={[yr]:"ENVMAP_MODE_REFRACTION"};function NE(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return LE[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var DE={[Vd]:"ENVMAP_BLENDING_MULTIPLY",[$d]:"ENVMAP_BLENDING_MIX",[Wd]:"ENVMAP_BLENDING_ADD"};function OE(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return DE[e.combine]||"ENVMAP_BLENDING_NONE"}function UE(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function FE(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=CE(n),l=IE(n),u=NE(n),f=OE(n),h=UE(n),d=vE(n),g=bE(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
-`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(co).join(`
+#define LOW_PRECISION`;return t}var PE={[Vs]:"SHADOWMAP_TYPE_PCF",[ss]:"SHADOWMAP_TYPE_VSM"};function IE(e){return PE[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var LE={[as]:"ENVMAP_TYPE_CUBE",[vr]:"ENVMAP_TYPE_CUBE",[Zs]:"ENVMAP_TYPE_CUBE_UV"};function NE(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return LE[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var DE={[vr]:"ENVMAP_MODE_REFRACTION"};function OE(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return DE[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var UE={[$d]:"ENVMAP_BLENDING_MULTIPLY",[Wd]:"ENVMAP_BLENDING_MIX",[Zd]:"ENVMAP_BLENDING_ADD"};function FE(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return UE[e.combine]||"ENVMAP_BLENDING_NONE"}function zE(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function kE(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=IE(n),l=NE(n),u=OE(n),f=FE(n),h=zE(n),d=SE(n),g=ME(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
+`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(fo).join(`
`),p.length>0)p+=`
-`;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(co).join(`
+`;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(fo).join(`
`),m.length>0)m+=`
-`}else p=[Op(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
-`].filter(co).join(`
-`),m=[Op(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Gn?"#define TONE_MAPPING":"",n.toneMapping!==Gn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Gn?xE("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,gE("linearToOutputTexel",n.outputColorSpace),yE(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
-`].filter(co).join(`
-`);if(o=Bu(o),o=Lp(o,n),o=Np(o,n),a=Bu(a),a=Lp(a,n),a=Np(a,n),o=Dp(o),a=Dp(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
+`}else p=[Up(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
+`].filter(fo).join(`
+`),m=[Up(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Hn?"#define TONE_MAPPING":"",n.toneMapping!==Hn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Hn?vE("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,xE("linearToOutputTexel",n.outputColorSpace),bE(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`].filter(fo).join(`
+`);if(o=Gu(o),o=Np(o,n),o=Dp(o,n),a=Gu(a),a=Np(a,n),a=Dp(a,n),o=Op(o),a=Op(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
`,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+p,m=["#define varying in",n.glslVersion===lu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===lu?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
+`+p,m=["#define varying in",n.glslVersion===uu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===uu?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+m;let R=E+p+o,v=E+m+a,M=Cp(r,r.VERTEX_SHADER,R),T=Cp(r,r.FRAGMENT_SHADER,v);if(r.attachShader(x,M),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(C){if(e.debug.checkShaderErrors){let U=r.getProgramInfoLog(x)||"",ee=r.getShaderInfoLog(M)||"",P=r.getShaderInfoLog(T)||"",V=U.trim(),j=ee.trim(),z=P.trim(),H=!0,F=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(H=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,M,T);else{let q=Ip(r,M,"vertex"),K=Ip(r,T,"fragment");Fe("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
+`+m;let R=E+p+o,v=E+m+a,M=Pp(r,r.VERTEX_SHADER,R),T=Pp(r,r.FRAGMENT_SHADER,v);if(r.attachShader(x,M),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(P){if(e.debug.checkShaderErrors){let F=r.getProgramInfoLog(x)||"",ee=r.getShaderInfoLog(M)||"",I=r.getShaderInfoLog(T)||"",H=F.trim(),q=ee.trim(),C=I.trim(),X=!0,k=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(X=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,M,T);else{let Y=Lp(r,M,"vertex"),Q=Lp(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
-Material Name: `+C.name+`
-Material Type: `+C.type+`
+Material Name: `+P.name+`
+Material Type: `+P.type+`
-Program Info Log: `+V+`
-`+q+`
-`+K)}else if(V!=="")Pe("WebGLProgram: Program Info Log:",V);else if(j===""||z==="")F=!1;if(F)C.diagnostics={runnable:H,programLog:V,vertexShader:{log:j,prefix:p},fragmentShader:{log:z,prefix:m}}}r.deleteShader(M),r.deleteShader(T),_=new lo(r,x),S=SE(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let S;this.getAttributes=function(){if(S===void 0)A(this);return S};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(k===!1)k=r.getProgramParameter(x,fE);return k},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=dE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var zE=0;class jp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Yp(e),t.set(e,n);return n}}class Yp{constructor(e){this.id=zE++,this.code=e,this.usedTimes=0}}function kE(e){return e===Mr||e===Ta||e===Aa}function BE(e,t,n,i,r,s){let o=new La,a=new jp,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,S,k,C,U,ee){let P=C.fog,V=U.geometry,j=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,H=t.get(_.envMap||j,z),F=!!H&&H.mapping===Hs?H.image.height:null,q=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Pe("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let K=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,xe=K!==void 0?K.length:0,ce=0;if(V.morphAttributes.position!==void 0)ce=1;if(V.morphAttributes.normal!==void 0)ce=2;if(V.morphAttributes.color!==void 0)ce=3;let De,ye,X,re;if(q){let gt=li[q];De=gt.vertexShader,ye=gt.fragmentShader}else{De=_.vertexShader,ye=_.fragmentShader;let gt=a.getVertexShaderStage(_),rt=a.getFragmentShaderStage(_);a.update(_,gt,rt),X=gt.id,re=rt.id}let se=e.getRenderTarget(),Te=e.state.buffers.depth.getReversed(),Ie=U.isInstancedMesh===!0,_e=U.isBatchedMesh===!0,Qe=!!_.map,ze=!!_.matcap,Ze=!!H,ot=!!_.aoMap,Ye=!!_.lightMap,Zt=!!_.bumpMap&&_.wireframe===!1,yt=!!_.normalMap,cn=!!_.displacementMap,Dt=!!_.emissiveMap,Ot=!!_.metalnessMap,L=!!_.roughnessMap,ln=_.anisotropy>0,it=_.clearcoat>0,wt=_.dispersion>0,w=_.retroreflectivity>0,y=_.iridescence>0,I=_.sheen>0,W=_.transmission>0,ie=ln&&!!_.anisotropyMap,ae=it&&!!_.clearcoatMap,he=it&&!!_.clearcoatNormalMap,Y=it&&!!_.clearcoatRoughnessMap,te=y&&!!_.iridescenceMap,ve=y&&!!_.iridescenceThicknessMap,Ce=I&&!!_.sheenColorMap,fe=I&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,Oe=!!_.specularIntensityMap,et=W&&!!_.transmissionMap,O=W&&!!_.thicknessMap,le=!!_.gradientMap,J=!!_.alphaMap,ue=_.alphaTest>0,be=!!_.alphaHash,ne=!!_.extensions,pe=Gn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:q,shaderType:_.type,shaderName:_.name,vertexShader:De,fragmentShader:ye,defines:_.defines,customVertexShaderID:X,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:_e,batchingColor:_e&&U._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&U.instanceColor!==null,instancingMorph:Ie&&U.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Qe,matcap:ze,envMap:Ze,envMapMode:Ze&&H.mapping,envMapCubeUVHeight:F,aoMap:ot,lightMap:Ye,bumpMap:Zt,normalMap:yt,displacementMap:cn,emissiveMap:Dt,normalMapObjectSpace:yt&&_.normalMapType===Qd,normalMapTangentSpace:yt&&_.normalMapType===au,packedNormalMap:yt&&_.normalMapType===au&&kE(_.normalMap.format),metalnessMap:Ot,roughnessMap:L,anisotropy:ln,anisotropyMap:ie,clearcoat:it,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:wt,retroreflection:w,iridescence:y,iridescenceMap:te,iridescenceThicknessMap:ve,sheen:I,sheenColorMap:Ce,sheenRoughnessMap:fe,specularMap:oe,specularColorMap:Le,specularIntensityMap:Oe,transmission:W,transmissionMap:et,thicknessMap:O,gradientMap:le,opaque:_.transparent===!1&&_.blending===Bs&&_.alphaToCoverage===!1,alphaMap:J,alphaTest:ue,alphaHash:be,combine:_.combine,mapUv:Qe&&g(_.map.channel),aoMapUv:ot&&g(_.aoMap.channel),lightMapUv:Ye&&g(_.lightMap.channel),bumpMapUv:Zt&&g(_.bumpMap.channel),normalMapUv:yt&&g(_.normalMap.channel),displacementMapUv:cn&&g(_.displacementMap.channel),emissiveMapUv:Dt&&g(_.emissiveMap.channel),metalnessMapUv:Ot&&g(_.metalnessMap.channel),roughnessMapUv:L&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:he&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:ve&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ce&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:fe&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:Oe&&g(_.specularIntensityMap.channel),transmissionMapUv:et&&g(_.transmissionMap.channel),thicknessMapUv:O&&g(_.thicknessMap.channel),alphaMapUv:J&&g(_.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(yt||ln),vertexNormals:!!V.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!V.attributes.uv&&(Qe||J),fog:!!P,useFog:_.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||V.attributes.normal===void 0&&yt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Te,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:V.attributes.position!==void 0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:xe,morphTextureStride:ce,numSunLights:S.sun.length,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numSunLightShadows:S.sunShadowMap.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&k.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Qe&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===pt,decodeVideoTextureEmissive:Dt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===pt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Cn,flipSided:_.side===Qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||_e)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let S=[];if(_.shaderID)S.push(_.shaderID);else S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let k in _.defines)S.push(k),S.push(_.defines[k]);if(_.isRawShaderMaterial===!1)m(S,_),E(S,_),S.push(e.outputColorSpace);return S.push(_.customProgramCacheKey),S.join()}function m(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numSunLights),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numSunLightShadows),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function E(_,S){if(o.disableAll(),S.instancing)o.enable(0);if(S.instancingColor)o.enable(1);if(S.instancingMorph)o.enable(2);if(S.matcap)o.enable(3);if(S.envMap)o.enable(4);if(S.normalMapObjectSpace)o.enable(5);if(S.normalMapTangentSpace)o.enable(6);if(S.clearcoat)o.enable(7);if(S.iridescence)o.enable(8);if(S.alphaTest)o.enable(9);if(S.vertexColors)o.enable(10);if(S.vertexAlphas)o.enable(11);if(S.vertexUv1s)o.enable(12);if(S.vertexUv2s)o.enable(13);if(S.vertexUv3s)o.enable(14);if(S.vertexTangents)o.enable(15);if(S.anisotropy)o.enable(16);if(S.alphaHash)o.enable(17);if(S.batching)o.enable(18);if(S.dispersion)o.enable(19);if(S.retroreflection)o.enable(24);if(S.batchingColor)o.enable(20);if(S.gradientMap)o.enable(21);if(S.packedNormalMap)o.enable(22);if(S.vertexNormals)o.enable(23);if(_.push(o.mask),o.disableAll(),S.fog)o.enable(0);if(S.useFog)o.enable(1);if(S.flatShading)o.enable(2);if(S.logarithmicDepthBuffer)o.enable(3);if(S.reversedDepthBuffer)o.enable(4);if(S.skinning)o.enable(5);if(S.morphTargets)o.enable(6);if(S.morphNormals)o.enable(7);if(S.morphColors)o.enable(8);if(S.premultipliedAlpha)o.enable(9);if(S.shadowMapEnabled)o.enable(10);if(S.doubleSided)o.enable(11);if(S.flipSided)o.enable(12);if(S.useDepthPacking)o.enable(13);if(S.dithering)o.enable(14);if(S.transmission)o.enable(15);if(S.sheen)o.enable(16);if(S.opaque)o.enable(17);if(S.pointsUvs)o.enable(18);if(S.decodeVideoTexture)o.enable(19);if(S.decodeVideoTextureEmissive)o.enable(20);if(S.alphaToCoverage)o.enable(21);if(S.numLightProbeGrids>0)o.enable(22);if(S.hasPositionAttribute)o.enable(23);_.push(o.mask)}function R(_){let S=d[_.type],k;if(S){let C=li[S];k=hp.clone(C.uniforms)}else k=_.uniforms;return k}function v(_,S){let k=u.get(S);if(k!==void 0)++k.usedTimes;else k=new FE(e,S,_,r),l.push(k),u.set(S,k);return k}function M(_){if(--_.usedTimes===0){let S=l.indexOf(_);l[S]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:v,releaseProgram:M,releaseShaderCache:T,programs:l,dispose:A}}function GE(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function HE(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Up(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Fp(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||HE);if(i.length>1)i.sort(d||Up);if(r.length>1)r.sort(d||Up)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function VE(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Fp,e.set(i,[o]);else if(r>=s.length)o=new Fp,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function $E(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new D,color:new Ue};break;case"SpotLight":n={position:new D,direction:new D,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new D,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":n={direction:new D,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":n={color:new Ue,position:new D,halfWidth:new D,halfHeight:new D};break}return e[t.id]=n,n}}}function WE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var ZE=0;function XE(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function qE(e){let t=new $E,n=WE(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);let r=new D,s=new Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let U=0;U<9;U++)i.probe[U].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,v=0,M=0,T=0,A=0,_=0,S=0,k=0;l.sort(XE);for(let U=0,ee=l.length;U<ee;U++){let P=l[U],{color:V,intensity:j,distance:z}=P,H=null;if(P.shadow&&P.shadow.map)if(P.shadow.map.texture.format===Mr)H=P.shadow.map.texture;else H=P.shadow.map.depthTexture||P.shadow.map.texture;if(P.isAmbientLight)u+=V.r*j,f+=V.g*j,h+=V.b*j;else if(P.isLightProbe){for(let F=0;F<9;F++)i.probe[F].addScaledVector(P.sh.coefficients[F],j);k++}else if(P.isSunLight){let F=t.get(P);if(F.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let q=P.shadow,K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[g]=K,i.sunShadowMap[g]=H;let xe=q.getViewportCount();for(let ce=0;ce<xe;ce++)i.sunShadowMatrix[x+ce]=q.getMatrix(ce),i.sunShadowCascade[x+ce]=q._cascadeData[ce];x+=xe,g++}i.sun[d]=F,d++}else if(P.isDirectionalLight){let F=t.get(P);if(F.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let q=P.shadow,K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize=q.mapSize,i.directionalShadow[p]=K,i.directionalShadowMap[p]=H,i.directionalShadowMatrix[p]=P.shadow.matrix,M++}i.directional[p]=F,p++}else if(P.isSpotLight){let F=t.get(P);F.position.setFromMatrixPosition(P.matrixWorld),F.color.copy(V).multiplyScalar(j),F.distance=z,F.coneCos=Math.cos(P.angle),F.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),F.decay=P.decay,i.spot[E]=F;let q=P.shadow;if(P.map){if(i.spotLightMap[_]=P.map,_++,q.updateMatrices(P),P.castShadow)S++}if(i.spotLightMatrix[E]=q.matrix,P.castShadow){let K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize=q.mapSize,i.spotShadow[E]=K,i.spotShadowMap[E]=H,A++}E++}else if(P.isRectAreaLight){let F=t.get(P);F.color.copy(V).multiplyScalar(j),F.halfWidth.set(P.width*0.5,0,0),F.halfHeight.set(0,P.height*0.5,0),i.rectArea[R]=F,R++}else if(P.isPointLight){let F=t.get(P);if(F.color.copy(P.color).multiplyScalar(P.intensity),F.distance=P.distance,F.decay=P.decay,P.castShadow){let q=P.shadow,K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize=q.mapSize,K.shadowCameraNear=q.camera.near,K.shadowCameraFar=q.camera.far,i.pointShadow[m]=K,i.pointShadowMap[m]=H,i.pointShadowMatrix[m]=P.shadow.matrix,T++}i.point[m]=F,m++}else if(P.isHemisphereLight){let F=t.get(P);F.skyColor.copy(P.color).multiplyScalar(j),F.groundColor.copy(P.groundColor).multiplyScalar(j),i.hemi[v]=F,v++}}if(R>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=de.LTC_FLOAT_1,i.rectAreaLTC2=de.LTC_FLOAT_2;else i.rectAreaLTC1=de.LTC_HALF_1,i.rectAreaLTC2=de.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=f,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==d||C.directionalLength!==p||C.pointLength!==m||C.spotLength!==E||C.rectAreaLength!==R||C.hemiLength!==v||C.numSunShadows!==g||C.numDirectionalShadows!==M||C.numPointShadows!==T||C.numSpotShadows!==A||C.numSpotMaps!==_||C.numLightProbes!==k)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=v,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.directionalShadowMatrix.length=M,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-S,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=k,C.sunLength=d,C.directionalLength=p,C.pointLength=m,C.spotLength=E,C.rectAreaLength=R,C.hemiLength=v,C.numSunShadows=g,C.numDirectionalShadows=M,C.numPointShadows=T,C.numSpotShadows=A,C.numSpotMaps=_,C.numLightProbes=k,i.version=ZE++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let v=l[E];if(v.isSunLight){let M=i.sun[f];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),f++}else if(v.isDirectionalLight){let M=i.directional[h];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),h++}else if(v.isSpotLight){let M=i.spot[g];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),g++}else if(v.isRectAreaLight){let M=i.rectArea[x];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),s.copy(v.matrixWorld),s.premultiply(m),o.extractRotation(s),M.halfWidth.set(v.width*0.5,0,0),M.halfHeight.set(0,v.height*0.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(v.isPointLight){let M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){let M=i.hemi[p];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function zp(e){let t=new qE(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function jE(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new zp(e),t.set(r,[a]);else if(s>=o.length)a=new zp(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var YE=`void main() {
+Program Info Log: `+H+`
+`+Y+`
+`+Q)}else if(H!=="")Ie("WebGLProgram: Program Info Log:",H);else if(q===""||C==="")k=!1;if(k)P.diagnostics={runnable:X,programLog:H,vertexShader:{log:q,prefix:p},fragmentShader:{log:C,prefix:m}}}r.deleteShader(M),r.deleteShader(T),_=new po(r,x),S=wE(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let S;this.getAttributes=function(){if(S===void 0)A(this);return S};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(x,pE);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var BE=0;class Yp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Kp(e),t.set(e,n);return n}}class Kp{constructor(e){this.id=BE++,this.code=e,this.usedTimes=0}}function GE(e){return e===wr||e===Ra||e===Ca}function HE(e,t,n,i,r,s){let o=new Da,a=new Yp,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,S,z,P,F,ee){let I=P.fog,H=F.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,C=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,X=t.get(_.envMap||q,C),k=!!X&&X.mapping===Zs?X.image.height:null,Y=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Ie("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let Q=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Se=Q!==void 0?Q.length:0,ue=0;if(H.morphAttributes.position!==void 0)ue=1;if(H.morphAttributes.normal!==void 0)ue=2;if(H.morphAttributes.color!==void 0)ue=3;let Fe,Me,Z,re;if(Y){let mt=li[Y];Fe=mt.vertexShader,Me=mt.fragmentShader}else{Fe=_.vertexShader,Me=_.fragmentShader;let mt=a.getVertexShaderStage(_),it=a.getFragmentShaderStage(_);a.update(_,mt,it),Z=mt.id,re=it.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),we=F.isInstancedMesh===!0,Ee=F.isBatchedMesh===!0,xt=!!_.map,ke=!!_.matcap,Ze=!!X,st=!!_.aoMap,Ye=!!_.lightMap,Zt=!!_.bumpMap&&_.wireframe===!1,yt=!!_.normalMap,cn=!!_.displacementMap,Dt=!!_.emissiveMap,Ot=!!_.metalnessMap,N=!!_.roughnessMap,ln=_.anisotropy>0,nt=_.clearcoat>0,wt=_.dispersion>0,w=_.retroreflectivity>0,y=_.iridescence>0,L=_.sheen>0,V=_.transmission>0,ie=ln&&!!_.anisotropyMap,ae=nt&&!!_.clearcoatMap,he=nt&&!!_.clearcoatNormalMap,j=nt&&!!_.clearcoatRoughnessMap,te=y&&!!_.iridescenceMap,_e=y&&!!_.iridescenceThicknessMap,Pe=L&&!!_.sheenColorMap,fe=L&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Qe=V&&!!_.transmissionMap,U=V&&!!_.thicknessMap,ce=!!_.gradientMap,K=!!_.alphaMap,le=_.alphaTest>0,ye=!!_.alphaHash,ne=!!_.extensions,pe=Hn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:Y,shaderType:_.type,shaderName:_.name,vertexShader:Fe,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:Ee,batchingColor:Ee&&F._colorsTexture!==null,instancing:we,instancingColor:we&&F.instanceColor!==null,instancingMorph:we&&F.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:xt,matcap:ke,envMap:Ze,envMapMode:Ze&&X.mapping,envMapCubeUVHeight:k,aoMap:st,lightMap:Ye,bumpMap:Zt,normalMap:yt,displacementMap:cn,emissiveMap:Dt,normalMapObjectSpace:yt&&_.normalMapType===ep,normalMapTangentSpace:yt&&_.normalMapType===cu,packedNormalMap:yt&&_.normalMapType===cu&&GE(_.normalMap.format),metalnessMap:Ot,roughnessMap:N,anisotropy:ln,anisotropyMap:ie,clearcoat:nt,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:j,dispersion:wt,retroreflection:w,iridescence:y,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:L,sheenColorMap:Pe,sheenRoughnessMap:fe,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Qe,thicknessMap:U,gradientMap:ce,opaque:_.transparent===!1&&_.blending===$s&&_.alphaToCoverage===!1,alphaMap:K,alphaTest:le,alphaHash:ye,combine:_.combine,mapUv:xt&&g(_.map.channel),aoMapUv:st&&g(_.aoMap.channel),lightMapUv:Ye&&g(_.lightMap.channel),bumpMapUv:Zt&&g(_.bumpMap.channel),normalMapUv:yt&&g(_.normalMap.channel),displacementMapUv:cn&&g(_.displacementMap.channel),emissiveMapUv:Dt&&g(_.emissiveMap.channel),metalnessMapUv:Ot&&g(_.metalnessMap.channel),roughnessMapUv:N&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:he&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:j&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Pe&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:fe&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Qe&&g(_.transmissionMap.channel),thicknessMapUv:U&&g(_.thicknessMap.channel),alphaMapUv:K&&g(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(yt||ln),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!H.attributes.uv&&(xt||K),fog:!!I,useFog:_.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&yt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:xe,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:ue,numSunLights:S.sun.length,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numSunLightShadows:S.sunShadowMap.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:xt&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===dt,decodeVideoTextureEmissive:Dt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===dt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Pn,flipSided:_.side===Qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||Ee)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let S=[];if(_.shaderID)S.push(_.shaderID);else S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let z in _.defines)S.push(z),S.push(_.defines[z]);if(_.isRawShaderMaterial===!1)m(S,_),E(S,_),S.push(e.outputColorSpace);return S.push(_.customProgramCacheKey),S.join()}function m(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numSunLights),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numSunLightShadows),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function E(_,S){if(o.disableAll(),S.instancing)o.enable(0);if(S.instancingColor)o.enable(1);if(S.instancingMorph)o.enable(2);if(S.matcap)o.enable(3);if(S.envMap)o.enable(4);if(S.normalMapObjectSpace)o.enable(5);if(S.normalMapTangentSpace)o.enable(6);if(S.clearcoat)o.enable(7);if(S.iridescence)o.enable(8);if(S.alphaTest)o.enable(9);if(S.vertexColors)o.enable(10);if(S.vertexAlphas)o.enable(11);if(S.vertexUv1s)o.enable(12);if(S.vertexUv2s)o.enable(13);if(S.vertexUv3s)o.enable(14);if(S.vertexTangents)o.enable(15);if(S.anisotropy)o.enable(16);if(S.alphaHash)o.enable(17);if(S.batching)o.enable(18);if(S.dispersion)o.enable(19);if(S.retroreflection)o.enable(24);if(S.batchingColor)o.enable(20);if(S.gradientMap)o.enable(21);if(S.packedNormalMap)o.enable(22);if(S.vertexNormals)o.enable(23);if(_.push(o.mask),o.disableAll(),S.fog)o.enable(0);if(S.useFog)o.enable(1);if(S.flatShading)o.enable(2);if(S.logarithmicDepthBuffer)o.enable(3);if(S.reversedDepthBuffer)o.enable(4);if(S.skinning)o.enable(5);if(S.morphTargets)o.enable(6);if(S.morphNormals)o.enable(7);if(S.morphColors)o.enable(8);if(S.premultipliedAlpha)o.enable(9);if(S.shadowMapEnabled)o.enable(10);if(S.doubleSided)o.enable(11);if(S.flipSided)o.enable(12);if(S.useDepthPacking)o.enable(13);if(S.dithering)o.enable(14);if(S.transmission)o.enable(15);if(S.sheen)o.enable(16);if(S.opaque)o.enable(17);if(S.pointsUvs)o.enable(18);if(S.decodeVideoTexture)o.enable(19);if(S.decodeVideoTextureEmissive)o.enable(20);if(S.alphaToCoverage)o.enable(21);if(S.numLightProbeGrids>0)o.enable(22);if(S.hasPositionAttribute)o.enable(23);_.push(o.mask)}function R(_){let S=d[_.type],z;if(S){let P=li[S];z=fp.clone(P.uniforms)}else z=_.uniforms;return z}function v(_,S){let z=u.get(S);if(z!==void 0)++z.usedTimes;else z=new kE(e,S,_,r),l.push(z),u.set(S,z);return z}function M(_){if(--_.usedTimes===0){let S=l.indexOf(_);l[S]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:v,releaseProgram:M,releaseShaderCache:T,programs:l,dispose:A}}function VE(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function $E(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Fp(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function zp(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||$E);if(i.length>1)i.sort(d||Fp);if(r.length>1)r.sort(d||Fp)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function WE(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new zp,e.set(i,[o]);else if(r>=s.length)o=new zp,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function ZE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new Oe};break;case"SpotLight":n={position:new O,direction:new O,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function XE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var qE=0;function jE(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function YE(e){let t=new ZE,n=XE(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new O);let r=new O,s=new Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,v=0,M=0,T=0,A=0,_=0,S=0,z=0;l.sort(jE);for(let F=0,ee=l.length;F<ee;F++){let I=l[F],{color:H,intensity:q,distance:C}=I,X=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===wr)X=I.shadow.map.texture;else X=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=H.r*q,f+=H.g*q,h+=H.b*q;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],q);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize.copy(Y.mapSize).multiply(Y.getFrameExtents()),i.sunShadow[g]=Q,i.sunShadowMap[g]=X;let Se=Y.getViewportCount();for(let ue=0;ue<Se;ue++)i.sunShadowMatrix[x+ue]=Y.getMatrix(ue),i.sunShadowCascade[x+ue]=Y._cascadeData[ue];x+=Se,g++}i.sun[d]=k,d++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=X,i.directionalShadowMatrix[p]=I.shadow.matrix,M++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(H).multiplyScalar(q),k.distance=C,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[E]=k;let Y=I.shadow;if(I.map){if(i.spotLightMap[_]=I.map,_++,Y.updateMatrices(I),I.castShadow)S++}if(i.spotLightMatrix[E]=Y.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,i.spotShadow[E]=Q,i.spotShadowMap[E]=X,A++}E++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(H).multiplyScalar(q),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[R]=k,R++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,Q.shadowCameraNear=Y.camera.near,Q.shadowCameraFar=Y.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=X,i.pointShadowMatrix[m]=I.shadow.matrix,T++}i.point[m]=k,m++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(q),k.groundColor.copy(I.groundColor).multiplyScalar(q),i.hemi[v]=k,v++}}if(R>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=de.LTC_FLOAT_1,i.rectAreaLTC2=de.LTC_FLOAT_2;else i.rectAreaLTC1=de.LTC_HALF_1,i.rectAreaLTC2=de.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=f,i.ambient[2]=h;let P=i.hash;if(P.sunLength!==d||P.directionalLength!==p||P.pointLength!==m||P.spotLength!==E||P.rectAreaLength!==R||P.hemiLength!==v||P.numSunShadows!==g||P.numDirectionalShadows!==M||P.numPointShadows!==T||P.numSpotShadows!==A||P.numSpotMaps!==_||P.numLightProbes!==z)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=v,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.directionalShadowMatrix.length=M,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-S,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=z,P.sunLength=d,P.directionalLength=p,P.pointLength=m,P.spotLength=E,P.rectAreaLength=R,P.hemiLength=v,P.numSunShadows=g,P.numDirectionalShadows=M,P.numPointShadows=T,P.numSpotShadows=A,P.numSpotMaps=_,P.numLightProbes=z,i.version=qE++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let v=l[E];if(v.isSunLight){let M=i.sun[f];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),f++}else if(v.isDirectionalLight){let M=i.directional[h];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),h++}else if(v.isSpotLight){let M=i.spot[g];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),g++}else if(v.isRectAreaLight){let M=i.rectArea[x];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),s.copy(v.matrixWorld),s.premultiply(m),o.extractRotation(s),M.halfWidth.set(v.width*0.5,0,0),M.halfHeight.set(0,v.height*0.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(v.isPointLight){let M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){let M=i.hemi[p];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function kp(e){let t=new YE(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function KE(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new kp(e),t.set(r,[a]);else if(s>=o.length)a=new kp(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var JE=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,KE=`uniform sampler2D shadow_pass;
+}`,QE=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
@@ -4317,12 +4317,12 @@ void main() {
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
-}`,JE=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],QE=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],kp=new Ge,ao=new D,zu=new D;function eT(e,t,n){let i=new Js,r=new Ne,s=new Ne,o=new ct,a=new xu,c=new yu,l={},u=n.maxTextureSize,f={[Xi]:Qt,[Qt]:Xi,[Cn]:Cn},h=new Pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:YE,fragmentShader:KE}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new xt(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ks;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===md)Pe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=ks;let S=e.getRenderTarget(),k=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),U=e.state;if(U.setBlending(ii),U.buffers.depth.getReversed()===!0)U.buffers.color.setClear(0,0,0,0);else U.buffers.color.setClear(1,1,1,1);U.buffers.depth.setTest(!0),U.setScissorTest(!1);let ee=m!==this.type;if(ee)A.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((V)=>V.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,V=T.length;P<V;P++){let j=T[P],z=j.shadow;if(z===void 0){Pe("WebGLShadowMap:",j,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);let H=z.getFrameExtents();if(r.multiply(H),s.copy(z.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/H.x),r.x=s.x*H.x,z.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/H.y),r.y=s.y*H.y,z.mapSize.y=s.y}let F=e.state.buffers.depth.getReversed();if(z.camera._reversedDepth=F,z.map===null||ee===!0){if(z.map!==null){if(z.map.depthTexture!==null)z.map.depthTexture.dispose(),z.map.depthTexture=null;z.map.dispose()}if(this.type===is){if(j.isPointLight){Pe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new _n(r.x,r.y,{format:Mr,type:si,minFilter:$t,magFilter:$t,generateMipmaps:!1}),z.map.texture.name=j.name+".shadowMap",z.map.depthTexture=new Er(r.x,r.y,Ai),z.map.depthTexture.name=j.name+".shadowMapDepth",z.map.depthTexture.format=br,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Hn,z.map.depthTexture.magFilter=Hn}else{if(j.isPointLight)z.map=new Gu(r.x),z.map.depthTexture=new mu(r.x,qi);else z.map=new _n(r.x,r.y),z.map.depthTexture=new Er(r.x,r.y,qi);if(z.map.depthTexture.name=j.name+".shadowMap",z.map.depthTexture.format=br,this.type===ks)z.map.depthTexture.compareFunction=F?Pa:Ca,z.map.depthTexture.minFilter=$t,z.map.depthTexture.magFilter=$t;else z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Hn,z.map.depthTexture.magFilter=Hn}z.camera.updateProjectionMatrix()}if(z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==r.x||z.map.height!==r.y))z.map.setSize(r.x,r.y);let q=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();if(j.isPointLight!==!0)z.updateMatrices(j,_);for(let K=0;K<q;K++){let xe=z.getCamera(K);if(j.isPointLight){let{camera:ce,matrix:De}=z,ye=j.distance||ce.far;if(ye!==ce.far)ce.far=ye,ce.updateProjectionMatrix();ao.setFromMatrixPosition(j.matrixWorld),ce.position.copy(ao),zu.copy(ce.position),zu.add(JE[K]),ce.up.copy(QE[K]),ce.lookAt(zu),ce.updateMatrixWorld(),De.makeTranslation(-ao.x,-ao.y,-ao.z),kp.multiplyMatrices(ce.projectionMatrix,ce.matrixWorldInverse),z._frustum.setFromProjectionMatrix(kp,ce.coordinateSystem,ce.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)e.setRenderTarget(z.map,K),e.clear();else{if(K===0)e.setRenderTarget(z.map),e.clear();let ce=z.getViewport(K);o.set(s.x*ce.x,s.y*ce.y,s.x*ce.z,s.y*ce.w),U.viewport(o)}i=z.getFrustum(K),v(A,_,xe,j,this.type)}if(z.isPointLightShadow!==!0&&this.type===is)E(z,_);z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(S,k,C)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:Mr,type:si});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,S){let k=null,C=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(C!==void 0)k=C;else if(k=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let U=k.uuid,ee=A.uuid,P=l[U];if(P===void 0)P={},l[U]=P;let V=P[ee];if(V===void 0)V=k.clone(),P[ee]=V,A.addEventListener("dispose",M);k=V}if(k.visible=A.visible,k.wireframe=A.wireframe,S===is)k.side=A.shadowSide!==null?A.shadowSide:A.side;else k.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(k.alphaMap=A.alphaMap,k.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,k.map=A.map,k.clipShadows=A.clipShadows,k.clippingPlanes=A.clippingPlanes,k.clipIntersection=A.clipIntersection,k.displacementMap=A.displacementMap,k.displacementScale=A.displacementScale,k.displacementBias=A.displacementBias,k.wireframeLinewidth=A.wireframeLinewidth,k.linewidth=A.linewidth,_.isPointLight===!0&&k.isMeshDistanceMaterial===!0){let U=e.properties.get(k);U.light=_}return k}function v(T,A,_,S,k){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&k===is)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let ee=t.update(T),P=T.material;if(Array.isArray(P)){let V=ee.groups;for(let j=0,z=V.length;j<z;j++){let H=V[j],F=P[H.materialIndex];if(F&&F.visible){let q=R(T,F,S,k);T.onBeforeShadow(e,T,A,_,ee,q,H),e.renderBufferDirect(_,null,ee,q,T,H),T.onAfterShadow(e,T,A,_,ee,q,H)}}}else if(P.visible){let V=R(T,P,S,k);T.onBeforeShadow(e,T,A,_,ee,V,null),e.renderBufferDirect(_,null,ee,V,T,null),T.onAfterShadow(e,T,A,_,ee,V,null)}}}let U=T.children;for(let ee=0,P=U.length;ee<P;ee++)v(U[ee],A,_,S,k)}function M(T){T.target.removeEventListener("dispose",M);for(let _ in l){let S=l[_],k=T.target.uuid;if(k in S)S[k].dispose(),delete S[k]}}}function tT(e,t){function n(){let O=!1,le=new ct,J=null,ue=new ct(0,0,0,0);return{setMask:function(be){if(J!==be&&!O)e.colorMask(be,be,be,be),J=be},setLocked:function(be){O=be},setClear:function(be,ne,pe,Be,gt){if(gt===!0)be*=Be,ne*=Be,pe*=Be;if(le.set(be,ne,pe,Be),ue.equals(le)===!1)e.clearColor(be,ne,pe,Be),ue.copy(le)},reset:function(){O=!1,J=null,ue.set(-1,0,0,0)}}}function i(){let O=!1,le=!1,J=null,ue=null,be=null;return{setReversed:function(ne){if(le!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);le=ne;let Be=be;be=null,this.setClear(Be)}},getReversed:function(){return le},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else Te(e.DEPTH_TEST)},setMask:function(ne){if(J!==ne&&!O)e.depthMask(ne),J=ne},setFunc:function(ne){if(le)ne=lp[ne];if(ue!==ne){switch(ne){case Ud:e.depthFunc(e.NEVER);break;case Fd:e.depthFunc(e.ALWAYS);break;case zd:e.depthFunc(e.LESS);break;case gl:e.depthFunc(e.LEQUAL);break;case kd:e.depthFunc(e.EQUAL);break;case Bd:e.depthFunc(e.GEQUAL);break;case Gd:e.depthFunc(e.GREATER);break;case Hd:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}ue=ne}},setLocked:function(ne){O=ne},setClear:function(ne){if(be!==ne){if(be=ne,le)ne=1-ne;e.clearDepth(ne)}},reset:function(){O=!1,J=null,ue=null,be=null,le=!1}}}function r(){let O=!1,le=null,J=null,ue=null,be=null,ne=null,pe=null,Be=null,gt=null;return{setTest:function(rt){if(!O)if(rt)se(e.STENCIL_TEST);else Te(e.STENCIL_TEST)},setMask:function(rt){if(le!==rt&&!O)e.stencilMask(rt),le=rt},setFunc:function(rt,Kn,yi){if(J!==rt||ue!==Kn||be!==yi)e.stencilFunc(rt,Kn,yi),J=rt,ue=Kn,be=yi},setOp:function(rt,Kn,yi){if(ne!==rt||pe!==Kn||Be!==yi)e.stencilOp(rt,Kn,yi),ne=rt,pe=Kn,Be=yi},setLocked:function(rt){O=rt},setClear:function(rt){if(gt!==rt)e.clearStencil(rt),gt=rt},reset:function(){O=!1,le=null,J=null,ue=null,be=null,ne=null,pe=null,Be=null,gt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Ue(0,0,0),S=0,k=!1,C=null,U=null,ee=null,P=null,V=null,j=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,H=0,F=e.getParameter(e.VERSION);if(F.indexOf("WebGL")!==-1)H=parseFloat(/^WebGL (\d)/.exec(F)[1]),z=H>=1;else if(F.indexOf("OpenGL ES")!==-1)H=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),z=H>=2;let q=null,K={},xe=e.getParameter(e.SCISSOR_BOX),ce=e.getParameter(e.VIEWPORT),De=new ct().fromArray(xe),ye=new ct().fromArray(ce);function X(O,le,J,ue){let be=new Uint8Array(4),ne=e.createTexture();e.bindTexture(O,ne),e.texParameteri(O,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(O,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<J;pe++)if(O===e.TEXTURE_3D||O===e.TEXTURE_2D_ARRAY)e.texImage3D(le,0,e.RGBA,1,1,ue,0,e.RGBA,e.UNSIGNED_BYTE,be);else e.texImage2D(le+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,be);return ne}let re={};re[e.TEXTURE_2D]=X(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=X(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=X(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=X(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(gl),Zt(!1),yt(fl),se(e.CULL_FACE),ot(ii);function se(O){if(u[O]!==!0)e.enable(O),u[O]=!0}function Te(O){if(u[O]!==!1)e.disable(O),u[O]=!1}function Ie(O,le){if(h[O]!==le){if(e.bindFramebuffer(O,le),h[O]=le,O===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=le;if(O===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=le;return!0}return!1}function _e(O,le){let J=g,ue=!1;if(O){if(J=d.get(le),J===void 0)J=[],d.set(le,J);let be=O.textures;if(J.length!==be.length||J[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=be.length;ne<pe;ne++)J[ne]=e.COLOR_ATTACHMENT0+ne;J.length=be.length,ue=!0}}else if(J[0]!==e.BACK)J[0]=e.BACK,ue=!0;if(ue)e.drawBuffers(J)}function Qe(O){if(x!==O)return e.useProgram(O),x=O,!0;return!1}let ze={[rs]:e.FUNC_ADD,[_d]:e.FUNC_SUBTRACT,[xd]:e.FUNC_REVERSE_SUBTRACT};ze[yd]=e.MIN,ze[vd]=e.MAX;let Ze={[bd]:e.ZERO,[Sd]:e.ONE,[Md]:e.SRC_COLOR,[Ed]:e.SRC_ALPHA,[Id]:e.SRC_ALPHA_SATURATE,[Cd]:e.DST_COLOR,[Ad]:e.DST_ALPHA,[wd]:e.ONE_MINUS_SRC_COLOR,[Td]:e.ONE_MINUS_SRC_ALPHA,[Pd]:e.ONE_MINUS_DST_COLOR,[Rd]:e.ONE_MINUS_DST_ALPHA,[Ld]:e.CONSTANT_COLOR,[Nd]:e.ONE_MINUS_CONSTANT_COLOR,[Dd]:e.CONSTANT_ALPHA,[Od]:e.ONE_MINUS_CONSTANT_ALPHA};function ot(O,le,J,ue,be,ne,pe,Be,gt,rt){if(O===ii){if(p===!0)Te(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(O!==gd){if(O!==m||rt!==k){if(E!==rs||M!==rs)e.blendEquation(e.FUNC_ADD),E=rs,M=rs;if(rt)switch(O){case Bs:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dl:e.blendFunc(e.ONE,e.ONE);break;case pl:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case ml:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Fe("WebGLState: Invalid blending: ",O);break}else switch(O){case Bs:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case pl:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ml:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",O);break}R=null,v=null,T=null,A=null,_.set(0,0,0),S=0,m=O,k=rt}return}if(be=be||le,ne=ne||J,pe=pe||ue,le!==E||be!==M)e.blendEquationSeparate(ze[le],ze[be]),E=le,M=be;if(J!==R||ue!==v||ne!==T||pe!==A)e.blendFuncSeparate(Ze[J],Ze[ue],Ze[ne],Ze[pe]),R=J,v=ue,T=ne,A=pe;if(Be.equals(_)===!1||gt!==S)e.blendColor(Be.r,Be.g,Be.b,gt),_.copy(Be),S=gt;m=O,k=!1}function Ye(O,le){O.side===Cn?Te(e.CULL_FACE):se(e.CULL_FACE);let J=O.side===Qt;if(le)J=!J;Zt(J),O.blending===Bs&&O.transparent===!1?ot(ii):ot(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),o.setFunc(O.depthFunc),o.setTest(O.depthTest),o.setMask(O.depthWrite),s.setMask(O.colorWrite);let ue=O.stencilWrite;if(a.setTest(ue),ue)a.setMask(O.stencilWriteMask),a.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),a.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass);Dt(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):Te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(O){if(C!==O){if(O)e.frontFace(e.CW);else e.frontFace(e.CCW);C=O}}function yt(O){if(O!==dd){if(se(e.CULL_FACE),O!==U)if(O===fl)e.cullFace(e.BACK);else if(O===pd)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Te(e.CULL_FACE);U=O}function cn(O){if(O!==ee){if(z)e.lineWidth(O);ee=O}}function Dt(O,le,J){if(O){if(se(e.POLYGON_OFFSET_FILL),P!==le||V!==J){if(P=le,V=J,o.getReversed())le=-le;e.polygonOffset(le,J)}}else Te(e.POLYGON_OFFSET_FILL)}function Ot(O){if(O)se(e.SCISSOR_TEST);else Te(e.SCISSOR_TEST)}function L(O){if(O===void 0)O=e.TEXTURE0+j-1;if(q!==O)e.activeTexture(O),q=O}function ln(O,le,J){if(J===void 0)if(q===null)J=e.TEXTURE0+j-1;else J=q;let ue=K[J];if(ue===void 0)ue={type:void 0,texture:void 0},K[J]=ue;if(ue.type!==O||ue.texture!==le){if(q!==J)e.activeTexture(J),q=J;e.bindTexture(O,le||re[O]),ue.type=O,ue.texture=le}}function it(){let O=K[q];if(O!==void 0&&O.type!==void 0)e.bindTexture(O.type,null),O.type=void 0,O.texture=void 0}function wt(){try{e.compressedTexImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function y(){try{e.texSubImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function I(){try{e.texSubImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function W(){try{e.compressedTexSubImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function ae(){try{e.texStorage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function he(){try{e.texStorage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function Y(){try{e.texImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function te(){try{e.texImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function ve(O){if(f[O]!==void 0)return f[O];else return e.getParameter(O)}function Ce(O,le){if(f[O]!==le)e.pixelStorei(O,le),f[O]=le}function fe(O){if(De.equals(O)===!1)e.scissor(O.x,O.y,O.z,O.w),De.copy(O)}function oe(O){if(ye.equals(O)===!1)e.viewport(O.x,O.y,O.z,O.w),ye.copy(O)}function Le(O,le){let J=l.get(le);if(J===void 0)J=new WeakMap,l.set(le,J);let ue=J.get(O);if(ue===void 0)ue=e.getUniformBlockIndex(le,O.name),J.set(O,ue)}function Oe(O,le){let ue=l.get(le).get(O);if(c.get(le)!==ue)e.uniformBlockBinding(le,ue,O.__bindingPointIndex),c.set(le,ue)}function et(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},q=null,K={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Ue(0,0,0),S=0,k=!1,C=null,U=null,ee=null,P=null,V=null,De.set(0,0,e.canvas.width,e.canvas.height),ye.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:Te,bindFramebuffer:Ie,drawBuffers:_e,useProgram:Qe,setBlending:ot,setMaterial:Ye,setFlipSided:Zt,setCullFace:yt,setLineWidth:cn,setPolygonOffset:Dt,setScissorTest:Ot,activeTexture:L,bindTexture:ln,unbindTexture:it,compressedTexImage2D:wt,compressedTexImage3D:w,texImage2D:Y,texImage3D:te,pixelStorei:Ce,getParameter:ve,updateUBOMapping:Le,uniformBlockBinding:Oe,texStorage2D:ae,texStorage3D:he,texSubImage2D:y,texSubImage3D:I,compressedTexSubImage2D:W,compressedTexSubImage3D:ie,scissor:fe,viewport:oe,reset:et}}function nT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,y){return g?new OffscreenCanvas(w,y):es("canvas")}function p(w,y,I){let W=1,ie=wt(w);if(ie.width>I||ie.height>I)W=I/Math.max(ie.width,ie.height);if(W<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(W*ie.width),he=Math.floor(W*ie.height);if(h===void 0)h=x(ae,he);let Y=y?x(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(w,0,0,ae,he),Pe("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in w)Pe("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(w,y,I,W,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Pe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let he;if(W){if(he=t.get("EXT_texture_norm16"),!he)Pe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=y;if(y===e.RED){if(I===e.FLOAT)Y=e.R32F;if(I===e.HALF_FLOAT)Y=e.R16F;if(I===e.UNSIGNED_BYTE)Y=e.R8;if(I===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(I===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.R8UI;if(I===e.UNSIGNED_SHORT)Y=e.R16UI;if(I===e.UNSIGNED_INT)Y=e.R32UI;if(I===e.BYTE)Y=e.R8I;if(I===e.SHORT)Y=e.R16I;if(I===e.INT)Y=e.R32I}if(y===e.RG){if(I===e.FLOAT)Y=e.RG32F;if(I===e.HALF_FLOAT)Y=e.RG16F;if(I===e.UNSIGNED_BYTE)Y=e.RG8;if(I===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(I===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.RG8UI;if(I===e.UNSIGNED_SHORT)Y=e.RG16UI;if(I===e.UNSIGNED_INT)Y=e.RG32UI;if(I===e.BYTE)Y=e.RG8I;if(I===e.SHORT)Y=e.RG16I;if(I===e.INT)Y=e.RG32I}if(y===e.RGB_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(I===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(I===e.UNSIGNED_INT)Y=e.RGB32UI;if(I===e.BYTE)Y=e.RGB8I;if(I===e.SHORT)Y=e.RGB16I;if(I===e.INT)Y=e.RGB32I}if(y===e.RGBA_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(I===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(I===e.UNSIGNED_INT)Y=e.RGBA32UI;if(I===e.BYTE)Y=e.RGBA8I;if(I===e.SHORT)Y=e.RGBA16I;if(I===e.INT)Y=e.RGBA32I}if(y===e.RGB){if(I===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(I===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(I===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(I===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(y===e.RGBA){let te=ae?cu:$e.getTransfer(ie);if(I===e.FLOAT)Y=e.RGBA32F;if(I===e.HALF_FLOAT)Y=e.RGBA16F;if(I===e.UNSIGNED_BYTE)Y=te===pt?e.SRGB8_ALPHA8:e.RGBA8;if(I===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(I===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(I===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(I===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function M(w,y){let I;if(w){if(y===null||y===qi||y===ls)I=e.DEPTH24_STENCIL8;else if(y===Ai)I=e.DEPTH32F_STENCIL8;else if(y===Vs)I=e.DEPTH24_STENCIL8,Pe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===qi||y===ls)I=e.DEPTH_COMPONENT24;else if(y===Ai)I=e.DEPTH_COMPONENT32F;else if(y===Vs)I=e.DEPTH_COMPONENT16;return I}function T(w,y){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Hn&&w.minFilter!==$t)return Math.log2(Math.max(y.width,y.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return y.mipmaps.length;else return 1}function A(w){let y=w.target;if(y.removeEventListener("dispose",A),S(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)f.delete(y)}function _(w){let y=w.target;y.removeEventListener("dispose",_),C(y)}function S(w){let y=i.get(w);if(y.__webglInit===void 0)return;let I=w.source,W=d.get(I);if(W){let ie=W[y.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)k(w);if(Object.keys(W).length===0)d.delete(I)}i.remove(w)}function k(w){let y=i.get(w);e.deleteTexture(y.__webglTexture);let I=w.source,W=d.get(I);delete W[y.__cacheKey],o.memory.textures--}function C(w){let y=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(y.__webglFramebuffer[W]))for(let ie=0;ie<y.__webglFramebuffer[W].length;ie++)e.deleteFramebuffer(y.__webglFramebuffer[W][ie]);else e.deleteFramebuffer(y.__webglFramebuffer[W]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[W])}else{if(Array.isArray(y.__webglFramebuffer))for(let W=0;W<y.__webglFramebuffer.length;W++)e.deleteFramebuffer(y.__webglFramebuffer[W]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let W=0;W<y.__webglColorRenderbuffer.length;W++)if(y.__webglColorRenderbuffer[W])e.deleteRenderbuffer(y.__webglColorRenderbuffer[W])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let I=w.textures;for(let W=0,ie=I.length;W<ie;W++){let ae=i.get(I[W]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(I[W])}i.remove(w)}let U=0;function ee(){U=0}function P(){return U}function V(w){U=w}function j(){let w=U;if(w>=r.maxTextures)Pe("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return U+=1,w}function z(w){let y=[];return y.push(w.wrapS),y.push(w.wrapT),y.push(w.wrapR||0),y.push(w.magFilter),y.push(w.minFilter),y.push(w.anisotropy),y.push(w.internalFormat),y.push(w.format),y.push(w.type),y.push(w.generateMipmaps),y.push(w.premultiplyAlpha),y.push(w.flipY),y.push(w.unpackAlignment),y.push(w.colorSpace),y.join()}function H(w,y){let I=i.get(w);if(w.isVideoTexture)ln(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&I.__version!==w.version){let W=w.image;if(W===null)Pe("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Pe("WebGLRenderer: Texture marked for update but image is incomplete");else{Te(I,w,y);return}}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,I.__webglTexture,e.TEXTURE0+y)}function F(w,y){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Te(I,w,y);return}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,I.__webglTexture,e.TEXTURE0+y)}function q(w,y){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Te(I,w,y);return}n.bindTexture(e.TEXTURE_3D,I.__webglTexture,e.TEXTURE0+y)}function K(w,y){let I=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&I.__version!==w.version){Ie(I,w,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,I.__webglTexture,e.TEXTURE0+y)}let xe={[os]:e.REPEAT,[as]:e.CLAMP_TO_EDGE,[va]:e.MIRRORED_REPEAT},ce={[Hn]:e.NEAREST,[ba]:e.NEAREST_MIPMAP_NEAREST,[vr]:e.NEAREST_MIPMAP_LINEAR,[$t]:e.LINEAR,[cs]:e.LINEAR_MIPMAP_NEAREST,[ri]:e.LINEAR_MIPMAP_LINEAR},De={[ep]:e.NEVER,[sp]:e.ALWAYS,[tp]:e.LESS,[Ca]:e.LEQUAL,[np]:e.EQUAL,[Pa]:e.GEQUAL,[ip]:e.GREATER,[rp]:e.NOTEQUAL};function ye(w,y){if(y.type===Ai&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===$t||y.magFilter===cs||y.magFilter===vr||y.magFilter===ri||y.minFilter===$t||y.minFilter===cs||y.minFilter===vr||y.minFilter===ri))Pe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,xe[y.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,xe[y.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,xe[y.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ce[y.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ce[y.minFilter]),y.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,De[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Hn)return;if(y.minFilter!==vr&&y.minFilter!==ri)return;if(y.type===Ai&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let I=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function X(w,y){let I=!1;if(w.__webglInit===void 0)w.__webglInit=!0,y.addEventListener("dispose",A);let W=y.source,ie=d.get(W);if(ie===void 0)ie={},d.set(W,ie);let ae=z(y);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,I=!0;ie[ae].usedTimes++;let he=ie[w.__cacheKey];if(he!==void 0){if(ie[w.__cacheKey].usedTimes--,he.usedTimes===0)k(y)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return I}function re(w,y,I){return Math.floor(Math.floor(w/I)/y)}function se(w,y,I,W){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,I,W,y.data);else{ae.sort((Ce,fe)=>Ce.start-fe.start);let he=0;for(let Ce=1;Ce<ae.length;Ce++){let fe=ae[he],oe=ae[Ce],Le=fe.start+fe.count,Oe=re(oe.start,y.width,4),et=re(fe.start,y.width,4);if(oe.start<=Le+1&&Oe===et&&re(oe.start+oe.count-1,y.width,4)===Oe)fe.count=Math.max(fe.count,oe.start+oe.count-fe.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),ve=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Ce=0,fe=ae.length;Ce<fe;Ce++){let oe=ae[Ce],Le=Math.floor(oe.start/4),Oe=Math.ceil(oe.count/4),et=Le%y.width,O=Math.floor(Le/y.width),le=Oe,J=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,et),n.pixelStorei(e.UNPACK_SKIP_ROWS,O),n.texSubImage2D(e.TEXTURE_2D,0,et,O,le,1,I,W,y.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,ve)}}function Te(w,y,I){let W=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)W=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)W=e.TEXTURE_3D;let ie=X(w,y),ae=y.source;n.bindTexture(W,w.__webglTexture,e.TEXTURE0+I);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+I),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let J=$e.getPrimaries($e.workingColorSpace),ue=y.colorSpace===wr?null:$e.getPrimaries(y.colorSpace),be=y.colorSpace===wr||J===ue?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,be)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let te=p(y.image,!1,r.maxTextureSize);te=it(y,te);let ve=s.convert(y.format,y.colorSpace),Ce=s.convert(y.type),fe=v(y.internalFormat,ve,Ce,y.normalized,y.colorSpace,y.isVideoTexture);ye(W,y);let oe,Le=y.mipmaps,Oe=y.isVideoTexture!==!0,et=he.__version===void 0||ie===!0,O=ae.dataReady,le=T(y,te);if(y.isDepthTexture){if(fe=M(y.format===Sr,y.type),et)if(Oe)n.texStorage2D(e.TEXTURE_2D,1,fe,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,ve,Ce,null)}else if(y.isDataTexture)if(Le.length>0){if(Oe&&et)n.texStorage2D(e.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],Oe){if(O)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,ve,Ce,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,fe,oe.width,oe.height,0,ve,Ce,oe.data);y.generateMipmaps=!1}else if(Oe){if(et)n.texStorage2D(e.TEXTURE_2D,le,fe,te.width,te.height);if(O)se(y,te,ve,Ce)}else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,ve,Ce,te.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(Oe&&et)n.texStorage3D(e.TEXTURE_2D_ARRAY,le,fe,Le[0].width,Le[0].height,te.depth);for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],y.format!==oi)if(ve!==null)if(Oe){if(O)if(y.layerUpdates.size>0){let be=Lu(oe.width,oe.height,y.format,y.type);for(let ne of y.layerUpdates){let pe=oe.data.subarray(ne*be/oe.data.BYTES_PER_ELEMENT,(ne+1)*be/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,ne,oe.width,oe.height,1,ve,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,te.depth,ve,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,J,fe,oe.width,oe.height,te.depth,0,oe.data,0,0);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(O)n.texSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,te.depth,ve,Ce,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,J,fe,oe.width,oe.height,te.depth,0,ve,Ce,oe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(Oe&&et)n.texStorage2D(e.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],y.format!==oi)if(ve!==null)if(Oe){if(O)n.compressedTexSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,ve,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,J,fe,oe.width,oe.height,0,oe.data);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(O)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,ve,Ce,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,fe,oe.width,oe.height,0,ve,Ce,oe.data)}else if(y.isDataArrayTexture)if(Oe){if(et)n.texStorage3D(e.TEXTURE_2D_ARRAY,le,fe,te.width,te.height,te.depth);if(O)if(y.layerUpdates.size>0){let J=Lu(te.width,te.height,y.format,y.type);for(let ue of y.layerUpdates){let be=te.data.subarray(ue*J/te.data.BYTES_PER_ELEMENT,(ue+1)*J/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,ue,te.width,te.height,1,ve,Ce,be)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,ve,Ce,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,fe,te.width,te.height,te.depth,0,ve,Ce,te.data);else if(y.isData3DTexture)if(Oe){if(et)n.texStorage3D(e.TEXTURE_3D,le,fe,te.width,te.height,te.depth);if(O)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,ve,Ce,te.data)}else n.texImage3D(e.TEXTURE_3D,0,fe,te.width,te.height,te.depth,0,ve,Ce,te.data);else if(y.isFramebufferTexture){if(et)if(Oe)n.texStorage2D(e.TEXTURE_2D,le,fe,te.width,te.height);else{let J=te.width,ue=te.height;for(let be=0;be<le;be++)n.texImage2D(e.TEXTURE_2D,be,fe,J,ue,0,ve,Ce,null),J>>=1,ue>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let J=e.canvas;if(!J.hasAttribute("layoutsubtree"))J.setAttribute("layoutsubtree","true");if(te.parentNode!==J){J.appendChild(te),f.add(y),J.onpaint=(ue)=>{let be=ue.changedElements;for(let ne of f)if(be.includes(ne.image))ne.needsUpdate=!0},J.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:be,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,be,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Oe&&et){let J=wt(Le[0]);n.texStorage2D(e.TEXTURE_2D,le,fe,J.width,J.height)}for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],Oe){if(O)n.texSubImage2D(e.TEXTURE_2D,J,0,0,ve,Ce,oe)}else n.texImage2D(e.TEXTURE_2D,J,fe,ve,Ce,oe);y.generateMipmaps=!1}else if(Oe){if(et){let J=wt(te);n.texStorage2D(e.TEXTURE_2D,le,fe,J.width,J.height)}if(O)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ve,Ce,te)}else n.texImage2D(e.TEXTURE_2D,0,fe,ve,Ce,te);if(m(y))E(W);if(he.__version=ae.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function Ie(w,y,I){if(y.image.length!==6)return;let W=X(w,y),ie=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+I);let ae=i.get(ie);if(ie.version!==ae.__version||W===!0){n.activeTexture(e.TEXTURE0+I);let he=$e.getPrimaries($e.workingColorSpace),Y=y.colorSpace===wr?null:$e.getPrimaries(y.colorSpace),te=y.colorSpace===wr||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let ve=y.isCompressedTexture||y.image[0].isCompressedTexture,Ce=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let ne=0;ne<6;ne++){if(!ve&&!Ce)fe[ne]=p(y.image[ne],!0,r.maxCubemapSize);else fe[ne]=Ce?y.image[ne].image:y.image[ne];fe[ne]=it(y,fe[ne])}let oe=fe[0],Le=s.convert(y.format,y.colorSpace),Oe=s.convert(y.type),et=v(y.internalFormat,Le,Oe,y.normalized,y.colorSpace),O=y.isVideoTexture!==!0,le=ae.__version===void 0||W===!0,J=ie.dataReady,ue=T(y,oe);ye(e.TEXTURE_CUBE_MAP,y);let be;if(ve){if(O&&le)n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,et,oe.width,oe.height);for(let ne=0;ne<6;ne++){be=fe[ne].mipmaps;for(let pe=0;pe<be.length;pe++){let Be=be[pe];if(y.format!==oi)if(Le!==null)if(O){if(J)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,et,Be.width,Be.height,0,Be.data);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Oe,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,et,Be.width,Be.height,0,Le,Oe,Be.data)}}}else{if(be=y.mipmaps,O&&le){if(be.length>0)ue++;let ne=wt(fe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,et,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ce){if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,fe[ne].width,fe[ne].height,Le,Oe,fe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,et,fe[ne].width,fe[ne].height,0,Le,Oe,fe[ne].data);for(let pe=0;pe<be.length;pe++){let gt=be[pe].image[ne].image;if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,gt.width,gt.height,Le,Oe,gt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,et,gt.width,gt.height,0,Le,Oe,gt.data)}}else{if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,Oe,fe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,et,Le,Oe,fe[ne]);for(let pe=0;pe<be.length;pe++){let Be=be[pe];if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Le,Oe,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,et,Le,Oe,Be.image[ne])}}}if(m(y))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function _e(w,y,I,W,ie,ae){let he=s.convert(I.format,I.colorSpace),Y=s.convert(I.type),te=v(I.internalFormat,he,Y,I.normalized,I.colorSpace),ve=i.get(y),Ce=i.get(I);if(Ce.__renderTarget=y,!ve.__hasExternalTextures){let fe=Math.max(1,y.width>>ae),oe=Math.max(1,y.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,fe,oe,y.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,fe,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),L(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,W,ie,Ce.__webglTexture,0,Ot(y));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,W,ie,Ce.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Qe(w,y,I){if(e.bindRenderbuffer(e.RENDERBUFFER,w),y.depthBuffer){let W=y.depthTexture,ie=W&&W.isDepthTexture?W.type:null,ae=M(y.stencilBuffer,ie),he=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,w)}else{let W=y.textures;for(let ie=0;ie<W.length;ie++){let ae=W[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=v(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(L(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,te,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ze(w,y,I){let W=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(y.depthTexture);if(ie.__renderTarget=y,!ie.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(W){if(ie.__webglInit===void 0)ie.__webglInit=!0,y.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),ye(e.TEXTURE_CUBE_MAP,y.depthTexture);let ve=s.convert(y.depthTexture.format),Ce=s.convert(y.depthTexture.type),fe;if(y.depthTexture.format===br)fe=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Sr)fe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,fe,y.width,y.height,0,ve,Ce,null)}}else H(y.depthTexture,0);let ae=ie.__webglTexture,he=Ot(y),Y=W?e.TEXTURE_CUBE_MAP_POSITIVE_X+I:e.TEXTURE_2D,te=y.depthTexture.format===Sr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===br)if(L(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(y.depthTexture.format===Sr)if(L(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let y=i.get(w),I=w.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==w.depthTexture){let W=w.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(W){let ie=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,W.removeEventListener("dispose",ie)};W.addEventListener("dispose",ie),y.__depthDisposeCallback=ie}y.__boundDepthTexture=W}if(w.depthTexture&&!y.__autoAllocateDepthBuffer)if(I)for(let W=0;W<6;W++)ze(y.__webglFramebuffer[W],w,W);else{let W=w.texture.mipmaps;if(W&&W.length>0)ze(y.__webglFramebuffer[0],w,0);else ze(y.__webglFramebuffer,w,0)}else if(I){y.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[W]),y.__webglDepthbuffer[W]===void 0)y.__webglDepthbuffer[W]=e.createRenderbuffer(),Qe(y.__webglDepthbuffer[W],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[W];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let W=w.texture.mipmaps;if(W&&W.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),Qe(y.__webglDepthbuffer,w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ot(w,y,I){let W=i.get(w);if(y!==void 0)_e(W.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(I!==void 0)Ze(w)}function Ye(w){let y=w.texture,I=i.get(w),W=i.get(y);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(W.__webglTexture===void 0)W.__webglTexture=e.createTexture();W.__version=y.version,o.memory.textures++}if(ae){I.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(y.mipmaps&&y.mipmaps.length>0){I.__webglFramebuffer[Y]=[];for(let te=0;te<y.mipmaps.length;te++)I.__webglFramebuffer[Y][te]=e.createFramebuffer()}else I.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){I.__webglFramebuffer=[];for(let Y=0;Y<y.mipmaps.length;Y++)I.__webglFramebuffer[Y]=e.createFramebuffer()}else I.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let ve=i.get(ie[Y]);if(ve.__webglTexture===void 0)ve.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&L(w)===!1){I.__webglMultisampledFramebuffer=e.createFramebuffer(),I.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];I.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,I.__webglColorRenderbuffer[Y]);let ve=s.convert(te.format,te.colorSpace),Ce=s.convert(te.type),fe=v(te.internalFormat,ve,Ce,te.normalized,te.colorSpace,w.isXRRenderTarget===!0),oe=Ot(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,fe,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,I.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)I.__webglDepthRenderbuffer=e.createRenderbuffer(),Qe(I.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,W.__webglTexture),ye(e.TEXTURE_CUBE_MAP,y);for(let Y=0;Y<6;Y++)if(y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)_e(I.__webglFramebuffer[Y][te],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else _e(I.__webglFramebuffer[Y],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(m(y))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let ve=ie[Y],Ce=i.get(ve),fe=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)fe=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(fe,Ce.__webglTexture),ye(fe,ve),_e(I.__webglFramebuffer,w,ve,e.COLOR_ATTACHMENT0+Y,fe,0),m(ve))E(fe)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)Y=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,W.__webglTexture),ye(Y,y),y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)_e(I.__webglFramebuffer[te],w,y,e.COLOR_ATTACHMENT0,Y,te);else _e(I.__webglFramebuffer,w,y,e.COLOR_ATTACHMENT0,Y,0);if(m(y))E(Y);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Zt(w){let y=w.textures;for(let I=0,W=y.length;I<W;I++){let ie=y[I];if(m(ie)){let ae=R(w),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),E(ae),n.unbindTexture()}}}let yt=[],cn=[];function Dt(w){if(w.samples>0){if(L(w)===!1){let{textures:y,width:I,height:W}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(w),Y=y.length>1;if(Y)for(let ve=0;ve<y.length;ve++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=w.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let ve=0;ve<y.length;ve++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[ve]);let Ce=i.get(y[ve]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ce,0)}if(e.blitFramebuffer(0,0,I,W,0,0,I,W,ie,e.NEAREST),c===!0){if(yt.length=0,cn.length=0,yt.push(e.COLOR_ATTACHMENT0+ve),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)yt.push(ae),cn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,cn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,yt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let ve=0;ve<y.length;ve++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.RENDERBUFFER,he.__webglColorRenderbuffer[ve]);let Ce=i.get(y[ve]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.TEXTURE_2D,Ce,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let y=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function Ot(w){return Math.min(r.maxSamples,w.samples)}function L(w){let y=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ln(w){let y=o.render.frame;if(u.get(w)!==y)u.set(w,y),w.update()}function it(w,y){let{colorSpace:I,format:W,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return y;if(I!==gn&&I!==wr)if($e.getTransfer(I)===pt){if(W!==oi||ie!==Vn)Pe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Fe("WebGLTextures: Unsupported texture color space:",I);return y}function wt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=j,this.resetTextureUnits=ee,this.getTextureUnits=P,this.setTextureUnits=V,this.setTexture2D=H,this.setTexture2DArray=F,this.setTexture3D=q,this.setTextureCube=K,this.rebindTextures=ot,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Zt,this.updateMultisampleRenderTarget=Dt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=_e,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function iT(e,t){function n(i,r=wr){let s,o=$e.getTransfer(r);if(i===Vn)return e.UNSIGNED_BYTE;if(i===wl)return e.UNSIGNED_SHORT_4_4_4_4;if(i===El)return e.UNSIGNED_SHORT_5_5_5_1;if(i===qd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===jd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Zd)return e.BYTE;if(i===Xd)return e.SHORT;if(i===Vs)return e.UNSIGNED_SHORT;if(i===Ml)return e.INT;if(i===qi)return e.UNSIGNED_INT;if(i===Ai)return e.FLOAT;if(i===si)return e.HALF_FLOAT;if(i===Yd)return e.ALPHA;if(i===Kd)return e.RGB;if(i===oi)return e.RGBA;if(i===br)return e.DEPTH_COMPONENT;if(i===Sr)return e.DEPTH_STENCIL;if(i===Jd)return e.RED;if(i===Tl)return e.RED_INTEGER;if(i===Mr)return e.RG;if(i===Al)return e.RG_INTEGER;if(i===Rl)return e.RGBA_INTEGER;if(i===Sa||i===Ma||i===wa||i===Ea)if(o===pt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Sa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===wa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Sa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===wa)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ea)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Cl||i===Pl||i===Il||i===Ll)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Cl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Pl)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Il)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ll)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nl||i===Dl||i===Ol||i===Ul||i===Fl||i===Ta||i===zl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Nl||i===Dl)return o===pt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ol)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ul)return s.COMPRESSED_R11_EAC;if(i===Fl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ta)return s.COMPRESSED_RG11_EAC;if(i===zl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===kl||i===Bl||i===Gl||i===Hl||i===Vl||i===$l||i===Wl||i===Zl||i===Xl||i===ql||i===jl||i===Yl||i===Kl||i===Jl)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===kl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Bl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Hl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Vl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$l)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Wl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Zl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Xl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ql)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===jl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Yl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Kl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Jl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ql||i===eu||i===tu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Ql)return o===pt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===eu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===tu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===nu||i===iu||i===Aa||i===ru)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===nu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===iu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Aa)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===ls)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var rT=`
+}`,eT=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],tT=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],Bp=new Ge,ho=new O,ku=new O;function nT(e,t,n){let i=new no,r=new Ne,s=new Ne,o=new at,a=new yu,c=new vu,l={},u=n.maxTextureSize,f={[qi]:Qt,[Qt]:qi,[Pn]:Pn},h=new In({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:JE,fragmentShader:QE}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new _t(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Vs;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===gd)Ie("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Vs;let S=e.getRenderTarget(),z=e.getActiveCubeFace(),P=e.getActiveMipmapLevel(),F=e.state;if(F.setBlending(ii),F.buffers.depth.getReversed()===!0)F.buffers.color.setClear(0,0,0,0);else F.buffers.color.setClear(1,1,1,1);F.buffers.depth.setTest(!0),F.setScissorTest(!1);let ee=m!==this.type;if(ee)A.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((H)=>H.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,H=T.length;I<H;I++){let q=T[I],C=q.shadow;if(C===void 0){Ie("WebGLShadowMap:",q,"has no shadow.");continue}if(C.autoUpdate===!1&&C.needsUpdate===!1)continue;r.copy(C.mapSize);let X=C.getFrameExtents();if(r.multiply(X),s.copy(C.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/X.x),r.x=s.x*X.x,C.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/X.y),r.y=s.y*X.y,C.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(C.camera._reversedDepth=k,C.map===null||ee===!0){if(C.map!==null){if(C.map.depthTexture!==null)C.map.depthTexture.dispose(),C.map.depthTexture=null;C.map.dispose()}if(this.type===ss){if(q.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}C.map=new _n(r.x,r.y,{format:wr,type:si,minFilter:$t,magFilter:$t,generateMipmaps:!1}),C.map.texture.name=q.name+".shadowMap",C.map.depthTexture=new Tr(r.x,r.y,Ri),C.map.depthTexture.name=q.name+".shadowMapDepth",C.map.depthTexture.format=Sr,C.map.depthTexture.compareFunction=null,C.map.depthTexture.minFilter=Vn,C.map.depthTexture.magFilter=Vn}else{if(q.isPointLight)C.map=new Hu(r.x),C.map.depthTexture=new gu(r.x,ji);else C.map=new _n(r.x,r.y),C.map.depthTexture=new Tr(r.x,r.y,ji);if(C.map.depthTexture.name=q.name+".shadowMap",C.map.depthTexture.format=Sr,this.type===Vs)C.map.depthTexture.compareFunction=k?La:Ia,C.map.depthTexture.minFilter=$t,C.map.depthTexture.magFilter=$t;else C.map.depthTexture.compareFunction=null,C.map.depthTexture.minFilter=Vn,C.map.depthTexture.magFilter=Vn}C.camera.updateProjectionMatrix()}if(C.map.isWebGLCubeRenderTarget!==!0&&(C.map.width!==r.x||C.map.height!==r.y))C.map.setSize(r.x,r.y);let Y=C.map.isWebGLCubeRenderTarget?6:C.getViewportCount();if(q.isPointLight!==!0)C.updateMatrices(q,_);for(let Q=0;Q<Y;Q++){let Se=C.getCamera(Q);if(q.isPointLight){let{camera:ue,matrix:Fe}=C,Me=q.distance||ue.far;if(Me!==ue.far)ue.far=Me,ue.updateProjectionMatrix();ho.setFromMatrixPosition(q.matrixWorld),ue.position.copy(ho),ku.copy(ue.position),ku.add(eT[Q]),ue.up.copy(tT[Q]),ue.lookAt(ku),ue.updateMatrixWorld(),Fe.makeTranslation(-ho.x,-ho.y,-ho.z),Bp.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),C._frustum.setFromProjectionMatrix(Bp,ue.coordinateSystem,ue.reversedDepth)}if(C.map.isWebGLCubeRenderTarget)e.setRenderTarget(C.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(C.map),e.clear();let ue=C.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),F.viewport(o)}i=C.getFrustum(Q),v(A,_,Se,q,this.type)}if(C.isPointLightShadow!==!0&&this.type===ss)E(C,_);C.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(S,z,P)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:wr,type:si});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,S){let z=null,P=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(P!==void 0)z=P;else if(z=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let F=z.uuid,ee=A.uuid,I=l[F];if(I===void 0)I={},l[F]=I;let H=I[ee];if(H===void 0)H=z.clone(),I[ee]=H,A.addEventListener("dispose",M);z=H}if(z.visible=A.visible,z.wireframe=A.wireframe,S===ss)z.side=A.shadowSide!==null?A.shadowSide:A.side;else z.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(z.alphaMap=A.alphaMap,z.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,z.map=A.map,z.clipShadows=A.clipShadows,z.clippingPlanes=A.clippingPlanes,z.clipIntersection=A.clipIntersection,z.displacementMap=A.displacementMap,z.displacementScale=A.displacementScale,z.displacementBias=A.displacementBias,z.wireframeLinewidth=A.wireframeLinewidth,z.linewidth=A.linewidth,_.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let F=e.properties.get(z);F.light=_}return z}function v(T,A,_,S,z){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&z===ss)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let ee=t.update(T),I=T.material;if(Array.isArray(I)){let H=ee.groups;for(let q=0,C=H.length;q<C;q++){let X=H[q],k=I[X.materialIndex];if(k&&k.visible){let Y=R(T,k,S,z);T.onBeforeShadow(e,T,A,_,ee,Y,X),e.renderBufferDirect(_,null,ee,Y,T,X),T.onAfterShadow(e,T,A,_,ee,Y,X)}}}else if(I.visible){let H=R(T,I,S,z);T.onBeforeShadow(e,T,A,_,ee,H,null),e.renderBufferDirect(_,null,ee,H,T,null),T.onAfterShadow(e,T,A,_,ee,H,null)}}}let F=T.children;for(let ee=0,I=F.length;ee<I;ee++)v(F[ee],A,_,S,z)}function M(T){T.target.removeEventListener("dispose",M);for(let _ in l){let S=l[_],z=T.target.uuid;if(z in S)S[z].dispose(),delete S[z]}}}function iT(e,t){function n(){let U=!1,ce=new at,K=null,le=new at(0,0,0,0);return{setMask:function(ye){if(K!==ye&&!U)e.colorMask(ye,ye,ye,ye),K=ye},setLocked:function(ye){U=ye},setClear:function(ye,ne,pe,Be,mt){if(mt===!0)ye*=Be,ne*=Be,pe*=Be;if(ce.set(ye,ne,pe,Be),le.equals(ce)===!1)e.clearColor(ye,ne,pe,Be),le.copy(ce)},reset:function(){U=!1,K=null,le.set(-1,0,0,0)}}}function i(){let U=!1,ce=!1,K=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let Be=ye;ye=null,this.setClear(Be)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(K!==ne&&!U)e.depthMask(ne),K=ne},setFunc:function(ne){if(ce)ne=up[ne];if(le!==ne){switch(ne){case Fd:e.depthFunc(e.NEVER);break;case zd:e.depthFunc(e.ALWAYS);break;case kd:e.depthFunc(e.LESS);break;case _l:e.depthFunc(e.LEQUAL);break;case Bd:e.depthFunc(e.EQUAL);break;case Gd:e.depthFunc(e.GEQUAL);break;case Hd:e.depthFunc(e.GREATER);break;case Vd:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){U=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){U=!1,K=null,le=null,ye=null,ce=!1}}}function r(){let U=!1,ce=null,K=null,le=null,ye=null,ne=null,pe=null,Be=null,mt=null;return{setTest:function(it){if(!U)if(it)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(it){if(ce!==it&&!U)e.stencilMask(it),ce=it},setFunc:function(it,Kn,vi){if(K!==it||le!==Kn||ye!==vi)e.stencilFunc(it,Kn,vi),K=it,le=Kn,ye=vi},setOp:function(it,Kn,vi){if(ne!==it||pe!==Kn||Be!==vi)e.stencilOp(it,Kn,vi),ne=it,pe=Kn,Be=vi},setLocked:function(it){U=it},setClear:function(it){if(mt!==it)e.clearStencil(it),mt=it},reset:function(){U=!1,ce=null,K=null,le=null,ye=null,ne=null,pe=null,Be=null,mt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Oe(0,0,0),S=0,z=!1,P=null,F=null,ee=null,I=null,H=null,q=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),C=!1,X=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)X=parseFloat(/^WebGL (\d)/.exec(k)[1]),C=X>=1;else if(k.indexOf("OpenGL ES")!==-1)X=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),C=X>=2;let Y=null,Q={},Se=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Fe=new at().fromArray(Se),Me=new at().fromArray(ue);function Z(U,ce,K,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(U,ne),e.texParameteri(U,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(U,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<K;pe++)if(U===e.TEXTURE_3D||U===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(_l),Zt(!1),yt(dl),se(e.CULL_FACE),st(ii);function se(U){if(u[U]!==!0)e.enable(U),u[U]=!0}function xe(U){if(u[U]!==!1)e.disable(U),u[U]=!1}function we(U,ce){if(h[U]!==ce){if(e.bindFramebuffer(U,ce),h[U]=ce,U===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(U===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ee(U,ce){let K=g,le=!1;if(U){if(K=d.get(ce),K===void 0)K=[],d.set(ce,K);let ye=U.textures;if(K.length!==ye.length||K[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)K[ne]=e.COLOR_ATTACHMENT0+ne;K.length=ye.length,le=!0}}else if(K[0]!==e.BACK)K[0]=e.BACK,le=!0;if(le)e.drawBuffers(K)}function xt(U){if(x!==U)return e.useProgram(U),x=U,!0;return!1}let ke={[os]:e.FUNC_ADD,[xd]:e.FUNC_SUBTRACT,[yd]:e.FUNC_REVERSE_SUBTRACT};ke[vd]=e.MIN,ke[bd]=e.MAX;let Ze={[Sd]:e.ZERO,[Md]:e.ONE,[wd]:e.SRC_COLOR,[Td]:e.SRC_ALPHA,[Ld]:e.SRC_ALPHA_SATURATE,[Pd]:e.DST_COLOR,[Rd]:e.DST_ALPHA,[Ed]:e.ONE_MINUS_SRC_COLOR,[Ad]:e.ONE_MINUS_SRC_ALPHA,[Id]:e.ONE_MINUS_DST_COLOR,[Cd]:e.ONE_MINUS_DST_ALPHA,[Nd]:e.CONSTANT_COLOR,[Dd]:e.ONE_MINUS_CONSTANT_COLOR,[Od]:e.CONSTANT_ALPHA,[Ud]:e.ONE_MINUS_CONSTANT_ALPHA};function st(U,ce,K,le,ye,ne,pe,Be,mt,it){if(U===ii){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(U!==_d){if(U!==m||it!==z){if(E!==os||M!==os)e.blendEquation(e.FUNC_ADD),E=os,M=os;if(it)switch(U){case $s:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case pl:e.blendFunc(e.ONE,e.ONE);break;case ml:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case gl:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",U);break}else switch(U){case $s:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case pl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case ml:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gl:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",U);break}R=null,v=null,T=null,A=null,_.set(0,0,0),S=0,m=U,z=it}return}if(ye=ye||ce,ne=ne||K,pe=pe||le,ce!==E||ye!==M)e.blendEquationSeparate(ke[ce],ke[ye]),E=ce,M=ye;if(K!==R||le!==v||ne!==T||pe!==A)e.blendFuncSeparate(Ze[K],Ze[le],Ze[ne],Ze[pe]),R=K,v=le,T=ne,A=pe;if(Be.equals(_)===!1||mt!==S)e.blendColor(Be.r,Be.g,Be.b,mt),_.copy(Be),S=mt;m=U,z=!1}function Ye(U,ce){U.side===Pn?xe(e.CULL_FACE):se(e.CULL_FACE);let K=U.side===Qt;if(ce)K=!K;Zt(K),U.blending===$s&&U.transparent===!1?st(ii):st(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),s.setMask(U.colorWrite);let le=U.stencilWrite;if(a.setTest(le),le)a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass);Dt(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(U){if(P!==U){if(U)e.frontFace(e.CW);else e.frontFace(e.CCW);P=U}}function yt(U){if(U!==pd){if(se(e.CULL_FACE),U!==F)if(U===dl)e.cullFace(e.BACK);else if(U===md)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);F=U}function cn(U){if(U!==ee){if(C)e.lineWidth(U);ee=U}}function Dt(U,ce,K){if(U){if(se(e.POLYGON_OFFSET_FILL),I!==ce||H!==K){if(I=ce,H=K,o.getReversed())ce=-ce;e.polygonOffset(ce,K)}}else xe(e.POLYGON_OFFSET_FILL)}function Ot(U){if(U)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function N(U){if(U===void 0)U=e.TEXTURE0+q-1;if(Y!==U)e.activeTexture(U),Y=U}function ln(U,ce,K){if(K===void 0)if(Y===null)K=e.TEXTURE0+q-1;else K=Y;let le=Q[K];if(le===void 0)le={type:void 0,texture:void 0},Q[K]=le;if(le.type!==U||le.texture!==ce){if(Y!==K)e.activeTexture(K),Y=K;e.bindTexture(U,ce||re[U]),le.type=U,le.texture=ce}}function nt(){let U=Q[Y];if(U!==void 0&&U.type!==void 0)e.bindTexture(U.type,null),U.type=void 0,U.texture=void 0}function wt(){try{e.compressedTexImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function y(){try{e.texSubImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function L(){try{e.texSubImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function ae(){try{e.texStorage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function he(){try{e.texStorage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function j(){try{e.texImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function te(){try{e.texImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function _e(U){if(f[U]!==void 0)return f[U];else return e.getParameter(U)}function Pe(U,ce){if(f[U]!==ce)e.pixelStorei(U,ce),f[U]=ce}function fe(U){if(Fe.equals(U)===!1)e.scissor(U.x,U.y,U.z,U.w),Fe.copy(U)}function oe(U){if(Me.equals(U)===!1)e.viewport(U.x,U.y,U.z,U.w),Me.copy(U)}function Le(U,ce){let K=l.get(ce);if(K===void 0)K=new WeakMap,l.set(ce,K);let le=K.get(U);if(le===void 0)le=e.getUniformBlockIndex(ce,U.name),K.set(U,le)}function De(U,ce){let le=l.get(ce).get(U);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,U.__bindingPointIndex),c.set(ce,le)}function Qe(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Y=null,Q={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Oe(0,0,0),S=0,z=!1,P=null,F=null,ee=null,I=null,H=null,Fe.set(0,0,e.canvas.width,e.canvas.height),Me.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:we,drawBuffers:Ee,useProgram:xt,setBlending:st,setMaterial:Ye,setFlipSided:Zt,setCullFace:yt,setLineWidth:cn,setPolygonOffset:Dt,setScissorTest:Ot,activeTexture:N,bindTexture:ln,unbindTexture:nt,compressedTexImage2D:wt,compressedTexImage3D:w,texImage2D:j,texImage3D:te,pixelStorei:Pe,getParameter:_e,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:he,texSubImage2D:y,texSubImage3D:L,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:fe,viewport:oe,reset:Qe}}function rT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,y){return g?new OffscreenCanvas(w,y):ns("canvas")}function p(w,y,L){let V=1,ie=wt(w);if(ie.width>L||ie.height>L)V=L/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(V*ie.width),he=Math.floor(V*ie.height);if(h===void 0)h=x(ae,he);let j=y?x(ae,he):h;return j.width=ae,j.height=he,j.getContext("2d").drawImage(w,0,0,ae,he),Ie("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),j}else{if("data"in w)Ie("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(w,y,L,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let he;if(V){if(he=t.get("EXT_texture_norm16"),!he)Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let j=y;if(y===e.RED){if(L===e.FLOAT)j=e.R32F;if(L===e.HALF_FLOAT)j=e.R16F;if(L===e.UNSIGNED_BYTE)j=e.R8;if(L===e.UNSIGNED_SHORT&&he)j=he.R16_EXT;if(L===e.SHORT&&he)j=he.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.R8UI;if(L===e.UNSIGNED_SHORT)j=e.R16UI;if(L===e.UNSIGNED_INT)j=e.R32UI;if(L===e.BYTE)j=e.R8I;if(L===e.SHORT)j=e.R16I;if(L===e.INT)j=e.R32I}if(y===e.RG){if(L===e.FLOAT)j=e.RG32F;if(L===e.HALF_FLOAT)j=e.RG16F;if(L===e.UNSIGNED_BYTE)j=e.RG8;if(L===e.UNSIGNED_SHORT&&he)j=he.RG16_EXT;if(L===e.SHORT&&he)j=he.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RG8UI;if(L===e.UNSIGNED_SHORT)j=e.RG16UI;if(L===e.UNSIGNED_INT)j=e.RG32UI;if(L===e.BYTE)j=e.RG8I;if(L===e.SHORT)j=e.RG16I;if(L===e.INT)j=e.RG32I}if(y===e.RGB_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RGB8UI;if(L===e.UNSIGNED_SHORT)j=e.RGB16UI;if(L===e.UNSIGNED_INT)j=e.RGB32UI;if(L===e.BYTE)j=e.RGB8I;if(L===e.SHORT)j=e.RGB16I;if(L===e.INT)j=e.RGB32I}if(y===e.RGBA_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RGBA8UI;if(L===e.UNSIGNED_SHORT)j=e.RGBA16UI;if(L===e.UNSIGNED_INT)j=e.RGBA32UI;if(L===e.BYTE)j=e.RGBA8I;if(L===e.SHORT)j=e.RGBA16I;if(L===e.INT)j=e.RGBA32I}if(y===e.RGB){if(L===e.UNSIGNED_SHORT&&he)j=he.RGB16_EXT;if(L===e.SHORT&&he)j=he.RGB16_SNORM_EXT;if(L===e.UNSIGNED_INT_5_9_9_9_REV)j=e.RGB9_E5;if(L===e.UNSIGNED_INT_10F_11F_11F_REV)j=e.R11F_G11F_B10F}if(y===e.RGBA){let te=ae?lu:$e.getTransfer(ie);if(L===e.FLOAT)j=e.RGBA32F;if(L===e.HALF_FLOAT)j=e.RGBA16F;if(L===e.UNSIGNED_BYTE)j=te===dt?e.SRGB8_ALPHA8:e.RGBA8;if(L===e.UNSIGNED_SHORT&&he)j=he.RGBA16_EXT;if(L===e.SHORT&&he)j=he.RGBA16_SNORM_EXT;if(L===e.UNSIGNED_SHORT_4_4_4_4)j=e.RGBA4;if(L===e.UNSIGNED_SHORT_5_5_5_1)j=e.RGB5_A1}if(j===e.R16F||j===e.R32F||j===e.RG16F||j===e.RG32F||j===e.RGBA16F||j===e.RGBA32F)t.get("EXT_color_buffer_float");return j}function M(w,y){let L;if(w){if(y===null||y===ji||y===hs)L=e.DEPTH24_STENCIL8;else if(y===Ri)L=e.DEPTH32F_STENCIL8;else if(y===Xs)L=e.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===ji||y===hs)L=e.DEPTH_COMPONENT24;else if(y===Ri)L=e.DEPTH_COMPONENT32F;else if(y===Xs)L=e.DEPTH_COMPONENT16;return L}function T(w,y){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Vn&&w.minFilter!==$t)return Math.log2(Math.max(y.width,y.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return y.mipmaps.length;else return 1}function A(w){let y=w.target;if(y.removeEventListener("dispose",A),S(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)f.delete(y)}function _(w){let y=w.target;y.removeEventListener("dispose",_),P(y)}function S(w){let y=i.get(w);if(y.__webglInit===void 0)return;let L=w.source,V=d.get(L);if(V){let ie=V[y.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(w);if(Object.keys(V).length===0)d.delete(L)}i.remove(w)}function z(w){let y=i.get(w);e.deleteTexture(y.__webglTexture);let L=w.source,V=d.get(L);delete V[y.__cacheKey],o.memory.textures--}function P(w){let y=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(y.__webglFramebuffer[V]))for(let ie=0;ie<y.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(y.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(y.__webglFramebuffer[V]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[V])}else{if(Array.isArray(y.__webglFramebuffer))for(let V=0;V<y.__webglFramebuffer.length;V++)e.deleteFramebuffer(y.__webglFramebuffer[V]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let V=0;V<y.__webglColorRenderbuffer.length;V++)if(y.__webglColorRenderbuffer[V])e.deleteRenderbuffer(y.__webglColorRenderbuffer[V])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let L=w.textures;for(let V=0,ie=L.length;V<ie;V++){let ae=i.get(L[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(L[V])}i.remove(w)}let F=0;function ee(){F=0}function I(){return F}function H(w){F=w}function q(){let w=F;if(w>=r.maxTextures)Ie("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return F+=1,w}function C(w){let y=[];return y.push(w.wrapS),y.push(w.wrapT),y.push(w.wrapR||0),y.push(w.magFilter),y.push(w.minFilter),y.push(w.anisotropy),y.push(w.internalFormat),y.push(w.format),y.push(w.type),y.push(w.generateMipmaps),y.push(w.premultiplyAlpha),y.push(w.flipY),y.push(w.unpackAlignment),y.push(w.colorSpace),y.join()}function X(w,y){let L=i.get(w);if(w.isVideoTexture)ln(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&L.__version!==w.version){let V=w.image;if(V===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(L,w,y);return}}else if(w.isExternalTexture)L.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,L.__webglTexture,e.TEXTURE0+y)}function k(w,y){let L=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&L.__version!==w.version){xe(L,w,y);return}else if(w.isExternalTexture)L.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,L.__webglTexture,e.TEXTURE0+y)}function Y(w,y){let L=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&L.__version!==w.version){xe(L,w,y);return}n.bindTexture(e.TEXTURE_3D,L.__webglTexture,e.TEXTURE0+y)}function Q(w,y){let L=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&L.__version!==w.version){we(L,w,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,L.__webglTexture,e.TEXTURE0+y)}let Se={[cs]:e.REPEAT,[ls]:e.CLAMP_TO_EDGE,[Sa]:e.MIRRORED_REPEAT},ue={[Vn]:e.NEAREST,[Ma]:e.NEAREST_MIPMAP_NEAREST,[br]:e.NEAREST_MIPMAP_LINEAR,[$t]:e.LINEAR,[us]:e.LINEAR_MIPMAP_NEAREST,[ri]:e.LINEAR_MIPMAP_LINEAR},Fe={[tp]:e.NEVER,[op]:e.ALWAYS,[np]:e.LESS,[Ia]:e.LEQUAL,[ip]:e.EQUAL,[La]:e.GEQUAL,[rp]:e.GREATER,[sp]:e.NOTEQUAL};function Me(w,y){if(y.type===Ri&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===$t||y.magFilter===us||y.magFilter===br||y.magFilter===ri||y.minFilter===$t||y.minFilter===us||y.minFilter===br||y.minFilter===ri))Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Se[y.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Se[y.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Se[y.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ue[y.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ue[y.minFilter]),y.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,Fe[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Vn)return;if(y.minFilter!==br&&y.minFilter!==ri)return;if(y.type===Ri&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let L=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Z(w,y){let L=!1;if(w.__webglInit===void 0)w.__webglInit=!0,y.addEventListener("dispose",A);let V=y.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=C(y);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,L=!0;ie[ae].usedTimes++;let he=ie[w.__cacheKey];if(he!==void 0){if(ie[w.__cacheKey].usedTimes--,he.usedTimes===0)z(y)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return L}function re(w,y,L){return Math.floor(Math.floor(w/L)/y)}function se(w,y,L,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,L,V,y.data);else{ae.sort((Pe,fe)=>Pe.start-fe.start);let he=0;for(let Pe=1;Pe<ae.length;Pe++){let fe=ae[he],oe=ae[Pe],Le=fe.start+fe.count,De=re(oe.start,y.width,4),Qe=re(fe.start,y.width,4);if(oe.start<=Le+1&&De===Qe&&re(oe.start+oe.count-1,y.width,4)===De)fe.count=Math.max(fe.count,oe.start+oe.count-fe.start);else++he,ae[he]=oe}ae.length=he+1;let j=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Pe=0,fe=ae.length;Pe<fe;Pe++){let oe=ae[Pe],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Qe=Le%y.width,U=Math.floor(Le/y.width),ce=De,K=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Qe),n.pixelStorei(e.UNPACK_SKIP_ROWS,U),n.texSubImage2D(e.TEXTURE_2D,0,Qe,U,ce,1,L,V,y.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,j),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(w,y,L){let V=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,y),ae=y.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+L);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+L),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let K=$e.getPrimaries($e.workingColorSpace),le=y.colorSpace===Er?null:$e.getPrimaries(y.colorSpace),ye=y.colorSpace===Er||K===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let te=p(y.image,!1,r.maxTextureSize);te=nt(y,te);let _e=s.convert(y.format,y.colorSpace),Pe=s.convert(y.type),fe=v(y.internalFormat,_e,Pe,y.normalized,y.colorSpace,y.isVideoTexture);Me(V,y);let oe,Le=y.mipmaps,De=y.isVideoTexture!==!0,Qe=he.__version===void 0||ie===!0,U=ae.dataReady,ce=T(y,te);if(y.isDepthTexture){if(fe=M(y.format===Mr,y.type),Qe)if(De)n.texStorage2D(e.TEXTURE_2D,1,fe,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,_e,Pe,null)}else if(y.isDataTexture)if(Le.length>0){if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,_e,Pe,oe.data);y.generateMipmaps=!1}else if(De){if(Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,te.width,te.height);if(U)se(y,te,_e,Pe)}else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,_e,Pe,te.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(De&&Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,te.depth);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],y.format!==oi)if(_e!==null)if(De){if(U)if(y.layerUpdates.size>0){let ye=Nu(oe.width,oe.height,y.format,y.type);for(let ne of y.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,K,fe,oe.width,oe.height,te.depth,0,oe.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(U)n.texSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,oe.width,oe.height,te.depth,_e,Pe,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,K,fe,oe.width,oe.height,te.depth,0,_e,Pe,oe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],y.format!==oi)if(_e!==null)if(De){if(U)n.compressedTexSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,oe.data);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,_e,Pe,oe.data)}else if(y.isDataArrayTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,fe,te.width,te.height,te.depth);if(U)if(y.layerUpdates.size>0){let K=Nu(te.width,te.height,y.format,y.type);for(let le of y.layerUpdates){let ye=te.data.subarray(le*K/te.data.BYTES_PER_ELEMENT,(le+1)*K/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Pe,ye)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Pe,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,fe,te.width,te.height,te.depth,0,_e,Pe,te.data);else if(y.isData3DTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_3D,ce,fe,te.width,te.height,te.depth);if(U)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Pe,te.data)}else n.texImage3D(e.TEXTURE_3D,0,fe,te.width,te.height,te.depth,0,_e,Pe,te.data);else if(y.isFramebufferTexture){if(Qe)if(De)n.texStorage2D(e.TEXTURE_2D,ce,fe,te.width,te.height);else{let K=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,fe,K,le,0,_e,Pe,null),K>>=1,le>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let K=e.canvas;if(!K.hasAttribute("layoutsubtree"))K.setAttribute("layoutsubtree","true");if(te.parentNode!==K){K.appendChild(te),f.add(y),K.onpaint=(le)=>{let ye=le.changedElements;for(let ne of f)if(ye.includes(ne.image))ne.needsUpdate=!0},K.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Qe){let K=wt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,fe,K.width,K.height)}for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,_e,Pe,oe)}else n.texImage2D(e.TEXTURE_2D,K,fe,_e,Pe,oe);y.generateMipmaps=!1}else if(De){if(Qe){let K=wt(te);n.texStorage2D(e.TEXTURE_2D,ce,fe,K.width,K.height)}if(U)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Pe,te)}else n.texImage2D(e.TEXTURE_2D,0,fe,_e,Pe,te);if(m(y))E(V);if(he.__version=ae.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function we(w,y,L){if(y.image.length!==6)return;let V=Z(w,y),ie=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+L);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+L);let he=$e.getPrimaries($e.workingColorSpace),j=y.colorSpace===Er?null:$e.getPrimaries(y.colorSpace),te=y.colorSpace===Er||he===j?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=y.isCompressedTexture||y.image[0].isCompressedTexture,Pe=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let ne=0;ne<6;ne++){if(!_e&&!Pe)fe[ne]=p(y.image[ne],!0,r.maxCubemapSize);else fe[ne]=Pe?y.image[ne].image:y.image[ne];fe[ne]=nt(y,fe[ne])}let oe=fe[0],Le=s.convert(y.format,y.colorSpace),De=s.convert(y.type),Qe=v(y.internalFormat,Le,De,y.normalized,y.colorSpace),U=y.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,K=ie.dataReady,le=T(y,oe);Me(e.TEXTURE_CUBE_MAP,y);let ye;if(_e){if(U&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=fe[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(y.format!==oi)if(Le!==null)if(U){if(K)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,Qe,Be.width,Be.height,0,Be.data);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,Qe,Be.width,Be.height,0,Le,De,Be.data)}}}else{if(ye=y.mipmaps,U&&ce){if(ye.length>0)le++;let ne=wt(fe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Pe){if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,fe[ne].width,fe[ne].height,Le,De,fe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,fe[ne].width,fe[ne].height,0,Le,De,fe[ne].data);for(let pe=0;pe<ye.length;pe++){let mt=ye[pe].image[ne].image;if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,mt.width,mt.height,Le,De,mt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,Qe,mt.width,mt.height,0,Le,De,mt.data)}}else{if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,fe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,Le,De,fe[ne]);for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Le,De,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,Qe,Le,De,Be.image[ne])}}}if(m(y))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function Ee(w,y,L,V,ie,ae){let he=s.convert(L.format,L.colorSpace),j=s.convert(L.type),te=v(L.internalFormat,he,j,L.normalized,L.colorSpace),_e=i.get(y),Pe=i.get(L);if(Pe.__renderTarget=y,!_e.__hasExternalTextures){let fe=Math.max(1,y.width>>ae),oe=Math.max(1,y.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,fe,oe,y.depth,0,he,j,null);else n.texImage2D(ie,ae,te,fe,oe,0,he,j,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,0,Ot(y));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function xt(w,y,L){if(e.bindRenderbuffer(e.RENDERBUFFER,w),y.depthBuffer){let V=y.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=M(y.stencilBuffer,ie),he=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(N(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else if(L)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,w)}else{let V=y.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],he=s.convert(ae.format,ae.colorSpace),j=s.convert(ae.type),te=v(ae.internalFormat,he,j,ae.normalized,ae.colorSpace);if(N(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else if(L)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,te,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ke(w,y,L){let V=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(y.depthTexture);if(ie.__renderTarget=y,!ie.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,y.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,y.depthTexture);let _e=s.convert(y.depthTexture.format),Pe=s.convert(y.depthTexture.type),fe;if(y.depthTexture.format===Sr)fe=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Mr)fe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,fe,y.width,y.height,0,_e,Pe,null)}}else X(y.depthTexture,0);let ae=ie.__webglTexture,he=Ot(y),j=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+L:e.TEXTURE_2D,te=y.depthTexture.format===Mr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Sr)if(N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,j,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,j,ae,0);else if(y.depthTexture.format===Mr)if(N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,j,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,j,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let y=i.get(w),L=w.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(V){let ie=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),y.__depthDisposeCallback=ie}y.__boundDepthTexture=V}if(w.depthTexture&&!y.__autoAllocateDepthBuffer)if(L)for(let V=0;V<6;V++)ke(y.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ke(y.__webglFramebuffer[0],w,0);else ke(y.__webglFramebuffer,w,0)}else if(L){y.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[V]),y.__webglDepthbuffer[V]===void 0)y.__webglDepthbuffer[V]=e.createRenderbuffer(),xt(y.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),xt(y.__webglDepthbuffer,w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function st(w,y,L){let V=i.get(w);if(y!==void 0)Ee(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(L!==void 0)Ze(w)}function Ye(w){let y=w.texture,L=i.get(w),V=i.get(y);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=y.version,o.memory.textures++}if(ae){L.__webglFramebuffer=[];for(let j=0;j<6;j++)if(y.mipmaps&&y.mipmaps.length>0){L.__webglFramebuffer[j]=[];for(let te=0;te<y.mipmaps.length;te++)L.__webglFramebuffer[j][te]=e.createFramebuffer()}else L.__webglFramebuffer[j]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){L.__webglFramebuffer=[];for(let j=0;j<y.mipmaps.length;j++)L.__webglFramebuffer[j]=e.createFramebuffer()}else L.__webglFramebuffer=e.createFramebuffer();if(he)for(let j=0,te=ie.length;j<te;j++){let _e=i.get(ie[j]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&N(w)===!1){L.__webglMultisampledFramebuffer=e.createFramebuffer(),L.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let j=0;j<ie.length;j++){let te=ie[j];L.__webglColorRenderbuffer[j]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,L.__webglColorRenderbuffer[j]);let _e=s.convert(te.format,te.colorSpace),Pe=s.convert(te.type),fe=v(te.internalFormat,_e,Pe,te.normalized,te.colorSpace,w.isXRRenderTarget===!0),oe=Ot(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,fe,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+j,e.RENDERBUFFER,L.__webglColorRenderbuffer[j])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)L.__webglDepthRenderbuffer=e.createRenderbuffer(),xt(L.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,y);for(let j=0;j<6;j++)if(y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)Ee(L.__webglFramebuffer[j][te],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+j,te);else Ee(L.__webglFramebuffer[j],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+j,0);if(m(y))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let j=0,te=ie.length;j<te;j++){let _e=ie[j],Pe=i.get(_e),fe=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)fe=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(fe,Pe.__webglTexture),Me(fe,_e),Ee(L.__webglFramebuffer,w,_e,e.COLOR_ATTACHMENT0+j,fe,0),m(_e))E(fe)}n.unbindTexture()}else{let j=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)j=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(j,V.__webglTexture),Me(j,y),y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)Ee(L.__webglFramebuffer[te],w,y,e.COLOR_ATTACHMENT0,j,te);else Ee(L.__webglFramebuffer,w,y,e.COLOR_ATTACHMENT0,j,0);if(m(y))E(j);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Zt(w){let y=w.textures;for(let L=0,V=y.length;L<V;L++){let ie=y[L];if(m(ie)){let ae=R(w),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),E(ae),n.unbindTexture()}}}let yt=[],cn=[];function Dt(w){if(w.samples>0){if(N(w)===!1){let{textures:y,width:L,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(w),j=y.length>1;if(j)for(let _e=0;_e<y.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=w.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<y.length;_e++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(j){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Pe=i.get(y[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Pe,0)}if(e.blitFramebuffer(0,0,L,V,0,0,L,V,ie,e.NEAREST),c===!0){if(yt.length=0,cn.length=0,yt.push(e.COLOR_ATTACHMENT0+_e),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)yt.push(ae),cn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,cn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,yt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),j)for(let _e=0;_e<y.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Pe=i.get(y[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Pe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let y=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function Ot(w){return Math.min(r.maxSamples,w.samples)}function N(w){let y=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ln(w){let y=o.render.frame;if(u.get(w)!==y)u.set(w,y),w.update()}function nt(w,y){let{colorSpace:L,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return y;if(L!==gn&&L!==Er)if($e.getTransfer(L)===dt){if(V!==oi||ie!==$n)Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",L);return y}function wt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=q,this.resetTextureUnits=ee,this.getTextureUnits=I,this.setTextureUnits=H,this.setTexture2D=X,this.setTexture2DArray=k,this.setTexture3D=Y,this.setTextureCube=Q,this.rebindTextures=st,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Zt,this.updateMultisampleRenderTarget=Dt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=N,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function sT(e,t){function n(i,r=Er){let s,o=$e.getTransfer(r);if(i===$n)return e.UNSIGNED_BYTE;if(i===El)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Tl)return e.UNSIGNED_SHORT_5_5_5_1;if(i===jd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===Yd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return e.BYTE;if(i===qd)return e.SHORT;if(i===Xs)return e.UNSIGNED_SHORT;if(i===wl)return e.INT;if(i===ji)return e.UNSIGNED_INT;if(i===Ri)return e.FLOAT;if(i===si)return e.HALF_FLOAT;if(i===Kd)return e.ALPHA;if(i===Jd)return e.RGB;if(i===oi)return e.RGBA;if(i===Sr)return e.DEPTH_COMPONENT;if(i===Mr)return e.DEPTH_STENCIL;if(i===Qd)return e.RED;if(i===Al)return e.RED_INTEGER;if(i===wr)return e.RG;if(i===Rl)return e.RG_INTEGER;if(i===Cl)return e.RGBA_INTEGER;if(i===wa||i===Ea||i===Ta||i===Aa)if(o===dt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===wa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Aa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===wa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ea)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Aa)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Pl||i===Il||i===Ll||i===Nl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Pl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Il)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ll)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Nl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Dl||i===Ol||i===Ul||i===Fl||i===zl||i===Ra||i===kl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Dl||i===Ol)return o===dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ul)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Fl)return s.COMPRESSED_R11_EAC;if(i===zl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ra)return s.COMPRESSED_RG11_EAC;if(i===kl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Bl||i===Gl||i===Hl||i===Vl||i===$l||i===Wl||i===Zl||i===Xl||i===ql||i===jl||i===Yl||i===Kl||i===Jl||i===Ql)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Bl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Gl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Hl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Vl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===$l)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Zl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Xl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ql)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===jl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Yl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Jl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ql)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===eu||i===tu||i===nu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===eu)return o===dt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===tu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===iu||i===ru||i===Ca||i===su)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===iu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ca)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===su)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===hs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var oT=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,sT=`
+}`,aT=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4341,11 +4341,11 @@ void main() {
}
-}`;class Kp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ka(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Pn({vertexShader:rT,fragmentShader:sT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new xt(new to(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Jp extends $n{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Kp,p={},m=t.getContextAttributes(),E=null,R=null,v=[],M=[],T=new Ne,A=null,_=null,S=new Ut;S.viewport=new ct;let k=new Ut;k.viewport=new ct;let C=[S,k],U=new Tu,ee=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let re=v[X];if(re===void 0)re=new Xs,v[X]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(X){let re=v[X];if(re===void 0)re=new Xs,v[X]=re;return re.getGripSpace()},this.getHand=function(X){let re=v[X];if(re===void 0)re=new Xs,v[X]=re;return re.getHandSpace()};function V(X){let re=M.indexOf(X.inputSource);if(re===-1)return;let se=v[re];if(se!==void 0)se.update(X.inputSource,X.frame,c||s),se.dispatchEvent({type:X.type,data:X.inputSource})}function j(){i.removeEventListener("select",V),i.removeEventListener("selectstart",V),i.removeEventListener("selectend",V),i.removeEventListener("squeeze",V),i.removeEventListener("squeezestart",V),i.removeEventListener("squeezeend",V),i.removeEventListener("end",j),i.removeEventListener("inputsourceschange",z);for(let X=0;X<v.length;X++){let re=M[X];if(re===null)continue;M[X]=null,v[X].disconnect(re)}ee=null,P=null,x.reset();for(let X in p)delete p[X];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,ye.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let X=_.camera;X.fov=_.fov,X.zoom=_.zoom,X.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){if(r=X,n.isPresenting===!0)Pe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){if(o=X,n.isPresenting===!0)Pe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",V),i.addEventListener("selectstart",V),i.addEventListener("selectend",V),i.addEventListener("squeeze",V),i.addEventListener("squeezestart",V),i.addEventListener("squeezeend",V),i.addEventListener("end",j),i.addEventListener("inputsourceschange",z),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:oi,type:Vn,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,Te=null,Ie=null;if(m.depth)Ie=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Sr:br,Te=m.stencil?ls:qi;let _e={colorFormat:t.RGBA8,depthFormat:Ie,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(_e),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:oi,type:Vn,depthTexture:new Er(f.textureWidth,f.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),ye.setContext(i),ye.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function z(X){for(let re=0;re<X.removed.length;re++){let se=X.removed[re],Te=M.indexOf(se);if(Te>=0)M[Te]=null,v[Te].disconnect(se)}for(let re=0;re<X.added.length;re++){let se=X.added[re],Te=M.indexOf(se);if(Te===-1){for(let _e=0;_e<v.length;_e++)if(_e>=M.length){M.push(se),Te=_e;break}else if(M[_e]===null){M[_e]=se,Te=_e;break}if(Te===-1)break}let Ie=v[Te];if(Ie)Ie.connect(se)}}let H=new D,F=new D;function q(X,re,se){H.setFromMatrixPosition(re.matrixWorld),F.setFromMatrixPosition(se.matrixWorld);let Te=H.distanceTo(F),Ie=re.projectionMatrix.elements,_e=se.projectionMatrix.elements,Qe=Ie[14]/(Ie[10]-1),ze=Ie[14]/(Ie[10]+1),Ze=(Ie[9]+1)/Ie[5],ot=(Ie[9]-1)/Ie[5],Ye=(Ie[8]-1)/Ie[0],Zt=(_e[8]+1)/_e[0],yt=Qe*Ye,cn=Qe*Zt,Dt=Te/(-Ye+Zt),Ot=Dt*-Ye;if(re.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Ot),X.translateZ(Dt),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),Ie[10]===-1)X.projectionMatrix.copy(re.projectionMatrix),X.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let L=Qe+Dt,ln=ze+Dt,it=yt-Ot,wt=cn+(Te-Ot),w=Ze*ze/ln*L,y=ot*ze/ln*L;X.projectionMatrix.makePerspective(it,wt,w,y,L,ln),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function K(X,re){if(re===null)X.matrixWorld.copy(X.matrix);else X.matrixWorld.multiplyMatrices(re.matrixWorld,X.matrix);X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let{near:re,far:se}=X;if(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(U.near=k.near=S.near=re,U.far=k.far=S.far=se,ee!==U.near||P!==U.far)i.updateRenderState({depthNear:U.near,depthFar:U.far}),ee=U.near,P=U.far;U.layers.mask=X.layers.mask|6,S.layers.mask=U.layers.mask&-5,k.layers.mask=U.layers.mask&-3;let Te=X.parent,Ie=U.cameras;K(U,Te);for(let _e=0;_e<Ie.length;_e++)K(Ie[_e],Te);if(Ie.length===2)q(U,S,k);else U.projectionMatrix.copy(S.projectionMatrix);if(_===null&&X.isPerspectiveCamera)_={camera:X,fov:X.fov,zoom:X.zoom};xe(X,U,Te)};function xe(X,re,se){if(se===null)X.matrix.copy(re.matrixWorld);else X.matrix.copy(se.matrixWorld),X.matrix.invert(),X.matrix.multiply(re.matrixWorld);if(X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(re.projectionMatrix),X.projectionMatrixInverse.copy(re.projectionMatrixInverse),X.isPerspectiveCamera)X.fov=xr*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1}this.getCamera=function(){return U},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(X){if(a=X,f!==null)f.fixedFoveation=X;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=X},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(U)},this.getCameraTexture=function(X){return p[X]};let ce=null;function De(X,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let Te=!1;if(se.length!==U.cameras.length)U.cameras.length=0,Te=!0;for(let ze=0;ze<se.length;ze++){let Ze=se[ze],ot=null;if(h!==null)ot=h.getViewport(Ze);else{let Zt=u.getViewSubImage(f,Ze);if(ot=Zt.viewport,ze===0)e.setRenderTargetTextures(R,Zt.colorTexture,Zt.depthStencilTexture),e.setRenderTarget(R)}let Ye=C[ze];if(Ye===void 0)Ye=new Ut,Ye.layers.enable(ze),Ye.viewport=new ct,C[ze]=Ye;if(Ye.matrix.fromArray(Ze.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Ze.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(ot.x,ot.y,ot.width,ot.height),ze===0)U.matrix.copy(Ye.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);if(Te===!0)U.cameras.push(Ye)}let Ie=i.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ze=u.getDepthInformation(se[0]);if(ze&&ze.isValid&&ze.texture)x.init(ze,i.renderState)}if(Ie&&Ie.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ze=0;ze<se.length;ze++){let Ze=se[ze].camera;if(Ze){let ot=p[Ze];if(!ot)ot=new ka,p[Ze]=ot;let Ye=u.getCameraImage(Ze);ot.sourceTexture=Ye}}}}for(let se=0;se<v.length;se++){let Te=M[se],Ie=v[se];if(Te!==null&&Ie!==void 0)Ie.update(Te,re,c||s)}if(ce)ce(X,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let ye=new Bp;ye.setAnimationLoop(De),this.setAnimationLoop=function(X){ce=X},this.dispose=function(){}}}var oT=new Ge,Qp=new ke;Qp.set(-1,0,0,0,1,0,0,0,1);function aT(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,gu(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,v){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,v)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Qt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Qt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:v}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(oT.makeRotationFromEuler(v)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Qp);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Qt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function cT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){let T=M.program;i.uniformBlockBinding(v,T)}function l(v,M){let T=r[v.id];if(T===void 0)p(v),T=u(v),r[v.id]=T,v.addEventListener("dispose",E);let A=M.program;i.updateUBOMapping(v,A);let _=t.render.frame;if(s[v.id]!==_)h(v),s[v.id]=_}function u(v){let M=f();v.__bindingPointIndex=M;let T=e.createBuffer(),{__size:A,usage:_}=v;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,M,T),T}function f(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Fe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let M=r[v.id],{uniforms:T,__cache:A}=v;e.bindBuffer(e.UNIFORM_BUFFER,M);for(let _=0,S=T.length;_<S;_++){let k=T[_];if(Array.isArray(k))for(let C=0,U=k.length;C<U;C++)d(k[C],_,C,A);else d(k,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(v,M,T,A){if(x(v,M,T,A)===!0){let{__offset:_,value:S}=v;if(Array.isArray(S)){let k=0;for(let C=0;C<S.length;C++){let U=S[C],ee=m(U);if(g(U,v.__data,k),typeof U!=="number"&&typeof U!=="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U))k+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else g(S,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,v.__data)}}function g(v,M,T){if(typeof v==="number"||typeof v==="boolean")M[0]=v;else if(v.isMatrix3)M[0]=v.elements[0],M[1]=v.elements[1],M[2]=v.elements[2],M[3]=0,M[4]=v.elements[3],M[5]=v.elements[4],M[6]=v.elements[5],M[7]=0,M[8]=v.elements[6],M[9]=v.elements[7],M[10]=v.elements[8],M[11]=0;else if(ArrayBuffer.isView(v))M.set(new v.constructor(v.buffer,v.byteOffset,M.length));else v.toArray(M,T)}function x(v,M,T,A){let _=v.value,S=M+"_"+T;if(A[S]===void 0){if(typeof _==="number"||typeof _==="boolean")A[S]=_;else if(ArrayBuffer.isView(_))A[S]=_.slice();else A[S]=_.clone();return!0}else{let k=A[S];if(typeof _==="number"||typeof _==="boolean"){if(k!==_)return A[S]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(k.equals(_)===!1)return k.copy(_),!0}return!1}function p(v){let M=v.uniforms,T=0,A=16;for(let S=0,k=M.length;S<k;S++){let C=Array.isArray(M[S])?M[S]:[M[S]];for(let U=0,ee=C.length;U<ee;U++){let P=C[U],V=Array.isArray(P.value)?P.value:[P.value];for(let j=0,z=V.length;j<z;j++){let H=V[j],F=m(H),q=T%A,K=q%F.boundary,xe=q+K;if(T+=K,xe!==0&&A-xe<F.storage)T+=A-xe;P.__data=new Float32Array(F.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=T,T+=F.storage}}}let _=T%A;if(_>0)T+=A-_;return v.__size=T,v.__cache={},this}function m(v){let M={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")M.boundary=4,M.storage=4;else if(v.isVector2)M.boundary=8,M.storage=8;else if(v.isVector3||v.isColor)M.boundary=16,M.storage=12;else if(v.isVector4)M.boundary=16,M.storage=16;else if(v.isMatrix3)M.boundary=48,M.storage=48;else if(v.isMatrix4)M.boundary=64,M.storage=64;else if(v.isTexture)Pe("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))M.boundary=16,M.storage=v.byteLength;else Pe("WebGLRenderer: Unsupported uniform value type.",v);return M}function E(v){let M=v.target;M.removeEventListener("dispose",E);let T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[M.id]),delete r[M.id],delete s[M.id]}function R(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var lT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ci=null;function uT(){if(ci===null)ci=new Ys(lT,16,16,Mr,si),ci.name="DFG_LUT",ci.minFilter=$t,ci.magFilter=$t,ci.wrapS=as,ci.wrapT=as,ci.generateMipmaps=!1,ci.needsUpdate=!0;return ci}class Hu{constructor(e={}){let{canvas:t=op(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=Vn}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Rl,Al,Tl]),p=new Set([Vn,qi,Vs,ls,wl,El]),m=new Uint32Array(4),E=new Int32Array(4),R=new D,v=null,M=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Gn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,k=!1,C=null,U=null,ee=null,P=null;this._outputColorSpace=ji;let V=0,j=0,z=null,H=-1,F=null,q=new ct,K=new ct,xe=null,ce=new Ue(0),De=0,{width:ye,height:X}=t,re=1,se=null,Te=null,Ie=new ct(0,0,ye,X),_e=new ct(0,0,ye,X),Qe=!1,ze=new Js,Ze=!1,ot=!1,Ye=new Ge,Zt=new D,yt=new ct,cn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Dt=!1;function Ot(){return z===null?re:1}let L=n;function ln(b,N){return t.getContext(b,N)}let it,wt,w,y,I,W,ie,ae,he,Y,te,ve,Ce,fe,oe,Le,Oe,et,O,le,J,ue,be;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${fd}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",gt,!1),t.addEventListener("webglcontextcreationerror",rt,!1),L===null){if(L=ln("webgl2",b),L===null)if(ln("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",gt,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Fe("WebGLRenderer: "+b.message),b}function ne(){if(it=new _w(L),it.init(),J=new iT(L,it),wt=new aw(L,it,e,J),w=new tT(L,it),wt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);U=L.createFramebuffer(),ee=L.createFramebuffer(),P=L.createFramebuffer(),y=new vw(L),I=new GE,W=new nT(L,it,w,I,wt,J,y),ie=new gw(S),ae=new Sb(L),ue=new sw(L,ae),he=new xw(L,ae,y,ue),Y=new Sw(L,he,ae,ue,y),et=new bw(L,wt,W),oe=new cw(I),te=new BE(S,ie,it,wt,ue,oe),ve=new aT(S,I),Ce=new VE,fe=new jE(it),Oe=new rw(S,ie,w,Y,d,a),Le=new eT(S,Y,wt),be=new cT(L,y,wt,w),O=new ow(L,it,y),le=new yw(L,it,y),y.programs=te.programs,S.capabilities=wt,S.extensions=it,S.properties=I,S.renderLists=Ce,S.shadowMap=Le,S.state=w,S.info=y}if(g!==Vn)_=new ww(g,t.width,t.height,o,i,r);let pe=new Jp(S,L);this.xr=pe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let b=it.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=it.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(ye,X,!1)},this.getSize=function(b){return b.set(ye,X)},this.setSize=function(b,N,Z=!0){if(pe.isPresenting){Pe("WebGLRenderer: Can't change size while VR device is presenting.");return}if(ye=b,X=N,t.width=Math.floor(b*re),t.height=Math.floor(N*re),Z===!0)t.style.width=b+"px",t.style.height=N+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,b,N)},this.getDrawingBufferSize=function(b){return b.set(ye*re,X*re).floor()},this.setDrawingBufferSize=function(b,N,Z){ye=b,X=N,re=Z,t.width=Math.floor(b*Z),t.height=Math.floor(N*Z),this.setViewport(0,0,b,N)},this.setEffects=function(b){if(g===Vn){Fe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let N=0;N<b.length;N++)if(b[N].isOutputPass===!0){Pe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ie)},this.setViewport=function(b,N,Z,B){if(b.isVector4)Ie.set(b.x,b.y,b.z,b.w);else Ie.set(b,N,Z,B);w.viewport(q.copy(Ie).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(_e)},this.setScissor=function(b,N,Z,B){if(b.isVector4)_e.set(b.x,b.y,b.z,b.w);else _e.set(b,N,Z,B);w.scissor(K.copy(_e).multiplyScalar(re).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(b){w.setScissorTest(Qe=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){Te=b},this.getClearColor=function(b){return b.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(b=!0,N=!0,Z=!0){let B=0;if(b){let G=!1;if(z!==null){let ge=z.texture.format;G=x.has(ge)}if(G){let ge=z.texture.type,Me=p.has(ge),me=Oe.getClearColor(),we=Oe.getClearAlpha(),{r:Ae,g:He,b:qe}=me;if(Me)m[0]=Ae,m[1]=He,m[2]=qe,m[3]=we,L.clearBufferuiv(L.COLOR,0,m);else E[0]=Ae,E[1]=He,E[2]=qe,E[3]=we,L.clearBufferiv(L.COLOR,0,E)}else B|=L.COLOR_BUFFER_BIT}if(N)B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(Z)B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",gt,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Oe.dispose(),Ce.dispose(),fe.dispose(),I.dispose(),ie.dispose(),Y.dispose(),ue.dispose(),be.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",vf),pe.removeEventListener("sessionend",bf),fr.stop()};function Be(b){b.preventDefault(),zs("WebGLRenderer: Context Lost."),k=!0}function gt(){zs("WebGLRenderer: Context Restored."),k=!1;let b=y.autoReset,N=Le.enabled,Z=Le.autoUpdate,B=Le.needsUpdate,G=Le.type;ne(),y.autoReset=b,Le.enabled=N,Le.autoUpdate=Z,Le.needsUpdate=B,Le.type=G}function rt(b){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Kn(b){let N=b.target;N.removeEventListener("dispose",Kn),yi(N)}function yi(b){fv(b),I.remove(b)}function fv(b){let N=I.get(b).programs;if(N!==void 0){if(N.forEach(function(Z){te.releaseProgram(Z)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,N,Z,B,G,ge){if(N===null)N=cn;let Me=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=mv(b,N,Z,B,G);w.setMaterial(B,Me);let we=Z.index,Ae=1;if(B.wireframe===!0){if(we=he.getWireframeAttribute(Z),we===void 0)return;Ae=2}let He=Z.drawRange,qe=Z.attributes.position,Ee=He.start*Ae,st=(He.start+He.count)*Ae;if(ge!==null)Ee=Math.max(Ee,ge.start*Ae),st=Math.min(st,(ge.start+ge.count)*Ae);if(we!==null)Ee=Math.max(Ee,0),st=Math.min(st,we.count);else if(qe!==void 0&&qe!==null)Ee=Math.max(Ee,0),st=Math.min(st,qe.count);let Lt=st-Ee;if(Lt<0||Lt===1/0)return;ue.setup(G,B,me,Z,we);let vt,dt=O;if(we!==null)vt=ae.get(we),dt=le,dt.setIndex(vt);if(G.isMesh)if(B.wireframe===!0)w.setLineWidth(B.wireframeLinewidth*Ot()),dt.setMode(L.LINES);else dt.setMode(L.TRIANGLES);else if(G.isLine){let Yt=B.linewidth;if(Yt===void 0)Yt=1;if(w.setLineWidth(Yt*Ot()),G.isLineSegments)dt.setMode(L.LINES);else if(G.isLineLoop)dt.setMode(L.LINE_LOOP);else dt.setMode(L.LINE_STRIP)}else if(G.isPoints)dt.setMode(L.POINTS);else if(G.isSprite)dt.setMode(L.TRIANGLES);if(G.isBatchedMesh)if(!it.get("WEBGL_multi_draw")){let{_multiDrawStarts:Yt,_multiDrawCounts:Se,_multiDrawCount:rn}=G,Ke=we?ae.get(we).bytesPerElement:1,En=I.get(B).currentProgram.getUniforms();for(let Jn=0;Jn<rn;Jn++)En.setValue(L,"_gl_DrawID",Jn),dt.render(Yt[Jn]/Ke,Se[Jn])}else dt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)dt.renderInstances(Ee,Lt,G.count);else if(Z.isInstancedBufferGeometry){let Yt=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Se=Math.min(Z.instanceCount,Yt);dt.renderInstances(Ee,Lt,Se)}else dt.render(Ee,Lt)};function yf(b,N,Z,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ze===!0)oe.setState(b,Z,!1);if(b.transparent===!0&&b.side===Cn&&b.forceSinglePass===!1)b.side=Qt,b.needsUpdate=!0,Vo(b,N,B),b.side=Xi,b.needsUpdate=!0,Vo(b,N,B),b.side=Cn;else Vo(b,N,B)}this.compile=function(b,N,Z=null){if(Z===null)Z=b;if(C!==null)C.renderStart(b,N,Z);if(M=fe.get(Z),M.init(N),A.push(M),Z.traverseVisible(function(G){if(G.isLight&&G.layers.test(N.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}}),b!==Z)b.traverseVisible(function(G){if(G.isLight&&G.layers.test(N.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}});if(M.setupLights(),C!==null)C.updateLights(M.state.lightsArray);if(ot=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,ot),Ze===!0)oe.setGlobalState(this.clippingPlanes,N);if(C!==null)Le.render(M.state.shadowsArray,Z,N);let B=new Set;if(b.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let ge=G.material;if(ge)if(Array.isArray(ge))for(let Me=0;Me<ge.length;Me++){let me=ge[Me];yf(me,Z,N,G),B.add(me)}else yf(ge,Z,N,G),B.add(ge)}),M=A.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,N,Z=null){let B=this.compile(b,N,Z);return new Promise((G)=>{function ge(){if(B.forEach(function(Me){let we=I.get(Me).currentProgram;if(we===void 0||we.isReady())B.delete(Me)}),B.size===0){G(b);return}setTimeout(ge,10)}if(it.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let kc=null;function dv(b){if(kc)kc(b)}function vf(){fr.stop()}function bf(){fr.start()}let fr=new Bp;if(fr.setAnimationLoop(dv),typeof self<"u")fr.setContext(self);this.setAnimationLoop=function(b){kc=b,pe.setAnimationLoop(b),b===null?fr.stop():fr.start()},pe.addEventListener("sessionstart",vf),pe.addEventListener("sessionend",bf),this.render=function(b,N){if(N!==void 0&&N.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(C!==null)C.renderStart(b,N);let Z=pe.enabled===!0&&pe.isPresenting===!0,B=_!==null&&(z===null||Z)&&_.begin(S,z);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(N.parent===null&&N.matrixWorldAutoUpdate===!0)N.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(N);N=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(S,b,N,z);if(M=fe.get(b,A.length),M.init(N),M.state.textureUnits=W.getTextureUnits(),A.push(M),Ye.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ze.setFromProjectionMatrix(Ye,uu,N.reversedDepth),ot=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,ot),v=Ce.get(b,T.length),v.init(),T.push(v),pe.enabled===!0&&pe.isPresenting===!0){let Me=S.xr.getDepthSensingMesh();if(Me!==null)Bc(Me,N,-1/0,S.sortObjects)}if(Bc(b,N,0,S.sortObjects),v.finish(),C!==null)C.updateLights(M.state.lightsArray);if(S.sortObjects===!0)v.sort(se,Te);if(Dt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,Dt)Oe.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let G=M.state.shadowsArray;if(Le.render(G,b,N),Ze===!0)oe.endShadows();if((B&&_.hasRenderPass())===!1){let Me=v.opaque,me=v.transmissive;if(M.setupLights(),N.isArrayCamera){let we=N.cameras;if(me.length>0)for(let Ae=0,He=we.length;Ae<He;Ae++){let qe=we[Ae];Mf(Me,me,b,qe)}if(Dt)Oe.render(b);for(let Ae=0,He=we.length;Ae<He;Ae++){let qe=we[Ae];Sf(v,b,qe,qe.viewport)}}else{if(me.length>0)Mf(Me,me,b,N);if(Dt)Oe.render(b);Sf(v,b,N)}}if(z!==null&&j===0)W.updateMultisampleRenderTarget(z),W.updateRenderTargetMipmap(z);if(B)_.end(S);if(b.isScene===!0)b.onAfterRender(S,b,N);if(ue.resetDefaultState(),H=-1,F=null,A.pop(),A.length>0){if(M=A[A.length-1],W.setTextureUnits(M.state.textureUnits),Ze===!0)oe.setGlobalState(S.clippingPlanes,M.state.camera)}else M=null;if(T.pop(),T.length>0)v=T[T.length-1];else v=null;if(C!==null)C.renderEnd()};function Bc(b,N,Z,B){if(b.visible===!1)return;if(b.layers.test(N.layers)){if(b.isGroup)Z=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(N)}else if(b.isLightProbeGrid)M.pushLightProbeGrid(b);else if(b.isLight){if(M.pushLight(b),b.castShadow)M.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(ze)){if(B)yt.setFromMatrixPosition(b.matrixWorld).applyMatrix4(Ye);let Me=Y.update(b),me=b.material;if(me.visible)v.push(b,Me,me,Z,yt.z,null,N)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(ze)){let Me=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();yt.copy(b.boundingSphere.center)}else{if(Me.boundingSphere===null)Me.computeBoundingSphere();yt.copy(Me.boundingSphere.center)}yt.applyMatrix4(b.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(me)){let we=Me.groups;for(let Ae=0,He=we.length;Ae<He;Ae++){let qe=we[Ae],Ee=me[qe.materialIndex];if(Ee&&Ee.visible)v.push(b,Me,Ee,Z,yt.z,qe,N)}}else if(me.visible)v.push(b,Me,me,Z,yt.z,null,N)}}}let ge=b.children;for(let Me=0,me=ge.length;Me<me;Me++)Bc(ge[Me],N,Z,B)}function Sf(b,N,Z,B){let{opaque:G,transmissive:ge,transparent:Me}=b;if(M.setupLightsView(Z),Ze===!0)oe.setGlobalState(S.clippingPlanes,Z);if(B)w.viewport(q.copy(B));if(G.length>0)Ho(G,N,Z);if(ge.length>0)Ho(ge,N,Z);if(Me.length>0)Ho(Me,N,Z);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function Mf(b,N,Z,B){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Ee=it.has("EXT_color_buffer_half_float")||it.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new _n(1,1,{generateMipmaps:!0,type:Ee?si:Vn,minFilter:ri,samples:Math.max(4,wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let ge=M.state.transmissionRenderTarget[B.id],Me=B.viewport||q;ge.setSize(Me.z*S.transmissionResolutionScale,Me.w*S.transmissionResolutionScale);let me=S.getRenderTarget(),we=S.getActiveCubeFace(),Ae=S.getActiveMipmapLevel();if(S.setRenderTarget(ge),S.getClearColor(ce),De=S.getClearAlpha(),De<1)S.setClearColor(16777215,0.5);if(S.clear(),Dt)Oe.render(Z);let He=S.toneMapping;S.toneMapping=Gn;let qe=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(M.setupLightsView(B),Ze===!0)oe.setGlobalState(S.clippingPlanes,B);if(Ho(b,Z,B),W.updateMultisampleRenderTarget(ge),W.updateRenderTargetMipmap(ge),it.has("WEBGL_multisampled_render_to_texture")===!1){let Ee=!1;for(let st=0,Lt=N.length;st<Lt;st++){let vt=N[st],{object:dt,geometry:Yt,material:Se,group:rn}=vt;if(Se.side===Cn&&dt.layers.test(B.layers)){let Ke=Se.side;Se.side=Qt,Se.needsUpdate=!0,wf(dt,Z,B,Yt,Se,rn),Se.side=Ke,Se.needsUpdate=!0,Ee=!0}}if(Ee===!0)W.updateMultisampleRenderTarget(ge),W.updateRenderTargetMipmap(ge)}if(S.setRenderTarget(me,we,Ae),S.setClearColor(ce,De),qe!==void 0)B.viewport=qe;S.toneMapping=He}function Ho(b,N,Z){let B=N.isScene===!0?N.overrideMaterial:null;for(let G=0,ge=b.length;G<ge;G++){let Me=b[G],{object:me,geometry:we,group:Ae}=Me,He=Me.material;if(He.allowOverride===!0&&B!==null)He=B;if(me.layers.test(Z.layers))wf(me,N,Z,we,He,Ae)}}function wf(b,N,Z,B,G,ge){if(C!==null&&G.isNodeMaterial)C.setObject(b,G);if(b.onBeforeRender(S,N,Z,B,G,ge),b.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),G.onBeforeRender(S,N,Z,B,b,ge),G.transparent===!0&&G.side===Cn&&G.forceSinglePass===!1)G.side=Qt,G.needsUpdate=!0,S.renderBufferDirect(Z,N,B,G,b,ge),G.side=Xi,G.needsUpdate=!0,S.renderBufferDirect(Z,N,B,G,b,ge),G.side=Cn;else S.renderBufferDirect(Z,N,B,G,b,ge);b.onAfterRender(S,N,Z,B,G,ge)}function Vo(b,N,Z){if(N.isScene!==!0)N=cn;let B=I.get(b),G=M.state.lights,ge=M.state.shadowsArray,Me=G.state.version,me=te.getParameters(b,G.state,ge,N,Z,M.state.lightProbeGridArray),we=te.getProgramCacheKey(me),Ae=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;let He=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,He),B.envMapRotation=B.environment!==null&&b.envMap===null?N.environmentRotation:b.envMapRotation,Ae===void 0)b.addEventListener("dispose",Kn),Ae=new Map,B.programs=Ae;let qe=Ae.get(we);if(qe!==void 0){if(B.currentProgram===qe&&B.lightsStateVersion===Me)return Tf(b,me),qe}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,Z,me);b.onBeforeCompile(me,S),qe=te.acquireProgram(me,we),Ae.set(we,qe),B.uniforms=me.uniforms}let Ee=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Ee.clippingPlanes=oe.uniform;if(Tf(b,me),B.needsLights=_v(b),B.lightsStateVersion=Me,B.needsLights)Ee.ambientLightColor.value=G.state.ambient,Ee.lightProbe.value=G.state.probe,Ee.sunLights.value=G.state.sun,Ee.sunLightShadows.value=G.state.sunShadow,Ee.directionalLights.value=G.state.directional,Ee.directionalLightShadows.value=G.state.directionalShadow,Ee.spotLights.value=G.state.spot,Ee.spotLightShadows.value=G.state.spotShadow,Ee.rectAreaLights.value=G.state.rectArea,Ee.ltc_1.value=G.state.rectAreaLTC1,Ee.ltc_2.value=G.state.rectAreaLTC2,Ee.pointLights.value=G.state.point,Ee.pointLightShadows.value=G.state.pointShadow,Ee.hemisphereLights.value=G.state.hemi,Ee.sunShadowMatrix.value=G.state.sunShadowMatrix,Ee.sunShadowCascade.value=G.state.sunShadowCascade,Ee.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ee.spotLightMatrix.value=G.state.spotLightMatrix,Ee.spotLightMap.value=G.state.spotLightMap,Ee.pointShadowMatrix.value=G.state.pointShadowMatrix;return B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=qe,B.uniformsList=null,qe}function Ef(b){if(b.uniformsList===null){let N=b.currentProgram.getUniforms();b.uniformsList=lo.seqWithValue(N.seq,b.uniforms)}return b.uniformsList}function Tf(b,N){let Z=I.get(b);Z.outputColorSpace=N.outputColorSpace,Z.batching=N.batching,Z.batchingColor=N.batchingColor,Z.instancing=N.instancing,Z.instancingColor=N.instancingColor,Z.instancingMorph=N.instancingMorph,Z.skinning=N.skinning,Z.morphTargets=N.morphTargets,Z.morphNormals=N.morphNormals,Z.morphColors=N.morphColors,Z.morphTargetsCount=N.morphTargetsCount,Z.numClippingPlanes=N.numClippingPlanes,Z.numIntersection=N.numClipIntersection,Z.vertexAlphas=N.vertexAlphas,Z.vertexTangents=N.vertexTangents,Z.toneMapping=N.toneMapping}function pv(b,N){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;R.setFromMatrixPosition(N.matrixWorld);for(let Z=0,B=b.length;Z<B;Z++){let G=b[Z];if(G.texture!==null&&G.boundingBox.containsPoint(R))return G}return null}function mv(b,N,Z,B,G){if(N.isScene!==!0)N=cn;W.resetTextureUnits();let ge=N.fog,Me=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,me=z===null?S.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:$e.workingColorSpace,we=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Ae=ie.get(B.envMap||Me,we),He=B.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,qe=!!Z.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ee=!!Z.morphAttributes.position,st=!!Z.morphAttributes.normal,Lt=!!Z.morphAttributes.color,vt=Gn;if(B.toneMapped){if(z===null||z.isXRRenderTarget===!0)vt=S.toneMapping}let dt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,Yt=dt!==void 0?dt.length:0,Se=I.get(B),rn=M.state.lights;if(Ze===!0){if(ot===!0||b!==F){let _t=b===F&&B.id===H;oe.setState(B,b,_t)}}let Ke=!1;if(B.version===Se.__version){if(Se.needsLights&&Se.lightsStateVersion!==rn.state.version)Ke=!0;else if(Se.outputColorSpace!==me)Ke=!0;else if(G.isBatchedMesh&&Se.batching===!1)Ke=!0;else if(!G.isBatchedMesh&&Se.batching===!0)Ke=!0;else if(G.isBatchedMesh&&Se.batchingColor===!0&&G._colorsTexture===null)Ke=!0;else if(G.isBatchedMesh&&Se.batchingColor===!1&&G._colorsTexture!==null)Ke=!0;else if(G.isInstancedMesh&&Se.instancing===!1)Ke=!0;else if(!G.isInstancedMesh&&Se.instancing===!0)Ke=!0;else if(G.isSkinnedMesh&&Se.skinning===!1)Ke=!0;else if(!G.isSkinnedMesh&&Se.skinning===!0)Ke=!0;else if(G.isInstancedMesh&&Se.instancingColor===!0&&G.instanceColor===null)Ke=!0;else if(G.isInstancedMesh&&Se.instancingColor===!1&&G.instanceColor!==null)Ke=!0;else if(G.isInstancedMesh&&Se.instancingMorph===!0&&G.morphTexture===null)Ke=!0;else if(G.isInstancedMesh&&Se.instancingMorph===!1&&G.morphTexture!==null)Ke=!0;else if(Se.envMap!==Ae)Ke=!0;else if(B.fog===!0&&Se.fog!==ge)Ke=!0;else if(Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==oe.numPlanes||Se.numIntersection!==oe.numIntersection))Ke=!0;else if(Se.vertexAlphas!==He)Ke=!0;else if(Se.vertexTangents!==qe)Ke=!0;else if(Se.morphTargets!==Ee)Ke=!0;else if(Se.morphNormals!==st)Ke=!0;else if(Se.morphColors!==Lt)Ke=!0;else if(Se.toneMapping!==vt)Ke=!0;else if(Se.morphTargetsCount!==Yt)Ke=!0;else if(!!Se.lightProbeGrid!==M.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,Se.__version=B.version;let En=Se.currentProgram;if(Ke===!0){if(En=Vo(B,N,G),C&&B.isNodeMaterial)C.onUpdateProgram(B,En,Se)}let Jn=!1,Oi=!1,Fr=!1,ut=En.getUniforms(),Ct=Se.uniforms;if(w.useProgram(En.program))Jn=!0,Oi=!0,Fr=!0;if(B.id!==H)H=B.id,Oi=!0;if(Se.needsLights){let _t=pv(M.state.lightProbeGridArray,G);if(Se.lightProbeGrid!==_t)Se.lightProbeGrid=_t,Oi=!0}if(Jn||F!==b){if(w.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();ut.setValue(L,"projectionMatrix",b.projectionMatrix),ut.setValue(L,"viewMatrix",b.matrixWorldInverse);let Fi=ut.map.cameraPosition;if(Fi!==void 0)Fi.setValue(L,Zt.setFromMatrixPosition(b.matrixWorld));if(wt.logarithmicDepthBuffer)ut.setValue(L,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)ut.setValue(L,"isOrthographic",b.isOrthographicCamera===!0);if(F!==b)F=b,Oi=!0,Fr=!0}if(Se.needsLights){if(rn.state.sunShadowMap.length>0)ut.setValue(L,"sunShadowMap",rn.state.sunShadowMap,W);if(rn.state.directionalShadowMap.length>0)ut.setValue(L,"directionalShadowMap",rn.state.directionalShadowMap,W);if(rn.state.spotShadowMap.length>0)ut.setValue(L,"spotShadowMap",rn.state.spotShadowMap,W);if(rn.state.pointShadowMap.length>0)ut.setValue(L,"pointShadowMap",rn.state.pointShadowMap,W)}if(G.isSkinnedMesh){ut.setOptional(L,G,"bindMatrix"),ut.setOptional(L,G,"bindMatrixInverse");let _t=G.skeleton;if(_t){if(_t.boneTexture===null)_t.computeBoneTexture();ut.setValue(L,"boneTexture",_t.boneTexture,W)}}if(G.isBatchedMesh){if(ut.setOptional(L,G,"batchingTexture"),ut.setValue(L,"batchingTexture",G._matricesTexture,W),ut.setOptional(L,G,"batchingIdTexture"),ut.setValue(L,"batchingIdTexture",G._indirectTexture,W),ut.setOptional(L,G,"batchingColorTexture"),G._colorsTexture!==null)ut.setValue(L,"batchingColorTexture",G._colorsTexture,W)}let Ui=Z.morphAttributes;if(Ui.position!==void 0||Ui.normal!==void 0||Ui.color!==void 0)et.update(G,Z,En);if(Oi||Se.receiveShadow!==G.receiveShadow)Se.receiveShadow=G.receiveShadow,ut.setValue(L,"receiveShadow",G.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null)Ct.envMapIntensity.value=N.environmentIntensity;if(Ct.dfgLUT!==void 0)Ct.dfgLUT.value=uT();if(Oi){if(ut.setValue(L,"toneMappingExposure",S.toneMappingExposure),Se.needsLights)gv(Ct,Fr);if(ge&&B.fog===!0)ve.refreshFogUniforms(Ct,ge);if(ve.refreshMaterialUniforms(Ct,B,re,X,M.state.transmissionRenderTarget[b.id]),Se.needsLights&&Se.lightProbeGrid){let _t=Se.lightProbeGrid;Ct.probesSH.value=_t.texture,Ct.probesMin.value.copy(_t.boundingBox.min),Ct.probesMax.value.copy(_t.boundingBox.max),Ct.probesResolution.value.copy(_t.resolution)}lo.upload(L,Ef(Se),Ct,W)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)lo.upload(L,Ef(Se),Ct,W),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)ut.setValue(L,"center",G.center);if(ut.setValue(L,"modelViewMatrix",G.modelViewMatrix),ut.setValue(L,"normalMatrix",G.normalMatrix),ut.setValue(L,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){let _t=B.uniformsGroups;for(let Fi=0,zr=_t.length;Fi<zr;Fi++){let Rf=_t[Fi];be.update(Rf,En),be.bind(Rf,En)}}return En}function gv(b,N){b.ambientLightColor.needsUpdate=N,b.lightProbe.needsUpdate=N,b.sunLights.needsUpdate=N,b.sunLightShadows.needsUpdate=N,b.directionalLights.needsUpdate=N,b.directionalLightShadows.needsUpdate=N,b.pointLights.needsUpdate=N,b.pointLightShadows.needsUpdate=N,b.spotLights.needsUpdate=N,b.spotLightShadows.needsUpdate=N,b.rectAreaLights.needsUpdate=N,b.hemisphereLights.needsUpdate=N}function _v(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(b,N,Z){let B=I.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;I.get(b.texture).__webglTexture=N,I.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:Z,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,N){let Z=I.get(b);Z.__webglFramebuffer=N,Z.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(b,N=0,Z=0){z=b,V=N,j=Z;let B=null,G=!1,ge=!1;if(b){let me=I.get(b);if(me.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(L.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),K.copy(b.scissor),xe=b.scissorTest,w.viewport(q),w.scissor(K),w.setScissorTest(xe),H=-1;return}else if(me.__webglFramebuffer===void 0)W.setupRenderTarget(b);else if(me.__hasExternalTextures)W.rebindTextures(b,I.get(b.texture).__webglTexture,I.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let He=b.depthTexture;if(me.__boundDepthTexture!==He){if(He!==null&&I.has(He)&&(b.width!==He.image.width||b.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");W.setupDepthRenderbuffer(b)}}let we=b.texture;if(we.isData3DTexture||we.isDataArrayTexture||we.isCompressedArrayTexture)ge=!0;let Ae=I.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Ae[N]))B=Ae[N][Z];else B=Ae[N];G=!0}else if(b.samples>0&&W.useMultisampledRTT(b)===!1)B=I.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Ae))B=Ae[Z];else B=Ae;q.copy(b.viewport),K.copy(b.scissor),xe=b.scissorTest}else q.copy(Ie).multiplyScalar(re).floor(),K.copy(_e).multiplyScalar(re).floor(),xe=Qe;if(Z!==0)B=U;if(w.bindFramebuffer(L.FRAMEBUFFER,B))w.drawBuffers(b,B);if(w.viewport(q),w.scissor(K),w.setScissorTest(xe),G){let me=I.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,me.__webglTexture,Z)}else if(ge){let me=N;for(let we=0;we<b.textures.length;we++){let Ae=I.get(b.textures[we]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+we,Ae.__webglTexture,Z,me)}}else if(b!==null&&Z!==0){let me=I.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,me.__webglTexture,Z)}H=-1};function Af(b){let N=I.get(b);if(N.__readFormat!==b.format||N.__readType!==b.type)N.__readFormat=b.format,N.__readType=b.type,N.__formatReadable=wt.textureFormatReadable(b.format),N.__typeReadable=wt.textureTypeReadable(b.type);return N}if(this.readRenderTargetPixels=function(b,N,Z,B,G,ge,Me,me=0){if(!(b&&b.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let we=I.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Me!==void 0)we=we[Me];if(we){w.bindFramebuffer(L.FRAMEBUFFER,we);try{let Ae=b.textures[me],{format:He,type:qe}=Ae;if(b.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+me);let Ee=Af(Ae);if(Ee.__formatReadable===!1){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ee.__typeReadable===!1){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(N>=0&&N<=b.width-B&&(Z>=0&&Z<=b.height-G))L.readPixels(N,Z,B,G,J.convert(He),J.convert(qe),ge)}finally{let Ae=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(b,N,Z,B,G,ge,Me,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let we=I.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Me!==void 0)we=we[Me];if(we)if(N>=0&&N<=b.width-B&&(Z>=0&&Z<=b.height-G)){w.bindFramebuffer(L.FRAMEBUFFER,we);let Ae=b.textures[me],{format:He,type:qe}=Ae;if(b.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+me);let Ee=Af(Ae);if(Ee.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ee.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let st=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,st),L.bufferData(L.PIXEL_PACK_BUFFER,ge.byteLength,L.STREAM_READ),L.readPixels(N,Z,B,G,J.convert(He),J.convert(qe),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Lt=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Lt);let vt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await cp(L,vt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,st),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ge),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(st),L.deleteSync(vt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,N=null,Z=0){let B=Math.pow(2,-Z),G=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Me=N!==null?N.x:0,me=N!==null?N.y:0;W.setTexture2D(b,0),L.copyTexSubImage2D(L.TEXTURE_2D,Z,0,0,Me,me,G,ge),w.unbindTexture()},this.copyTextureToTexture=function(b,N,Z=null,B=null,G=0,ge=0){let Me,me,we,Ae,He,qe,Ee,st,Lt,vt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(Z!==null)Me=Z.max.x-Z.min.x,me=Z.max.y-Z.min.y,we=Z.isBox3?Z.max.z-Z.min.z:1,Ae=Z.min.x,He=Z.min.y,qe=Z.isBox3?Z.min.z:0;else{let Ct=Math.pow(2,-G);if(Me=Math.floor(vt.width*Ct),me=Math.floor(vt.height*Ct),b.isDataArrayTexture)we=vt.depth;else if(b.isData3DTexture)we=Math.floor(vt.depth*Ct);else we=1;Ae=0,He=0,qe=0}if(B!==null)Ee=B.x,st=B.y,Lt=B.z;else Ee=0,st=0,Lt=0;let dt=J.convert(N.format),Yt=J.convert(N.type),Se;if(N.isData3DTexture)W.setTexture3D(N,0),Se=L.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)W.setTexture2DArray(N,0),Se=L.TEXTURE_2D_ARRAY;else W.setTexture2D(N,0),Se=L.TEXTURE_2D;w.activeTexture(L.TEXTURE0),w.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),w.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),w.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let rn=w.getParameter(L.UNPACK_ROW_LENGTH),Ke=w.getParameter(L.UNPACK_IMAGE_HEIGHT),En=w.getParameter(L.UNPACK_SKIP_PIXELS),Jn=w.getParameter(L.UNPACK_SKIP_ROWS),Oi=w.getParameter(L.UNPACK_SKIP_IMAGES);w.pixelStorei(L.UNPACK_ROW_LENGTH,vt.width),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,vt.height),w.pixelStorei(L.UNPACK_SKIP_PIXELS,Ae),w.pixelStorei(L.UNPACK_SKIP_ROWS,He),w.pixelStorei(L.UNPACK_SKIP_IMAGES,qe);let Fr=b.isDataArrayTexture||b.isData3DTexture,ut=N.isDataArrayTexture||N.isData3DTexture;if(b.isDepthTexture){let Ct=I.get(b),Ui=I.get(N),_t=I.get(Ct.__renderTarget),Fi=I.get(Ui.__renderTarget);w.bindFramebuffer(L.READ_FRAMEBUFFER,_t.__webglFramebuffer),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,Fi.__webglFramebuffer);for(let zr=0;zr<we;zr++){if(Fr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(b).__webglTexture,G,qe+zr),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(N).__webglTexture,ge,Lt+zr);L.blitFramebuffer(Ae,He,Me,me,Ee,st,Me,me,L.DEPTH_BUFFER_BIT,L.NEAREST)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(G!==0||b.isRenderTargetTexture||I.has(b)){let Ct=I.get(b),Ui=I.get(N);w.bindFramebuffer(L.READ_FRAMEBUFFER,ee),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,P);for(let _t=0;_t<we;_t++){if(Fr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ct.__webglTexture,G,qe+_t);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ct.__webglTexture,G);if(ut)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ui.__webglTexture,ge,Lt+_t);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ui.__webglTexture,ge);if(G!==0)L.blitFramebuffer(Ae,He,Me,me,Ee,st,Me,me,L.COLOR_BUFFER_BIT,L.NEAREST);else if(ut)L.copyTexSubImage3D(Se,ge,Ee,st,Lt+_t,Ae,He,Me,me);else L.copyTexSubImage2D(Se,ge,Ee,st,Ae,He,Me,me)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(ut)if(b.isDataTexture||b.isData3DTexture)L.texSubImage3D(Se,ge,Ee,st,Lt,Me,me,we,dt,Yt,vt.data);else if(N.isCompressedArrayTexture)L.compressedTexSubImage3D(Se,ge,Ee,st,Lt,Me,me,we,dt,vt.data);else L.texSubImage3D(Se,ge,Ee,st,Lt,Me,me,we,dt,Yt,vt);else if(b.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,ge,Ee,st,Me,me,dt,Yt,vt.data);else if(b.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,ge,Ee,st,vt.width,vt.height,dt,vt.data);else L.texSubImage2D(L.TEXTURE_2D,ge,Ee,st,Me,me,dt,Yt,vt);if(w.pixelStorei(L.UNPACK_ROW_LENGTH,rn),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(L.UNPACK_SKIP_PIXELS,En),w.pixelStorei(L.UNPACK_SKIP_ROWS,Jn),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Oi),ge===0&&N.generateMipmaps)L.generateMipmap(Se);w.unbindTexture()},this.initRenderTarget=function(b){if(I.get(b).__webglFramebuffer===void 0)W.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)W.setTextureCube(b,0);else if(b.isData3DTexture)W.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)W.setTexture2DArray(b,0);else W.setTexture2D(b,0);w.unbindTexture()},this.resetState=function(){V=0,j=0,z=null,w.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return uu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}function Vu(e,t){if(t===ou)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===us||t===$s){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===us)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function tm(e){let t=new Map,n=new Map,i=e.clone();return nm(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function nm(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)nm(e.children[i],t.children[i],n)}class Yu extends Pi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new um(t)}),this.register(function(t){return new hm(t)}),this.register(function(t){return new vm(t)}),this.register(function(t){return new bm(t)}),this.register(function(t){return new Sm(t)}),this.register(function(t){return new dm(t)}),this.register(function(t){return new pm(t)}),this.register(function(t){return new mm(t)}),this.register(function(t){return new gm(t)}),this.register(function(t){return new lm(t)}),this.register(function(t){return new _m(t)}),this.register(function(t){return new fm(t)}),this.register(function(t){return new ym(t)}),this.register(function(t){return new xm(t)}),this.register(function(t){return new am(t)}),this.register(function(t){return new Xu(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Xu(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Mm(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=ir.extractUrlBase(e);s=ir.resolveURL(c,this.path)}else s=ir.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new io(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===wm){try{s[Xe.KHR_BINARY_GLTF]=new Em(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Pm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new cm;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Tm(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new Am;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Rm;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function hT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Pt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class am{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Ue(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new _s(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new gs(l),c.distance=u;break;case"spot":c=new Za(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ui(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class cm{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return ai}extendParams(e,t,n){let i=[];e.color=new Ue(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,ji))}return Promise.all(i)}}class lm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class um{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class hm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class fm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class dm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Ue(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,ji));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class pm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ue().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class gm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class _m{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Ue().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,ji));return Promise.all(i)}}class xm{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class ym{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class vm{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class bm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Sm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Xu{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Mm{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==In.TRIANGLES&&c.mode!==In.TRIANGLE_STRIP&&c.mode!==In.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new D,p=new Ht,m=new D(1,1,1),E=new ds(d.geometry,d.material,f);for(let v=0;v<f;v++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)m.fromBufferAttribute(a.SCALE,v);E.setMatrixAt(v,g.compose(x,p,m))}let R=null;for(let v in a)if(v==="_COLOR_0"){let M=a[v];E.instanceColor=new $i(M.array,M.itemSize,M.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(R===null){let T=E.geometry;R=new en,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let M=a[v];R.setAttribute(v,new $i(M.array,M.itemSize,M.normalized))}ht.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var wm="glTF",ho=12,im={JSON:1313821514,BIN:5130562};class Em{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,ho),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==wm)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-ho,r=new DataView(e,ho),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===im.JSON){let c=new Uint8Array(e,ho+s,o);this.content=n.decode(c)}else if(a===im.BIN){let c=ho+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Tm{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=qu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=qu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=bs[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class Am{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Rm{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class Ku extends Ci{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let v=s[g+R+o],M=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*v+E*M+x*T+p*A}return r}}var fT=new Ht;class Cm extends Ku{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return fT.fromArray(r).normalize().toArray(r),r}}var In={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},bs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},rm={9728:Hn,9729:$t,9984:ba,9985:cs,9986:vr,9987:ri},sm={33071:as,33648:va,10497:os},$u={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},rr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},dT={CUBICSPLINE:void 0,LINEAR:Ra,STEP:su},Wu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function pT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ri({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Xi});return e.DefaultMaterial}function Pr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ui(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function mT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function gT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function _T(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Zu(n.attributes);else t=e.indices+":"+Zu(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Zu(e.targets[i]);return t}function Zu(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function ju(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function xT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var yT=new Ge;class Pm{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Va(this.options.manager);else this.textureLoader=new Xa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new io(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Pr(r,o,i),ui(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(ir.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=$u[i.type],o=bs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Vt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=$u[i.type],c=bs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new qs(g,h/l),t.cache.add(m,E);x=new fs(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Vt(g,a,d)}if(i.sparse!==void 0){let p=$u.SCALAR,m=bs[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,v=new m(s[1],E,i.sparse.count*p),M=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Vt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=v.length;T<A;T++){let _=v[T];if(x.setX(_,M[T*a]),a>=2)x.setY(_,M[T*a+1]);if(a>=3)x.setZ(_,M[T*a+2]);if(a>=4)x.setW(_,M[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=rm[f.magFilter]||$t,l.minFilter=rm[f.minFilter]||ri,l.wrapS=sm[f.wrapS]||os,l.wrapT=sm[f.wrapT]||os,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Hn&&l.minFilter!==$t,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new At(g);x.needsUpdate=!0,f(x)};t.load(ir.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ui(u,s),u.userData.mimeType=s.mimeType||xT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new eo,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Qs,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Ri}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Ue(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,ji));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Cn;let l=r.alphaMode||Wu.OPAQUE;if(l===Wu.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Wu.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==ai){let u=r.emissiveFactor;o.emissive=new Ue().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==ai)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,ji));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ui(u,r),t.associations.set(u,{materials:e}),r.extensions)Pr(i,u,r);return u})}createUniqueName(e){let t=tt.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return om(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=_T(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=om(new en,c,t);if(c.mode===In.TRIANGLE_STRIP)f=f.then((h)=>Vu(h,$s));else if(c.mode===In.TRIANGLE_FAN)f=f.then((h)=>Vu(h,us));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?pT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===In.TRIANGLES||x.mode===In.TRIANGLE_STRIP||x.mode===In.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new Oa(g,m):new xt(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===In.LINES)p=new Ua(g,m);else if(x.mode===In.LINE_STRIP)p=new Ki(g,m);else if(x.mode===In.LINE_LOOP)p=new Fa(g,m);else if(x.mode===In.POINTS)p=new ps(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)gT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ui(p,r),x.extensions)Pr(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Pr(i,u[0],r);return u[0]}let f=new ei;if(r.extensions)Pr(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ut(Ws.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Rr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return ui(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ks(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let v=f[E],M=h[E],T=d[E],A=g[E],_=x[E];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let S=n._createAnimationTracks(v,M,T,A,_);if(S)for(let k=0;k<S.length;k++)p.push(S[k])}let m=new ns(r,void 0,p);return ui(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,yT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new D().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new js;else if(c.length>1)l=new ei;else if(c.length===1)l=c[0];else l=new ht;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ui(l,r),r.extensions)Pr(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ei;if(n.name)r.name=i.createUniqueName(n.name);if(ui(r,n),n.extensions)Pr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(tm(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof hn||f instanceof At)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(rr[r.path]===rr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(rr[r.path]){case rr.weights:l=er;break;case rr.rotation:l=tr;break;case rr.translation:case rr.scale:l=Ar;break;default:switch(n.itemSize){case 1:l=er;break;case 2:case 3:default:l=Ar;break}break}let u=i.interpolation!==void 0?dT[i.interpolation]:Ra,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+rr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=ju(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof tr?Cm:Ku)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function vT(e,t,n){let i=t.attributes,r=new Ft;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new D(c[0],c[1],c[2]),new D(l[0],l[1],l[2])),a.normalized){let u=ju(bs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new D,c=new D;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=ju(bs[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function om(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=qu[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return ui(e,t),vT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?mT(e,t.targets,n):e})}var Im={type:"change"},Qu={type:"start"},Nm={type:"end"},ec=new Yi,Lm=new An,bT=Math.cos(70*Ws.DEG2RAD),Bt=new D,fn=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ju=0.000001;class eh extends ja{constructor(e,t=null){super(e,t);if(this.state=lt.NONE,this.target=new D,this.cursor=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Wi.ROTATE,MIDDLE:Wi.DOLLY,RIGHT:Wi.PAN},this.touches={ONE:Zi.ROTATE,TWO:Zi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new D,this._lastQuaternion=new Ht,this._lastTargetPosition=new D,this._quat=new Ht().setFromUnitVectors(e.up,new D(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new so,this._sphericalDelta=new so,this._scale=1,this._panOffset=new D,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new D,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=MT.bind(this),this._onPointerDown=ST.bind(this),this._onPointerUp=wT.bind(this),this._onContextMenu=IT.bind(this),this._onMouseWheel=AT.bind(this),this._onKeyDown=RT.bind(this),this._onTouchStart=CT.bind(this),this._onTouchMove=PT.bind(this),this._onMouseDown=ET.bind(this),this._onMouseMove=TT.bind(this),this._interceptControlDown=LT.bind(this),this._interceptControlUp=NT.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=lt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Im),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Bt.copy(t).sub(this.target),Bt.applyQuaternion(this._quat),this._spherical.setFromVector3(Bt),this.autoRotate&&this.state===lt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=fn;else if(n>Math.PI)n-=fn;if(i<-Math.PI)i+=fn;else if(i>Math.PI)i-=fn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Bt.setFromSpherical(this._spherical),Bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Bt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new D(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new D(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(ec.origin.copy(this.object.position),ec.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ec.direction))<bT)this.object.lookAt(this.target);else Lm.setFromNormalAndCoplanarPoint(this.object.up,this.target),ec.intersectPlane(Lm,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Ju||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ju||this._lastTargetPosition.distanceToSquared(this.target)>Ju)return this.dispatchEvent(Im),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return fn/60*this.autoRotateSpeed*e;else return fn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bt.setFromMatrixColumn(t,0),Bt.multiplyScalar(-e),this._panOffset.add(Bt)}_panUp(e,t){if(this.screenSpacePanning===!0)Bt.setFromMatrixColumn(t,1);else Bt.setFromMatrixColumn(t,0),Bt.crossVectors(this.object.up,Bt);Bt.multiplyScalar(e),this._panOffset.add(Bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Bt.copy(i).sub(this.target);let r=Bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function ST(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function MT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function wT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Nm),this.state=lt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function ET(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Wi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=lt.DOLLY;break;case Wi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=lt.ROTATE}break;case Wi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=lt.PAN}break;default:this.state=lt.NONE}if(this.state!==lt.NONE)this.dispatchEvent(Qu)}function TT(e){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function AT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE)return;e.preventDefault(),this.dispatchEvent(Qu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Nm)}function RT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function CT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Zi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=lt.TOUCH_ROTATE;break;case Zi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case Zi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=lt.TOUCH_DOLLY_PAN;break;case Zi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}if(this.state!==lt.NONE)this.dispatchEvent(Qu)}function PT(e){switch(this._trackPointer(e),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=lt.NONE}}function IT(e){if(this.enabled===!1)return;e.preventDefault()}function LT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function NT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class th extends hs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Ji;e.deleteAttribute("uv");let t=new Ri({side:Qt}),n=new Ri,i=new gs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new xt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ds(e,n,6),o=new ht;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new xt(e,Ss(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new xt(e,Ss(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new xt(e,Ss(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new xt(e,Ss(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new xt(e,Ss(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new xt(e,Ss(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Ss(e){return new Ba({color:0,emissive:16777215,emissiveIntensity:e})}function po(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function ih(e,t="|"){return e.map((n)=>oh(n)).join(t)}function mo(e,t){if(typeof t==="bigint")return t.toString();return t}class Dm{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function go(e){return new Dm(e)}function Om(e){return e===null||e===void 0}function tc(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Um(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Ln(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _o(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ii(e){return _o(e._zod.def)??e._zod.def.shape}function Fm(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Ln(this,t,i),i},enumerable:!0,configurable:!0})}function zm(e,t,n){if(t in e)Ln(e,t,n);else e[t]=n}function Ir(e,t,n,i){let r=Ii(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Fm(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else zm(e,s,i?i(o.value,s):o.value)}}function DT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Fm(e,n,()=>t[n]);else zm(e,n,i.value)}}function bn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function km(e){return JSON.stringify(e)}function Bm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var rh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ms(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Gm=go(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Lr(e){if(Ms(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Ms(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function sh(e){if(Lr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Hm=new Set(["string","number","symbol"]);function or(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Re(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function oh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Vm(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var nc=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ah={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function OT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Ir(s,e,ic(e,t)),hi(e,bn(n,{shape:s,checks:[]}))}function ic(e,t){let n=Ii(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function UT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(ic(e,t)),o={};return Ir(o,e,Reflect.ownKeys(Ii(e)).filter((a)=>!s.has(a))),hi(e,bn(n,{shape:o,checks:[]}))}function FT(e,t){if(!Lr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Ii(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return hi(e,bn(e._zod.def,{shape:$m(e,t)}))}function $m(e,t){let n={};return Ir(n,e,Reflect.ownKeys(Ii(e))),DT(n,t),n}function zT(e,t){if(!Lr(t))throw Error("Invalid input to safeExtend: expected a plain object");return hi(e,bn(e._zod.def,{shape:$m(e,t)}))}function kT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Ir(n,e,Reflect.ownKeys(Ii(e))),Ir(n,t,Reflect.ownKeys(Ii(t)));let i=bn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return hi(e,i)}function Wm(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(ic(t,n)):void 0,c={};return Ir(c,t,Reflect.ownKeys(Ii(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),hi(t,bn(t._zod.def,{shape:c,checks:[]}))}function BT(e,t,n){let i=n?new Set(ic(t,n)):void 0,r={};return Ir(r,t,Reflect.ownKeys(Ii(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),hi(t,bn(t._zod.def,{shape:r}))}function fi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ar(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function fo(e){return typeof e==="string"?e:e?.message}function ch(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function di(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:fo(e.inst?._zod.def?.error?.(e))??fo(s?.(e))??fo(t?.error?.(e))??fo(n.customError?.(e))??fo(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var GT=/[\uD800-\uDBFF]/;function rc(e){let t=e.length;if(!GT.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function sc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Xm(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Nr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function qm(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else HT(e,n,i.value)}}function Li(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function oc(e,t,n){return Li(e,t,n,!1)}function jm(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Li(this,n,i(this))},set(r){Li(this,n,r)}})}return t}function HT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Li(this,t,n.bind(this))},set(i){Li(this,t,i)}})}function VT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var nh,sr=!1,$T={configurable:!0,get(){sr=!0;return}};function nt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&nh!==e._zod){nh=void 0;return}nh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,$T);let r=sr;sr=!1;try{let s=n(this);if(sr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return sr=sr||r,s}catch(s){throw delete this[t],sr=sr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function WT(e,t,n,i){let r=VT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var ZT="~constantCatch";function Ym(e){let t=()=>e;return t[ZT]=!0,t}var Km;var lh={value:void 0,enumerable:!1},Jm="captureStackTrace"in Error?Error:null;function XT(e){let t=Jm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Jm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Q(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){lh.value=new s(d);try{Object.defineProperty(h,"_zod",lh)}finally{lh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),qm(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?XT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class pi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Km=globalThis).__zod_globalConfig??(Km.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Sn(e){if(e)Object.assign(dn,e);return dn}function qT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mo,2)),e.message}function jT(e){this._zod.message=e}var YT={get:qT,set:jT,enumerable:!0,configurable:!0},hh={value:void 0,enumerable:!1},Qm=new WeakSet([Object.prototype,Error.prototype]),eg=(e,t)=>{e.name="$ZodError",hh.value=t,Object.defineProperty(e,"issues",hh),hh.value=void 0,Object.defineProperty(e,"message",YT);let n=Object.getPrototypeOf(e);if(!Qm.has(n))Qm.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},tg=Q("$ZodError",eg),XI=Q("$ZodError",eg,void 0,{Parent:Error});function KT(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function ng(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)KT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function ig(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function ac(e,t){return{callee:t?.callee??e,Err:t?.Err}}var cc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new pi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw rh(c,s?.callee??t),c}return a.value};return t};var lc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw rh(c,s?.callee??t),c}return a.value};return t};var uc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new pi;return s.issues.length?rg(e,s.issues,r):{success:!0,data:s.value}};function rg(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>di(r,n,Sn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var hc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?rg(e,s.issues,r):{success:!0,data:s.value}};var JT=Symbol.for("zod.compile.invalid"),QT=Symbol.for("zod.compile.fallback"),fh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==JT)return!0;if(i.definite===!0&&n===void 0)return!1}return eA(e,t,n)};function eA(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[QT]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new pi;return s.issues.length===0}var dh=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},sg=(e)=>{let t=cc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,ac(n,o))};return n};var og=(e)=>{let t=cc(e),n=(i,r,s,o)=>t(i,r,s,ac(n,o));return n};var ag=(e)=>{let t=lc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,ac(n,o))};return n};var cg=(e)=>{let t=lc(e),n=async(i,r,s,o)=>await t(i,r,s,ac(n,o));return n};var lg=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return uc(e)(t,n,r)};var ug=(e)=>(t,n,i)=>uc(e)(t,n,i);var hg=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return hc(e)(t,n,r)};var fg=(e)=>async(t,n,i)=>hc(e)(t,n,i);var dg=/^[cC][0-9a-z]{6,}$/,pg=/^[0-9a-z]+$/,mg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,gg=/^[0-9a-vA-V]{20}$/,_g=/^[A-Za-z0-9]{27}$/,xg=/^[a-zA-Z0-9_-]{21}$/;function yg(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var vg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var bg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Sg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var tA="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Mg(){return new RegExp(tA,"u")}var wg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Eg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Tg=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ag=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Pg=/^https?$/,Ig=/^\+[1-9]\d{6,14}$/;var Lg="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function nA(e){return new RegExp(`^${e}$`)}var Ng=nA(Lg);function ph(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Dg(e){return new RegExp(`^${ph(e)}$`)}function Og(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${ph({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${ph({precision:e.precision})}`:n;return new RegExp(`^${Lg}T(?:${i})$`)}var Ug=/^[\s\S]{0,}$/;var gh=/^-?\d+$/,yo=/^-?\d+(?:\.\d+)?$/,Fg=/^(?:true|false)$/i;var zg=/^[^A-Z]*$/,kg=/^[^a-z]*$/;var Xt=Q("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var _h=(e)=>{let t=e.value;return!Om(t)&&t.length!==void 0},fc={number:"number",bigint:"bigint",object:"date"},xh=Q("$ZodCheckLessThan",(e,t)=>{Xt.init(e,t);let n=fc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:fc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yh=Q("$ZodCheckGreaterThan",(e,t)=>{Xt.init(e,t);let n=fc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:fc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bg=Q("$ZodCheckMultipleOf",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Um(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Gg=Q("$ZodCheckNumberFormat",(e,t)=>{Xt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=nc[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Hg=Q("$ZodCheckMaxLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=_h),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?rc(r):s)<=t.maximum)return;let a=sc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vg=Q("$ZodCheckMinLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=_h),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?rc(r):s)>=t.minimum)return;let a=sc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$g=Q("$ZodCheckLengthEquals",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=_h),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?rc(r):s;if(o===t.length)return;let a=sc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),bo=Q("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Xt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Wg=Q("$ZodCheckRegex",(e,t)=>{bo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zg=Q("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=zg),bo.init(e,t)}),Xg=Q("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=kg),bo.init(e,t)}),qg=Q("$ZodCheckIncludes",(e,t)=>{Xt.init(e,t);let n=or(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),jg=Q("$ZodCheckStartsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`^${or(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Yg=Q("$ZodCheckEndsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`.*${or(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Kg=Q("$ZodCheckOverwrite",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class vh{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
+}`;class Jp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ga(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new In({vertexShader:oT,fragmentShader:aT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _t(new so(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Qp extends Wn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Jp,p={},m=t.getContextAttributes(),E=null,R=null,v=[],M=[],T=new Ne,A=null,_=null,S=new Ut;S.viewport=new at;let z=new Ut;z.viewport=new at;let P=[S,z],F=new Au,ee=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getHandSpace()};function H(Z){let re=M.indexOf(Z.inputSource);if(re===-1)return;let se=v[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function q(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",C);for(let Z=0;Z<v.length;Z++){let re=M[Z];if(re===null)continue;M[Z]=null,v[Z].disconnect(re)}ee=null,I=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",q),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:oi,type:$n,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,we=null;if(m.depth)we=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Mr:Sr,xe=m.stencil?hs:ji;let Ee={colorFormat:t.RGBA8,depthFormat:we,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(Ee),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:oi,type:$n,depthTexture:new Tr(f.textureWidth,f.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function C(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=M.indexOf(se);if(xe>=0)M[xe]=null,v[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=M.indexOf(se);if(xe===-1){for(let Ee=0;Ee<v.length;Ee++)if(Ee>=M.length){M.push(se),xe=Ee;break}else if(M[Ee]===null){M[Ee]=se,xe=Ee;break}if(xe===-1)break}let we=v[xe];if(we)we.connect(se)}}let X=new O,k=new O;function Y(Z,re,se){X.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=X.distanceTo(k),we=re.projectionMatrix.elements,Ee=se.projectionMatrix.elements,xt=we[14]/(we[10]-1),ke=we[14]/(we[10]+1),Ze=(we[9]+1)/we[5],st=(we[9]-1)/we[5],Ye=(we[8]-1)/we[0],Zt=(Ee[8]+1)/Ee[0],yt=xt*Ye,cn=xt*Zt,Dt=xe/(-Ye+Zt),Ot=Dt*-Ye;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Ot),Z.translateZ(Dt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),we[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let N=xt+Dt,ln=ke+Dt,nt=yt-Ot,wt=cn+(xe-Ot),w=Ze*ke/ln*N,y=st*ke/ln*N;Z.projectionMatrix.makePerspective(nt,wt,w,y,N,ln),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(F.near=z.near=S.near=re,F.far=z.far=S.far=se,ee!==F.near||I!==F.far)i.updateRenderState({depthNear:F.near,depthFar:F.far}),ee=F.near,I=F.far;F.layers.mask=Z.layers.mask|6,S.layers.mask=F.layers.mask&-5,z.layers.mask=F.layers.mask&-3;let xe=Z.parent,we=F.cameras;Q(F,xe);for(let Ee=0;Ee<we.length;Ee++)Q(we[Ee],xe);if(we.length===2)Y(F,S,z);else F.projectionMatrix.copy(S.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Se(Z,F,xe)};function Se(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=yr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return F},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(F)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Fe(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let xe=!1;if(se.length!==F.cameras.length)F.cameras.length=0,xe=!0;for(let ke=0;ke<se.length;ke++){let Ze=se[ke],st=null;if(h!==null)st=h.getViewport(Ze);else{let Zt=u.getViewSubImage(f,Ze);if(st=Zt.viewport,ke===0)e.setRenderTargetTextures(R,Zt.colorTexture,Zt.depthStencilTexture),e.setRenderTarget(R)}let Ye=P[ke];if(Ye===void 0)Ye=new Ut,Ye.layers.enable(ke),Ye.viewport=new at,P[ke]=Ye;if(Ye.matrix.fromArray(Ze.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Ze.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(st.x,st.y,st.width,st.height),ke===0)F.matrix.copy(Ye.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);if(xe===!0)F.cameras.push(Ye)}let we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ke=u.getDepthInformation(se[0]);if(ke&&ke.isValid&&ke.texture)x.init(ke,i.renderState)}if(we&&we.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ke=0;ke<se.length;ke++){let Ze=se[ke].camera;if(Ze){let st=p[Ze];if(!st)st=new Ga,p[Ze]=st;let Ye=u.getCameraImage(Ze);st.sourceTexture=Ye}}}}for(let se=0;se<v.length;se++){let xe=M[se],we=v[se];if(xe!==null&&we!==void 0)we.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new Gp;Me.setAnimationLoop(Fe),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var cT=new Ge,em=new ze;em.set(-1,0,0,0,1,0,0,0,1);function lT(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,_u(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,v){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,v)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Qt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Qt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:v}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(cT.makeRotationFromEuler(v)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(em);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Qt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function uT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){let T=M.program;i.uniformBlockBinding(v,T)}function l(v,M){let T=r[v.id];if(T===void 0)p(v),T=u(v),r[v.id]=T,v.addEventListener("dispose",E);let A=M.program;i.updateUBOMapping(v,A);let _=t.render.frame;if(s[v.id]!==_)h(v),s[v.id]=_}function u(v){let M=f();v.__bindingPointIndex=M;let T=e.createBuffer(),{__size:A,usage:_}=v;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,M,T),T}function f(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let M=r[v.id],{uniforms:T,__cache:A}=v;e.bindBuffer(e.UNIFORM_BUFFER,M);for(let _=0,S=T.length;_<S;_++){let z=T[_];if(Array.isArray(z))for(let P=0,F=z.length;P<F;P++)d(z[P],_,P,A);else d(z,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(v,M,T,A){if(x(v,M,T,A)===!0){let{__offset:_,value:S}=v;if(Array.isArray(S)){let z=0;for(let P=0;P<S.length;P++){let F=S[P],ee=m(F);if(g(F,v.__data,z),typeof F!=="number"&&typeof F!=="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F))z+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else g(S,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,v.__data)}}function g(v,M,T){if(typeof v==="number"||typeof v==="boolean")M[0]=v;else if(v.isMatrix3)M[0]=v.elements[0],M[1]=v.elements[1],M[2]=v.elements[2],M[3]=0,M[4]=v.elements[3],M[5]=v.elements[4],M[6]=v.elements[5],M[7]=0,M[8]=v.elements[6],M[9]=v.elements[7],M[10]=v.elements[8],M[11]=0;else if(ArrayBuffer.isView(v))M.set(new v.constructor(v.buffer,v.byteOffset,M.length));else v.toArray(M,T)}function x(v,M,T,A){let _=v.value,S=M+"_"+T;if(A[S]===void 0){if(typeof _==="number"||typeof _==="boolean")A[S]=_;else if(ArrayBuffer.isView(_))A[S]=_.slice();else A[S]=_.clone();return!0}else{let z=A[S];if(typeof _==="number"||typeof _==="boolean"){if(z!==_)return A[S]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(z.equals(_)===!1)return z.copy(_),!0}return!1}function p(v){let M=v.uniforms,T=0,A=16;for(let S=0,z=M.length;S<z;S++){let P=Array.isArray(M[S])?M[S]:[M[S]];for(let F=0,ee=P.length;F<ee;F++){let I=P[F],H=Array.isArray(I.value)?I.value:[I.value];for(let q=0,C=H.length;q<C;q++){let X=H[q],k=m(X),Y=T%A,Q=Y%k.boundary,Se=Y+Q;if(T+=Q,Se!==0&&A-Se<k.storage)T+=A-Se;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=T,T+=k.storage}}}let _=T%A;if(_>0)T+=A-_;return v.__size=T,v.__cache={},this}function m(v){let M={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")M.boundary=4,M.storage=4;else if(v.isVector2)M.boundary=8,M.storage=8;else if(v.isVector3||v.isColor)M.boundary=16,M.storage=12;else if(v.isVector4)M.boundary=16,M.storage=16;else if(v.isMatrix3)M.boundary=48,M.storage=48;else if(v.isMatrix4)M.boundary=64,M.storage=64;else if(v.isTexture)Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))M.boundary=16,M.storage=v.byteLength;else Ie("WebGLRenderer: Unsupported uniform value type.",v);return M}function E(v){let M=v.target;M.removeEventListener("dispose",E);let T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[M.id]),delete r[M.id],delete s[M.id]}function R(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var hT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ci=null;function fT(){if(ci===null)ci=new eo(hT,16,16,wr,si),ci.name="DFG_LUT",ci.minFilter=$t,ci.magFilter=$t,ci.wrapS=ls,ci.wrapT=ls,ci.generateMipmaps=!1,ci.needsUpdate=!0;return ci}class Vu{constructor(e={}){let{canvas:t=ap(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=$n}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Cl,Rl,Al]),p=new Set([$n,ji,Xs,hs,El,Tl]),m=new Uint32Array(4),E=new Int32Array(4),R=new O,v=null,M=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,z=!1,P=null,F=null,ee=null,I=null;this._outputColorSpace=Yi;let H=0,q=0,C=null,X=-1,k=null,Y=new at,Q=new at,Se=null,ue=new Oe(0),Fe=0,{width:Me,height:Z}=t,re=1,se=null,xe=null,we=new at(0,0,Me,Z),Ee=new at(0,0,Me,Z),xt=!1,ke=new no,Ze=!1,st=!1,Ye=new Ge,Zt=new O,yt=new at,cn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Dt=!1;function Ot(){return C===null?re:1}let N=n;function ln(b,D){return t.getContext(b,D)}let nt,wt,w,y,L,V,ie,ae,he,j,te,_e,Pe,fe,oe,Le,De,Qe,U,ce,K,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${dd}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",mt,!1),t.addEventListener("webglcontextcreationerror",it,!1),N===null){if(N=ln("webgl2",b),N===null)if(ln("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",mt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),Ue("WebGLRenderer: "+b.message),b}function ne(){if(nt=new yw(N),nt.init(),K=new sT(N,nt),wt=new lw(N,nt,e,K),w=new iT(N,nt),wt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);F=N.createFramebuffer(),ee=N.createFramebuffer(),I=N.createFramebuffer(),y=new Sw(N),L=new VE,V=new rT(N,nt,w,L,wt,K,y),ie=new xw(S),ae=new wb(N),le=new aw(N,ae),he=new vw(N,ae,y,le),j=new ww(N,he,ae,le,y),Qe=new Mw(N,wt,V),oe=new uw(L),te=new HE(S,ie,nt,wt,le,oe),_e=new lT(S,L),Pe=new WE,fe=new KE(nt),De=new ow(S,ie,w,j,d,a),Le=new nT(S,j,wt),ye=new uT(N,y,wt,w),U=new cw(N,nt,y),ce=new bw(N,nt,y),y.programs=te.programs,S.capabilities=wt,S.extensions=nt,S.properties=L,S.renderLists=Pe,S.shadowMap=Le,S.state=w,S.info=y}if(g!==$n)_=new Tw(g,t.width,t.height,o,i,r);let pe=new Qp(S,N);this.xr=pe,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let b=nt.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=nt.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(Me,Z,!1)},this.getSize=function(b){return b.set(Me,Z)},this.setSize=function(b,D,W=!0){if(pe.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=b,Z=D,t.width=Math.floor(b*re),t.height=Math.floor(D*re),W===!0)t.style.width=b+"px",t.style.height=D+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,b,D)},this.getDrawingBufferSize=function(b){return b.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(b,D,W){Me=b,Z=D,re=W,t.width=Math.floor(b*W),t.height=Math.floor(D*W),this.setViewport(0,0,b,D)},this.setEffects=function(b){if(g===$n){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let D=0;D<b.length;D++)if(b[D].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(Y)},this.getViewport=function(b){return b.copy(we)},this.setViewport=function(b,D,W,B){if(b.isVector4)we.set(b.x,b.y,b.z,b.w);else we.set(b,D,W,B);w.viewport(Y.copy(we).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ee)},this.setScissor=function(b,D,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,D,W,B);w.scissor(Q.copy(Ee).multiplyScalar(re).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(b){w.setScissorTest(xt=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(b=!0,D=!0,W=!0){let B=0;if(b){let G=!1;if(C!==null){let ge=C.texture.format;G=x.has(ge)}if(G){let ge=C.texture.type,be=p.has(ge),me=De.getClearColor(),Te=De.getClearAlpha(),{r:Re,g:He,b:qe}=me;if(be)m[0]=Re,m[1]=He,m[2]=qe,m[3]=Te,N.clearBufferuiv(N.COLOR,0,m);else E[0]=Re,E[1]=He,E[2]=qe,E[3]=Te,N.clearBufferiv(N.COLOR,0,E)}else B|=N.COLOR_BUFFER_BIT}if(D)B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)N.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),P=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",mt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),De.dispose(),Pe.dispose(),fe.dispose(),L.dispose(),ie.dispose(),j.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",bf),pe.removeEventListener("sessionend",Sf),dr.stop()};function Be(b){b.preventDefault(),Hs("WebGLRenderer: Context Lost."),z=!0}function mt(){Hs("WebGLRenderer: Context Restored."),z=!1;let b=y.autoReset,D=Le.enabled,W=Le.autoUpdate,B=Le.needsUpdate,G=Le.type;ne(),y.autoReset=b,Le.enabled=D,Le.autoUpdate=W,Le.needsUpdate=B,Le.type=G}function it(b){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Kn(b){let D=b.target;D.removeEventListener("dispose",Kn),vi(D)}function vi(b){pv(b),L.remove(b)}function pv(b){let D=L.get(b).programs;if(D!==void 0){if(D.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,D,W,B,G,ge){if(D===null)D=cn;let be=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=_v(b,D,W,B,G);w.setMaterial(B,be);let Te=W.index,Re=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Re=2}let He=W.drawRange,qe=W.attributes.position,Ae=He.start*Re,rt=(He.start+He.count)*Re;if(ge!==null)Ae=Math.max(Ae,ge.start*Re),rt=Math.min(rt,(ge.start+ge.count)*Re);if(Te!==null)Ae=Math.max(Ae,0),rt=Math.min(rt,Te.count);else if(qe!==void 0&&qe!==null)Ae=Math.max(Ae,0),rt=Math.min(rt,qe.count);let Lt=rt-Ae;if(Lt<0||Lt===1/0)return;le.setup(G,B,me,W,Te);let vt,ft=U;if(Te!==null)vt=ae.get(Te),ft=ce,ft.setIndex(vt);if(G.isMesh)if(B.wireframe===!0)w.setLineWidth(B.wireframeLinewidth*Ot()),ft.setMode(N.LINES);else ft.setMode(N.TRIANGLES);else if(G.isLine){let Yt=B.linewidth;if(Yt===void 0)Yt=1;if(w.setLineWidth(Yt*Ot()),G.isLineSegments)ft.setMode(N.LINES);else if(G.isLineLoop)ft.setMode(N.LINE_LOOP);else ft.setMode(N.LINE_STRIP)}else if(G.isPoints)ft.setMode(N.POINTS);else if(G.isSprite)ft.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(!nt.get("WEBGL_multi_draw")){let{_multiDrawStarts:Yt,_multiDrawCounts:ve,_multiDrawCount:rn}=G,Ke=Te?ae.get(Te).bytesPerElement:1,Tn=L.get(B).currentProgram.getUniforms();for(let Jn=0;Jn<rn;Jn++)Tn.setValue(N,"_gl_DrawID",Jn),ft.render(Yt[Jn]/Ke,ve[Jn])}else ft.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)ft.renderInstances(Ae,Lt,G.count);else if(W.isInstancedBufferGeometry){let Yt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,Yt);ft.renderInstances(Ae,Lt,ve)}else ft.render(Ae,Lt)};function vf(b,D,W,B){if(P!==null&&b.isNodeMaterial)P.setObject(B,b);if(Ze===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===Pn&&b.forceSinglePass===!1)b.side=Qt,b.needsUpdate=!0,Wo(b,D,B),b.side=qi,b.needsUpdate=!0,Wo(b,D,B),b.side=Pn;else Wo(b,D,B)}this.compile=function(b,D,W=null){if(W===null)W=b;if(P!==null)P.renderStart(b,D,W);if(M=fe.get(W),M.init(D),A.push(M),W.traverseVisible(function(G){if(G.isLight&&G.layers.test(D.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}}),b!==W)b.traverseVisible(function(G){if(G.isLight&&G.layers.test(D.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}});if(M.setupLights(),P!==null)P.updateLights(M.state.lightsArray);if(st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),Ze===!0)oe.setGlobalState(this.clippingPlanes,D);if(P!==null)Le.render(M.state.shadowsArray,W,D);let B=new Set;if(b.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let ge=G.material;if(ge)if(Array.isArray(ge))for(let be=0;be<ge.length;be++){let me=ge[be];vf(me,W,D,G),B.add(me)}else vf(ge,W,D,G),B.add(ge)}),M=A.pop(),P!==null)P.renderEnd();return B},this.compileAsync=function(b,D,W=null){let B=this.compile(b,D,W);return new Promise((G)=>{function ge(){if(B.forEach(function(be){let Te=L.get(be).currentProgram;if(Te===void 0||Te.isReady())B.delete(be)}),B.size===0){G(b);return}setTimeout(ge,10)}if(nt.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Bc=null;function mv(b){if(Bc)Bc(b)}function bf(){dr.stop()}function Sf(){dr.start()}let dr=new Gp;if(dr.setAnimationLoop(mv),typeof self<"u")dr.setContext(self);this.setAnimationLoop=function(b){Bc=b,pe.setAnimationLoop(b),b===null?dr.stop():dr.start()},pe.addEventListener("sessionstart",bf),pe.addEventListener("sessionend",Sf),this.render=function(b,D){if(D!==void 0&&D.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(P!==null)P.renderStart(b,D);let W=pe.enabled===!0&&pe.isPresenting===!0,B=_!==null&&(C===null||W)&&_.begin(S,C);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(D);D=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(S,b,D,C);if(M=fe.get(b,A.length),M.init(D),M.state.textureUnits=V.getTextureUnits(),A.push(M),Ye.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),ke.setFromProjectionMatrix(Ye,hu,D.reversedDepth),st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),v=Pe.get(b,T.length),v.init(),T.push(v),pe.enabled===!0&&pe.isPresenting===!0){let be=S.xr.getDepthSensingMesh();if(be!==null)Gc(be,D,-1/0,S.sortObjects)}if(Gc(b,D,0,S.sortObjects),v.finish(),P!==null)P.updateLights(M.state.lightsArray);if(S.sortObjects===!0)v.sort(se,xe);if(Dt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,Dt)De.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let G=M.state.shadowsArray;if(Le.render(G,b,D),Ze===!0)oe.endShadows();if((B&&_.hasRenderPass())===!1){let be=v.opaque,me=v.transmissive;if(M.setupLights(),D.isArrayCamera){let Te=D.cameras;if(me.length>0)for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re];wf(be,me,b,qe)}if(Dt)De.render(b);for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re];Mf(v,b,qe,qe.viewport)}}else{if(me.length>0)wf(be,me,b,D);if(Dt)De.render(b);Mf(v,b,D)}}if(C!==null&&q===0)V.updateMultisampleRenderTarget(C),V.updateRenderTargetMipmap(C);if(B)_.end(S);if(b.isScene===!0)b.onAfterRender(S,b,D);if(le.resetDefaultState(),X=-1,k=null,A.pop(),A.length>0){if(M=A[A.length-1],V.setTextureUnits(M.state.textureUnits),Ze===!0)oe.setGlobalState(S.clippingPlanes,M.state.camera)}else M=null;if(T.pop(),T.length>0)v=T[T.length-1];else v=null;if(P!==null)P.renderEnd()};function Gc(b,D,W,B){if(b.visible===!1)return;if(b.layers.test(D.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(D)}else if(b.isLightProbeGrid)M.pushLightProbeGrid(b);else if(b.isLight){if(M.pushLight(b),b.castShadow)M.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(ke)){if(B)yt.setFromMatrixPosition(b.matrixWorld).applyMatrix4(Ye);let be=j.update(b),me=b.material;if(me.visible)v.push(b,be,me,W,yt.z,null,D)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(ke)){let be=j.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();yt.copy(b.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();yt.copy(be.boundingSphere.center)}yt.applyMatrix4(b.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(me)){let Te=be.groups;for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re],Ae=me[qe.materialIndex];if(Ae&&Ae.visible)v.push(b,be,Ae,W,yt.z,qe,D)}}else if(me.visible)v.push(b,be,me,W,yt.z,null,D)}}}let ge=b.children;for(let be=0,me=ge.length;be<me;be++)Gc(ge[be],D,W,B)}function Mf(b,D,W,B){let{opaque:G,transmissive:ge,transparent:be}=b;if(M.setupLightsView(W),Ze===!0)oe.setGlobalState(S.clippingPlanes,W);if(B)w.viewport(Y.copy(B));if(G.length>0)$o(G,D,W);if(ge.length>0)$o(ge,D,W);if(be.length>0)$o(be,D,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function wf(b,D,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Ae=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new _n(1,1,{generateMipmaps:!0,type:Ae?si:$n,minFilter:ri,samples:Math.max(4,wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let ge=M.state.transmissionRenderTarget[B.id],be=B.viewport||Y;ge.setSize(be.z*S.transmissionResolutionScale,be.w*S.transmissionResolutionScale);let me=S.getRenderTarget(),Te=S.getActiveCubeFace(),Re=S.getActiveMipmapLevel();if(S.setRenderTarget(ge),S.getClearColor(ue),Fe=S.getClearAlpha(),Fe<1)S.setClearColor(16777215,0.5);if(S.clear(),Dt)De.render(W);let He=S.toneMapping;S.toneMapping=Hn;let qe=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(M.setupLightsView(B),Ze===!0)oe.setGlobalState(S.clippingPlanes,B);if($o(b,W,B),V.updateMultisampleRenderTarget(ge),V.updateRenderTargetMipmap(ge),nt.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let rt=0,Lt=D.length;rt<Lt;rt++){let vt=D[rt],{object:ft,geometry:Yt,material:ve,group:rn}=vt;if(ve.side===Pn&&ft.layers.test(B.layers)){let Ke=ve.side;ve.side=Qt,ve.needsUpdate=!0,Ef(ft,W,B,Yt,ve,rn),ve.side=Ke,ve.needsUpdate=!0,Ae=!0}}if(Ae===!0)V.updateMultisampleRenderTarget(ge),V.updateRenderTargetMipmap(ge)}if(S.setRenderTarget(me,Te,Re),S.setClearColor(ue,Fe),qe!==void 0)B.viewport=qe;S.toneMapping=He}function $o(b,D,W){let B=D.isScene===!0?D.overrideMaterial:null;for(let G=0,ge=b.length;G<ge;G++){let be=b[G],{object:me,geometry:Te,group:Re}=be,He=be.material;if(He.allowOverride===!0&&B!==null)He=B;if(me.layers.test(W.layers))Ef(me,D,W,Te,He,Re)}}function Ef(b,D,W,B,G,ge){if(P!==null&&G.isNodeMaterial)P.setObject(b,G);if(b.onBeforeRender(S,D,W,B,G,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),G.onBeforeRender(S,D,W,B,b,ge),G.transparent===!0&&G.side===Pn&&G.forceSinglePass===!1)G.side=Qt,G.needsUpdate=!0,S.renderBufferDirect(W,D,B,G,b,ge),G.side=qi,G.needsUpdate=!0,S.renderBufferDirect(W,D,B,G,b,ge),G.side=Pn;else S.renderBufferDirect(W,D,B,G,b,ge);b.onAfterRender(S,D,W,B,G,ge)}function Wo(b,D,W){if(D.isScene!==!0)D=cn;let B=L.get(b),G=M.state.lights,ge=M.state.shadowsArray,be=G.state.version,me=te.getParameters(b,G.state,ge,D,W,M.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Re=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?D.environment:null,B.fog=D.fog;let He=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,He),B.envMapRotation=B.environment!==null&&b.envMap===null?D.environmentRotation:b.envMapRotation,Re===void 0)b.addEventListener("dispose",Kn),Re=new Map,B.programs=Re;let qe=Re.get(Te);if(qe!==void 0){if(B.currentProgram===qe&&B.lightsStateVersion===be)return Af(b,me),qe}else{if(me.uniforms=te.getUniforms(b),P!==null&&b.isNodeMaterial)P.build(b,W,me);b.onBeforeCompile(me,S),qe=te.acquireProgram(me,Te),Re.set(Te,qe),B.uniforms=me.uniforms}let Ae=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Ae.clippingPlanes=oe.uniform;if(Af(b,me),B.needsLights=yv(b),B.lightsStateVersion=be,B.needsLights)Ae.ambientLightColor.value=G.state.ambient,Ae.lightProbe.value=G.state.probe,Ae.sunLights.value=G.state.sun,Ae.sunLightShadows.value=G.state.sunShadow,Ae.directionalLights.value=G.state.directional,Ae.directionalLightShadows.value=G.state.directionalShadow,Ae.spotLights.value=G.state.spot,Ae.spotLightShadows.value=G.state.spotShadow,Ae.rectAreaLights.value=G.state.rectArea,Ae.ltc_1.value=G.state.rectAreaLTC1,Ae.ltc_2.value=G.state.rectAreaLTC2,Ae.pointLights.value=G.state.point,Ae.pointLightShadows.value=G.state.pointShadow,Ae.hemisphereLights.value=G.state.hemi,Ae.sunShadowMatrix.value=G.state.sunShadowMatrix,Ae.sunShadowCascade.value=G.state.sunShadowCascade,Ae.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ae.spotLightMatrix.value=G.state.spotLightMatrix,Ae.spotLightMap.value=G.state.spotLightMap,Ae.pointShadowMatrix.value=G.state.pointShadowMatrix;return B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=qe,B.uniformsList=null,qe}function Tf(b){if(b.uniformsList===null){let D=b.currentProgram.getUniforms();b.uniformsList=po.seqWithValue(D.seq,b.uniforms)}return b.uniformsList}function Af(b,D){let W=L.get(b);W.outputColorSpace=D.outputColorSpace,W.batching=D.batching,W.batchingColor=D.batchingColor,W.instancing=D.instancing,W.instancingColor=D.instancingColor,W.instancingMorph=D.instancingMorph,W.skinning=D.skinning,W.morphTargets=D.morphTargets,W.morphNormals=D.morphNormals,W.morphColors=D.morphColors,W.morphTargetsCount=D.morphTargetsCount,W.numClippingPlanes=D.numClippingPlanes,W.numIntersection=D.numClipIntersection,W.vertexAlphas=D.vertexAlphas,W.vertexTangents=D.vertexTangents,W.toneMapping=D.toneMapping}function gv(b,D){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;R.setFromMatrixPosition(D.matrixWorld);for(let W=0,B=b.length;W<B;W++){let G=b[W];if(G.texture!==null&&G.boundingBox.containsPoint(R))return G}return null}function _v(b,D,W,B,G){if(D.isScene!==!0)D=cn;V.resetTextureUnits();let ge=D.fog,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?D.environment:null,me=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:$e.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Re=ie.get(B.envMap||be,Te),He=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,qe=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ae=!!W.morphAttributes.position,rt=!!W.morphAttributes.normal,Lt=!!W.morphAttributes.color,vt=Hn;if(B.toneMapped){if(C===null||C.isXRRenderTarget===!0)vt=S.toneMapping}let ft=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Yt=ft!==void 0?ft.length:0,ve=L.get(B),rn=M.state.lights;if(Ze===!0){if(st===!0||b!==k){let gt=b===k&&B.id===X;oe.setState(B,b,gt)}}let Ke=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==rn.state.version)Ke=!0;else if(ve.outputColorSpace!==me)Ke=!0;else if(G.isBatchedMesh&&ve.batching===!1)Ke=!0;else if(!G.isBatchedMesh&&ve.batching===!0)Ke=!0;else if(G.isBatchedMesh&&ve.batchingColor===!0&&G._colorsTexture===null)Ke=!0;else if(G.isBatchedMesh&&ve.batchingColor===!1&&G._colorsTexture!==null)Ke=!0;else if(G.isInstancedMesh&&ve.instancing===!1)Ke=!0;else if(!G.isInstancedMesh&&ve.instancing===!0)Ke=!0;else if(G.isSkinnedMesh&&ve.skinning===!1)Ke=!0;else if(!G.isSkinnedMesh&&ve.skinning===!0)Ke=!0;else if(G.isInstancedMesh&&ve.instancingColor===!0&&G.instanceColor===null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingColor===!1&&G.instanceColor!==null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingMorph===!0&&G.morphTexture===null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingMorph===!1&&G.morphTexture!==null)Ke=!0;else if(ve.envMap!==Re)Ke=!0;else if(B.fog===!0&&ve.fog!==ge)Ke=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))Ke=!0;else if(ve.vertexAlphas!==He)Ke=!0;else if(ve.vertexTangents!==qe)Ke=!0;else if(ve.morphTargets!==Ae)Ke=!0;else if(ve.morphNormals!==rt)Ke=!0;else if(ve.morphColors!==Lt)Ke=!0;else if(ve.toneMapping!==vt)Ke=!0;else if(ve.morphTargetsCount!==Yt)Ke=!0;else if(!!ve.lightProbeGrid!==M.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,ve.__version=B.version;let Tn=ve.currentProgram;if(Ke===!0){if(Tn=Wo(B,D,G),P&&B.isNodeMaterial)P.onUpdateProgram(B,Tn,ve)}let Jn=!1,Ui=!1,kr=!1,lt=Tn.getUniforms(),Ct=ve.uniforms;if(w.useProgram(Tn.program))Jn=!0,Ui=!0,kr=!0;if(B.id!==X)X=B.id,Ui=!0;if(ve.needsLights){let gt=gv(M.state.lightProbeGridArray,G);if(ve.lightProbeGrid!==gt)ve.lightProbeGrid=gt,Ui=!0}if(Jn||k!==b){if(w.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();lt.setValue(N,"projectionMatrix",b.projectionMatrix),lt.setValue(N,"viewMatrix",b.matrixWorldInverse);let zi=lt.map.cameraPosition;if(zi!==void 0)zi.setValue(N,Zt.setFromMatrixPosition(b.matrixWorld));if(wt.logarithmicDepthBuffer)lt.setValue(N,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)lt.setValue(N,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ui=!0,kr=!0}if(ve.needsLights){if(rn.state.sunShadowMap.length>0)lt.setValue(N,"sunShadowMap",rn.state.sunShadowMap,V);if(rn.state.directionalShadowMap.length>0)lt.setValue(N,"directionalShadowMap",rn.state.directionalShadowMap,V);if(rn.state.spotShadowMap.length>0)lt.setValue(N,"spotShadowMap",rn.state.spotShadowMap,V);if(rn.state.pointShadowMap.length>0)lt.setValue(N,"pointShadowMap",rn.state.pointShadowMap,V)}if(G.isSkinnedMesh){lt.setOptional(N,G,"bindMatrix"),lt.setOptional(N,G,"bindMatrixInverse");let gt=G.skeleton;if(gt){if(gt.boneTexture===null)gt.computeBoneTexture();lt.setValue(N,"boneTexture",gt.boneTexture,V)}}if(G.isBatchedMesh){if(lt.setOptional(N,G,"batchingTexture"),lt.setValue(N,"batchingTexture",G._matricesTexture,V),lt.setOptional(N,G,"batchingIdTexture"),lt.setValue(N,"batchingIdTexture",G._indirectTexture,V),lt.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null)lt.setValue(N,"batchingColorTexture",G._colorsTexture,V)}let Fi=W.morphAttributes;if(Fi.position!==void 0||Fi.normal!==void 0||Fi.color!==void 0)Qe.update(G,W,Tn);if(Ui||ve.receiveShadow!==G.receiveShadow)ve.receiveShadow=G.receiveShadow,lt.setValue(N,"receiveShadow",G.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&D.environment!==null)Ct.envMapIntensity.value=D.environmentIntensity;if(Ct.dfgLUT!==void 0)Ct.dfgLUT.value=fT();if(Ui){if(lt.setValue(N,"toneMappingExposure",S.toneMappingExposure),ve.needsLights)xv(Ct,kr);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ct,ge);if(_e.refreshMaterialUniforms(Ct,B,re,Z,M.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let gt=ve.lightProbeGrid;Ct.probesSH.value=gt.texture,Ct.probesMin.value.copy(gt.boundingBox.min),Ct.probesMax.value.copy(gt.boundingBox.max),Ct.probesResolution.value.copy(gt.resolution)}po.upload(N,Tf(ve),Ct,V)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)po.upload(N,Tf(ve),Ct,V),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)lt.setValue(N,"center",G.center);if(lt.setValue(N,"modelViewMatrix",G.modelViewMatrix),lt.setValue(N,"normalMatrix",G.normalMatrix),lt.setValue(N,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){let gt=B.uniformsGroups;for(let zi=0,Br=gt.length;zi<Br;zi++){let Cf=gt[zi];ye.update(Cf,Tn),ye.bind(Cf,Tn)}}return Tn}function xv(b,D){b.ambientLightColor.needsUpdate=D,b.lightProbe.needsUpdate=D,b.sunLights.needsUpdate=D,b.sunLightShadows.needsUpdate=D,b.directionalLights.needsUpdate=D,b.directionalLightShadows.needsUpdate=D,b.pointLights.needsUpdate=D,b.pointLightShadows.needsUpdate=D,b.spotLights.needsUpdate=D,b.spotLightShadows.needsUpdate=D,b.rectAreaLights.needsUpdate=D,b.hemisphereLights.needsUpdate=D}function yv(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(b,D,W){let B=L.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;L.get(b.texture).__webglTexture=D,L.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,D){let W=L.get(b);W.__webglFramebuffer=D,W.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(b,D=0,W=0){C=b,H=D,q=W;let B=null,G=!1,ge=!1;if(b){let me=L.get(b);if(me.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(N.FRAMEBUFFER,me.__webglFramebuffer),Y.copy(b.viewport),Q.copy(b.scissor),Se=b.scissorTest,w.viewport(Y),w.scissor(Q),w.setScissorTest(Se),X=-1;return}else if(me.__webglFramebuffer===void 0)V.setupRenderTarget(b);else if(me.__hasExternalTextures)V.rebindTextures(b,L.get(b.texture).__webglTexture,L.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let He=b.depthTexture;if(me.__boundDepthTexture!==He){if(He!==null&&L.has(He)&&(b.width!==He.image.width||b.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Re=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Re[D]))B=Re[D][W];else B=Re[D];G=!0}else if(b.samples>0&&V.useMultisampledRTT(b)===!1)B=L.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Re))B=Re[W];else B=Re;Y.copy(b.viewport),Q.copy(b.scissor),Se=b.scissorTest}else Y.copy(we).multiplyScalar(re).floor(),Q.copy(Ee).multiplyScalar(re).floor(),Se=xt;if(W!==0)B=F;if(w.bindFramebuffer(N.FRAMEBUFFER,B))w.drawBuffers(b,B);if(w.viewport(Y),w.scissor(Q),w.setScissorTest(Se),G){let me=L.get(b.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+D,me.__webglTexture,W)}else if(ge){let me=D;for(let Te=0;Te<b.textures.length;Te++){let Re=L.get(b.textures[Te]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Te,Re.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=L.get(b.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,me.__webglTexture,W)}X=-1};function Rf(b){let D=L.get(b);if(D.__readFormat!==b.format||D.__readType!==b.type)D.__readFormat=b.format,D.__readType=b.type,D.__formatReadable=wt.textureFormatReadable(b.format),D.__typeReadable=wt.textureTypeReadable(b.type);return D}if(this.readRenderTargetPixels=function(b,D,W,B,G,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te){w.bindFramebuffer(N.FRAMEBUFFER,Te);try{let Re=b.textures[me],{format:He,type:qe}=Re;if(b.textures.length>1)N.readBuffer(N.COLOR_ATTACHMENT0+me);let Ae=Rf(Re);if(Ae.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ae.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=b.width-B&&(W>=0&&W<=b.height-G))N.readPixels(D,W,B,G,K.convert(He),K.convert(qe),ge)}finally{let Re=C!==null?L.get(C).__webglFramebuffer:null;w.bindFramebuffer(N.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(b,D,W,B,G,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te)if(D>=0&&D<=b.width-B&&(W>=0&&W<=b.height-G)){w.bindFramebuffer(N.FRAMEBUFFER,Te);let Re=b.textures[me],{format:He,type:qe}=Re;if(b.textures.length>1)N.readBuffer(N.COLOR_ATTACHMENT0+me);let Ae=Rf(Re);if(Ae.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ae.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let rt=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,rt),N.bufferData(N.PIXEL_PACK_BUFFER,ge.byteLength,N.STREAM_READ),N.readPixels(D,W,B,G,K.convert(He),K.convert(qe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let Lt=C!==null?L.get(C).__webglFramebuffer:null;w.bindFramebuffer(N.FRAMEBUFFER,Lt);let vt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await lp(N,vt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,rt),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ge),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(rt),N.deleteSync(vt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,D=null,W=0){let B=Math.pow(2,-W),G=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),be=D!==null?D.x:0,me=D!==null?D.y:0;V.setTexture2D(b,0),N.copyTexSubImage2D(N.TEXTURE_2D,W,0,0,be,me,G,ge),w.unbindTexture()},this.copyTextureToTexture=function(b,D,W=null,B=null,G=0,ge=0){let be,me,Te,Re,He,qe,Ae,rt,Lt,vt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)be=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Re=W.min.x,He=W.min.y,qe=W.isBox3?W.min.z:0;else{let Ct=Math.pow(2,-G);if(be=Math.floor(vt.width*Ct),me=Math.floor(vt.height*Ct),b.isDataArrayTexture)Te=vt.depth;else if(b.isData3DTexture)Te=Math.floor(vt.depth*Ct);else Te=1;Re=0,He=0,qe=0}if(B!==null)Ae=B.x,rt=B.y,Lt=B.z;else Ae=0,rt=0,Lt=0;let ft=K.convert(D.format),Yt=K.convert(D.type),ve;if(D.isData3DTexture)V.setTexture3D(D,0),ve=N.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),ve=N.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),ve=N.TEXTURE_2D;w.activeTexture(N.TEXTURE0),w.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,D.flipY),w.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),w.pixelStorei(N.UNPACK_ALIGNMENT,D.unpackAlignment);let rn=w.getParameter(N.UNPACK_ROW_LENGTH),Ke=w.getParameter(N.UNPACK_IMAGE_HEIGHT),Tn=w.getParameter(N.UNPACK_SKIP_PIXELS),Jn=w.getParameter(N.UNPACK_SKIP_ROWS),Ui=w.getParameter(N.UNPACK_SKIP_IMAGES);w.pixelStorei(N.UNPACK_ROW_LENGTH,vt.width),w.pixelStorei(N.UNPACK_IMAGE_HEIGHT,vt.height),w.pixelStorei(N.UNPACK_SKIP_PIXELS,Re),w.pixelStorei(N.UNPACK_SKIP_ROWS,He),w.pixelStorei(N.UNPACK_SKIP_IMAGES,qe);let kr=b.isDataArrayTexture||b.isData3DTexture,lt=D.isDataArrayTexture||D.isData3DTexture;if(b.isDepthTexture){let Ct=L.get(b),Fi=L.get(D),gt=L.get(Ct.__renderTarget),zi=L.get(Fi.__renderTarget);w.bindFramebuffer(N.READ_FRAMEBUFFER,gt.__webglFramebuffer),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,zi.__webglFramebuffer);for(let Br=0;Br<Te;Br++){if(kr)N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,L.get(b).__webglTexture,G,qe+Br),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,L.get(D).__webglTexture,ge,Lt+Br);N.blitFramebuffer(Re,He,be,me,Ae,rt,be,me,N.DEPTH_BUFFER_BIT,N.NEAREST)}w.bindFramebuffer(N.READ_FRAMEBUFFER,null),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||b.isRenderTargetTexture||L.has(b)){let Ct=L.get(b),Fi=L.get(D);w.bindFramebuffer(N.READ_FRAMEBUFFER,ee),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,I);for(let gt=0;gt<Te;gt++){if(kr)N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ct.__webglTexture,G,qe+gt);else N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ct.__webglTexture,G);if(lt)N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Fi.__webglTexture,ge,Lt+gt);else N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Fi.__webglTexture,ge);if(G!==0)N.blitFramebuffer(Re,He,be,me,Ae,rt,be,me,N.COLOR_BUFFER_BIT,N.NEAREST);else if(lt)N.copyTexSubImage3D(ve,ge,Ae,rt,Lt+gt,Re,He,be,me);else N.copyTexSubImage2D(ve,ge,Ae,rt,Re,He,be,me)}w.bindFramebuffer(N.READ_FRAMEBUFFER,null),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(lt)if(b.isDataTexture||b.isData3DTexture)N.texSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,Yt,vt.data);else if(D.isCompressedArrayTexture)N.compressedTexSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,vt.data);else N.texSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,Yt,vt);else if(b.isDataTexture)N.texSubImage2D(N.TEXTURE_2D,ge,Ae,rt,be,me,ft,Yt,vt.data);else if(b.isCompressedTexture)N.compressedTexSubImage2D(N.TEXTURE_2D,ge,Ae,rt,vt.width,vt.height,ft,vt.data);else N.texSubImage2D(N.TEXTURE_2D,ge,Ae,rt,be,me,ft,Yt,vt);if(w.pixelStorei(N.UNPACK_ROW_LENGTH,rn),w.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(N.UNPACK_SKIP_PIXELS,Tn),w.pixelStorei(N.UNPACK_SKIP_ROWS,Jn),w.pixelStorei(N.UNPACK_SKIP_IMAGES,Ui),ge===0&&D.generateMipmaps)N.generateMipmap(ve);w.unbindTexture()},this.initRenderTarget=function(b){if(L.get(b).__webglFramebuffer===void 0)V.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)V.setTextureCube(b,0);else if(b.isData3DTexture)V.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)V.setTexture2DArray(b,0);else V.setTexture2D(b,0);w.unbindTexture()},this.resetState=function(){H=0,q=0,C=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}var nm={type:"change"},Wu={type:"start"},rm={type:"end"},tc=new Ki,im=new Rn,dT=Math.cos(70*js.DEG2RAD),Bt=new O,fn=2*Math.PI,ct={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$u=0.000001;class Zu extends Ya{constructor(e,t=null){super(e,t);if(this.state=ct.NONE,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Zi.ROTATE,MIDDLE:Zi.DOLLY,RIGHT:Zi.PAN},this.touches={ONE:Xi.ROTATE,TWO:Xi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new O,this._lastQuaternion=new Ht,this._lastTargetPosition=new O,this._quat=new Ht().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lo,this._sphericalDelta=new lo,this._scale=1,this._panOffset=new O,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new O,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mT.bind(this),this._onPointerDown=pT.bind(this),this._onPointerUp=gT.bind(this),this._onContextMenu=MT.bind(this),this._onMouseWheel=yT.bind(this),this._onKeyDown=vT.bind(this),this._onTouchStart=bT.bind(this),this._onTouchMove=ST.bind(this),this._onMouseDown=_T.bind(this),this._onMouseMove=xT.bind(this),this._interceptControlDown=wT.bind(this),this._interceptControlUp=ET.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ct.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(nm),this.update(),this.state=ct.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Bt.copy(t).sub(this.target),Bt.applyQuaternion(this._quat),this._spherical.setFromVector3(Bt),this.autoRotate&&this.state===ct.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=fn;else if(n>Math.PI)n-=fn;if(i<-Math.PI)i+=fn;else if(i>Math.PI)i-=fn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Bt.setFromSpherical(this._spherical),Bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Bt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new O(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new O(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(tc.origin.copy(this.object.position),tc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(tc.direction))<dT)this.object.lookAt(this.target);else im.setFromNormalAndCoplanarPoint(this.object.up,this.target),tc.intersectPlane(im,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>$u||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$u||this._lastTargetPosition.distanceToSquared(this.target)>$u)return this.dispatchEvent(nm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return fn/60*this.autoRotateSpeed*e;else return fn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bt.setFromMatrixColumn(t,0),Bt.multiplyScalar(-e),this._panOffset.add(Bt)}_panUp(e,t){if(this.screenSpacePanning===!0)Bt.setFromMatrixColumn(t,1);else Bt.setFromMatrixColumn(t,0),Bt.crossVectors(this.object.up,Bt);Bt.multiplyScalar(e),this._panOffset.add(Bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Bt.copy(i).sub(this.target);let r=Bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function pT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function mT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function gT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(rm),this.state=ct.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function _T(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Zi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=ct.DOLLY;break;case Zi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}break;case Zi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Wu)}function xT(e){switch(this.state){case ct.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case ct.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case ct.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function yT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==ct.NONE)return;e.preventDefault(),this.dispatchEvent(Wu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(rm)}function vT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function bT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=ct.TOUCH_ROTATE;break;case Xi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=ct.TOUCH_PAN;break;default:this.state=ct.NONE}break;case 2:switch(this.touches.TWO){case Xi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=ct.TOUCH_DOLLY_PAN;break;case Xi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=ct.TOUCH_DOLLY_ROTATE;break;default:this.state=ct.NONE}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Wu)}function ST(e){switch(this._trackPointer(e),this.state){case ct.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case ct.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case ct.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case ct.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=ct.NONE}}function MT(e){if(this.enabled===!1)return;e.preventDefault()}function wT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function ET(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Xu extends ds{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Qi;e.deleteAttribute("uv");let t=new Ci({side:Qt}),n=new Ci,i=new ys(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new _t(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ms(e,n,6),o=new ut;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new _t(e,ws(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new _t(e,ws(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new _t(e,ws(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new _t(e,ws(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new _t(e,ws(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new _t(e,ws(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function ws(e){return new Ha({color:0,emissive:16777215,emissiveIntensity:e})}function qu(e,t){if(t===au)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===fs||t===qs){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===fs)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function sm(e){let t=new Map,n=new Map,i=e.clone();return om(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function om(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)om(e.children[i],t.children[i],n)}class th extends Ii{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new pm(t)}),this.register(function(t){return new mm(t)}),this.register(function(t){return new wm(t)}),this.register(function(t){return new Em(t)}),this.register(function(t){return new Tm(t)}),this.register(function(t){return new _m(t)}),this.register(function(t){return new xm(t)}),this.register(function(t){return new ym(t)}),this.register(function(t){return new vm(t)}),this.register(function(t){return new dm(t)}),this.register(function(t){return new bm(t)}),this.register(function(t){return new gm(t)}),this.register(function(t){return new Mm(t)}),this.register(function(t){return new Sm(t)}),this.register(function(t){return new hm(t)}),this.register(function(t){return new Ju(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ju(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Am(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=rr.extractUrlBase(e);s=rr.resolveURL(c,this.path)}else s=rr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new ao(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Rm){try{s[Xe.KHR_BINARY_GLTF]=new Cm(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Dm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new fm;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Pm(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new Im;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Lm;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function TT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Pt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class hm{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new vs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ys(l),c.distance=u;break;case"spot":c=new Xa(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ui(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class fm{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return ai}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Yi))}return Promise.all(i)}}class dm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class pm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class gm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class _m{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Yi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class xm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class ym{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class vm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class bm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Yi));return Promise.all(i)}}class Sm{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class wm{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Em{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Tm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Ju{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Am{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Ln.TRIANGLES&&c.mode!==Ln.TRIANGLE_STRIP&&c.mode!==Ln.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new O,p=new Ht,m=new O(1,1,1),E=new ms(d.geometry,d.material,f);for(let v=0;v<f;v++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)m.fromBufferAttribute(a.SCALE,v);E.setMatrixAt(v,g.compose(x,p,m))}let R=null;for(let v in a)if(v==="_COLOR_0"){let M=a[v];E.instanceColor=new Wi(M.array,M.itemSize,M.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(R===null){let T=E.geometry;R=new en,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let M=a[v];R.setAttribute(v,new Wi(M.array,M.itemSize,M.normalized))}ut.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Rm="glTF",go=12,am={JSON:1313821514,BIN:5130562};class Cm{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,go),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Rm)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-go,r=new DataView(e,go),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===am.JSON){let c=new Uint8Array(e,go+s,o);this.content=n.decode(c)}else if(a===am.BIN){let c=go+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Pm{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Qu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Qu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=Es[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class Im{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Lm{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class nh extends Pi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let v=s[g+R+o],M=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*v+E*M+x*T+p*A}return r}}var AT=new Ht;class Nm extends nh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return AT.fromArray(r).normalize().toArray(r),r}}var Ln={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Es={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},cm={9728:Vn,9729:$t,9984:Ma,9985:us,9986:br,9987:ri},lm={33071:ls,33648:Sa,10497:cs},ju={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},sr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},RT={CUBICSPLINE:void 0,LINEAR:Pa,STEP:ou},Yu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function CT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ci({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:qi});return e.DefaultMaterial}function Ir(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ui(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function PT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function IT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function LT(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Ku(n.attributes);else t=e.indices+":"+Ku(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Ku(e.targets[i]);return t}function Ku(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function eh(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function NT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var DT=new Ge;class Dm{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new TT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new _s(this.options.manager);else this.textureLoader=new qa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ao(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Ir(r,o,i),ui(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(rr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=ju[i.type],o=Es[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Vt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=ju[i.type],c=Es[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new Js(g,h/l),t.cache.add(m,E);x=new ps(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Vt(g,a,d)}if(i.sparse!==void 0){let p=ju.SCALAR,m=Es[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,v=new m(s[1],E,i.sparse.count*p),M=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Vt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=v.length;T<A;T++){let _=v[T];if(x.setX(_,M[T*a]),a>=2)x.setY(_,M[T*a+1]);if(a>=3)x.setZ(_,M[T*a+2]);if(a>=4)x.setW(_,M[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=cm[f.magFilter]||$t,l.minFilter=cm[f.minFilter]||ri,l.wrapS=lm[f.wrapS]||cs,l.wrapT=lm[f.wrapT]||cs,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Vn&&l.minFilter!==$t,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new At(g);x.needsUpdate=!0,f(x)};t.load(rr.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ui(u,s),u.userData.mimeType=s.mimeType||NT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ro,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new io,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Ci}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Yi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Pn;let l=r.alphaMode||Yu.OPAQUE;if(l===Yu.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Yu.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==ai){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==ai)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Yi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ui(u,r),t.associations.set(u,{materials:e}),r.extensions)Ir(i,u,r);return u})}createUniqueName(e){let t=et.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return um(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=LT(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=um(new en,c,t);if(c.mode===Ln.TRIANGLE_STRIP)f=f.then((h)=>qu(h,qs));else if(c.mode===Ln.TRIANGLE_FAN)f=f.then((h)=>qu(h,fs));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?CT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===Ln.TRIANGLES||x.mode===Ln.TRIANGLE_STRIP||x.mode===Ln.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new Fa(g,m):new _t(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===Ln.LINES)p=new za(g,m);else if(x.mode===Ln.LINE_STRIP)p=new Ji(g,m);else if(x.mode===Ln.LINE_LOOP)p=new ka(g,m);else if(x.mode===Ln.POINTS)p=new gs(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)IT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ui(p,r),x.extensions)Ir(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Ir(i,u[0],r);return u[0]}let f=new ei;if(r.extensions)Ir(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ut(js.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Cr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return ui(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new to(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let v=f[E],M=h[E],T=d[E],A=g[E],_=x[E];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let S=n._createAnimationTracks(v,M,T,A,_);if(S)for(let z=0;z<S.length;z++)p.push(S[z])}let m=new rs(r,void 0,p);return ui(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,DT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new O().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Qs;else if(c.length>1)l=new ei;else if(c.length===1)l=c[0];else l=new ut;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ui(l,r),r.extensions)Ir(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ei;if(n.name)r.name=i.createUniqueName(n.name);if(ui(r,n),n.extensions)Ir(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(sm(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof hn||f instanceof At)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(sr[r.path]===sr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(sr[r.path]){case sr.weights:l=tr;break;case sr.rotation:l=nr;break;case sr.translation:case sr.scale:l=Rr;break;default:switch(n.itemSize){case 1:l=tr;break;case 2:case 3:default:l=Rr;break}break}let u=i.interpolation!==void 0?RT[i.interpolation]:Pa,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+sr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=eh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof nr?Nm:nh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function OT(e,t,n){let i=t.attributes,r=new Ft;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new O(c[0],c[1],c[2]),new O(l[0],l[1],l[2])),a.normalized){let u=eh(Es[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new O,c=new O;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=eh(Es[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function um(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Qu[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return ui(e,t),OT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?PT(e,t.targets,n):e})}function xo(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function rh(e,t="|"){return e.map((n)=>ah(n)).join(t)}function yo(e,t){if(typeof t==="bigint")return t.toString();return t}class Om{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function vo(e){return new Om(e)}function Um(e){return e===null||e===void 0}function nc(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Fm(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Nn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Li(e){return bo(e._zod.def)??e._zod.def.shape}function zm(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Nn(this,t,i),i},enumerable:!0,configurable:!0})}function km(e,t,n){if(t in e)Nn(e,t,n);else e[t]=n}function Lr(e,t,n,i){let r=Li(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)zm(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else km(e,s,i?i(o.value,s):o.value)}}function UT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)zm(e,n,()=>t[n]);else km(e,n,i.value)}}function bn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Bm(e){return JSON.stringify(e)}function Gm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var sh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ts(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Hm=vo(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Nr(e){if(Ts(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Ts(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function oh(e){if(Nr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Vm=new Set(["string","number","symbol"]);function ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function ah(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function $m(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var ic=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ch={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function FT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Lr(s,e,rc(e,t)),hi(e,bn(n,{shape:s,checks:[]}))}function rc(e,t){let n=Li(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function zT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(rc(e,t)),o={};return Lr(o,e,Reflect.ownKeys(Li(e)).filter((a)=>!s.has(a))),hi(e,bn(n,{shape:o,checks:[]}))}function kT(e,t){if(!Nr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Li(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return hi(e,bn(e._zod.def,{shape:Wm(e,t)}))}function Wm(e,t){let n={};return Lr(n,e,Reflect.ownKeys(Li(e))),UT(n,t),n}function BT(e,t){if(!Nr(t))throw Error("Invalid input to safeExtend: expected a plain object");return hi(e,bn(e._zod.def,{shape:Wm(e,t)}))}function GT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Lr(n,e,Reflect.ownKeys(Li(e))),Lr(n,t,Reflect.ownKeys(Li(t)));let i=bn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return hi(e,i)}function Zm(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(rc(t,n)):void 0,c={};return Lr(c,t,Reflect.ownKeys(Li(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),hi(t,bn(t._zod.def,{shape:c,checks:[]}))}function HT(e,t,n){let i=n?new Set(rc(t,n)):void 0,r={};return Lr(r,t,Reflect.ownKeys(Li(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),hi(t,bn(t._zod.def,{shape:r}))}function fi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Xm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function cr(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function _o(e){return typeof e==="string"?e:e?.message}function lh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function di(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:_o(e.inst?._zod.def?.error?.(e))??_o(s?.(e))??_o(t?.error?.(e))??_o(n.customError?.(e))??_o(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var VT=/[\uD800-\uDBFF]/;function sc(e){let t=e.length;if(!VT.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function oc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function qm(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Dr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function jm(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else $T(e,n,i.value)}}function Ni(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ac(e,t,n){return Ni(e,t,n,!1)}function Ym(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ni(this,n,i(this))},set(r){Ni(this,n,r)}})}return t}function $T(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ni(this,t,n.bind(this))},set(i){Ni(this,t,i)}})}function WT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var ih,or=!1,ZT={configurable:!0,get(){or=!0;return}};function tt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&ih!==e._zod){ih=void 0;return}ih=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,ZT);let r=or;or=!1;try{let s=n(this);if(or)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return or=or||r,s}catch(s){throw delete this[t],or=or||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function XT(e,t,n,i){let r=WT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var qT="~constantCatch";function Km(e){let t=()=>e;return t[qT]=!0,t}var Jm;var uh={value:void 0,enumerable:!1},Qm="captureStackTrace"in Error?Error:null;function jT(e){let t=Qm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Qm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){uh.value=new s(d);try{Object.defineProperty(h,"_zod",uh)}finally{uh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),jm(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?jT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class pi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class So extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Jm=globalThis).__zod_globalConfig??(Jm.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Sn(e){if(e)Object.assign(dn,e);return dn}function YT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yo,2)),e.message}function KT(e){this._zod.message=e}var JT={get:YT,set:KT,enumerable:!0,configurable:!0},fh={value:void 0,enumerable:!1},eg=new WeakSet([Object.prototype,Error.prototype]),tg=(e,t)=>{e.name="$ZodError",fh.value=t,Object.defineProperty(e,"issues",fh),fh.value=void 0,Object.defineProperty(e,"message",JT);let n=Object.getPrototypeOf(e);if(!eg.has(n))eg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},ng=J("$ZodError",tg),jI=J("$ZodError",tg,void 0,{Parent:Error});function QT(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function ig(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)QT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function rg(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function cc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var lc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new pi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw sh(c,s?.callee??t),c}return a.value};return t};var uc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw sh(c,s?.callee??t),c}return a.value};return t};var hc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new pi;return s.issues.length?sg(e,s.issues,r):{success:!0,data:s.value}};function sg(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>di(r,n,Sn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var fc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?sg(e,s.issues,r):{success:!0,data:s.value}};var eA=Symbol.for("zod.compile.invalid"),tA=Symbol.for("zod.compile.fallback"),dh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==eA)return!0;if(i.definite===!0&&n===void 0)return!1}return nA(e,t,n)};function nA(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[tA]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new pi;return s.issues.length===0}var ph=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},og=(e)=>{let t=lc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,cc(n,o))};return n};var ag=(e)=>{let t=lc(e),n=(i,r,s,o)=>t(i,r,s,cc(n,o));return n};var cg=(e)=>{let t=uc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,cc(n,o))};return n};var lg=(e)=>{let t=uc(e),n=async(i,r,s,o)=>await t(i,r,s,cc(n,o));return n};var ug=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return hc(e)(t,n,r)};var hg=(e)=>(t,n,i)=>hc(e)(t,n,i);var fg=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return fc(e)(t,n,r)};var dg=(e)=>async(t,n,i)=>fc(e)(t,n,i);var pg=/^[cC][0-9a-z]{6,}$/,mg=/^[0-9a-z]+$/,gg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_g=/^[0-9a-vA-V]{20}$/,xg=/^[A-Za-z0-9]{27}$/,yg=/^[a-zA-Z0-9_-]{21}$/;function vg(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var bg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Sg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,gh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Mg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var iA="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function wg(){return new RegExp(iA,"u")}var Eg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ag=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Rg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Cg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ig=/^https?$/,Lg=/^\+[1-9]\d{6,14}$/;var Ng="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function rA(e){return new RegExp(`^${e}$`)}var Dg=rA(Ng);function mh(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Og(e){return new RegExp(`^${mh(e)}$`)}function Ug(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${mh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${mh({precision:e.precision})}`:n;return new RegExp(`^${Ng}T(?:${i})$`)}var Fg=/^[\s\S]{0,}$/;var _h=/^-?\d+$/,Mo=/^-?\d+(?:\.\d+)?$/,zg=/^(?:true|false)$/i;var kg=/^[^A-Z]*$/,Bg=/^[^a-z]*$/;var Xt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var xh=(e)=>{let t=e.value;return!Um(t)&&t.length!==void 0},dc={number:"number",bigint:"bigint",object:"date"},yh=J("$ZodCheckLessThan",(e,t)=>{Xt.init(e,t);let n=dc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:dc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vh=J("$ZodCheckGreaterThan",(e,t)=>{Xt.init(e,t);let n=dc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:dc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gg=J("$ZodCheckMultipleOf",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Fm(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Hg=J("$ZodCheckNumberFormat",(e,t)=>{Xt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=ic[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Vg=J("$ZodCheckMaxLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?sc(r):s)<=t.maximum)return;let a=oc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$g=J("$ZodCheckMinLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?sc(r):s)>=t.minimum)return;let a=oc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Wg=J("$ZodCheckLengthEquals",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?sc(r):s;if(o===t.length)return;let a=oc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Eo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Xt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Zg=J("$ZodCheckRegex",(e,t)=>{Eo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Xg=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kg),Eo.init(e,t)}),qg=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Bg),Eo.init(e,t)}),jg=J("$ZodCheckIncludes",(e,t)=>{Xt.init(e,t);let n=ar(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Yg=J("$ZodCheckStartsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`^${ar(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Kg=J("$ZodCheckEndsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`.*${ar(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Jg=J("$ZodCheckOverwrite",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class bh{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
`).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
${t.join(`
`)}
-};`)(...Object.values(this.closed))}}var Qg={major:4,minor:6,patch:5};var Mt=Q("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qg;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=fi(a),f;for(let h of c){if(h._zod.def.when){if(Zm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new pi;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(ch(a.issues,d,e),!u)u=fi(a,d)});else{if(a.issues.length===d)continue;if(ch(a.issues,d,e),!u)u=fi(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(fi(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new pi;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new pi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return oc(this,"~standard",Sh(this))},set "~standard"(e){Li(this,"~standard",e)}}),u_=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>di(n,t,Sn()))}:{value:e.value};async function iA(e,t){let n={async:!0};return u_(await e._zod.run({value:t,issues:[]},n),n)}function Sh(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return u_(i,n)}catch(i){}return iA(e,t)},vendor:"zod",version:1}}var gc=Q("$ZodString",(e,t)=>{Mt.init(e,t),e._zod.pattern=t.pattern??Ug,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),bt=Q("$ZodStringFormat",(e,t)=>{bo.init(e,t),gc.init(e,t)}),h_=Q("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bg),bt.init(e,t)}),f_=Q("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mh(i))}else t.pattern??(t.pattern=mh());bt.init(e,t)}),d_=Q("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Sg),bt.init(e,t)}),p_=1,pc=2;function m_(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function rA(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return m_(e)||pc;return sA(e,t)}function sA(e,t){if(!t.normalize&&t.protocol?.source===Pg.source&&!/^https?:\/\//i.test(e))return p_;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??pc}return new URL(e)}catch{return pc}}var oA=/[\t\n\r]/g;function e_(e){return e.replace(oA,"")}function aA(e,t){return t.lastIndex=0,t.test(e.hostname)}function cA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var g_=Q("$ZodURL",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=rA(i,t);if(r===p_){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===pc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=e_(i);return}if(t.hostname&&!aA(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!cA(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:e_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),__=Q("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Mg()),bt.init(e,t)}),x_=Q("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?xg:yg(t.length)),bt.init(e,t)}),y_=Q("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=dg),bt.init(e,t)}),v_=Q("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=pg),bt.init(e,t)}),b_=Q("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mg),bt.init(e,t)}),S_=Q("$ZodXID",(e,t)=>{t.pattern??(t.pattern=gg),bt.init(e,t)}),M_=Q("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_g),bt.init(e,t)}),w_=Q("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Og(t)),bt.init(e,t)}),E_=Q("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ng),bt.init(e,t)}),T_=Q("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Dg(t)),bt.init(e,t)}),A_=Q("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vg),bt.init(e,t)}),R_=Q("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=wg),bt.init(e,t)}),lA=/^[0-9a-fA-F:.]+$/;function C_(e){if(!lA.test(e))return!1;return m_(`http://[${e}]`)}var P_=Q("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Eg),bt.init(e,t),e._zod.check=(n)=>{if(!C_(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var I_=Q("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tg),bt.init(e,t)});function uA(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return C_(n)}var L_=Q("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ag),bt.init(e,t),e._zod.check=(n)=>{if(!uA(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function N_(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Mh=/^[0-9a-zA-Z+/]*={0,2}$/,D_=Q("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Mh),bt.init(e,t),e._zod.check=(n)=>{if(N_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),_c=/^[A-Za-z0-9_-]*$/;function hA(e){if(!_c.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return N_(n)}var O_=Q("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=_c),bt.init(e,t),e._zod.check=(n)=>{if(hA(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),U_=Q("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ig),bt.init(e,t)});function fA(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var F_=Q("$ZodJWT",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{if(fA(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var wh=Q("$ZodNumber",(e,t)=>{Mt.init(e,t),e._zod.pattern=yo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),z_=Q("$ZodNumberFormat",(e,t)=>{Gg.init(e,t),wh.init(e,t)}),k_=Q("$ZodBoolean",(e,t)=>{Mt.init(e,t),e._zod.pattern=Fg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var B_=Q("$ZodUnknown",(e,t)=>{Mt.init(e,t),e._zod.parse=(n)=>n}),G_=Q("$ZodNever",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function t_(e,t,n){if(e.issues.length)t.issues.push(...ar(n,e.issues));t.value[n]=e.value}var H_=Q("$ZodArray",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>t_(f,i,c)));else if(t_(u,i,c),a&&u.issues.length!==0&&fi(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function mc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...ar(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var dA=[];function V_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:dA,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Vm(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function $_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(fi(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>mc(p,n,g,t,f,h)));else mc(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var pA=Q("$ZodObject",(e,t)=>{Mt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=go(()=>V_(t));nt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))Ln(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ms,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(fi(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,v=m._zod.run({value:f[p],issues:[]},u);if(v instanceof Promise)h.push(v.then((M)=>mc(M,l,p,f,E,R)));else mc(v,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return $_(h,f,l,u,r.value,e,g===!0)}}),W_=Q("$ZodObjectJIT",(e,t)=>{pA.init(e,t);let n=e._zod.parse,i=go(()=>V_(t)),r=dn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new vh(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(M)=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,E=(M,T)=>`
+};`)(...Object.values(this.closed))}}var e_={major:4,minor:6,patch:5};var Mt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=e_;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=fi(a),f;for(let h of c){if(h._zod.def.when){if(Xm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new pi;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(lh(a.issues,d,e),!u)u=fi(a,d)});else{if(a.issues.length===d)continue;if(lh(a.issues,d,e),!u)u=fi(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(fi(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new pi;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new pi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ac(this,"~standard",Mh(this))},set "~standard"(e){Ni(this,"~standard",e)}}),h_=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>di(n,t,Sn()))}:{value:e.value};async function sA(e,t){let n={async:!0};return h_(await e._zod.run({value:t,issues:[]},n),n)}function Mh(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return h_(i,n)}catch(i){}return sA(e,t)},vendor:"zod",version:1}}var _c=J("$ZodString",(e,t)=>{Mt.init(e,t),e._zod.pattern=t.pattern??Fg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),bt=J("$ZodStringFormat",(e,t)=>{Eo.init(e,t),_c.init(e,t)}),f_=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Sg),bt.init(e,t)}),d_=J("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=gh(i))}else t.pattern??(t.pattern=gh());bt.init(e,t)}),p_=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mg),bt.init(e,t)}),m_=1,mc=2;function g_(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function oA(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return g_(e)||mc;return aA(e,t)}function aA(e,t){if(!t.normalize&&t.protocol?.source===Ig.source&&!/^https?:\/\//i.test(e))return m_;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??mc}return new URL(e)}catch{return mc}}var cA=/[\t\n\r]/g;function t_(e){return e.replace(cA,"")}function lA(e,t){return t.lastIndex=0,t.test(e.hostname)}function uA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var __=J("$ZodURL",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=oA(i,t);if(r===m_){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===mc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=t_(i);return}if(t.hostname&&!lA(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!uA(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:t_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),x_=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wg()),bt.init(e,t)}),y_=J("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?yg:vg(t.length)),bt.init(e,t)}),v_=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pg),bt.init(e,t)}),b_=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=mg),bt.init(e,t)}),S_=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gg),bt.init(e,t)}),M_=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_g),bt.init(e,t)}),w_=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xg),bt.init(e,t)}),E_=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ug(t)),bt.init(e,t)}),T_=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Dg),bt.init(e,t)}),A_=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Og(t)),bt.init(e,t)}),R_=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=bg),bt.init(e,t)}),C_=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Eg),bt.init(e,t)}),hA=/^[0-9a-fA-F:.]+$/;function P_(e){if(!hA.test(e))return!1;return g_(`http://[${e}]`)}var I_=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Tg),bt.init(e,t),e._zod.check=(n)=>{if(!P_(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var L_=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ag),bt.init(e,t)});function fA(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return P_(n)}var N_=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Rg),bt.init(e,t),e._zod.check=(n)=>{if(!fA(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function D_(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var wh=/^[0-9a-zA-Z+/]*={0,2}$/,O_=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=wh),bt.init(e,t),e._zod.check=(n)=>{if(D_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),xc=/^[A-Za-z0-9_-]*$/;function dA(e){if(!xc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return D_(n)}var U_=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xc),bt.init(e,t),e._zod.check=(n)=>{if(dA(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),F_=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Lg),bt.init(e,t)});function pA(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var z_=J("$ZodJWT",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{if(pA(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Eh=J("$ZodNumber",(e,t)=>{Mt.init(e,t),e._zod.pattern=Mo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),k_=J("$ZodNumberFormat",(e,t)=>{Hg.init(e,t),Eh.init(e,t)}),B_=J("$ZodBoolean",(e,t)=>{Mt.init(e,t),e._zod.pattern=zg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var G_=J("$ZodUnknown",(e,t)=>{Mt.init(e,t),e._zod.parse=(n)=>n}),H_=J("$ZodNever",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function n_(e,t,n){if(e.issues.length)t.issues.push(...cr(n,e.issues));t.value[n]=e.value}var V_=J("$ZodArray",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>n_(f,i,c)));else if(n_(u,i,c),a&&u.issues.length!==0&&fi(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function gc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...cr(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var mA=[];function $_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:mA,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=$m(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function W_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(fi(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>gc(p,n,g,t,f,h)));else gc(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var gA=J("$ZodObject",(e,t)=>{Mt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=vo(()=>$_(t));tt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))Nn(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ts,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(fi(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,v=m._zod.run({value:f[p],issues:[]},u);if(v instanceof Promise)h.push(v.then((M)=>gc(M,l,p,f,E,R)));else gc(v,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return W_(h,f,l,u,r.value,e,g===!0)}}),Z_=J("$ZodObjectJIT",(e,t)=>{gA.init(e,t);let n=e._zod.parse,i=vo(()=>$_(t)),r=dn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new bh(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(M)=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,E=(M,T)=>`
let ${M}_ab = false;
for (let i = 0; i < ${M}.issues.length; i++) {
const iss = ${M}.issues[i];
@@ -4356,7 +4356,7 @@ ${t.join(`
if (${M}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;p.write("const input = payload.value;");let R=Object.create(null),v=0;for(let M of g.allKeys)R[M]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let M of g.allKeys){if(M==="__proto__")continue;let T=R[M],A=typeof M==="symbol"?`syms[${x.indexOf(M)}]`:km(M),_=`${A} in input`,S=d[M],k=S?._zod?.optin,C=k!==void 0,U=S?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),C&&U){let ee=k==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
+ }`;p.write("const input = payload.value;");let R=Object.create(null),v=0;for(let M of g.allKeys)R[M]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let M of g.allKeys){if(M==="__proto__")continue;let T=R[M],A=typeof M==="symbol"?`syms[${x.indexOf(M)}]`:Bm(M),_=`${A} in input`,S=d[M],z=S?._zod?.optin,P=z!==void 0,F=S?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),P&&F){let ee=z==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
const ${T}_present = ${_};
if (!${T}.issues.length || ${T}_present) {
if (${T}.issues.length) {${E(T,A)}
@@ -4367,7 +4367,7 @@ ${t.join(`
}
}
- `)}else if(!C)p.write(`
+ `)}else if(!P)p.write(`
const ${T}_present = ${_};
if (${T}.issues.length) {${E(T,A)}
}
@@ -4391,18 +4391,18 @@ ${t.join(`
`);else if(p.write(`
if (${T}.issues.length) {${E(T,A)}
}
- `),k==="defaulted")p.write(`newResult[${A}] = ${T}.value;`);else p.write(`
+ `),z==="defaulted")p.write(`newResult[${A}] = ${T}.value;`);else p.write(`
if (${T}.value !== undefined || ${_}) {
newResult[${A}] = ${T}.value;
}
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ms,c=!dn.jitless,u=c&&Gm.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return $_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function n_(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!fi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>di(o,i,Sn())))}),t}var Eh=Q("$ZodUnion",(e,t)=>{Mt.init(e,t),nt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),nt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),nt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),nt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>tc(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return n_(o,i,e,r);return Promise.all(o).then((a)=>n_(a,i,e,r))}});function mA(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Z_=Q("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Eh.init(e,t);let n=e._zod.parse;nt(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Ln(s,l,new Set);for(let f of u)s[l].add(f)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=_o(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=go(()=>mA(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Ms(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),X_=Q("$ZodIntersection",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>i_(n,c,l));return i_(n,s,o)}});function bh(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Lr(e)&&Lr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=bh(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=bh(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function i_(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=bh(t.value,n.value);if(!c.valid){if(fi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var q_=Q("$ZodRecord",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Lr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>di(g,r,Sn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...ar(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...ar(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&yo.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>di(g,r,Sn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...ar(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...ar(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var j_=Q("$ZodEnum",(e,t)=>{Mt.init(e,t);let n=po(t.entries),i=new Set(n);e._zod.values=i,nt(e,"pattern",(r)=>{let s=po(r.def.entries).filter((o)=>Hm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>or(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Y_=Q("$ZodLiteral",(e,t)=>{Mt.init(e,t);let n=new Set(t.values);e._zod.values=n,nt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?or(s):s?or(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var K_=Q("$ZodTransform",(e,t)=>{Mt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new xo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new pi;return n.value=r,n}});function r_(e,t){return e.value=t.issues.length?void 0:t.value,e}var Th=Q("$ZodOptional",(e,t)=>{Mt.init(e,t),nt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",nt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),nt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${tc(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>r_(n,s));return r_(n,r)}return t.innerType._zod.run(n,i)}}),J_=Q("$ZodExactOptional",(e,t)=>{Th.init(e,t),nt(e,"values",(n)=>n.def.innerType._zod.values),nt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Q_=Q("$ZodNullable",(e,t)=>{Mt.init(e,t),nt(e,"optin",(n)=>n.def.innerType._zod.optin),nt(e,"optout",(n)=>n.def.innerType._zod.optout),nt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${tc(i.source)}|null)$`):void 0}),nt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),e0=Q("$ZodDefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",nt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>s_(s,t));return s_(r,t)}});function s_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var t0=Q("$ZodPrefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",nt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),n0=Q("$ZodNonOptional",(e,t)=>{Mt.init(e,t),nt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>o_(s,e));return o_(r,e)}});function o_(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function a_(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>di(r,i,Sn()))},input:e.value}),e}var i0=Q("$ZodCatch",(e,t)=>{Mt.init(e,t),nt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),nt(e,"optout",(n)=>n.def.innerType._zod.optout),nt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>a_(n,s,t,i));return a_(n,r,t,i)}});var r0=Q("$ZodPipe",(e,t)=>{Mt.init(e,t),nt(e,"values",(n)=>n.def.in._zod.values),nt(e,"optin",(n)=>n.def.in._zod.optin),nt(e,"optout",(n)=>n.def.out._zod.optout),nt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>dc(o,t.in,i));return dc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>dc(s,t.out,i));return dc(r,t.out,i)}});function dc(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var s0=Q("$ZodReadonly",(e,t)=>{Mt.init(e,t),nt(e,"propValues",(n)=>n.def.innerType._zod.propValues),nt(e,"values",(n)=>n.def.innerType._zod.values),nt(e,"optin",(n)=>n.def.innerType?._zod?.optin),nt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(c_);return c_(r)}});function c_(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var o0=Q("$ZodCustom",(e,t)=>{Xt.init(e,t),Mt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>l_(s,n,i,e));l_(r,n,i,e);return}});function l_(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Nr(r))}}class c0 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Rh="~memo",a0=[];function l0(e){return e!==null&&typeof e==="object"}function Ah(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var u0=new WeakMap,So=0,vc=1,Mo=2;function bc(e,t,n){let i=u0.get(e);if(i!==void 0)return i?Mo:So;if(t.has(e))return Mo;t.add(e);let r=So,s=(u)=>{if(r!==Mo&&u?._zod){let f=bc(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=So;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?vc:g.value?._zod?bc(g.value,t,n):So;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=_o(c);a(u?o(u,!0):vc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?bc(u,t,!1):vc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),gA(e,r)}function gA(e,t){if(t!==vc)u0.set(e,t===Mo);return t}function _A(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var xc,yc=[],xA={alloc(e,t,n){let i=xc;if(!i)return n;xc=void 0;let r={value:n,issues:null};return i.set(t.value,r),yc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&yA(s,r.value))throw new c0;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=bc(e,new Set,!1);if(m===So){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Mo||i)n=!0;else i=!0}let u=c.value;if(!l0(u))return o(c,l);let f=l[Rh];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Rh]=f;let h;if(r===l)h=s;else h=_A(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Ah(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}xc=h;let g=yc.length,x=o(c,l);xc=void 0;let p=yc.length>g?yc.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Ah(m.issues):a0;return m});if(p)p.issues=x.issues.length?Ah(x.issues):a0;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function h0(){return xA}function yA(e,t){let n=e[Rh]?.backEdges;return n!==void 0&&l0(t)&&n.has(t)}var vA=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Xm(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${oh(s.values[0])}`;return`Invalid option: expected one of ${ih(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${ih(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ch(){return{localeError:vA()}}var f0;class d0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function bA(){return new d0}(f0=globalThis).__zod_globalRegistry??(f0.__zod_globalRegistry=bA());var Dr=globalThis.__zod_globalRegistry;function p0(e){if(e.checks)e.checks=[...e.checks];return e}function m0(e,t){return new e(p0({type:"string",...Re(t)}))}function g0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Re(t)})}function _0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Re(t)})}function x0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Re(t)})}function y0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Re(t)})}function v0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Re(t)})}function b0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Re(t)})}function S0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Re(t)})}function M0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Re(t)})}function w0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Re(t)})}function E0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Re(t)})}function T0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Re(t)})}function A0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Re(t)})}function R0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Re(t)})}function C0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Re(t)})}function P0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Re(t)})}function I0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Re(t)})}function L0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Re(t)})}function N0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Re(t)})}function D0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Re(t)})}function O0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Re(t)})}function U0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Re(t)})}function F0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Re(t)})}function z0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Re(t)})}function k0(e,t){return new e({type:"string",format:"date",check:"string_format",...Re(t)})}function B0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Re(t)})}function G0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Re(t)})}function H0(e,t){return new e(p0({type:"number",checks:[],...Re(t)}))}function V0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Re(t)})}function $0(e,t){return new e({type:"boolean",...Re(t)})}function W0(e){return new e({type:"unknown"})}function Z0(e,t){return new e({type:"never",...Re(t)})}function Sc(e,t){return new xh({check:"less_than",...Re(t),value:e,inclusive:!1})}function wo(e,t){return new xh({check:"less_than",...Re(t),value:e,inclusive:!0})}function Mc(e,t){return new yh({check:"greater_than",...Re(t),value:e,inclusive:!1})}function Eo(e,t){return new yh({check:"greater_than",...Re(t),value:e,inclusive:!0})}function wc(e,t){return new Bg({check:"multiple_of",...Re(t),value:e})}function Ec(e,t){return new Hg({check:"max_length",...Re(t),maximum:e})}function ws(e,t){return new Vg({check:"min_length",...Re(t),minimum:e})}function Tc(e,t){return new $g({check:"length_equals",...Re(t),length:e})}function Ph(e,t){return new Wg({check:"string_format",format:"regex",...Re(t),pattern:e})}function Ih(e){return new Zg({check:"string_format",format:"lowercase",...Re(e)})}function Lh(e){return new Xg({check:"string_format",format:"uppercase",...Re(e)})}function Nh(e,t){return new qg({check:"string_format",format:"includes",...Re(t),includes:e})}function Dh(e,t){return new jg({check:"string_format",format:"starts_with",...Re(t),prefix:e})}function Oh(e,t){return new Yg({check:"string_format",format:"ends_with",...Re(t),suffix:e})}function cr(e){return new Kg({check:"overwrite",tx:e})}function Uh(e){return cr((t)=>t.normalize(e))}function Fh(){return cr((e)=>e.trim())}function zh(){return cr((e)=>e.toLowerCase())}function kh(){return cr((e)=>e.toUpperCase())}function Bh(){return cr((e)=>Bm(e))}function X0(e,t,n){return new e({type:"array",element:t,...Re(n)})}function q0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Re(n)})}function j0(e,t){let n=SA((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Nr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Nr(s))}},e(i.value,i)),t);return n}function SA(e,t){let n=new Xt({check:"custom",...Re(t)});return n._zod.check=e,n}function To(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Ln(e,i,n[i]);return e}function Hh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Dr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ni(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;It(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)To(o.schema,c);if(t.io==="input"&&on(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Y0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Vh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${Y0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Y0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ts,c=!dn.jitless,u=c&&Hm.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return W_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function i_(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!fi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>di(o,i,Sn())))}),t}var Th=J("$ZodUnion",(e,t)=>{Mt.init(e,t),tt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),tt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),tt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),tt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>nc(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return i_(o,i,e,r);return Promise.all(o).then((a)=>i_(a,i,e,r))}});function _A(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var X_=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Th.init(e,t);let n=e._zod.parse;tt(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Nn(s,l,new Set);for(let f of u)s[l].add(f)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=bo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=vo(()=>_A(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Ts(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),q_=J("$ZodIntersection",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>r_(n,c,l));return r_(n,s,o)}});function Sh(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Nr(e)&&Nr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=Sh(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=Sh(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function r_(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Sh(t.value,n.value);if(!c.valid){if(fi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var j_=J("$ZodRecord",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Nr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>di(g,r,Sn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...cr(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...cr(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Mo.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>di(g,r,Sn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...cr(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...cr(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Y_=J("$ZodEnum",(e,t)=>{Mt.init(e,t);let n=xo(t.entries),i=new Set(n);e._zod.values=i,tt(e,"pattern",(r)=>{let s=xo(r.def.entries).filter((o)=>Vm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>ar(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),K_=J("$ZodLiteral",(e,t)=>{Mt.init(e,t);let n=new Set(t.values);e._zod.values=n,tt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?ar(s):s?ar(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var J_=J("$ZodTransform",(e,t)=>{Mt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new So(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new pi;return n.value=r,n}});function s_(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ah=J("$ZodOptional",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${nc(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>s_(n,s));return s_(n,r)}return t.innerType._zod.run(n,i)}}),Q_=J("$ZodExactOptional",(e,t)=>{Ah.init(e,t),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),e0=J("$ZodNullable",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${nc(i.source)}|null)$`):void 0}),tt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),t0=J("$ZodDefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>o_(s,t));return o_(r,t)}});function o_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var n0=J("$ZodPrefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),i0=J("$ZodNonOptional",(e,t)=>{Mt.init(e,t),tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>a_(s,e));return a_(r,e)}});function a_(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function c_(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>di(r,i,Sn()))},input:e.value}),e}var r0=J("$ZodCatch",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>c_(n,s,t,i));return c_(n,r,t,i)}});var s0=J("$ZodPipe",(e,t)=>{Mt.init(e,t),tt(e,"values",(n)=>n.def.in._zod.values),tt(e,"optin",(n)=>n.def.in._zod.optin),tt(e,"optout",(n)=>n.def.out._zod.optout),tt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>pc(o,t.in,i));return pc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>pc(s,t.out,i));return pc(r,t.out,i)}});function pc(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var o0=J("$ZodReadonly",(e,t)=>{Mt.init(e,t),tt(e,"propValues",(n)=>n.def.innerType._zod.propValues),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"optin",(n)=>n.def.innerType?._zod?.optin),tt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(l_);return l_(r)}});function l_(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var a0=J("$ZodCustom",(e,t)=>{Xt.init(e,t),Mt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>u_(s,n,i,e));u_(r,n,i,e);return}});function u_(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Dr(r))}}class l0 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ch="~memo",c0=[];function u0(e){return e!==null&&typeof e==="object"}function Rh(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var h0=new WeakMap,To=0,bc=1,Ao=2;function Sc(e,t,n){let i=h0.get(e);if(i!==void 0)return i?Ao:To;if(t.has(e))return Ao;t.add(e);let r=To,s=(u)=>{if(r!==Ao&&u?._zod){let f=Sc(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=To;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?bc:g.value?._zod?Sc(g.value,t,n):To;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=bo(c);a(u?o(u,!0):bc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Sc(u,t,!1):bc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),xA(e,r)}function xA(e,t){if(t!==bc)h0.set(e,t===Ao);return t}function yA(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var yc,vc=[],vA={alloc(e,t,n){let i=yc;if(!i)return n;yc=void 0;let r={value:n,issues:null};return i.set(t.value,r),vc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&bA(s,r.value))throw new l0;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=Sc(e,new Set,!1);if(m===To){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Ao||i)n=!0;else i=!0}let u=c.value;if(!u0(u))return o(c,l);let f=l[Ch];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Ch]=f;let h;if(r===l)h=s;else h=yA(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Rh(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}yc=h;let g=vc.length,x=o(c,l);yc=void 0;let p=vc.length>g?vc.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Rh(m.issues):c0;return m});if(p)p.issues=x.issues.length?Rh(x.issues):c0;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function f0(){return vA}function bA(e,t){let n=e[Ch]?.backEdges;return n!==void 0&&u0(t)&&n.has(t)}var SA=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=qm(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${ah(s.values[0])}`;return`Invalid option: expected one of ${rh(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${rh(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ph(){return{localeError:SA()}}var d0;class p0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function MA(){return new p0}(d0=globalThis).__zod_globalRegistry??(d0.__zod_globalRegistry=MA());var Or=globalThis.__zod_globalRegistry;function m0(e){if(e.checks)e.checks=[...e.checks];return e}function g0(e,t){return new e(m0({type:"string",...Ce(t)}))}function _0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function x0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function y0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function v0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function b0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function S0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function M0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function w0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function E0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function T0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function A0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function R0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function C0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function P0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function I0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function L0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function N0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function D0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function O0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function U0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function F0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function z0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function k0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function B0(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function G0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function H0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function V0(e,t){return new e(m0({type:"number",checks:[],...Ce(t)}))}function $0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function W0(e,t){return new e({type:"boolean",...Ce(t)})}function Z0(e){return new e({type:"unknown"})}function X0(e,t){return new e({type:"never",...Ce(t)})}function Mc(e,t){return new yh({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Ro(e,t){return new yh({check:"less_than",...Ce(t),value:e,inclusive:!0})}function wc(e,t){return new vh({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function Co(e,t){return new vh({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function Ec(e,t){return new Gg({check:"multiple_of",...Ce(t),value:e})}function Tc(e,t){return new Vg({check:"max_length",...Ce(t),maximum:e})}function As(e,t){return new $g({check:"min_length",...Ce(t),minimum:e})}function Ac(e,t){return new Wg({check:"length_equals",...Ce(t),length:e})}function Ih(e,t){return new Zg({check:"string_format",format:"regex",...Ce(t),pattern:e})}function Lh(e){return new Xg({check:"string_format",format:"lowercase",...Ce(e)})}function Nh(e){return new qg({check:"string_format",format:"uppercase",...Ce(e)})}function Dh(e,t){return new jg({check:"string_format",format:"includes",...Ce(t),includes:e})}function Oh(e,t){return new Yg({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function Uh(e,t){return new Kg({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function lr(e){return new Jg({check:"overwrite",tx:e})}function Fh(e){return lr((t)=>t.normalize(e))}function zh(){return lr((e)=>e.trim())}function kh(){return lr((e)=>e.toLowerCase())}function Bh(){return lr((e)=>e.toUpperCase())}function Gh(){return lr((e)=>Gm(e))}function q0(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function j0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Y0(e,t){let n=wA((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Dr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Dr(s))}},e(i.value,i)),t);return n}function wA(e,t){let n=new Xt({check:"custom",...Ce(t)});return n._zod.check=e,n}function Po(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Nn(e,i,n[i]);return e}function Vh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Or,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;It(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Po(o.schema,c);if(t.io==="input"&&on(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function K0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function $h(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${K0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+K0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Q0(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;Q0(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var ex=new Set(["type","properties","required","additionalProperties"]),K0=["oneOf","anyOf"];function J0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Gh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!ex.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??J0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Gh(a)??{allOf:a};Ln(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=J0(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function MA(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of ex)if(r in e)return;let n=t.filter((r)=>K0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Gh(t);else{let r=n[0],s=K0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Gh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,To(e,i)}function $h(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else To(l,g);if(To(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Q0(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])MA(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}To(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Ln(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ao(t,"input",e.processors),output:Ao(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function on(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return on(i.element,n);if(i.type==="set")return on(i.valueType,n);if(i.type==="lazy")return on(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return on(i.innerType,n);if(i.type==="intersection")return on(i.left,n)||on(i.right,n);if(i.type==="record"||i.type==="map")return on(i.keyType,n)||on(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return on(i.in,n)||on(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(on(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(on(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(on(r,n))return!0;if(i.rest&&on(i.rest,n))return!0;return!1}return!1}var tx=(e,t={})=>(n)=>{let i=Hh({...n,processors:t});return It(e,i),Vh(i,e),$h(i,e)},Ao=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Hh({...r??{},target:s,io:t,processors:n});return It(e,o),Vh(o,e),$h(o,e)};var Es=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Ts=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},nx=(e,t)=>{Es(e,"minimum",t),Ts(e,"maximum",t)},ox=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ax=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},cx=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},lx=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ix=(e,t)=>Es(e,"minimum",t.minimum),rx=(e,t)=>Ts(e,"maximum",t.maximum),sx=(e)=>(t,n)=>{lx(t,n.format);let[i,r]=e[n.format];Es(t,"minimum",i),Ts(t,"maximum",r)},wA={greater_than:(e,t)=>Es(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ts(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ox(e,t.value),number_format:sx(nc),bigint_format:sx(ah),min_length:ix,max_length:rx,length_equals:(e,t)=>nx(e,t.length),min_size:ix,max_size:rx,size_equals:(e,t)=>nx(e,t.size),string_format:(e,t)=>{if(lx(e,t.format),t.pattern)ax(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>cx(e,t.mime)};function Nn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)wA[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Es(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Es(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Ts(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Ts(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)ox(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)cx(t,r.mime);for(let s of r.patterns??[])ax(t,s);return t}var EA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},TA=new Map([[Mh,Rg],[_c,Cg]]),ux=(e)=>TA.get(e)??e,hx=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Nn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=EA[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(ux);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},fx=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Nn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else Ni(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},dx=(e,t,n,i)=>{n.type="boolean"};var px=(e,t,n,i)=>{n.not={}};var mx=(e,t,n,i)=>{};var gx=(e,t,n,i)=>{let r=e._zod.def,s=po(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},_x=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Ni(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Ni(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var xx=(e,t,n,i)=>{Ni(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var yx=(e,t,n,i)=>{Ni(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var vx=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Nn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function Ac(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ac(t.out);if(t.type==="catch")return Ac(t.innerType);return e._zod.optin}var bx=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Ni(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Ln(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Ac(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Sx=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Mx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Wh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=Wh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>Wh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?yo:gh).source;return d}var Zh=new WeakMap;function AA(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Zh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Wh(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var wx=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Nn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)Ln(r.patternProperties,ux(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Zh.get(t);if(!u)u=[],Zh.set(t,u),t.deferred.push(()=>AA(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Ac(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},Ex=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Tx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Xh=Symbol();function Ax(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Ni(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Xh}var Rx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Ax(r.defaultValue,e,t,n,i);if(o!==Xh)n.default=o},Cx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Ax(r.defaultValue,e,t,n,i);if(o!==Xh)n._prefault=o},Px=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Ni(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Ix=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},Lx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var qh=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Nx=new WeakSet([Object.prototype,Error.prototype]);function Rc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var OA=(e,t)=>{tg.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Nx.has(n))return;Nx.add(n),Rc(n,"format",(i)=>(r)=>ig(i,r)),Rc(n,"flatten",(i)=>(r)=>ng(i,r)),Rc(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,mo,2)}),Rc(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,mo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=Q("ZodError",OA,void 0,{Parent:Error});var Dx=cc(Mn),Ox=lc(Mn),Ux=uc(Mn),Fx=hc(Mn),zx=sg(Mn),kx=og(Mn),Bx=ag(Mn),Gx=cg(Mn),Hx=lg(Mn),Vx=ug(Mn),$x=hg(Mn),Wx=fg(Mn);function FA(){if(!dn.localeError)Sn(Ch())}function Pc(){if(!dn.memoizer)Sn({memoizer:h0()})}var Et=Q("ZodType",(e,t)=>(FA(),Mt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(bn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return hi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(D1(e,t))},superRefine(e,t){return this.check(O1(e,t))},overwrite(e){return this.check(cr(e))},optional(){return qx(this)},exactOptional(){return b1(this)},nullable(){return jx(this)},nullish(){return qx(jx(this))},nonoptional(e){return A1(this,e)},array(){return an(this)},or(e){return ey([this,e])},and(e){return _1(this,e)},transform(e){return Yx(this,v1(e))},default(e){return w1(this,e)},prefault(e){return T1(this,e)},catch(e){return C1(this,e)},pipe(e){return Yx(this,e)},readonly(){return L1(this)},describe(e){let t=this.clone();return Dr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dr.get(this);let t=this.clone();return Dr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return oc(this,"~standard",{...Sh(this),jsonSchema:{input:Ao(this,"input"),output:Ao(this,"output")}})},set "~standard"(e){Li(this,"~standard",e)},parse:function e(t,n){return Dx(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ox(this,t,n,{callee:e})},safeParse(e,t){return Ux(this,e,t)},async safeParseAsync(e,t){return Fx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Li(this,"spa",e)},validate(e,t){return fh(this,e,t)},validateAsync(e,t){return dh(this,e,t)},encode:function e(t,n){return zx(this,t,n,{callee:e})},decode:function e(t,n){return kx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Bx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Gx(this,t,n,{callee:e})},safeEncode(e,t){return Hx(this,e,t)},safeDecode(e,t){return Vx(this,e,t)},async safeEncodeAsync(e,t){return $x(this,e,t)},async safeDecodeAsync(e,t){return Wx(this,e,t)},toJSONSchema(e){return tx(this,{})(e)},get description(){return Dr.get(this)?.description},get _def(){return this._zod.def}}),Kx=Q("_ZodString",(e,t)=>{gc.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hx(e,n,i,r)},jm({format:(e)=>Nn(e).format??null,minLength:(e)=>Nn(e).minimum??null,maxLength:(e)=>Nn(e).maximum??null},{regex(...e){return this.check(Ph(...e))},includes(...e){return this.check(Nh(...e))},startsWith(...e){return this.check(Dh(...e))},endsWith(...e){return this.check(Oh(...e))},min(...e){return this.check(ws(...e))},max(...e){return this.check(Ec(...e))},length(...e){return this.check(Tc(...e))},nonempty(...e){return this.check(ws(1,...e))},lowercase(e){return this.check(Ih(e))},uppercase(e){return this.check(Lh(e))},trim(){return this.check(Fh())},normalize(...e){return this.check(Uh(...e))},toLowerCase(){return this.check(zh())},toUpperCase(){return this.check(kh())},slugify(){return this.check(Bh())}})),zA=Q("ZodString",(e,t)=>{gc.init(e,t),Kx.init(e,t)},{email(e){return this.check(g0(VA,e))},url(e){return this.check(S0(WA,e))},jwt(e){return this.check(F0(o1,e))},emoji(e){return this.check(M0(ZA,e))},guid(e){return this.check(_0($A,e))},uuid(e){return this.check(x0(Cc,e))},uuidv4(e){return this.check(y0(Cc,e))},uuidv6(e){return this.check(v0(Cc,e))},uuidv7(e){return this.check(b0(Cc,e))},nanoid(e){return this.check(w0(XA,e))},cuid(e){return this.check(E0(qA,e))},cuid2(e){return this.check(T0(jA,e))},ulid(e){return this.check(A0(YA,e))},base64(e){return this.check(D0(i1,e))},base64url(e){return this.check(O0(r1,e))},xid(e){return this.check(R0(KA,e))},ksuid(e){return this.check(C0(JA,e))},ipv4(e){return this.check(P0(QA,e))},ipv6(e){return this.check(I0(e1,e))},cidrv4(e){return this.check(L0(t1,e))},cidrv6(e){return this.check(N0(n1,e))},e164(e){return this.check(U0(s1,e))},datetime(e){return this.check(z0(kA,e))},date(e){return this.check(k0(BA,e))},time(e){return this.check(B0(GA,e))},duration(e){return this.check(G0(HA,e))}});function Je(e){return m0(zA,e)}var Tt=Q("ZodStringFormat",(e,t)=>{bt.init(e,t),Kx.init(e,t)}),kA=Q("ZodISODateTime",(e,t)=>{w_.init(e,t),Tt.init(e,t)}),BA=Q("ZodISODate",(e,t)=>{E_.init(e,t),Tt.init(e,t)}),GA=Q("ZodISOTime",(e,t)=>{T_.init(e,t),Tt.init(e,t)}),HA=Q("ZodISODuration",(e,t)=>{A_.init(e,t),Tt.init(e,t)}),VA=Q("ZodEmail",(e,t)=>{d_.init(e,t),Tt.init(e,t)});var $A=Q("ZodGUID",(e,t)=>{h_.init(e,t),Tt.init(e,t)});var Cc=Q("ZodUUID",(e,t)=>{f_.init(e,t),Tt.init(e,t)});var WA=Q("ZodURL",(e,t)=>{g_.init(e,t),Tt.init(e,t)});var ZA=Q("ZodEmoji",(e,t)=>{__.init(e,t),Tt.init(e,t)});var XA=Q("ZodNanoID",(e,t)=>{x_.init(e,t),Tt.init(e,t)});var qA=Q("ZodCUID",(e,t)=>{y_.init(e,t),Tt.init(e,t)});var jA=Q("ZodCUID2",(e,t)=>{v_.init(e,t),Tt.init(e,t)});var YA=Q("ZodULID",(e,t)=>{b_.init(e,t),Tt.init(e,t)});var KA=Q("ZodXID",(e,t)=>{S_.init(e,t),Tt.init(e,t)});var JA=Q("ZodKSUID",(e,t)=>{M_.init(e,t),Tt.init(e,t)});var QA=Q("ZodIPv4",(e,t)=>{R_.init(e,t),Tt.init(e,t)});var e1=Q("ZodIPv6",(e,t)=>{P_.init(e,t),Tt.init(e,t)});var t1=Q("ZodCIDRv4",(e,t)=>{I_.init(e,t),Tt.init(e,t)});var n1=Q("ZodCIDRv6",(e,t)=>{L_.init(e,t),Tt.init(e,t)});var i1=Q("ZodBase64",(e,t)=>{D_.init(e,t),Tt.init(e,t)});var r1=Q("ZodBase64URL",(e,t)=>{O_.init(e,t),Tt.init(e,t)});var s1=Q("ZodE164",(e,t)=>{U_.init(e,t),Tt.init(e,t)});var o1=Q("ZodJWT",(e,t)=>{F_.init(e,t),Tt.init(e,t)});var Jx=Q("ZodNumber",(e,t)=>{wh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fx(e,n,i,r),e.isFinite=!0},jm({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Nn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Nn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Nn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Nn(e).format??null},{gt(e,t){return this.check(Mc(e,t))},gte(e,t){return this.check(Eo(e,t))},min(e,t){return this.check(Eo(e,t))},lt(e,t){return this.check(Sc(e,t))},lte(e,t){return this.check(wo(e,t))},max(e,t){return this.check(wo(e,t))},int(e){return this.check(Zx(e))},safe(e){return this.check(Zx(e))},positive(e){return this.check(Mc(0,e))},nonnegative(e){return this.check(Eo(0,e))},negative(e){return this.check(Sc(0,e))},nonpositive(e){return this.check(wo(0,e))},multipleOf(e,t){return this.check(wc(e,t))},step(e,t){return this.check(wc(e,t))},finite(){return this}}));function mt(e){return H0(Jx,e)}var a1=Q("ZodNumberFormat",(e,t)=>{z_.init(e,t),Jx.init(e,t)});function Zx(e){return V0(a1,e)}var c1=Q("ZodBoolean",(e,t)=>{k_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dx(e,n,i,r)});function Ro(e){return $0(c1,e)}var l1=Q("ZodUnknown",(e,t)=>{B_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mx(e,n,i,r)});function Or(){return W0(l1)}var u1=Q("ZodNever",(e,t)=>{G_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>px(e,n,i,r)});function h1(e){return Z0(u1,e)}var f1=Q("ZodArray",(e,t)=>{Pc(),H_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vx(e,n,i,r),e.element=t.element},{min(e,t){return this.check(ws(e,t))},nonempty(e){return this.check(ws(1,e))},max(e,t){return this.check(Ec(e,t))},length(e,t){return this.check(Tc(e,t))},unwrap(){return this.element}});function an(e,t){return X0(f1,e,t)}var d1=Q("ZodObject",(e,t)=>{Pc(),W_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bx(e,n,i,r),WT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Dn(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(bn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(bn(this._zod.def,{catchall:Or()}))},loose(){return this.clone(bn(this._zod.def,{catchall:Or()}))},strict(){return this.clone(bn(this._zod.def,{catchall:h1()}))},strip(){return this.clone(bn(this._zod.def,{catchall:void 0}))},extend(e){return FT(this,e)},safeExtend(e){return zT(this,e)},merge(e){return kT(this,e)},pick(e){return OT(this,e)},omit(e){return UT(this,e)},partial(...e){return Wm(ty,this,e[0])},exactPartial(...e){return Wm(ny,this,e[0],"exactPartial")},required(...e){return BT(iy,this,e[0])}});function ft(e,t){let n={type:"object",shape:e??{},...Re(t)};return new d1(n)}var Qx=Q("ZodUnion",(e,t)=>{Eh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sx(e,n,i,r),e.options=t.options});function ey(e,t){return new Qx({type:"union",options:e,...Re(t)})}var p1=Q("ZodDiscriminatedUnion",(e,t)=>{Qx.init(e,t),Z_.init(e,t)});function m1(e,t,n){return new p1({type:"union",options:t,discriminator:e,...Re(n)})}var g1=Q("ZodIntersection",(e,t)=>{X_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mx(e,n,i,r)});function _1(e,t){return new g1({type:"intersection",left:e,right:t})}var Xx=Q("ZodRecord",(e,t)=>{Pc(),q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wx(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ic(e,t,n){if(!t||!t._zod)return new Xx({type:"record",keyType:Je(),valueType:e,...Re(t)});return new Xx({type:"record",keyType:e,valueType:t,...Re(n)})}var Yh=Q("ZodEnum",(e,t)=>{j_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(i,r,s)=>gx(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Yh({...t,checks:[],...Re(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Yh({...t,checks:[],...Re(r),entries:s})}});function Dn(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Yh({type:"enum",entries:n,...Re(t)})}var x1=Q("ZodLiteral",(e,t)=>{Y_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_x(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qt(e,t){return new x1({type:"literal",values:Array.isArray(e)?e:[e],...Re(t)})}var y1=Q("ZodTransform",(e,t)=>{Pc(),K_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yx(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new xo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Nr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Nr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function v1(e){return new y1({type:"transform",transform:e})}var ty=Q("ZodOptional",(e,t)=>{Th.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function qx(e){return new ty({type:"optional",innerType:e})}var ny=Q("ZodExactOptional",(e,t)=>{J_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function b1(e){return new ny({type:"optional",innerType:e})}var S1=Q("ZodNullable",(e,t)=>{Q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ex(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function jx(e){return new S1({type:"nullable",innerType:e})}var M1=Q("ZodDefault",(e,t)=>{e0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Rx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function w1(e,t){return new M1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():sh(t)}})}var E1=Q("ZodPrefault",(e,t)=>{t0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function T1(e,t){return new E1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():sh(t)}})}var iy=Q("ZodNonOptional",(e,t)=>{n0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function A1(e,t){return new iy({type:"nonoptional",innerType:e,...Re(t)})}var R1=Q("ZodCatch",(e,t)=>{i0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Px(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function C1(e,t){return new R1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Ym(t)})}var P1=Q("ZodPipe",(e,t)=>{r0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ix(e,n,i,r),e.in=t.in,e.out=t.out});function Yx(e,t){return new P1({type:"pipe",in:e,out:t})}var I1=Q("ZodReadonly",(e,t)=>{s0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function L1(e){return new I1({type:"readonly",innerType:e})}var N1=Q("ZodCustom",(e,t)=>{o0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xx(e,n,i,r)});function D1(e,t={}){return q0(N1,e,t)}function O1(e,t){return j0(e,t)}var sy=["neutral","dark","light"];var Kh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),oy=Object.freeze({neutral:Kh("neutral",[170,177,188]),dark:Kh("dark",[26,26,26]),light:Kh("light",[223,227,232])});var gD=oy.neutral.rgb,_D=oy.neutral.hex;/*!
+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function ex(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;ex(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var tx=new Set(["type","properties","required","additionalProperties"]),J0=["oneOf","anyOf"];function Q0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Hh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!tx.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??Q0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Hh(a)??{allOf:a};Nn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=Q0(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function EA(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of tx)if(r in e)return;let n=t.filter((r)=>J0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Hh(t);else{let r=n[0],s=J0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Hh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Po(e,i)}function Wh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Po(l,g);if(Po(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())ex(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])EA(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Po(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Nn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Io(t,"input",e.processors),output:Io(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function on(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return on(i.element,n);if(i.type==="set")return on(i.valueType,n);if(i.type==="lazy")return on(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return on(i.innerType,n);if(i.type==="intersection")return on(i.left,n)||on(i.right,n);if(i.type==="record"||i.type==="map")return on(i.keyType,n)||on(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return on(i.in,n)||on(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(on(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(on(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(on(r,n))return!0;if(i.rest&&on(i.rest,n))return!0;return!1}return!1}var nx=(e,t={})=>(n)=>{let i=Vh({...n,processors:t});return It(e,i),$h(i,e),Wh(i,e)},Io=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Vh({...r??{},target:s,io:t,processors:n});return It(e,o),$h(o,e),Wh(o,e)};var Rs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Cs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},ix=(e,t)=>{Rs(e,"minimum",t),Cs(e,"maximum",t)},ax=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},cx=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},lx=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},ux=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},rx=(e,t)=>Rs(e,"minimum",t.minimum),sx=(e,t)=>Cs(e,"maximum",t.maximum),ox=(e)=>(t,n)=>{ux(t,n.format);let[i,r]=e[n.format];Rs(t,"minimum",i),Cs(t,"maximum",r)},TA={greater_than:(e,t)=>Rs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Cs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ax(e,t.value),number_format:ox(ic),bigint_format:ox(ch),min_length:rx,max_length:sx,length_equals:(e,t)=>ix(e,t.length),min_size:rx,max_size:sx,size_equals:(e,t)=>ix(e,t.size),string_format:(e,t)=>{if(ux(e,t.format),t.pattern)cx(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>lx(e,t.mime)};function Dn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)TA[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Rs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Rs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Cs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Cs(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)ax(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)lx(t,r.mime);for(let s of r.patterns??[])cx(t,s);return t}var AA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},RA=new Map([[wh,Cg],[xc,Pg]]),hx=(e)=>RA.get(e)??e,fx=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Dn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=AA[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(hx);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},dx=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Dn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else Di(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},px=(e,t,n,i)=>{n.type="boolean"};var mx=(e,t,n,i)=>{n.not={}};var gx=(e,t,n,i)=>{};var _x=(e,t,n,i)=>{let r=e._zod.def,s=xo(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},xx=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var yx=(e,t,n,i)=>{Di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var vx=(e,t,n,i)=>{Di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var bx=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Dn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function Rc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Rc(t.out);if(t.type==="catch")return Rc(t.innerType);return e._zod.optin}var Sx=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Nn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Rc(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Mx=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},wx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Zh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=Zh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>Zh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?Mo:_h).source;return d}var Xh=new WeakMap;function CA(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Xh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Zh(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var Ex=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Dn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)Nn(r.patternProperties,hx(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Xh.get(t);if(!u)u=[],Xh.set(t,u),t.deferred.push(()=>CA(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Rc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},Tx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Ax=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},qh=Symbol();function Rx(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),qh}var Cx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Rx(r.defaultValue,e,t,n,i);if(o!==qh)n.default=o},Px=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Rx(r.defaultValue,e,t,n,i);if(o!==qh)n._prefault=o},Ix=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Lx=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},Nx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var jh=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Dx=new WeakSet([Object.prototype,Error.prototype]);function Cc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var FA=(e,t)=>{ng.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Dx.has(n))return;Dx.add(n),Cc(n,"format",(i)=>(r)=>rg(i,r)),Cc(n,"flatten",(i)=>(r)=>ig(i,r)),Cc(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,yo,2)}),Cc(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,yo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=J("ZodError",FA,void 0,{Parent:Error});var Ox=lc(Mn),Ux=uc(Mn),Fx=hc(Mn),zx=fc(Mn),kx=og(Mn),Bx=ag(Mn),Gx=cg(Mn),Hx=lg(Mn),Vx=ug(Mn),$x=hg(Mn),Wx=fg(Mn),Zx=dg(Mn);function kA(){if(!dn.localeError)Sn(Ph())}function Ic(){if(!dn.memoizer)Sn({memoizer:f0()})}var Et=J("ZodType",(e,t)=>(kA(),Mt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(bn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return hi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(U1(e,t))},superRefine(e,t){return this.check(F1(e,t))},overwrite(e){return this.check(lr(e))},optional(){return jx(this)},exactOptional(){return M1(this)},nullable(){return Yx(this)},nullish(){return jx(Yx(this))},nonoptional(e){return C1(this,e)},array(){return an(this)},or(e){return ty([this,e])},and(e){return y1(this,e)},transform(e){return Kx(this,S1(e))},default(e){return T1(this,e)},prefault(e){return R1(this,e)},catch(e){return I1(this,e)},pipe(e){return Kx(this,e)},readonly(){return D1(this)},describe(e){let t=this.clone();return Or.add(t,{description:e}),t},meta(...e){if(e.length===0)return Or.get(this);let t=this.clone();return Or.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return ac(this,"~standard",{...Mh(this),jsonSchema:{input:Io(this,"input"),output:Io(this,"output")}})},set "~standard"(e){Ni(this,"~standard",e)},parse:function e(t,n){return Ox(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ux(this,t,n,{callee:e})},safeParse(e,t){return Fx(this,e,t)},async safeParseAsync(e,t){return zx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ni(this,"spa",e)},validate(e,t){return dh(this,e,t)},validateAsync(e,t){return ph(this,e,t)},encode:function e(t,n){return kx(this,t,n,{callee:e})},decode:function e(t,n){return Bx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Hx(this,t,n,{callee:e})},safeEncode(e,t){return Vx(this,e,t)},safeDecode(e,t){return $x(this,e,t)},async safeEncodeAsync(e,t){return Wx(this,e,t)},async safeDecodeAsync(e,t){return Zx(this,e,t)},toJSONSchema(e){return nx(this,{})(e)},get description(){return Or.get(this)?.description},get _def(){return this._zod.def}}),Jx=J("_ZodString",(e,t)=>{_c.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fx(e,n,i,r)},Ym({format:(e)=>Dn(e).format??null,minLength:(e)=>Dn(e).minimum??null,maxLength:(e)=>Dn(e).maximum??null},{regex(...e){return this.check(Ih(...e))},includes(...e){return this.check(Dh(...e))},startsWith(...e){return this.check(Oh(...e))},endsWith(...e){return this.check(Uh(...e))},min(...e){return this.check(As(...e))},max(...e){return this.check(Tc(...e))},length(...e){return this.check(Ac(...e))},nonempty(...e){return this.check(As(1,...e))},lowercase(e){return this.check(Lh(e))},uppercase(e){return this.check(Nh(e))},trim(){return this.check(zh())},normalize(...e){return this.check(Fh(...e))},toLowerCase(){return this.check(kh())},toUpperCase(){return this.check(Bh())},slugify(){return this.check(Gh())}})),BA=J("ZodString",(e,t)=>{_c.init(e,t),Jx.init(e,t)},{email(e){return this.check(_0(WA,e))},url(e){return this.check(M0(XA,e))},jwt(e){return this.check(z0(c1,e))},emoji(e){return this.check(w0(qA,e))},guid(e){return this.check(x0(ZA,e))},uuid(e){return this.check(y0(Pc,e))},uuidv4(e){return this.check(v0(Pc,e))},uuidv6(e){return this.check(b0(Pc,e))},uuidv7(e){return this.check(S0(Pc,e))},nanoid(e){return this.check(E0(jA,e))},cuid(e){return this.check(T0(YA,e))},cuid2(e){return this.check(A0(KA,e))},ulid(e){return this.check(R0(JA,e))},base64(e){return this.check(O0(s1,e))},base64url(e){return this.check(U0(o1,e))},xid(e){return this.check(C0(QA,e))},ksuid(e){return this.check(P0(e1,e))},ipv4(e){return this.check(I0(t1,e))},ipv6(e){return this.check(L0(n1,e))},cidrv4(e){return this.check(N0(i1,e))},cidrv6(e){return this.check(D0(r1,e))},e164(e){return this.check(F0(a1,e))},datetime(e){return this.check(k0(GA,e))},date(e){return this.check(B0(HA,e))},time(e){return this.check(G0(VA,e))},duration(e){return this.check(H0($A,e))}});function Je(e){return g0(BA,e)}var Tt=J("ZodStringFormat",(e,t)=>{bt.init(e,t),Jx.init(e,t)}),GA=J("ZodISODateTime",(e,t)=>{E_.init(e,t),Tt.init(e,t)}),HA=J("ZodISODate",(e,t)=>{T_.init(e,t),Tt.init(e,t)}),VA=J("ZodISOTime",(e,t)=>{A_.init(e,t),Tt.init(e,t)}),$A=J("ZodISODuration",(e,t)=>{R_.init(e,t),Tt.init(e,t)}),WA=J("ZodEmail",(e,t)=>{p_.init(e,t),Tt.init(e,t)});var ZA=J("ZodGUID",(e,t)=>{f_.init(e,t),Tt.init(e,t)});var Pc=J("ZodUUID",(e,t)=>{d_.init(e,t),Tt.init(e,t)});var XA=J("ZodURL",(e,t)=>{__.init(e,t),Tt.init(e,t)});var qA=J("ZodEmoji",(e,t)=>{x_.init(e,t),Tt.init(e,t)});var jA=J("ZodNanoID",(e,t)=>{y_.init(e,t),Tt.init(e,t)});var YA=J("ZodCUID",(e,t)=>{v_.init(e,t),Tt.init(e,t)});var KA=J("ZodCUID2",(e,t)=>{b_.init(e,t),Tt.init(e,t)});var JA=J("ZodULID",(e,t)=>{S_.init(e,t),Tt.init(e,t)});var QA=J("ZodXID",(e,t)=>{M_.init(e,t),Tt.init(e,t)});var e1=J("ZodKSUID",(e,t)=>{w_.init(e,t),Tt.init(e,t)});var t1=J("ZodIPv4",(e,t)=>{C_.init(e,t),Tt.init(e,t)});var n1=J("ZodIPv6",(e,t)=>{I_.init(e,t),Tt.init(e,t)});var i1=J("ZodCIDRv4",(e,t)=>{L_.init(e,t),Tt.init(e,t)});var r1=J("ZodCIDRv6",(e,t)=>{N_.init(e,t),Tt.init(e,t)});var s1=J("ZodBase64",(e,t)=>{O_.init(e,t),Tt.init(e,t)});var o1=J("ZodBase64URL",(e,t)=>{U_.init(e,t),Tt.init(e,t)});var a1=J("ZodE164",(e,t)=>{F_.init(e,t),Tt.init(e,t)});var c1=J("ZodJWT",(e,t)=>{z_.init(e,t),Tt.init(e,t)});var Qx=J("ZodNumber",(e,t)=>{Eh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dx(e,n,i,r),e.isFinite=!0},Ym({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Dn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Dn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Dn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Dn(e).format??null},{gt(e,t){return this.check(wc(e,t))},gte(e,t){return this.check(Co(e,t))},min(e,t){return this.check(Co(e,t))},lt(e,t){return this.check(Mc(e,t))},lte(e,t){return this.check(Ro(e,t))},max(e,t){return this.check(Ro(e,t))},int(e){return this.check(Xx(e))},safe(e){return this.check(Xx(e))},positive(e){return this.check(wc(0,e))},nonnegative(e){return this.check(Co(0,e))},negative(e){return this.check(Mc(0,e))},nonpositive(e){return this.check(Ro(0,e))},multipleOf(e,t){return this.check(Ec(e,t))},step(e,t){return this.check(Ec(e,t))},finite(){return this}}));function pt(e){return V0(Qx,e)}var l1=J("ZodNumberFormat",(e,t)=>{k_.init(e,t),Qx.init(e,t)});function Xx(e){return $0(l1,e)}var u1=J("ZodBoolean",(e,t)=>{B_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>px(e,n,i,r)});function Lo(e){return W0(u1,e)}var h1=J("ZodUnknown",(e,t)=>{G_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gx(e,n,i,r)});function Ur(){return Z0(h1)}var f1=J("ZodNever",(e,t)=>{H_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mx(e,n,i,r)});function d1(e){return X0(f1,e)}var p1=J("ZodArray",(e,t)=>{Ic(),V_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bx(e,n,i,r),e.element=t.element},{min(e,t){return this.check(As(e,t))},nonempty(e){return this.check(As(1,e))},max(e,t){return this.check(Tc(e,t))},length(e,t){return this.check(Ac(e,t))},unwrap(){return this.element}});function an(e,t){return q0(p1,e,t)}var m1=J("ZodObject",(e,t)=>{Ic(),Z_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sx(e,n,i,r),XT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return On(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(bn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(bn(this._zod.def,{catchall:Ur()}))},loose(){return this.clone(bn(this._zod.def,{catchall:Ur()}))},strict(){return this.clone(bn(this._zod.def,{catchall:d1()}))},strip(){return this.clone(bn(this._zod.def,{catchall:void 0}))},extend(e){return kT(this,e)},safeExtend(e){return BT(this,e)},merge(e){return GT(this,e)},pick(e){return FT(this,e)},omit(e){return zT(this,e)},partial(...e){return Zm(ny,this,e[0])},exactPartial(...e){return Zm(iy,this,e[0],"exactPartial")},required(...e){return HT(ry,this,e[0])}});function ht(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new m1(n)}var ey=J("ZodUnion",(e,t)=>{Th.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mx(e,n,i,r),e.options=t.options});function ty(e,t){return new ey({type:"union",options:e,...Ce(t)})}var g1=J("ZodDiscriminatedUnion",(e,t)=>{ey.init(e,t),X_.init(e,t)});function _1(e,t,n){return new g1({type:"union",options:t,discriminator:e,...Ce(n)})}var x1=J("ZodIntersection",(e,t)=>{q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wx(e,n,i,r)});function y1(e,t){return new x1({type:"intersection",left:e,right:t})}var qx=J("ZodRecord",(e,t)=>{Ic(),j_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ex(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Lc(e,t,n){if(!t||!t._zod)return new qx({type:"record",keyType:Je(),valueType:e,...Ce(t)});return new qx({type:"record",keyType:e,valueType:t,...Ce(n)})}var Kh=J("ZodEnum",(e,t)=>{Y_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(i,r,s)=>_x(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Kh({...t,checks:[],...Ce(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Kh({...t,checks:[],...Ce(r),entries:s})}});function On(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Kh({type:"enum",entries:n,...Ce(t)})}var v1=J("ZodLiteral",(e,t)=>{K_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xx(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qt(e,t){return new v1({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var b1=J("ZodTransform",(e,t)=>{Ic(),J_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vx(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new So(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Dr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Dr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function S1(e){return new b1({type:"transform",transform:e})}var ny=J("ZodOptional",(e,t)=>{Ah.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function jx(e){return new ny({type:"optional",innerType:e})}var iy=J("ZodExactOptional",(e,t)=>{Q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function M1(e){return new iy({type:"optional",innerType:e})}var w1=J("ZodNullable",(e,t)=>{e0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Yx(e){return new w1({type:"nullable",innerType:e})}var E1=J("ZodDefault",(e,t)=>{t0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function T1(e,t){return new E1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():oh(t)}})}var A1=J("ZodPrefault",(e,t)=>{n0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Px(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function R1(e,t){return new A1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():oh(t)}})}var ry=J("ZodNonOptional",(e,t)=>{i0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ax(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function C1(e,t){return new ry({type:"nonoptional",innerType:e,...Ce(t)})}var P1=J("ZodCatch",(e,t)=>{r0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ix(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function I1(e,t){return new P1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Km(t)})}var L1=J("ZodPipe",(e,t)=>{s0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lx(e,n,i,r),e.in=t.in,e.out=t.out});function Kx(e,t){return new L1({type:"pipe",in:e,out:t})}var N1=J("ZodReadonly",(e,t)=>{o0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Nx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function D1(e){return new N1({type:"readonly",innerType:e})}var O1=J("ZodCustom",(e,t)=>{a0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yx(e,n,i,r)});function U1(e,t={}){return j0(O1,e,t)}function F1(e,t){return Y0(e,t)}var oy=["neutral","dark","light"];var Jh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),ay=Object.freeze({neutral:Jh("neutral",[170,177,188]),dark:Jh("dark",[26,26,26]),light:Jh("light",[223,227,232])});var xD=ay.neutral.rgb,yD=ay.neutral.hex;/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
-*/var Rt=Uint8Array,wn=Uint16Array,af=Int32Array,Lc=new Rt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Nc=new Rt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),tf=new Rt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dy=function(e,t){var n=new wn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new af(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},py=dy(Lc,2),{b:my,r:nf}=py;my[28]=258,nf[258]=28;var gy=dy(Nc,0),{b:U1,r:ay}=gy,rf=new wn(32768);for(je=0;je<32768;++je)mi=(je&43690)>>1|(je&21845)<<1,mi=(mi&52428)>>2|(mi&13107)<<2,mi=(mi&61680)>>4|(mi&3855)<<4,rf[je]=((mi&65280)>>8|(mi&255)<<8)>>1;var mi,je,gi=function(e,t,n){var i=e.length,r=0,s=new wn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new wn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new wn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[rf[f]>>c]=l}}else{a=new wn(i);for(r=0;r<i;++r)if(e[r])a[r]=rf[o[e[r]-1]++]>>15-e[r]}return a},lr=new Rt(288);for(je=0;je<144;++je)lr[je]=8;var je;for(je=144;je<256;++je)lr[je]=9;var je;for(je=256;je<280;++je)lr[je]=7;var je;for(je=280;je<288;++je)lr[je]=8;var je,Io=new Rt(32);for(je=0;je<32;++je)Io[je]=5;var je,F1=gi(lr,9,0),z1=gi(lr,9,1),k1=gi(Io,5,0),B1=gi(Io,5,1),Jh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Zn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Qh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},cf=function(e){return(e+7)/8|0},lf=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Rt(e.subarray(t,n))};var G1=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],On=function(e,t,n){var i=Error(t||G1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,On);if(!n)throw i;return i},H1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Rt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Rt(r*3);var l=function(_e){var Qe=n.length;if(_e>Qe){var ze=new Rt(Math.max(Qe*2,_e));ze.set(n),n=ze}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Zn(e,f,1);var E=Zn(e,f+1,3);if(f+=3,!E){var R=cf(f)+4,v=e[R-4]|e[R-3]<<8,M=R+v;if(M>r){if(c)On(0);break}if(a)l(h+v);n.set(e.subarray(R,M),h),t.b=h+=v,t.p=f=M*8,t.f=u;continue}else if(E==1)d=z1,g=B1,x=9,p=5;else if(E==2){var T=Zn(e,f,31)+257,A=Zn(e,f+10,15)+4,_=T+Zn(e,f+5,31)+1;f+=14;var S=new Rt(_),k=new Rt(19);for(var C=0;C<A;++C)k[tf[C]]=Zn(e,f+C*3,7);f+=A*3;var U=Jh(k),ee=(1<<U)-1,P=gi(k,U,1);for(var C=0;C<_;){var V=P[Zn(e,f,ee)];f+=V&15;var R=V>>4;if(R<16)S[C++]=R;else{var j=0,z=0;if(R==16)z=3+Zn(e,f,3),f+=2,j=S[C-1];else if(R==17)z=3+Zn(e,f,7),f+=3;else if(R==18)z=11+Zn(e,f,127),f+=7;while(z--)S[C++]=j}}var H=S.subarray(0,T),F=S.subarray(T);x=Jh(H),p=Jh(F),d=gi(H,x,1),g=gi(F,p,1)}else On(1);if(f>m){if(c)On(0);break}}if(a)l(h+131072);var q=(1<<x)-1,K=(1<<p)-1,xe=f;for(;;xe=f){var j=d[Qh(e,f)&q],ce=j>>4;if(f+=j&15,f>m){if(c)On(0);break}if(!j)On(2);if(ce<256)n[h++]=ce;else if(ce==256){xe=f,d=null;break}else{var De=ce-254;if(ce>264){var C=ce-257,ye=Lc[C];De=Zn(e,f,(1<<ye)-1)+my[C],f+=ye}var X=g[Qh(e,f)&K],re=X>>4;if(!X)On(3);f+=X&15;var F=U1[re];if(re>3){var ye=Nc[re];F+=Qh(e,f)&(1<<ye)-1,f+=ye}if(f>m){if(c)On(0);break}if(a)l(h+131072);var se=h+De;if(h<F){var Te=s-F,Ie=Math.min(F,se);if(Te+h<0)On(3);for(;h<Ie;++h)n[h]=i[Te+h]}for(;h<se;++h)n[h]=n[h-F]}}if(t.l=d,t.p=xe,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?lf(n,0,h):n.subarray(0,h)},Di=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},Co=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},ef=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:xy,l:0};if(r==1){var o=new Rt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(M,T){return M.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new wn(h+1),g=sf(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var v=s[i].s;if(d[v]==t)--d[v],++x}g=t}return{t:new Rt(d),l:g}},sf=function(e,t,n){return e.s==-1?Math.max(sf(e.l,t,n+1),sf(e.r,t,n+1)):t[e.s]=n},cy=function(e){var t=e.length;while(t&&!e[--t]);var n=new wn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},Po=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},_y=function(e,t,n){var i=n.length,r=cf(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},ly=function(e,t,n,i,r,s,o,a,c,l,u){Di(t,u++,n),++r[256];var f=ef(r,15),{t:h,l:d}=f,g=ef(s,15),{t:x,l:p}=g,m=cy(h),{c:E,n:R}=m,v=cy(x),{c:M,n:T}=v,A=new wn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<M.length;++_)++A[M[_]&31];var S=ef(A,7),{t:k,l:C}=S,U=19;for(;U>4&&!k[tf[U-1]];--U);var ee=l+5<<3,P=Po(r,lr)+Po(s,Io)+o,V=Po(r,h)+Po(s,x)+o+14+3*U+Po(A,k)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&ee<=P&&ee<=V)return _y(t,u,e.subarray(c,c+l));var j,z,H,F;if(Di(t,u,1+(V<P)),u+=2,V<P){j=gi(h,d,0),z=h,H=gi(x,p,0),F=x;var q=gi(k,C,0);Di(t,u,R-257),Di(t,u+5,T-1),Di(t,u+10,U-4),u+=14;for(var _=0;_<U;++_)Di(t,u+3*_,k[tf[_]]);u+=3*U;var K=[E,M];for(var xe=0;xe<2;++xe){var ce=K[xe];for(var _=0;_<ce.length;++_){var De=ce[_]&31;if(Di(t,u,q[De]),u+=k[De],De>15)Di(t,u,ce[_]>>5&127),u+=ce[_]>>12}}}else j=F1,z=lr,H=k1,F=Io;for(var _=0;_<a;++_){var ye=i[_];if(ye>255){var De=ye>>18&31;if(Co(t,u,j[De+257]),u+=z[De+257],De>7)Di(t,u,ye>>23&31),u+=Lc[De];var X=ye&31;if(Co(t,u,H[X]),u+=F[X],X>3)Co(t,u,ye>>5&8191),u+=Nc[X]}else Co(t,u,j[ye]),u+=z[ye]}return Co(t,u,j[256]),u+z[256]},V1=new af([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xy=new Rt(0),$1=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Rt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=V1[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new wn(32768),p=s.h||new wn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},v=new af(25000),M=new wn(288),T=new wn(32),A=0,_=0,S=s.i||0,k=0,C=s.w||0,U=0;for(;S+2<o;++S){var ee=R(S),P=S&32767,V=p[ee];if(x[P]=V,p[ee]=P,C<=S){var j=o-S;if((A>7000||k>24576)&&(j>423||!l)){u=ly(e,c,0,v,M,T,_,k,U,S-U,u),k=A=_=0,U=S;for(var z=0;z<286;++z)M[z]=0;for(var z=0;z<30;++z)T[z]=0}var H=2,F=0,q=d,K=P-V&32767;if(j>2&&ee==R(S-K)){var xe=Math.min(h,j)-1,ce=Math.min(32767,S),De=Math.min(258,j);while(K<=ce&&--q&&P!=V){if(e[S+H]==e[S+H-K]){var ye=0;for(;ye<De&&e[S+ye]==e[S+ye-K];++ye);if(ye>H){if(H=ye,F=K,ye>xe)break;var X=Math.min(K,ye-2),re=0;for(var z=0;z<X;++z){var se=S-K+z&32767,Te=x[se],Ie=se-Te&32767;if(Ie>re)re=Ie,V=se}}}P=V,V=x[P],K+=P-V&32767}}if(F){v[k++]=268435456|nf[H]<<18|ay[F];var _e=nf[H]&31,Qe=ay[F]&31;_+=Lc[_e]+Nc[Qe],++M[257+_e],++T[Qe],C=S+H,++A}else v[k++]=e[S],++M[e[S]]}}for(S=Math.max(S,C);S<o;++S)v[k++]=e[S],++M[e[S]];if(u=ly(e,c,l,v,M,T,_,k,U,S-U,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=S,s.w=C}else{for(var S=s.w||0;S<o+l;S+=65535){var ze=S+65535;if(ze>=o)c[u/8|0]=l,ze=o;u=_y(c,u+1,e.subarray(S,ze))}s.i=o}return lf(a,0,i+cf(u)+r)},W1=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Z1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=W1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var X1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Rt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return $1(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},yy=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var jt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function vy(e,t){return X1(e,t||{},0,0)}function by(e,t){return H1(e,{i:2},t&&t.out,t&&t.dictionary)}var Sy=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=yy(i,s[1]),s=s[0];if(s instanceof Rt)n[o]=[s,a];else n[o+="/"]=[new Rt(0),a],Sy(s,o,n,i)}},uy=typeof TextEncoder<"u"&&new TextEncoder,q1=typeof TextDecoder<"u"&&new TextDecoder,j1=0;try{q1.decode(xy,{stream:!0}),j1=1}catch(e){}function hy(e,t){if(t){var n=new Rt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(uy)return uy.encode(e);var r=e.length,s=new Rt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Rt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return lf(s,0,o)}var of=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)On(9);t+=i+4}return t},fy=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=of(l);if(jt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)On(10);if(jt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)jt(e,t,n.crc),jt(e,t+4,s<0?-s-2:s),jt(e,t+8,n.size);if(jt(e,t+12,c),jt(e,t+14,f),t+=16,o!=null)jt(e,t,u),jt(e,t+6,n.attrs),jt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;jt(e,t,+g),jt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},Y1=function(e,t,n,i,r){jt(e,t,101010256),jt(e,t+8,n),jt(e,t+10,n),jt(e,t+12,i),jt(e,t+16,r)};function My(e,t){if(!t)t={};var n={},i=[];Sy(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=hy(o),h=f.length,d=l.comment,g=d&&hy(d),x=g&&g.length,p=of(l.extra);if(h>65535)On(11);var m=u?vy(c,l):c,E=m.length,R=Z1();R.p(c),i.push(yy(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var v=new Rt(s+22),M=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];fy(v,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+of(f.extra);v.set(f.c,f.o+_),fy(v,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return Y1(v,r,i.length,T,M),v}var uf=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function K1(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class hf extends Error{diagnostic;constructor(e,t=K1(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var wy=1024,Ey=4,Ty=8,J1=6,Ay=80,Lo=256;class St extends hf{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Ry=["solid","checker","stripes","gradient","bricks","noise"],Cy=["normal","multiply","screen","overlay"],Q1=new Set(["__proto__","prototype","constructor"]);function Dc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new St(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new St(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new St(`${t} must not contain symbol keys.`);if(Q1.has(i))throw new St(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new St(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new St(`${t}.${i} must be a plain JSON data field.`)}return e}function eR(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new St(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new St(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new St(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new St(`${t} must be a dense JSON array (missing index ${n}).`);return e}function ur(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new St(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Xn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new St(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Ur(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new St(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Iy(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new St(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function ff(e,t,n){return Iy(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function tR(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Ay||n)throw new St(`${t} must be 1..${Ay} visible characters.`);return e}function nR(e,t,n){if(e===void 0)return n;if(!uf.includes(e))throw new St(`${t} must be one of ${uf.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Py(e,t){let i=(Iy(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function iR(e,t){let n=e.blend??"normal";if(!Cy.includes(n))throw new St(`${t}.blend ${JSON.stringify(n)} is not one of ${Cy.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function rR(e,t){let n=`proceduralTexture.layers[${t}]`,i=Dc(e,n),r=i.op;if(!Ry.includes(r))throw new St(`${n}.op ${JSON.stringify(r)} is not one of ${Ry.join(", ")}.`);let s=iR(i,n),o=ff(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return ur(i,["op","color","blend","opacity"],n),{op:r,color:Xn(i.color,`${n}.color`),...a};case"checker":return ur(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Xn(i.colorA,`${n}.colorA`),colorB:Xn(i.colorB,`${n}.colorB`),squares:Ur(i.squares,`${n}.squares`,8,1,Lo),...a};case"stripes":return ur(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Xn(i.colorA,`${n}.colorA`),colorB:Xn(i.colorB,`${n}.colorB`),count:Ur(i.count,`${n}.count`,8,1,Lo),angleDeg:Py(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return ur(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Xn(i.from,`${n}.from`),to:Xn(i.to,`${n}.to`),angleDeg:Py(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return ur(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Xn(i.brick,`${n}.brick`),mortar:Xn(i.mortar,`${n}.mortar`),rows:Ur(i.rows,`${n}.rows`,8,1,Lo),cols:Ur(i.cols,`${n}.cols`,4,1,Lo),mortarWidth:ff(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:ff(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return ur(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Xn(i.colorA,`${n}.colorA`),colorB:Xn(i.colorB,`${n}.colorB`),scale:Ur(i.scale,`${n}.scale`,8,1,Lo),octaves:Ur(i.octaves,`${n}.octaves`,3,1,J1),seed:Ur(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new St(`${n}.op is unsupported.`)}}function sR(e){let t=Dc(e,"proceduralTexture");if(ur(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new St(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Ly(e){let t=Dc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Dc(sR(t),"proceduralTexture"):t;if(ur(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new St(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Ey||i>wy||(i&i-1)!==0)throw new St(`proceduralTexture.size must be a power of two between ${Ey} and ${wy}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new St("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=eR(r,"proceduralTexture.layers");if(s.length>Ty)throw new St(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Ty}.`);let o=tR(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:nR(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(rR)}}var wD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var jn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Dy=["baseColor","normal","metallicRoughness","emissive","occlusion"],oR={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Do=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),Oo=Je().regex(/^sha256:[a-f0-9]{64}$/),hr=Je().min(1).max(1000),Ny=Je().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Oy=ft({id:Do,kind:Dn(["external","procedural"]),provider:hr,creator:hr,assetId:hr.optional(),assetUrl:Ny.optional(),accessedAt:Je().datetime().optional(),license:ft({spdx:hr,url:Ny,attribution:Je().max(4000)}).strict(),originalFiles:an(ft({name:Je().min(1).max(200),sha256:Oo,bytes:mt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Uy=ft({operation:hr,tool:hr,version:hr,parameters:Ic(Je().max(100),ey([Je().max(2000),mt().finite(),Ro()])).optional()}).strict(),qn=mt().int().min(0).max(16777215),No=mt().int().min(1).max(256),As={blend:Dn(["normal","multiply","screen","overlay"]).default("normal"),opacity:mt().min(0).max(1).default(1)},Fy=ft({schemaVersion:qt(2),size:mt().int().min(4).max(1024).default(256),usage:Dn(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Je().min(1).max(80).optional(),layers:an(m1("op",[ft({op:qt("solid"),color:qn,...As}).strict(),ft({op:qt("checker"),colorA:qn,colorB:qn,squares:No.default(8),...As}).strict(),ft({op:qt("stripes"),colorA:qn,colorB:qn,count:No.default(8),angleDeg:mt().min(-36000).max(36000).default(0),...As}).strict(),ft({op:qt("gradient"),from:qn,to:qn,angleDeg:mt().min(-36000).max(36000).default(0),...As}).strict(),ft({op:qt("bricks"),brick:qn,mortar:qn,rows:No.default(8),cols:No.default(4),mortarWidth:mt().min(0).max(1).default(0.06),stagger:mt().min(0).max(1).default(0.5),...As}).strict(),ft({op:qt("noise"),colorA:qn,colorB:qn,scale:No.default(8),octaves:mt().int().min(1).max(6).default(3),seed:mt().int().min(-2147483648).max(2147483647).default(0),...As}).strict()])).min(1).max(8)}).strict(),zy=ft({kind:qt("normal-from-height"),strength:mt().finite().positive().max(64)}).strict(),aR=ft({compiler:qt("kiln.procedural-texture.v2"),spec:Fy,derive:zy.optional(),recipeHash:Oo,pixelHash:Oo,encoder:ft({name:qt("sharp"),version:hr}).strict()}).strict(),ky=ft({baseColor:mt().int().min(0).max(16777215).optional(),roughness:mt().min(0).max(1).default(1),metalness:mt().min(0).max(1).default(0),emissive:mt().int().min(0).max(16777215).optional(),emissiveIntensity:mt().min(0).max(64).default(1),alphaMode:Dn(["opaque","mask","blend"]).default("opaque"),alphaCutoff:mt().min(0).max(1).default(0.5),doubleSided:Ro().default(!1)}).strict(),By=ft({schemaVersion:qt(1),materialId:Do,revisionId:Oo,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30),tileable:Ro(),physicalSizeMeters:ft({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:ky,sources:an(Oy).min(1).max(20),maps:an(ft({slot:Dn(Dy),file:Dn(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Oo,bytes:mt().int().positive().max(jn.maxMapBytes),width:mt().int().positive().max(jn.maxMapEdge),height:mt().int().positive().max(jn.maxMapEdge),usage:Dn(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Dn(["srgb","linear"]),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Do,originalFile:Je().min(1).max(200).optional(),transforms:an(Uy).max(30),procedural:aR.optional()}).strict()).min(1).max(5)}).strict(),RD=ft({materialId:Do,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30).optional(),tileable:Ro(),physicalSizeMeters:ft({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:ky.partial().optional(),sources:an(Oy).min(1).max(20),maps:an(ft({slot:Dn(Dy),sourceId:Do,transforms:an(Uy).max(30),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),procedural:Fy,derive:zy.optional()}).strict()).min(1).max(5)}).strict(),Gy=ft({schemaVersion:qt(1),records:an(ft({manifest:By,files:Ic(Je().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Je().max(Math.ceil(jn.maxMapBytes/3)*4))}).strict()).max(jn.maxPayloadRecords)}).strict();function Fo(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Fo(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Uo(e){Fo(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function Hy(e){if(Fo(e),new TextEncoder().encode(JSON.stringify(e)).length>jn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=By.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==oR[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Uo(r.procedural.spec)!==Uo(Ly(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>jn.maxRecordBytes||i>jn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Oc=67108864,df=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),cR=Je().regex(/^sha256:[a-f0-9]{64}$/),pf=ft({version:qt("kiln.asset.v1"),assetId:df,revisionId:df,parentRevision:df.optional(),name:Je().min(1).max(200),tags:an(Je().max(80)).max(30),createdAt:Je().datetime(),description:Je().max(4000).optional(),brief:Je().max(8000).optional(),attribution:ft({model:Je().max(200).optional(),harness:Je().max(200).optional(),author:Je().max(200).optional()}).optional(),editable:Ro(),files:Ic(Je(),ft({sha256:cR,bytes:mt().int().nonnegative().max(Oc)})),build:ft({engine:Je(),options:Ic(Je(),Or()),warnings:an(Je()),integration:Or().optional(),qa:Or().optional(),dependencies:an(Or()).optional(),rebuild:Dn(["engine-required","external-dependencies-required"])}).optional(),preview:ft({fidelity:Or().optional(),error:Je().optional(),backdrop:Dn(sy).optional()}).optional()}),lR="materials.kiln.json",uR=25165824;function Vy(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=Hy(c.manifest);return[`${l.materialId}/${l.revisionId}`,Uo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Fo(e.materialResources);let r=Gy.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Uo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>jn.maxPayloadBytes||o>jn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var hR=new Set(["asset.glb","source.kiln.js","preview.png"]);function fR(e){let t=pf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!hR.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Oc||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");mf(e.files["asset.glb"]),Vy(e)}function mf(e){if(e.length<20||e.length>Oc)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function $y(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){fR(i),Vy(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>uR)throw Error("Asset material payload exceeds byte limit");t[r+lR]=s}}for(let i of Object.values(t))n+=i.length;if(n>Oc)throw Error("Bundle exceeds 64 MiB");return My(t,{level:0})}function Wy(e,t,n=40,i=[e]){let r=e.getCenter(new D),s=Math.max(e.getSize(new D).length()/2,0.01),o=new D(1,0.65,1.25).normalize(),a=new D().crossVectors(new D(0,1,0),o).normalize(),c=new D().crossVectors(o,a),l=[];for(let E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let v of[E.min.y,E.max.y])for(let M of[E.min.z,E.max.z])l.push(new D(R,v,M));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),v=R.dot(a),M=R.dot(c);u=Math.min(u,v),f=Math.max(f,v),h=Math.min(h,M),d=Math.max(d,M)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),v=R.dot(o);p=Math.max(p,v+Math.abs(R.dot(a))*1.12/x,v+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function gf(e,t){return{position:e.position.clone(),target:t.clone()}}function _f(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new D).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new D))+r*20,10),e.updateProjectionMatrix()}function Zy(e,t,n){let i=e.getWorldDirection(new D);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new D(0,1,0)),s=new D;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function Xy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function qy(e,t,n){if(t())return e;n(e);return}function Uc(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function Fc(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Ft().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Ft,i=new Ft,r=new D;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Ft().setFromObject(e,!0):n}function zo(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function jy(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((g)=>!Number.isInteger(g)||!t[g]||n.has(g)))continue;let f=l.parent;while(f&&!i.has(f))f=f.parent;if(f)continue;let h=[l];for(let g of u)h.push(await e.parser.getDependency("node",g));Uc(e,h.slice(1)),i.add(l);let d=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:d,levels:h})}if(r.length===0)return;let s=zo(e.scene)-r.reduce((c,l)=>c+xf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,f)=>u+xf(f,l),0));return{chains:r,triangles:a}}var Yy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function xf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return zo(Yy(e,t))}function Ky(e,t){let n=Yy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Jy(e,t){for(let n of e.chains)Ky(n,t)}function Qy(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Ky(i,n),!0}function ev(e,t){if(!e)return;return{triangles:zo(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>xf(n,r))}))}}function ko(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function tv(e){let t=new Hu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Gs,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new hs,i=new Ut(40,1,0.01,1000),r=new eh(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(H)=>{if(!o||!c.has(H.code))return;H.preventDefault(),s.add(H.code)},u=(H)=>s.delete(H.code),f=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",f);let h=new uo(t),d=new th,g=h.fromScene(d,0.04);n.environment=g.texture,d.dispose(),h.dispose();let x=new _s(16773591,2.4);x.position.set(4,8,5),n.add(x),n.add(new $a(14806490,5065021,1.7));let p,m,E,R=[],v=!0,M=performance.now(),T=0,A=0,_=!1,S,k,C,U=(H)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(H)),C=void 0},ee=(H)=>{let F=t.getContext(),q=F.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:H-C.started,frameMs:Xy(C.samples),...k===void 0?{}:{loadToFirstFrameMs:k},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(F.getParameter(F.VERSION)),vendor:String(F.getParameter(F.VENDOR)),renderer:String(F.getParameter(F.RENDERER)),browser:navigator.userAgent,...q?{unmaskedVendor:String(F.getParameter(q.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(F.getParameter(q.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},P=(H)=>{let F=new Set,q=new Set,K=new Set;H.traverse((xe)=>{let ce=xe;if(!ce.isMesh)return;F.add(ce.geometry);for(let De of Array.isArray(ce.material)?ce.material:[ce.material]){q.add(De);for(let ye of Object.values(De))if(ye instanceof At)K.add(ye)}});for(let xe of[...F,...q,...K])xe.dispose()},V=()=>{if(!p)return;let H=Fc(p),F=[];p.traverseVisible((De)=>{if(De instanceof xt||De instanceof Ki||De instanceof ps){let ye=new Ft().setFromObject(De,!0);if(!ye.isEmpty())F.push(ye)}});let{center:q,radius:K,distance:xe,position:ce}=Wy(H,i.aspect,i.fov,F);if(r.target.copy(q),i.position.copy(ce),i.near=Math.max(K/1000,0.0001),i.far=xe+K*100,r.minDistance=K*0.1,r.maxDistance=K*80,a=Math.max(K*0.35,0.01),o)r.minDistance=K*0.00001;i.updateProjectionMatrix(),r.update()},j=new ResizeObserver(()=>{let{clientWidth:H,clientHeight:F}=e;if(!H||!F)return;t.setSize(H,F),i.aspect=H/F,i.updateProjectionMatrix()});j.observe(e);let z=(H)=>{if(_)return;let F=Math.min((H-M)/1000,0.1);if(M=H,e.clientWidth&&e.clientHeight){if(v)E?.update(F);if(o&&s.size){let q=Zy(i,s,F*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(q),r.target.add(q)}if(r.update(),t.render(n,i),S!==void 0)k=performance.now()-S,S=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(H-C.previous);if(C.previous=H,H-C.started>=C.duration&&C.samples.length){let q=ee(H);clearTimeout(C.timeout),C.resolve(q),C=void 0}}}else s.clear(),U("Keep the measured viewport visible for the complete sampling window.");T=requestAnimationFrame(z)};return T=requestAnimationFrame(z),{async load(H,F={}){let q=performance.now(),K=++A;U("The artifact changed during measurement. Measure the new revision again."),mf(H);let xe=new no;xe.setURLModifier((_e)=>{if(!_e.startsWith("blob:")&&!_e.startsWith("data:"))throw Error("External model resources are not loaded");return _e});let ce=await new Yu(xe).parseAsync(Uint8Array.from(H).buffer,"");Uc(ce,[ce.scene]);let De=await jy(ce),ye=qy(ce,()=>!_&&K===A&&F.isCurrent?.()!==!1,(_e)=>{P(_e.scene);for(let Qe of ko(De))P(Qe)});if(!ye)return;let X=p&&F.preserveView?gf(i,r.target):void 0;if(p){E?.stopAllAction(),E?.uncacheRoot(p),n.remove(p),P(p);for(let _e of ko(m))P(_e)}p=ye.scene,m=De,S=q,k=void 0,n.add(p),R=ye.animations,E=new qa(p),v=!0;let{clientWidth:re,clientHeight:se}=e;if(t.setSize(re,se),i.aspect=re&&se?re/se:i.aspect,V(),X)_f(i,r.target,X,Fc(p)),r.update();let Te=0,Ie=new Set;return p.traverseVisible((_e)=>{let Qe=_e;if(!Qe.isMesh)return;Te++;for(let ze of Array.isArray(Qe.material)?Qe.material:[Qe.material])Ie.add(ze)}),F.onCommit?.(),{triangles:zo(p),meshes:Te,materials:Ie.size,clips:R.map((_e)=>_e.name),...m?{levels:m.triangles}:{}}},level(H){if(U("The level of detail changed. Measure the displayed combination again."),m)Jy(m,H)},partLevel(H,F){if(U("The level of detail changed. Measure the displayed combination again."),m)Qy(m,H,F)},lod(){return p?ev(m,p):void 0},reset:V,cancelMeasurement:U,measure(H=3000){if(_||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(H)||H<1000||H>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((F,q)=>{C={started:performance.now(),previous:0,duration:H,samples:[],resolve:F,reject:q,timeout:setTimeout(()=>U("Measurement was interrupted or the browser stopped delivering frames."),H+2000)}})},view(){return gf(i,r.target)},setView(H){if(!p)return;_f(i,r.target,H,Fc(p)),r.update()},navigation(H){if(o=H==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(H){for(let F of p?[p,...ko(m)]:[])F.traverse((q)=>{let K=q;if(K.isMesh){for(let xe of Array.isArray(K.material)?K.material:[K.material])if("wireframe"in xe)xe.wireframe=H}})},lighting(H){t.toneMappingExposure=H==="bright"?1.65:H==="soft"?0.85:1.15,x.intensity=H==="soft"?0.8:2.4},clip(H){if(E?.stopAllAction(),R[H])E?.clipAction(R[H]).play()},pause(H){v=!H},dispose(){if(U("The viewport closed before measurement finished."),_=!0,A++,cancelAnimationFrame(T),j.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",f),p)P(p);for(let H of ko(m))P(H);g.dispose(),t.dispose(),e.replaceChildren()}}}var nv=["127.0.0.1","localhost","[::1]"];async function iv(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&nv.includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var sv=16777216,ov=Math.ceil(sv/3)*4,Wt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function dR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function rv(e){if(typeof e!=="string"||e.length>ov)return Wt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Wt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Wt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(dR(n)!==e)Wt("contains noncanonical base64 data");return n}function Bo(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function av(e){if(!Bo(e))return Wt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=pf.safeParse(e.manifest);if(!t.success||!Bo(e.files))return Wt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Wt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Wt("file metadata is missing");if(r+=n.files[c].bytes,r>sv)return Wt("exceeds the decoded size limit");let u=typeof l==="string"?l:Bo(l)?l.data:void 0;if(typeof u!=="string")return Wt("file encoding is malformed");if(s+=u.length,s>ov)return Wt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=rv(l);else{if(!Bo(l)||l.encoding!=="kiln.deflate-base64.v1")return Wt("encoding is unsupported");let g=rv(l.data);try{f=by(g,{out:new Uint8Array(u.bytes+1)})}catch{return Wt("compressed data is damaged")}}if(f.length!==u.bytes)return Wt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Wt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Wt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!Bo(e.downloadUrls))return Wt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Wt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function cv(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Yn=(e)=>document.getElementById(e),_i=Yn("status"),nn,uv={},Go,pR=0,xi=0,zc=new Map;function hv(e,t){let n=++pR;return new Promise((i,r)=>{let s=setTimeout(()=>{zc.delete(n),r(Error("Chat host did not respond."))},20000);zc.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function lv(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function mR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function gR(e){let t=++xi;nn=void 0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await _R(e,t)}catch(n){if(t!==xi)return;_i.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function _R(e,t){if(e.isError){_i.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await av(e._meta?.kilnAsset)}catch(i){if(t!==xi)return;_i.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==xi)return;nn=n.record,Yn("name").textContent=nn.manifest.name,uv=n.downloadUrls,Yn("revision").textContent=`${nn.manifest.editable?"Editable source included":"GLB asset"} · ${nn.manifest.revisionId.slice(0,10)}`,Yn("attribution").textContent=cv(nn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{Go??=tv(Yn("stage"));let i=await Go.load(nn.files["asset.glb"]);if(t!==xi)return;if(i){Yn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(nn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Yn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}_i.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==xi)return;let r=nn.files["preview.png"];if(r){let s=new Image;s.alt=nn.manifest.name,s.src=`data:image/png;base64,${mR(r)}`,Yn("stage").replaceChildren(s)}_i.textContent=`3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Yn("source").hidden=!nn.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=zc.get(t.id);if(zc.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")gR(t.params);if(t.method==="ui/resource-teardown")Go?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Yn("reset").onclick=()=>Go?.reset();Yn("clips").onchange=(e)=>Go?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!nn)return;let t=xi,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?$y([nn]):nn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=nn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,_i.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await iv(r,`${o}-${i}`,s,hv,a,uv[i]);if(t!==xi)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},_i.replaceChildren("Download ready. ",l)}else _i.textContent="Download requested."}catch(a){if(t===xi)_i.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!nn||t!==xi}};hv("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{lv("ui/notifications/initialized"),lv("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{_i.textContent=e.message});
+*/var Rt=Uint8Array,wn=Uint16Array,cf=Int32Array,Nc=new Rt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Dc=new Rt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nf=new Rt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),py=function(e,t){var n=new wn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new cf(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},my=py(Nc,2),{b:gy,r:rf}=my;gy[28]=258,rf[258]=28;var _y=py(Dc,0),{b:z1,r:cy}=_y,sf=new wn(32768);for(je=0;je<32768;++je)mi=(je&43690)>>1|(je&21845)<<1,mi=(mi&52428)>>2|(mi&13107)<<2,mi=(mi&61680)>>4|(mi&3855)<<4,sf[je]=((mi&65280)>>8|(mi&255)<<8)>>1;var mi,je,gi=function(e,t,n){var i=e.length,r=0,s=new wn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new wn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new wn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[sf[f]>>c]=l}}else{a=new wn(i);for(r=0;r<i;++r)if(e[r])a[r]=sf[o[e[r]-1]++]>>15-e[r]}return a},ur=new Rt(288);for(je=0;je<144;++je)ur[je]=8;var je;for(je=144;je<256;++je)ur[je]=9;var je;for(je=256;je<280;++je)ur[je]=7;var je;for(je=280;je<288;++je)ur[je]=8;var je,Oo=new Rt(32);for(je=0;je<32;++je)Oo[je]=5;var je,k1=gi(ur,9,0),B1=gi(ur,9,1),G1=gi(Oo,5,0),H1=gi(Oo,5,1),Qh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Xn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},ef=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},lf=function(e){return(e+7)/8|0},uf=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Rt(e.subarray(t,n))};var V1=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Un=function(e,t,n){var i=Error(t||V1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Un);if(!n)throw i;return i},$1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Rt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Rt(r*3);var l=function(Ee){var xt=n.length;if(Ee>xt){var ke=new Rt(Math.max(xt*2,Ee));ke.set(n),n=ke}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Xn(e,f,1);var E=Xn(e,f+1,3);if(f+=3,!E){var R=lf(f)+4,v=e[R-4]|e[R-3]<<8,M=R+v;if(M>r){if(c)Un(0);break}if(a)l(h+v);n.set(e.subarray(R,M),h),t.b=h+=v,t.p=f=M*8,t.f=u;continue}else if(E==1)d=B1,g=H1,x=9,p=5;else if(E==2){var T=Xn(e,f,31)+257,A=Xn(e,f+10,15)+4,_=T+Xn(e,f+5,31)+1;f+=14;var S=new Rt(_),z=new Rt(19);for(var P=0;P<A;++P)z[nf[P]]=Xn(e,f+P*3,7);f+=A*3;var F=Qh(z),ee=(1<<F)-1,I=gi(z,F,1);for(var P=0;P<_;){var H=I[Xn(e,f,ee)];f+=H&15;var R=H>>4;if(R<16)S[P++]=R;else{var q=0,C=0;if(R==16)C=3+Xn(e,f,3),f+=2,q=S[P-1];else if(R==17)C=3+Xn(e,f,7),f+=3;else if(R==18)C=11+Xn(e,f,127),f+=7;while(C--)S[P++]=q}}var X=S.subarray(0,T),k=S.subarray(T);x=Qh(X),p=Qh(k),d=gi(X,x,1),g=gi(k,p,1)}else Un(1);if(f>m){if(c)Un(0);break}}if(a)l(h+131072);var Y=(1<<x)-1,Q=(1<<p)-1,Se=f;for(;;Se=f){var q=d[ef(e,f)&Y],ue=q>>4;if(f+=q&15,f>m){if(c)Un(0);break}if(!q)Un(2);if(ue<256)n[h++]=ue;else if(ue==256){Se=f,d=null;break}else{var Fe=ue-254;if(ue>264){var P=ue-257,Me=Nc[P];Fe=Xn(e,f,(1<<Me)-1)+gy[P],f+=Me}var Z=g[ef(e,f)&Q],re=Z>>4;if(!Z)Un(3);f+=Z&15;var k=z1[re];if(re>3){var Me=Dc[re];k+=ef(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)Un(0);break}if(a)l(h+131072);var se=h+Fe;if(h<k){var xe=s-k,we=Math.min(k,se);if(xe+h<0)Un(3);for(;h<we;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=d,t.p=Se,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?uf(n,0,h):n.subarray(0,h)},Oi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},No=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},tf=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:yy,l:0};if(r==1){var o=new Rt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(M,T){return M.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new wn(h+1),g=of(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var v=s[i].s;if(d[v]==t)--d[v],++x}g=t}return{t:new Rt(d),l:g}},of=function(e,t,n){return e.s==-1?Math.max(of(e.l,t,n+1),of(e.r,t,n+1)):t[e.s]=n},ly=function(e){var t=e.length;while(t&&!e[--t]);var n=new wn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},Do=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},xy=function(e,t,n){var i=n.length,r=lf(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},uy=function(e,t,n,i,r,s,o,a,c,l,u){Oi(t,u++,n),++r[256];var f=tf(r,15),{t:h,l:d}=f,g=tf(s,15),{t:x,l:p}=g,m=ly(h),{c:E,n:R}=m,v=ly(x),{c:M,n:T}=v,A=new wn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<M.length;++_)++A[M[_]&31];var S=tf(A,7),{t:z,l:P}=S,F=19;for(;F>4&&!z[nf[F-1]];--F);var ee=l+5<<3,I=Do(r,ur)+Do(s,Oo)+o,H=Do(r,h)+Do(s,x)+o+14+3*F+Do(A,z)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&ee<=I&&ee<=H)return xy(t,u,e.subarray(c,c+l));var q,C,X,k;if(Oi(t,u,1+(H<I)),u+=2,H<I){q=gi(h,d,0),C=h,X=gi(x,p,0),k=x;var Y=gi(z,P,0);Oi(t,u,R-257),Oi(t,u+5,T-1),Oi(t,u+10,F-4),u+=14;for(var _=0;_<F;++_)Oi(t,u+3*_,z[nf[_]]);u+=3*F;var Q=[E,M];for(var Se=0;Se<2;++Se){var ue=Q[Se];for(var _=0;_<ue.length;++_){var Fe=ue[_]&31;if(Oi(t,u,Y[Fe]),u+=z[Fe],Fe>15)Oi(t,u,ue[_]>>5&127),u+=ue[_]>>12}}}else q=k1,C=ur,X=G1,k=Oo;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var Fe=Me>>18&31;if(No(t,u,q[Fe+257]),u+=C[Fe+257],Fe>7)Oi(t,u,Me>>23&31),u+=Nc[Fe];var Z=Me&31;if(No(t,u,X[Z]),u+=k[Z],Z>3)No(t,u,Me>>5&8191),u+=Dc[Z]}else No(t,u,q[Me]),u+=C[Me]}return No(t,u,q[256]),u+C[256]},W1=new cf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),yy=new Rt(0),Z1=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Rt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=W1[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new wn(32768),p=s.h||new wn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},v=new cf(25000),M=new wn(288),T=new wn(32),A=0,_=0,S=s.i||0,z=0,P=s.w||0,F=0;for(;S+2<o;++S){var ee=R(S),I=S&32767,H=p[ee];if(x[I]=H,p[ee]=I,P<=S){var q=o-S;if((A>7000||z>24576)&&(q>423||!l)){u=uy(e,c,0,v,M,T,_,z,F,S-F,u),z=A=_=0,F=S;for(var C=0;C<286;++C)M[C]=0;for(var C=0;C<30;++C)T[C]=0}var X=2,k=0,Y=d,Q=I-H&32767;if(q>2&&ee==R(S-Q)){var Se=Math.min(h,q)-1,ue=Math.min(32767,S),Fe=Math.min(258,q);while(Q<=ue&&--Y&&I!=H){if(e[S+X]==e[S+X-Q]){var Me=0;for(;Me<Fe&&e[S+Me]==e[S+Me-Q];++Me);if(Me>X){if(X=Me,k=Q,Me>Se)break;var Z=Math.min(Q,Me-2),re=0;for(var C=0;C<Z;++C){var se=S-Q+C&32767,xe=x[se],we=se-xe&32767;if(we>re)re=we,H=se}}}I=H,H=x[I],Q+=I-H&32767}}if(k){v[z++]=268435456|rf[X]<<18|cy[k];var Ee=rf[X]&31,xt=cy[k]&31;_+=Nc[Ee]+Dc[xt],++M[257+Ee],++T[xt],P=S+X,++A}else v[z++]=e[S],++M[e[S]]}}for(S=Math.max(S,P);S<o;++S)v[z++]=e[S],++M[e[S]];if(u=uy(e,c,l,v,M,T,_,z,F,S-F,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=S,s.w=P}else{for(var S=s.w||0;S<o+l;S+=65535){var ke=S+65535;if(ke>=o)c[u/8|0]=l,ke=o;u=xy(c,u+1,e.subarray(S,ke))}s.i=o}return uf(a,0,i+lf(u)+r)},X1=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),q1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=X1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var j1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Rt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return Z1(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},vy=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var jt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function by(e,t){return j1(e,t||{},0,0)}function Sy(e,t){return $1(e,{i:2},t&&t.out,t&&t.dictionary)}var My=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=vy(i,s[1]),s=s[0];if(s instanceof Rt)n[o]=[s,a];else n[o+="/"]=[new Rt(0),a],My(s,o,n,i)}},hy=typeof TextEncoder<"u"&&new TextEncoder,Y1=typeof TextDecoder<"u"&&new TextDecoder,K1=0;try{Y1.decode(yy,{stream:!0}),K1=1}catch(e){}function fy(e,t){if(t){var n=new Rt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(hy)return hy.encode(e);var r=e.length,s=new Rt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Rt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return uf(s,0,o)}var af=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Un(9);t+=i+4}return t},dy=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=af(l);if(jt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)Un(10);if(jt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)jt(e,t,n.crc),jt(e,t+4,s<0?-s-2:s),jt(e,t+8,n.size);if(jt(e,t+12,c),jt(e,t+14,f),t+=16,o!=null)jt(e,t,u),jt(e,t+6,n.attrs),jt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;jt(e,t,+g),jt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},J1=function(e,t,n,i,r){jt(e,t,101010256),jt(e,t+8,n),jt(e,t+10,n),jt(e,t+12,i),jt(e,t+16,r)};function wy(e,t){if(!t)t={};var n={},i=[];My(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=fy(o),h=f.length,d=l.comment,g=d&&fy(d),x=g&&g.length,p=af(l.extra);if(h>65535)Un(11);var m=u?by(c,l):c,E=m.length,R=q1();R.p(c),i.push(vy(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var v=new Rt(s+22),M=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];dy(v,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+af(f.extra);v.set(f.c,f.o+_),dy(v,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return J1(v,r,i.length,T,M),v}var hf=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function Q1(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class ff extends Error{diagnostic;constructor(e,t=Q1(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var Ey=1024,Ty=4,Ay=8,eR=6,Ry=80,Uo=256;class St extends ff{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Cy=["solid","checker","stripes","gradient","bricks","noise"],Py=["normal","multiply","screen","overlay"],tR=new Set(["__proto__","prototype","constructor"]);function Oc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new St(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new St(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new St(`${t} must not contain symbol keys.`);if(tR.has(i))throw new St(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new St(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new St(`${t}.${i} must be a plain JSON data field.`)}return e}function nR(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new St(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new St(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new St(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new St(`${t} must be a dense JSON array (missing index ${n}).`);return e}function hr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new St(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function qn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new St(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Fr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new St(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Ly(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new St(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function df(e,t,n){return Ly(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function iR(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Ry||n)throw new St(`${t} must be 1..${Ry} visible characters.`);return e}function rR(e,t,n){if(e===void 0)return n;if(!hf.includes(e))throw new St(`${t} must be one of ${hf.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Iy(e,t){let i=(Ly(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function sR(e,t){let n=e.blend??"normal";if(!Py.includes(n))throw new St(`${t}.blend ${JSON.stringify(n)} is not one of ${Py.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function oR(e,t){let n=`proceduralTexture.layers[${t}]`,i=Oc(e,n),r=i.op;if(!Cy.includes(r))throw new St(`${n}.op ${JSON.stringify(r)} is not one of ${Cy.join(", ")}.`);let s=sR(i,n),o=df(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return hr(i,["op","color","blend","opacity"],n),{op:r,color:qn(i.color,`${n}.color`),...a};case"checker":return hr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),squares:Fr(i.squares,`${n}.squares`,8,1,Uo),...a};case"stripes":return hr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),count:Fr(i.count,`${n}.count`,8,1,Uo),angleDeg:Iy(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return hr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:qn(i.from,`${n}.from`),to:qn(i.to,`${n}.to`),angleDeg:Iy(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return hr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:qn(i.brick,`${n}.brick`),mortar:qn(i.mortar,`${n}.mortar`),rows:Fr(i.rows,`${n}.rows`,8,1,Uo),cols:Fr(i.cols,`${n}.cols`,4,1,Uo),mortarWidth:df(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:df(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return hr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),scale:Fr(i.scale,`${n}.scale`,8,1,Uo),octaves:Fr(i.octaves,`${n}.octaves`,3,1,eR),seed:Fr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new St(`${n}.op is unsupported.`)}}function aR(e){let t=Oc(e,"proceduralTexture");if(hr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new St(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Ny(e){let t=Oc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Oc(aR(t),"proceduralTexture"):t;if(hr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new St(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Ty||i>Ey||(i&i-1)!==0)throw new St(`proceduralTexture.size must be a power of two between ${Ty} and ${Ey}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new St("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=nR(r,"proceduralTexture.layers");if(s.length>Ay)throw new St(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Ay}.`);let o=iR(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:rR(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(oR)}}var TD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var Yn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Oy=["baseColor","normal","metallicRoughness","emissive","occlusion"],cR={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var zo=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),ko=Je().regex(/^sha256:[a-f0-9]{64}$/),fr=Je().min(1).max(1000),Dy=Je().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Uy=ht({id:zo,kind:On(["external","procedural"]),provider:fr,creator:fr,assetId:fr.optional(),assetUrl:Dy.optional(),accessedAt:Je().datetime().optional(),license:ht({spdx:fr,url:Dy,attribution:Je().max(4000)}).strict(),originalFiles:an(ht({name:Je().min(1).max(200),sha256:ko,bytes:pt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Fy=ht({operation:fr,tool:fr,version:fr,parameters:Lc(Je().max(100),ty([Je().max(2000),pt().finite(),Lo()])).optional()}).strict(),jn=pt().int().min(0).max(16777215),Fo=pt().int().min(1).max(256),Ps={blend:On(["normal","multiply","screen","overlay"]).default("normal"),opacity:pt().min(0).max(1).default(1)},zy=ht({schemaVersion:qt(2),size:pt().int().min(4).max(1024).default(256),usage:On(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Je().min(1).max(80).optional(),layers:an(_1("op",[ht({op:qt("solid"),color:jn,...Ps}).strict(),ht({op:qt("checker"),colorA:jn,colorB:jn,squares:Fo.default(8),...Ps}).strict(),ht({op:qt("stripes"),colorA:jn,colorB:jn,count:Fo.default(8),angleDeg:pt().min(-36000).max(36000).default(0),...Ps}).strict(),ht({op:qt("gradient"),from:jn,to:jn,angleDeg:pt().min(-36000).max(36000).default(0),...Ps}).strict(),ht({op:qt("bricks"),brick:jn,mortar:jn,rows:Fo.default(8),cols:Fo.default(4),mortarWidth:pt().min(0).max(1).default(0.06),stagger:pt().min(0).max(1).default(0.5),...Ps}).strict(),ht({op:qt("noise"),colorA:jn,colorB:jn,scale:Fo.default(8),octaves:pt().int().min(1).max(6).default(3),seed:pt().int().min(-2147483648).max(2147483647).default(0),...Ps}).strict()])).min(1).max(8)}).strict(),ky=ht({kind:qt("normal-from-height"),strength:pt().finite().positive().max(64)}).strict(),lR=ht({compiler:qt("kiln.procedural-texture.v2"),spec:zy,derive:ky.optional(),recipeHash:ko,pixelHash:ko,encoder:ht({name:qt("sharp"),version:fr}).strict()}).strict(),By=ht({baseColor:pt().int().min(0).max(16777215).optional(),roughness:pt().min(0).max(1).default(1),metalness:pt().min(0).max(1).default(0),emissive:pt().int().min(0).max(16777215).optional(),emissiveIntensity:pt().min(0).max(64).default(1),alphaMode:On(["opaque","mask","blend"]).default("opaque"),alphaCutoff:pt().min(0).max(1).default(0.5),doubleSided:Lo().default(!1)}).strict(),Gy=ht({schemaVersion:qt(1),materialId:zo,revisionId:ko,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30),tileable:Lo(),physicalSizeMeters:ht({width:pt().finite().positive().max(1e5),height:pt().finite().positive().max(1e5)}).strict().optional(),parameters:By,sources:an(Uy).min(1).max(20),maps:an(ht({slot:On(Oy),file:On(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:ko,bytes:pt().int().positive().max(Yn.maxMapBytes),width:pt().int().positive().max(Yn.maxMapEdge),height:pt().int().positive().max(Yn.maxMapEdge),usage:On(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:On(["srgb","linear"]),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:zo,originalFile:Je().min(1).max(200).optional(),transforms:an(Fy).max(30),procedural:lR.optional()}).strict()).min(1).max(5)}).strict(),PD=ht({materialId:zo,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30).optional(),tileable:Lo(),physicalSizeMeters:ht({width:pt().finite().positive().max(1e5),height:pt().finite().positive().max(1e5)}).strict().optional(),parameters:By.partial().optional(),sources:an(Uy).min(1).max(20),maps:an(ht({slot:On(Oy),sourceId:zo,transforms:an(Fy).max(30),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),procedural:zy,derive:ky.optional()}).strict()).min(1).max(5)}).strict(),Hy=ht({schemaVersion:qt(1),records:an(ht({manifest:Gy,files:Lc(Je().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Je().max(Math.ceil(Yn.maxMapBytes/3)*4))}).strict()).max(Yn.maxPayloadRecords)}).strict();function Go(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Go(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Bo(e){Go(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function Vy(e){if(Go(e),new TextEncoder().encode(JSON.stringify(e)).length>Yn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=Gy.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==cR[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Bo(r.procedural.spec)!==Bo(Ny(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>Yn.maxRecordBytes||i>Yn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Uc=67108864,pf=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),uR=Je().regex(/^sha256:[a-f0-9]{64}$/),mf=ht({version:qt("kiln.asset.v1"),assetId:pf,revisionId:pf,parentRevision:pf.optional(),name:Je().min(1).max(200),tags:an(Je().max(80)).max(30),createdAt:Je().datetime(),description:Je().max(4000).optional(),brief:Je().max(8000).optional(),attribution:ht({model:Je().max(200).optional(),harness:Je().max(200).optional(),author:Je().max(200).optional()}).optional(),editable:Lo(),files:Lc(Je(),ht({sha256:uR,bytes:pt().int().nonnegative().max(Uc)})),build:ht({engine:Je(),options:Lc(Je(),Ur()),warnings:an(Je()),integration:Ur().optional(),qa:Ur().optional(),dependencies:an(Ur()).optional(),rebuild:On(["engine-required","external-dependencies-required"])}).optional(),preview:ht({fidelity:Ur().optional(),error:Je().optional(),backdrop:On(oy).optional()}).optional()}),hR="materials.kiln.json",fR=25165824;function $y(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=Vy(c.manifest);return[`${l.materialId}/${l.revisionId}`,Bo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Go(e.materialResources);let r=Hy.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Bo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>Yn.maxPayloadBytes||o>Yn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var dR=new Set(["asset.glb","source.kiln.js","preview.png"]);function pR(e){let t=mf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!dR.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Uc||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");gf(e.files["asset.glb"]),$y(e)}function gf(e){if(e.length<20||e.length>Uc)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Wy(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){pR(i),$y(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>fR)throw Error("Asset material payload exceeds byte limit");t[r+hR]=s}}for(let i of Object.values(t))n+=i.length;if(n>Uc)throw Error("Bundle exceeds 64 MiB");return wy(t,{level:0})}function _i(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof At)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Zy(e){gf(e);let t=new oo,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new _s(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new th(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)_i(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function Xy(e,t,n=40,i=[e]){let r=e.getCenter(new O),s=Math.max(e.getSize(new O).length()/2,0.01),o=new O(1,0.65,1.25).normalize(),a=new O().crossVectors(new O(0,1,0),o).normalize(),c=new O().crossVectors(o,a),l=[];for(let E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let v of[E.min.y,E.max.y])for(let M of[E.min.z,E.max.z])l.push(new O(R,v,M));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),v=R.dot(a),M=R.dot(c);u=Math.min(u,v),f=Math.max(f,v),h=Math.min(h,M),d=Math.max(d,M)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),v=R.dot(o);p=Math.max(p,v+Math.abs(R.dot(a))*1.12/x,v+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function _f(e,t){return{position:e.position.clone(),target:t.clone()}}function xf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new O).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new O))+r*20,10),e.updateProjectionMatrix()}function qy(e,t,n){let i=e.getWorldDirection(new O);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new O(0,1,0)),s=new O;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function jy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function Yy(e,t,n){if(t())return e;n(e);return}function Fc(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function zc(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Ft().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Ft,i=new Ft,r=new O;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Ft().setFromObject(e,!0):n}function Ho(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Ky(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((g)=>!Number.isInteger(g)||!t[g]||n.has(g)))continue;let f=l.parent;while(f&&!i.has(f))f=f.parent;if(f)continue;let h=[l];for(let g of u)h.push(await e.parser.getDependency("node",g));Fc(e,h.slice(1)),i.add(l);let d=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:d,levels:h})}if(r.length===0)return;let s=Ho(e.scene)-r.reduce((c,l)=>c+yf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,f)=>u+yf(f,l),0));return{chains:r,triangles:a}}var Jy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function yf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return Ho(Jy(e,t))}function Qy(e,t){let n=Jy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function ev(e,t){for(let n of e.chains)Qy(n,t)}function tv(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Qy(i,n),!0}function nv(e,t){if(!e)return;return{triangles:Ho(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>yf(n,r))}))}}function Is(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function iv(e){let t=new Vu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Ws,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new ds,i=new Ut(40,1,0.01,1000),r=new Zu(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(C)=>{if(!o||!c.has(C.code))return;C.preventDefault(),s.add(C.code)},u=(C)=>s.delete(C.code),f=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",f);let h=new mo(t),d=new Xu,g=h.fromScene(d,0.04);n.environment=g.texture,d.dispose(),h.dispose();let x=new vs(16773591,2.4);x.position.set(4,8,5),n.add(x),n.add(new Wa(14806490,5065021,1.7));let p,m,E,R=[],v=!0,M=performance.now(),T=0,A=0,_=!1,S,z,P,F=(C)=>{if(!P)return;clearTimeout(P.timeout),P.reject(Error(C)),P=void 0},ee=(C)=>{let X=t.getContext(),k=X.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:C-P.started,frameMs:jy(P.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(X.getParameter(X.VERSION)),vendor:String(X.getParameter(X.VENDOR)),renderer:String(X.getParameter(X.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(X.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(X.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let C=zc(p),X=[];p.traverseVisible((ue)=>{if(ue instanceof _t||ue instanceof Ji||ue instanceof gs){let Fe=new Ft().setFromObject(ue,!0);if(!Fe.isEmpty())X.push(Fe)}});let{center:k,radius:Y,distance:Q,position:Se}=Xy(C,i.aspect,i.fov,X);if(r.target.copy(k),i.position.copy(Se),i.near=Math.max(Y/1000,0.0001),i.far=Q+Y*100,r.minDistance=Y*0.1,r.maxDistance=Y*80,a=Math.max(Y*0.35,0.01),o)r.minDistance=Y*0.00001;i.updateProjectionMatrix(),r.update()},H=new ResizeObserver(()=>{let{clientWidth:C,clientHeight:X}=e;if(!C||!X)return;t.setSize(C,X),i.aspect=C/X,i.updateProjectionMatrix()});H.observe(e);let q=(C)=>{if(_)return;let X=Math.min((C-M)/1000,0.1);if(M=C,e.clientWidth&&e.clientHeight){if(v)E?.update(X);if(o&&s.size){let k=qy(i,s,X*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),S!==void 0)z=performance.now()-S,S=void 0;if(P){if(P.previous>0&&P.samples.length<1800)P.samples.push(C-P.previous);if(P.previous=C,C-P.started>=P.duration&&P.samples.length){let k=ee(C);clearTimeout(P.timeout),P.resolve(k),P=void 0}}}else s.clear(),F("Keep the measured viewport visible for the complete sampling window.");T=requestAnimationFrame(q)};return T=requestAnimationFrame(q),{async load(C,X={}){let k=performance.now(),Y=++A;F("The artifact changed during measurement. Measure the new revision again.");let Q=await Zy(C);Fc(Q,[Q.scene]);let Se=await Ky(Q);try{Q.assertTexturesLoaded()}catch(xe){_i(Q.scene);for(let we of Is(Se))_i(we);throw xe}let ue=Yy(Q,()=>!_&&Y===A&&X.isCurrent?.()!==!1,(xe)=>{_i(xe.scene);for(let we of Is(Se))_i(we)});if(!ue)return;let Fe=p&&X.preserveView?_f(i,r.target):void 0;if(p){E?.stopAllAction(),E?.uncacheRoot(p),n.remove(p),_i(p);for(let xe of Is(m))_i(xe)}p=ue.scene,m=Se,S=k,z=void 0,n.add(p),R=ue.animations,E=new ja(p),v=!0;let{clientWidth:Me,clientHeight:Z}=e;if(t.setSize(Me,Z),i.aspect=Me&&Z?Me/Z:i.aspect,I(),Fe)xf(i,r.target,Fe,zc(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let we=xe;if(!we.isMesh)return;re++;for(let Ee of Array.isArray(we.material)?we.material:[we.material])se.add(Ee)}),X.onCommit?.(),{triangles:Ho(p),meshes:re,materials:se.size,clips:R.map((xe)=>xe.name),...m?{levels:m.triangles}:{}}},level(C){if(F("The level of detail changed. Measure the displayed combination again."),m)ev(m,C)},partLevel(C,X){if(F("The level of detail changed. Measure the displayed combination again."),m)tv(m,C,X)},lod(){return p?nv(m,p):void 0},reset:I,cancelMeasurement:F,measure(C=3000){if(_||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(C)||C<1000||C>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(P)return Promise.reject(Error("A measurement is already running."));return new Promise((X,k)=>{P={started:performance.now(),previous:0,duration:C,samples:[],resolve:X,reject:k,timeout:setTimeout(()=>F("Measurement was interrupted or the browser stopped delivering frames."),C+2000)}})},view(){return _f(i,r.target)},setView(C){if(!p)return;xf(i,r.target,C,zc(p)),r.update()},navigation(C){if(o=C==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(C){for(let X of p?[p,...Is(m)]:[])X.traverse((k)=>{let Y=k;if(Y.isMesh){for(let Q of Array.isArray(Y.material)?Y.material:[Y.material])if("wireframe"in Q)Q.wireframe=C}})},lighting(C){t.toneMappingExposure=C==="bright"?1.65:C==="soft"?0.85:1.15,x.intensity=C==="soft"?0.8:2.4},clip(C){if(E?.stopAllAction(),R[C])E?.clipAction(R[C]).play()},pause(C){v=!C},dispose(){if(F("The viewport closed before measurement finished."),_=!0,A++,cancelAnimationFrame(T),H.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",f),p)_i(p);for(let C of Is(m))_i(C);g.dispose(),t.dispose(),e.replaceChildren()}}}var rv=["127.0.0.1","localhost","[::1]"];async function sv(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&rv.includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var av=16777216,cv=Math.ceil(av/3)*4,Wt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function mR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function ov(e){if(typeof e!=="string"||e.length>cv)return Wt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Wt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Wt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(mR(n)!==e)Wt("contains noncanonical base64 data");return n}function Vo(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function lv(e){if(!Vo(e))return Wt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=mf.safeParse(e.manifest);if(!t.success||!Vo(e.files))return Wt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Wt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Wt("file metadata is missing");if(r+=n.files[c].bytes,r>av)return Wt("exceeds the decoded size limit");let u=typeof l==="string"?l:Vo(l)?l.data:void 0;if(typeof u!=="string")return Wt("file encoding is malformed");if(s+=u.length,s>cv)return Wt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=ov(l);else{if(!Vo(l)||l.encoding!=="kiln.deflate-base64.v1")return Wt("encoding is unsupported");let g=ov(l.data);try{f=Sy(g,{out:new Uint8Array(u.bytes+1)})}catch{return Wt("compressed data is damaged")}}if(f.length!==u.bytes)return Wt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Wt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Wt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!Vo(e.downloadUrls))return Wt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Wt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function uv(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var En=(e)=>document.getElementById(e),xi=En("status"),nn,fv={},zr,gR=0,yi=0,kc=new Map;function dv(e,t){let n=++gR;return new Promise((i,r)=>{let s=setTimeout(()=>{kc.delete(n),r(Error("Chat host did not respond."))},20000);kc.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function hv(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function _R(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function xR(e){let t=++yi;nn=void 0,En("stats").textContent="",En("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await yR(e,t)}catch(n){if(t!==yi)return;xi.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function yR(e,t){if(e.isError){xi.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await lv(e._meta?.kilnAsset)}catch(i){if(t!==yi)return;xi.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==yi)return;nn=n.record,En("name").textContent=nn.manifest.name,fv=n.downloadUrls,En("revision").textContent=`${nn.manifest.editable?"Editable source included":"GLB asset"} · ${nn.manifest.revisionId.slice(0,10)}`,En("attribution").textContent=uv(nn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{zr??=iv(En("stage"));let i=await zr.load(nn.files["asset.glb"]);if(t!==yi)return;if(i){En("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(nn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=En("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}xi.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==yi)return;zr?.dispose(),zr=void 0;let r=nn.files["preview.png"];if(r){let s=new Image;s.alt=`${nn.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${_R(r)}`,En("stage").replaceChildren(s)}xi.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;En("source").hidden=!nn.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=kc.get(t.id);if(kc.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")xR(t.params);if(t.method==="ui/resource-teardown")zr?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});En("reset").onclick=()=>zr?.reset();En("clips").onchange=(e)=>zr?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!nn)return;let t=yi,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?Wy([nn]):nn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=nn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,xi.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await sv(r,`${o}-${i}`,s,dv,a,fv[i]);if(t!==yi)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},xi.replaceChildren("Download ready. ",l)}else xi.textContent="Download requested."}catch(a){if(t===yi)xi.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!nn||t!==yi}};dv("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{hv("ui/notifications/initialized"),hv("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{xi.textContent=e.message});
</script>
</body>
diff --git a/package.json b/package.json
index ff965f2d..09d786b5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@instruktlabs/kiln",
- "version": "1.2.0",
+ "version": "1.2.1",
"description": "Create and refine procedural 3D assets with JavaScript, image feedback, and reusable source revisions.",
"license": "MIT",
"author": "Matthew Kissinger",
diff --git a/plugin.json b/plugin.json
index 4132c8e9..586e161e 100644
--- a/plugin.json
+++ b/plugin.json
@@ -2,7 +2,7 @@
"name": "kiln",
"displayName": "Kiln",
"description": "Build and revise 3D assets with your coding agent. Write JavaScript, inspect selected views, edit saved source revisions, and export GLB files locally.",
- "version": "1.2.0",
+ "version": "1.2.1",
"license": "MIT",
"homepage": "https://github.com/instruktlabs/kiln",
"keywords": [
diff --git a/plugins/kiln-engine.release.json b/plugins/kiln-engine.release.json
index a4a3c717..1d48f7ea 100644
--- a/plugins/kiln-engine.release.json
+++ b/plugins/kiln-engine.release.json
@@ -1,4 +1,4 @@
{
- "version": "1.2.0",
- "engineVersion": "1.2.0"
+ "version": "1.2.1",
+ "engineVersion": "1.2.1"
}
diff --git a/plugins/kiln-engine/.claude-plugin/plugin.json b/plugins/kiln-engine/.claude-plugin/plugin.json
index c8e99cea..f399e2d9 100644
--- a/plugins/kiln-engine/.claude-plugin/plugin.json
+++ b/plugins/kiln-engine/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "kiln-engine",
- "version": "1.2.0",
+ "version": "1.2.1",
"description": "Set up a local Kiln workspace to create, inspect and revise editable 3D assets with Claude Code or Codex.",
"author": {
"name": "Instrukt Labs",
diff --git a/plugins/kiln-engine/README.md b/plugins/kiln-engine/README.md
index d20d6192..ece58294 100644
--- a/plugins/kiln-engine/README.md
+++ b/plugins/kiln-engine/README.md
@@ -1,7 +1,7 @@
# Kiln local plugin
-Plugin version 1.2.0, maintained by Instrukt Labs under the MIT license.
-This plugin pins engine 1.2.0. Registry setup requires that exact version
+Plugin version 1.2.1, maintained by Instrukt Labs under the MIT license.
+This plugin pins engine 1.2.1. Registry setup requires that exact version
to be published. Use a published release tag for normal installation or a reviewed
local archive for development qualification. The installation ID remains
`kiln-engine@instruktlabs`.
@@ -31,7 +31,7 @@ codex plugin add kiln-engine@instruktlabs
Restart or reload your coding agent's plugins as its installation message directs.
Then ask it to set up a Kiln workspace. The maintained setup skill runs this
plugin's `bin/kiln-setup-workspace.mjs` with Node, installs
-`@instruktlabs/[email protected]` outside the project and configures your chosen
+`@instruktlabs/[email protected]` outside the project and configures your chosen
workspace. The same initializer supports existing projects and new workspaces.
The plugin registers setup only. The workspace supplies authoring skills and one
diff --git a/plugins/kiln-engine/package-provenance.json b/plugins/kiln-engine/package-provenance.json
index e3173fe8..2cb0db0f 100644
--- a/plugins/kiln-engine/package-provenance.json
+++ b/plugins/kiln-engine/package-provenance.json
@@ -1,20 +1,20 @@
{
"schemaVersion": 1,
"kind": "kiln-local-plugin",
- "pluginVersion": "1.2.0",
- "engineVersion": "1.2.0",
+ "pluginVersion": "1.2.1",
+ "engineVersion": "1.2.1",
"executables": [
"bin/kiln-setup-workspace.mjs"
],
"files": {
".claude-plugin/icon.png": "sha256:b4b651c402793b7e27cab780f04b14f80daec6d0cd5b7e4e90313930581a54e9",
- ".claude-plugin/plugin.json": "sha256:616a6a61da072fcfdd4d0e1cf513e0e91bf1e56fb61b9b02d23e72fa291556bc",
+ ".claude-plugin/plugin.json": "sha256:bef717ea5e0c96411c2db93d54e298dc3798512df9909ba74c950a6c1c03f6cb",
"bin/kiln-setup-workspace.mjs": "sha256:3d9a30236919a6ca91acb6b26f808cec442e6edc3dd88fe010645b010d76e838",
"LICENSE": "sha256:cdba278ebf1d6de618869936226bf03be4887179c128efc7aaa13d22034826a5",
- "plugin.json": "sha256:3437107d46ad4fef4a710a8e821e56b43894cc1722504fe4e8ff0120fa6a8d8d",
+ "plugin.json": "sha256:9ef79b862a25ae3efe86c03a37e09cd622912b97a0165a08fdf55cff8b71a010",
"PRIVACY.md": "sha256:5f58d981667e40441e21c2dec411f269a9a67a6141cec61976d27088fb12573b",
- "README.md": "sha256:0b82e6eb8b679f8b991c1a5567957574ed7b3341a87ef989403e5521f83ab50e",
- "runtime.json": "sha256:5ebac8387f4bedcc7cac02a36f73c5ffba969ce6c8c6e2b0e356ef569168d0a5",
+ "README.md": "sha256:029732d7bb9e04561105727f8e46118d3106f513b4575a8d74d57cbd1bb68e7a",
+ "runtime.json": "sha256:b6d078f1223cb5ed3a522b0ef5a3cb778e051afc0115237cfd9cfe04c1f42025",
"skills/kiln-setup-workspace/references/plugin-install.md": "sha256:c338fb792e7fad0364c3e1a13c94c506afa1395489ec1b6e83b36d04728935fb",
"skills/kiln-setup-workspace/references/renderer-setup.md": "sha256:b743b1b2827fa814385990e1e5b849391cb427413e9c016d273aa19cebd46031",
"skills/kiln-setup-workspace/SKILL.md": "sha256:65ed926b3503a33f4fe793e84e4a045ce36e3967f0e6b340e456a15dd010ce54"
diff --git a/plugins/kiln-engine/plugin.json b/plugins/kiln-engine/plugin.json
index ffca8188..0993a1ff 100644
--- a/plugins/kiln-engine/plugin.json
+++ b/plugins/kiln-engine/plugin.json
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "kiln-engine",
- "version": "1.2.0",
+ "version": "1.2.1",
"description": "Set up a local Kiln workspace to create, inspect and revise editable 3D assets with Claude Code or Codex.",
"author": {
"name": "Instrukt Labs",
diff --git a/plugins/kiln-engine/runtime.json b/plugins/kiln-engine/runtime.json
index df4e63ac..1238342b 100644
--- a/plugins/kiln-engine/runtime.json
+++ b/plugins/kiln-engine/runtime.json
@@ -1,6 +1,6 @@
{
"name": "@instruktlabs/kiln",
- "version": "1.2.0",
+ "version": "1.2.1",
"harnesses": [
"claude",
"codex",
diff --git a/plugins/kiln-hosted/plugin.json b/plugins/kiln-hosted/plugin.json
index 2cf87260..3871982b 100644
--- a/plugins/kiln-hosted/plugin.json
+++ b/plugins/kiln-hosted/plugin.json
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "kiln-engine",
- "version": "1.2.0",
+ "version": "1.2.1",
"description": "Create, review and revise editable 3D assets, with private saved revisions and GLB downloads.",
"author": {
"name": "Instrukt Labs",
diff --git a/scripts/build-runtime.mjs b/scripts/build-runtime.mjs
index 12547e27..e19d3581 100644
--- a/scripts/build-runtime.mjs
+++ b/scripts/build-runtime.mjs
@@ -126,14 +126,20 @@ export async function buildRuntime(target, root = repo) {
return entry;
}
+export async function buildAllRuntime(root = repo) {
+ const entries = [];
+ // MCP regenerates an identity input. Do it before any sibling captures its
+ // source identity, so a version/widget change needs only one complete build.
+ for (const target of ['mcp', 'worker', 'agent-run', 'agent-providers', 'engine', 'cli'])
+ entries.push(await buildRuntime(target, root));
+ return entries;
+}
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
try {
- const targets =
- process.argv[2] === 'all'
- ? ['worker', 'agent-run', 'agent-providers', 'engine', 'mcp', 'cli']
- : [process.argv[2]];
- for (const target of targets) {
- const entry = await buildRuntime(target);
+ const entries =
+ process.argv[2] === 'all' ? await buildAllRuntime() : [await buildRuntime(process.argv[2])];
+ for (const entry of entries) {
console.log(`${entry.file} ${entry.bundleHash} (${entry.identity})`);
}
if (process.argv[2] === 'all') await buildSdk();
diff --git a/scripts/build-runtime.test.mjs b/scripts/build-runtime.test.mjs
new file mode 100644
index 00000000..4d71fb54
--- /dev/null
+++ b/scripts/build-runtime.test.mjs
@@ -0,0 +1,49 @@
+import { expect, test } from 'bun:test';
+import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { buildAllRuntime, runtimeBuildIdentity } from './build-runtime.mjs';
+
+test('one full build uses the regenerated manifest identity for every runtime', async () => {
+ const root = await mkdtemp(join(tmpdir(), 'kiln-manifest-build-'));
+ try {
+ const { bun } = JSON.parse(
+ await readFile(new URL('../toolchain.json', import.meta.url), 'utf8'),
+ );
+ await writeFile(
+ join(root, 'package.json'),
+ JSON.stringify({ version: '1.2.1', packageManager: `bun@${bun}` }),
+ );
+ await writeFile(join(root, 'bun.lock'), '{}');
+ for (const dir of [
+ 'scripts',
+ 'src/generated',
+ 'src/evaluator',
+ 'src/agent',
+ 'render-service/src',
+ ])
+ await mkdir(join(root, dir), { recursive: true });
+ await writeFile(join(root, 'src/generated/mcp-manifest.json'), '{"revision":"stale"}');
+ await writeFile(
+ join(root, 'scripts/generate-mcp-manifest.ts'),
+ "await Bun.write('src/generated/mcp-manifest.json', JSON.stringify({revision:'current'}));",
+ );
+ for (const name of [
+ 'cli.ts',
+ 'mcp-server.ts',
+ 'mcp-engine.ts',
+ 'evaluator/worker.ts',
+ 'agent/run.ts',
+ 'agent/providers.ts',
+ ])
+ await writeFile(join(root, 'src', name), 'export const fixture = true;');
+ const entries = await buildAllRuntime(root);
+ const current = await runtimeBuildIdentity(root);
+ expect(new Set(entries.map((entry) => entry.identity))).toEqual(new Set([current.identity]));
+ expect(
+ JSON.parse(await readFile(join(root, 'src/generated/mcp-manifest.json'), 'utf8')).revision,
+ ).toBe('current');
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
diff --git a/scripts/integration/run-viewer-textures.mjs b/scripts/integration/run-viewer-textures.mjs
new file mode 100644
index 00000000..92dd2e51
--- /dev/null
+++ b/scripts/integration/run-viewer-textures.mjs
@@ -0,0 +1,191 @@
+/** Optional browser regression; uses an installed Playwright and Chrome, no live service. */
+import { spawnSync } from 'node:child_process';
+import { createHash } from 'node:crypto';
+import { createServer } from 'node:http';
+import { mkdtemp, readFile, writeFile } from 'node:fs/promises';
+import { createRequire } from 'node:module';
+import os from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import sharp from 'sharp';
+
+const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
+const args = process.argv.slice(2);
+const option = (name, fallback) => (args.includes(name) ? args[args.indexOf(name) + 1] : fallback);
+const output = await mkdtemp(path.join(os.tmpdir(), 'kiln-viewer-textures-'));
+const bundle = path.join(output, 'browser.js');
+const build = spawnSync(
+ option('--bun', 'bun'),
+ [
+ 'build',
+ 'scripts/integration/viewer-texture-fixtures.mjs',
+ '--target=browser',
+ `--outfile=${bundle}`,
+ ],
+ { cwd: root, encoding: 'utf8', windowsHide: true },
+);
+if (build.status !== 0) throw new Error(`Browser build failed: ${build.error ?? build.stderr}`);
+const js = await readFile(bundle, 'utf8');
+const widget = await readFile(path.join(root, 'dist/viewer/chat.html'), 'utf8');
+const server = createServer((request, response) => {
+ response.setHeader('Content-Type', 'text/html');
+ response.setHeader(
+ 'Content-Security-Policy',
+ "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src 'self' data:; connect-src 'none'",
+ );
+ if (request.url === '/widget') {
+ response.end(widget);
+ return;
+ }
+ response.end(
+ `<html><body><script type="module">${js.replaceAll('</script', '<\\/script')}</script></body></html>`,
+ );
+});
+await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
+let browser;
+try {
+ const { chromium } = createRequire(import.meta.url)(option('--playwright', 'playwright'));
+ browser = await chromium.launch({
+ channel: 'chrome',
+ headless: true,
+ args: ['--enable-gpu', ...(process.platform === 'win32' ? ['--use-angle=d3d11'] : [])],
+ });
+ const page = await browser.newPage();
+ const errors = [];
+ page.on('console', (message) => {
+ if (message.type() === 'error') errors.push(message.text());
+ });
+ await page.goto(`http://127.0.0.1:${server.address().port}`);
+ await page.waitForFunction(() => window.audit, {}, { timeout: 20000 });
+ const receipt = {
+ ...(await page.evaluate(() => window.audit)),
+ browser: browser.version(),
+ errors,
+ };
+ const fixture = await page.evaluate(() => window.viewerFixture);
+ // Emulate the component's documented host messages. Actual ChatGPT acceptance
+ // remains a separate integration check; this test uses a fresh local profile.
+ await page.addInitScript(() =>
+ window.addEventListener('message', (event) => {
+ if (event.data?.method === 'ui/initialize')
+ window.postMessage(
+ {
+ jsonrpc: '2.0',
+ id: event.data.id,
+ result: { protocolVersion: '2026-01-26', hostCapabilities: {} },
+ },
+ '*',
+ );
+ }),
+ );
+ await page.goto(`http://127.0.0.1:${server.address().port}/widget`);
+ const present = async (glb, preview) => {
+ const bytes = {
+ 'asset.glb': Buffer.from(glb),
+ ...(preview ? { 'preview.png': Buffer.from(fixture.preview, 'base64') } : {}),
+ };
+ const payload = {
+ manifest: {
+ version: 'kiln.asset.v1',
+ assetId: 'a_viewer_test',
+ revisionId: 'r_viewer_test',
+ name: 'Viewer texture regression',
+ tags: [],
+ createdAt: '2026-10-09T00:00:00.000Z',
+ editable: false,
+ files: Object.fromEntries(
+ Object.entries(bytes).map(([name, data]) => [
+ name,
+ {
+ bytes: data.length,
+ sha256: `sha256:${createHash('sha256').update(data).digest('hex')}`,
+ },
+ ]),
+ ),
+ },
+ files: Object.fromEntries(
+ Object.entries(bytes).map(([name, data]) => [name, data.toString('base64')]),
+ ),
+ };
+ await page.evaluate(
+ (kilnAsset) =>
+ window.postMessage(
+ {
+ jsonrpc: '2.0',
+ method: 'ui/notifications/tool-result',
+ params: { _meta: { kilnAsset } },
+ },
+ '*',
+ ),
+ payload,
+ );
+ };
+ const check = async (name, run) => {
+ try {
+ await run();
+ receipt.results.push({ name, passed: true });
+ } catch (error) {
+ receipt.results.push({ name, passed: false, error: String(error) });
+ }
+ };
+ await check('packaged component renders both texture colors', async () => {
+ await present(fixture.glb, true);
+ await page.waitForFunction(() =>
+ document.querySelector('#status').textContent.startsWith('Drag to orbit'),
+ );
+ const screenshot = await page
+ .locator('#stage')
+ .screenshot({ path: path.join(output, 'widget.png') });
+ const { data, info } = await sharp(screenshot)
+ .removeAlpha()
+ .raw()
+ .toBuffer({ resolveWithObject: true });
+ let red = 0,
+ green = 0;
+ // Studio tone mapping lifts green's red channel; require chromatic separation,
+ // not raw authoring RGB. White or background pixels satisfy neither predicate.
+ for (let i = 0; i < data.length; i += info.channels) {
+ if (data[i] > 100 && data[i] > data[i + 1] + 30) red++;
+ if (data[i + 1] > 100 && data[i + 1] > data[i] + 20 && data[i + 1] > data[i + 2] + 20)
+ green++;
+ }
+ if (red < 500 || green < 500)
+ throw new Error(`Missing visible texture colors: red=${red}, green=${green}`);
+ });
+ for (const preview of [true, false]) {
+ await check(
+ `failed component load ${preview ? 'shows labeled preview' : 'clears stale geometry'} and recovers`,
+ async () => {
+ await present(fixture.corrupt, preview);
+ await page.waitForFunction(() =>
+ document.querySelector('#status').textContent.includes('3D preview unavailable'),
+ );
+ if (await page.locator('#stage canvas').count())
+ throw new Error('Failed model left a live canvas');
+ if ((await page.locator('#stage img').count()) !== Number(preview))
+ throw new Error('Wrong fallback surface');
+ if (
+ preview &&
+ !(await page.locator('#status').innerText()).includes('Showing saved preview')
+ )
+ throw new Error('Unlabeled fallback');
+ await present(fixture.glb, true);
+ await page.waitForFunction(() =>
+ document.querySelector('#status').textContent.startsWith('Drag to orbit'),
+ );
+ if (
+ (await page.locator('#stage canvas').count()) !== 1 ||
+ (await page.locator('#stage img').count())
+ )
+ throw new Error('Viewer did not recover after fallback');
+ },
+ );
+ }
+ receipt.passed = receipt.results.every((row) => row.passed);
+ await writeFile(path.join(output, 'receipt.json'), JSON.stringify(receipt, null, 2));
+ console.log(JSON.stringify({ output, ...receipt }, null, 2));
+ if (!receipt.passed) process.exitCode = 1;
+} finally {
+ await browser?.close();
+ await new Promise((resolve) => server.close(resolve));
+}
diff --git a/scripts/integration/viewer-texture-fixtures.mjs b/scripts/integration/viewer-texture-fixtures.mjs
new file mode 100644
index 00000000..804d9647
--- /dev/null
+++ b/scripts/integration/viewer-texture-fixtures.mjs
@@ -0,0 +1,140 @@
+import * as THREE from 'three';
+import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
+import { loadAssetGlb } from '../../src/viewer/glb-loader.ts';
+
+const results = [];
+const assert = (condition, message) => {
+ if (!condition) throw new Error(message);
+};
+async function check(name, run) {
+ try {
+ await run();
+ results.push({ name, passed: true });
+ } catch (error) {
+ results.push({ name, passed: false, error: String(error) });
+ }
+}
+const canvas = document.createElement('canvas');
+canvas.width = canvas.height = 2;
+const context = canvas.getContext('2d');
+context.fillStyle = '#ff0000';
+context.fillRect(0, 0, 1, 2);
+context.fillStyle = '#00ff00';
+context.fillRect(1, 0, 1, 2);
+const map = new THREE.CanvasTexture(canvas);
+map.colorSpace = THREE.SRGBColorSpace;
+map.magFilter = THREE.NearestFilter;
+map.minFilter = THREE.NearestFilter;
+map.wrapS = THREE.MirroredRepeatWrapping;
+map.offset.set(0.25, 0.5);
+map.repeat.set(2, 3);
+const model = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshStandardMaterial({ map }));
+const original = new Uint8Array(await new GLTFExporter().parseAsync(model, { binary: true }));
+const originalCopy = original.slice();
+
+function rewrite(bytes, change) {
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
+ const length = view.getUint32(12, true);
+ const json = JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + length)));
+ const bin = bytes.slice(28 + length);
+ change(json, bin);
+ const text = new TextEncoder().encode(JSON.stringify(json));
+ const padded = Math.ceil(text.length / 4) * 4;
+ const out = new Uint8Array(28 + padded + bin.length);
+ const header = new DataView(out.buffer);
+ header.setUint32(0, 0x46546c67, true);
+ header.setUint32(4, 2, true);
+ header.setUint32(8, out.length, true);
+ header.setUint32(12, padded, true);
+ header.setUint32(16, 0x4e4f534a, true);
+ out.fill(32, 20, 20 + padded);
+ out.set(text, 20);
+ header.setUint32(20 + padded, bin.length, true);
+ header.setUint32(24 + padded, 0x004e4942, true);
+ out.set(bin, 28 + padded);
+ return out;
+}
+function loadedMap(gltf) {
+ let texture;
+ gltf.scene.traverse((node) => {
+ if (node.isMesh) texture = node.material.map;
+ });
+ assert(texture, 'Embedded base-color texture disappeared');
+ return texture;
+}
+function inspectPixels(texture) {
+ const pixels = document.createElement('canvas');
+ pixels.width = pixels.height = 2;
+ const ctx = pixels.getContext('2d');
+ ctx.drawImage(texture.image, 0, 0);
+ assert(
+ [...ctx.getImageData(0, 0, 2, 1).data].join(',') === '255,0,0,255,0,255,0,255',
+ 'Texture pixels changed',
+ );
+}
+await check('embedded PNG, sampler, color space and UV transform under strict CSP', async () => {
+ const texture = loadedMap(await loadAssetGlb(original));
+ inspectPixels(texture);
+ assert(
+ texture.colorSpace === THREE.SRGBColorSpace && !texture.flipY,
+ 'glTF color space/orientation changed',
+ );
+ assert(
+ texture.magFilter === THREE.NearestFilter && texture.wrapS === THREE.MirroredRepeatWrapping,
+ 'Sampler changed',
+ );
+ assert(
+ texture.offset.equals(map.offset) && texture.repeat.equals(map.repeat),
+ 'UV transform changed',
+ );
+ assert(
+ original.every((v, i) => v === originalCopy[i]),
+ 'Input GLB was mutated',
+ );
+});
+await check('data-URI PNG uses the same image path', async () => {
+ const bytes = rewrite(original, (json, bin) => {
+ const image = json.images[0],
+ buffer = json.bufferViews[image.bufferView];
+ image.uri = `data:image/png;base64,${btoa(String.fromCharCode(...bin.subarray(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)))}`;
+ delete image.bufferView;
+ });
+ inspectPixels(loadedMap(await loadAssetGlb(bytes)));
+});
+await check('corrupt embedded texture rejects instead of returning white geometry', async () => {
+ const bytes = rewrite(original, (json, bin) => {
+ const buffer = json.bufferViews[json.images[0].bufferView];
+ bin.fill(0, buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
+ });
+ let rejected = false;
+ try {
+ await loadAssetGlb(bytes);
+ } catch (error) {
+ rejected = /texture|image/i.test(String(error));
+ }
+ assert(rejected, 'Corrupt texture was accepted silently');
+});
+await check('external image rejects before any request', async () => {
+ const bytes = rewrite(original, (json) => {
+ json.images[0] = { uri: 'https://example.invalid/forbidden.png' };
+ });
+ let rejected = false;
+ try {
+ await loadAssetGlb(bytes);
+ } catch (error) {
+ rejected = /embed/i.test(String(error));
+ }
+ assert(rejected, 'External texture was accepted');
+});
+document.body.textContent = JSON.stringify(results, null, 2);
+window.audit = { passed: results.every((row) => row.passed), results };
+window.viewerFixture = {
+ glb: Array.from(original),
+ corrupt: Array.from(
+ rewrite(original, (json, bin) => {
+ const buffer = json.bufferViews[json.images[0].bufferView];
+ bin.fill(0, buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
+ }),
+ ),
+ preview: canvas.toDataURL('image/png').split(',')[1],
+};
diff --git a/scripts/integration/viewer-textures.md b/scripts/integration/viewer-textures.md
new file mode 100644
index 00000000..9533c22b
--- /dev/null
+++ b/scripts/integration/viewer-textures.md
@@ -0,0 +1,35 @@
+# Viewer texture regression
+
+After `bun run build:viewer`, run:
+
+```sh
+node scripts/integration/run-viewer-textures.mjs --playwright /path/to/playwright
+```
+
+This uses an existing Playwright installation and isolated Chrome profile. It
+does not install dependencies, change browser protections, call models or use a
+hosted service. `--bun` selects an existing Bun executable. Results and a component
+screenshot are retained in the reported temporary folder.
+
+The local page uses `connect-src 'none'` and `img-src 'self' data:`. Before the fix,
+Three.js ImageBitmapLoader fetched blob/data URLs, the browser blocked those
+connections, and GLTFLoader resolved with a missing material map. The fixed
+viewer uses GLTFLoader's registered plugin and LoadingManager image handler:
+embedded images become in-memory data URIs and TextureLoader uses the image path.
+The source GLB is unchanged and no network permissions are added. Samplers,
+color spaces, UV transforms and material extensions stay owned by GLTFLoader.
+
+Checks cover embedded and data-URI PNG pixels, sampler/UV/color-space preservation,
+corrupt-image rejection, and external-resource rejection. The built chat component
+must visibly render both fixture colors, label fallback to the saved preview,
+clear stale geometry without a preview, and recover on the next valid asset.
+Pixel checks here test the viewer regression, not engine QA acceptance or GPU
+performance. Expected corrupt-image loader errors remain in the receipt.
+
+The regression failed before the fix and passed in Chrome 154.0.8037.98 on
+October 9, 2026. This is local browser evidence. The RPC messages emulate a host;
+they do not establish actual ChatGPT host acceptance, which must be checked with
+the released component and CSP enforcement enabled.
+
+Supported APIs: [GLTFLoader.register](https://threejs.org/docs/pages/GLTFLoader.html#register)
+and [LoadingManager.addHandler](https://threejs.org/docs/pages/LoadingManager.html#addHandler).
diff --git a/src/asset-widget-uri.ts b/src/asset-widget-uri.ts
index 65902fae..98e37275 100644
--- a/src/asset-widget-uri.ts
+++ b/src/asset-widget-uri.ts
@@ -6,4 +6,4 @@
* engine has loaded. Neither of those may import the other, so the literal
* lives here on its own.
*/
-export const KILN_ASSET_WIDGET_URI = 'ui://kiln/asset-v5.html';
+export const KILN_ASSET_WIDGET_URI = 'ui://kiln/asset-v6.html';
diff --git a/src/engine-identity.ts b/src/engine-identity.ts
index 66ac05ed..c6e1c94b 100644
--- a/src/engine-identity.ts
+++ b/src/engine-identity.ts
@@ -27,7 +27,7 @@
* `src/__tests__/package-contents.test.ts` fails if it disagrees with the manifest
* or with any plugin manifest, which is what keeps the literal honest.
*/
-export const ENGINE_VERSION = '1.2.0';
+export const ENGINE_VERSION = '1.2.1';
/**
* Where this engine was loaded from, as a `file://` URL of the package root.
diff --git a/src/generated/mcp-manifest.json b/src/generated/mcp-manifest.json
index 1e38b44b..e6ac76a7 100644
--- a/src/generated/mcp-manifest.json
+++ b/src/generated/mcp-manifest.json
@@ -1733,13 +1733,13 @@
},
"_meta": {
"ui": {
- "resourceUri": "ui://kiln/asset-v5.html",
+ "resourceUri": "ui://kiln/asset-v6.html",
"visibility": [
"model"
]
},
- "openai/outputTemplate": "ui://kiln/asset-v5.html",
- "ui/resourceUri": "ui://kiln/asset-v5.html"
+ "openai/outputTemplate": "ui://kiln/asset-v6.html",
+ "ui/resourceUri": "ui://kiln/asset-v6.html"
},
"outputSchema": {
"type": "object",
@@ -2018,7 +2018,7 @@
],
"resources": [
{
- "uri": "ui://kiln/asset-v5.html",
+ "uri": "ui://kiln/asset-v6.html",
"name": "kiln-asset-viewer",
"mimeType": "text/html;profile=mcp-app",
"description": "Interactive Kiln asset viewer and downloads",
diff --git a/src/tools/registry.ts b/src/tools/registry.ts
index 0e133343..83822c73 100644
--- a/src/tools/registry.ts
+++ b/src/tools/registry.ts
@@ -94,7 +94,8 @@ import type { TextureUsage } from '../textures';
// Tool definition contract
// =============================================================================
-export const KILN_ASSET_WIDGET_URI = 'ui://kiln/asset-v5.html';
+export { KILN_ASSET_WIDGET_URI } from '../asset-widget-uri';
+import { KILN_ASSET_WIDGET_URI } from '../asset-widget-uri';
export interface KilnToolDef {
/** Shared action ownership and requirements; never hand-maintained by transports. */
actionContract?: Readonly<Record<string, import('./operation-contract').KilnActionContract>>;
diff --git a/src/viewer/chat-app.ts b/src/viewer/chat-app.ts
index 4020827e..5c5d87f1 100644
--- a/src/viewer/chat-app.ts
+++ b/src/viewer/chat-app.ts
@@ -51,6 +51,8 @@ function encode(bytes: Uint8Array) {
async function show(input: unknown) {
const revision = ++presentationRevision;
record = undefined;
+ element('stats').textContent = '';
+ element<HTMLSelectElement>('clips').hidden = true;
for (const button of document.querySelectorAll<HTMLButtonElement>('button[data-download]'))
button.disabled = true;
try {
@@ -116,14 +118,16 @@ async function showResult(
status.textContent = 'Drag to orbit · Scroll to zoom';
} catch (error) {
if (revision !== presentationRevision) return;
+ stage?.dispose();
+ stage = undefined;
const preview = record.files['preview.png'];
if (preview) {
const image = new Image();
- image.alt = record.manifest.name;
+ image.alt = `${record.manifest.name} · saved preview image`;
image.src = `data:image/png;base64,${encode(preview)}`;
element('stage').replaceChildren(image);
}
- status.textContent = `3D preview unavailable: ${String(error)}`;
+ status.textContent = `${preview ? 'Showing saved preview. ' : ''}3D preview unavailable: ${String(error)}`;
}
for (const button of document.querySelectorAll<HTMLButtonElement>('button[data-download]'))
button.disabled = false;
diff --git a/src/viewer/glb-loader.test.ts b/src/viewer/glb-loader.test.ts
new file mode 100644
index 00000000..93ba0a6f
--- /dev/null
+++ b/src/viewer/glb-loader.test.ts
@@ -0,0 +1,155 @@
+import { expect, spyOn, test } from 'bun:test';
+import { BoxGeometry, Group, Mesh, MeshStandardMaterial, Texture, TextureLoader } from 'three';
+import { loadAssetGlb, disposeAssetModel } from './glb-loader';
+import { loadViewerLevels } from './lod';
+
+function fixture(
+ image: Record<string, unknown> = { bufferView: 1, mimeType: 'image/png' },
+ late = false,
+) {
+ const binary = new Uint8Array(40);
+ binary.set([1, 2, 3, 4], 36);
+ const json = new TextEncoder().encode(
+ JSON.stringify({
+ asset: { version: '2.0' },
+ scene: 0,
+ scenes: [{ nodes: [0] }],
+ nodes: late
+ ? [{ mesh: 0, extensions: { MSFT_lod: { ids: [1] } } }, { mesh: 1 }]
+ : [{ mesh: 0 }],
+ meshes: [
+ { primitives: [{ attributes: { POSITION: 0 }, material: late ? 1 : 0 }] },
+ ...(late ? [{ primitives: [{ attributes: { POSITION: 0 }, material: 0 }] }] : []),
+ ],
+ materials: [{ pbrMetallicRoughness: { baseColorTexture: { index: 0 } } }, {}],
+ textures: [{ source: 0 }],
+ images: [image],
+ accessors: [
+ {
+ bufferView: 0,
+ componentType: 5126,
+ count: 3,
+ type: 'VEC3',
+ min: [0, 0, 0],
+ max: [0, 0, 0],
+ },
+ ],
+ buffers: [{ byteLength: binary.length }],
+ bufferViews: [
+ { buffer: 0, byteLength: 36 },
+ { buffer: 0, byteOffset: 36, byteLength: 4 },
+ ],
+ }),
+ );
+ const size = Math.ceil(json.length / 4) * 4;
+ const bytes = new Uint8Array(28 + size + binary.length);
+ const header = new DataView(bytes.buffer);
+ for (const [offset, value] of [
+ [0, 0x46546c67],
+ [4, 2],
+ [8, bytes.length],
+ [12, size],
+ [16, 0x4e4f534a],
+ [20 + size, binary.length],
+ [24 + size, 0x004e4942],
+ ])
+ header.setUint32(offset!, value!, true);
+ bytes.fill(32, 20, 20 + size);
+ bytes.set(json, 20);
+ bytes.set(binary, 28 + size);
+ return bytes;
+}
+
+test('embedded bytes use the image handler without mutating the GLB', async () => {
+ const urls: string[] = [];
+ const loader = spyOn(TextureLoader.prototype, 'load').mockImplementation((url, loaded) => {
+ urls.push(url);
+ const texture = new Texture<HTMLImageElement>();
+ queueMicrotask(() => loaded?.(texture));
+ return texture;
+ });
+ try {
+ const bytes = fixture();
+ const before = bytes.slice();
+ const gltf = await loadAssetGlb(bytes);
+ gltf.assertTexturesLoaded();
+ expect(urls).toEqual(['data:image/png;base64,AQIDBA==']);
+ expect(bytes).toEqual(before);
+ expect((gltf.scene.children[0] as Mesh).material).toBeInstanceOf(MeshStandardMaterial);
+ disposeAssetModel(gltf.scene);
+ } finally {
+ loader.mockRestore();
+ }
+});
+
+test('a failed image decode rejects the model instead of committing a null map', async () => {
+ const loader = spyOn(TextureLoader.prototype, 'load').mockImplementation(function (
+ this: TextureLoader,
+ url,
+ _loaded,
+ _progress,
+ failed,
+ ) {
+ queueMicrotask(() => {
+ this.manager.itemError(url);
+ failed?.(new Error('Test image decoder failure'));
+ });
+ return new Texture<HTMLImageElement>();
+ });
+ try {
+ await expect(loadAssetGlb(fixture())).rejects.toThrow('embedded texture');
+ } finally {
+ loader.mockRestore();
+ }
+});
+
+test('unsupported embedded image formats and external URLs fail before decoding', async () => {
+ await expect(loadAssetGlb(fixture({ bufferView: 1, mimeType: 'image/svg+xml' }))).rejects.toThrow(
+ 'Unsupported embedded image',
+ );
+ await expect(loadAssetGlb(fixture({ uri: 'https://example.invalid/image.png' }))).rejects.toThrow(
+ 'embed',
+ );
+});
+
+test('a texture failure in a detached LOD is detected before the stage can commit', async () => {
+ const loader = spyOn(TextureLoader.prototype, 'load').mockImplementation(function (
+ this: TextureLoader,
+ url,
+ _loaded,
+ _progress,
+ failed,
+ ) {
+ queueMicrotask(() => {
+ this.manager.itemError(url);
+ failed?.(new Error('Test LOD image decoder failure'));
+ });
+ return new Texture<HTMLImageElement>();
+ });
+ try {
+ const gltf = await loadAssetGlb(fixture(undefined, true));
+ expect(() => gltf.assertTexturesLoaded()).not.toThrow();
+ const levels = await loadViewerLevels(gltf);
+ expect(levels?.chains.length).toBe(1);
+ expect(() => gltf.assertTexturesLoaded()).toThrow('embedded texture');
+ for (const root of [gltf.scene, ...levels!.chains.flatMap((chain) => chain.levels.slice(1))])
+ disposeAssetModel(root);
+ } finally {
+ loader.mockRestore();
+ }
+});
+
+test('disposing a rejected model releases shared geometry, materials and textures once', () => {
+ const geometry = new BoxGeometry();
+ const map = new Texture();
+ const material = new MeshStandardMaterial({ map });
+ const root = new Group().add(new Mesh(geometry, material), new Mesh(geometry, [material]));
+ const counts = [0, 0, 0];
+ [geometry, material, map].forEach((resource, i) => {
+ resource.addEventListener('dispose', () => {
+ counts[i]!++;
+ });
+ });
+ disposeAssetModel(root);
+ expect(counts).toEqual([1, 1, 1]);
+});
diff --git a/src/viewer/glb-loader.ts b/src/viewer/glb-loader.ts
new file mode 100644
index 00000000..0e19dbe6
--- /dev/null
+++ b/src/viewer/glb-loader.ts
@@ -0,0 +1,78 @@
+import {
+ LoadingManager,
+ TextureLoader,
+ Texture,
+ type Object3D,
+ type Mesh,
+ type BufferGeometry,
+ type Material,
+} from 'three';
+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+import { validateAssetGlb } from '../assets';
+
+export function disposeAssetModel(model: Object3D) {
+ const geometries = new Set<BufferGeometry>();
+ const materials = new Set<Material>();
+ const textures = new Set<Texture>();
+ model.traverse((object) => {
+ const mesh = object as Mesh;
+ if (!mesh.isMesh) return;
+ geometries.add(mesh.geometry);
+ for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) {
+ materials.add(material);
+ for (const value of Object.values(material))
+ if (value instanceof Texture) textures.add(value);
+ }
+ });
+ for (const value of [...geometries, ...materials, ...textures]) value.dispose();
+}
+
+/**
+ * Parse self-contained GLBs under MCP Apps' img-src data: / connect-src none policy.
+ * ImageBitmapLoader fetches even blob/data URLs. Use the documented image handler
+ * instead, preserving GLTFLoader's sampler, UV, color-space and extension logic.
+ * Only the parser's private JSON copy changes; downloaded GLB bytes remain exact.
+ */
+export async function loadAssetGlb(bytes: Uint8Array) {
+ validateAssetGlb(bytes);
+ const manager = new LoadingManager();
+ let imageFailed = false;
+ manager.onError = () => {
+ imageFailed = true;
+ };
+ manager.addHandler(/^data:image\//, new TextureLoader(manager));
+ manager.setURLModifier((url) => {
+ if (!url.startsWith('blob:') && !url.startsWith('data:'))
+ throw new Error('External model resources are not loaded');
+ return url;
+ });
+ const loader = new GLTFLoader(manager);
+ loader.register((parser) => ({
+ name: 'KILN_embedded_images',
+ async beforeRoot() {
+ for (const image of parser.json.images ?? []) {
+ if (image.bufferView === undefined) continue;
+ const buffer = new Uint8Array(await parser.getDependency('bufferView', image.bufferView));
+ let binary = '';
+ for (let i = 0; i < buffer.length; i += 8192)
+ binary += String.fromCharCode(...buffer.subarray(i, i + 8192));
+ if (!/^image\/(png|jpeg|webp|avif)$/.test(image.mimeType ?? ''))
+ throw new Error('Unsupported embedded image type');
+ image.uri = `data:${image.mimeType};base64,${btoa(binary)}`;
+ delete image.bufferView;
+ }
+ },
+ }));
+ const gltf = await loader.parseAsync(Uint8Array.from(bytes).buffer, '');
+ if (imageFailed) {
+ for (const scene of gltf.scenes) disposeAssetModel(scene);
+ throw new Error('An embedded texture could not be decoded.');
+ }
+ // GLTFLoader deliberately converts failed images to null maps. Never commit a
+ // material-degraded scene, including resources loaded later for detached LODs.
+ return Object.assign(gltf, {
+ assertTexturesLoaded() {
+ if (imageFailed) throw new Error('An embedded texture could not be decoded.');
+ },
+ });
+}
diff --git a/src/viewer/scene.ts b/src/viewer/scene.ts
index 2cf9c91d..85465022 100644
--- a/src/viewer/scene.ts
+++ b/src/viewer/scene.ts
@@ -1,9 +1,8 @@
/// <reference lib="dom" />
import * as THREE from 'three';
-import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
-import { validateAssetGlb } from '../assets';
+import { loadAssetGlb, disposeAssetModel as disposeModel } from './glb-loader';
import { frameAssetBounds } from './framing';
import {
captureCameraView,
@@ -156,22 +155,6 @@ export function createAssetStage(container: HTMLElement) {
],
};
};
- const disposeModel = (model: THREE.Object3D) => {
- const geometries = new Set<THREE.BufferGeometry>();
- const materials = new Set<THREE.Material>();
- const textures = new Set<THREE.Texture>();
- model.traverse((object) => {
- const mesh = object as THREE.Mesh;
- if (!mesh.isMesh) return;
- geometries.add(mesh.geometry);
- for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) {
- materials.add(material);
- for (const value of Object.values(material))
- if (value instanceof THREE.Texture) textures.add(value);
- }
- });
- for (const value of [...geometries, ...materials, ...textures]) value.dispose();
- };
const reset = () => {
if (!root) return;
const box = drawnBounds(root);
@@ -263,17 +246,17 @@ export function createAssetStage(container: HTMLElement) {
const loadStarted = performance.now();
const current = ++generation;
cancelMeasurement('The artifact changed during measurement. Measure the new revision again.');
- validateAssetGlb(bytes);
- const manager = new THREE.LoadingManager();
- manager.setURLModifier((url) => {
- if (!url.startsWith('blob:') && !url.startsWith('data:'))
- throw new Error('External model resources are not loaded');
- return url;
- });
- const parsed = await new GLTFLoader(manager).parseAsync(Uint8Array.from(bytes).buffer, '');
+ const parsed = await loadAssetGlb(bytes);
// three's loader draws every node; hide what KHR_node_visibility hides before counting.
applyNodeVisibility(parsed, [parsed.scene]);
const parsedLevels = await loadViewerLevels(parsed);
+ try {
+ parsed.assertTexturesLoaded();
+ } catch (error) {
+ disposeModel(parsed.scene);
+ for (const level of detachedLevels(parsedLevels)) disposeModel(level);
+ throw error;
+ }
const gltf = acceptLoadedResource(
parsed,
() => !disposed && current === generation && options.isCurrent?.() !== false,