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.

chore: prepare engine and plugin 1.3.1 release (#185)

Matthew Kissinger4788c5acd4d3
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index bad585ce..a65a2819 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.3.0",
+ "version": "1.3.1",
"author": {
"name": "Matthew Kissinger"
},
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index 78248e7f..32f1d847 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "kiln",
- "version": "1.3.0",
+ "version": "1.3.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 dc085da1..ffde2b62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,13 @@ does not publish a package.
## Unreleased
+## 1.3.1 (unpublished)
+
- Document private security reporting, include the policy in distributed
packages, complete Codex plugin website and repository metadata, and
configure monthly dependency update proposals.
+- Correct installation instructions to reference the published 1.3.0 plugin.
+- Use single-view posters for Cabin gallery assets on the website.
## 1.3.0 (2026-10-16)
diff --git a/dist/agent-run.mjs b/dist/agent-run.mjs
index 564dd2d4..7d1f3006 100644
--- a/dist/agent-run.mjs
+++ b/dist/agent-run.mjs
@@ -40024,7 +40024,7 @@ function createKilnSourceDef(store) {
}
// src/engine-identity.ts
-var ENGINE_VERSION = "1.3.0";
+var ENGINE_VERSION = "1.3.1";
var ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
function engineIdentity() {
return { version: ENGINE_VERSION, installUrl: ENGINE_INSTALL_URL };
diff --git a/dist/build.json b/dist/build.json
index ddb4db87..c866e4c3 100644
--- a/dist/build.json
+++ b/dist/build.json
@@ -2,10 +2,10 @@
"schemaVersion": 1,
"entries": {
"worker": {
- "identity": "sha256:8c6011a053d15863ced9171f045302f1df9656e66298aab07600e5abf5cb9b68",
- "engineVersion": "1.3.0",
+ "identity": "sha256:d191b9c64e679e2175cda0dc8dd86ca11870c2955991ce7510bf350d62b37db4",
+ "engineVersion": "1.3.1",
"toolchain": "[email protected]",
- "sourceHash": "da55f9afb5a12898addb335ee7e8adbdd5236196c23fdae9f432693c2b1ea566",
+ "sourceHash": "947ee3b7e06e83a91fa377b06d065e5d994cba34eabac8715bb7575172184711",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "f17d705cc5de6856252c111542b8e179695cc81448eb1e2fc4d9a343ed42370a",
"dependencies": {
@@ -40,10 +40,10 @@
"bundleHash": "sha256:07c1b534e55c1b7fa3fb8136028209b5187fbc9b16810970ad76140ea436696e"
},
"agent-run": {
- "identity": "sha256:8c6011a053d15863ced9171f045302f1df9656e66298aab07600e5abf5cb9b68",
- "engineVersion": "1.3.0",
+ "identity": "sha256:d191b9c64e679e2175cda0dc8dd86ca11870c2955991ce7510bf350d62b37db4",
+ "engineVersion": "1.3.1",
"toolchain": "[email protected]",
- "sourceHash": "da55f9afb5a12898addb335ee7e8adbdd5236196c23fdae9f432693c2b1ea566",
+ "sourceHash": "947ee3b7e06e83a91fa377b06d065e5d994cba34eabac8715bb7575172184711",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "f17d705cc5de6856252c111542b8e179695cc81448eb1e2fc4d9a343ed42370a",
"dependencies": {
@@ -75,13 +75,13 @@
},
"target": "node",
"file": "agent-run.mjs",
- "bundleHash": "sha256:05be3a3342f08b36b4412d7ddcb0c56ec2036100845dcad0b4840338885a0621"
+ "bundleHash": "sha256:45a9bf04ade13494e77465880b22402d9e248ad4fe316407c228db6b0c6b8a8c"
},
"agent-providers": {
- "identity": "sha256:8c6011a053d15863ced9171f045302f1df9656e66298aab07600e5abf5cb9b68",
- "engineVersion": "1.3.0",
+ "identity": "sha256:d191b9c64e679e2175cda0dc8dd86ca11870c2955991ce7510bf350d62b37db4",
+ "engineVersion": "1.3.1",
"toolchain": "[email protected]",
- "sourceHash": "da55f9afb5a12898addb335ee7e8adbdd5236196c23fdae9f432693c2b1ea566",
+ "sourceHash": "947ee3b7e06e83a91fa377b06d065e5d994cba34eabac8715bb7575172184711",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "f17d705cc5de6856252c111542b8e179695cc81448eb1e2fc4d9a343ed42370a",
"dependencies": {
@@ -116,10 +116,10 @@
"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"
},
"mcp": {
- "identity": "sha256:8c6011a053d15863ced9171f045302f1df9656e66298aab07600e5abf5cb9b68",
- "engineVersion": "1.3.0",
+ "identity": "sha256:d191b9c64e679e2175cda0dc8dd86ca11870c2955991ce7510bf350d62b37db4",
+ "engineVersion": "1.3.1",
"toolchain": "[email protected]",
- "sourceHash": "da55f9afb5a12898addb335ee7e8adbdd5236196c23fdae9f432693c2b1ea566",
+ "sourceHash": "947ee3b7e06e83a91fa377b06d065e5d994cba34eabac8715bb7575172184711",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "f17d705cc5de6856252c111542b8e179695cc81448eb1e2fc4d9a343ed42370a",
"dependencies": {
@@ -151,13 +151,13 @@
},
"target": "node",
"file": "mcp-server.mjs",
- "bundleHash": "sha256:7488f7b83f132bf1de7a05a66d884e8ea08ab8e5accddcd1cbbad54b2e1a7ea6"
+ "bundleHash": "sha256:814d8ca81116501226d58e6f67c6ab2fe408c5ad08ae4995d6136b22ad024285"
},
"cli": {
- "identity": "sha256:8c6011a053d15863ced9171f045302f1df9656e66298aab07600e5abf5cb9b68",
- "engineVersion": "1.3.0",
+ "identity": "sha256:d191b9c64e679e2175cda0dc8dd86ca11870c2955991ce7510bf350d62b37db4",
+ "engineVersion": "1.3.1",
"toolchain": "[email protected]",
- "sourceHash": "da55f9afb5a12898addb335ee7e8adbdd5236196c23fdae9f432693c2b1ea566",
+ "sourceHash": "947ee3b7e06e83a91fa377b06d065e5d994cba34eabac8715bb7575172184711",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "f17d705cc5de6856252c111542b8e179695cc81448eb1e2fc4d9a343ed42370a",
"dependencies": {
@@ -189,13 +189,13 @@
},
"target": "node",
"file": "cli.mjs",
- "bundleHash": "sha256:2301a0fe7b2ecb2bbc96d2adba2df8cbed07a751609741f549cbaa31f91d3d11"
+ "bundleHash": "sha256:ae308a69bc0403d06afe903f12974bfecc22ecbbfacced32f724f3bc72610a63"
},
"engine": {
- "identity": "sha256:8c6011a053d15863ced9171f045302f1df9656e66298aab07600e5abf5cb9b68",
- "engineVersion": "1.3.0",
+ "identity": "sha256:d191b9c64e679e2175cda0dc8dd86ca11870c2955991ce7510bf350d62b37db4",
+ "engineVersion": "1.3.1",
"toolchain": "[email protected]",
- "sourceHash": "da55f9afb5a12898addb335ee7e8adbdd5236196c23fdae9f432693c2b1ea566",
+ "sourceHash": "947ee3b7e06e83a91fa377b06d065e5d994cba34eabac8715bb7575172184711",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "f17d705cc5de6856252c111542b8e179695cc81448eb1e2fc4d9a343ed42370a",
"dependencies": {
@@ -227,7 +227,7 @@
},
"target": "node",
"file": "mcp-engine.mjs",
- "bundleHash": "sha256:723dcd58529e9856281adac58f70bc2f11ac298283092d7a7f2de617e8a3bd90"
+ "bundleHash": "sha256:f3dcdceed72bd0868f34160dd9037b9154cbe945655e04eaf87676c02f44e929"
}
}
}
diff --git a/dist/cli.mjs b/dist/cli.mjs
index 0f94459b..ffb39846 100644
--- a/dist/cli.mjs
+++ b/dist/cli.mjs
@@ -43357,7 +43357,7 @@ var init_program_artifacts = __esm(() => {
function engineIdentity() {
return { version: ENGINE_VERSION, installUrl: ENGINE_INSTALL_URL };
}
-var ENGINE_VERSION = "1.3.0", ENGINE_INSTALL_URL;
+var ENGINE_VERSION = "1.3.1", ENGINE_INSTALL_URL;
var init_engine_identity = __esm(() => {
ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
});
diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjs
index bdfdf0fa..945a96f9 100644
--- a/dist/mcp-engine.mjs
+++ b/dist/mcp-engine.mjs
@@ -43299,7 +43299,7 @@ import { readFile as readFile8 } from "node:fs/promises";
var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v6.html";
// src/engine-identity.ts
-var ENGINE_VERSION = "1.3.0";
+var ENGINE_VERSION = "1.3.1";
var ENGINE_INSTALL_URL = new URL("../", import.meta.url).href;
function engineIdentity() {
return { version: ENGINE_VERSION, installUrl: ENGINE_INSTALL_URL };
diff --git a/dist/mcp-server.mjs b/dist/mcp-server.mjs
index a1c2e48d..2dd0d9cd 100644
--- a/dist/mcp-server.mjs
+++ b/dist/mcp-server.mjs
@@ -2085,7 +2085,7 @@ import { readFile } from "node:fs/promises";
var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v6.html";
// src/engine-identity.ts
-var ENGINE_VERSION = "1.3.0";
+var ENGINE_VERSION = "1.3.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 cb81fddf..241efe7f 100644
--- a/dist/viewer/app.js
+++ b/dist/viewer/app.js
@@ -1,75 +1,321 @@
-function Io(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 pu(e,t="|"){return e.map((n)=>_u(n)).join(t)}function Po(e,t){if(typeof t==="bigint")return t.toString();return t}class Tp{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 Lo(e){return new Tp(e)}function Rp(e){return e===null||e===void 0}function mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Cp(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 Hn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function No(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xi(e){return No(e._zod.def)??e._zod.def.shape}function Ip(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Hn(this,t,i),i},enumerable:!0,configurable:!0})}function Pp(e,t,n){if(t in e)Hn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Xi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Ip(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Pp(e,s,i?i(o.value,s):o.value)}}function JS(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Ip(e,n,()=>t[n]);else Pp(e,n,i.value)}}function Cn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Lp(e){return JSON.stringify(e)}function Np(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var mu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ms(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Dp=Lo(()=>{if(vn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function qr(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 gu(e){if(qr(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 Op=new Set(["string","number","symbol"]),Up=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Yi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xi(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 _u(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function kp(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var sc=(()=>({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]}))(),xu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function KS(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 Xr(s,e,oc(e,t)),xi(e,Cn(n,{shape:s,checks:[]}))}function oc(e,t){let n=Xi(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 QS(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(oc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Xi(e)).filter((a)=>!s.has(a))),xi(e,Cn(n,{shape:o,checks:[]}))}function ew(e,t){if(!qr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Xi(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 xi(e,Cn(e._zod.def,{shape:Fp(e,t)}))}function Fp(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Xi(e))),JS(n,t),n}function tw(e,t){if(!qr(t))throw Error("Invalid input to safeExtend: expected a plain object");return xi(e,Cn(e._zod.def,{shape:Fp(e,t)}))}function nw(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={};Xr(n,e,Reflect.ownKeys(Xi(e))),Xr(n,t,Reflect.ownKeys(Xi(t)));let i=Cn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return xi(e,i)}function zp(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(oc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Xi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),xi(t,Cn(t._zod.def,{shape:c,checks:[]}))}function iw(e,t,n){let i=n?new Set(oc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Xi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),xi(t,Cn(t._zod.def,{shape:r}))}function Gn(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 Bp(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 vi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Co(e){return typeof e==="string"?e:e?.message}function vu(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function yi(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:Co(e.inst?._zod.def?.error?.(e))??Co(s?.(e))??Co(t?.error?.(e))??Co(n.customError?.(e))??Co(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 rw=/[\uD800-\uDBFF]/;function ac(e){let t=e.length;if(!rw.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 cc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Vp(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 Yr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Hp(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else sw(e,n,i.value)}}function qi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function lc(e,t,n){return qi(e,t,n,!1)}function Gp(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return qi(this,n,i(this))},set(r){qi(this,n,r)}})}return t}function sw(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:qi(this,t,n.bind(this))},set(i){qi(this,t,i)}})}function ow(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var fu,pr=!1,aw={configurable:!0,get(){pr=!0;return}};function pt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&fu!==e._zod){fu=void 0;return}fu=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,aw);let r=pr;pr=!1;try{let s=n(this);if(pr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return pr=pr||r,s}catch(s){throw delete this[t],pr=pr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function cw(e,t,n,i){let r=ow(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 lw="~constantCatch";function $p(e){let t=()=>e;return t[lw]=!0,t}var Wp;var yu={value:void 0,enumerable:!1},Zp="captureStackTrace"in Error?Error:null;function uw(e){let t=Zp;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Zp=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){yu.value=new s(f);try{Object.defineProperty(d,"_zod",yu)}finally{yu.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 y=g??_;if(!a.has(y))a.add(y),Hp(y,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?uw(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 bi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Do extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Wp=globalThis).__zod_globalConfig??(Wp.__zod_globalConfig={});var vn=globalThis.__zod_globalConfig;function In(e){if(e)Object.assign(vn,e);return vn}function hw(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Po,2)),e.message}function dw(e){this._zod.message=e}var fw={get:hw,set:dw,enumerable:!0,configurable:!0},Su={value:void 0,enumerable:!1},jp=new WeakSet([Object.prototype,Error.prototype]),Xp=(e,t)=>{e.name="$ZodError",Su.value=t,Object.defineProperty(e,"issues",Su),Su.value=void 0,Object.defineProperty(e,"message",fw);let n=Object.getPrototypeOf(e);if(!jp.has(n))jp.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})}})},qp=ie("$ZodError",Xp),LP=ie("$ZodError",Xp,void 0,{Parent:Error});function pw(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 Yp(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)pw(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Jp(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 uc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var hc=(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 bi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>yi(l,o,In())));throw mu(c,s?.callee??t),c}return a.value};return t};var dc=(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)=>yi(l,o,In())));throw mu(c,s?.callee??t),c}return a.value};return t};var fc=(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 bi;return s.issues.length?Kp(e,s.issues,r):{success:!0,data:s.value}};function Kp(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>yi(r,n,In()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var pc=(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?Kp(e,s.issues,r):{success:!0,data:s.value}};var mw=Symbol.for("zod.compile.invalid"),gw=Symbol.for("zod.compile.fallback"),wu=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==mw)return!0;if(i.definite===!0&&n===void 0)return!1}return _w(e,t,n)};function _w(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[gw]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new bi;return s.issues.length===0}var Mu=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},Qp=(e)=>{let t=hc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,uc(n,o))};return n};var em=(e)=>{let t=hc(e),n=(i,r,s,o)=>t(i,r,s,uc(n,o));return n};var tm=(e)=>{let t=dc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,uc(n,o))};return n};var nm=(e)=>{let t=dc(e),n=async(i,r,s,o)=>await t(i,r,s,uc(n,o));return n};var im=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return fc(e)(t,n,r)};var rm=(e)=>(t,n,i)=>fc(e)(t,n,i);var sm=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return pc(e)(t,n,r)};var om=(e)=>async(t,n,i)=>pc(e)(t,n,i);var am=/^[cC][0-9a-z]{6,}$/,cm=/^[0-9a-z]+$/,lm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,um=/^[0-9a-vA-V]{20}$/,hm=/^[A-Za-z0-9]{27}$/,dm=/^[a-zA-Z0-9_-]{21}$/;function fm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var pm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var mm=/^([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})$/,Au=(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 gm=/^(?:[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 xw="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function _m(){return new RegExp(xw,"u")}var xm=/^(?:(?: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])$/,vm=/^(([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 ym=/^((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])$/,bm=/^(([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])$/,Sm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Mm=/^https?$/,Em=/^\+[1-9]\d{6,14}$/;var Am="(?:(?:\\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 vw(e){return new RegExp(`^${e}$`)}var Tm=vw(Am);function Eu(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 Rm(e){return new RegExp(`^${Eu(e)}$`)}function Cm(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Eu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Eu({precision:e.precision})}`:n;return new RegExp(`^${Am}T(?:${i})$`)}var Im=/^[\s\S]{0,}$/,Pm=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var mc=/^-?\d+$/,Es=/^-?\d+(?:\.\d+)?$/,Lm=/^(?:true|false)$/i;var Nm=/^[^A-Z]*$/,Dm=/^[^a-z]*$/;var cn=ie("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Tu=(e)=>{let t=e.value;return!Rp(t)&&t.length!==void 0},gc={number:"number",bigint:"bigint",object:"date"},Ru=ie("$ZodCheckLessThan",(e,t)=>{cn.init(e,t);let n=gc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:gc[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})}}),Cu=ie("$ZodCheckGreaterThan",(e,t)=>{cn.init(e,t);let n=gc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:gc[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})}}),Om=ie("$ZodCheckMultipleOf",(e,t)=>{cn.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):Cp(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})}}),Um=ie("$ZodCheckNumberFormat",(e,t)=>{cn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=sc[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 km=ie("$ZodCheckMaxLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=Tu),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?ac(r):s)<=t.maximum)return;let a=cc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Fm=ie("$ZodCheckMinLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=Tu),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?ac(r):s)>=t.minimum)return;let a=cc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),zm=ie("$ZodCheckLengthEquals",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=Tu),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?ac(r):s;if(o===t.length)return;let a=cc(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})}}),Uo=ie("$ZodCheckStringFormat",(e,t)=>{var n,i;if(cn.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=()=>{})}),Bm=ie("$ZodCheckRegex",(e,t)=>{Uo.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})}}),Vm=ie("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Nm),Uo.init(e,t)}),Hm=ie("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Dm),Uo.init(e,t)}),Gm=ie("$ZodCheckIncludes",(e,t)=>{cn.init(e,t);let n=Yi(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})}}),$m=ie("$ZodCheckStartsWith",(e,t)=>{cn.init(e,t);let n=new RegExp(`^${Yi(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})}}),Wm=ie("$ZodCheckEndsWith",(e,t)=>{cn.init(e,t);let n=new RegExp(`.*${Yi(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 Zm=ie("$ZodCheckOverwrite",(e,t)=>{cn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Iu{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 Xm={major:4,minor:6,patch:5};var At=ie("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xm;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=Gn(a),h;for(let d of c){if(d._zod.def.when){if(Bp(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 bi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(vu(a.issues,f,e),!u)u=Gn(a,f)});else{if(a.issues.length===f)continue;if(vu(a.issues,f,e),!u)u=Gn(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(Gn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new bi;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 bi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return lc(this,"~standard",Nu(this))},set "~standard"(e){qi(this,"~standard",e)}}),cg=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>yi(n,t,In()))}:{value:e.value};async function yw(e,t){let n={async:!0};return cg(await e._zod.run({value:t,issues:[]},n),n)}function Nu(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return cg(i,n)}catch(i){}return yw(e,t)},vendor:"zod",version:1}}var yc=ie("$ZodString",(e,t)=>{At.init(e,t),e._zod.pattern=t.pattern??Im,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}}),Nt=ie("$ZodStringFormat",(e,t)=>{Uo.init(e,t),yc.init(e,t)}),lg=ie("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=mm),Nt.init(e,t)}),ug=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=Au(i))}else t.pattern??(t.pattern=Au());Nt.init(e,t)}),hg=ie("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=gm),Nt.init(e,t)}),dg=1,xc=2;function fg(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function bw(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return fg(e)||xc;return Sw(e,t)}function Sw(e,t){if(!t.normalize&&t.protocol?.source===Mm.source&&!/^https?:\/\//i.test(e))return dg;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??xc}return new URL(e)}catch{return xc}}var ww=/[\t\n\r]/g;function qm(e){return e.replace(ww,"")}function Mw(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ew(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var pg=ie("$ZodURL",(e,t)=>{Nt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=bw(i,t);if(r===dg){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===xc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=qm(i);return}if(t.hostname&&!Mw(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&&!Ew(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:qm(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),mg=ie("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=_m()),Nt.init(e,t)}),gg=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?dm:fm(t.length)),Nt.init(e,t)}),_g=ie("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=am),Nt.init(e,t)}),xg=ie("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cm),Nt.init(e,t)}),vg=ie("$ZodULID",(e,t)=>{t.pattern??(t.pattern=lm),Nt.init(e,t)}),yg=ie("$ZodXID",(e,t)=>{t.pattern??(t.pattern=um),Nt.init(e,t)}),bg=ie("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hm),Nt.init(e,t)}),Sg=ie("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Cm(t)),Nt.init(e,t)}),wg=ie("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Tm),Nt.init(e,t)}),Mg=ie("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Rm(t)),Nt.init(e,t)}),Eg=ie("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pm),Nt.init(e,t)}),Ag=ie("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=xm),Nt.init(e,t)}),Aw=/^[0-9a-fA-F:.]+$/;function Tg(e){if(!Aw.test(e))return!1;return fg(`http://[${e}]`)}var Rg=ie("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vm),Nt.init(e,t),e._zod.check=(n)=>{if(!Tg(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Cg=ie("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ym),Nt.init(e,t)});function Tw(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 Tg(n)}var Ig=ie("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=bm),Nt.init(e,t),e._zod.check=(n)=>{if(!Tw(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Pg(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 Du=/^[0-9a-zA-Z+/]*={0,2}$/,Lg=ie("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Du),Nt.init(e,t),e._zod.check=(n)=>{if(Pg(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),bc=/^[A-Za-z0-9_-]*$/;function Rw(e){if(!bc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Pg(n)}var Ng=ie("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bc),Nt.init(e,t),e._zod.check=(n)=>{if(Rw(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Dg=ie("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Em),Nt.init(e,t)});function Cw(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 Og=ie("$ZodJWT",(e,t)=>{Nt.init(e,t),e._zod.check=(n)=>{if(Cw(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Ou=ie("$ZodNumber",(e,t)=>{At.init(e,t),e._zod.pattern=Es,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}}),Ug=ie("$ZodNumberFormat",(e,t)=>{Um.init(e,t),Ou.init(e,t)}),kg=ie("$ZodBoolean",(e,t)=>{At.init(e,t),e._zod.pattern=Lm,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 Fg=ie("$ZodUnknown",(e,t)=>{At.init(e,t),e._zod.parse=(n)=>n}),zg=ie("$ZodNever",(e,t)=>{At.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ym(e,t,n){if(e.issues.length)t.issues.push(...vi(n,e.issues));t.value[n]=e.value}var Bg=ie("$ZodArray",(e,t)=>{At.init(e,t);let n=vn.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)=>Ym(h,i,c)));else if(Ym(u,i,c),a&&u.issues.length!==0&&Gn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function vc(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(...vi(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 Iw=[];function Vg(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:Iw,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=kp(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Hg(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(Gn(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)=>vc(p,n,m,t,h,d)));else vc(_,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 Pw=ie("$ZodObject",(e,t)=>{At.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=Lo(()=>Vg(t));pt(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))Hn(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=Ms,o=t.catchall,a,c=vn.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(Gn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],y=g._zod.optin,S=g._zod.optout,x=g._zod.run({value:h[p],issues:[]},u);if(x instanceof Promise)d.push(x.then((b)=>vc(b,l,p,h,y,S)));else vc(x,l,p,h,y,S)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Hg(d,h,l,u,r.value,e,m===!0)}}),Gg=ie("$ZodObjectJIT",(e,t)=>{Pw.init(e,t);let n=e._zod.parse,i=Lo(()=>Vg(t)),r=vn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new Iu(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(b)=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,y=(b,M)=>`
- let ${b}_ab = false;
- for (let i = 0; i < ${b}.issues.length; i++) {
- const iss = ${b}.issues[i];
- iss.path = iss.path ? [${M}, ...iss.path] : [${M}];
- payload.issues.push(iss);
- if (iss.continue !== true) ${b}_ab = true;
- }
- if (${b}_ab && ctx && ctx.abortEarly) {
- payload.value = newResult;
- return payload;
- }`;p.write("const input = payload.value;");let S=Object.create(null),x=0;for(let b of m.allKeys)S[b]=`key_${x++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of m.allKeys){if(b==="__proto__")continue;let M=S[b],T=typeof b==="symbol"?`syms[${_.indexOf(b)}]`:Lp(b),v=`${T} in input`,A=f[b],V=A?._zod?.optin,C=V!==void 0,N=A?._zod?.optout==="optional";if(p.write(`const ${M} = ${g(T)};`),C&&N){let Y=V==="optional"?`${M}_present`:`${M}.value !== undefined || ${M}_present`;p.write(`
- const ${M}_present = ${v};
- if (!${M}.issues.length || ${M}_present) {
- if (${M}.issues.length) {${y(M,T)}
- }
+var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNames:ER}=Object;var hb=Object.prototype.hasOwnProperty;function TR(e){return this[e]}var AR,SR,bf=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?AR??=new WeakMap:SR??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?_R(vR(e)):{};let a=t||!e||!e.__esModule||!hb.call(e,"default")?gf(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let o of ER(e))if(!hb.call(a,o))gf(a,o,{get:TR.bind(e,o),enumerable:!0})}if(i)r.set(e,a);return a};var Xr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var wR=(e)=>e;function MR(e,t){this[e]=wR.bind(null,t)}var pb=(e,t)=>{for(var n in t)gf(e,n,{get:t[n],enumerable:!0,configurable:!0,set:MR.bind(t,n)})};var Ft=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};function eC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";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==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';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.":""}var ja;var ou=Ft(()=>{ja=class ja extends Error{diagnostic;constructor(e,t=eC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}});function DC(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function LC(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ho(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ET(){let e=ho("canvas");return e.style.display="block",e}function Oc(...e){let t="THREE."+e.shift();if(po)po("log",t,...e);else console.log(t,...e)}function TT(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 je(...e){e=TT(e);let t="THREE."+e.shift();if(po)po("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ze(...e){e=TT(e);let t="THREE."+e.shift();if(po)po("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function fa(...e){let t=e.join(" ");if(t in $v)return;$v[t]=!0,je(...e)}function AT(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)})}class Bi{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}}}function Di(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Cn[e&255]+Cn[e>>8&255]+Cn[e>>16&255]+Cn[e>>24&255]+"-"+Cn[t&255]+Cn[t>>8&255]+"-"+Cn[t>>16&15|64]+Cn[t>>24&255]+"-"+Cn[n&63|128]+Cn[n>>8&255]+"-"+Cn[n>>16&255]+Cn[n>>24&255]+Cn[i&255]+Cn[i>>8&255]+Cn[i>>16&255]+Cn[i>>24&255]).toLowerCase()}function ct(e,t,n){return Math.max(t,Math.min(n,e))}function pm(e,t){return(e%t+t)%t}function FC(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function UC(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Pc(e,t,n){return(1-n)*e+n*t}function BC(e,t,n,i){return Pc(e,t,1-Math.exp(-n*i))}function zC(e,t=1){return t-Math.abs(pm(e,t*2)-t)}function VC(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 jC(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 HC(e,t){return e+Math.floor(Math.random()*(t-e+1))}function GC(e,t){return e+Math.random()*(t-e)}function $C(e){return e*(0.5-Math.random())}function KC(e){if(e!==void 0)Kv=e;let t=Kv+=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 WC(e){return e*Nc}function XC(e){return e*ha}function qC(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function JC(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function ZC(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function YC(e,t,n,i,r){let{cos:s,sin:a}=Math,o=s(n/2),c=a(n/2),l=s((t+i)/2),u=a((t+i)/2),d=s((t-i)/2),f=a((t-i)/2),h=s((i-t)/2),y=a((i-t)/2);switch(r){case"XYX":e.set(o*u,c*d,c*f,o*l);break;case"YZY":e.set(c*f,o*u,c*d,o*l);break;case"ZXZ":e.set(c*d,c*f,o*u,o*l);break;case"XZX":e.set(o*u,c*y,c*h,o*l);break;case"YXY":e.set(c*h,o*u,c*y,o*l);break;case"ZYZ":e.set(c*y,c*h,o*u,o*l);break;default:je("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ki(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 Ct(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.")}}function QC(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,a){if(this.enabled===!1||s===a||!s||!a)return r;if(this.spaces[s].transfer==="srgb")r.r=Lr(r.r),r.g=Lr(r.g),r.b=Lr(r.b);if(this.spaces[s].primaries!==this.spaces[a].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")r.r=fo(r.r),r.g=fo(r.g),r.b=fo(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,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].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 fa("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return fa("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:Xv,fromXYZ:qv,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}function Lr(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function fo(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}class mm{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(Za===void 0)Za=ho("canvas");Za.width=e.width,Za.height=e.height;let i=Za.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Za}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=ho("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]=Lr(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(Lr(t[n]/255)*255);else t[n]=Lr(t[n]);return{data:t,width:e.width,height:e.height}}else return je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class Vc{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:eN++}),this.uuid=Di(),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,a=i.length;s<a;s++)if(i[s].isDataTexture)r.push(Kh(i[s].image));else r.push(Kh(i[s]))}else r=Kh(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Kh(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return mm.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 je("Texture: Unable to serialize Texture."),{}}class od{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}}class jc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ar,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 ar,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ar,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j,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,a=this._targetRay,o=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,n),m=this._getHandJoint(c,y);if(g!==null)m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius;m.visible=g!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),f=0.02,h=0.005;if(c.inputState.pinching&&d>f+h)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=f-h)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity);else o.hasLinearVelocity=!1;if(r.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(a!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(cN)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.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 ar;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}function qh(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 yi{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Pi.subVectors(e,t),i.cross(Pi);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){Pi.subVectors(i,t),Nr.subVectors(n,t),Jh.subVectors(e,t);let s=Pi.dot(Pi),a=Pi.dot(Nr),o=Pi.dot(Jh),c=Nr.dot(Nr),l=Nr.dot(Jh),u=s*c-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(c*o-a*l)*d,h=(s*l-a*o)*d;return r.set(1-f-h,h,f)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Pr)===null)return!1;return Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getInterpolation(e,t,n,i,r,s,a,o){if(this.getBarycoord(e,t,n,i,Pr)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(r,Pr.x),o.addScaledVector(s,Pr.y),o.addScaledVector(a,Pr.z),o}static getInterpolatedAttribute(e,t,n,i,r,s){return ep.setScalar(0),tp.setScalar(0),np.setScalar(0),ep.fromBufferAttribute(e,t),tp.fromBufferAttribute(e,n),np.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(ep,r.x),s.addScaledVector(tp,r.y),s.addScaledVector(np,r.z),s}static isFrontFacing(e,t,n,i){return Pi.subVectors(n,t),Nr.subVectors(e,t),Pi.cross(Nr).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 Pi.subVectors(this.c,this.b),Nr.subVectors(this.a,this.b),Pi.cross(Nr).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return yi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return yi.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return yi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yi.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,a;to.subVectors(i,n),no.subVectors(r,n),Zh.subVectors(e,n);let o=to.dot(Zh),c=no.dot(Zh);if(o<=0&&c<=0)return t.copy(n);Yh.subVectors(e,i);let l=to.dot(Yh),u=no.dot(Yh);if(l>=0&&u<=l)return t.copy(i);let d=o*u-l*c;if(d<=0&&o>=0&&l<=0)return s=o/(o-l),t.copy(n).addScaledVector(to,s);Qh.subVectors(e,r);let f=to.dot(Qh),h=no.dot(Qh);if(h>=0&&f<=h)return t.copy(r);let y=f*c-o*h;if(y<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(no,a);let g=l*h-f*u;if(g<=0&&u-l>=0&&f-h>=0)return iE.subVectors(r,i),a=(u-l)/(u-l+(f-h)),t.copy(i).addScaledVector(iE,a);let m=1/(g+y+d);return s=y*m,a=d*m,t.copy(n).addScaledVector(to,s).addScaledVector(no,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class hn{constructor(e=new j(1/0,1/0,1/0),t=new j(-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(Oi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Oi.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=Oi.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,a=r.count;s<a;s++){if(e.isMesh===!0)e.getVertexPosition(s,Oi);else Oi.fromBufferAttribute(r,s);Oi.applyMatrix4(e.matrixWorld),this.expandByPoint(Oi)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Eu.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Eu.copy(n.boundingBox)}Eu.applyMatrix4(e.matrixWorld),this.union(Eu)}}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,Oi),Oi.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(Ac),Tu.subVectors(this.max,Ac),io.subVectors(e.a,Ac),ro.subVectors(e.b,Ac),so.subVectors(e.c,Ac),is.subVectors(ro,io),rs.subVectors(so,ro),ca.subVectors(io,so);let t=[0,-is.z,is.y,0,-rs.z,rs.y,0,-ca.z,ca.y,is.z,0,-is.x,rs.z,0,-rs.x,ca.z,0,-ca.x,-is.y,is.x,0,-rs.y,rs.x,0,-ca.y,ca.x,0];if(!ip(t,io,ro,so,Tu))return!1;if(t=[1,0,0,0,1,0,0,0,1],!ip(t,io,ro,so,Tu))return!1;return Au.crossVectors(is,rs),t=[Au.x,Au.y,Au.z],ip(t,io,ro,so,Tu)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Oi).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Oi).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 Or[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Or[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Or[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Or[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Or[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Or[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Or[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Or[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Or),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}}function ip(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){la.fromArray(e,s);let o=r.x*Math.abs(la.x)+r.y*Math.abs(la.y)+r.z*Math.abs(la.z),c=t.dot(la),l=n.dot(la),u=i.dot(la);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}class oi{constructor(e=new j,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 uN.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;Sc.subVectors(e,this.center);let t=Sc.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Sc,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 rp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Sc.copy(e.center).add(rp)),this.expandByPoint(Sc.copy(e.center).sub(rp));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}}class Hc{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=Di()}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=Di();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=Di();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}}class So{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++)Vn.fromBufferAttribute(this,t),Vn.applyMatrix4(e),this.setXYZ(t,Vn.x,Vn.y,Vn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Vn.fromBufferAttribute(this,t),Vn.applyNormalMatrix(e),this.setXYZ(t,Vn.x,Vn.y,Vn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Vn.fromBufferAttribute(this,t),Vn.transformDirection(e),this.setXYZ(t,Vn.x,Vn.y,Vn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=ki(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Ct(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=Ct(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=ki(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=ki(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=ki(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=ki(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=Ct(t,this.array),n=Ct(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=Ct(t,this.array),n=Ct(n,this.array),i=Ct(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=Ct(t,this.array),n=Ct(n,this.array),i=Ct(i,this.array),r=Ct(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){Oc("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 vn(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 So(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Oc("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}}}}class bi{constructor(e=new j(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=ap.subVectors(n,t).cross(fN.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(ap),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||hN.getNormalMatrix(e),i=this.coplanarPoint(ap).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}}class hs{constructor(e=new j,t=new j(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,kr)),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=kr.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return kr.copy(this.origin).addScaledVector(this.direction,t),kr.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){op.copy(e).add(t).multiplyScalar(0.5),wu.copy(t).sub(e).normalize(),Mu.copy(this.origin).sub(op);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(wu),a=Mu.dot(this.direction),o=-Mu.dot(wu),c=Mu.lengthSq(),l=Math.abs(1-s*s),u,d,f,h;if(l>0)if(u=s*o-a,d=s*a-o,h=r*l,u>=0)if(d>=-h)if(d<=h){let y=1/l;u*=y,d*=y,f=u*(u+s*d+2*a)+d*(s*u+d+2*o)+c}else d=r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else d=-r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else if(d<=-h)u=Math.max(0,-(-s*r+a)),d=u>0?-r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else if(d<=h)u=0,d=Math.min(Math.max(-r,-o),r),f=d*(d+2*o)+c;else u=Math.max(0,-(s*r+a)),d=u>0?r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(op).addScaledVector(wu,d);return f}intersectSphere(e,t){if(e.radius<0)return null;kr.subVectors(e.center,this.origin);let n=kr.dot(this.direction),i=kr.dot(kr)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),a=n-s,o=n+s;if(o<0)return null;if(a<0)return this.at(o,t);return this.at(a,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,a,o,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.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)a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,kr)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,a=this.direction,{x:o,y:c,z:l}=a,u=e.x-s.x,d=e.y-s.y,f=e.z-s.z,h=t.x-s.x,y=t.y-s.y,g=t.z-s.z,m=n.x-s.x,p=n.y-s.y,b=n.z-s.z,_=Math.abs(o),x=Math.abs(c),v=Math.abs(l),E,S,T,A,P,w,I,F,N,U,D,O;if(_>=x&&_>=v)if(T=o,w=u,N=h,O=m,o>=0)E=c,S=l,A=d,P=f,I=y,F=g,U=p,D=b;else E=l,S=c,A=f,P=d,I=g,F=y,U=b,D=p;else if(x>=v)if(T=c,w=d,N=y,O=p,c>=0)E=l,S=o,A=f,P=u,I=g,F=h,U=b,D=m;else E=o,S=l,A=u,P=f,I=h,F=g,U=m,D=b;else if(T=l,w=f,N=g,O=b,l>=0)E=o,S=c,A=u,P=d,I=h,F=y,U=m,D=p;else E=c,S=o,A=d,P=u,I=y,F=h,U=p,D=m;if(T===0)return null;let K=E/T,B=S/T,X=1/T,q=A-K*w,le=P-B*w,de=I-K*N,Me=F-B*N,pe=U-K*O,J=D-B*O,L=pe*Me-J*de,W=q*J-le*pe,te=de*le-Me*q;if(i){if(L<0||W<0||te<0)return null}else if((L<0||W<0||te<0)&&(L>0||W>0||te>0))return null;let ie=L+W+te;if(ie===0)return null;let ce=X*(L*w+W*N+te*O);if(ie>0?ce<0:ce>0)return null;return this.at(ce/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)}}function mN(e,t,n,i,r,s,a,o){let c;if(t.side===1)c=i.intersectTriangle(a,s,r,!0,o);else c=i.intersectTriangle(r,s,a,t.side===0,o);if(c===null)return null;Ou.copy(o),Ou.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ou);if(l<n.near||l>n.far)return null;return{distance:l,point:Ou.clone(),object:e}}function ku(e,t,n,i,r,s,a,o,c,l){e.getVertexPosition(o,Iu),e.getVertexPosition(c,Cu),e.getVertexPosition(l,Nu);let u=mN(e,t,n,i,Iu,Cu,Nu,aE);if(u){let d=new j;if(yi.getBarycoord(aE,Iu,Cu,Nu,d),r)u.uv=yi.getInterpolatedAttribute(r,o,c,l,d,new Ke);if(s)u.uv1=yi.getInterpolatedAttribute(s,o,c,l,d,new Ke);if(a){if(u.normal=yi.getInterpolatedAttribute(a,o,c,l,d,new j),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let f={a:o,b:c,c:l,normal:new j,materialIndex:0};yi.getNormal(Iu,Cu,Nu,f.normal),u.face=f,u.barycoord=d}return u}class Kc{constructor(e=[],t=[]){this.uuid=Di(),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){je("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 Qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Qe;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 a=e[r]?e[r].matrixWorld:bN;dE.multiplyMatrices(a,t[r]),dE.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Kc(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 $c(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)je("Skeleton: No bone found with UUID:",r),s=new Gc;this.bones.push(s),this.boneInverses.push(new Qe().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 a=n[i];e.boneInverses.push(a.toArray())}return e}}class Wc{constructor(e=new bi,t=new bi,n=new bi,i=new bi,r=new bi,s=new bi){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[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],a=r[1],o=r[2],c=r[3],l=r[4],u=r[5],d=r[6],f=r[7],h=r[8],y=r[9],g=r[10],m=r[11],p=r[12],b=r[13],_=r[14],x=r[15];if(i[0].setComponents(c-s,f-l,m-h,x-p).normalize(),i[1].setComponents(c+s,f+l,m+h,x+p).normalize(),i[2].setComponents(c+a,f+u,m+y,x+b).normalize(),i[3].setComponents(c-a,f-u,m-y,x-b).normalize(),n)i[4].setComponents(o,d,g,_).normalize(),i[5].setComponents(c-o,f-d,m-g,x-_).normalize();else if(i[4].setComponents(c-o,f-d,m-g,x-_).normalize(),t===2000)i[5].setComponents(c+o,f+d,m+g,x+_).normalize();else if(t===2001)i[5].setComponents(o,d,g,_).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();da.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();da.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(da)}intersectsSprite(e){da.center.set(0,0,0);let t=xN.distanceTo(e.center);return da.radius=0.7071067811865476+t,da.applyMatrix4(e.matrixWorld),this.intersectsSphere(da)}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(Fu.x=i.normal.x>0?e.max.x:e.min.x,Fu.y=i.normal.y>0?e.max.y:e.min.y,Fu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Fu)<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)}}function Bu(e,t,n,i,r,s,a){let o=e.geometry.attributes.position;if($u.fromBufferAttribute(o,r),Ku.fromBufferAttribute(o,s),n.distanceSqToSegment($u,Ku,dp,mE)>i)return;dp.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(dp);if(l<t.near||l>t.far)return;return{distance:l,point:mE.clone().applyMatrix4(e.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:e}}function xE(e,t,n,i,r,s,a){let o=pp.distanceSqToPoint(e);if(o<n){let c=new j;pp.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(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}function va(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(_E(r))if(r.isRenderTargetTexture)je("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(_E(r[0])){let s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function kn(e){let t={};for(let n=0;n<e.length;n++){let i=va(e[n]);for(let r in i)t[r]=i[r]}return t}function _E(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function _N(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function xm(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return ot.workingColorSpace}function as(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 Gu(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function TN(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 vE(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){let o=n[s]*t;for(let c=0;c!==t;++c)r[a++]=e[o+c]}return r}function AN(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 a=s[i];if(a===void 0)return;if(Array.isArray(a))do{if(a=s[i],a!==void 0)t.push(s.time),n.push(...a);s=e[r++]}while(s!==void 0);else if(a.toArray!==void 0)do{if(a=s[i],a!==void 0)t.push(s.time),a.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(a=s[i],a!==void 0)t.push(s.time),n.push(a);s=e[r++]}while(s!==void 0)}class Br{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 a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let a=t[1];if(e<a)n=2,r=a;for(let o=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let a=n+s>>>1;if(e<t[a])s=a;else n=a+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_(){}}function RT(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 SN(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 wN(e,t,n,i,r){let s=(e-t)/(r-t);for(let a=0;a<8;a++){let o=RT(s,t,n,i,r)-e;if(Math.abs(o)<0.0000000001)break;let c=SN(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-o/c))}return s}class li{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=as(t,this.TimeBufferType),this.values=as(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:as(e.times,Array),values:as(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Gu(e.settings))n.settings={inTangents:as(e.settings.inTangents,Array),outTangents:as(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Am(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new gd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Tm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Sm(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 je("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(Gu(this.settings))EE(this.settings.inTangents,e),EE(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 a=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*a,s*a)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ze("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ze("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let a=0;a!==r;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ze("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(s!==null&&s>o){Ze("KeyframeTrack: Out of order keys.",this,a,o,s),e=!1;break}s=o}if(i!==void 0){if(LC(i))for(let a=0,o=i.length;a!==o;++a){let c=i[a];if(isNaN(c)){Ze("KeyframeTrack: Value is not a valid number.",this,a,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 a=1;a<r;++a){let o=!1,c=e[a],l=e[a+1];if(c!==l&&(a!==1||c!==e[0]))if(!i){let u=a*n,d=u-n,f=u+n;for(let h=0;h!==n;++h){let y=t[u+h];if(y!==t[d+h]||y!==t[f+h]){o=!0;break}}}else o=!0;if(o){if(a!==s){e[s]=e[a];let u=a*n,d=s*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++s}}if(r>0){e[s]=e[r];for(let a=r*n,o=s*n,c=0;c!==n;++c)t[o+c]=t[a+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,Gu(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function EE(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}class mo{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Di(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,a=n.length;s!==a;++s)t.push(RN(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(li.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let a=0;a<r;a++){let o=[],c=[];o.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);let l=TN(o);if(o=vE(o,1,l),c=vE(c,1,l),!i&&o[0]===0)o.push(r),c.push(c[0]);s.push(new bs(".morphTargetInfluences["+t[a].name+"]",o,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 a=0,o=e.length;a<o;a++){let c=e[a],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let a in i)s.push(this.CreateFromMorphTargetSequence(a,i[a],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 MN(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return bs;case"vector":case"vector2":case"vector3":case"vector4":return Ea;case"color":return bd;case"quaternion":return ys;case"bool":case"boolean":return gs;case"string":return xs}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function RN(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=MN(e.type);if(e.times===void 0){let i=[],r=[];AN(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(Gu(e.settings))n.settings={inTangents:as(e.settings.inTangents,Float32Array),outTangents:as(e.settings.outTangents,Float32Array)};return n}function TE(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Zc{constructor(e,t,n){let i=this,r=!1,s=0,a=0,o=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(a++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,a)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,a);if(s===a){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"),o)return o(l);return l},this.setURLModifier=function(l){return o=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,d=c.length;u<d;u+=2){let f=c[u],h=c[u+1];if(f.global)f.lastIndex=0;if(f.test(l))return h}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}}class zr{constructor(e){if(this.manager=e!==void 0?e:IT,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}}class Qc{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 Qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wc,this._frameExtents=new Ke(1,1),this._viewportCount=1,this._viewports=[new Nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;AE.setFromMatrixPosition(e.matrixWorld),t.position.copy(AE),SE.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(SE),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){fp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(fp,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,a=i?i.w/r.y:1,o=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+o,0,0.5*a,0,0.5*a+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,0.5,0.5,0,0,0,1);t.multiply(fp)}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}}class _s{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}}class Cm{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 a=0;a!==i;++a)n[r+a]=n[a];s=t}else{s+=t;let a=t/s;this._mixBufferRegion(n,r,0,a,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,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let o=t*this._origIndex;this._mixBufferRegion(n,i,o,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,c=t+t;o!==c;++o)if(n[o]!==n[o+t]){a.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){ln.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;ln.multiplyQuaternionsFlat(e,s,e,t,e,n),ln.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let a=0;a!==r;++a){let o=t+a;e[o]=e[o]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let a=t+s;e[a]=e[a]+e[n+s]*i}}}class kT{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(IN,"")}static parseTrackName(e){let t=DN.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(LN.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 a=r[s];if(a.name===t||a.uuid===t)return a;let o=n(a.children);if(o)return o}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){je("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ze("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){Ze("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){Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ze("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){Ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ze("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;Ze("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ze("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]}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))o=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}class Om{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,a=Array(s),o={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);a[c]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,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,a=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(a,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,a=this._timeScaleInterpolant;if(a===null)a=i._lendControlInterpolant(),this._timeScaleInterpolant=a;let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,o[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 o=(e-r)*n;if(o<0||n===0)t=0;else this._startTime=null,t=n*o}t*=this._updateTimeScale(e);let s=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulateAdditive(a);break;case 2500:default:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulate(i,a)}}}_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 a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);let o=this.repetitions-r;if(o<=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(o===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:a})}}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 a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}class el{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=ct(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(ct(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}function Dm(e,t,n,i){let r=UN(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 UN(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}.`)}var RE="186",cs,ls,IE=0,mp=1,CE=2,kc=1,NE=2,go=3,us=0,Pn=1,xi=2,lr=0,Dc=1,gp=2,bp=3,yp=4,PE=5,bo=100,OE=101,kE=102,DE=103,LE=104,FE=200,UE=201,BE=202,zE=203,VE=204,jE=205,HE=206,GE=207,$E=208,KE=209,WE=210,XE=211,qE=212,JE=213,ZE=214,YE=0,QE=1,eT=2,xp=3,tT=4,nT=5,iT=6,rT=7,sT=0,aT=1,oT=2,Li=0,_p=1,vp=2,Ep=3,Lc=4,Tp=5,Ap=6,Sp=7,yo=301,pa=302,Wu=303,Xu=304,Fc=306,xo=1000,_o=1001,qu=1002,Fi=1003,Ju=1004,ma=1005,En=1006,vo=1007,ur=1008,Ui=1009,cT=1010,lT=1011,Uc=1012,wp=1013,ds=1014,Fr=1015,dr=1016,Mp=1017,Rp=1018,Eo=1020,uT=35902,dT=35899,fT=1021,hT=1022,fr=1023,ga=1026,ba=1027,pT=1028,Ip=1029,ya=1030,Cp=1031,Np=1033,Zu=33776,Yu=33777,Qu=33778,ed=33779,Pp=35840,Op=35841,kp=35842,Dp=35843,Lp=36196,Fp=37492,Up=37496,Bp=37488,zp=37489,td=37490,Vp=37491,jp=37808,Hp=37809,Gp=37810,$p=37811,Kp=37812,Wp=37813,Xp=37814,qp=37815,Jp=37816,Zp=37817,Yp=37818,Qp=37819,em=37820,tm=37821,nm=36492,im=36494,rm=36495,sm=36283,am=36284,nd=36285,om=36286,cm=2300,id=2301,lm=0,Bc=1,To=2,um=0,mT=1,xa="",fs="srgb",si="srgb-linear",dm="linear",Bt="srgb",gT=512,bT=513,yT=514,rd=515,xT=516,_T=517,sd=518,vT=519,fm="300 es",hm=2000,$v,po=null,ST,Cn,Kv=1234567,Nc,ha,zc,Ke,ln,j,Gh,Wv,tt,$h,Xv,qv,ot,Za,eN=0,tN=0,Wh,Qt,Nt,gm,ai,ad,bm,Qe,Ya,Ni,nN,iN,ts,xu,ii,Jv,Zv,cr,rN=0,Yv,Qa,Cr,_u,Tc,sN,aN,Qv,eE,tE,nE,oN,eo,Xh,kt,ar,cN,wT,ns,vu,qe,Nn,Ao,Pi,Nr,Jh,Pr,to,no,iE,Zh,Yh,Qh,ep,tp,np,Or,Oi,Eu,io,ro,so,is,rs,ca,Ac,Tu,Au,la,cn,Su,lN=0,vn,cd,ld,Gn,uN,Sc,rp,dN=0,gi,sp,ao,ri,wc,_n,On,Vn,ap,fN,hN,pN=0,$n,kr,op,wu,Mu,hr,rE,ua,Ru,sE,Iu,Cu,Nu,cp,Pu,aE,Ou,jt,Mc,oE,cE,gN,lE,Du,lp,uE,up,ud,Gc,$c,dE,bN,os,oo,fE,Lu,hE,yN,Rc,Ic,wo,da,xN,Fu,Xc,$u,Ku,pE,Cc,Uu,dp,mE,ps,gE,bE,dd,fd,qc,yE,pp,zu,Vu,Mo,hd,_a,ym,pd,ms,Jc,MT,vN=`void main() {
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+}`,EN=`void main() {
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
+}`,_i,_m,Ur,ci,md,vm,Em,Tm,gd,Am,Sm,gs,bd,bs,wm,ys,xs,Ea,or,IT,Dr,CT,Yc,co,Mm,Ro,Io,yd,fp,AE,SE,ju,Hu,sr,xd,ss,wE,ME,fn,NT,_d,PT,Co,Ta,OT,No,hp,vd,lo=-90,uo=1,Rm,Im,Nm="\\[\\]\\.:\\/",IN,Pm,CN,NN,PN,ON,kN,DN,LN,FN,Ed,km,Td;var Lm=Ft(()=>{cs={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ls={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};$v={};ST={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};Cn=["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"],Nc=Math.PI/180,ha=180/Math.PI;zc={DEG2RAD:Nc,RAD2DEG:ha,generateUUID:Di,clamp:ct,euclideanModulo:pm,mapLinear:FC,inverseLerp:UC,lerp:Pc,damp:BC,pingpong:zC,smoothstep:VC,smootherstep:jC,randInt:HC,randFloat:GC,randFloatSpread:$C,seededRandom:KC,degToRad:WC,radToDeg:XC,isPowerOfTwo:qC,ceilPowerOfTwo:JC,floorPowerOfTwo:ZC,setQuaternionFromProperEuler:YC,normalize:Ct,denormalize:ki};Ke=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=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(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(ct(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}};ln=class ln{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,a){let o=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],f=r[s+1],h=r[s+2],y=r[s+3];if(u!==y||o!==d||c!==f||l!==h){let g=o*d+c*f+l*h+u*y;if(g<0)d=-d,f=-f,h=-h,y=-y,g=-g;let m=1-a;if(g<0.9995){let p=Math.acos(g),b=Math.sin(p);m=Math.sin(m*p)/b,a=Math.sin(a*p)/b,o=o*m+d*a,c=c*m+f*a,l=l*m+h*a,u=u*m+y*a}else{o=o*m+d*a,c=c*m+f*a,l=l*m+h*a,u=u*m+y*a;let p=1/Math.sqrt(o*o+c*c+l*l+u*u);o*=p,c*=p,l*=p,u*=p}}e[t]=o,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let a=n[i],o=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],f=r[s+2],h=r[s+3];return e[t]=a*h+l*u+o*f-c*d,e[t+1]=o*h+l*d+c*u-a*f,e[t+2]=c*h+l*f+a*d-o*u,e[t+3]=l*h-a*u-o*d-c*f,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:a,sin:o}=Math,c=a(n/2),l=a(i/2),u=a(r/2),d=o(n/2),f=o(i/2),h=o(r/2);switch(s){case"XYZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"YXZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"ZXY":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"ZYX":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"YZX":this._x=d*l*u+c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u-d*f*h;break;case"XZY":this._x=d*l*u-c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u+d*f*h;break;default:je("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],a=t[5],o=t[9],c=t[2],l=t[6],u=t[10],d=n+a+u;if(d>0){let f=0.5/Math.sqrt(d+1);this._w=0.25/f,this._x=(l-o)*f,this._y=(r-c)*f,this._z=(s-i)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(l-o)/f,this._x=0.25*f,this._y=(i+s)/f,this._z=(r+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(r-c)/f,this._x=(i+s)/f,this._y=0.25*f,this._z=(o+l)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(s-i)/f,this._x=(r+c)/f,this._y=(o+l)/f,this._z=0.25*f}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(ct(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:a,_y:o,_z:c,_w:l}=t;return this._x=n*l+s*a+i*c-r*o,this._y=i*l+s*o+r*a-n*c,this._z=r*l+s*c+n*o-i*a,this._w=s*l-n*a-i*o-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,a=this.dot(e);if(a<0)n=-n,i=-i,r=-r,s=-s,a=-a;let o=1-t;if(a<0.9995){let c=Math.acos(a),l=Math.sin(c);o=Math.sin(o*c)/l,t=Math.sin(t*c)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+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}};j=class j{static{j.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(Wv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wv.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:a,w:o}=e,c=2*(s*i-a*n),l=2*(a*t-r*i),u=2*(r*n-s*t);return this.x=t+o*c+s*u-a*l,this.y=n+o*l+a*c-r*u,this.z=i+o*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=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(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:a,z:o}=t;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-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 Gh.copy(this).projectOnVector(e),this.sub(Gh)}reflect(e){return this.sub(Gh.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(ct(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}};Gh=new j,Wv=new ln;tt=class tt{static{tt.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,a,o,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c)}set(e,t,n,i,r,s,a,o,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=a,l[3]=t,l[4]=r,l[5]=o,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],a=n[3],o=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],h=n[8],y=i[0],g=i[3],m=i[6],p=i[1],b=i[4],_=i[7],x=i[2],v=i[5],E=i[8];return r[0]=s*y+a*p+o*x,r[3]=s*g+a*b+o*v,r[6]=s*m+a*_+o*E,r[1]=c*y+l*p+u*x,r[4]=c*g+l*b+u*v,r[7]=c*m+l*_+u*E,r[2]=d*y+f*p+h*x,r[5]=d*g+f*b+h*v,r[8]=d*m+f*_+h*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],a=e[5],o=e[6],c=e[7],l=e[8];return t*s*l-t*a*c-n*r*l+n*a*o+i*r*c-i*s*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=l*s-a*c,d=a*o-l*r,f=c*r-s*o,h=t*u+n*d+i*f;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/h;return e[0]=u*y,e[1]=(i*c-l*n)*y,e[2]=(a*n-i*s)*y,e[3]=d*y,e[4]=(l*t-i*o)*y,e[5]=(i*r-a*t)*y,e[6]=f*y,e[7]=(n*o-c*t)*y,e[8]=(s*t-n*r)*y,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,a){let o=Math.cos(r),c=Math.sin(r);return this.set(n*o,n*c,-n*(o*s+c*a)+s+e,-i*c,i*o,-i*(-c*s+o*a)+a+t,0,0,1),this}scale(e,t){return fa("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply($h.makeScale(e,t)),this}rotate(e){return fa("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply($h.makeRotation(-e)),this}translate(e,t){return fa("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply($h.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)}};$h=new tt,Xv=new tt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),qv=new tt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);ot=QC();Wh=new j;Qt=class Qt extends Bi{constructor(e=Qt.DEFAULT_IMAGE,t=Qt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,c=Qt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:tN++}),this.uuid=Di(),this.name="",this.source=new Vc(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=a,this.internalFormat=null,this.type=o,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 tt,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(Wh).x}get height(){return this.source.getSize(Wh).y}get depth(){return this.source.getSize(Wh).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){je(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`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++}};Qt.DEFAULT_IMAGE=null;Qt.DEFAULT_MAPPING=300;Qt.DEFAULT_ANISOTROPY=1;Nt=class Nt{static{Nt.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,a=0.1,o=e.elements,c=o[0],l=o[4],u=o[8],d=o[1],f=o[5],h=o[9],y=o[2],g=o[6],m=o[10];if(Math.abs(l-d)<0.01&&Math.abs(u-y)<0.01&&Math.abs(h-g)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+y)<0.1&&Math.abs(h+g)<0.1&&Math.abs(c+f+m-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let b=(c+1)/2,_=(f+1)/2,x=(m+1)/2,v=(l+d)/4,E=(u+y)/4,S=(h+g)/4;if(b>_&&b>x)if(b<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(b),i=v/n,r=E/n;else if(_>x)if(_<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(_),n=v/i,r=S/i;else if(x<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(x),n=E/r,i=S/r;return this.set(n,i,r,t),this}let p=Math.sqrt((g-h)*(g-h)+(u-y)*(u-y)+(d-l)*(d-l));if(Math.abs(p)<0.001)p=1;return this.x=(g-h)/p,this.y=(u-y)/p,this.z=(d-l)/p,this.w=Math.acos((c+f+m-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=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this.w=ct(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this.w=ct(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(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}};gm=class gm extends Bi{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 Nt(0,0,e,t),this.scissorTest=!1,this.viewport=new Nt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Qt(i),s=n.count;for(let a=0;a<s;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].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 Vc(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"})}};ai=class ai extends gm{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}};ad=class ad extends Qt{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()}};bm=class bm extends Qt{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}};Qe=class Qe{static{Qe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,a,o,c,l,u,d,f,h,y,g){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,a,o,c,l,u,d,f,h,y,g)}set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=s,m[9]=a,m[13]=o,m[2]=c,m[6]=l,m[10]=u,m[14]=d,m[3]=f,m[7]=h,m[11]=y,m[15]=g,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 Qe().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/Ya.setFromMatrixColumn(e,0).length(),r=1/Ya.setFromMatrixColumn(e,1).length(),s=1/Ya.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),a=Math.sin(n),o=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,f=s*u,h=a*l,y=a*u;t[0]=o*l,t[4]=-o*u,t[8]=c,t[1]=f+h*c,t[5]=d-y*c,t[9]=-a*o,t[2]=y-d*c,t[6]=h+f*c,t[10]=s*o}else if(e.order==="YXZ"){let d=o*l,f=o*u,h=c*l,y=c*u;t[0]=d+y*a,t[4]=h*a-f,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-a,t[2]=f*a-h,t[6]=y+d*a,t[10]=s*o}else if(e.order==="ZXY"){let d=o*l,f=o*u,h=c*l,y=c*u;t[0]=d-y*a,t[4]=-s*u,t[8]=h+f*a,t[1]=f+h*a,t[5]=s*l,t[9]=y-d*a,t[2]=-s*c,t[6]=a,t[10]=s*o}else if(e.order==="ZYX"){let d=s*l,f=s*u,h=a*l,y=a*u;t[0]=o*l,t[4]=h*c-f,t[8]=d*c+y,t[1]=o*u,t[5]=y*c+d,t[9]=f*c-h,t[2]=-c,t[6]=a*o,t[10]=s*o}else if(e.order==="YZX"){let d=s*o,f=s*c,h=a*o,y=a*c;t[0]=o*l,t[4]=y-d*u,t[8]=h*u+f,t[1]=u,t[5]=s*l,t[9]=-a*l,t[2]=-c*l,t[6]=f*u+h,t[10]=d-y*u}else if(e.order==="XZY"){let d=s*o,f=s*c,h=a*o,y=a*c;t[0]=o*l,t[4]=-u,t[8]=c*l,t[1]=d*u+y,t[5]=s*l,t[9]=f*u-h,t[2]=h*u-f,t[6]=a*l,t[10]=y*u+d}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(nN,e,iN)}lookAt(e,t,n){let i=this.elements;if(ii.subVectors(e,t),ii.lengthSq()===0)ii.z=1;if(ii.normalize(),ts.crossVectors(n,ii),ts.lengthSq()===0){if(Math.abs(n.z)===1)ii.x+=0.0001;else ii.z+=0.0001;ii.normalize(),ts.crossVectors(n,ii)}return ts.normalize(),xu.crossVectors(ii,ts),i[0]=ts.x,i[4]=xu.x,i[8]=ii.x,i[1]=ts.y,i[5]=xu.y,i[9]=ii.y,i[2]=ts.z,i[6]=xu.z,i[10]=ii.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],a=n[4],o=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],h=n[2],y=n[6],g=n[10],m=n[14],p=n[3],b=n[7],_=n[11],x=n[15],v=i[0],E=i[4],S=i[8],T=i[12],A=i[1],P=i[5],w=i[9],I=i[13],F=i[2],N=i[6],U=i[10],D=i[14],O=i[3],K=i[7],B=i[11],X=i[15];return r[0]=s*v+a*A+o*F+c*O,r[4]=s*E+a*P+o*N+c*K,r[8]=s*S+a*w+o*U+c*B,r[12]=s*T+a*I+o*D+c*X,r[1]=l*v+u*A+d*F+f*O,r[5]=l*E+u*P+d*N+f*K,r[9]=l*S+u*w+d*U+f*B,r[13]=l*T+u*I+d*D+f*X,r[2]=h*v+y*A+g*F+m*O,r[6]=h*E+y*P+g*N+m*K,r[10]=h*S+y*w+g*U+m*B,r[14]=h*T+y*I+g*D+m*X,r[3]=p*v+b*A+_*F+x*O,r[7]=p*E+b*P+_*N+x*K,r[11]=p*S+b*w+_*U+x*B,r[15]=p*T+b*I+_*D+x*X,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],a=e[5],o=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],h=e[3],y=e[7],g=e[11],m=e[15],p=o*f-c*d,b=a*f-c*u,_=a*d-o*u,x=s*f-c*l,v=s*d-o*l,E=s*u-a*l;return t*(y*p-g*b+m*_)-n*(h*p-g*x+m*v)+i*(h*b-y*x+m*E)-r*(h*_-y*v+g*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],a=e[9],o=e[2],c=e[6],l=e[10];return t*(s*l-a*c)-n*(r*l-a*o)+i*(r*c-s*o)}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],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],y=e[13],g=e[14],m=e[15],p=t*a-n*s,b=t*o-i*s,_=t*c-r*s,x=n*o-i*a,v=n*c-r*a,E=i*c-r*o,S=l*y-u*h,T=l*g-d*h,A=l*m-f*h,P=u*g-d*y,w=u*m-f*y,I=d*m-f*g,F=p*I-b*w+_*P+x*A-v*T+E*S;if(F===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/F;return e[0]=(a*I-o*w+c*P)*N,e[1]=(i*w-n*I-r*P)*N,e[2]=(y*E-g*v+m*x)*N,e[3]=(d*v-u*E-f*x)*N,e[4]=(o*A-s*I-c*T)*N,e[5]=(t*I-i*A+r*T)*N,e[6]=(g*_-h*E-m*b)*N,e[7]=(l*E-d*_+f*b)*N,e[8]=(s*w-a*A+c*S)*N,e[9]=(n*A-t*w-r*S)*N,e[10]=(h*v-y*_+m*p)*N,e[11]=(u*_-l*v-f*p)*N,e[12]=(a*T-s*P-o*S)*N,e[13]=(t*P-n*T+i*S)*N,e[14]=(y*b-h*x-g*p)*N,e[15]=(l*x-u*b+d*p)*N,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:a,z:o}=e,c=r*s,l=r*a;return this.set(c*s+n,c*a-i*o,c*o+i*a,0,c*a+i*o,l*a+n,l*o-i*s,0,c*o-i*a,l*o+i*s,r*o*o+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:a,_w:o}=t,c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,y=s*l,g=s*u,m=a*u,p=o*c,b=o*l,_=o*u,{x,y:v,z:E}=n;return i[0]=(1-(y+m))*x,i[1]=(f+_)*x,i[2]=(h-b)*x,i[3]=0,i[4]=(f-_)*v,i[5]=(1-(d+m))*v,i[6]=(g+p)*v,i[7]=0,i[8]=(h+b)*E,i[9]=(g-p)*E,i[10]=(1-(d+y))*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=Ya.set(i[0],i[1],i[2]).length(),a=Ya.set(i[4],i[5],i[6]).length(),o=Ya.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Ni.copy(this);let c=1/s,l=1/a,u=1/o;return Ni.elements[0]*=c,Ni.elements[1]*=c,Ni.elements[2]*=c,Ni.elements[4]*=l,Ni.elements[5]*=l,Ni.elements[6]*=l,Ni.elements[8]*=u,Ni.elements[9]*=u,Ni.elements[10]*=u,t.setFromRotationMatrix(Ni),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i),h,y;if(o)h=r/(s-r),y=s*r/(s-r);else if(a===2000)h=-(s+r)/(s-r),y=-2*s*r/(s-r);else if(a===2001)h=-s/(s-r),y=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=h,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i),h,y;if(o)h=1/(s-r),y=s/(s-r);else if(a===2000)h=-2/(s-r),y=-(s+r)/(s-r);else if(a===2001)h=-1/(s-r),y=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=h,c[14]=y,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}};Ya=new j,Ni=new Qe,nN=new j(0,0,0),iN=new j(1,1,1),ts=new j,xu=new j,ii=new j,Jv=new Qe,Zv=new ln;cr=class cr{constructor(e=0,t=0,n=0,i=cr.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],a=i[8],o=i[1],c=i[5],l=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":if(this._y=Math.asin(ct(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,f),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-ct(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(a,f),this._z=Math.atan2(o,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(ct(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,f),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(o,r);break;case"ZYX":if(this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,f),this._z=Math.atan2(o,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(ct(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(a,f);break;case"XZY":if(this._z=Math.asin(-ct(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(a,r);else this._x=Math.atan2(-l,f),this._y=0;break;default:je("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Jv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Jv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zv.setFromEuler(this),this.setFromQuaternion(Zv,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}};cr.DEFAULT_ORDER="XYZ";Yv=new j,Qa=new ln,Cr=new Qe,_u=new j,Tc=new j,sN=new j,aN=new ln,Qv=new j(1,0,0),eE=new j(0,1,0),tE=new j(0,0,1),nE={type:"added"},oN={type:"removed"},eo={type:"childadded",child:null},Xh={type:"childremoved",child:null};kt=class kt extends Bi{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:rN++}),this.uuid=Di(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=kt.DEFAULT_UP.clone();let e=new j,t=new cr,n=new ln,i=new j(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 Qe},normalMatrix:{value:new tt}}),this.matrix=new Qe,this.matrixWorld=new Qe,this.matrixAutoUpdate=kt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new od,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 Qa.setFromAxisAngle(e,t),this.quaternion.multiply(Qa),this}rotateOnWorldAxis(e,t){return Qa.setFromAxisAngle(e,t),this.quaternion.premultiply(Qa),this}rotateX(e){return this.rotateOnAxis(Qv,e)}rotateY(e){return this.rotateOnAxis(eE,e)}rotateZ(e){return this.rotateOnAxis(tE,e)}translateOnAxis(e,t){return Yv.copy(e).applyQuaternion(this.quaternion),this.position.add(Yv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Qv,e)}translateY(e){return this.translateOnAxis(eE,e)}translateZ(e){return this.translateOnAxis(tE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Cr.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)_u.copy(e);else _u.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Tc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Cr.lookAt(Tc,_u,this.up);else Cr.lookAt(_u,Tc,this.up);if(this.quaternion.setFromRotationMatrix(Cr),i)Cr.extractRotation(i.matrixWorld),Qa.setFromRotationMatrix(Cr),this.quaternion.premultiply(Qa.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 Ze("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(nE),eo.child=e,this.dispatchEvent(eo),eo.child=null;else Ze("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(oN),Xh.child=e,this.dispatchEvent(Xh),Xh.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),Cr.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Cr.multiply(e.parent.matrixWorld);return e.applyMatrix4(Cr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(nE),eo.child=e,this.dispatchEvent(eo),eo.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(Tc,e,sN),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tc,aN,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,a=r.length;s<a;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((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),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(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(e);return o.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 a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let c=0,l=o.length;c<l;c++){let u=o[c];r(e.shapes,u)}else r(e.shapes,o)}}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 a=[];for(let o=0,c=this.material.length;o<c;o++)a.push(r(e.materials,this.material[o]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(r(e.animations,o))}}if(t){let a=s(e.geometries),o=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),f=s(e.animations),h=s(e.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(f.length>0)n.animations=f;if(h.length>0)n.nodes=h}return n.object=i,n;function s(a){let o=[];for(let c in a){let l=a[c];delete l.metadata,o.push(l)}return o}}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"})}};kt.DEFAULT_UP=new j(0,1,0);kt.DEFAULT_MATRIX_AUTO_UPDATE=!0;kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;ar=class ar extends kt{constructor(){super();this.isGroup=!0,this.type="Group"}};cN={type:"move"};wT={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},ns={h:0,s:0,l:0},vu={h:0,s:0,l:0};qe=class qe{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,ot.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=ot.workingColorSpace){return this.r=e,this.g=t,this.b=n,ot.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=ot.workingColorSpace){if(e=pm(e,1),t=ct(t,0,1),n=ct(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=qh(s,r,e+0.3333333333333333),this.g=qh(s,r,e),this.b=qh(s,r,e-0.3333333333333333)}return ot.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)je("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:je("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 je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=wT[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else je("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=Lr(e.r),this.g=Lr(e.g),this.b=Lr(e.b),this}copyLinearToSRGB(e){return this.r=fo(e.r),this.g=fo(e.g),this.b=fo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return ot.workingToColorSpace(Nn.copy(this),e),Math.round(ct(Nn.r*255,0,255))*65536+Math.round(ct(Nn.g*255,0,255))*256+Math.round(ct(Nn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ot.workingColorSpace){ot.workingToColorSpace(Nn.copy(this),t);let{r:n,g:i,b:r}=Nn,s=Math.max(n,i,r),a=Math.min(n,i,r),o,c,l=(a+s)/2;if(a===s)o=0,c=0;else{let u=s-a;switch(c=l<=0.5?u/(s+a):u/(2-s-a),s){case n:o=(i-r)/u+(i<r?6:0);break;case i:o=(r-n)/u+2;break;case r:o=(n-i)/u+4;break}o/=6}return e.h=o,e.s=c,e.l=l,e}getRGB(e,t=ot.workingColorSpace){return ot.workingToColorSpace(Nn.copy(this),t),e.r=Nn.r,e.g=Nn.g,e.b=Nn.b,e}getStyle(e="srgb"){ot.workingToColorSpace(Nn.copy(this),e);let{r:t,g:n,b:i}=Nn;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(ns),this.setHSL(ns.h+e,ns.s+t,ns.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(ns),e.getHSL(vu);let n=Pc(ns.h,vu.h,t),i=Pc(ns.s,vu.s,t),r=Pc(ns.l,vu.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}};Nn=new qe;qe.NAMES=wT;Ao=class Ao extends kt{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 cr,this.environmentIntensity=1,this.environmentRotation=new cr,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}};Pi=new j,Nr=new j,Jh=new j,Pr=new j,to=new j,no=new j,iE=new j,Zh=new j,Yh=new j,Qh=new j,ep=new Nt,tp=new Nt,np=new Nt;Or=[new j,new j,new j,new j,new j,new j,new j,new j],Oi=new j,Eu=new hn,io=new j,ro=new j,so=new j,is=new j,rs=new j,ca=new j,Ac=new j,Tu=new j,Au=new j,la=new j;cn=new j,Su=new Ke;vn=class vn extends Bi{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:lN++}),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++)Su.fromBufferAttribute(this,t),Su.applyMatrix3(e),this.setXY(t,Su.x,Su.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.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=ki(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Ct(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=ki(t,this.array);return t}setX(e,t){if(this.normalized)t=Ct(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=ki(t,this.array);return t}setY(e,t){if(this.normalized)t=Ct(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=ki(t,this.array);return t}setZ(e,t){if(this.normalized)t=Ct(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=ki(t,this.array);return t}setW(e,t){if(this.normalized)t=Ct(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=Ct(t,this.array),n=Ct(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=Ct(t,this.array),n=Ct(n,this.array),i=Ct(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=Ct(t,this.array),n=Ct(n,this.array),i=Ct(i,this.array),r=Ct(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"})}};cd=class cd extends vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}};ld=class ld extends vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}};Gn=class Gn extends vn{constructor(e,t,n){super(new Float32Array(e),t,n)}};uN=new hn,Sc=new j,rp=new j;gi=new Qe,sp=new kt,ao=new j,ri=new hn,wc=new hn,_n=new j;On=class On extends Bi{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:dN++}),this.uuid=Di(),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((DC(e))?ld:cd)(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 tt().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 gi.makeRotationFromQuaternion(e),this.applyMatrix4(gi),this}rotateX(e){return gi.makeRotationX(e),this.applyMatrix4(gi),this}rotateY(e){return gi.makeRotationY(e),this.applyMatrix4(gi),this}rotateZ(e){return gi.makeRotationZ(e),this.applyMatrix4(gi),this}translate(e,t,n){return gi.makeTranslation(e,t,n),this.applyMatrix4(gi),this}scale(e,t,n){return gi.makeScale(e,t,n),this.applyMatrix4(gi),this}lookAt(e){return sp.lookAt(e),sp.updateMatrix(),this.applyMatrix4(sp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ao).negate(),this.translate(ao.x,ao.y,ao.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 Gn(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)je("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 hn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(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(ri.setFromBufferAttribute(r),this.morphTargetsRelative)_n.addVectors(this.boundingBox.min,ri.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,ri.max),this.boundingBox.expandByPoint(_n);else this.boundingBox.expandByPoint(ri.min),this.boundingBox.expandByPoint(ri.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ze('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 oi;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){let n=this.boundingSphere.center;if(ri.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let a=t[r];if(wc.setFromBufferAttribute(a),this.morphTargetsRelative)_n.addVectors(ri.min,wc.min),ri.expandByPoint(_n),_n.addVectors(ri.max,wc.max),ri.expandByPoint(_n);else ri.expandByPoint(wc.min),ri.expandByPoint(wc.max)}ri.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)_n.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(_n));if(t)for(let r=0,s=t.length;r<s;r++){let a=t[r],o=this.morphTargetsRelative;for(let c=0,l=a.count;c<l;c++){if(_n.fromBufferAttribute(a,c),o)ao.fromBufferAttribute(e,c),_n.add(ao);i=Math.max(i,n.distanceToSquared(_n))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ze('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){Ze("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 vn(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let a=[],o=[];for(let S=0;S<n.count;S++)a[S]=new j,o[S]=new j;let c=new j,l=new j,u=new j,d=new Ke,f=new Ke,h=new Ke,y=new j,g=new j;function m(S,T,A){c.fromBufferAttribute(n,S),l.fromBufferAttribute(n,T),u.fromBufferAttribute(n,A),d.fromBufferAttribute(r,S),f.fromBufferAttribute(r,T),h.fromBufferAttribute(r,A),l.sub(c),u.sub(c),f.sub(d),h.sub(d);let P=1/(f.x*h.y-h.x*f.y);if(!isFinite(P))return;y.copy(l).multiplyScalar(h.y).addScaledVector(u,-f.y).multiplyScalar(P),g.copy(u).multiplyScalar(f.x).addScaledVector(l,-h.x).multiplyScalar(P),a[S].add(y),a[T].add(y),a[A].add(y),o[S].add(g),o[T].add(g),o[A].add(g)}let p=this.groups;if(p.length===0)p=[{start:0,count:e.count}];for(let S=0,T=p.length;S<T;++S){let A=p[S],{start:P,count:w}=A;for(let I=P,F=P+w;I<F;I+=3)m(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let b=new j,_=new j,x=new j,v=new j;function E(S){x.fromBufferAttribute(i,S),v.copy(x);let T=a[S];b.copy(T),b.sub(x.multiplyScalar(x.dot(T))).normalize(),_.crossVectors(v,T);let P=_.dot(o[S])<0?-1:1;s.setXYZW(S,b.x,b.y,b.z,P)}for(let S=0,T=p.length;S<T;++S){let A=p[S],{start:P,count:w}=A;for(let I=P,F=P+w;I<F;I+=3)E(e.getX(I+0)),E(e.getX(I+1)),E(e.getX(I+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 vn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new j,r=new j,s=new j,a=new j,o=new j,c=new j,l=new j,u=new j;if(e)for(let d=0,f=e.count;d<f;d+=3){let h=e.getX(d+0),y=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(t,h),r.fromBufferAttribute(t,y),s.fromBufferAttribute(t,g),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),a.fromBufferAttribute(n,h),o.fromBufferAttribute(n,y),c.fromBufferAttribute(n,g),a.add(l),o.add(l),c.add(l),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(y,o.x,o.y,o.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+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++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(a,o){let{array:c,itemSize:l,normalized:u}=a,d=new c.constructor(o.length*l),f=0,h=0;for(let y=0,g=o.length;y<g;y++){if(a.isInterleavedBufferAttribute)f=o[y]*a.data.stride+a.offset;else f=o[y]*l;for(let m=0;m<l;m++)d[h++]=c[f++]}return new vn(d,l,u)}if(this.index===null)return je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new On,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],c=e(o,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let o=[],c=r[a];for(let l=0,u=c.length;l<u;l++){let d=c[l],f=e(d,n);o.push(f)}t.morphAttributes[a]=o}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let a=0,o=s.length;a<o;a++){let c=s[a];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 o=this.parameters;for(let c in o)if(o[c]!==void 0)e[c]=o[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 o in n){let c=n[o];e.data.attributes[o]=c.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let c=this.morphAttributes[o],l=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];l.push(f.toJSON(e.data))}if(l.length>0)i[o]=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 a=this.boundingSphere;if(a!==null)e.data.boundingSphere=a.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 d=0,f=u.length;d<f;d++)l.push(u[d].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 a=e.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.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"})}};Vn=new j;ap=new j,fN=new j,hN=new tt;$n=class $n extends Bi{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:pN++}),this.uuid=Di(),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 qe(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){je(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`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 a in r){let o=r[a];delete o.metadata,s.push(o)}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 qe().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 bi().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++}};kr=new j,op=new j,wu=new j,Mu=new j;hr=class hr extends $n{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 cr,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}};rE=new Qe,ua=new hs,Ru=new oi,sE=new j,Iu=new j,Cu=new j,Nu=new j,cp=new j,Pu=new j,aE=new j,Ou=new j;jt=class jt extends kt{constructor(e=new On,t=new hr){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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(r&&a){Pu.set(0,0,0);for(let o=0,c=r.length;o<c;o++){let l=a[o],u=r[o];if(l===0)continue;if(cp.fromBufferAttribute(u,e),s)Pu.addScaledVector(cp,l);else Pu.addScaledVector(cp.sub(t),l)}t.add(Pu)}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(Ru.copy(n.boundingSphere),Ru.applyMatrix4(r),ua.copy(e.ray).recast(e.near),Ru.containsPoint(ua.origin)===!1){if(ua.intersectSphere(Ru,sE)===null)return;if(ua.origin.distanceToSquared(sE)>(e.far-e.near)**2)return}if(rE.copy(r).invert(),ua.copy(e.ray).applyMatrix4(rE),n.boundingBox!==null){if(ua.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,ua)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:f}=r;if(a!==null)if(Array.isArray(s))for(let h=0,y=d.length;h<y;h++){let g=d[h],m=s[g.materialIndex],p=Math.max(g.start,f.start),b=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let _=p,x=b;_<x;_+=3){let v=a.getX(_),E=a.getX(_+1),S=a.getX(_+2);if(i=ku(this,m,e,n,c,l,u,v,E,S),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=h,m=y;g<m;g+=3){let p=a.getX(g),b=a.getX(g+1),_=a.getX(g+2);if(i=ku(this,s,e,n,c,l,u,p,b,_),i)i.faceIndex=Math.floor(g/3),t.push(i)}}else if(o!==void 0)if(Array.isArray(s))for(let h=0,y=d.length;h<y;h++){let g=d[h],m=s[g.materialIndex],p=Math.max(g.start,f.start),b=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let _=p,x=b;_<x;_+=3){let v=_,E=_+1,S=_+2;if(i=ku(this,m,e,n,c,l,u,v,E,S),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),y=Math.min(o.count,f.start+f.count);for(let g=h,m=y;g<m;g+=3){let p=g,b=g+1,_=g+2;if(i=ku(this,s,e,n,c,l,u,p,b,_),i)i.faceIndex=Math.floor(g/3),t.push(i)}}}};Mc=new Nt,oE=new Nt,cE=new Nt,gN=new Nt,lE=new Qe,Du=new j,lp=new oi,uE=new Qe,up=new hs;ud=class ud extends jt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Qe,this.bindMatrixInverse=new Qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new hn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Du),this.boundingBox.expandByPoint(Du)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new oi;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Du),this.boundingSphere.expandByPoint(Du)}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(lp.copy(this.boundingSphere),lp.applyMatrix4(i),e.ray.intersectsSphere(lp)===!1)return;if(uE.copy(i).invert(),up.copy(e.ray).applyMatrix4(uE),this.boundingBox!==null){if(up.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,up)}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 Nt,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 je("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(oE.fromBufferAttribute(i.attributes.skinIndex,e),cE.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Mc.copy(t),t.set(0,0,0,0);else Mc.set(...t,1),t.set(0,0,0);Mc.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=cE.getComponent(r);if(s!==0){let a=oE.getComponent(r);lE.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(gN.copy(Mc).applyMatrix4(lE),s)}}if(t.isVector4)t.w=Mc.w;return t.applyMatrix4(this.bindMatrixInverse)}};Gc=class Gc extends kt{constructor(){super();this.isBone=!0,this.type="Bone"}};$c=class $c extends Qt{constructor(e=null,t=1,n=1,i,r,s,a,o,c=1003,l=1003,u,d){super(null,s,a,o,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};dE=new Qe,bN=new Qe;os=class os extends vn{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}};oo=new Qe,fE=new Qe,Lu=[],hE=new hn,yN=new Qe,Rc=new jt,Ic=new oi;wo=class wo extends jt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new os(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,yN)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new hn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,oo),hE.copy(e.boundingBox).applyMatrix4(oo),this.boundingBox.union(hE)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new oi;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,oo),Ic.copy(e.boundingSphere).applyMatrix4(oo),this.boundingSphere.union(Ic)}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 a=0;a<n.length;a++)n[a]=i[s+a]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Rc.geometry=this.geometry,Rc.material=this.material,Rc.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Ic.copy(this.boundingSphere),Ic.applyMatrix4(n),e.ray.intersectsSphere(Ic)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,oo),fE.multiplyMatrices(n,oo),Rc.matrixWorld=fE,Rc.raycast(e,Lu);for(let s=0,a=Lu.length;s<a;s++){let o=Lu[s];o.instanceId=r,o.object=this,t.push(o)}Lu.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new os(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 $c(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 a=this.geometry.morphTargetsRelative?1:1-s,o=i*e;return r[o]=a,r.set(n,o+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}};da=new oi,xN=new Ke(0.5,0.5),Fu=new j;Xc=class Xc extends $n{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(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}};$u=new j,Ku=new j,pE=new Qe,Cc=new hs,Uu=new oi,dp=new j,mE=new j;ps=class ps extends kt{constructor(e=new On,t=new Xc){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++)$u.fromBufferAttribute(t,i-1),Ku.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=$u.distanceTo(Ku);e.setAttribute("lineDistance",new Gn(n,1))}else je("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(Uu.copy(n.boundingSphere),Uu.applyMatrix4(i),Uu.radius+=r,e.ray.intersectsSphere(Uu)===!1)return;pE.copy(i).invert(),Cc.copy(e.ray).applyMatrix4(pE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let f=Math.max(0,s.start),h=Math.min(l.count,s.start+s.count);for(let y=f,g=h-1;y<g;y+=c){let m=l.getX(y),p=l.getX(y+1),b=Bu(this,e,Cc,o,m,p,y);if(b)t.push(b)}if(this.isLineLoop){let y=l.getX(h-1),g=l.getX(f),m=Bu(this,e,Cc,o,y,g,h-1);if(m)t.push(m)}}else{let f=Math.max(0,s.start),h=Math.min(d.count,s.start+s.count);for(let y=f,g=h-1;y<g;y+=c){let m=Bu(this,e,Cc,o,y,y+1,y);if(m)t.push(m)}if(this.isLineLoop){let y=Bu(this,e,Cc,o,h-1,f,h-1);if(y)t.push(y)}}}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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};gE=new j,bE=new j;dd=class dd extends ps{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)gE.fromBufferAttribute(t,i),bE.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+gE.distanceTo(bE);e.setAttribute("lineDistance",new Gn(n,1))}else je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};fd=class fd extends ps{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}};qc=class qc extends $n{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(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}};yE=new Qe,pp=new hs,zu=new oi,Vu=new j;Mo=class Mo extends kt{constructor(e=new On,t=new qc){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(zu.copy(n.boundingSphere),zu.applyMatrix4(i),zu.radius+=r,e.ray.intersectsSphere(zu)===!1)return;yE.copy(i).invert(),pp.copy(e.ray).applyMatrix4(yE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),f=Math.min(c.count,s.start+s.count);for(let h=d,y=f;h<y;h++){let g=c.getX(h);Vu.fromBufferAttribute(u,g),xE(Vu,g,o,i,e,t,this)}}else{let d=Math.max(0,s.start),f=Math.min(u.count,s.start+s.count);for(let h=d,y=f;h<y;h++)Vu.fromBufferAttribute(u,h),xE(Vu,h,o,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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};hd=class hd extends Qt{constructor(e=[],t=301,n,i,r,s,a,o,c,l){super(e,t,n,i,r,s,a,o,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};_a=class _a extends Qt{constructor(e,t,n=1014,i,r,s,a=1003,o=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 d={width:e,height:t,depth:u};super(d,i,r,s,a,o,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Vc(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}};ym=class ym extends _a{constructor(e,t=1014,n=301,i,r,s=1003,a=1003,o,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,a,o,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}};pd=class pd extends Qt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};ms=class ms extends On{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 a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let o=[],c=[],l=[],u=[],d=0,f=0;h("z","y","x",-1,-1,n,t,e,s,r,0),h("z","y","x",1,-1,n,t,-e,s,r,1),h("x","z","y",1,1,e,n,t,i,s,2),h("x","z","y",1,-1,e,n,-t,i,s,3),h("x","y","z",1,-1,e,t,n,i,r,4),h("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Gn(c,3)),this.setAttribute("normal",new Gn(l,3)),this.setAttribute("uv",new Gn(u,2));function h(y,g,m,p,b,_,x,v,E,S,T){let A=_/E,P=x/S,w=_/2,I=x/2,F=v/2,N=E+1,U=S+1,D=0,O=0,K=new j;for(let B=0;B<U;B++){let X=B*P-I;for(let q=0;q<N;q++){let le=q*A-w;K[y]=le*p,K[g]=X*b,K[m]=F,c.push(K.x,K.y,K.z),K[y]=0,K[g]=0,K[m]=v>0?1:-1,l.push(K.x,K.y,K.z),u.push(q/E),u.push(1-B/S),D+=1}}for(let B=0;B<S;B++)for(let X=0;X<E;X++){let q=d+X+N*B,le=d+X+N*(B+1),de=d+(X+1)+N*(B+1),Me=d+(X+1)+N*B;o.push(q,le,Me),o.push(le,de,Me),O+=6}a.addGroup(f,O,T),f+=O,d+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ms(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};Jc=class Jc extends On{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,a=Math.floor(n),o=Math.floor(i),c=a+1,l=o+1,u=e/a,d=t/o,f=[],h=[],y=[],g=[];for(let m=0;m<l;m++){let p=m*d-s;for(let b=0;b<c;b++){let _=b*u-r;h.push(_,-p,0),y.push(0,0,1),g.push(b/a),g.push(1-m/o)}}for(let m=0;m<o;m++)for(let p=0;p<a;p++){let b=p+c*m,_=p+c*(m+1),x=p+1+c*(m+1),v=p+1+c*m;f.push(b,_,v),f.push(_,x,v)}this.setIndex(f),this.setAttribute("position",new Gn(h,3)),this.setAttribute("normal",new Gn(y,3)),this.setAttribute("uv",new Gn(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jc(e.width,e.height,e.widthSegments,e.heightSegments)}};MT={clone:va,merge:kn};_i=class _i extends $n{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vN,this.fragmentShader=EN,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=va(e.uniforms),this.uniformsGroups=_N(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 qe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new j().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Nt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new tt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Qe().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}};_m=class _m extends _i{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};Ur=class Ur extends $n{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(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 qe(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 cr,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}};ci=class ci extends Ur{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 ct(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 qe(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 qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(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}};md=class md extends $n{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(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 cr,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}};vm=class vm extends $n{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}};Em=class Em extends $n{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}};Tm=class Tm extends Br{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,a=i[r],o=i[s];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,a=2*t-n;break;case 2402:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,o=2*n-t;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=e-1,o=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(o-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(i-t),y=h*h,g=y*h,m=-d*g+2*d*y-d*h,p=(1+d)*g+(-1.5-2*d)*y+(-0.5+d)*h+1,b=(-1-f)*g+(1.5+f)*y+0.5*h,_=f*g-f*y;for(let x=0;x!==a;++x)r[x]=m*s[l+x]+p*s[c+x]+b*s[o+x]+_*s[u+x];return r}};gd=class gd extends Br{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==a;++d)r[d]=s[c+d]*u+s[o+d]*l;return r}};Am=class Am extends Br{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}};Sm=class Sm extends Br{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this.inTangents,u=this.outTangents;if(!l||!u){let h=(n-t)/(i-t),y=1-h;for(let g=0;g!==a;++g)r[g]=s[c+g]*y+s[o+g]*h;return r}let d=a*2,f=e-1;for(let h=0;h!==a;++h){let y=s[c+h],g=s[o+h],m=f*d+h*2,p=u[m],b=u[m+1],_=e*d+h*2,x=l[_],v=l[_+1],E=wN(n,t,p,x,i);r[h]=RT(E,y,b,v,g)}return r}};li.prototype.ValueTypeName="";li.prototype.TimeBufferType=Float32Array;li.prototype.ValueBufferType=Float32Array;li.prototype.DefaultInterpolation=2301;gs=class gs extends li{constructor(e,t,n){super(e,t,n)}};gs.prototype.ValueTypeName="bool";gs.prototype.ValueBufferType=Array;gs.prototype.DefaultInterpolation=2300;gs.prototype.InterpolantFactoryMethodLinear=void 0;gs.prototype.InterpolantFactoryMethodSmooth=void 0;bd=class bd extends li{constructor(e,t,n,i){super(e,t,n,i)}};bd.prototype.ValueTypeName="color";bs=class bs extends li{constructor(e,t,n,i){super(e,t,n,i)}};bs.prototype.ValueTypeName="number";wm=class wm extends Br{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t),c=e*a;for(let l=c+a;c!==l;c+=4)ln.slerpFlat(r,0,s,c-a,s,c,o);return r}};ys=class ys extends li{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wm(this.times,this.values,this.getValueSize(),e)}};ys.prototype.ValueTypeName="quaternion";ys.prototype.InterpolantFactoryMethodSmooth=void 0;xs=class xs extends li{constructor(e,t,n){super(e,t,n)}};xs.prototype.ValueTypeName="string";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=2300;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;Ea=class Ea extends li{constructor(e,t,n,i){super(e,t,n,i)}};Ea.prototype.ValueTypeName="vector";or={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(TE(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(TE(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};IT=new Zc;zr.DEFAULT_MATERIAL_NAME="__DEFAULT";Dr={};CT=class CT extends Error{constructor(e,t){super(e);this.response=t}};Yc=class Yc extends zr{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=or.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Dr[e]!==void 0){Dr[e].push({onLoad:t,onProgress:n,onError:i});return}Dr[e]=[],Dr[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}),a=this.mimeType,o=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)je("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Dr[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,h=f!==0,y=0,g=new ReadableStream({start(m){p();function p(){u.read().then(({done:b,value:_})=>{if(b)m.close();else{y+=_.byteLength;let x=new ProgressEvent("progress",{lengthComputable:h,loaded:y,total:f});for(let v=0,E=l.length;v<E;v++){let S=l[v];if(S.onProgress)S.onProgress(x)}m.enqueue(_),p()}},(b)=>{m.error(b)})}}});return new Response(g)}else throw new CT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(o){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,a));case"json":return c.json();default:if(a==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then((h)=>f.decode(h))}}}).then((c)=>{or.add(`file:${e}`,c);let l=Dr[e];delete Dr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onLoad)f.onLoad(c)}}).catch((c)=>{let l=Dr[e];if(l===void 0)throw this.manager.itemError(e),c;delete Dr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onError)f.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}};co=new WeakMap;Mm=class Mm extends zr{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=or.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=co.get(s);if(u===void 0)u=[],co.set(s,u);u.push({onLoad:t,onError:i})}return s}let a=ho("img");function o(){if(l(),t)t(this);let u=co.get(this)||[];for(let d=0;d<u.length;d++){let f=u[d];if(f.onLoad)f.onLoad(this)}co.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);or.remove(`image:${e}`);let d=co.get(this)||[];for(let f=0;f<d.length;f++){let h=d[f];if(h.onError)h.onError(u)}co.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){a.removeEventListener("load",o,!1),a.removeEventListener("error",c,!1)}if(a.addEventListener("load",o,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)a.crossOrigin=this.crossOrigin}return or.add(`image:${e}`,a),r.manager.itemStart(e),a.src=e,a}};Ro=class Ro extends zr{constructor(e){super(e)}load(e,t,n,i){let r=new Qt,s=new Mm(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(a){if(r.image=a,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}};Io=class Io extends kt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new qe(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}};yd=class yd extends Io{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(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}};fp=new Qe,AE=new j,SE=new j;ju=new j,Hu=new ln,sr=new j;xd=class xd extends kt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe,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(ju,Hu,sr),sr.x===1&&sr.y===1&&sr.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ju,Hu,sr.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ju,Hu,sr),sr.x===1&&sr.y===1&&sr.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ju,Hu,sr.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};ss=new j,wE=new Ke,ME=new Ke;fn=class fn extends xd{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=ha*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Nc*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return ha*2*Math.atan(Math.tan(Nc*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){ss.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(ss.x,ss.y).multiplyScalar(-e/ss.z),ss.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ss.x,ss.y).multiplyScalar(-e/ss.z)}getViewSize(e,t){return this.getViewBounds(e,wE,ME),t.subVectors(ME,wE)}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(Nc*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:o,fullHeight:c}=s;r+=s.offsetX*i/o,t-=s.offsetY*n/c,i*=s.width/o,n*=s.height/c}let a=this.filmOffset;if(a!==0)r+=e*a/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}};NT=class NT extends Qc{constructor(){super(new fn(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=ha*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}};_d=class _d extends Io{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(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new NT}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}};PT=class PT extends Qc{constructor(){super(new fn(90,1,0.5,500));this.isPointLightShadow=!0}};Co=class Co extends Io{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 PT}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}};Ta=class Ta extends xd{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,a=i+t,o=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,a-=l*this.view.offsetY,o=a-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,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}};OT=class OT extends Qc{constructor(){super(new Ta(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}};No=class No extends Io{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.shadow=new OT}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}};hp=new WeakMap;vd=class vd extends zr{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")je("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")je("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=or.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(hp.has(s)===!0){if(i)i(hp.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 a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(or.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);hp.set(o,c),or.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});or.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};Rm=class Rm extends kt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new fn(lo,uo,e,t);i.layers=this.layers,this.add(i);let r=new fn(lo,uo,e,t);r.layers=this.layers,this.add(r);let s=new fn(lo,uo,e,t);s.layers=this.layers,this.add(s);let a=new fn(lo,uo,e,t);a.layers=this.layers,this.add(a);let o=new fn(lo,uo,e,t);o.layers=this.layers,this.add(o);let c=new fn(lo,uo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=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),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.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),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.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,a,o,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),h=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;if(e.isWebGLRenderer===!0)g=e.state.buffers.depth.getReversed();else g=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,3,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,i),g&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}};Im=class Im extends fn{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};IN=new RegExp("["+Nm+"]","g"),Pm="[^"+Nm+"]",CN="[^"+Nm.replace("\\.","")+"]",NN=/((?:WC+[\/:])*)/.source.replace("WC",Pm),PN=/(WCOD+)?/.source.replace("WCOD",CN),ON=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Pm),kN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Pm),DN=new RegExp("^"+NN+PN+ON+kN+"$"),LN=["material","materials","bones","map"];Et.Composite=kT;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]];FN=new Float32Array(1);Ed=class Ed extends Bi{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:a}=e,o=n.uuid,c=this._bindingsByRootAndName,l=c[o];if(l===void 0)l={},c[o]=l;for(let u=0;u!==r;++u){let d=i[u],f=d.name,h=l[f];if(h!==void 0)++h.referenceCount,s[u]=h;else{if(h=s[u],h!==void 0){if(h._cacheIndex===null)++h.referenceCount,this._addInactiveBinding(h,o,f);continue}let y=t&&t._propertyBindings[u].binding.parsedPath;h=new Cm(Et.create(n,f,y),d.ValueTypeName,d.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,f),s[u]=h}a[u].resultBuffer=h.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 a=s.knownActions;e._byClipCacheIndex=a.length,a.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,a=s[r],o=a.knownActions,c=o[o.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,o[l]=c,o.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],o.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,a=s[i],o=t[t.length-1],c=e._cacheIndex;if(o._cacheIndex=c,t[c]=o,t.pop(),delete a[r],Object.keys(a).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 gd(new Float32Array(2),new Float32Array(2),1,FN),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"?mo.findByName(i,e):e,a=s!==null?s.uuid:e,o=this._actionsByClip[a],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(o!==void 0){let u=o.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=o.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Om(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,a,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?mo.findByName(n,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];if(a!==void 0)return a.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 a=this._bindings,o=this._nActiveBindings;for(let c=0;c!==o;++c)a[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 a=0,o=s.length;a!==o;++a){let c=s[a];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 a=n[s].actionByRoot,o=a[t];if(o!==void 0)this._deactivateAction(o),this._removeInactiveAction(o)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let a=r[s];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}};km=class km{static{km.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}};Td=class Td extends Bi{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(){}};if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)je("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186"});function nA(){let e=null,t=!1,n=null,i=null;function r(s,a){i=e.requestAnimationFrame(r),n(s,a)}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 BN(e){let t=new WeakMap;function n(o,c){let{array:l,usage:u}=o,d=l.byteLength,f=e.createBuffer();e.bindBuffer(c,f),e.bufferData(c,l,u),o.onUploadCallback();let h;if(l instanceof Float32Array)h=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)h=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(o.isFloat16BufferAttribute)h=e.HALF_FLOAT;else h=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)h=e.SHORT;else if(l instanceof Uint32Array)h=e.UNSIGNED_INT;else if(l instanceof Int32Array)h=e.INT;else if(l instanceof Int8Array)h=e.BYTE;else if(l instanceof Uint8Array)h=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)h=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:h,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,o),d.length===0)e.bufferSubData(l,0,u);else{d.sort((h,y)=>h.start-y.start);let f=0;for(let h=1;h<d.length;h++){let y=d[f],g=d[h];if(g.start<=y.start+y.count+1)y.count=Math.max(y.count,g.start+g.count-y.start);else++f,d[f]=g}d.length=f+1;for(let h=0,y=d.length;h<y;h++){let g=d[h];e.bufferSubData(l,g.start*u.BYTES_PER_ELEMENT,u,g.start,g.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;let c=t.get(o);if(c)e.deleteBuffer(c.buffer),t.delete(o)}function a(o,c){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,n(o,c));else if(l.version<o.version){if(l.size!==o.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,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}function vk(e,t,n,i,r,s){let a=new qe(0),o=r===!0?0:1,c,l,u=null,d=0,f=null;function h(b){let _=b.isScene===!0?b.background:null;if(_&&_.isTexture){let x=b.backgroundBlurriness>0;_=t.get(_,x)}return _}function y(b){let _=!1,x=h(b);if(x===null)m(a,o);else if(x&&x.isColor)m(x,1),_=!0;let v=e.xr.getEnvironmentBlendMode();if(v==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(v==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||_)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function g(b,_){let x=h(_);if(x&&(x.isCubeTexture||x.mapping===Fc)){if(l===void 0)l=new jt(new ms(1,1,1),new _i({name:"BackgroundCubeMaterial",uniforms:va(mr.backgroundCube.uniforms),vertexShader:mr.backgroundCube.vertexShader,fragmentShader:mr.backgroundCube.fragmentShader,side:Pn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(v,E,S){this.matrixWorld.copyPosition(S.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=x,l.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(_k.makeRotationFromEuler(_.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(iA);if(l.material.toneMapped=ot.getTransfer(x.colorSpace)!==Bt,u!==x||d!==x.version||f!==e.toneMapping)l.material.needsUpdate=!0,u=x,d=x.version,f=e.toneMapping;l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)}else if(x&&x.isTexture){if(c===void 0)c=new jt(new Jc(2,2),new _i({name:"BackgroundMaterial",uniforms:va(mr.background.uniforms),vertexShader:mr.background.vertexShader,fragmentShader:mr.background.fragmentShader,side:us,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=x,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=ot.getTransfer(x.colorSpace)!==Bt,x.matrixAutoUpdate===!0)x.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(x.matrix),u!==x||d!==x.version||f!==e.toneMapping)c.material.needsUpdate=!0,u=x,d=x.version,f=e.toneMapping;c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)}}function m(b,_){b.getRGB(Ad,xm(e)),n.buffers.color.setClear(Ad.r,Ad.g,Ad.b,_,s)}function p(){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 a},setClearColor:function(b,_=1){a.set(b),o=_,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:y,addToRenderList:g,dispose:p}}function Ek(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=f(null),s=r,a=!1;function o(w,I,F,N,U){let D=!1,O=d(w,N,F,I);if(s!==O)s=O,l(s.object);if(D=h(w,N,F,U),D)y(w,N,F,U);if(U!==null)t.update(U,e.ELEMENT_ARRAY_BUFFER);if(D||a){if(a=!1,x(w,I,F,N),U!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(U).buffer)}}function c(){return e.createVertexArray()}function l(w){return e.bindVertexArray(w)}function u(w){return e.deleteVertexArray(w)}function d(w,I,F,N){let U=N.wireframe===!0,D=i[I.id];if(D===void 0)D={},i[I.id]=D;let O=w.isInstancedMesh===!0?w.id:0,K=D[O];if(K===void 0)K={},D[O]=K;let B=K[F.id];if(B===void 0)B={},K[F.id]=B;let X=B[U];if(X===void 0)X=f(c()),B[U]=X;return X}function f(w){let I=[],F=[],N=[];for(let U=0;U<n;U++)I[U]=0,F[U]=0,N[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:F,attributeDivisors:N,object:w,attributes:{},index:null}}function h(w,I,F,N){let U=s.attributes,D=I.attributes,O=0,K=F.getAttributes();for(let B in K)if(K[B].location>=0){let q=U[B],le=D[B];if(le===void 0){if(B==="instanceMatrix"&&w.instanceMatrix)le=w.instanceMatrix;if(B==="instanceColor"&&w.instanceColor)le=w.instanceColor}if(q===void 0)return!0;if(q.attribute!==le)return!0;if(le&&q.data!==le.data)return!0;O++}if(s.attributesNum!==O)return!0;if(s.index!==N)return!0;return!1}function y(w,I,F,N){let U={},D=I.attributes,O=0,K=F.getAttributes();for(let B in K)if(K[B].location>=0){let q=D[B];if(q===void 0){if(B==="instanceMatrix"&&w.instanceMatrix)q=w.instanceMatrix;if(B==="instanceColor"&&w.instanceColor)q=w.instanceColor}let le={};if(le.attribute=q,q&&q.data)le.data=q.data;U[B]=le,O++}s.attributes=U,s.attributesNum=O,s.index=N}function g(){let w=s.newAttributes;for(let I=0,F=w.length;I<F;I++)w[I]=0}function m(w){p(w,0)}function p(w,I){let F=s.newAttributes,N=s.enabledAttributes,U=s.attributeDivisors;if(F[w]=1,N[w]===0)e.enableVertexAttribArray(w),N[w]=1;if(U[w]!==I)e.vertexAttribDivisor(w,I),U[w]=I}function b(){let w=s.newAttributes,I=s.enabledAttributes;for(let F=0,N=I.length;F<N;F++)if(I[F]!==w[F])e.disableVertexAttribArray(F),I[F]=0}function _(w,I,F,N,U,D,O){if(O===!0)e.vertexAttribIPointer(w,I,F,U,D);else e.vertexAttribPointer(w,I,F,N,U,D)}function x(w,I,F,N){g();let U=N.attributes,D=F.getAttributes(),O=I.defaultAttributeValues;for(let K in D){let B=D[K];if(B.location>=0){let X=U[K];if(X===void 0){if(K==="instanceMatrix"&&w.instanceMatrix)X=w.instanceMatrix;if(K==="instanceColor"&&w.instanceColor)X=w.instanceColor}if(X!==void 0){let q=X.normalized,le=X.itemSize,de=t.get(X);if(de===void 0)continue;let{buffer:Me,type:pe,bytesPerElement:J}=de,L=pe===e.INT||pe===e.UNSIGNED_INT||X.gpuType===wp;if(X.isInterleavedBufferAttribute){let W=X.data,te=W.stride,ie=X.offset;if(W.isInstancedInterleavedBuffer){for(let ce=0;ce<B.locationSize;ce++)p(B.location+ce,W.meshPerAttribute);if(w.isInstancedMesh!==!0&&N._maxInstanceCount===void 0)N._maxInstanceCount=W.meshPerAttribute*W.count}else for(let ce=0;ce<B.locationSize;ce++)m(B.location+ce);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let ce=0;ce<B.locationSize;ce++)_(B.location+ce,le/B.locationSize,pe,q,te*J,(ie+le/B.locationSize*ce)*J,L)}else{if(X.isInstancedBufferAttribute){for(let W=0;W<B.locationSize;W++)p(B.location+W,X.meshPerAttribute);if(w.isInstancedMesh!==!0&&N._maxInstanceCount===void 0)N._maxInstanceCount=X.meshPerAttribute*X.count}else for(let W=0;W<B.locationSize;W++)m(B.location+W);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let W=0;W<B.locationSize;W++)_(B.location+W,le/B.locationSize,pe,q,le*J,le/B.locationSize*W*J,L)}}else if(O!==void 0){let q=O[K];if(q!==void 0)switch(q.length){case 2:e.vertexAttrib2fv(B.location,q);break;case 3:e.vertexAttrib3fv(B.location,q);break;case 4:e.vertexAttrib4fv(B.location,q);break;default:e.vertexAttrib1fv(B.location,q)}}}}b()}function v(){A();for(let w in i){let I=i[w];for(let F in I){let N=I[F];for(let U in N){let D=N[U];for(let O in D)u(D[O].object),delete D[O];delete N[U]}}delete i[w]}}function E(w){if(i[w.id]===void 0)return;let I=i[w.id];for(let F in I){let N=I[F];for(let U in N){let D=N[U];for(let O in D)u(D[O].object),delete D[O];delete N[U]}}delete i[w.id]}function S(w){for(let I in i){let F=i[I];for(let N in F){let U=F[N];if(U[w.id]===void 0)continue;let D=U[w.id];for(let O in D)u(D[O].object),delete D[O];delete U[w.id]}}}function T(w){for(let I in i){let F=i[I],N=w.isInstancedMesh===!0?w.id:0,U=F[N];if(U===void 0)continue;for(let D in U){let O=U[D];for(let K in O)u(O[K].object),delete O[K];delete U[D]}if(delete F[N],Object.keys(F).length===0)delete i[I]}}function A(){if(P(),a=!0,s===r)return;s=r,l(s.object)}function P(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:A,resetDefaultState:P,dispose:v,releaseStatesOfGeometry:E,releaseStatesOfObject:T,releaseStatesOfProgram:S,initAttributes:g,enableAttribute:m,disableUnusedAttributes:b}}function Tk(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 a(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function o(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let f=0;for(let h=0;h<u;h++)f+=l[h];n.update(f,i,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function Ak(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let S=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(S){if(S!==fr&&i.convert(S)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(S){let T=S===dr&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(S!==Ui&&S!==Fr&&!T&&i.convert(S)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(S){if(S==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";S="mediump"}if(S==="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)je("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&f===!1)je("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),y=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_TEXTURE_SIZE),m=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),b=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),_=e.getParameter(e.MAX_VARYING_VECTORS),x=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:h,maxVertexTextures:y,maxTextureSize:g,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:_,maxFragmentUniforms:x,maxSamples:v,samples:E}}function Sk(e){let t=this,n=null,i=0,r=!1,s=!1,a=new bi,o=new tt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let h=d.length!==0||f||i!==0||r;return r=f,i=d.length,h},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){n=u(d,f,0)},this.setState=function(d,f,h){let{clippingPlanes:y,clipIntersection:g,clipShadows:m}=d,p=e.get(d);if(!r||y===null||y.length===0||s&&!m)if(s)u(null);else l();else{let b=s?0:i,_=b*4,x=p.clippingState||null;c.value=x,x=u(y,f,_,h);for(let v=0;v!==_;++v)x[v]=n[v];p.clippingState=x,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=b}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,f,h,y){let g=d!==null?d.length:0,m=null;if(g!==0){if(m=c.value,y!==!0||m===null){let p=h+g*4,b=f.matrixWorldInverse;if(o.getNormalMatrix(b),m===null||m.length<p)m=new Float32Array(p);for(let _=0,x=h;_!==g;++_,x+=4)a.copy(d[_]).applyMatrix4(b,o),a.normal.toArray(m,x),m[x+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=g,t.numIntersection=0,m}}class sl{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:a=Ik}=r;Fm=this._renderer.getRenderTarget(),Um=this._renderer.getActiveCubeFace(),Bm=this._renderer.getActiveMipmapLevel(),zm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}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=UT(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=FT(),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(Fm,Um,Bm),this._renderer.xr.enabled=zm,e.scissorTest=!1,Po(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===yo||e.mapping===pa)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Fm=this._renderer.getRenderTarget(),Um=this._renderer.getActiveCubeFace(),Bm=this._renderer.getActiveMipmapLevel(),zm=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:En,minFilter:En,generateMipmaps:!1,type:dr,format:fr,colorSpace:si,depthBuffer:!1},i=LT(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=LT(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=Ck(r)),this._blurMaterial=Pk(r,e,t),this._ggxMaterial=Nk(r,e,t)}return i}_compileMaterial(e){let t=new jt(new On,e);this._renderer.compile(t,tl)}_sceneToCubeUV(e,t,n,i,r){let o=new fn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:f}=u;if(u.getClearColor(DT),u.toneMapping=Li,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new jt(new ms,new hr({name:"PMREM.Background",side:Pn,depthWrite:!1,depthTest:!1}));let y=this._backgroundBox,g=y.material,m=!1,p=e.background;if(p){if(p.isColor)g.color.copy(p),e.background=null,m=!0}else g.color.copy(DT),m=!0;for(let b=0;b<6;b++){let _=b%3;if(_===0)o.up.set(0,c[b],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x+l[b],r.y,r.z);else if(_===1)o.up.set(0,0,c[b]),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y+l[b],r.z);else o.up.set(0,c[b],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y,r.z+l[b]);let x=this._cubeSize;if(Po(i,_*x,b>2?x:0,x,x),u.setRenderTarget(i),m)u.render(y,o);u.render(e,o)}u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===yo||e.mapping===pa;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=UT();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=FT();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let a=r.uniforms;a.envMap.value=e;let o=this._cubeSize;Po(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(s,tl)}_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,a=this._lodMeshes[n];a.material=s;let o=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,f=u*d,{_lodMax:h}=this,y=this._sizeLods[n],g=3*y*(n>h-Oo?n-h+Oo:0),m=4*(this._cubeSize-y);o.envMap.value=e.texture,o.roughness.value=f,o.mipInt.value=h-t,Po(r,g,m,3*y,2*y),i.setRenderTarget(r),i.render(a,tl),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,Po(e,g,m,3*y,2*y),i.setRenderTarget(e),i.render(a,tl)}_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,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let c=a.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-Oo?i-this._lodMax+Oo:0),d=4*(this._cubeSize-l);Po(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(o,tl)}}function Ck(e){let t=[],n=[],i=e,r=e-Oo+1+wk;for(let s=0;s<r;s++){let a=Math.pow(2,i);t.push(a);let o=1/(a-2),c=-o,l=1+o,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,f=6,h=3,y=new Float32Array(h*f*d),g=new Float32Array(h*f*d);for(let p=0;p<d;p++){let b=p%3*2/3-1,_=p>2?0:-1,x=[b,_,0,b+0.6666666666666666,_,0,b+0.6666666666666666,_+1,0,b,_,0,b+0.6666666666666666,_+1,0,b,_+1,0];y.set(x,h*f*p);for(let v=0;v<f;v++){let E=u[v*2]*2-1,S=u[v*2+1]*2-1;if(p===0)Aa.set(1,S,E);else if(p===1)Aa.set(-E,1,-S);else if(p===2)Aa.set(-E,S,1);else if(p===3)Aa.set(-1,S,-E);else if(p===4)Aa.set(-E,-1,S);else Aa.set(E,S,-1);Aa.toArray(g,(p*f+v)*h)}}let m=new On;if(m.setAttribute("position",new vn(y,h)),m.setAttribute("outputDirection",new vn(g,h)),n.push(new jt(m,null)),i>Oo)i--}return{lodMeshes:n,sizeLods:t}}function LT(e,t,n){let i=new ai(e,t,n);return i.texture.mapping=Fc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Po(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Nk(e,t,n){return new _i({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Rk,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:wd(),fragmentShader:`
- if (${Y}) {
- newResult[${T}] = ${M}.value;
- }
- }
+ precision highp float;
+ precision highp int;
- `)}else if(!C)p.write(`
- const ${M}_present = ${v};
- if (${M}.issues.length) {${y(M,T)}
- }
- if (!${M}_present && !${M}.issues.length) {
- payload.issues.push({
- code: "invalid_type",
- expected: "nonoptional",
- input: undefined,
- path: [${T}]
- });
- if (ctx && ctx.abortEarly) {
- payload.value = newResult;
- return payload;
- }
- }
+ varying vec3 vOutputDirection;
- if (${M}_present) {
- newResult[${T}] = ${M}.value;
- }
+ uniform sampler2D envMap;
+ uniform float roughness;
+ uniform float mipInt;
- `);else if(p.write(`
- if (${M}.issues.length) {${y(M,T)}
- }
- `),V==="defaulted")p.write(`newResult[${T}] = ${M}.value;`);else p.write(`
- if (${M}.value !== undefined || ${v}) {
- newResult[${T}] = ${M}.value;
- }
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ms,c=!vn.jitless,u=c&&Dp.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 Hg([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function Jm(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)=>!Gn(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)=>yi(o,i,In())))}),t}var Uu=ie("$ZodUnion",(e,t)=>{At.init(e,t),pt(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),pt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),pt(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}),pt(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)=>mr(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 Jm(o,i,e,r);return Promise.all(o).then((a)=>Jm(a,i,e,r))}});function Lw(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 $g=ie("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Uu.init(e,t);let n=e._zod.parse;pt(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))Hn(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=No(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Lo(()=>Lw(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}}),Wg=ie("$ZodIntersection",(e,t)=>{At.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])=>Km(n,c,l));return Km(n,s,o)}});function Pu(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(qr(e)&&qr(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=Pu(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=Pu(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 Km(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=Pu(t.value,n.value);if(!c.valid){if(Gn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Zg=ie("$ZodTuple",(e,t)=>{At.init(e,t);let n=t.items,i=vn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=Qm(n,"optin"),l=Qm(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),h=t.rest?s?.abortEarly:void 0,d=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,h&&!d&&m.issues.length)d=Gn(m)}if(t.rest&&!d){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(h&&r.issues.length!==_){if(Gn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((y)=>eg(y,r,f)));else eg(g,r,f)}}if(a.length)return Promise.all(a).then(()=>tg(u,r,n,o,l));return tg(u,r,n,o,l)}});function Qm(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function eg(e,t,n){if(e.issues.length)t.issues.push(...vi(n,e.issues));t.value[n]=e.value}function tg(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...vi(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var jg=ie("$ZodRecord",(e,t)=>{At.init(e,t);let n=vn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!qr(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)=>yi(m,r,In())),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(...vi(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...vi(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"&&Es.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)=>yi(m,r,In())),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(...vi(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...vi(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 Xg=ie("$ZodEnum",(e,t)=>{At.init(e,t);let n=Io(t.entries),i=new Set(n);e._zod.values=i,pt(e,"pattern",(r)=>{let s=Io(r.def.entries).filter((o)=>Op.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Yi(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}}),qg=ie("$ZodLiteral",(e,t)=>{At.init(e,t);let n=new Set(t.values);e._zod.values=n,pt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Yi(s):s?Yi(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 Yg=ie("$ZodTransform",(e,t)=>{At.init(e,t),e._zod.optin="optional",vn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Do(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 bi;return n.value=r,n}});function ng(e,t){return e.value=t.issues.length?void 0:t.value,e}var ku=ie("$ZodOptional",(e,t)=>{At.init(e,t),pt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",pt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),pt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${mr(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)=>ng(n,s));return ng(n,r)}return t.innerType._zod.run(n,i)}}),Jg=ie("$ZodExactOptional",(e,t)=>{ku.init(e,t),pt(e,"values",(n)=>n.def.innerType._zod.values),pt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Kg=ie("$ZodNullable",(e,t)=>{At.init(e,t),pt(e,"optin",(n)=>n.def.innerType._zod.optin),pt(e,"optout",(n)=>n.def.innerType._zod.optout),pt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${mr(i.source)}|null)$`):void 0}),pt(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)}}),Qg=ie("$ZodDefault",(e,t)=>{At.init(e,t),e._zod.optin="defaulted",pt(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)=>ig(s,t));return ig(r,t)}});function ig(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var e_=ie("$ZodPrefault",(e,t)=>{At.init(e,t),e._zod.optin="defaulted",pt(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)}}),t_=ie("$ZodNonOptional",(e,t)=>{At.init(e,t),pt(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)=>rg(s,e));return rg(r,e)}});function rg(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 sg(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)=>yi(r,i,In()))},input:e.value}),e}var n_=ie("$ZodCatch",(e,t)=>{At.init(e,t),pt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),pt(e,"optout",(n)=>n.def.innerType._zod.optout),pt(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)=>sg(n,s,t,i));return sg(n,r,t,i)}});var i_=ie("$ZodPipe",(e,t)=>{At.init(e,t),pt(e,"values",(n)=>n.def.in._zod.values),pt(e,"optin",(n)=>n.def.in._zod.optin),pt(e,"optout",(n)=>n.def.out._zod.optout),pt(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)=>_c(o,t.in,i));return _c(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>_c(s,t.out,i));return _c(r,t.out,i)}});function _c(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 r_=ie("$ZodReadonly",(e,t)=>{At.init(e,t),pt(e,"propValues",(n)=>n.def.innerType._zod.propValues),pt(e,"values",(n)=>n.def.innerType._zod.values),pt(e,"optin",(n)=>n.def.innerType?._zod?.optin),pt(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(og);return og(r)}});function og(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function Nw(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return Pm({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===Es?mc:o)?.source}function Lu(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=Lu(i);if(n&&r&&s&&s!==r)return n.replace(mr(r),()=>mr(s));return n}if(t.options){let r=t.options.map(Lu);if(r.every(Boolean))return`^(${r.map((s)=>mr(s)).join("|")})$`}return Nw(e)}var s_=ie("$ZodTemplateLiteral",(e,t)=>{At.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=Lu(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(mr(r))}else if(i===null||Up.has(typeof i))n.push(Yi(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var o_=ie("$ZodCustom",(e,t)=>{cn.init(e,t),At.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)=>ag(s,n,i,e));ag(r,n,i,e);return}});function ag(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(Yr(r))}}class c_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var zu="~memo",a_=[];function l_(e){return e!==null&&typeof e==="object"}function Fu(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var u_=new WeakMap,ko=0,Mc=1,Fo=2;function Ec(e,t,n){let i=u_.get(e);if(i!==void 0)return i?Fo:ko;if(t.has(e))return Fo;t.add(e);let r=ko,s=(u)=>{if(r!==Fo&&u?._zod){let h=Ec(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=ko;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?Mc:m.value?._zod?Ec(m.value,t,n):ko;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=No(c);a(u?o(u,!0):Mc),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?Ec(u,t,!1):Mc);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),Dw(e,r)}function Dw(e,t){if(t!==Mc)u_.set(e,t===Fo);return t}function Ow(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Sc,wc=[],Uw={alloc(e,t,n){let i=Sc;if(!i)return n;Sc=void 0;let r={value:n,issues:null};return i.set(t.value,r),wc.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"&&kw(s,r.value))throw new c_;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=Ec(e,new Set,!1);if(g===ko){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Fo||i)n=!0;else i=!0}let u=c.value;if(!l_(u))return o(c,l);let h=l[zu];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[zu]=h;let d;if(r===l)d=s;else d=Ow(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(...Fu(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}Sc=d;let m=wc.length,_=o(c,l);Sc=void 0;let p=wc.length>m?wc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?Fu(g.issues):a_;return g});if(p)p.issues=_.issues.length?Fu(_.issues):a_;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function h_(){return Uw}function kw(e,t){let n=e[zu]?.backEdges;return n!==void 0&&l_(t)&&n.has(t)}var Fw=()=>{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=Vp(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 ${_u(s.values[0])}`;return`Invalid option: expected one of ${pu(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":""}: ${pu(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 Bu(){return{localeError:Fw()}}var d_;class f_{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 zw(){return new f_}(d_=globalThis).__zod_globalRegistry??(d_.__zod_globalRegistry=zw());var Jr=globalThis.__zod_globalRegistry;function p_(e){if(e.checks)e.checks=[...e.checks];return e}function m_(e,t){return new e(p_({type:"string",...De(t)}))}function g_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...De(t)})}function __(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...De(t)})}function x_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...De(t)})}function v_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...De(t)})}function y_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...De(t)})}function b_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...De(t)})}function S_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...De(t)})}function w_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...De(t)})}function M_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...De(t)})}function E_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...De(t)})}function A_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...De(t)})}function T_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...De(t)})}function R_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...De(t)})}function C_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...De(t)})}function I_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...De(t)})}function P_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...De(t)})}function L_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...De(t)})}function N_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...De(t)})}function D_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...De(t)})}function O_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...De(t)})}function U_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...De(t)})}function k_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...De(t)})}function F_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...De(t)})}function z_(e,t){return new e({type:"string",format:"date",check:"string_format",...De(t)})}function B_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...De(t)})}function V_(e,t){return new e({type:"string",format:"duration",check:"string_format",...De(t)})}function H_(e,t){return new e(p_({type:"number",checks:[],...De(t)}))}function G_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...De(t)})}function $_(e,t){return new e({type:"boolean",...De(t)})}function W_(e){return new e({type:"unknown"})}function Z_(e,t){return new e({type:"never",...De(t)})}function Ac(e,t){return new Ru({check:"less_than",...De(t),value:e,inclusive:!1})}function zo(e,t){return new Ru({check:"less_than",...De(t),value:e,inclusive:!0})}function Tc(e,t){return new Cu({check:"greater_than",...De(t),value:e,inclusive:!1})}function Bo(e,t){return new Cu({check:"greater_than",...De(t),value:e,inclusive:!0})}function Rc(e,t){return new Om({check:"multiple_of",...De(t),value:e})}function Cc(e,t){return new km({check:"max_length",...De(t),maximum:e})}function As(e,t){return new Fm({check:"min_length",...De(t),minimum:e})}function Ic(e,t){return new zm({check:"length_equals",...De(t),length:e})}function Vu(e,t){return new Bm({check:"string_format",format:"regex",...De(t),pattern:e})}function Hu(e){return new Vm({check:"string_format",format:"lowercase",...De(e)})}function Gu(e){return new Hm({check:"string_format",format:"uppercase",...De(e)})}function $u(e,t){return new Gm({check:"string_format",format:"includes",...De(t),includes:e})}function Wu(e,t){return new $m({check:"string_format",format:"starts_with",...De(t),prefix:e})}function Zu(e,t){return new Wm({check:"string_format",format:"ends_with",...De(t),suffix:e})}function gr(e){return new Zm({check:"overwrite",tx:e})}function ju(e){return gr((t)=>t.normalize(e))}function Xu(){return gr((e)=>e.trim())}function qu(){return gr((e)=>e.toLowerCase())}function Yu(){return gr((e)=>e.toUpperCase())}function Ju(){return gr((e)=>Np(e))}function j_(e,t,n){return new e({type:"array",element:t,...De(n)})}function X_(e,t,n){return new e({type:"custom",check:"custom",fn:t,...De(n)})}function q_(e,t){let n=Bw((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Yr(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(Yr(s))}},e(i.value,i)),t);return n}function Bw(e,t){let n=new cn({check:"custom",...De(t)});return n._zod.check=e,n}function Vo(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Hn(e,i,n[i]);return e}function Qu(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??Jr,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 Ji(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 kt(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;kt(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Vo(o.schema,c);if(t.io==="input"&&yn(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 Y_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function eh(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}/${Y_(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+Y_(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>
+ #define ENVMAP_TYPE_CUBE_UV
+ #include <cube_uv_reflection_fragment>
-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 Q_(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;Q_(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"]),J_=["oneOf","anyOf"];function K_(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 Ku(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]??K_(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]:Ku(a)??{allOf:a};Hn(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=K_(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 Vw(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)=>J_.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Ku(t);else{let r=n[0],s=J_.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)=>Ku([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Vo(e,i)}function th(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 Vo(l,m);if(Vo(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())Q_(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)??[])Vw(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)}Vo(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;Hn(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:Ho(t,"input",e.processors),output:Ho(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function yn(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 yn(i.element,n);if(i.type==="set")return yn(i.valueType,n);if(i.type==="lazy")return yn(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 yn(i.innerType,n);if(i.type==="intersection")return yn(i.left,n)||yn(i.right,n);if(i.type==="record"||i.type==="map")return yn(i.keyType,n)||yn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return yn(i.in,n)||yn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(yn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(yn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(yn(r,n))return!0;if(i.rest&&yn(i.rest,n))return!0;return!1}return!1}var tx=(e,t={})=>(n)=>{let i=Qu({...n,processors:t});return kt(e,i),eh(i,e),th(i,e)},Ho=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Qu({...r??{},target:s,io:t,processors:n});return kt(e,o),eh(o,e),th(o,e)};var Ts=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Rs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},nx=(e,t)=>{Ts(e,"minimum",t),Rs(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)=>Ts(e,"minimum",t.minimum),rx=(e,t)=>Rs(e,"maximum",t.maximum),sx=(e)=>(t,n)=>{lx(t,n.format);let[i,r]=e[n.format];Ts(t,"minimum",i),Rs(t,"maximum",r)},Hw={greater_than:(e,t)=>Ts(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Rs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ox(e,t.value),number_format:sx(sc),bigint_format:sx(xu),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 Pn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)Hw[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ts(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ts(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Rs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Rs(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 Gw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$w=new Map([[Du,Sm],[bc,wm]]),ux=(e)=>$w.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}=Pn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=Gw[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(ux);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}))]}},dx=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Pn(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 Ji(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}))]}},fx=(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=Io(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(Ji(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Ji(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)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var vx=(e,t,n,i)=>{Ji(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var yx=(e,t,n,i)=>{Ji(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}=Pn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=kt(s.element,t,{...i,path:[...i.path,"items"]})};function Go(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Go(t.out);if(t.type==="catch")return Go(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&&Ji(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Hn(r.properties,l,kt(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"?Go(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=kt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},wx=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>kt(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=kt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=kt(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)},Ex=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>kt(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?kt(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?Go(_)!==void 0:_._zod.optout==="optional"))break;u--}let h=s.items.length,d=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,d)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(d)r.maxItems=h}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(d)r.maxItems=h}else{if(r.items=c,d)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(d)r.maxItems=h}let{minimum:f,maximum:m}=Pn(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function nh(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 _=nh(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>nh(e,g,n));if(p.some((g,y)=>g!==_[y]))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")?Es:mc).source;return f}var ih=new WeakMap;function Ww(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 ih.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=nh(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 Ax=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Pn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=kt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let h of a)Hn(r.patternProperties,ux(h).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=kt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=ih.get(t);if(!u)u=[],ih.set(t,u),t.deferred.push(()=>Ww(t));u.push(e)}r.additionalProperties=kt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Go(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)}},Tx=(e,t,n,i)=>{let r=e._zod.def,s=kt(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"}]},Rx=(e,t,n,i)=>{let r=e._zod.def;kt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},rh=Symbol();function Cx(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 Ji(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),rh}var Ix=(e,t,n,i)=>{let r=e._zod.def;kt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Cx(r.defaultValue,e,t,n,i);if(o!==rh)n.default=o},Px=(e,t,n,i)=>{let r=e._zod.def;kt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Cx(r.defaultValue,e,t,n,i);if(o!==rh)n._prefault=o},Lx=(e,t,n,i)=>{let r=e._zod.def;kt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Ji(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Nx=(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;kt(o,t,i);let a=t.seen.get(e);a.ref=o},Dx=(e,t,n,i)=>{let r=e._zod.def;kt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var sh=(e,t,n,i)=>{let r=e._zod.def;kt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Ox=new WeakSet([Object.prototype,Error.prototype]);function Pc(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 Qw=(e,t)=>{qp.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Ox.has(n))return;Ox.add(n),Pc(n,"format",(i)=>(r)=>Jp(i,r)),Pc(n,"flatten",(i)=>(r)=>Yp(i,r)),Pc(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Po,2)}),Pc(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Po,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Ln=ie("ZodError",Qw,void 0,{Parent:Error});var Ux=hc(Ln),kx=dc(Ln),Fx=fc(Ln),zx=pc(Ln),Bx=Qp(Ln),Vx=em(Ln),Hx=tm(Ln),Gx=nm(Ln),$x=im(Ln),Wx=rm(Ln),Zx=sm(Ln),jx=om(Ln);function tM(){if(!vn.localeError)In(Bu())}function $o(){if(!vn.memoizer)In({memoizer:h_()})}var Dt=ie("ZodType",(e,t)=>(tM(),At.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Cn(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 xi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(eE(e,t))},superRefine(e,t){return this.check(tE(e,t))},overwrite(e){return this.check(gr(e))},optional(){return Yx(this)},exactOptional(){return zM(this)},nullable(){return Jx(this)},nullish(){return Yx(Jx(this))},nonoptional(e){return WM(this,e)},array(){return tt(this)},or(e){return Wo([this,e])},and(e){return DM(this,e)},transform(e){return Kx(this,FM(e))},default(e){return HM(this,e)},prefault(e){return $M(this,e)},catch(e){return jM(this,e)},pipe(e){return Kx(this,e)},readonly(){return YM(this)},describe(e){let t=this.clone();return Jr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Jr.get(this);let t=this.clone();return Jr.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 lc(this,"~standard",{...Nu(this),jsonSchema:{input:Ho(this,"input"),output:Ho(this,"output")}})},set "~standard"(e){qi(this,"~standard",e)},parse:function e(t,n){return Ux(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await kx(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){qi(this,"spa",e)},validate(e,t){return wu(this,e,t)},validateAsync(e,t){return Mu(this,e,t)},encode:function e(t,n){return Bx(this,t,n,{callee:e})},decode:function e(t,n){return Vx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Hx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Gx(this,t,n,{callee:e})},safeEncode(e,t){return $x(this,e,t)},safeDecode(e,t){return Wx(this,e,t)},async safeEncodeAsync(e,t){return Zx(this,e,t)},async safeDecodeAsync(e,t){return jx(this,e,t)},toJSONSchema(e){return tx(this,{})(e)},get description(){return Jr.get(this)?.description},get _def(){return this._zod.def}}),Qx=ie("_ZodString",(e,t)=>{yc.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hx(e,n,i,r)},Gp({format:(e)=>Pn(e).format??null,minLength:(e)=>Pn(e).minimum??null,maxLength:(e)=>Pn(e).maximum??null},{regex(...e){return this.check(Vu(...e))},includes(...e){return this.check($u(...e))},startsWith(...e){return this.check(Wu(...e))},endsWith(...e){return this.check(Zu(...e))},min(...e){return this.check(As(...e))},max(...e){return this.check(Cc(...e))},length(...e){return this.check(Ic(...e))},nonempty(...e){return this.check(As(1,...e))},lowercase(e){return this.check(Hu(e))},uppercase(e){return this.check(Gu(e))},trim(){return this.check(Xu())},normalize(...e){return this.check(ju(...e))},toLowerCase(){return this.check(qu())},toUpperCase(){return this.check(Yu())},slugify(){return this.check(Ju())}})),nM=ie("ZodString",(e,t)=>{yc.init(e,t),Qx.init(e,t)},{email(e){return this.check(g_(aM,e))},url(e){return this.check(S_(lM,e))},jwt(e){return this.check(k_(MM,e))},emoji(e){return this.check(w_(uM,e))},guid(e){return this.check(__(cM,e))},uuid(e){return this.check(x_(Lc,e))},uuidv4(e){return this.check(v_(Lc,e))},uuidv6(e){return this.check(y_(Lc,e))},uuidv7(e){return this.check(b_(Lc,e))},nanoid(e){return this.check(M_(hM,e))},cuid(e){return this.check(E_(dM,e))},cuid2(e){return this.check(A_(fM,e))},ulid(e){return this.check(T_(pM,e))},base64(e){return this.check(D_(bM,e))},base64url(e){return this.check(O_(SM,e))},xid(e){return this.check(R_(mM,e))},ksuid(e){return this.check(C_(gM,e))},ipv4(e){return this.check(I_(_M,e))},ipv6(e){return this.check(P_(xM,e))},cidrv4(e){return this.check(L_(vM,e))},cidrv6(e){return this.check(N_(yM,e))},e164(e){return this.check(U_(wM,e))},datetime(e){return this.check(F_(iM,e))},date(e){return this.check(z_(rM,e))},time(e){return this.check(B_(sM,e))},duration(e){return this.check(V_(oM,e))}});function Ne(e){return m_(nM,e)}var Ft=ie("ZodStringFormat",(e,t)=>{Nt.init(e,t),Qx.init(e,t)}),iM=ie("ZodISODateTime",(e,t)=>{Sg.init(e,t),Ft.init(e,t)}),rM=ie("ZodISODate",(e,t)=>{wg.init(e,t),Ft.init(e,t)}),sM=ie("ZodISOTime",(e,t)=>{Mg.init(e,t),Ft.init(e,t)}),oM=ie("ZodISODuration",(e,t)=>{Eg.init(e,t),Ft.init(e,t)}),aM=ie("ZodEmail",(e,t)=>{hg.init(e,t),Ft.init(e,t)});var cM=ie("ZodGUID",(e,t)=>{lg.init(e,t),Ft.init(e,t)});var Lc=ie("ZodUUID",(e,t)=>{ug.init(e,t),Ft.init(e,t)});var lM=ie("ZodURL",(e,t)=>{pg.init(e,t),Ft.init(e,t)});var uM=ie("ZodEmoji",(e,t)=>{mg.init(e,t),Ft.init(e,t)});var hM=ie("ZodNanoID",(e,t)=>{gg.init(e,t),Ft.init(e,t)});var dM=ie("ZodCUID",(e,t)=>{_g.init(e,t),Ft.init(e,t)});var fM=ie("ZodCUID2",(e,t)=>{xg.init(e,t),Ft.init(e,t)});var pM=ie("ZodULID",(e,t)=>{vg.init(e,t),Ft.init(e,t)});var mM=ie("ZodXID",(e,t)=>{yg.init(e,t),Ft.init(e,t)});var gM=ie("ZodKSUID",(e,t)=>{bg.init(e,t),Ft.init(e,t)});var _M=ie("ZodIPv4",(e,t)=>{Ag.init(e,t),Ft.init(e,t)});var xM=ie("ZodIPv6",(e,t)=>{Rg.init(e,t),Ft.init(e,t)});var vM=ie("ZodCIDRv4",(e,t)=>{Cg.init(e,t),Ft.init(e,t)});var yM=ie("ZodCIDRv6",(e,t)=>{Ig.init(e,t),Ft.init(e,t)});var bM=ie("ZodBase64",(e,t)=>{Lg.init(e,t),Ft.init(e,t)});var SM=ie("ZodBase64URL",(e,t)=>{Ng.init(e,t),Ft.init(e,t)});var wM=ie("ZodE164",(e,t)=>{Dg.init(e,t),Ft.init(e,t)});var MM=ie("ZodJWT",(e,t)=>{Og.init(e,t),Ft.init(e,t)});var e0=ie("ZodNumber",(e,t)=>{Ou.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dx(e,n,i,r),e.isFinite=!0},Gp({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Pn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Pn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Pn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Pn(e).format??null},{gt(e,t){return this.check(Tc(e,t))},gte(e,t){return this.check(Bo(e,t))},min(e,t){return this.check(Bo(e,t))},lt(e,t){return this.check(Ac(e,t))},lte(e,t){return this.check(zo(e,t))},max(e,t){return this.check(zo(e,t))},int(e){return this.check(Xx(e))},safe(e){return this.check(Xx(e))},positive(e){return this.check(Tc(0,e))},nonnegative(e){return this.check(Bo(0,e))},negative(e){return this.check(Ac(0,e))},nonpositive(e){return this.check(zo(0,e))},multipleOf(e,t){return this.check(Rc(e,t))},step(e,t){return this.check(Rc(e,t))},finite(){return this}}));function lt(e){return H_(e0,e)}var EM=ie("ZodNumberFormat",(e,t)=>{Ug.init(e,t),e0.init(e,t)});function Xx(e){return G_(EM,e)}var AM=ie("ZodBoolean",(e,t)=>{kg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fx(e,n,i,r)});function Qr(e){return $_(AM,e)}var TM=ie("ZodUnknown",(e,t)=>{Fg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mx(e,n,i,r)});function Kr(){return W_(TM)}var RM=ie("ZodNever",(e,t)=>{zg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>px(e,n,i,r)});function CM(e){return Z_(RM,e)}var IM=ie("ZodArray",(e,t)=>{$o(),Bg.init(e,t),Dt.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(Cc(e,t))},length(e,t){return this.check(Ic(e,t))},unwrap(){return this.element}});function tt(e,t){return j_(IM,e,t)}var PM=ie("ZodObject",(e,t)=>{$o(),Gg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sx(e,n,i,r),cw(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Tt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Cn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Cn(this._zod.def,{catchall:Kr()}))},loose(){return this.clone(Cn(this._zod.def,{catchall:Kr()}))},strict(){return this.clone(Cn(this._zod.def,{catchall:CM()}))},strip(){return this.clone(Cn(this._zod.def,{catchall:void 0}))},extend(e){return ew(this,e)},safeExtend(e){return tw(this,e)},merge(e){return nw(this,e)},pick(e){return KS(this,e)},omit(e){return QS(this,e)},partial(...e){return zp(ch,this,e[0])},exactPartial(...e){return zp(i0,this,e[0],"exactPartial")},required(...e){return iw(r0,this,e[0])}});function _e(e,t){let n={type:"object",shape:e??{},...De(t)};return new PM(n)}var t0=ie("ZodUnion",(e,t)=>{Uu.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wx(e,n,i,r),e.options=t.options});function Wo(e,t){return new t0({type:"union",options:e,...De(t)})}var LM=ie("ZodDiscriminatedUnion",(e,t)=>{t0.init(e,t),$g.init(e,t)});function ei(e,t,n){return new LM({type:"union",options:t,discriminator:e,...De(n)})}var NM=ie("ZodIntersection",(e,t)=>{Wg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mx(e,n,i,r)});function DM(e,t){return new NM({type:"intersection",left:e,right:t})}var OM=ie("ZodTuple",(e,t)=>{$o(),Zg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ex(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new ch({type:"optional",innerType:t}))})}});function n0(e,t,n){let i=t instanceof At,r=i?n:t;return new OM({type:"tuple",items:e,rest:i?t:null,...De(r)})}var qx=ie("ZodRecord",(e,t)=>{$o(),jg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ax(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nc(e,t,n){if(!t||!t._zod)return new qx({type:"record",keyType:Ne(),valueType:e,...De(t)});return new qx({type:"record",keyType:e,valueType:t,...De(n)})}var ah=ie("ZodEnum",(e,t)=>{Xg.init(e,t),Dt.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 ah({...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 ah({...t,checks:[],...De(r),entries:s})}});function Tt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new ah({type:"enum",entries:n,...De(t)})}var UM=ie("ZodLiteral",(e,t)=>{qg.init(e,t),Dt.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 He(e,t){return new UM({type:"literal",values:Array.isArray(e)?e:[e],...De(t)})}var kM=ie("ZodTransform",(e,t)=>{$o(),Yg.init(e,t),Dt.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 Do(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Yr(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(Yr(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 FM(e){return new kM({type:"transform",transform:e})}var ch=ie("ZodOptional",(e,t)=>{ku.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Yx(e){return new ch({type:"optional",innerType:e})}var i0=ie("ZodExactOptional",(e,t)=>{Jg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function zM(e){return new i0({type:"optional",innerType:e})}var BM=ie("ZodNullable",(e,t)=>{Kg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Jx(e){return new BM({type:"nullable",innerType:e})}var VM=ie("ZodDefault",(e,t)=>{Qg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ix(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function HM(e,t){return new VM({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():gu(t)}})}var GM=ie("ZodPrefault",(e,t)=>{e_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Px(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function $M(e,t){return new GM({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():gu(t)}})}var r0=ie("ZodNonOptional",(e,t)=>{t_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Rx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function WM(e,t){return new r0({type:"nonoptional",innerType:e,...De(t)})}var ZM=ie("ZodCatch",(e,t)=>{n_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jM(e,t){return new ZM({type:"catch",innerType:e,catchValue:typeof t==="function"?t:$p(t)})}var XM=ie("ZodPipe",(e,t)=>{i_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Nx(e,n,i,r),e.in=t.in,e.out=t.out});function Kx(e,t){return new XM({type:"pipe",in:e,out:t})}var qM=ie("ZodReadonly",(e,t)=>{r_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function YM(e){return new qM({type:"readonly",innerType:e})}var JM=ie("ZodTemplateLiteral",(e,t)=>{s_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xx(e,n,i,r)});function KM(e,t){return new JM({type:"template_literal",parts:e,...De(t)})}var QM=ie("ZodCustom",(e,t)=>{o_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vx(e,n,i,r)});function eE(e,t={}){return X_(QM,e,t)}function tE(e,t){return q_(e,t)}var Dc={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 s0;(function(e){})(s0||(s0={}));var o0=["neutral","dark","light"];var lh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),a0=Object.freeze({neutral:lh("neutral",[170,177,188]),dark:lh("dark",[26,26,26]),light:lh("light",[223,227,232])});var YN=a0.neutral.rgb,JN=a0.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 zt=Uint8Array,Nn=Uint16Array,yh=Int32Array,Uc=new zt([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]),kc=new zt([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]),ph=new zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p0=function(e,t){var n=new Nn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new yh(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}},m0=p0(Uc,2),{b:g0,r:mh}=m0;g0[28]=258,mh[258]=28;var _0=p0(kc,0),{b:nE,r:c0}=_0,gh=new Nn(32768);for(ct=0;ct<32768;++ct)Si=(ct&43690)>>1|(ct&21845)<<1,Si=(Si&52428)>>2|(Si&13107)<<2,Si=(Si&61680)>>4|(Si&3855)<<4,gh[ct]=((Si&65280)>>8|(Si&255)<<8)>>1;var Si,ct,Mi=function(e,t,n){var i=e.length,r=0,s=new Nn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new Nn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new Nn(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[gh[h]>>c]=l}}else{a=new Nn(i);for(r=0;r<i;++r)if(e[r])a[r]=gh[o[e[r]-1]++]>>15-e[r]}return a},_r=new zt(288);for(ct=0;ct<144;++ct)_r[ct]=8;var ct;for(ct=144;ct<256;++ct)_r[ct]=9;var ct;for(ct=256;ct<280;++ct)_r[ct]=7;var ct;for(ct=280;ct<288;++ct)_r[ct]=8;var ct,Xo=new zt(32);for(ct=0;ct<32;++ct)Xo[ct]=5;var ct,iE=Mi(_r,9,0),rE=Mi(_r,9,1),sE=Mi(Xo,5,0),oE=Mi(Xo,5,1),uh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ti=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},hh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},bh=function(e){return(e+7)/8|0},qo=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new zt(e.subarray(t,n))};var aE=["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"],bn=function(e,t,n){var i=Error(t||aE[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,bn);if(!n)throw i;return i},cE=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new zt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new zt(r*3);var l=function(ce){var Ae=n.length;if(ce>Ae){var Te=new zt(Math.max(Ae*2,ce));Te.set(n),n=Te}},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=ti(e,h,1);var y=ti(e,h+1,3);if(h+=3,!y){var S=bh(h)+4,x=e[S-4]|e[S-3]<<8,b=S+x;if(b>r){if(c)bn(0);break}if(a)l(d+x);n.set(e.subarray(S,b),d),t.b=d+=x,t.p=h=b*8,t.f=u;continue}else if(y==1)f=rE,m=oE,_=9,p=5;else if(y==2){var M=ti(e,h,31)+257,T=ti(e,h+10,15)+4,v=M+ti(e,h+5,31)+1;h+=14;var A=new zt(v),V=new zt(19);for(var C=0;C<T;++C)V[ph[C]]=ti(e,h+C*3,7);h+=T*3;var N=uh(V),Y=(1<<N)-1,D=Mi(V,N,1);for(var C=0;C<v;){var W=D[ti(e,h,Y)];h+=W&15;var S=W>>4;if(S<16)A[C++]=S;else{var z=0,P=0;if(S==16)P=3+ti(e,h,3),h+=2,z=A[C-1];else if(S==17)P=3+ti(e,h,7),h+=3;else if(S==18)P=11+ti(e,h,127),h+=7;while(P--)A[C++]=z}}var q=A.subarray(0,M),H=A.subarray(M);_=uh(q),p=uh(H),f=Mi(q,_,1),m=Mi(H,p,1)}else bn(1);if(h>g){if(c)bn(0);break}}if(a)l(d+131072);var ee=(1<<_)-1,J=(1<<p)-1,de=h;for(;;de=h){var z=f[hh(e,h)&ee],pe=z>>4;if(h+=z&15,h>g){if(c)bn(0);break}if(!z)bn(2);if(pe<256)n[d++]=pe;else if(pe==256){de=h,f=null;break}else{var Be=pe-254;if(pe>264){var C=pe-257,me=Uc[C];Be=ti(e,h,(1<<me)-1)+g0[C],h+=me}var X=m[hh(e,h)&J],L=X>>4;if(!X)bn(3);h+=X&15;var H=nE[L];if(L>3){var me=kc[L];H+=hh(e,h)&(1<<me)-1,h+=me}if(h>g){if(c)bn(0);break}if(a)l(d+131072);var G=d+Be;if(d<H){var te=s-H,se=Math.min(H,G);if(te+d<0)bn(3);for(;d<se;++d)n[d]=i[te+d]}for(;d<G;++d)n[d]=n[d-H]}}if(t.l=f,t.p=de,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?qo(n,0,d):n.subarray(0,d)},Ki=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},Zo=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},dh=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:v0,l:0};if(r==1){var o=new zt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(b,M){return b.f-M.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 Nn(d+1),m=_h(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(M,T){return f[T.s]-f[M.s]||M.f-T.f});for(;i<r;++i){var y=s[i].s;if(f[y]>t)_+=g-(1<<m-f[y]),f[y]=t;else break}_>>=p;while(_>0){var S=s[i].s;if(f[S]<t)_-=1<<t-f[S]++-1;else++i}for(;i>=0&&_;--i){var x=s[i].s;if(f[x]==t)--f[x],++_}m=t}return{t:new zt(f),l:m}},_h=function(e,t,n){return e.s==-1?Math.max(_h(e.l,t,n+1),_h(e.r,t,n+1)):t[e.s]=n},l0=function(e){var t=e.length;while(t&&!e[--t]);var n=new Nn(++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}},jo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},x0=function(e,t,n){var i=n.length,r=bh(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},u0=function(e,t,n,i,r,s,o,a,c,l,u){Ki(t,u++,n),++r[256];var h=dh(r,15),{t:d,l:f}=h,m=dh(s,15),{t:_,l:p}=m,g=l0(d),{c:y,n:S}=g,x=l0(_),{c:b,n:M}=x,T=new Nn(19);for(var v=0;v<y.length;++v)++T[y[v]&31];for(var v=0;v<b.length;++v)++T[b[v]&31];var A=dh(T,7),{t:V,l:C}=A,N=19;for(;N>4&&!V[ph[N-1]];--N);var Y=l+5<<3,D=jo(r,_r)+jo(s,Xo)+o,W=jo(r,d)+jo(s,_)+o+14+3*N+jo(T,V)+2*T[16]+3*T[17]+7*T[18];if(c>=0&&Y<=D&&Y<=W)return x0(t,u,e.subarray(c,c+l));var z,P,q,H;if(Ki(t,u,1+(W<D)),u+=2,W<D){z=Mi(d,f,0),P=d,q=Mi(_,p,0),H=_;var ee=Mi(V,C,0);Ki(t,u,S-257),Ki(t,u+5,M-1),Ki(t,u+10,N-4),u+=14;for(var v=0;v<N;++v)Ki(t,u+3*v,V[ph[v]]);u+=3*N;var J=[y,b];for(var de=0;de<2;++de){var pe=J[de];for(var v=0;v<pe.length;++v){var Be=pe[v]&31;if(Ki(t,u,ee[Be]),u+=V[Be],Be>15)Ki(t,u,pe[v]>>5&127),u+=pe[v]>>12}}}else z=iE,P=_r,q=sE,H=Xo;for(var v=0;v<a;++v){var me=i[v];if(me>255){var Be=me>>18&31;if(Zo(t,u,z[Be+257]),u+=P[Be+257],Be>7)Ki(t,u,me>>23&31),u+=Uc[Be];var X=me&31;if(Zo(t,u,q[X]),u+=H[X],X>3)Zo(t,u,me>>5&8191),u+=kc[X]}else Zo(t,u,z[me]),u+=P[me]}return Zo(t,u,z[256]),u+P[256]},lE=new yh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),v0=new zt(0),uE=function(e,t,n,i,r,s){var o=s.z||e.length,a=new zt(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=lE[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new Nn(32768),p=s.h||new Nn(m+1),g=Math.ceil(n/3),y=2*g,S=function(Ue){return(e[Ue]^e[Ue+1]<<g^e[Ue+2]<<y)&m},x=new yh(25000),b=new Nn(288),M=new Nn(32),T=0,v=0,A=s.i||0,V=0,C=s.w||0,N=0;for(;A+2<o;++A){var Y=S(A),D=A&32767,W=p[Y];if(_[D]=W,p[Y]=D,C<=A){var z=o-A;if((T>7000||V>24576)&&(z>423||!l)){u=u0(e,c,0,x,b,M,v,V,N,A-N,u),V=T=v=0,N=A;for(var P=0;P<286;++P)b[P]=0;for(var P=0;P<30;++P)M[P]=0}var q=2,H=0,ee=f,J=D-W&32767;if(z>2&&Y==S(A-J)){var de=Math.min(d,z)-1,pe=Math.min(32767,A),Be=Math.min(258,z);while(J<=pe&&--ee&&D!=W){if(e[A+q]==e[A+q-J]){var me=0;for(;me<Be&&e[A+me]==e[A+me-J];++me);if(me>q){if(q=me,H=J,me>de)break;var X=Math.min(J,me-2),L=0;for(var P=0;P<X;++P){var G=A-J+P&32767,te=_[G],se=G-te&32767;if(se>L)L=se,W=G}}}D=W,W=_[D],J+=D-W&32767}}if(H){x[V++]=268435456|mh[q]<<18|c0[H];var ce=mh[q]&31,Ae=c0[H]&31;v+=Uc[ce]+kc[Ae],++b[257+ce],++M[Ae],C=A+q,++T}else x[V++]=e[A],++b[e[A]]}}for(A=Math.max(A,C);A<o;++A)x[V++]=e[A],++b[e[A]];if(u=u0(e,c,l,x,b,M,v,V,N,A-N,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=A,s.w=C}else{for(var A=s.w||0;A<o+l;A+=65535){var Te=A+65535;if(Te>=o)c[u/8|0]=l,Te=o;u=x0(c,u+1,e.subarray(A,Te))}s.i=o}return qo(a,0,i+bh(u)+r)},hE=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}(),dE=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=hE[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var fE=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new zt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return uE(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)},y0=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 wi=function(e,t){return e[t]|e[t+1]<<8},ni=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},fh=function(e,t){return ni(e,t)+ni(e,t+4)*4294967296},ln=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function pE(e,t){return fE(e,t||{},0,0)}function mE(e,t){return cE(e,{i:2},t&&t.out,t&&t.dictionary)}var b0=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=y0(i,s[1]),s=s[0];if(s instanceof zt)n[o]=[s,a];else n[o+="/"]=[new zt(0),a],b0(s,o,n,i)}},h0=typeof TextEncoder<"u"&&new TextEncoder,xh=typeof TextDecoder<"u"&&new TextDecoder,gE=0;try{xh.decode(v0,{stream:!0}),gE=1}catch(e){}var _E=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:qo(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 d0(e,t){if(t){var n=new zt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(h0)return h0.encode(e);var r=e.length,s=new zt(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 zt(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 qo(s,0,o)}function xE(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(xh)return xh.decode(e);else{var r=_E(e),{s,r:n}=r;if(n.length)bn(8);return s}}var vE=function(e,t){return t+30+wi(e,t+26)+wi(e,t+28)},yE=function(e,t,n){var i=wi(e,t+28),r=xE(e.subarray(t+46,t+46+i),!(wi(e,t+8)&2048)),s=t+46+i,o=ni(e,t+20),a=n&&o==4294967295?bE(e,s):[o,ni(e,t+24),ni(e,t+42)],c=a[0],l=a[1],u=a[2];return[wi(e,t+10),c,l,r,s+wi(e,t+30)+wi(e,t+32),u]},bE=function(e,t){for(;wi(e,t)!=1;t+=4+wi(e,t+2));return[fh(e,t+12),fh(e,t+4),fh(e,t+20)]},vh=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)bn(9);t+=i+4}return t},f0=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=vh(l);if(ln(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)bn(10);if(ln(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)ln(e,t,n.crc),ln(e,t+4,s<0?-s-2:s),ln(e,t+8,n.size);if(ln(e,t+12,c),ln(e,t+14,h),t+=16,o!=null)ln(e,t,u),ln(e,t+6,n.attrs),ln(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;ln(e,t,+m),ln(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},SE=function(e,t,n,i,r){ln(e,t,101010256),ln(e,t+8,n),ln(e,t+10,n),ln(e,t+12,i),ln(e,t+16,r)};function S0(e,t){if(!t)t={};var n={},i=[];b0(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=d0(o),d=h.length,f=l.comment,m=f&&d0(f),_=m&&m.length,p=vh(l.extra);if(d>65535)bn(11);var g=u?pE(c,l):c,y=g.length,S=dE();S.p(c),i.push(y0(l,{size:c.length,crc:S.d(),c:g,f:h,m,u:d!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+d+p+y,s+=76+2*(d+p)+(_||0)+y}var x=new zt(s+22),b=r,M=s-r;for(var T=0;T<i.length;++T){var h=i[T];f0(x,h.o,h,h.f,h.u,h.c.length);var v=30+h.f.length+vh(h.extra);x.set(h.c,h.o+v),f0(x,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+v+(h.m?h.m.length:0)}return SE(x,r,i.length,M,b),x}function w0(e,t){var n={},i=e.length-22;for(;ni(e,i)!=101010256;--i)if(!i||e.length-i>65558)bn(13);var r=wi(e,i+8);if(!r)return{};var s=ni(e,i+16),o=s==4294967295||r==65535;if(o){var a=ni(e,i-12);if(o=ni(e,a)==101075792,o)r=ni(e,a+32),s=ni(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=yE(e,s,o),h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=u[5],g=vE(e,p);if(s=_,!c||c({name:m,size:d,originalSize:f,compression:h}))if(!h)n[m]=qo(e,g,g+d);else if(h==8)n[m]=mE(e.subarray(g,g+d),{out:new zt(f)});else bn(14,"unknown compression type "+h)}return n}var Ei=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function wE(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";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 Yo extends Error{diagnostic;constructor(e,t=wE(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var Fc=1024,zc=4,Bc=8,wh=6,M0=80,ts=256;class dt extends Yo{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var E0=["solid","checker","stripes","gradient","bricks","noise"],A0=["normal","multiply","screen","overlay"],ME=new Set(["__proto__","prototype","constructor"]);function Vc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new dt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new dt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new dt(`${t} must not contain symbol keys.`);if(ME.has(i))throw new dt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new dt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new dt(`${t}.${i} must be a plain JSON data field.`)}return e}function EE(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new dt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new dt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new dt(`${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 dt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function xr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new dt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function ii(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new dt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function es(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new dt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function R0(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 dt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Sh(e,t,n){return R0(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function AE(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>M0||n)throw new dt(`${t} must be 1..${M0} visible characters.`);return e}function TE(e,t,n){if(e===void 0)return n;if(!Ei.includes(e))throw new dt(`${t} must be one of ${Ei.join(", ")}, got ${JSON.stringify(e)}.`);return e}function T0(e,t){let i=(R0(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function RE(e,t){let n=e.blend??"normal";if(!A0.includes(n))throw new dt(`${t}.blend ${JSON.stringify(n)} is not one of ${A0.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function CE(e,t){let n=`proceduralTexture.layers[${t}]`,i=Vc(e,n),r=i.op;if(!E0.includes(r))throw new dt(`${n}.op ${JSON.stringify(r)} is not one of ${E0.join(", ")}.`);let s=RE(i,n),o=Sh(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return xr(i,["op","color","blend","opacity"],n),{op:r,color:ii(i.color,`${n}.color`),...a};case"checker":return xr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:ii(i.colorA,`${n}.colorA`),colorB:ii(i.colorB,`${n}.colorB`),squares:es(i.squares,`${n}.squares`,8,1,ts),...a};case"stripes":return xr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:ii(i.colorA,`${n}.colorA`),colorB:ii(i.colorB,`${n}.colorB`),count:es(i.count,`${n}.count`,8,1,ts),angleDeg:T0(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return xr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:ii(i.from,`${n}.from`),to:ii(i.to,`${n}.to`),angleDeg:T0(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return xr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:ii(i.brick,`${n}.brick`),mortar:ii(i.mortar,`${n}.mortar`),rows:es(i.rows,`${n}.rows`,8,1,ts),cols:es(i.cols,`${n}.cols`,4,1,ts),mortarWidth:Sh(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Sh(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return xr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:ii(i.colorA,`${n}.colorA`),colorB:ii(i.colorB,`${n}.colorB`),scale:es(i.scale,`${n}.scale`,8,1,ts),octaves:es(i.octaves,`${n}.octaves`,3,1,wh),seed:es(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new dt(`${n}.op is unsupported.`)}}function IE(e){let t=Vc(e,"proceduralTexture");if(xr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new dt(`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 Jo(e){let t=Vc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Vc(IE(t),"proceduralTexture"):t;if(xr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new dt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<zc||i>Fc||(i&i-1)!==0)throw new dt(`proceduralTexture.size must be a power of two between ${zc} and ${Fc}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new dt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=EE(r,"proceduralTexture.layers");if(s.length>Bc)throw new dt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Bc}.`);let o=AE(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:TE(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(CE)}}var PE=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]),Ai=(e,t)=>e>>>t|e<<32-t;function Cs(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let y=0;y<16;y++)a[y]=s.getUint32(c+y*4,!1);for(let y=16;y<64;y++){let S=a[y-15],x=a[y-2],b=Ai(S,7)^Ai(S,18)^S>>>3,M=Ai(x,17)^Ai(x,19)^x>>>10;a[y]=a[y-16]+b+a[y-7]+M>>>0}let[l,u,h,d,f,m,_,p]=o;for(let y=0;y<64;y++){let S=Ai(f,6)^Ai(f,11)^Ai(f,25),x=f&m^~f&_,b=p+S+x+PE[y]+a[y]>>>0,M=Ai(l,2)^Ai(l,13)^Ai(l,22),T=l&u^l&h^u&h,v=M+T>>>0;p=_,_=m,m=f,f=d+b>>>0,d=h,h=u,u=l,l=b+v>>>0}let g=[l,u,h,d,f,m,_,p];for(let y=0;y<8;y++)o[y]=o[y]+g[y]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Is="kiln.procedural-rgba.v3.1";var Qo=1024,LE=1048576,ea=64,Gc=64,Ko=256,$c=32,C0=64000000,NE=67108864;function ut(e){throw new dt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var DE=new Set(["__proto__","prototype","constructor"]);function OE(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)ut(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)ut(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))ut(`${r} must be finite.`);return}if(typeof i!=="object")ut(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)ut(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))ut(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)ut(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let h of l){if(typeof h!=="string"||DE.has(h))ut(`${r} has a forbidden key.`);if(o&&h==="length")continue;let d=u[h];if(!d.enumerable||!("value"in d))ut(`${r}.${h} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=c))ut(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)ut(`${r} must be a dense JSON array.`);for(let h of l)if(h!=="length"||!o)n(u[h].value,`${r}.${String(h)}`,s+1)};n(e,"recipe",0)}function $n(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))ut(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))ut(`${n} has unknown field ${r}.`);return i}function Sn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)ut(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function I0(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")ut(`${t} must be boolean.`);return e}function Hc(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)ut(`${n} must be a ${t}-element array.`);return e.map((s,o)=>Sn(s,i,r,`${n}[${o}]`))}function P0(e,t){let n=Hc(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function L0(e,t,n){let i=$n(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:Sn(i.x,-4096,4096,`${t}.x`),y:Sn(i.y,-4096,4096,`${t}.y`),width:Sn(i.width,1,2048,`${t}.width`),height:Sn(i.height,1,2048,`${t}.height`)}}function UE(e,t){let n=$n(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...L0(n,t,n.kind)};if(n.kind==="polygon"){$n(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>Gc)ut(`${t}.points requires 3..${Gc} vertices.`);return{kind:"polygon",points:i.map((r,s)=>Hc(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return $n(n,["kind","from","to","width"],t),{kind:"line",from:Hc(n.from,2,`${t}.from`,-4096,4096),to:Hc(n.to,2,`${t}.to`,-4096,4096),width:Sn(n.width,1,2048,`${t}.width`)};return ut(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function N0(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function kE(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function FE(e,t,n,i=0,r=0){let[s,o,a,c]=N0(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function Wc(e){OE(e);let t=$n(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)ut("schemaVersion must be 3.");let n=Sn(t.width,4,Qo,"width"),i=Sn(t.height,4,Qo,"height"),r=n*i;if(r>LE)ut("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ei.includes(s))ut("usage must be a known texture usage.");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))ut("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>ea)ut(`operations must be an array with at most ${ea} entries.`);let l=r,u=0,h=0,d=c.map((p,g)=>{let y=`operations[${g}]`,S=$n(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],y);if(S.op==="legacy-v2"){$n(S,["op","spec","alpha","opacity"],y);let q=$n(S.spec,["schemaVersion","size","usage","name","layers"],`${y}.spec`);if(q.schemaVersion!==2)ut(`${y}.spec requires explicit schemaVersion 2.`);let H=Jo(q);if(H.size!==n||H.size!==i||H.usage!==s)ut(`${y} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+H.layers.reduce((ee,J)=>ee+(J.op==="noise"?J.octaves*16:4),0)),h+=r*4,{op:"legacy-v2",spec:H,alpha:Sn(S.alpha,0,255,`${y}.alpha`,255),opacity:Sn(S.opacity,0,255,`${y}.opacity`,255)}}let x=UE(S.shape,`${y}.shape`),b=kE(x),[M,T,v,A]=FE(x,n,i),V=Math.max(0,v-M)*Math.max(0,A-T);if(S.op==="mask")return $n(S,["op","shape","alpha","invert"],y),l+=r+V*b,{op:"mask",shape:x,alpha:Sn(S.alpha,0,255,`${y}.alpha`,255),invert:I0(S.invert,`${y}.invert`)};if(S.op!=="paint"&&S.op!=="stamps")return ut(`${y}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:x,rgba:P0(S.rgba,`${y}.rgba`),opacity:Sn(S.opacity,0,255,`${y}.opacity`,255)};if(S.op==="paint")return $n(S,["op","shape","rgba","opacity"],y),l+=V*(b+1),{op:"paint",...C};if($n(S,["op","shape","rgba","opacity","count","seed","area","periodic"],y),!o)ut("stamps are supported only for color usages albedo and emissive.");let N=Sn(S.count,1,Ko,`${y}.count`),Y=I0(S.periodic,`${y}.periodic`),[D,W,z,P]=N0(x);if(Y&&(z-D>n||P-W>i))ut(`${y} periodic shape bounds must fit one surface period.`);if(u+=N*(Y?9:1),u>Ko)ut(`expanded stamps budget exceeds ${Ko}.`);return l+=N*(Y?9:1)*Math.min(n,Math.ceil(z-D)+1)*Math.min(i,Math.ceil(P-W)+1)*(b+1),{op:"stamps",...C,count:N,seed:Sn(S.seed,0,4294967295,`${y}.seed`),area:L0(S.area,`${y}.area`),periodic:Y}}),f;if(t.palette!==void 0){if(!o)ut("palette and dither are supported only for color usages albedo and emissive.");let p=$n(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>$c)ut(`palette.colors requires 1..${$c} entries.`);let y=p.dither===void 0?"none":p.dither;if(y!=="none"&&y!=="bayer4")ut("palette.dither must be none or bayer4.");f={colors:g.map((S,x)=>Sn(S,0,16777215,`palette.colors[${x}]`)),dither:y},l+=r*(g.length+1)}if(l>C0)ut(`estimated work budget ${l} exceeds ${C0}.`);if(r*4+h>NE)ut("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:P0(t.background,"background"),operations:d,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)ut("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+h}}function Mh(e){return Wc(e).spec}function zE(e){return Wc(e).canonicalJson}function Eh(e){return`sha256:${Cs(`${Is}
-${zE(e)}`)}`}var Ah=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],Th=["nearest","linear"],ta=["repeat","clamp-to-edge","mirrored-repeat"];function Zc(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new dt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new dt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new dt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Ah,magFilter:Th,wrapS:ta,wrapT:ta};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new dt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new dt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Ps="kiln.texture-atlas.v1.1",wn=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728});class O0 extends Yo{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function qe(e){throw new O0(e)}function Ch(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>wn.jsonBytes)qe("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)qe("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))qe("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)qe("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")qe("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)qe("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))qe("JSON array budget exceeded.");let h=Reflect.ownKeys(o);if(h.length>1024||c&&h.length!==u+1)qe("dense bounded JSON fields are required.");r(2+Math.max(0,h.length-(c?1:0)-1));for(let d of h){if(c&&d==="length")continue;if(typeof d!=="string"||["__proto__","prototype","constructor"].includes(d))qe("forbidden JSON field.");if(d.length>4096)qe("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(d)).length+1);let f=Object.getOwnPropertyDescriptor(o,d);if(!f.enumerable||!("value"in f))qe("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=u))qe("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function En(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))qe(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))qe(`${n} has an unknown field.`);return i}function Wn(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)qe(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function vr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))qe(`${t} must be an exact SHA-256 hash.`);return e}function D0(e,t){let n=En(e,["x","y","width","height"],t);return{x:Wn(n.x,0,4096,`${t}.x`),y:Wn(n.y,0,4096,`${t}.y`),width:Wn(n.width,1,4096,`${t}.width`),height:Wn(n.height,1,4096,`${t}.height`)}}function na(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function U0(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)qe("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)qe("source crop/content dimensions must match; resampling is unsupported.")}function Rh(e){return e.kind==="procedural"?`procedural:${Eh(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}function ia(e){Ch(e);let t=En(e,["schemaVersion","width","height","usage","sampler","regions"],"atlas");if(t.schemaVersion!==1)qe("schemaVersion must be 1.");let n=Wn(t.width,4,wn.edge,"width"),i=Wn(t.height,4,wn.edge,"height");if(!Ei.includes(t.usage))qe("usage must be a texture usage.");let r=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>wn.regions)qe("regions must contain 1..64 entries.");let s=t.regions.map((c,l)=>{let u=En(c,["name","content","gutter","edgeMode","source","crop"],`regions[${l}]`);if(typeof u.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(u.name))qe("region name must be a stable lowercase identifier.");let h=D0(u.content,"content"),d=u.gutter===void 0?2:Wn(u.gutter,0,32,"gutter"),f=u.edgeMode===void 0?"copy-edge":u.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(f))qe("unsupported edgeMode.");if(f==="mask-rgb-dilate"&&r!=="albedo"&&r!=="emissive")qe("mask RGB dilation requires color usage.");let m=En(u.source,["kind","spec","resourceId","pin","expected"],"source"),_,p=u.crop===void 0?void 0:D0(u.crop,"crop");if(m.kind==="procedural"){En(m,["kind","spec"],"procedural source");let S=Wc(m.spec);if(S.spec.usage!==r)qe("source usage does not match atlas usage.");_={kind:"procedural",spec:S.spec},p??={x:0,y:0,width:S.spec.width,height:S.spec.height},U0(p,h,S.spec.width,S.spec.height)}else if(m.kind==="resource"){if(En(m,["kind","resourceId","pin","expected"],"resource source"),typeof m.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(m.resourceId))qe("source resourceId must be an exact returned map ID.");let S=En(m.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof S.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(S.resourceId))qe("pin resourceId must be a material ID.");let x=vr(S.revisionId,"pin revisionId"),b=vr(S.sha256,"pin sha256");if(x!==b)qe("source pin revision/hash mismatch.");let M;if(m.expected!==void 0){let T=En(m.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");M={...T.width===void 0?{}:{width:Wn(T.width,1,4096,"expected.width")},...T.height===void 0?{}:{height:Wn(T.height,1,4096,"expected.height")},...T.imageSha256===void 0?{}:{imageSha256:vr(T.imageSha256,"expected.imageSha256")},...T.decodedPixelHash===void 0?{}:{decodedPixelHash:vr(T.decodedPixelHash,"expected.decodedPixelHash")}}}if(_={kind:"resource",resourceId:m.resourceId,pin:{resourceId:S.resourceId,revisionId:x,sha256:b},...M?{expected:M}:{}},p&&(p.width!==h.width||p.height!==h.height))qe("source crop/content dimensions must match; resampling is unsupported.")}else qe("source kind must be procedural or pinned resource.");let g={name:u.name,content:h,gutter:d,edgeMode:f,source:_,...p?{crop:p}:{}},y=na(g);if(y.x<0||y.y<0||y.x+y.width>n||y.y+y.height>i)qe("padded allocation is out of bounds.");return g}).sort((c,l)=>c.name<l.name?-1:c.name>l.name?1:0);if(new Set(s.map((c)=>c.name)).size!==s.length)qe("duplicate region name.");for(let c=0;c<s.length;c++)for(let l=c+1;l<s.length;l++){let u=na(s[c]),h=na(s[l]);if(u.x<h.x+h.width&&h.x<u.x+u.width&&u.y<h.y+h.height&&h.y<u.y+u.height)qe(`padded allocations overlap: ${s[c].name}, ${s[l].name}.`)}if(new Set(s.map((c)=>Rh(c.source))).size>wn.sources)qe("distinct source budget exceeds 16.");let o;try{o=Zc(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(c){qe(`sampler: ${c.message}`)}let a={schemaVersion:1,width:n,height:i,usage:r,sampler:o,regions:s};if(new TextEncoder().encode(JSON.stringify(a)).length>wn.jsonBytes)qe("canonical JSON byte budget exceeded.");return a}function BE(e){return JSON.stringify(ia(e))}function VE(e){return`sha256:${Cs(`${Ps}
-${BE(e)}`)}`}function Ti(e){Ch(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 HE(e){return`sha256:${Cs(`kiln.atlas-layout.v1
-${Ti({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:na(t)}))})}`)}`}function Ih(e,t){Ch(e);let n=ia(t),i=En(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Ps||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")qe("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ti(i.sampler)!==Ti(n.sampler)||i.specHash!==VE(n)||i.layoutHash!==HE(n))qe("manifest sampler/spec/layout identity mismatch.");vr(i.decodedPixelHash,"manifest decodedPixelHash"),vr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[Rh(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)qe("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=En(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))qe("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)qe("manifest source identity mismatch.");let h=Wn(l.width,1,4096,"manifest source width"),d=Wn(l.height,1,4096,"manifest source height");if(vr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(En(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),h!==u.spec.width||d!==u.spec.height||l.recipeHash!==Eh(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")qe("manifest procedural source identity mismatch.")}else{En(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=En(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==h||f.height!==d||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))qe("manifest pinned resource descriptor mismatch.");if(vr(f.imageSha256,"manifest source imageSha256"),Wn(f.encodedByteLength,1,wn.encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)qe("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))qe("manifest source expectation mismatch.")}}s.set(l.id,{width:h,height:d})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=En(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),h=Rh(l.source),d=s.get(h),f=l.crop??{x:0,y:0,width:d.width,height:d.height};if(U0(f,l.content,d.width,d.height),u.name!==l.name||u.sourceId!==h||Ti(u.content)!==Ti(l.content)||Ti(u.allocation)!==Ti(na(l))||Ti(u.crop)!==Ti(f))qe("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${Cs(`kiln.atlas-manifest.v1
-${Ti(a)}`)}`)qe("manifest hash mismatch.");return structuredClone(e)}var GE=(()=>{let e=lt().int().min(0).max(16777215),t=lt().int().min(1).max(ts),n=lt().min(-36000).max(36000),i=lt().min(0).max(1),r={blend:Tt(["normal","multiply","screen","overlay"]),opacity:i};return _e({schemaVersion:He(2),size:lt().int().min(zc).max(Fc),usage:Tt(Ei),name:Ne().min(1).max(80).optional(),layers:tt(ei("op",[_e({op:He("solid"),color:e,...r}).strict(),_e({op:He("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),_e({op:He("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),_e({op:He("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),_e({op:He("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),_e({op:He("noise"),colorA:e,colorB:e,scale:t,octaves:lt().int().min(1).max(wh),seed:lt().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(Bc)}).strict()})();function k0(e,t=GE){let n=(H,ee)=>lt().int().min(H).max(ee),i=n(0,255),r=n(-4096,4096),s=n0([r,r]),o=n0([i,i,i,i]),a=Tt(Ei),c=KM(["sha256:",Ne().regex(/^[a-f0-9]{64}$/)]),l=Ne().min(1).max(80),u=Ne().regex(/^[a-z][a-z0-9_-]{0,79}$/),h=Ne().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),d={width:n(1,4096),height:n(1,4096)},f=_e({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=_e({x:n(0,4096),y:n(0,4096),...d}).strict(),_=ei("kind",[f.extend({kind:He("rectangle")}).strict(),f.extend({kind:He("ellipse")}).strict(),_e({kind:He("polygon"),points:tt(s).min(3).max(Gc)}).strict(),_e({kind:He("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=_e({op:He("paint"),shape:_,rgba:o,opacity:i}).strict(),g=_e({op:He("mask"),shape:_,alpha:i,invert:Qr()}).strict(),y=_e({op:He("stamps"),shape:_,rgba:o,opacity:i,count:n(1,Ko),seed:n(0,4294967295),area:f,periodic:Qr()}).strict(),S=_e({op:He("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),x=_e({colors:tt(n(0,16777215)).min(1).max($c),dither:Tt(["none","bayer4"])}).strict(),b={schemaVersion:He(3),width:n(4,Qo),height:n(4,Qo),usage:a,name:l.optional(),background:o},M=_e({...b,operations:tt(ei("op",[p,g,y,S.extend({spec:t})])).max(ea),palette:x.optional()}).strict(),T=_e({...b,usage:a.optional(),background:o.optional(),operations:tt(ei("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),y.partial({opacity:!0,periodic:!0}),S.partial({alpha:!0,opacity:!0})])).max(ea),palette:x.partial({dither:!0}).optional()}).strict(),v=_e({minFilter:Tt(Ah),magFilter:Tt(Th),wrapS:Tt(ta),wrapT:Tt(ta)}).strict(),A=_e({resourceId:u,revisionId:c,sha256:c}).strict(),V=_e({kind:He("resource"),resourceId:h,pin:A,expected:_e({...d,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=_e({name:u,content:m,gutter:n(0,32),edgeMode:Tt(["copy-edge","mask-rgb-dilate"]),source:ei("kind",[_e({kind:He("procedural"),spec:M}).strict(),V]),crop:m.optional()}).strict(),N={schemaVersion:He(1),width:n(4,wn.edge),height:n(4,wn.edge),usage:a,sampler:v},Y=_e({...N,regions:tt(C).min(1).max(wn.regions)}).strict(),D=_e({...N,sampler:v.optional(),regions:tt(C.extend({source:ei("kind",[_e({kind:He("procedural"),spec:T}).strict(),V])}).partial({gutter:!0,edgeMode:!0})).min(1).max(wn.regions)}).strict(),W=_e({materialId:u,revisionId:c,resourceId:h,slot:Tt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:Tt(["srgb","linear"]),...d,encodedByteLength:n(1,wn.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),z={id:Ne().min(1).max(1024),...d,decodedPixelHash:c},P=ei("kind",[_e({...z,kind:He("procedural"),recipeHash:c,compilerId:He(Is)}).strict(),_e({...z,kind:He("resource"),descriptor:W}).strict()]),q=_e({version:He("kiln.atlas-manifest.v1"),compilerId:He(Ps),width:N.width,height:N.height,usage:a,origin:He("top-left"),sampler:v,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:tt(P).min(1).max(wn.sources),regions:tt(_e({name:u,content:m,allocation:m,crop:m,sourceId:Ne().min(1).max(1024)}).strict()).min(1).max(wn.regions),manifestHash:c}).strict();return{portableSamplerSchema:v,proceduralTextureSpecV3Schema:T,canonicalProceduralTextureSpecV3Schema:M,textureAtlasSpecV1Schema:D,canonicalTextureAtlasSpecV1Schema:Y,textureAtlasManifestV1Schema:q,materialMapPinSchema:A,verifiedPinnedMaterialMapDescriptorSchema:W}}var dn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),z0=["baseColor","normal","metallicRoughness","emissive","occlusion"],B0={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Ns=Ne().regex(/^[a-z][a-z0-9_-]{0,79}$/),Ci=Ne().regex(/^sha256:[a-f0-9]{64}$/),Ri=Ne().min(1).max(1000),F0=Ne().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),V0=_e({id:Ns,kind:Tt(["external","procedural"]),provider:Ri,creator:Ri,assetId:Ri.optional(),assetUrl:F0.optional(),accessedAt:Ne().datetime().optional(),license:_e({spdx:Ri,url:F0,attribution:Ne().max(4000)}).strict(),originalFiles:tt(_e({name:Ne().min(1).max(200),sha256:Ci,bytes:lt().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"})}),H0=_e({operation:Ri,tool:Ri,version:Ri,parameters:Nc(Ne().max(100),Wo([Ne().max(2000),lt().finite(),Qr()])).optional()}).strict(),ri=lt().int().min(0).max(16777215),ra=lt().int().min(1).max(256),Ls={blend:Tt(["normal","multiply","screen","overlay"]).default("normal"),opacity:lt().min(0).max(1).default(1)},oa=_e({schemaVersion:He(2),size:lt().int().min(4).max(1024).default(256),usage:Tt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Ne().min(1).max(80).optional(),layers:tt(ei("op",[_e({op:He("solid"),color:ri,...Ls}).strict(),_e({op:He("checker"),colorA:ri,colorB:ri,squares:ra.default(8),...Ls}).strict(),_e({op:He("stripes"),colorA:ri,colorB:ri,count:ra.default(8),angleDeg:lt().min(-36000).max(36000).default(0),...Ls}).strict(),_e({op:He("gradient"),from:ri,to:ri,angleDeg:lt().min(-36000).max(36000).default(0),...Ls}).strict(),_e({op:He("bricks"),brick:ri,mortar:ri,rows:ra.default(8),cols:ra.default(4),mortarWidth:lt().min(0).max(1).default(0.06),stagger:lt().min(0).max(1).default(0.5),...Ls}).strict(),_e({op:He("noise"),colorA:ri,colorB:ri,scale:ra.default(8),octaves:lt().int().min(1).max(6).default(3),seed:lt().int().min(-2147483648).max(2147483647).default(0),...Ls}).strict()])).min(1).max(8)}).strict(),Nh=_e({kind:He("normal-from-height"),strength:lt().finite().positive().max(64)}).strict(),$E=_e({compiler:He("kiln.procedural-texture.v2"),spec:oa,derive:Nh.optional(),recipeHash:Ci,pixelHash:Ci,encoder:_e({name:He("sharp"),version:Ri}).strict()}).strict(),G0=_e({baseColor:lt().int().min(0).max(16777215).optional(),roughness:lt().min(0).max(1).default(1),metalness:lt().min(0).max(1).default(0),emissive:lt().int().min(0).max(16777215).optional(),emissiveIntensity:lt().min(0).max(64).default(1),alphaMode:Tt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:lt().min(0).max(1).default(0.5),doubleSided:Qr().default(!1)}).strict(),sa=_e({schemaVersion:He(1),materialId:Ns,revisionId:Ci,name:Ne().min(1).max(200),tags:tt(Ne().min(1).max(80)).max(30),tileable:Qr(),physicalSizeMeters:_e({width:lt().finite().positive().max(1e5),height:lt().finite().positive().max(1e5)}).strict().optional(),parameters:G0,sources:tt(V0).min(1).max(20),maps:tt(_e({slot:Tt(z0),file:Tt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Ci,bytes:lt().int().positive().max(dn.maxMapBytes),width:lt().int().positive().max(dn.maxMapEdge),height:lt().int().positive().max(dn.maxMapEdge),usage:Tt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Tt(["srgb","linear"]),normalConvention:He("opengl").optional(),channelPacking:He("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Ns,originalFile:Ne().min(1).max(200).optional(),transforms:tt(H0).max(30),procedural:$E.optional()}).strict()).min(1).max(5)}).strict(),Ph=_e({materialId:Ns,name:Ne().min(1).max(200),tags:tt(Ne().min(1).max(80)).max(30).optional(),tileable:Qr(),physicalSizeMeters:_e({width:lt().finite().positive().max(1e5),height:lt().finite().positive().max(1e5)}).strict().optional(),parameters:G0.partial().optional(),sources:tt(V0).min(1).max(20),maps:tt(_e({slot:Tt(z0),sourceId:Ns,transforms:tt(H0).max(30),normalConvention:He("opengl").optional(),channelPacking:He("r-occlusion-g-roughness-b-metallic").optional(),procedural:oa,derive:Nh.optional()}).strict()).min(1).max(5)}).strict(),Lh=_e({schemaVersion:He(1),records:tt(_e({manifest:sa,files:Nc(Ne().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Ne().max(Math.ceil(dn.maxMapBytes/3)*4))}).strict()).max(dn.maxPayloadRecords)}).strict();function Os(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");Os(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Zt(e){Os(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 WE(e){if(Os(e),new TextEncoder().encode(JSON.stringify(e)).length>dn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=sa.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!==B0[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(Zt(r.procedural.spec)!==Zt(Jo(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>dn.maxRecordBytes||i>dn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Ds=k0(oa),$0=Ds.portableSamplerSchema.refine((e)=>{try{return Zt(e)===Zt(Zc(e))}catch{return!1}}),ZE=Ds.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return Zt(e)===Zt(Mh(e))}catch{return!1}}),jE=Ds.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return Zt(e)===Zt(ia(e))}catch{return!1}}),XE=Ds.textureAtlasManifestV1Schema,qE=_e({resourceId:Ns,revisionId:Ci,sha256:Ci}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),YE=ei("kind",[_e({kind:He("procedural"),compilerId:Tt(["kiln.procedural-texture.v2",Is]),spec:Wo([oa,ZE]),recipeHash:Ci,pixelHash:Ci,encoder:_e({name:He("sharp"),version:Ri}).strict(),derive:Nh.optional()}).strict(),_e({kind:He("atlas"),compilerId:He(Ps),spec:jE,manifest:XE,encoder:_e({name:He("sharp"),version:Ri}).strict()}).strict().superRefine((e,t)=>{try{Ih(e.manifest,e.spec)}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),W0=sa.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:He(2),dependencies:tt(qE).max(16),maps:tt(sa.shape.maps.element.omit({procedural:!0}).extend({sampler:$0,pixelHash:Ci,recipe:YE.optional()}).strict()).min(1).max(5)}).strict(),JE=ei("schemaVersion",[sa,W0]),KE=Lh.extend({schemaVersion:He(2),records:tt(Lh.shape.records.element.extend({manifest:JE}).strict()).max(dn.maxPayloadRecords)}).strict(),Z0=ei("schemaVersion",[Lh,KE]);function j0(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var QE=Ph.extend({schemaVersion:He(2),maps:tt(Ph.shape.maps.element.omit({procedural:!0}).extend({sampler:$0,procedural:Wo([oa,Ds.proceduralTextureSpecV3Schema.refine((e)=>{try{return Mh(e),!0}catch{return!1}})]).optional(),atlas:Ds.textureAtlasSpecV1Schema.refine((e)=>{try{return ia(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),C2=Wo([Ph,QE]);function Us(e){if(Os(e),new TextEncoder().encode(JSON.stringify(e)).length>dn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return WE(e);let t=W0.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==B0[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Is||c.derive||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||Zt(l)!==Zt(Jo(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(Ih(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||Zt(c.spec.sampler)!==Zt(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>dn.maxRecordBytes||i>dn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var Zn=67108864,Dh=Ne().regex(/^[a-z][a-z0-9_-]{0,79}$/),eA=Ne().regex(/^sha256:[a-f0-9]{64}$/),X0=_e({version:He("kiln.asset.v1"),assetId:Dh,revisionId:Dh,parentRevision:Dh.optional(),name:Ne().min(1).max(200),tags:tt(Ne().max(80)).max(30),createdAt:Ne().datetime(),description:Ne().max(4000).optional(),brief:Ne().max(8000).optional(),attribution:_e({model:Ne().max(200).optional(),harness:Ne().max(200).optional(),author:Ne().max(200).optional()}).optional(),editable:Qr(),files:Nc(Ne(),_e({sha256:eA,bytes:lt().int().nonnegative().max(Zn)})),build:_e({engine:Ne(),options:Nc(Ne(),Kr()),warnings:tt(Ne()),integration:Kr().optional(),qa:Kr().optional(),dependencies:tt(Kr()).optional(),rebuild:Tt(["engine-required","external-dependencies-required"])}).optional(),preview:_e({fidelity:Kr().optional(),error:Ne().optional(),backdrop:Tt(o0).optional()}).optional()}),aa="materials.kiln.json",q0=25165824;function Oh(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=Us(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&Zt(o)!==Zt(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>dn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function Y0(e,t=!1){let n=Oh(e),i=new Map(n.map((h)=>[`${h.materialId}/${h.revisionId}`,Zt(h)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Os(e.materialResources);let r=Z0.parse(e.materialResources),s=0,o=0,a=new Map;for(let h of r.records){let d=Us(h.manifest),f=`${h.manifest.materialId}/${h.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==Zt(d))throw Error("Asset material closure mismatch");if(a.set(f,d),Object.keys(h.files).length!==h.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of h.manifest.maps){if(h.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>dn.maxPayloadBytes||o>dn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(h)=>{if(l.has(h))throw Error("Asset material closure contains a cycle");if(c.has(h))return;let d=a.get(h);if(!d)throw Error("Asset material closure incomplete");l.add(h);for(let f of j0(d))u(`${f.resourceId}/${f.revisionId}`);l.delete(h),c.add(h)};for(let h of i.keys())u(h);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var tA=new Set(["asset.glb","source.kiln.js","preview.png"]);function jc(e){let t=X0.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(!tA.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>Zn||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");Uh(e.files["asset.glb"]),Y0(e)}function Uh(e){if(e.length<20||e.length>Zn)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 kh(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){jc(i),Y0(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>q0)throw Error("Asset material payload exceeds byte limit");t[r+aa]=s}}for(let i of Object.values(t))n+=i.length;if(n>Zn)throw Error("Bundle exceeds 64 MiB");return S0(t,{level:0})}function J0(e){if(e.length>Zn+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=w0(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>Zn||n>500||o.name.endsWith(`/${aa}`)&&o.originalSize>q0||!/^[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=X0.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+aa])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+aa])),s.add(l+aa);jc(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 Uv="186",Tr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Rr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},kv=0,ld=1,Fv=2;var va=1,zv=2,to=3,Cr=0,mn=1,Yn=2,Di=0,ya=1,ud=2,hd=3,dd=4,Bv=5;var no=100,Vv=101,Hv=102,Gv=103,$v=104,Wv=200,Zv=201,jv=202,Xv=203,qv=204,Yv=205,Jv=206,Kv=207,Qv=208,ey=209,ty=210,ny=211,iy=212,ry=213,sy=214,oy=0,ay=1,cy=2,fd=3,ly=4,uy=5,hy=6,dy=7,fy=0,py=1,my=2,ui=0,pd=1,md=2,gd=3,ba=4,_d=5,xd=6,vd=7;var io=301,cs=302,Sl=303,wl=304,Sa=306,ro=1000,so=1001,Ml=1002,hi=1003,El=1004;var ls=1005;var sn=1006,oo=1007;var Oi=1008;var di=1009,gy=1010,_y=1011,wa=1012,yd=1013,Ir=1014,or=1015,Ui=1016,bd=1017,Sd=1018,ao=1020,xy=35902,vy=35899,yy=1021,by=1022,ki=1023,us=1026,hs=1027,Sy=1028,wd=1029,ds=1030,Md=1031;var Ed=1033,Al=33776,Tl=33777,Rl=33778,Cl=33779,Ad=35840,Td=35841,Rd=35842,Cd=35843,Id=36196,Pd=37492,Ld=37496,Nd=37488,Dd=37489,Il=37490,Od=37491,Ud=37808,kd=37809,Fd=37810,zd=37811,Bd=37812,Vd=37813,Hd=37814,Gd=37815,$d=37816,Wd=37817,Zd=37818,jd=37819,Xd=37820,qd=37821,Yd=36492,Jd=36494,Kd=36495,Qd=36283,ef=36284,Pl=36285,tf=36286;var nf=2300,Ll=2301;var rf=0,Ma=1,co=2;var sf=0,wy=1,fs="",Pr="srgb",Un="srgb-linear",of="linear",Rt="srgb";var My=512,Ey=513,Ay=514,Nl=515,Ty=516,Ry=517,Dl=518,Cy=519;var af="300 es",cf=2000;function nA(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function iA(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ks(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Iy(){let e=Ks("canvas");return e.style.display="block",e}var Q0={},Qs=null;function xa(...e){let t="THREE."+e.shift();if(Qs)Qs("log",t,...e);else console.log(t,...e)}function Py(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 ze(...e){e=Py(e);let t="THREE."+e.shift();if(Qs)Qs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function je(...e){e=Py(e);let t="THREE."+e.shift();if(Qs)Qs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function os(...e){let t=e.join(" ");if(t in Q0)return;Q0[t]=!0,ze(...e)}function Ly(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 Ny={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class fi{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 fn=["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"],ev=1234567,ga=Math.PI/180,as=180/Math.PI;function li(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(fn[e&255]+fn[e>>8&255]+fn[e>>16&255]+fn[e>>24&255]+"-"+fn[t&255]+fn[t>>8&255]+"-"+fn[t>>16&15|64]+fn[t>>24&255]+"-"+fn[n&63|128]+fn[n>>8&255]+"-"+fn[n>>16&255]+fn[n>>24&255]+fn[i&255]+fn[i>>8&255]+fn[i>>16&255]+fn[i>>24&255]).toLowerCase()}function it(e,t,n){return Math.max(t,Math.min(n,e))}function lf(e,t){return(e%t+t)%t}function rA(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function sA(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function _a(e,t,n){return(1-n)*e+n*t}function oA(e,t,n,i){return _a(e,t,1-Math.exp(-n*i))}function aA(e,t=1){return t-Math.abs(lf(e,t*2)-t)}function cA(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 lA(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 uA(e,t){return e+Math.floor(Math.random()*(t-e+1))}function hA(e,t){return e+Math.random()*(t-e)}function dA(e){return e*(0.5-Math.random())}function fA(e){if(e!==void 0)ev=e;let t=ev+=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 pA(e){return e*ga}function mA(e){return e*as}function gA(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function _A(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function xA(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function vA(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:ze("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ci(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 vt(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 Ea={DEG2RAD:ga,RAD2DEG:as,generateUUID:li,clamp:it,euclideanModulo:lf,mapLinear:rA,inverseLerp:sA,lerp:_a,damp:oA,pingpong:aA,smoothstep:cA,smootherstep:lA,randInt:uA,randFloat:hA,randFloatSpread:dA,seededRandom:fA,degToRad:pA,radToDeg:mA,isPowerOfTwo:gA,ceilPowerOfTwo:_A,floorPowerOfTwo:xA,setQuaternionFromProperEuler:vA,normalize:vt,denormalize:ci};class Ge{static{Ge.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=it(this.x,e.x,t.x),this.y=it(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=it(this.x,e,t),this.y=it(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(it(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(it(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 nn{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(_),y=Math.sin(g);p=Math.sin(p*g)/y,o=Math.sin(o*g)/y,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:ze("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(it(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(tv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(tv.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=it(this.x,e.x,t.x),this.y=it(this.y,e.y,t.y),this.z=it(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=it(this.x,e,t),this.y=it(this.y,e,t),this.z=it(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(it(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 Fh.copy(this).projectOnVector(e),this.sub(Fh)}reflect(e){return this.sub(Fh.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(it(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 Fh=new F,tv=new nn;class Ye{static{Ye.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],y=i[4],S=i[7],x=i[2],b=i[5],M=i[8];return r[0]=s*m+o*g+a*x,r[3]=s*_+o*y+a*b,r[6]=s*p+o*S+a*M,r[1]=c*m+l*g+u*x,r[4]=c*_+l*y+u*b,r[7]=c*p+l*S+u*M,r[2]=h*m+d*g+f*x,r[5]=h*_+d*y+f*b,r[8]=h*p+d*S+f*M,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 os("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(zh.makeScale(e,t)),this}rotate(e){return os("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(zh.makeRotation(-e)),this}translate(e,t){return os("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(zh.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 zh=new Ye,nv=new Ye().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),iv=new Ye().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function yA(){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=sr(r.r),r.g=sr(r.g),r.b=sr(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=Js(r.r),r.g=Js(r.g),r.b=Js(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 os("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return os("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:nv,fromXYZ:iv,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:nv,fromXYZ:iv,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var nt=yA();function sr(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Js(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ks;class uf{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(ks===void 0)ks=Ks("canvas");ks.width=e.width,ks.height=e.height;let i=ks.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ks}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=Ks("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]=sr(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(sr(t[n]/255)*255);else t[n]=sr(t[n]);return{data:t,width:e.width,height:e.height}}else return ze("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var bA=0;class Aa{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:bA++}),this.uuid=li(),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(Bh(i[s].image));else r.push(Bh(i[s]))}else r=Bh(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Bh(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return uf.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 ze("Texture: Unable to serialize Texture."),{}}var SA=0,Vh=new F;class Vt extends fi{constructor(e=Vt.DEFAULT_IMAGE,t=Vt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Vt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:SA++}),this.uuid=li(),this.name="",this.source=new Aa(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 Ge(0,0),this.repeat=new Ge(1,1),this.center=new Ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ye,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(Vh).x}get height(){return this.source.getSize(Vh).y}get depth(){return this.source.getSize(Vh).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){ze(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){ze(`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++}}Vt.DEFAULT_IMAGE=null;Vt.DEFAULT_MAPPING=300;Vt.DEFAULT_ANISOTROPY=1;class yt{static{yt.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 y=(c+1)/2,S=(d+1)/2,x=(p+1)/2,b=(l+h)/4,M=(u+m)/4,T=(f+_)/4;if(y>S&&y>x)if(y<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(y),i=b/n,r=M/n;else if(S>x)if(S<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(S),n=b/i,r=T/i;else if(x<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(x),n=M/r,i=T/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=it(this.x,e.x,t.x),this.y=it(this.y,e.y,t.y),this.z=it(this.z,e.z,t.z),this.w=it(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=it(this.x,e,t),this.y=it(this.y,e,t),this.z=it(this.z,e,t),this.w=it(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(it(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 hf extends fi{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 yt(0,0,e,t),this.scissorTest=!1,this.viewport=new yt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Vt(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 Aa(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 kn extends hf{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Ol extends Vt{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 df extends Vt{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 Ke{static{Ke.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 Ke().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(wA,e,MA)}lookAt(e,t,n){let i=this.elements;if(Dn.subVectors(e,t),Dn.lengthSq()===0)Dn.z=1;if(Dn.normalize(),yr.crossVectors(n,Dn),yr.lengthSq()===0){if(Math.abs(n.z)===1)Dn.x+=0.0001;else Dn.z+=0.0001;Dn.normalize(),yr.crossVectors(n,Dn)}return yr.normalize(),Xc.crossVectors(Dn,yr),i[0]=yr.x,i[4]=Xc.x,i[8]=Dn.x,i[1]=yr.y,i[5]=Xc.y,i[9]=Dn.y,i[2]=yr.z,i[6]=Xc.z,i[10]=Dn.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],y=n[7],S=n[11],x=n[15],b=i[0],M=i[4],T=i[8],v=i[12],A=i[1],V=i[5],C=i[9],N=i[13],Y=i[2],D=i[6],W=i[10],z=i[14],P=i[3],q=i[7],H=i[11],ee=i[15];return r[0]=s*b+o*A+a*Y+c*P,r[4]=s*M+o*V+a*D+c*q,r[8]=s*T+o*C+a*W+c*H,r[12]=s*v+o*N+a*z+c*ee,r[1]=l*b+u*A+h*Y+d*P,r[5]=l*M+u*V+h*D+d*q,r[9]=l*T+u*C+h*W+d*H,r[13]=l*v+u*N+h*z+d*ee,r[2]=f*b+m*A+_*Y+p*P,r[6]=f*M+m*V+_*D+p*q,r[10]=f*T+m*C+_*W+p*H,r[14]=f*v+m*N+_*z+p*ee,r[3]=g*b+y*A+S*Y+x*P,r[7]=g*M+y*V+S*D+x*q,r[11]=g*T+y*C+S*W+x*H,r[15]=g*v+y*N+S*z+x*ee,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,y=o*d-c*u,S=o*h-a*u,x=s*d-c*l,b=s*h-a*l,M=s*u-o*l;return t*(m*g-_*y+p*S)-n*(f*g-_*x+p*b)+i*(f*y-m*x+p*M)-r*(f*S-m*b+_*M)}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,y=t*a-i*s,S=t*c-r*s,x=n*a-i*o,b=n*c-r*o,M=i*c-r*a,T=l*m-u*f,v=l*_-h*f,A=l*p-d*f,V=u*_-h*m,C=u*p-d*m,N=h*p-d*_,Y=g*N-y*C+S*V+x*A-b*v+M*T;if(Y===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let D=1/Y;return e[0]=(o*N-a*C+c*V)*D,e[1]=(i*C-n*N-r*V)*D,e[2]=(m*M-_*b+p*x)*D,e[3]=(h*b-u*M-d*x)*D,e[4]=(a*A-s*N-c*v)*D,e[5]=(t*N-i*A+r*v)*D,e[6]=(_*S-f*M-p*y)*D,e[7]=(l*M-h*S+d*y)*D,e[8]=(s*C-o*A+c*T)*D,e[9]=(n*A-t*C-r*T)*D,e[10]=(f*b-m*S+p*g)*D,e[11]=(u*S-l*b-d*g)*D,e[12]=(o*v-s*V-a*T)*D,e[13]=(t*V-n*v+i*T)*D,e[14]=(m*y-f*x-_*g)*D,e[15]=(l*x-u*y+h*g)*D,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,y=a*l,S=a*u,{x,y:b,z:M}=n;return i[0]=(1-(m+p))*x,i[1]=(d+S)*x,i[2]=(f-y)*x,i[3]=0,i[4]=(d-S)*b,i[5]=(1-(h+p))*b,i[6]=(_+g)*b,i[7]=0,i[8]=(f+y)*M,i[9]=(_-g)*M,i[10]=(1-(h+m))*M,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;si.copy(this);let c=1/s,l=1/o,u=1/a;return si.elements[0]*=c,si.elements[1]*=c,si.elements[2]*=c,si.elements[4]*=l,si.elements[5]*=l,si.elements[6]*=l,si.elements[8]*=u,si.elements[9]*=u,si.elements[10]*=u,t.setFromRotationMatrix(si),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 F,si=new Ke,wA=new F(0,0,0),MA=new F(1,1,1),yr=new F,Xc=new F,Dn=new F,rv=new Ke,sv=new nn;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],h=i[6],d=i[10];switch(t){case"XYZ":if(this._y=Math.asin(it(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(-it(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(it(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(-it(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(it(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(-it(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:ze("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return rv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(rv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return sv.setFromEuler(this),this.setFromQuaternion(sv,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 Ul{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 EA=0,ov=new F,zs=new nn,Qi=new Ke,qc=new F,ca=new F,AA=new F,TA=new nn,av=new F(1,0,0),cv=new F(0,1,0),lv=new F(0,0,1),uv={type:"added"},RA={type:"removed"},Bs={type:"childadded",child:null},Hh={type:"childremoved",child:null};class wt extends fi{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:EA++}),this.uuid=li(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=wt.DEFAULT_UP.clone();let e=new F,t=new Ni,n=new nn,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 Ke},normalMatrix:{value:new Ye}}),this.matrix=new Ke,this.matrixWorld=new Ke,this.matrixAutoUpdate=wt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ul,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 zs.setFromAxisAngle(e,t),this.quaternion.multiply(zs),this}rotateOnWorldAxis(e,t){return zs.setFromAxisAngle(e,t),this.quaternion.premultiply(zs),this}rotateX(e){return this.rotateOnAxis(av,e)}rotateY(e){return this.rotateOnAxis(cv,e)}rotateZ(e){return this.rotateOnAxis(lv,e)}translateOnAxis(e,t){return ov.copy(e).applyQuaternion(this.quaternion),this.position.add(ov.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(av,e)}translateY(e){return this.translateOnAxis(cv,e)}translateZ(e){return this.translateOnAxis(lv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Qi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)qc.copy(e);else qc.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),ca.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Qi.lookAt(ca,qc,this.up);else Qi.lookAt(qc,ca,this.up);if(this.quaternion.setFromRotationMatrix(Qi),i)Qi.extractRotation(i.matrixWorld),zs.setFromRotationMatrix(Qi),this.quaternion.premultiply(zs.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 je("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(uv),Bs.child=e,this.dispatchEvent(Bs),Bs.child=null;else je("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(RA),Hh.child=e,this.dispatchEvent(Hh),Hh.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),Qi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Qi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Qi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(uv),Bs.child=e,this.dispatchEvent(Bs),Bs.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(ca,e,AA),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ca,TA,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"})}}wt.DEFAULT_UP=new F(0,1,0);wt.DEFAULT_MATRIX_AUTO_UPDATE=!0;wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Pi extends wt{constructor(){super();this.isGroup=!0,this.type="Group"}}var CA={type:"move"};class Ta{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Pi,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 Pi,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 Pi,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(CA)}}}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 Pi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var Dy={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},br={h:0,s:0,l:0},Yc={h:0,s:0,l:0};function Gh(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 Ze{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,nt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=nt.workingColorSpace){return this.r=e,this.g=t,this.b=n,nt.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=nt.workingColorSpace){if(e=lf(e,1),t=it(t,0,1),n=it(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=Gh(s,r,e+0.3333333333333333),this.g=Gh(s,r,e),this.b=Gh(s,r,e-0.3333333333333333)}return nt.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)ze("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:ze("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 ze("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=Dy[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else ze("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=sr(e.r),this.g=sr(e.g),this.b=sr(e.b),this}copyLinearToSRGB(e){return this.r=Js(e.r),this.g=Js(e.g),this.b=Js(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return nt.workingToColorSpace(pn.copy(this),e),Math.round(it(pn.r*255,0,255))*65536+Math.round(it(pn.g*255,0,255))*256+Math.round(it(pn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=nt.workingColorSpace){nt.workingToColorSpace(pn.copy(this),t);let{r:n,g:i,b:r}=pn,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=nt.workingColorSpace){return nt.workingToColorSpace(pn.copy(this),t),e.r=pn.r,e.g=pn.g,e.b=pn.b,e}getStyle(e="srgb"){nt.workingToColorSpace(pn.copy(this),e);let{r:t,g:n,b:i}=pn;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(br),this.setHSL(br.h+e,br.s+t,br.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(br),e.getHSL(Yc);let n=_a(br.h,Yc.h,t),i=_a(br.s,Yc.s,t),r=_a(br.l,Yc.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 pn=new Ze;Ze.NAMES=Dy;class lo extends wt{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 oi=new F,er=new F,$h=new F,tr=new F,Vs=new F,Hs=new F,hv=new F,Wh=new F,Zh=new F,jh=new F,Xh=new yt,qh=new yt,Yh=new yt;class qn{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),oi.subVectors(e,t),i.cross(oi);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){oi.subVectors(i,t),er.subVectors(n,t),$h.subVectors(e,t);let s=oi.dot(oi),o=oi.dot(er),a=oi.dot($h),c=er.dot(er),l=er.dot($h),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,tr)===null)return!1;return tr.x>=0&&tr.y>=0&&tr.x+tr.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,tr)===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,tr.x),a.addScaledVector(s,tr.y),a.addScaledVector(o,tr.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Xh.setScalar(0),qh.setScalar(0),Yh.setScalar(0),Xh.fromBufferAttribute(e,t),qh.fromBufferAttribute(e,n),Yh.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Xh,r.x),s.addScaledVector(qh,r.y),s.addScaledVector(Yh,r.z),s}static isFrontFacing(e,t,n,i){return oi.subVectors(n,t),er.subVectors(e,t),oi.cross(er).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 oi.subVectors(this.c,this.b),er.subVectors(this.a,this.b),oi.cross(er).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return qn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return qn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return qn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return qn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qn.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;Vs.subVectors(i,n),Hs.subVectors(r,n),Wh.subVectors(e,n);let a=Vs.dot(Wh),c=Hs.dot(Wh);if(a<=0&&c<=0)return t.copy(n);Zh.subVectors(e,i);let l=Vs.dot(Zh),u=Hs.dot(Zh);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(Vs,s);jh.subVectors(e,r);let d=Vs.dot(jh),f=Hs.dot(jh);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(Hs,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return hv.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(hv,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(Vs,s).addScaledVector(Hs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Yt{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(ai.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(ai.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=ai.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,ai);else ai.fromBufferAttribute(r,s);ai.applyMatrix4(e.matrixWorld),this.expandByPoint(ai)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Jc.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Jc.copy(n.boundingBox)}Jc.applyMatrix4(e.matrixWorld),this.union(Jc)}}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,ai),ai.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(la),Kc.subVectors(this.max,la),Gs.subVectors(e.a,la),$s.subVectors(e.b,la),Ws.subVectors(e.c,la),Sr.subVectors($s,Gs),wr.subVectors(Ws,$s),ns.subVectors(Gs,Ws);let t=[0,-Sr.z,Sr.y,0,-wr.z,wr.y,0,-ns.z,ns.y,Sr.z,0,-Sr.x,wr.z,0,-wr.x,ns.z,0,-ns.x,-Sr.y,Sr.x,0,-wr.y,wr.x,0,-ns.y,ns.x,0];if(!Jh(t,Gs,$s,Ws,Kc))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Jh(t,Gs,$s,Ws,Kc))return!1;return Qc.crossVectors(Sr,wr),t=[Qc.x,Qc.y,Qc.z],Jh(t,Gs,$s,Ws,Kc)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ai).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(ai).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 nr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),nr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),nr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),nr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),nr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),nr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),nr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),nr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(nr),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 nr=[new F,new F,new F,new F,new F,new F,new F,new F],ai=new F,Jc=new Yt,Gs=new F,$s=new F,Ws=new F,Sr=new F,wr=new F,ns=new F,la=new F,Kc=new F,Qc=new F,is=new F;function Jh(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){is.fromArray(e,s);let a=r.x*Math.abs(is.x)+r.y*Math.abs(is.y)+r.z*Math.abs(is.z),c=t.dot(is),l=n.dot(is),u=i.dot(is);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var jt=new F,el=new Ge,IA=0;class rn extends fi{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:IA++}),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++)el.fromBufferAttribute(this,t),el.applyMatrix3(e),this.setXY(t,el.x,el.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix3(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix4(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyNormalMatrix(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.transformDirection(e),this.setXYZ(t,jt.x,jt.y,jt.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=ci(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=vt(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=ci(t,this.array);return t}setX(e,t){if(this.normalized)t=vt(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=ci(t,this.array);return t}setY(e,t){if(this.normalized)t=vt(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=ci(t,this.array);return t}setZ(e,t){if(this.normalized)t=vt(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=ci(t,this.array);return t}setW(e,t){if(this.normalized)t=vt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=vt(t,this.array),n=vt(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=vt(t,this.array),n=vt(n,this.array),i=vt(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=vt(t,this.array),n=vt(n,this.array),i=vt(i,this.array),r=vt(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 kl extends rn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Fl extends rn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class An extends rn{constructor(e,t,n){super(new Float32Array(e),t,n)}}var PA=new Yt,ua=new F,Kh=new F;class Fn{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 PA.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;ua.subVectors(e,this.center);let t=ua.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(ua,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 Kh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ua.copy(e.center).add(Kh)),this.expandByPoint(ua.copy(e.center).sub(Kh));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 LA=0,jn=new Ke,Qh=new wt,Zs=new F,On=new Yt,ha=new Yt,tn=new F;class gn extends fi{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:LA++}),this.uuid=li(),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((nA(e))?Fl:kl)(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 Ye().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 jn.makeRotationFromQuaternion(e),this.applyMatrix4(jn),this}rotateX(e){return jn.makeRotationX(e),this.applyMatrix4(jn),this}rotateY(e){return jn.makeRotationY(e),this.applyMatrix4(jn),this}rotateZ(e){return jn.makeRotationZ(e),this.applyMatrix4(jn),this}translate(e,t,n){return jn.makeTranslation(e,t,n),this.applyMatrix4(jn),this}scale(e,t,n){return jn.makeScale(e,t,n),this.applyMatrix4(jn),this}lookAt(e){return Qh.lookAt(e),Qh.updateMatrix(),this.applyMatrix4(Qh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Zs).negate(),this.translate(Zs.x,Zs.y,Zs.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 An(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)ze("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 Yt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){je("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(On.setFromBufferAttribute(r),this.morphTargetsRelative)tn.addVectors(this.boundingBox.min,On.min),this.boundingBox.expandByPoint(tn),tn.addVectors(this.boundingBox.max,On.max),this.boundingBox.expandByPoint(tn);else this.boundingBox.expandByPoint(On.min),this.boundingBox.expandByPoint(On.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))je('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 Fn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){je("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(On.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(ha.setFromBufferAttribute(o),this.morphTargetsRelative)tn.addVectors(On.min,ha.min),On.expandByPoint(tn),tn.addVectors(On.max,ha.max),On.expandByPoint(tn);else On.expandByPoint(ha.min),On.expandByPoint(ha.max)}On.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)tn.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(tn));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(tn.fromBufferAttribute(o,c),a)Zs.fromBufferAttribute(e,c),tn.add(Zs);i=Math.max(i,n.distanceToSquared(tn))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))je('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){je("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 rn(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let T=0;T<n.count;T++)o[T]=new F,a[T]=new F;let c=new F,l=new F,u=new F,h=new Ge,d=new Ge,f=new Ge,m=new F,_=new F;function p(T,v,A){c.fromBufferAttribute(n,T),l.fromBufferAttribute(n,v),u.fromBufferAttribute(n,A),h.fromBufferAttribute(r,T),d.fromBufferAttribute(r,v),f.fromBufferAttribute(r,A),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let V=1/(d.x*f.y-f.x*d.y);if(!isFinite(V))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(V),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(V),o[T].add(m),o[v].add(m),o[A].add(m),a[T].add(_),a[v].add(_),a[A].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let T=0,v=g.length;T<v;++T){let A=g[T],{start:V,count:C}=A;for(let N=V,Y=V+C;N<Y;N+=3)p(e.getX(N+0),e.getX(N+1),e.getX(N+2))}let y=new F,S=new F,x=new F,b=new F;function M(T){x.fromBufferAttribute(i,T),b.copy(x);let v=o[T];y.copy(v),y.sub(x.multiplyScalar(x.dot(v))).normalize(),S.crossVectors(b,v);let V=S.dot(a[T])<0?-1:1;s.setXYZW(T,y.x,y.y,y.z,V)}for(let T=0,v=g.length;T<v;++T){let A=g[T],{start:V,count:C}=A;for(let N=V,Y=V+C;N<Y;N+=3)M(e.getX(N+0)),M(e.getX(N+1)),M(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 rn(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++)tn.fromBufferAttribute(e,t),tn.normalize(),e.setXYZ(t,tn.x,tn.y,tn.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 rn(h,l,u)}if(this.index===null)return ze("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new gn,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 Ra{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=li()}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=li();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=li();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 Mn=new F;class uo{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++)Mn.fromBufferAttribute(this,t),Mn.applyMatrix4(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Mn.fromBufferAttribute(this,t),Mn.applyNormalMatrix(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Mn.fromBufferAttribute(this,t),Mn.transformDirection(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=ci(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=vt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=vt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=vt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=vt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=vt(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=ci(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=ci(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=ci(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=ci(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=vt(t,this.array),n=vt(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=vt(t,this.array),n=vt(n,this.array),i=vt(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=vt(t,this.array),n=vt(n,this.array),i=vt(i,this.array),r=vt(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){xa("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 rn(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 uo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){xa("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 ed=new F,NA=new F,DA=new Ye;class Xn{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=ed.subVectors(n,t).cross(NA.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(ed),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||DA.getNormalMatrix(e),i=this.coplanarPoint(ed).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 OA=0;class Tn extends fi{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:OA++}),this.uuid=li(),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 Ze(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){ze(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){ze(`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 Ze().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 Xn().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 Ge().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 Ge().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 ir=new F,td=new F,tl=new F,nl=new F;class Lr{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,ir)),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=ir.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return ir.copy(this.origin).addScaledVector(this.direction,t),ir.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){td.copy(e).add(t).multiplyScalar(0.5),tl.copy(t).sub(e).normalize(),nl.copy(this.origin).sub(td);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(tl),o=nl.dot(this.direction),a=-nl.dot(tl),c=nl.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(td).addScaledVector(tl,h);return d}intersectSphere(e,t){if(e.radius<0)return null;ir.subVectors(e.center,this.origin);let n=ir.dot(this.direction),i=ir.dot(ir)-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,ir)!==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,y=n.z-s.z,S=Math.abs(a),x=Math.abs(c),b=Math.abs(l),M,T,v,A,V,C,N,Y,D,W,z,P;if(S>=x&&S>=b)if(v=a,C=u,D=f,P=p,a>=0)M=c,T=l,A=h,V=d,N=m,Y=_,W=g,z=y;else M=l,T=c,A=d,V=h,N=_,Y=m,W=y,z=g;else if(x>=b)if(v=c,C=h,D=m,P=g,c>=0)M=l,T=a,A=d,V=u,N=_,Y=f,W=y,z=p;else M=a,T=l,A=u,V=d,N=f,Y=_,W=p,z=y;else if(v=l,C=d,D=_,P=y,l>=0)M=a,T=c,A=u,V=h,N=f,Y=m,W=p,z=g;else M=c,T=a,A=h,V=u,N=m,Y=f,W=g,z=p;if(v===0)return null;let q=M/v,H=T/v,ee=1/v,J=A-q*C,de=V-H*C,pe=N-q*D,Be=Y-H*D,me=W-q*P,X=z-H*P,L=me*Be-X*pe,G=J*X-de*me,te=pe*de-Be*J;if(i){if(L<0||G<0||te<0)return null}else if((L<0||G<0||te<0)&&(L>0||G>0||te>0))return null;let se=L+G+te;if(se===0)return null;let ce=ee*(L*C+G*D+te*P);if(se>0?ce<0:ce>0)return null;return this.at(ce/se,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 Fi extends Tn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ze(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 dv=new Ke,rs=new Lr,il=new Fn,fv=new F,rl=new F,sl=new F,ol=new F,nd=new F,al=new F,pv=new F,cl=new F;class Pt extends wt{constructor(e=new gn,t=new Fi){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){al.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(nd.fromBufferAttribute(u,e),s)al.addScaledVector(nd,l);else al.addScaledVector(nd.sub(t),l)}t.add(al)}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(il.copy(n.boundingSphere),il.applyMatrix4(r),rs.copy(e.ray).recast(e.near),il.containsPoint(rs.origin)===!1){if(rs.intersectSphere(il,fv)===null)return;if(rs.origin.distanceToSquared(fv)>(e.far-e.near)**2)return}if(dv.copy(r).invert(),rs.copy(e.ray).applyMatrix4(dv),n.boundingBox!==null){if(rs.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,rs)}_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),y=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let S=g,x=y;S<x;S+=3){let b=o.getX(S),M=o.getX(S+1),T=o.getX(S+2);if(i=ll(this,p,e,n,c,l,u,b,M,T),i)i.faceIndex=Math.floor(S/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(_),y=o.getX(_+1),S=o.getX(_+2);if(i=ll(this,s,e,n,c,l,u,g,y,S),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),y=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let S=g,x=y;S<x;S+=3){let b=S,M=S+1,T=S+2;if(i=ll(this,p,e,n,c,l,u,b,M,T),i)i.faceIndex=Math.floor(S/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=_,y=_+1,S=_+2;if(i=ll(this,s,e,n,c,l,u,g,y,S),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function UA(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;cl.copy(a),cl.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(cl);if(l<n.near||l>n.far)return null;return{distance:l,point:cl.clone(),object:e}}function ll(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,rl),e.getVertexPosition(c,sl),e.getVertexPosition(l,ol);let u=UA(e,t,n,i,rl,sl,ol,pv);if(u){let h=new F;if(qn.getBarycoord(pv,rl,sl,ol,h),r)u.uv=qn.getInterpolatedAttribute(r,a,c,l,h,new Ge);if(s)u.uv1=qn.getInterpolatedAttribute(s,a,c,l,h,new Ge);if(o){if(u.normal=qn.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};qn.getNormal(rl,sl,ol,d.normal),u.face=d,u.barycoord=h}return u}var da=new yt,mv=new yt,gv=new yt,kA=new yt,_v=new Ke,ul=new F,id=new Fn,xv=new Ke,rd=new Lr;class zl extends Pt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ke,this.bindMatrixInverse=new Ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Yt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ul),this.boundingBox.expandByPoint(ul)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new Fn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ul),this.boundingSphere.expandByPoint(ul)}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(id.copy(this.boundingSphere),id.applyMatrix4(i),e.ray.intersectsSphere(id)===!1)return;if(xv.copy(i).invert(),rd.copy(e.ray).applyMatrix4(xv),this.boundingBox!==null){if(rd.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,rd)}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 yt,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 ze("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(mv.fromBufferAttribute(i.attributes.skinIndex,e),gv.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)da.copy(t),t.set(0,0,0,0);else da.set(...t,1),t.set(0,0,0);da.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=gv.getComponent(r);if(s!==0){let o=mv.getComponent(r);_v.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(kA.copy(da).applyMatrix4(_v),s)}}if(t.isVector4)t.w=da.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Ca extends wt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Ia extends Vt{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 vv=new Ke,FA=new Ke;class Pa{constructor(e=[],t=[]){this.uuid=li(),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){ze("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 Ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ke;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:FA;vv.multiplyMatrices(o,t[r]),vv.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Pa(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 Ia(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)ze("Skeleton: No bone found with UUID:",r),s=new Ca;this.bones.push(s),this.boneInverses.push(new Ke().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 Ar extends rn{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 js=new Ke,yv=new Ke,hl=[],bv=new Yt,zA=new Ke,fa=new Pt,pa=new Fn;class ho extends Pt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Ar(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,zA)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Yt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,js),bv.copy(e.boundingBox).applyMatrix4(js),this.boundingBox.union(bv)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new Fn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,js),pa.copy(e.boundingSphere).applyMatrix4(js),this.boundingSphere.union(pa)}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(fa.geometry=this.geometry,fa.material=this.material,fa.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(pa.copy(this.boundingSphere),pa.applyMatrix4(n),e.ray.intersectsSphere(pa)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,js),yv.multiplyMatrices(n,js),fa.matrixWorld=yv,fa.raycast(e,hl);for(let s=0,o=hl.length;s<o;s++){let a=hl[s];a.instanceId=r,a.object=this,t.push(a)}hl.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Ar(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 Ia(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 ss=new Fn,BA=new Ge(0.5,0.5),dl=new F;class La{constructor(e=new Xn,t=new Xn,n=new Xn,i=new Xn,r=new Xn,s=new Xn){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],y=r[13],S=r[14],x=r[15];if(i[0].setComponents(c-s,d-l,p-f,x-g).normalize(),i[1].setComponents(c+s,d+l,p+f,x+g).normalize(),i[2].setComponents(c+o,d+u,p+m,x+y).normalize(),i[3].setComponents(c-o,d-u,p-m,x-y).normalize(),n)i[4].setComponents(a,h,_,S).normalize(),i[5].setComponents(c-a,d-h,p-_,x-S).normalize();else if(i[4].setComponents(c-a,d-h,p-_,x-S).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,x+S).normalize();else if(t===2001)i[5].setComponents(a,h,_,S).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();ss.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();ss.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ss)}intersectsSprite(e){ss.center.set(0,0,0);let t=BA.distanceTo(e.center);return ss.radius=0.7071067811865476+t,ss.applyMatrix4(e.matrixWorld),this.intersectsSphere(ss)}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(dl.x=i.normal.x>0?e.max.x:e.min.x,dl.y=i.normal.y>0?e.max.y:e.min.y,dl.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(dl)<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 Tn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ze(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 yl=new F,bl=new F,Sv=new Ke,ma=new Lr,fl=new Fn,sd=new F,wv=new F;class Nr extends wt{constructor(e=new gn,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++)yl.fromBufferAttribute(t,i-1),bl.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=yl.distanceTo(bl);e.setAttribute("lineDistance",new An(n,1))}else ze("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(fl.copy(n.boundingSphere),fl.applyMatrix4(i),fl.radius+=r,e.ray.intersectsSphere(fl)===!1)return;Sv.copy(i).invert(),ma.copy(e.ray).applyMatrix4(Sv);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),y=pl(this,e,ma,a,p,g,m);if(y)t.push(y)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=pl(this,e,ma,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=pl(this,e,ma,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=pl(this,e,ma,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 pl(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(yl.fromBufferAttribute(a,r),bl.fromBufferAttribute(a,s),n.distanceSqToSegment(yl,bl,sd,wv)>i)return;sd.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(sd);if(l<t.near||l>t.far)return;return{distance:l,point:wv.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Mv=new F,Ev=new F;class Bl extends Nr{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)Mv.fromBufferAttribute(t,i),Ev.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Mv.distanceTo(Ev);e.setAttribute("lineDistance",new An(n,1))}else ze("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Vl extends Nr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Da extends Tn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ze(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 Av=new Ke,cd=new Lr,ml=new Fn,gl=new F;class fo extends wt{constructor(e=new gn,t=new Da){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(ml.copy(n.boundingSphere),ml.applyMatrix4(i),ml.radius+=r,e.ray.intersectsSphere(ml)===!1)return;Av.copy(i).invert(),cd.copy(e.ray).applyMatrix4(Av);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);gl.fromBufferAttribute(u,_),Tv(gl,_,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++)gl.fromBufferAttribute(u,f),Tv(gl,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 Tv(e,t,n,i,r,s,o){let a=cd.distanceSqToPoint(e);if(a<n){let c=new F;cd.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 Hl extends Vt{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 ps extends Vt{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 Aa(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class ff extends ps{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 Gl extends Vt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Dr extends gn{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 An(c,3)),this.setAttribute("normal",new An(l,3)),this.setAttribute("uv",new An(u,2));function f(m,_,p,g,y,S,x,b,M,T,v){let A=S/M,V=x/T,C=S/2,N=x/2,Y=b/2,D=M+1,W=T+1,z=0,P=0,q=new F;for(let H=0;H<W;H++){let ee=H*V-N;for(let J=0;J<D;J++){let de=J*A-C;q[m]=de*g,q[_]=ee*y,q[p]=Y,c.push(q.x,q.y,q.z),q[m]=0,q[_]=0,q[p]=b>0?1:-1,l.push(q.x,q.y,q.z),u.push(J/M),u.push(1-H/T),z+=1}}for(let H=0;H<T;H++)for(let ee=0;ee<M;ee++){let J=h+ee+D*H,de=h+ee+D*(H+1),pe=h+(ee+1)+D*(H+1),Be=h+(ee+1)+D*H;a.push(J,de,Be),a.push(de,pe,Be),P+=6}o.addGroup(d,P,v),d+=P,h+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Dr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Oa extends gn{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 y=0;y<c;y++){let S=y*u-r;f.push(S,-g,0),m.push(0,0,1),_.push(y/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let y=g+c*p,S=g+c*(p+1),x=g+1+c*(p+1),b=g+1+c*p;d.push(y,S,b),d.push(S,x,b)}this.setIndex(d),this.setAttribute("position",new An(f,3)),this.setAttribute("normal",new An(m,3)),this.setAttribute("uv",new An(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Oa(e.width,e.height,e.widthSegments,e.heightSegments)}}function ms(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(Rv(r))if(r.isRenderTargetTexture)ze("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(Rv(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 _n(e){let t={};for(let n=0;n<e.length;n++){let i=ms(e[n]);for(let r in i)t[r]=i[r]}return t}function Rv(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function VA(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function pf(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return nt.workingColorSpace}var Oy={clone:ms,merge:_n},HA=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,GA=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Jn extends Tn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=HA,this.fragmentShader=GA,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=ms(e.uniforms),this.uniformsGroups=VA(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 Ze().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ge().fromArray(i.value);break;case"v3":this.uniforms[n].value=new F().fromArray(i.value);break;case"v4":this.uniforms[n].value=new yt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ye().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ke().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 mf extends Jn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ar extends Tn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ze(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 Ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ge(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 zn extends ar{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 Ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return it(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 Ze(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 Ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ze(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 $l extends Tn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ge(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 gf extends Tn{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 _f extends Tn{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 Er(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 vl(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function $A(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 Cv(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 WA(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 cr{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 xf extends cr{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,y=(-1-d)*_+(1.5+d)*m+0.5*f,S=d*_-d*m;for(let x=0;x!==o;++x)r[x]=p*s[l+x]+g*s[c+x]+y*s[a+x]+S*s[u+x];return r}}class Wl extends cr{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 vf extends cr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class yf extends cr{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],y=u[p+1],S=e*h+f*2,x=l[S],b=l[S+1],M=jA(n,t,g,x,i);r[f]=Uy(M,m,y,b,_)}return r}}function Uy(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 ZA(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 jA(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=Uy(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=ZA(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 Bn{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=Er(t,this.TimeBufferType),this.values=Er(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:Er(e.times,Array),values:Er(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(vl(e.settings))n.settings={inTangents:Er(e.settings.inTangents,Array),outTangents:Er(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new vf(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Wl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xf(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new yf(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 ze("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(vl(this.settings))Iv(this.settings.inTangents,e),Iv(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)je("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)je("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)){je("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){je("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(iA(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){je("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,vl(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function Iv(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Bn.prototype.ValueTypeName="";Bn.prototype.TimeBufferType=Float32Array;Bn.prototype.ValueBufferType=Float32Array;Bn.prototype.DefaultInterpolation=2301;class Or extends Bn{constructor(e,t,n){super(e,t,n)}}Or.prototype.ValueTypeName="bool";Or.prototype.ValueBufferType=Array;Or.prototype.DefaultInterpolation=2300;Or.prototype.InterpolantFactoryMethodLinear=void 0;Or.prototype.InterpolantFactoryMethodSmooth=void 0;class Zl extends Bn{constructor(e,t,n,i){super(e,t,n,i)}}Zl.prototype.ValueTypeName="color";class Ur extends Bn{constructor(e,t,n,i){super(e,t,n,i)}}Ur.prototype.ValueTypeName="number";class bf extends cr{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)nn.slerpFlat(r,0,s,c-o,s,c,a);return r}}class kr extends Bn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new bf(this.times,this.values,this.getValueSize(),e)}}kr.prototype.ValueTypeName="quaternion";kr.prototype.InterpolantFactoryMethodSmooth=void 0;class Fr extends Bn{constructor(e,t,n){super(e,t,n)}}Fr.prototype.ValueTypeName="string";Fr.prototype.ValueBufferType=Array;Fr.prototype.DefaultInterpolation=2300;Fr.prototype.InterpolantFactoryMethodLinear=void 0;Fr.prototype.InterpolantFactoryMethodSmooth=void 0;class gs extends Bn{constructor(e,t,n,i){super(e,t,n,i)}}gs.prototype.ValueTypeName="vector";class eo{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=li(),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(qA(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(Bn.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=$A(a);if(a=Cv(a,1,l),c=Cv(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new Ur(".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 XA(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ur;case"vector":case"vector2":case"vector3":case"vector4":return gs;case"color":return Zl;case"quaternion":return kr;case"bool":case"boolean":return Or;case"string":return Fr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function qA(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=XA(e.type);if(e.times===void 0){let i=[],r=[];WA(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(vl(e.settings))n.settings={inTangents:Er(e.settings.inTangents,Float32Array),outTangents:Er(e.settings.outTangents,Float32Array)};return n}var Li={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(Pv(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(Pv(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Pv(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Ua{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 ky=new Ua;class lr{constructor(e){if(this.manager=e!==void 0?e:ky,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}}lr.DEFAULT_MATERIAL_NAME="__DEFAULT";var rr={};class Fy extends Error{constructor(e,t){super(e);this.response=t}}class ka extends lr{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=Li.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(rr[e]!==void 0){rr[e].push({onLoad:t,onProgress:n,onError:i});return}rr[e]=[],rr[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)ze("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=rr[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:y,value:S})=>{if(y)p.close();else{m+=S.byteLength;let x=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let b=0,M=l.length;b<M;b++){let T=l[b];if(T.onProgress)T.onProgress(x)}p.enqueue(S),g()}},(y)=>{p.error(y)})}}});return new Response(_)}else throw new Fy(`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)=>{Li.add(`file:${e}`,c);let l=rr[e];delete rr[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=rr[e];if(l===void 0)throw this.manager.itemError(e),c;delete rr[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 Xs=new WeakMap;class Sf extends lr{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=Li.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=Xs.get(s);if(u===void 0)u=[],Xs.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Ks("img");function a(){if(l(),t)t(this);let u=Xs.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}Xs.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);Li.remove(`image:${e}`);let h=Xs.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}Xs.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 Li.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class po extends lr{constructor(e){super(e)}load(e,t,n,i){let r=new Vt,s=new Sf(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 mo extends wt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ze(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 jl extends mo{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ze(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 od=new Ke,Lv=new F,Nv=new F;class Fa{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 Ge(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new La,this._frameExtents=new Ge(1,1),this._viewportCount=1,this._viewports=[new yt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Lv.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lv),Nv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Nv),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){od.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(od,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(od)}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 _l=new F,xl=new nn,Ii=new F;class Xl extends wt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ke,this.projectionMatrix=new Ke,this.projectionMatrixInverse=new Ke,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(_l,xl,Ii),Ii.x===1&&Ii.y===1&&Ii.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(_l,xl,Ii.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(_l,xl,Ii),Ii.x===1&&Ii.y===1&&Ii.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(_l,xl,Ii.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Mr=new F,Dv=new Ge,Ov=new Ge;class qt extends Xl{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=as*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ga*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return as*2*Math.atan(Math.tan(ga*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){Mr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mr.x,Mr.y).multiplyScalar(-e/Mr.z),Mr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Mr.x,Mr.y).multiplyScalar(-e/Mr.z)}getViewSize(e,t){return this.getViewBounds(e,Dv,Ov),t.subVectors(Ov,Dv)}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(ga*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 zy extends Fa{constructor(){super(new qt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=as*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 ql extends mo{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(wt.DEFAULT_UP),this.updateMatrix(),this.target=new wt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new zy}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 By extends Fa{constructor(){super(new qt(90,1,0.5,500));this.isPointLightShadow=!0}}class go extends mo{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 By}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 _s extends Xl{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 Vy extends Fa{constructor(){super(new _s(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class _o extends mo{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.target=new wt,this.shadow=new Vy}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 zr{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 ad=new WeakMap;class Yl extends lr{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")ze("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")ze("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=Li.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(ad.has(s)===!0){if(i)i(ad.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(Li.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);ad.set(a,c),Li.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Li.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var qs=-90,Ys=1;class wf extends wt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new qt(qs,Ys,e,t);i.layers=this.layers,this.add(i);let r=new qt(qs,Ys,e,t);r.layers=this.layers,this.add(r);let s=new qt(qs,Ys,e,t);s.layers=this.layers,this.add(s);let o=new qt(qs,Ys,e,t);o.layers=this.layers,this.add(o);let a=new qt(qs,Ys,e,t);a.layers=this.layers,this.add(a);let c=new qt(qs,Ys,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 Mf extends qt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ef{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){nn.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;nn.multiplyQuaternionsFlat(e,s,e,t,e,n),nn.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 Af="\\[\\]\\.:\\/",YA=new RegExp("["+Af+"]","g"),Tf="[^"+Af+"]",JA="[^"+Af.replace("\\.","")+"]",KA=/((?:WC+[\/:])*)/.source.replace("WC",Tf),QA=/(WCOD+)?/.source.replace("WCOD",JA),eT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Tf),tT=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Tf),nT=new RegExp("^"+KA+QA+eT+tT+"$"),iT=["material","materials","bones","map"];class Hy{constructor(e,t,n){let i=n||mt.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 mt{constructor(e,t,n){this.path=t,this.parsedPath=n||mt.parseTrackName(t),this.node=mt.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 mt(e,t,n);else return new mt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(YA,"")}static parseTrackName(e){let t=nT.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(iT.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=mt.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){ze("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){je("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){je("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){je("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){je("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){je("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){je("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){je("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;je("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){je("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){je("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}}mt.Composite=Hy;mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};mt.prototype.GetterByBindingType=[mt.prototype._getValue_direct,mt.prototype._getValue_array,mt.prototype._getValue_arrayElement,mt.prototype._getValue_toArray];mt.prototype.SetterByBindingTypeAndVersioning=[[mt.prototype._setValue_direct,mt.prototype._setValue_direct_setNeedsUpdate,mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_array,mt.prototype._setValue_array_setNeedsUpdate,mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_arrayElement,mt.prototype._setValue_arrayElement_setNeedsUpdate,mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_fromArray,mt.prototype._setValue_fromArray_setNeedsUpdate,mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Rf{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 rT=new Float32Array(1);class Jl extends fi{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 Ef(mt.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 Wl(new Float32Array(2),new Float32Array(2),1,rT),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"?eo.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 Rf(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"?eo.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 za{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=it(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(it(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Cf{static{Cf.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 Kl extends fi{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 If(e,t,n,i){let r=sT(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 sT(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__)ze("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function ub(){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 oT(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 aT=`#ifdef USE_ALPHAHASH
+ #define PI 3.14159265359
+
+ // Van der Corput radical inverse
+ float radicalInverse_VdC(uint bits) {
+ bits = (bits << 16u) | (bits >> 16u);
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
+ }
+
+ // Hammersley sequence
+ vec2 hammersley(uint i, uint N) {
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
+ }
+
+ // GGX VNDF importance sampling (Eric Heitz 2018)
+ // "Sampling the GGX Distribution of Visible Normals"
+ // https://jcgt.org/published/0007/04/01/
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
+ float alpha = roughness * roughness;
+
+ // Section 4.1: Orthonormal basis
+ vec3 T1 = vec3(1.0, 0.0, 0.0);
+ vec3 T2 = cross(V, T1);
+
+ // Section 4.2: Parameterization of projected area
+ float r = sqrt(Xi.x);
+ float phi = 2.0 * PI * Xi.y;
+ float t1 = r * cos(phi);
+ float t2 = r * sin(phi);
+ float s = 0.5 * (1.0 + V.z);
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
+
+ // Section 4.3: Reprojection onto hemisphere
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
+
+ // Section 3.4: Transform back to ellipsoid configuration
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
+ }
+
+ void main() {
+ vec3 N = normalize(vOutputDirection);
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
+
+ vec3 prefilteredColor = vec3(0.0);
+ float totalWeight = 0.0;
+
+ // For very low roughness, just sample the environment directly
+ if (roughness < 0.001) {
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
+ return;
+ }
+
+ // Tangent space basis for VNDF sampling
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
+ vec3 tangent = normalize(cross(up, N));
+ vec3 bitangent = cross(N, tangent);
+
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
+
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
+
+ // Transform H back to world space
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
+
+ float NdotL = max(dot(N, L), 0.0);
+
+ if(NdotL > 0.0) {
+ // Sample environment at fixed mip level
+ // VNDF importance sampling handles the distribution filtering
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
+
+ // Weight by NdotL for the split-sum approximation
+ // VNDF PDF naturally accounts for the visible microfacet distribution
+ prefilteredColor += sampleColor * NdotL;
+ totalWeight += NdotL;
+ }
+ }
+
+ if (totalWeight > 0.0) {
+ prefilteredColor = prefilteredColor / totalWeight;
+ }
+
+ gl_FragColor = vec4(prefilteredColor, 1.0);
+ }
+ `,blending:lr,depthTest:!1,depthWrite:!1})}function Pk(e,t,n){return new _i({name:"SphericalGaussianBlur",defines:{SAMPLES:Mk,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:wd(),fragmentShader:`
+
+ precision highp float;
+ precision highp int;
+
+ varying vec3 vOutputDirection;
+
+ uniform sampler2D envMap;
+ uniform float sigma;
+ uniform float mipInt;
+
+ #define ENVMAP_TYPE_CUBE_UV
+ #include <cube_uv_reflection_fragment>
+
+ #define PI 3.14159265359
+ #define GOLDEN_ANGLE 2.39996322973
+
+ void main() {
+
+ if ( sigma == 0.0 ) {
+
+ gl_FragColor = vec4( bilinearCubeUV( envMap, vOutputDirection, mipInt ), 1.0 );
+ return;
+
+ }
+
+ vec3 outputDirection = normalize( vOutputDirection );
+
+ vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );
+ vec3 tangent = normalize( cross( up, outputDirection ) );
+ vec3 bitangent = cross( outputDirection, tangent );
+
+ // Truncate the kernel at three standard deviations or at the antipode.
+ float thetaMax = min( 3.0 * sigma, PI );
+ float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );
+
+ vec3 accumColor = vec3( 0.0 );
+ float accumWeight = 0.0;
+
+ for ( int i = 0; i < SAMPLES; i ++ ) {
+
+ // Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral.
+ float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );
+ float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );
+ float phi = float( i ) * GOLDEN_ANGLE;
+
+ vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent;
+ vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;
+
+ // Correct the planar sample density to solid angle.
+ float weight = sin( theta ) / theta;
+
+ accumColor += weight * bilinearCubeUV( envMap, sampleDirection, mipInt );
+ accumWeight += weight;
+
+ }
+
+ gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
+
+ }
+ `,blending:lr,depthTest:!1,depthWrite:!1})}function FT(){return new _i({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:wd(),fragmentShader:`
+
+ precision mediump float;
+ precision mediump int;
+
+ varying vec3 vOutputDirection;
+
+ uniform sampler2D envMap;
+
+ #include <common>
+
+ void main() {
+
+ vec3 outputDirection = normalize( vOutputDirection );
+ vec2 uv = equirectUv( outputDirection );
+
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
+
+ }
+ `,blending:lr,depthTest:!1,depthWrite:!1})}function UT(){return new _i({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:wd(),fragmentShader:`
+
+ precision mediump float;
+ precision mediump int;
+
+ uniform float flipEnvMap;
+
+ varying vec3 vOutputDirection;
+
+ uniform samplerCube envMap;
+
+ void main() {
+
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
+
+ }
+ `,blending:lr,depthTest:!1,depthWrite:!1})}function wd(){return`
+
+ precision mediump float;
+ precision mediump int;
+
+ attribute vec3 outputDirection;
+
+ varying vec3 vOutputDirection;
+
+ void main() {
+
+ vOutputDirection = outputDirection;
+ gl_Position = vec4( position, 1.0 );
+
+ }
+ `}function Ok(e){let t=new WeakMap,n=new WeakMap,i=null;function r(f,h=!1){if(f===null||f===void 0)return null;if(h)return a(f);return s(f)}function s(f){if(f&&f.isTexture){let h=f.mapping;if(h===Wu||h===Xu)if(t.has(f)){let y=t.get(f).texture;return o(y,f.mapping)}else{let y=f.image;if(y&&y.height>0){let g=new $m(y.height);return g.fromEquirectangularTexture(e,f),t.set(f,g),f.addEventListener("dispose",l),o(g.texture,f.mapping)}else return null}}return f}function a(f){if(f&&f.isTexture){let h=f.mapping,y=h===Wu||h===Xu,g=h===yo||h===pa;if(y||g){let m=n.get(f),p=m!==void 0?m.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==p){if(i===null)i=new sl(e);return m=y?i.fromEquirectangular(f,m):i.fromCubemap(f,m),m.texture.pmremVersion=f.pmremVersion,n.set(f,m),m.texture}else if(m!==void 0)return m.texture;else{let b=f.image;if(y&&b&&b.height>0||g&&b&&c(b)){if(i===null)i=new sl(e);return m=y?i.fromEquirectangular(f):i.fromCubemap(f),m.texture.pmremVersion=f.pmremVersion,n.set(f,m),f.addEventListener("dispose",u),m.texture}else return null}}}return f}function o(f,h){if(h===Wu)f.mapping=yo;else if(h===Xu)f.mapping=pa;return f}function c(f){let h=0,y=6;for(let g=0;g<y;g++)if(f[g]!==void 0)h++;return h===y}function l(f){let h=f.target;h.removeEventListener("dispose",l);let y=t.get(h);if(y!==void 0)t.delete(h),y.dispose()}function u(f){let h=f.target;h.removeEventListener("dispose",u);let y=n.get(h);if(y!==void 0)n.delete(h),y.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function kk(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)fa("WebGLRenderer: "+i+" extension not supported.");return r}}}function Dk(e,t,n,i){let r={},s=new WeakMap;function a(d){let f=d.target;if(f.index!==null)t.remove(f.index);for(let y in f.attributes)t.remove(f.attributes[y]);f.removeEventListener("dispose",a),delete r[f.id];let h=s.get(f);if(h)t.remove(h),s.delete(f);if(i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0)delete f._maxInstanceCount;n.memory.geometries--}function o(d,f){if(r[f.id]===!0)return f;return f.addEventListener("dispose",a),r[f.id]=!0,n.memory.geometries++,f}function c(d){let f=d.attributes;for(let h in f)t.update(f[h],e.ARRAY_BUFFER)}function l(d){let f=[],h=d.index,y=d.attributes.position,g=0;if(y===void 0)return;if(h!==null){let b=h.array;g=h.version;for(let _=0,x=b.length;_<x;_+=3){let v=b[_+0],E=b[_+1],S=b[_+2];f.push(v,E,E,S,S,v)}}else{let b=y.array;g=y.version;for(let _=0,x=b.length/3-1;_<x;_+=3){let v=_+0,E=_+1,S=_+2;f.push(v,E,E,S,S,v)}}let m=new(y.count>=65535?ld:cd)(f,1);m.version=g;let p=s.get(d);if(p)t.remove(p);s.set(d,m)}function u(d){let f=s.get(d);if(f){let h=d.index;if(h!==null){if(f.version<h.version)l(d)}}else l(d);return s.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function Lk(e,t,n){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function c(d,f){e.drawElements(i,f,s,d*a),n.update(f,i,1)}function l(d,f,h){if(h===0)return;e.drawElementsInstanced(i,f,s,d*a,h),n.update(f,i,h)}function u(d,f,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,f,0,s,d,0,h);let g=0;for(let m=0;m<h;m++)g+=f[m];n.update(g,i,1)}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Fk(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(n.calls++,a){case e.TRIANGLES:n.triangles+=o*(s/3);break;case e.LINES:n.lines+=o*(s/2);break;case e.LINE_STRIP:n.lines+=o*(s-1);break;case e.LINE_LOOP:n.lines+=o*s;break;case e.POINTS:n.points+=o*s;break;default:Ze("WebGLInfo: Unknown draw mode:",a);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 Uk(e,t,n){let i=new WeakMap,r=new Nt;function s(a,o,c){let l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,f=i.get(o);if(f===void 0||f.count!==d){let A=function(){S.dispose(),i.delete(o),o.removeEventListener("dispose",A)};if(f!==void 0)f.texture.dispose();let h=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],b=o.morphAttributes.color||[],_=0;if(h===!0)_=1;if(y===!0)_=2;if(g===!0)_=3;let x=o.attributes.position.count*_,v=1;if(x>t.maxTextureSize)v=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize;let E=new Float32Array(x*v*4*d),S=new ad(E,x,v,d);S.type=Fr,S.needsUpdate=!0;let T=_*4;for(let P=0;P<d;P++){let w=m[P],I=p[P],F=b[P],N=x*v*4*P;for(let U=0;U<w.count;U++){let D=U*T;if(h===!0)r.fromBufferAttribute(w,U),E[N+D+0]=r.x,E[N+D+1]=r.y,E[N+D+2]=r.z,E[N+D+3]=0;if(y===!0)r.fromBufferAttribute(I,U),E[N+D+4]=r.x,E[N+D+5]=r.y,E[N+D+6]=r.z,E[N+D+7]=0;if(g===!0)r.fromBufferAttribute(F,U),E[N+D+8]=r.x,E[N+D+9]=r.y,E[N+D+10]=r.z,E[N+D+11]=F.itemSize===4?r.w:1}}f={count:d,texture:S,size:new Ke(x,v)},i.set(o,f),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let h=0;for(let g=0;g<l.length;g++)h+=l[g];let y=o.morphTargetsRelative?1:1-h;c.getUniforms().setValue(e,"morphTargetBaseInfluence",y),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}return{update:s}}function Bk(e,t,n,i,r){let s=new WeakMap;function a(l){let u=r.render.frame,d=l.geometry,f=t.get(l,d);if(s.get(f)!==u)t.update(f),s.set(f,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 h=l.skeleton;if(s.get(h)!==u)h.update(),s.set(h,u)}return f}function o(){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:a,dispose:o}}function Vk(e,t,n,i,r,s){let a=new ai(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=new On;l.setAttribute("position",new Gn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Gn([0,2,0,0,2,0],2));let u=new _m({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ precision highp float;
+
+ uniform mat4 modelViewMatrix;
+ uniform mat4 projectionMatrix;
+
+ attribute vec3 position;
+ attribute vec2 uv;
+
+ varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,fragmentShader:`
+ precision highp float;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ #include <tonemapping_pars_fragment>
+ #include <colorspace_pars_fragment>
+
+ void main() {
+ gl_FragColor = texture2D( tDiffuse, vUv );
+
+ #ifdef LINEAR_TONE_MAPPING
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
+ #elif defined( REINHARD_TONE_MAPPING )
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
+ #elif defined( CINEON_TONE_MAPPING )
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
+ #elif defined( AGX_TONE_MAPPING )
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
+ #elif defined( NEUTRAL_TONE_MAPPING )
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
+ #elif defined( CUSTOM_TONE_MAPPING )
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
+ #endif
+
+ #ifdef SRGB_TRANSFER
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
+ #endif
+ }`,depthTest:!1,depthWrite:!1}),d=new jt(l,u),f=new Ta(-1,1,1,-1,0,1),h=null,y=null,g=!1,m,p=null,b=[],_=!1;this.setSize=function(x,v){if(a.setSize(x,v),o!==null)o.setSize(x,v);if(c!==null)c.setSize(x,v);for(let E=0;E<b.length;E++){let S=b[E];if(S.setSize)S.setSize(x,v)}},this.setEffects=function(x){b=x,_=b.length>0&&b[0].isRenderPass===!0;let{width:v,height:E}=a;if(b.length>0&&o===null)o=new ai(v,E,{type:dr,depthBuffer:!1,stencilBuffer:!1}),c=new ai(v,E,{type:dr,depthBuffer:!1,stencilBuffer:!1});for(let S=0;S<b.length;S++){let T=b[S];if(T.setSize)T.setSize(v,E)}},this.begin=function(x,v){if(g)return!1;if(x.toneMapping===Li&&b.length===0)return!1;if(p=v,v!==null){let{width:E,height:S}=v;if(a.width!==E||a.height!==S)this.setSize(E,S)}if(_===!1)x.setRenderTarget(a);return m=x.toneMapping,x.toneMapping=Li,!0},this.hasRenderPass=function(){return _},this.end=function(x,v){x.toneMapping=m,g=!0;let E=a,S=o;for(let T=0;T<b.length;T++){let A=b[T];if(A.enabled===!1)continue;if(A.render(x,S,E,v),A.needsSwap!==!1)E=S,S=S===o?c:o}if(h!==x.outputColorSpace||y!==x.toneMapping){if(h=x.outputColorSpace,y=x.toneMapping,u.defines={},ot.getTransfer(h)===Bt)u.defines.SRGB_TRANSFER="";let T=zk[y];if(T)u.defines[T]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,x.setRenderTarget(p),x.render(d,f),p=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}function ko(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=BT[r];if(s===void 0)s=new Float32Array(r),BT[r]=s;if(t!==0){i.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=n,e[a].toArray(s,o)}return s}function pn(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 mn(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Md(e,t){let n=zT[t];if(n===void 0)n=new Int32Array(t),zT[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function jk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Hk(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(pn(n,t))return;e.uniform2fv(this.addr,t),mn(n,t)}}function Gk(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(pn(n,t))return;e.uniform3fv(this.addr,t),mn(n,t)}}function $k(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(pn(n,t))return;e.uniform4fv(this.addr,t),mn(n,t)}}function Kk(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;HT.set(i),e.uniformMatrix2fv(this.addr,!1,HT),mn(n,i)}}function Wk(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;jT.set(i),e.uniformMatrix3fv(this.addr,!1,jT),mn(n,i)}}function Xk(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;VT.set(i),e.uniformMatrix4fv(this.addr,!1,VT),mn(n,i)}}function qk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Jk(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(pn(n,t))return;e.uniform2iv(this.addr,t),mn(n,t)}}function Zk(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(pn(n,t))return;e.uniform3iv(this.addr,t),mn(n,t)}}function Yk(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(pn(n,t))return;e.uniform4iv(this.addr,t),mn(n,t)}}function Qk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function eD(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(pn(n,t))return;e.uniform2uiv(this.addr,t),mn(n,t)}}function tD(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(pn(n,t))return;e.uniform3uiv(this.addr,t),mn(n,t)}}function nD(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(pn(n,t))return;e.uniform4uiv(this.addr,t),mn(n,t)}}function iD(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)Hm.compareFunction=n.isReversedDepthBuffer()?sd:rd,s=Hm;else s=rA;n.setTexture2D(t||s,r)}function rD(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||aA,r)}function sD(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||oA,r)}function aD(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||sA,r)}function oD(e){switch(e){case 5126:return jk;case 35664:return Hk;case 35665:return Gk;case 35666:return $k;case 35674:return Kk;case 35675:return Wk;case 35676:return Xk;case 5124:case 35670:return qk;case 35667:case 35671:return Jk;case 35668:case 35672:return Zk;case 35669:case 35673:return Yk;case 5125:return Qk;case 36294:return eD;case 36295:return tD;case 36296:return nD;case 35678:case 36198:case 36298:case 36306:case 35682:return iD;case 35679:case 36299:case 36307:return rD;case 35680:case 36300:case 36308:case 36293:return sD;case 36289:case 36303:case 36311:case 36292:return aD}}function cD(e,t){e.uniform1fv(this.addr,t)}function lD(e,t){let n=ko(t,this.size,2);e.uniform2fv(this.addr,n)}function uD(e,t){let n=ko(t,this.size,3);e.uniform3fv(this.addr,n)}function dD(e,t){let n=ko(t,this.size,4);e.uniform4fv(this.addr,n)}function fD(e,t){let n=ko(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function hD(e,t){let n=ko(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function pD(e,t){let n=ko(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function mD(e,t){e.uniform1iv(this.addr,t)}function gD(e,t){e.uniform2iv(this.addr,t)}function bD(e,t){e.uniform3iv(this.addr,t)}function yD(e,t){e.uniform4iv(this.addr,t)}function xD(e,t){e.uniform1uiv(this.addr,t)}function _D(e,t){e.uniform2uiv(this.addr,t)}function vD(e,t){e.uniform3uiv(this.addr,t)}function ED(e,t){e.uniform4uiv(this.addr,t)}function TD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);let a;if(this.type===e.SAMPLER_2D_SHADOW)a=Hm;else a=rA;for(let o=0;o!==r;++o)n.setTexture2D(t[o]||a,s[o])}function AD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTexture3D(t[a]||aA,s[a])}function SD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTextureCube(t[a]||oA,s[a])}function wD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTexture2DArray(t[a]||sA,s[a])}function MD(e){switch(e){case 5126:return cD;case 35664:return lD;case 35665:return uD;case 35666:return dD;case 35674:return fD;case 35675:return hD;case 35676:return pD;case 5124:case 35670:return mD;case 35667:case 35671:return gD;case 35668:case 35672:return bD;case 35669:case 35673:return yD;case 5125:return xD;case 36294:return _D;case 36295:return vD;case 36296:return ED;case 35678:case 36198:case 36298:case 36306:case 35682:return TD;case 35679:case 36299:case 36307:return AD;case 35680:case 36300:case 36308:case 36293:return SD;case 36289:case 36303:case 36311:case 36292:return wD}}class cA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=oD(t.type)}}class lA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=MD(t.type)}}class uA{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 a=i[r];a.setValue(e,t[a.id],n)}}}function GT(e,t){e.seq.push(t),e.map[t.id]=t}function RD(e,t,n){let i=e.name,r=i.length;Vm.lastIndex=0;while(!0){let s=Vm.exec(i),a=Vm.lastIndex,o=s[1],c=s[2]==="]",l=s[3];if(c)o=o|0;if(l===void 0||l==="["&&a+2===r){GT(n,l===void 0?new cA(o,e,t):new lA(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new uA(o),GT(n,d);n=d}}}class rl{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let a=e.getActiveUniform(t,s),o=e.getUniformLocation(t,a.name);RD(a,o,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 a=t[r],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(e,o.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 $T(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}function ND(e,t){let n=e.split(`
+`),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let a=r;a<s;a++){let o=a+1;i.push(`${o===t?">":" "} ${o}: ${n[a]}`)}return i.join(`
+`)}function PD(e){ot._getMatrix(KT,ot.workingColorSpace,e);let t=`mat3( ${KT.elements.map((n)=>n.toFixed(4))} )`;switch(ot.getTransfer(e)){case dm:return[t,"LinearTransferOETF"];case Bt:return[t,"sRGBTransferOETF"];default:return je("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function WT(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let o=parseInt(a[1]);return n.toUpperCase()+`
+
+`+s+`
+
+`+ND(e.getShaderSource(t),o)}else return s}function OD(e,t){let n=PD(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}function DD(e,t){let n=kD[t];if(n===void 0)return je("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function LD(){ot.getLuminanceCoefficients(Sd);let e=Sd.x.toFixed(4),t=Sd.y.toFixed(4),n=Sd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function FD(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(il).join(`
+`)}function UD(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 BD(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),a=s.name,o=1;if(s.type===e.FLOAT_MAT2)o=2;if(s.type===e.FLOAT_MAT3)o=3;if(s.type===e.FLOAT_MAT4)o=4;n[a]={type:s.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function il(e){return e!==""}function XT(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 qT(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Gm(e){return e.replace(zD,jD)}function jD(e,t){let n=st[t];if(n===void 0){let i=VD.get(t);if(i!==void 0)n=st[i],je('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Gm(n)}function JT(e){return e.replace(HD,GD)}function GD(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 ZT(e){let t=`precision ${e.precision} float;
+ precision ${e.precision} int;
+ precision ${e.precision} sampler2D;
+ precision ${e.precision} samplerCube;
+ precision ${e.precision} sampler3D;
+ precision ${e.precision} sampler2DArray;
+ precision ${e.precision} sampler2DShadow;
+ precision ${e.precision} samplerCubeShadow;
+ precision ${e.precision} sampler2DArrayShadow;
+ precision ${e.precision} isampler2D;
+ precision ${e.precision} isampler3D;
+ precision ${e.precision} isamplerCube;
+ precision ${e.precision} isampler2DArray;
+ precision ${e.precision} usampler2D;
+ precision ${e.precision} usampler3D;
+ precision ${e.precision} usamplerCube;
+ precision ${e.precision} usampler2DArray;
+ `;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}function KD(e){return $D[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function XD(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return WD[e.envMapMode]||"ENVMAP_TYPE_CUBE"}function JD(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return qD[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}function YD(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return ZD[e.combine]||"ENVMAP_BLENDING_NONE"}function QD(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 eL(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:a,fragmentShader:o}=n,c=KD(n),l=XD(n),u=JD(n),d=YD(n),f=QD(n),h=FD(n),y=UD(s),g=r.createProgram(),m,p,b=n.glslVersion?"#version "+n.glslVersion+`
+`:"";if(n.isRawShaderMaterial){if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(il).join(`
+`),m.length>0)m+=`
+`;if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(il).join(`
+`),p.length>0)p+=`
+`}else m=[ZT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,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(il).join(`
+`),p=[ZT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,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 "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.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!==Li?"#define TONE_MAPPING":"",n.toneMapping!==Li?st.tonemapping_pars_fragment:"",n.toneMapping!==Li?DD("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",st.colorspace_pars_fragment,OD("linearToOutputTexel",n.outputColorSpace),LD(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`].filter(il).join(`
+`);if(a=Gm(a),a=XT(a,n),a=qT(a,n),o=Gm(o),o=XT(o,n),o=qT(o,n),a=JT(a),o=JT(o),n.isRawShaderMaterial!==!0)b=`#version 300 es
+`,m=[h,"#define attribute in","#define varying out","#define texture2D texture"].join(`
+`)+`
+`+m,p=["#define varying in",n.glslVersion===fm?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===fm?"":"#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;let _=b+m+a,x=b+p+o,v=$T(r,r.VERTEX_SHADER,_),E=$T(r,r.FRAGMENT_SHADER,x);if(r.attachShader(g,v),r.attachShader(g,E),n.index0AttributeName!==void 0)r.bindAttribLocation(g,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(g,0,"position");r.linkProgram(g);function S(w){if(e.debug.checkShaderErrors){let I=r.getProgramInfoLog(g)||"",F=r.getShaderInfoLog(v)||"",N=r.getShaderInfoLog(E)||"",U=I.trim(),D=F.trim(),O=N.trim(),K=!0,B=!0;if(r.getProgramParameter(g,r.LINK_STATUS)===!1)if(K=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,g,v,E);else{let X=WT(r,v,"vertex"),q=WT(r,E,"fragment");Ze("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(g,r.VALIDATE_STATUS)+`
+
+Material Name: `+w.name+`
+Material Type: `+w.type+`
+
+Program Info Log: `+U+`
+`+X+`
+`+q)}else if(U!=="")je("WebGLProgram: Program Info Log:",U);else if(D===""||O==="")B=!1;if(B)w.diagnostics={runnable:K,programLog:U,vertexShader:{log:D,prefix:m},fragmentShader:{log:O,prefix:p}}}r.deleteShader(v),r.deleteShader(E),T=new rl(r,g),A=BD(r,g)}let T;this.getUniforms=function(){if(T===void 0)S(this);return T};let A;this.getAttributes=function(){if(A===void 0)S(this);return A};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(P===!1)P=r.getProgramParameter(g,ID);return P},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(g),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=CD++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=v,this.fragmentShader=E,this}class dA{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 fA(e),t.set(e,n);return n}}class fA{constructor(e){this.id=tL++,this.code=e,this.usedTimes=0}}function nL(e){return e===ya||e===td||e===nd}function iL(e,t,n,i,r,s){let a=new od,o=new dA,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:f}=i,h={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 y(T){if(c.add(T),T===0)return"uv";return`uv${T}`}function g(T,A,P,w,I,F){let N=w.fog,U=I.geometry,D=T.isMeshStandardMaterial||T.isMeshLambertMaterial||T.isMeshPhongMaterial?w.environment:null,O=T.isMeshStandardMaterial||T.isMeshLambertMaterial&&!T.envMap||T.isMeshPhongMaterial&&!T.envMap,K=t.get(T.envMap||D,O),B=!!K&&K.mapping===Fc?K.image.height:null,X=h[T.type];if(T.precision!==null){if(f=i.getMaxPrecision(T.precision),f!==T.precision)je("WebGLProgram.getParameters:",T.precision,"not supported, using",f,"instead.")}let q=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,le=q!==void 0?q.length:0,de=0;if(U.morphAttributes.position!==void 0)de=1;if(U.morphAttributes.normal!==void 0)de=2;if(U.morphAttributes.color!==void 0)de=3;let Me,pe,J,L;if(X){let zt=mr[X];Me=zt.vertexShader,pe=zt.fragmentShader}else{Me=T.vertexShader,pe=T.fragmentShader;let zt=o.getVertexShaderStage(T),wt=o.getFragmentShaderStage(T);o.update(T,zt,wt),J=zt.id,L=wt.id}let W=e.getRenderTarget(),te=e.state.buffers.depth.getReversed(),ie=I.isInstancedMesh===!0,ce=I.isBatchedMesh===!0,_e=!!T.map,Re=!!T.matcap,Oe=!!K,We=!!T.aoMap,Ye=!!T.lightMap,Kt=!!T.bumpMap&&T.wireframe===!1,lt=!!T.normalMap,Dt=!!T.displacementMap,Yt=!!T.emissiveMap,tn=!!T.metalnessMap,z=!!T.roughnessMap,xn=T.anisotropy>0,St=T.clearcoat>0,Wt=T.dispersion>0,C=T.retroreflectivity>0,M=T.iridescence>0,V=T.sheen>0,Q=T.transmission>0,he=xn&&!!T.anisotropyMap,ge=St&&!!T.clearcoatMap,ve=St&&!!T.clearcoatNormalMap,re=St&&!!T.clearcoatRoughnessMap,oe=M&&!!T.iridescenceMap,Ie=M&&!!T.iridescenceThicknessMap,Ve=V&&!!T.sheenColorMap,Ee=V&&!!T.sheenRoughnessMap,me=!!T.specularMap,Ge=!!T.specularColorMap,Xe=!!T.specularIntensityMap,_t=Q&&!!T.transmissionMap,G=Q&&!!T.thicknessMap,ye=!!T.gradientMap,ae=!!T.alphaMap,xe=T.alphaTest>0,Ce=!!T.alphaHash,fe=!!T.extensions,Ae=Li;if(T.toneMapped){if(W===null||W.isXRRenderTarget===!0)Ae=e.toneMapping}let it={shaderID:X,shaderType:T.type,shaderName:T.name,vertexShader:Me,fragmentShader:pe,defines:T.defines,customVertexShaderID:J,customFragmentShaderID:L,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:f,batching:ce,batchingColor:ce&&I._colorsTexture!==null,instancing:ie,instancingColor:ie&&I.instanceColor!==null,instancingMorph:ie&&I.morphTexture!==null,outputColorSpace:W===null?e.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:ot.workingColorSpace,alphaToCoverage:!!T.alphaToCoverage,map:_e,matcap:Re,envMap:Oe,envMapMode:Oe&&K.mapping,envMapCubeUVHeight:B,aoMap:We,lightMap:Ye,bumpMap:Kt,normalMap:lt,displacementMap:Dt,emissiveMap:Yt,normalMapObjectSpace:lt&&T.normalMapType===mT,normalMapTangentSpace:lt&&T.normalMapType===um,packedNormalMap:lt&&T.normalMapType===um&&nL(T.normalMap.format),metalnessMap:tn,roughnessMap:z,anisotropy:xn,anisotropyMap:he,clearcoat:St,clearcoatMap:ge,clearcoatNormalMap:ve,clearcoatRoughnessMap:re,dispersion:Wt,retroreflection:C,iridescence:M,iridescenceMap:oe,iridescenceThicknessMap:Ie,sheen:V,sheenColorMap:Ve,sheenRoughnessMap:Ee,specularMap:me,specularColorMap:Ge,specularIntensityMap:Xe,transmission:Q,transmissionMap:_t,thicknessMap:G,gradientMap:ye,opaque:T.transparent===!1&&T.blending===Dc&&T.alphaToCoverage===!1,alphaMap:ae,alphaTest:xe,alphaHash:Ce,combine:T.combine,mapUv:_e&&y(T.map.channel),aoMapUv:We&&y(T.aoMap.channel),lightMapUv:Ye&&y(T.lightMap.channel),bumpMapUv:Kt&&y(T.bumpMap.channel),normalMapUv:lt&&y(T.normalMap.channel),displacementMapUv:Dt&&y(T.displacementMap.channel),emissiveMapUv:Yt&&y(T.emissiveMap.channel),metalnessMapUv:tn&&y(T.metalnessMap.channel),roughnessMapUv:z&&y(T.roughnessMap.channel),anisotropyMapUv:he&&y(T.anisotropyMap.channel),clearcoatMapUv:ge&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:ve&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&y(T.sheenRoughnessMap.channel),specularMapUv:me&&y(T.specularMap.channel),specularColorMapUv:Ge&&y(T.specularColorMap.channel),specularIntensityMapUv:Xe&&y(T.specularIntensityMap.channel),transmissionMapUv:_t&&y(T.transmissionMap.channel),thicknessMapUv:G&&y(T.thicknessMap.channel),alphaMapUv:ae&&y(T.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(lt||xn),vertexNormals:!!U.attributes.normal,vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!U.attributes.uv&&(_e||ae),fog:!!N,useFog:T.fog===!0,fogExp2:!!N&&N.isFogExp2,flatShading:T.wireframe===!1&&(T.flatShading===!0||U.attributes.normal===void 0&&lt===!1&&(T.isMeshLambertMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isMeshPhysicalMaterial)),sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:te,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:de,numSunLights:A.sun.length,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numSunLightShadows:A.sunShadowMap.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:F.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:T.dithering,shadowMapEnabled:e.shadowMap.enabled&&P.length>0,shadowMapType:e.shadowMap.type,toneMapping:Ae,decodeVideoTexture:_e&&T.map.isVideoTexture===!0&&ot.getTransfer(T.map.colorSpace)===Bt,decodeVideoTextureEmissive:Yt&&T.emissiveMap.isVideoTexture===!0&&ot.getTransfer(T.emissiveMap.colorSpace)===Bt,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===xi,flipSided:T.side===Pn,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:fe&&T.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(fe&&T.extensions.multiDraw===!0||ce)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return it.vertexUv1s=c.has(1),it.vertexUv2s=c.has(2),it.vertexUv3s=c.has(3),c.clear(),it}function m(T){let A=[];if(T.shaderID)A.push(T.shaderID);else A.push(T.customVertexShaderID),A.push(T.customFragmentShaderID);if(T.defines!==void 0)for(let P in T.defines)A.push(P),A.push(T.defines[P]);if(T.isRawShaderMaterial===!1)p(A,T),b(A,T),A.push(e.outputColorSpace);return A.push(T.customProgramCacheKey),A.join()}function p(T,A){T.push(A.precision),T.push(A.outputColorSpace),T.push(A.envMapMode),T.push(A.envMapCubeUVHeight),T.push(A.mapUv),T.push(A.alphaMapUv),T.push(A.lightMapUv),T.push(A.aoMapUv),T.push(A.bumpMapUv),T.push(A.normalMapUv),T.push(A.displacementMapUv),T.push(A.emissiveMapUv),T.push(A.metalnessMapUv),T.push(A.roughnessMapUv),T.push(A.anisotropyMapUv),T.push(A.clearcoatMapUv),T.push(A.clearcoatNormalMapUv),T.push(A.clearcoatRoughnessMapUv),T.push(A.iridescenceMapUv),T.push(A.iridescenceThicknessMapUv),T.push(A.sheenColorMapUv),T.push(A.sheenRoughnessMapUv),T.push(A.specularMapUv),T.push(A.specularColorMapUv),T.push(A.specularIntensityMapUv),T.push(A.transmissionMapUv),T.push(A.thicknessMapUv),T.push(A.combine),T.push(A.fogExp2),T.push(A.sizeAttenuation),T.push(A.morphTargetsCount),T.push(A.morphAttributeCount),T.push(A.numSunLights),T.push(A.numDirLights),T.push(A.numPointLights),T.push(A.numSpotLights),T.push(A.numSpotLightMaps),T.push(A.numHemiLights),T.push(A.numRectAreaLights),T.push(A.numSunLightShadows),T.push(A.numDirLightShadows),T.push(A.numPointLightShadows),T.push(A.numSpotLightShadows),T.push(A.numSpotLightShadowsWithMaps),T.push(A.numLightProbes),T.push(A.shadowMapType),T.push(A.toneMapping),T.push(A.numClippingPlanes),T.push(A.numClipIntersection),T.push(A.depthPacking)}function b(T,A){if(a.disableAll(),A.instancing)a.enable(0);if(A.instancingColor)a.enable(1);if(A.instancingMorph)a.enable(2);if(A.matcap)a.enable(3);if(A.envMap)a.enable(4);if(A.normalMapObjectSpace)a.enable(5);if(A.normalMapTangentSpace)a.enable(6);if(A.clearcoat)a.enable(7);if(A.iridescence)a.enable(8);if(A.alphaTest)a.enable(9);if(A.vertexColors)a.enable(10);if(A.vertexAlphas)a.enable(11);if(A.vertexUv1s)a.enable(12);if(A.vertexUv2s)a.enable(13);if(A.vertexUv3s)a.enable(14);if(A.vertexTangents)a.enable(15);if(A.anisotropy)a.enable(16);if(A.alphaHash)a.enable(17);if(A.batching)a.enable(18);if(A.dispersion)a.enable(19);if(A.retroreflection)a.enable(24);if(A.batchingColor)a.enable(20);if(A.gradientMap)a.enable(21);if(A.packedNormalMap)a.enable(22);if(A.vertexNormals)a.enable(23);if(T.push(a.mask),a.disableAll(),A.fog)a.enable(0);if(A.useFog)a.enable(1);if(A.flatShading)a.enable(2);if(A.logarithmicDepthBuffer)a.enable(3);if(A.reversedDepthBuffer)a.enable(4);if(A.skinning)a.enable(5);if(A.morphTargets)a.enable(6);if(A.morphNormals)a.enable(7);if(A.morphColors)a.enable(8);if(A.premultipliedAlpha)a.enable(9);if(A.shadowMapEnabled)a.enable(10);if(A.doubleSided)a.enable(11);if(A.flipSided)a.enable(12);if(A.useDepthPacking)a.enable(13);if(A.dithering)a.enable(14);if(A.transmission)a.enable(15);if(A.sheen)a.enable(16);if(A.opaque)a.enable(17);if(A.pointsUvs)a.enable(18);if(A.decodeVideoTexture)a.enable(19);if(A.decodeVideoTextureEmissive)a.enable(20);if(A.alphaToCoverage)a.enable(21);if(A.numLightProbeGrids>0)a.enable(22);if(A.hasPositionAttribute)a.enable(23);T.push(a.mask)}function _(T){let A=h[T.type],P;if(A){let w=mr[A];P=MT.clone(w.uniforms)}else P=T.uniforms;return P}function x(T,A){let P=u.get(A);if(P!==void 0)++P.usedTimes;else P=new eL(e,A,T,r),l.push(P),u.set(A,P);return P}function v(T){if(--T.usedTimes===0){let A=l.indexOf(T);l[A]=l[l.length-1],l.pop(),u.delete(T.cacheKey),T.destroy()}}function E(T){o.remove(T)}function S(){o.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:_,acquireProgram:x,releaseProgram:v,releaseShaderCache:E,programs:l,dispose:S}}function rL(){let e=new WeakMap;function t(a){return e.has(a)}function n(a){let o=e.get(a);if(o===void 0)o={},e.set(a,o);return o}function i(a){e.delete(a)}function r(a,o,c){e.get(a)[o]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function sL(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 YT(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 QT(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function a(f){let h=0;if(f.isInstancedMesh)h+=2;if(f.isSkinnedMesh)h+=1;return h}function o(f,h,y,g,m,p){let b=e[t];if(b===void 0)b={id:f.id,object:f,geometry:h,material:y,materialVariant:a(f),groupOrder:g,renderOrder:f.renderOrder,z:m,group:p},e[t]=b;else b.id=f.id,b.object=f,b.geometry=h,b.material=y,b.materialVariant=a(f),b.groupOrder=g,b.renderOrder=f.renderOrder,b.z=m,b.group=p;return t++,b}function c(f,h,y,g,m,p,b){if(b.reversedDepth===!0)m=-m;let _=o(f,h,y,g,m,p);if(y.transmission>0)i.push(_);else if(y.transparent===!0)r.push(_);else n.push(_)}function l(f,h,y,g,m,p){let b=o(f,h,y,g,m,p);if(y.transmission>0)i.unshift(b);else if(y.transparent===!0)r.unshift(b);else n.unshift(b)}function u(f,h){if(n.length>1)n.sort(f||sL);if(i.length>1)i.sort(h||YT);if(r.length>1)r.sort(h||YT)}function d(){for(let f=t,h=e.length;f<h;f++){let y=e[f];if(y.id===null)break;y.id=null,y.object=null,y.geometry=null,y.material=null,y.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function aL(){let e=new WeakMap;function t(i,r){let s=e.get(i),a;if(s===void 0)a=new QT,e.set(i,[a]);else if(r>=s.length)a=new QT,s.push(a);else a=s[r];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function oL(){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 j,color:new qe};break;case"SpotLight":n={position:new j,direction:new j,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new j,color:new qe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new j,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":n={color:new qe,position:new j,halfWidth:new j,halfHeight:new j};break}return e[t.id]=n,n}}}function cL(){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}}}function uL(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function dL(e){let t=new oL,n=cL(),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 j);let r=new j,s=new Qe,a=new Qe;function o(l){let u=0,d=0,f=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let h=0,y=0,g=0,m=0,p=0,b=0,_=0,x=0,v=0,E=0,S=0,T=0,A=0,P=0;l.sort(uL);for(let I=0,F=l.length;I<F;I++){let N=l[I],{color:U,intensity:D,distance:O}=N,K=null;if(N.shadow&&N.shadow.map)if(N.shadow.map.texture.format===ya)K=N.shadow.map.texture;else K=N.shadow.map.depthTexture||N.shadow.map.texture;if(N.isAmbientLight)u+=U.r*D,d+=U.g*D,f+=U.b*D;else if(N.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(N.sh.coefficients[B],D);P++}else if(N.isSunLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize.copy(X.mapSize).multiply(X.getFrameExtents()),i.sunShadow[y]=q,i.sunShadowMap[y]=K;let le=X.getViewportCount();for(let de=0;de<le;de++)i.sunShadowMatrix[g+de]=X.getMatrix(de),i.sunShadowCascade[g+de]=X._cascadeData[de];g+=le,y++}i.sun[h]=B,h++}else if(N.isDirectionalLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.directionalShadow[m]=q,i.directionalShadowMap[m]=K,i.directionalShadowMatrix[m]=N.shadow.matrix,v++}i.directional[m]=B,m++}else if(N.isSpotLight){let B=t.get(N);B.position.setFromMatrixPosition(N.matrixWorld),B.color.copy(U).multiplyScalar(D),B.distance=O,B.coneCos=Math.cos(N.angle),B.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),B.decay=N.decay,i.spot[b]=B;let X=N.shadow;if(N.map){if(i.spotLightMap[T]=N.map,T++,X.updateMatrices(N),N.castShadow)A++}if(i.spotLightMatrix[b]=X.matrix,N.castShadow){let q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.spotShadow[b]=q,i.spotShadowMap[b]=K,S++}b++}else if(N.isRectAreaLight){let B=t.get(N);B.color.copy(U).multiplyScalar(D),B.halfWidth.set(N.width*0.5,0,0),B.halfHeight.set(0,N.height*0.5,0),i.rectArea[_]=B,_++}else if(N.isPointLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),B.distance=N.distance,B.decay=N.decay,N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,q.shadowCameraNear=X.camera.near,q.shadowCameraFar=X.camera.far,i.pointShadow[p]=q,i.pointShadowMap[p]=K,i.pointShadowMatrix[p]=N.shadow.matrix,E++}i.point[p]=B,p++}else if(N.isHemisphereLight){let B=t.get(N);B.skyColor.copy(N.color).multiplyScalar(D),B.groundColor.copy(N.groundColor).multiplyScalar(D),i.hemi[x]=B,x++}}if(_>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=Te.LTC_FLOAT_1,i.rectAreaLTC2=Te.LTC_FLOAT_2;else i.rectAreaLTC1=Te.LTC_HALF_1,i.rectAreaLTC2=Te.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=f;let w=i.hash;if(w.sunLength!==h||w.directionalLength!==m||w.pointLength!==p||w.spotLength!==b||w.rectAreaLength!==_||w.hemiLength!==x||w.numSunShadows!==y||w.numDirectionalShadows!==v||w.numPointShadows!==E||w.numSpotShadows!==S||w.numSpotMaps!==T||w.numLightProbes!==P)i.sun.length=h,i.directional.length=m,i.spot.length=b,i.rectArea.length=_,i.point.length=p,i.hemi.length=x,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=g,i.sunShadowCascade.length=g,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.directionalShadowMatrix.length=v,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=S,i.spotShadowMap.length=S,i.spotLightMatrix.length=S+T-A,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=P,w.sunLength=h,w.directionalLength=m,w.pointLength=p,w.spotLength=b,w.rectAreaLength=_,w.hemiLength=x,w.numSunShadows=y,w.numDirectionalShadows=v,w.numPointShadows=E,w.numSpotShadows=S,w.numSpotMaps=T,w.numLightProbes=P,i.version=lL++}function c(l,u){let d=0,f=0,h=0,y=0,g=0,m=0,p=u.matrixWorldInverse;for(let b=0,_=l.length;b<_;b++){let x=l[b];if(x.isSunLight){let v=i.sun[d];v.direction.setFromMatrixPosition(x.matrixWorld),v.direction.transformDirection(p),d++}else if(x.isDirectionalLight){let v=i.directional[f];v.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),f++}else if(x.isSpotLight){let v=i.spot[y];v.position.setFromMatrixPosition(x.matrixWorld),v.position.applyMatrix4(p),v.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),y++}else if(x.isRectAreaLight){let v=i.rectArea[g];v.position.setFromMatrixPosition(x.matrixWorld),v.position.applyMatrix4(p),a.identity(),s.copy(x.matrixWorld),s.premultiply(p),a.extractRotation(s),v.halfWidth.set(x.width*0.5,0,0),v.halfHeight.set(0,x.height*0.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),g++}else if(x.isPointLight){let v=i.point[h];v.position.setFromMatrixPosition(x.matrixWorld),v.position.applyMatrix4(p),h++}else if(x.isHemisphereLight){let v=i.hemi[m];v.direction.setFromMatrixPosition(x.matrixWorld),v.direction.transformDirection(p),m++}}}return{setup:o,setupView:c,state:i}}function eA(e){let t=new dL(e),n=[],i=[],r=[];function s(f){d.camera=f,n.length=0,i.length=0,r.length=0}function a(f){n.push(f)}function o(f){i.push(f)}function c(f){r.push(f)}function l(){t.setup(n)}function u(f){t.setupView(n,f)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function fL(e){let t=new WeakMap;function n(r,s=0){let a=t.get(r),o;if(a===void 0)o=new eA(e),t.set(r,[o]);else if(s>=a.length)o=new eA(e),a.push(o);else o=a[s];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}function bL(e,t,n){let i=new Wc,r=new Ke,s=new Ke,a=new Nt,o=new vm,c=new Em,l={},u=n.maxTextureSize,d={[us]:Pn,[Pn]:us,[xi]:xi},f=new _i({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ke},radius:{value:4}},vertexShader:hL,fragmentShader:pL}),h=f.clone();h.defines.HORIZONTAL_PASS=1;let y=new On;y.setAttribute("position",new vn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let g=new jt(y,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kc;let p=this.type;this.render=function(E,S,T){if(m.enabled===!1)return;if(m.autoUpdate===!1&&m.needsUpdate===!1)return;if(E.length===0)return;if(this.type===NE)je("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=kc;let A=e.getRenderTarget(),P=e.getActiveCubeFace(),w=e.getActiveMipmapLevel(),I=e.state;if(I.setBlending(lr),I.buffers.depth.getReversed()===!0)I.buffers.color.setClear(0,0,0,0);else I.buffers.color.setClear(1,1,1,1);I.buffers.depth.setTest(!0),I.setScissorTest(!1);let F=p!==this.type;if(F)S.traverse(function(N){if(N.material)if(Array.isArray(N.material))N.material.forEach((U)=>U.needsUpdate=!0);else N.material.needsUpdate=!0});for(let N=0,U=E.length;N<U;N++){let D=E[N],O=D.shadow;if(O===void 0){je("WebGLShadowMap:",D,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let K=O.getFrameExtents();if(r.multiply(K),s.copy(O.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/K.x),r.x=s.x*K.x,O.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/K.y),r.y=s.y*K.y,O.mapSize.y=s.y}let B=e.state.buffers.depth.getReversed();if(O.camera._reversedDepth=B,O.map===null||F===!0){if(O.map!==null){if(O.map.depthTexture!==null)O.map.depthTexture.dispose(),O.map.depthTexture=null;O.map.dispose()}if(this.type===go){if(D.isPointLight){je("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new ai(r.x,r.y,{format:ya,type:dr,minFilter:En,magFilter:En,generateMipmaps:!1}),O.map.texture.name=D.name+".shadowMap",O.map.depthTexture=new _a(r.x,r.y,Fr),O.map.depthTexture.name=D.name+".shadowMapDepth",O.map.depthTexture.format=ga,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Fi,O.map.depthTexture.magFilter=Fi}else{if(D.isPointLight)O.map=new $m(r.x),O.map.depthTexture=new ym(r.x,ds);else O.map=new ai(r.x,r.y),O.map.depthTexture=new _a(r.x,r.y,ds);if(O.map.depthTexture.name=D.name+".shadowMap",O.map.depthTexture.format=ga,this.type===kc)O.map.depthTexture.compareFunction=B?sd:rd,O.map.depthTexture.minFilter=En,O.map.depthTexture.magFilter=En;else O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Fi,O.map.depthTexture.magFilter=Fi}O.camera.updateProjectionMatrix()}if(O.map.isWebGLCubeRenderTarget!==!0&&(O.map.width!==r.x||O.map.height!==r.y))O.map.setSize(r.x,r.y);let X=O.map.isWebGLCubeRenderTarget?6:O.getViewportCount();if(D.isPointLight!==!0)O.updateMatrices(D,T);for(let q=0;q<X;q++){let le=O.getCamera(q);if(D.isPointLight){let{camera:de,matrix:Me}=O,pe=D.distance||de.far;if(pe!==de.far)de.far=pe,de.updateProjectionMatrix();nl.setFromMatrixPosition(D.matrixWorld),de.position.copy(nl),jm.copy(de.position),jm.add(mL[q]),de.up.copy(gL[q]),de.lookAt(jm),de.updateMatrixWorld(),Me.makeTranslation(-nl.x,-nl.y,-nl.z),tA.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),O._frustum.setFromProjectionMatrix(tA,de.coordinateSystem,de.reversedDepth)}if(O.map.isWebGLCubeRenderTarget)e.setRenderTarget(O.map,q),e.clear();else{if(q===0)e.setRenderTarget(O.map),e.clear();let de=O.getViewport(q);a.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),I.viewport(a)}i=O.getFrustum(q),x(S,T,le,D,this.type)}if(O.isPointLightShadow!==!0&&this.type===go)b(O,T);O.needsUpdate=!1}p=this.type,m.needsUpdate=!1,e.setRenderTarget(A,P,w)};function b(E,S){let T=t.update(g);if(f.defines.VSM_SAMPLES!==E.blurSamples)f.defines.VSM_SAMPLES=E.blurSamples,h.defines.VSM_SAMPLES=E.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new ai(r.x,r.y,{format:ya,type:dr});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);f.uniforms.shadow_pass.value=E.map.depthTexture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(S,null,T,f,g,null),h.uniforms.shadow_pass.value=E.mapPass.texture,h.uniforms.resolution.value.set(E.map.width,E.map.height),h.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(S,null,T,h,g,null)}function _(E,S,T,A){let P=null,w=T.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(w!==void 0)P=w;else if(P=T.isPointLight===!0?c:o,e.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0||S.alphaToCoverage===!0){let I=P.uuid,F=S.uuid,N=l[I];if(N===void 0)N={},l[I]=N;let U=N[F];if(U===void 0)U=P.clone(),N[F]=U,S.addEventListener("dispose",v);P=U}if(P.visible=S.visible,P.wireframe=S.wireframe,A===go)P.side=S.shadowSide!==null?S.shadowSide:S.side;else P.side=S.shadowSide!==null?S.shadowSide:d[S.side];if(P.alphaMap=S.alphaMap,P.alphaTest=S.alphaToCoverage===!0?0.5:S.alphaTest,P.map=S.map,P.clipShadows=S.clipShadows,P.clippingPlanes=S.clippingPlanes,P.clipIntersection=S.clipIntersection,P.displacementMap=S.displacementMap,P.displacementScale=S.displacementScale,P.displacementBias=S.displacementBias,P.wireframeLinewidth=S.wireframeLinewidth,P.linewidth=S.linewidth,T.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let I=e.properties.get(P);I.light=T}return P}function x(E,S,T,A,P){if(E.visible===!1)return;if(E.layers.test(S.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&P===go)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,E.matrixWorld);let F=t.update(E),N=E.material;if(Array.isArray(N)){let U=F.groups;for(let D=0,O=U.length;D<O;D++){let K=U[D],B=N[K.materialIndex];if(B&&B.visible){let X=_(E,B,A,P);E.onBeforeShadow(e,E,S,T,F,X,K),e.renderBufferDirect(T,null,F,X,E,K),E.onAfterShadow(e,E,S,T,F,X,K)}}}else if(N.visible){let U=_(E,N,A,P);E.onBeforeShadow(e,E,S,T,F,U,null),e.renderBufferDirect(T,null,F,U,E,null),E.onAfterShadow(e,E,S,T,F,U,null)}}}let I=E.children;for(let F=0,N=I.length;F<N;F++)x(I[F],S,T,A,P)}function v(E){E.target.removeEventListener("dispose",v);for(let T in l){let A=l[T],P=E.target.uuid;if(P in A)A[P].dispose(),delete A[P]}}}function yL(e,t){function n(){let G=!1,ye=new Nt,ae=null,xe=new Nt(0,0,0,0);return{setMask:function(Ce){if(ae!==Ce&&!G)e.colorMask(Ce,Ce,Ce,Ce),ae=Ce},setLocked:function(Ce){G=Ce},setClear:function(Ce,fe,Ae,it,zt){if(zt===!0)Ce*=it,fe*=it,Ae*=it;if(ye.set(Ce,fe,Ae,it),xe.equals(ye)===!1)e.clearColor(Ce,fe,Ae,it),xe.copy(ye)},reset:function(){G=!1,ae=null,xe.set(-1,0,0,0)}}}function i(){let G=!1,ye=!1,ae=null,xe=null,Ce=null;return{setReversed:function(fe){if(ye!==fe){let Ae=t.get("EXT_clip_control");if(fe)Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT);else Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT);ye=fe;let it=Ce;Ce=null,this.setClear(it)}},getReversed:function(){return ye},setTest:function(fe){if(fe)W(e.DEPTH_TEST);else te(e.DEPTH_TEST)},setMask:function(fe){if(ae!==fe&&!G)e.depthMask(fe),ae=fe},setFunc:function(fe){if(ye)fe=ST[fe];if(xe!==fe){switch(fe){case YE:e.depthFunc(e.NEVER);break;case QE:e.depthFunc(e.ALWAYS);break;case eT:e.depthFunc(e.LESS);break;case xp:e.depthFunc(e.LEQUAL);break;case tT:e.depthFunc(e.EQUAL);break;case nT:e.depthFunc(e.GEQUAL);break;case iT:e.depthFunc(e.GREATER);break;case rT:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=fe}},setLocked:function(fe){G=fe},setClear:function(fe){if(Ce!==fe){if(Ce=fe,ye)fe=1-fe;e.clearDepth(fe)}},reset:function(){G=!1,ae=null,xe=null,Ce=null,ye=!1}}}function r(){let G=!1,ye=null,ae=null,xe=null,Ce=null,fe=null,Ae=null,it=null,zt=null;return{setTest:function(wt){if(!G)if(wt)W(e.STENCIL_TEST);else te(e.STENCIL_TEST)},setMask:function(wt){if(ye!==wt&&!G)e.stencilMask(wt),ye=wt},setFunc:function(wt,$i,Tr){if(ae!==wt||xe!==$i||Ce!==Tr)e.stencilFunc(wt,$i,Tr),ae=wt,xe=$i,Ce=Tr},setOp:function(wt,$i,Tr){if(fe!==wt||Ae!==$i||it!==Tr)e.stencilOp(wt,$i,Tr),fe=wt,Ae=$i,it=Tr},setLocked:function(wt){G=wt},setClear:function(wt){if(zt!==wt)e.clearStencil(wt),zt=wt},reset:function(){G=!1,ye=null,ae=null,xe=null,Ce=null,fe=null,Ae=null,it=null,zt=null}}}let s=new n,a=new i,o=new r,c=new WeakMap,l=new WeakMap,u={},d={},f={},h=new WeakMap,y=[],g=null,m=!1,p=null,b=null,_=null,x=null,v=null,E=null,S=null,T=new qe(0,0,0),A=0,P=!1,w=null,I=null,F=null,N=null,U=null,D=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,K=0,B=e.getParameter(e.VERSION);if(B.indexOf("WebGL")!==-1)K=parseFloat(/^WebGL (\d)/.exec(B)[1]),O=K>=1;else if(B.indexOf("OpenGL ES")!==-1)K=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),O=K>=2;let X=null,q={},le=e.getParameter(e.SCISSOR_BOX),de=e.getParameter(e.VIEWPORT),Me=new Nt().fromArray(le),pe=new Nt().fromArray(de);function J(G,ye,ae,xe){let Ce=new Uint8Array(4),fe=e.createTexture();e.bindTexture(G,fe),e.texParameteri(G,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(G,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Ae=0;Ae<ae;Ae++)if(G===e.TEXTURE_3D||G===e.TEXTURE_2D_ARRAY)e.texImage3D(ye,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Ce);else e.texImage2D(ye+Ae,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Ce);return fe}let L={};L[e.TEXTURE_2D]=J(e.TEXTURE_2D,e.TEXTURE_2D,1),L[e.TEXTURE_CUBE_MAP]=J(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),L[e.TEXTURE_2D_ARRAY]=J(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),L[e.TEXTURE_3D]=J(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),W(e.DEPTH_TEST),a.setFunc(xp),Kt(!1),lt(mp),W(e.CULL_FACE),We(lr);function W(G){if(u[G]!==!0)e.enable(G),u[G]=!0}function te(G){if(u[G]!==!1)e.disable(G),u[G]=!1}function ie(G,ye){if(f[G]!==ye){if(e.bindFramebuffer(G,ye),f[G]=ye,G===e.DRAW_FRAMEBUFFER)f[e.FRAMEBUFFER]=ye;if(G===e.FRAMEBUFFER)f[e.DRAW_FRAMEBUFFER]=ye;return!0}return!1}function ce(G,ye){let ae=y,xe=!1;if(G){if(ae=h.get(ye),ae===void 0)ae=[],h.set(ye,ae);let Ce=G.textures;if(ae.length!==Ce.length||ae[0]!==e.COLOR_ATTACHMENT0){for(let fe=0,Ae=Ce.length;fe<Ae;fe++)ae[fe]=e.COLOR_ATTACHMENT0+fe;ae.length=Ce.length,xe=!0}}else if(ae[0]!==e.BACK)ae[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(ae)}function _e(G){if(g!==G)return e.useProgram(G),g=G,!0;return!1}let Re={[bo]:e.FUNC_ADD,[OE]:e.FUNC_SUBTRACT,[kE]:e.FUNC_REVERSE_SUBTRACT};Re[DE]=e.MIN,Re[LE]=e.MAX;let Oe={[FE]:e.ZERO,[UE]:e.ONE,[BE]:e.SRC_COLOR,[VE]:e.SRC_ALPHA,[WE]:e.SRC_ALPHA_SATURATE,[$E]:e.DST_COLOR,[HE]:e.DST_ALPHA,[zE]:e.ONE_MINUS_SRC_COLOR,[jE]:e.ONE_MINUS_SRC_ALPHA,[KE]:e.ONE_MINUS_DST_COLOR,[GE]:e.ONE_MINUS_DST_ALPHA,[XE]:e.CONSTANT_COLOR,[qE]:e.ONE_MINUS_CONSTANT_COLOR,[JE]:e.CONSTANT_ALPHA,[ZE]:e.ONE_MINUS_CONSTANT_ALPHA};function We(G,ye,ae,xe,Ce,fe,Ae,it,zt,wt){if(G===lr){if(m===!0)te(e.BLEND),m=!1;return}if(m===!1)W(e.BLEND),m=!0;if(G!==PE){if(G!==p||wt!==P){if(b!==bo||v!==bo)e.blendEquation(e.FUNC_ADD),b=bo,v=bo;if(wt)switch(G){case Dc:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case gp:e.blendFunc(e.ONE,e.ONE);break;case bp:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case yp:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ze("WebGLState: Invalid blending: ",G);break}else switch(G){case Dc:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case gp:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case bp:Ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case yp:Ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ze("WebGLState: Invalid blending: ",G);break}_=null,x=null,E=null,S=null,T.set(0,0,0),A=0,p=G,P=wt}return}if(Ce=Ce||ye,fe=fe||ae,Ae=Ae||xe,ye!==b||Ce!==v)e.blendEquationSeparate(Re[ye],Re[Ce]),b=ye,v=Ce;if(ae!==_||xe!==x||fe!==E||Ae!==S)e.blendFuncSeparate(Oe[ae],Oe[xe],Oe[fe],Oe[Ae]),_=ae,x=xe,E=fe,S=Ae;if(it.equals(T)===!1||zt!==A)e.blendColor(it.r,it.g,it.b,zt),T.copy(it),A=zt;p=G,P=!1}function Ye(G,ye){G.side===xi?te(e.CULL_FACE):W(e.CULL_FACE);let ae=G.side===Pn;if(ye)ae=!ae;Kt(ae),G.blending===Dc&&G.transparent===!1?We(lr):We(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),a.setFunc(G.depthFunc),a.setTest(G.depthTest),a.setMask(G.depthWrite),s.setMask(G.colorWrite);let xe=G.stencilWrite;if(o.setTest(xe),xe)o.setMask(G.stencilWriteMask),o.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),o.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass);Yt(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?W(e.SAMPLE_ALPHA_TO_COVERAGE):te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Kt(G){if(w!==G){if(G)e.frontFace(e.CW);else e.frontFace(e.CCW);w=G}}function lt(G){if(G!==IE){if(W(e.CULL_FACE),G!==I)if(G===mp)e.cullFace(e.BACK);else if(G===CE)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else te(e.CULL_FACE);I=G}function Dt(G){if(G!==F){if(O)e.lineWidth(G);F=G}}function Yt(G,ye,ae){if(G){if(W(e.POLYGON_OFFSET_FILL),N!==ye||U!==ae){if(N=ye,U=ae,a.getReversed())ye=-ye;e.polygonOffset(ye,ae)}}else te(e.POLYGON_OFFSET_FILL)}function tn(G){if(G)W(e.SCISSOR_TEST);else te(e.SCISSOR_TEST)}function z(G){if(G===void 0)G=e.TEXTURE0+D-1;if(X!==G)e.activeTexture(G),X=G}function xn(G,ye,ae){if(ae===void 0)if(X===null)ae=e.TEXTURE0+D-1;else ae=X;let xe=q[ae];if(xe===void 0)xe={type:void 0,texture:void 0},q[ae]=xe;if(xe.type!==G||xe.texture!==ye){if(X!==ae)e.activeTexture(ae),X=ae;e.bindTexture(G,ye||L[G]),xe.type=G,xe.texture=ye}}function St(){let G=q[X];if(G!==void 0&&G.type!==void 0)e.bindTexture(G.type,null),G.type=void 0,G.texture=void 0}function Wt(){try{e.compressedTexImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function C(){try{e.compressedTexImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function M(){try{e.texSubImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function V(){try{e.texSubImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function Q(){try{e.compressedTexSubImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function he(){try{e.compressedTexSubImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function ge(){try{e.texStorage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function ve(){try{e.texStorage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function re(){try{e.texImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function oe(){try{e.texImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function Ie(G){if(d[G]!==void 0)return d[G];else return e.getParameter(G)}function Ve(G,ye){if(d[G]!==ye)e.pixelStorei(G,ye),d[G]=ye}function Ee(G){if(Me.equals(G)===!1)e.scissor(G.x,G.y,G.z,G.w),Me.copy(G)}function me(G){if(pe.equals(G)===!1)e.viewport(G.x,G.y,G.z,G.w),pe.copy(G)}function Ge(G,ye){let ae=l.get(ye);if(ae===void 0)ae=new WeakMap,l.set(ye,ae);let xe=ae.get(G);if(xe===void 0)xe=e.getUniformBlockIndex(ye,G.name),ae.set(G,xe)}function Xe(G,ye){let xe=l.get(ye).get(G);if(c.get(ye)!==xe)e.uniformBlockBinding(ye,xe,G.__bindingPointIndex),c.set(ye,xe)}function _t(){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),a.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={},d={},X=null,q={},f={},h=new WeakMap,y=[],g=null,m=!1,p=null,b=null,_=null,x=null,v=null,E=null,S=null,T=new qe(0,0,0),A=0,P=!1,w=null,I=null,F=null,N=null,U=null,Me.set(0,0,e.canvas.width,e.canvas.height),pe.set(0,0,e.canvas.width,e.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:W,disable:te,bindFramebuffer:ie,drawBuffers:ce,useProgram:_e,setBlending:We,setMaterial:Ye,setFlipSided:Kt,setCullFace:lt,setLineWidth:Dt,setPolygonOffset:Yt,setScissorTest:tn,activeTexture:z,bindTexture:xn,unbindTexture:St,compressedTexImage2D:Wt,compressedTexImage3D:C,texImage2D:re,texImage3D:oe,pixelStorei:Ve,getParameter:Ie,updateUBOMapping:Ge,uniformBlockBinding:Xe,texStorage2D:ge,texStorage3D:ve,texSubImage2D:M,texSubImage3D:V,compressedTexSubImage2D:Q,compressedTexSubImage3D:he,scissor:Ee,viewport:me,reset:_t}}function xL(e,t,n,i,r,s,a){let o=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,d=new Set,f,h=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(C){}function g(C,M){return y?new OffscreenCanvas(C,M):ho("canvas")}function m(C,M,V){let Q=1,he=Wt(C);if(he.width>V||he.height>V)Q=V/Math.max(he.width,he.height);if(Q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){let ge=Math.floor(Q*he.width),ve=Math.floor(Q*he.height);if(f===void 0)f=g(ge,ve);let re=M?g(ge,ve):f;return re.width=ge,re.height=ve,re.getContext("2d").drawImage(C,0,0,ge,ve),je("WebGLRenderer: Texture has been resized from ("+he.width+"x"+he.height+") to ("+ge+"x"+ve+")."),re}else{if("data"in C)je("WebGLRenderer: Image in DataTexture is too big ("+he.width+"x"+he.height+").");return C}return C}function p(C){return C.generateMipmaps}function b(C){e.generateMipmap(C)}function _(C){if(C.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(C.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function x(C,M,V,Q,he,ge=!1){if(C!==null){if(e[C]!==void 0)return e[C];je("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let ve;if(Q){if(ve=t.get("EXT_texture_norm16"),!ve)je("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let re=M;if(M===e.RED){if(V===e.FLOAT)re=e.R32F;if(V===e.HALF_FLOAT)re=e.R16F;if(V===e.UNSIGNED_BYTE)re=e.R8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.R16_EXT;if(V===e.SHORT&&ve)re=ve.R16_SNORM_EXT}if(M===e.RED_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.R8UI;if(V===e.UNSIGNED_SHORT)re=e.R16UI;if(V===e.UNSIGNED_INT)re=e.R32UI;if(V===e.BYTE)re=e.R8I;if(V===e.SHORT)re=e.R16I;if(V===e.INT)re=e.R32I}if(M===e.RG){if(V===e.FLOAT)re=e.RG32F;if(V===e.HALF_FLOAT)re=e.RG16F;if(V===e.UNSIGNED_BYTE)re=e.RG8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RG16_EXT;if(V===e.SHORT&&ve)re=ve.RG16_SNORM_EXT}if(M===e.RG_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RG8UI;if(V===e.UNSIGNED_SHORT)re=e.RG16UI;if(V===e.UNSIGNED_INT)re=e.RG32UI;if(V===e.BYTE)re=e.RG8I;if(V===e.SHORT)re=e.RG16I;if(V===e.INT)re=e.RG32I}if(M===e.RGB_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGB8UI;if(V===e.UNSIGNED_SHORT)re=e.RGB16UI;if(V===e.UNSIGNED_INT)re=e.RGB32UI;if(V===e.BYTE)re=e.RGB8I;if(V===e.SHORT)re=e.RGB16I;if(V===e.INT)re=e.RGB32I}if(M===e.RGBA_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGBA8UI;if(V===e.UNSIGNED_SHORT)re=e.RGBA16UI;if(V===e.UNSIGNED_INT)re=e.RGBA32UI;if(V===e.BYTE)re=e.RGBA8I;if(V===e.SHORT)re=e.RGBA16I;if(V===e.INT)re=e.RGBA32I}if(M===e.RGB){if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGB16_EXT;if(V===e.SHORT&&ve)re=ve.RGB16_SNORM_EXT;if(V===e.UNSIGNED_INT_5_9_9_9_REV)re=e.RGB9_E5;if(V===e.UNSIGNED_INT_10F_11F_11F_REV)re=e.R11F_G11F_B10F}if(M===e.RGBA){let oe=ge?dm:ot.getTransfer(he);if(V===e.FLOAT)re=e.RGBA32F;if(V===e.HALF_FLOAT)re=e.RGBA16F;if(V===e.UNSIGNED_BYTE)re=oe===Bt?e.SRGB8_ALPHA8:e.RGBA8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGBA16_EXT;if(V===e.SHORT&&ve)re=ve.RGBA16_SNORM_EXT;if(V===e.UNSIGNED_SHORT_4_4_4_4)re=e.RGBA4;if(V===e.UNSIGNED_SHORT_5_5_5_1)re=e.RGB5_A1}if(re===e.R16F||re===e.R32F||re===e.RG16F||re===e.RG32F||re===e.RGBA16F||re===e.RGBA32F)t.get("EXT_color_buffer_float");return re}function v(C,M){let V;if(C){if(M===null||M===ds||M===Eo)V=e.DEPTH24_STENCIL8;else if(M===Fr)V=e.DEPTH32F_STENCIL8;else if(M===Uc)V=e.DEPTH24_STENCIL8,je("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(M===null||M===ds||M===Eo)V=e.DEPTH_COMPONENT24;else if(M===Fr)V=e.DEPTH_COMPONENT32F;else if(M===Uc)V=e.DEPTH_COMPONENT16;return V}function E(C,M){if(p(C)===!0||C.isFramebufferTexture&&C.minFilter!==Fi&&C.minFilter!==En)return Math.log2(Math.max(M.width,M.height))+1;else if(C.mipmaps!==void 0&&C.mipmaps.length>0)return C.mipmaps.length;else if(C.isCompressedTexture&&Array.isArray(C.image))return M.mipmaps.length;else return 1}function S(C){let M=C.target;if(M.removeEventListener("dispose",S),A(M),M.isVideoTexture)u.delete(M);if(M.isHTMLTexture)d.delete(M)}function T(C){let M=C.target;M.removeEventListener("dispose",T),w(M)}function A(C){let M=i.get(C);if(M.__webglInit===void 0)return;let V=C.source,Q=h.get(V);if(Q){let he=Q[M.__cacheKey];if(he.usedTimes--,he.usedTimes===0)P(C);if(Object.keys(Q).length===0)h.delete(V)}i.remove(C)}function P(C){let M=i.get(C);e.deleteTexture(M.__webglTexture);let V=C.source,Q=h.get(V);delete Q[M.__cacheKey],a.memory.textures--}function w(C){let M=i.get(C);if(C.depthTexture)C.depthTexture.dispose(),i.remove(C.depthTexture);if(C.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(M.__webglFramebuffer[Q]))for(let he=0;he<M.__webglFramebuffer[Q].length;he++)e.deleteFramebuffer(M.__webglFramebuffer[Q][he]);else e.deleteFramebuffer(M.__webglFramebuffer[Q]);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer[Q])}else{if(Array.isArray(M.__webglFramebuffer))for(let Q=0;Q<M.__webglFramebuffer.length;Q++)e.deleteFramebuffer(M.__webglFramebuffer[Q]);else e.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer);if(M.__webglMultisampledFramebuffer)e.deleteFramebuffer(M.__webglMultisampledFramebuffer);if(M.__webglColorRenderbuffer){for(let Q=0;Q<M.__webglColorRenderbuffer.length;Q++)if(M.__webglColorRenderbuffer[Q])e.deleteRenderbuffer(M.__webglColorRenderbuffer[Q])}if(M.__webglDepthRenderbuffer)e.deleteRenderbuffer(M.__webglDepthRenderbuffer)}let V=C.textures;for(let Q=0,he=V.length;Q<he;Q++){let ge=i.get(V[Q]);if(ge.__webglTexture)e.deleteTexture(ge.__webglTexture),a.memory.textures--;i.remove(V[Q])}i.remove(C)}let I=0;function F(){I=0}function N(){return I}function U(C){I=C}function D(){let C=I;if(C>=r.maxTextures)je("WebGLTextures: Trying to use "+(C+1)+" texture units while this GPU supports only "+r.maxTextures);return I+=1,C}function O(C){let M=[];return M.push(C.wrapS),M.push(C.wrapT),M.push(C.wrapR||0),M.push(C.magFilter),M.push(C.minFilter),M.push(C.anisotropy),M.push(C.internalFormat),M.push(C.format),M.push(C.type),M.push(C.generateMipmaps),M.push(C.premultiplyAlpha),M.push(C.flipY),M.push(C.unpackAlignment),M.push(C.colorSpace),M.join()}function K(C,M){let V=i.get(C);if(C.isVideoTexture)xn(C);if(C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&V.__version!==C.version){let Q=C.image;if(Q===null)je("WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)je("WebGLRenderer: Texture marked for update but image is incomplete");else{te(V,C,M);return}}else if(C.isExternalTexture)V.__webglTexture=C.sourceTexture?C.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,V.__webglTexture,e.TEXTURE0+M)}function B(C,M){let V=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){te(V,C,M);return}else if(C.isExternalTexture)V.__webglTexture=C.sourceTexture?C.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,V.__webglTexture,e.TEXTURE0+M)}function X(C,M){let V=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){te(V,C,M);return}n.bindTexture(e.TEXTURE_3D,V.__webglTexture,e.TEXTURE0+M)}function q(C,M){let V=i.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&V.__version!==C.version){ie(V,C,M);return}n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture,e.TEXTURE0+M)}let le={[xo]:e.REPEAT,[_o]:e.CLAMP_TO_EDGE,[qu]:e.MIRRORED_REPEAT},de={[Fi]:e.NEAREST,[Ju]:e.NEAREST_MIPMAP_NEAREST,[ma]:e.NEAREST_MIPMAP_LINEAR,[En]:e.LINEAR,[vo]:e.LINEAR_MIPMAP_NEAREST,[ur]:e.LINEAR_MIPMAP_LINEAR},Me={[gT]:e.NEVER,[vT]:e.ALWAYS,[bT]:e.LESS,[rd]:e.LEQUAL,[yT]:e.EQUAL,[sd]:e.GEQUAL,[xT]:e.GREATER,[_T]:e.NOTEQUAL};function pe(C,M){if(M.type===Fr&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===En||M.magFilter===vo||M.magFilter===ma||M.magFilter===ur||M.minFilter===En||M.minFilter===vo||M.minFilter===ma||M.minFilter===ur))je("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(C,e.TEXTURE_WRAP_S,le[M.wrapS]),e.texParameteri(C,e.TEXTURE_WRAP_T,le[M.wrapT]),C===e.TEXTURE_3D||C===e.TEXTURE_2D_ARRAY)e.texParameteri(C,e.TEXTURE_WRAP_R,le[M.wrapR]);if(e.texParameteri(C,e.TEXTURE_MAG_FILTER,de[M.magFilter]),e.texParameteri(C,e.TEXTURE_MIN_FILTER,de[M.minFilter]),M.compareFunction)e.texParameteri(C,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(C,e.TEXTURE_COMPARE_FUNC,Me[M.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Fi)return;if(M.minFilter!==ma&&M.minFilter!==ur)return;if(M.type===Fr&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){let V=t.get("EXT_texture_filter_anisotropic");e.texParameterf(C,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function J(C,M){let V=!1;if(C.__webglInit===void 0)C.__webglInit=!0,M.addEventListener("dispose",S);let Q=M.source,he=h.get(Q);if(he===void 0)he={},h.set(Q,he);let ge=O(M);if(ge!==C.__cacheKey){if(he[ge]===void 0)he[ge]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,V=!0;he[ge].usedTimes++;let ve=he[C.__cacheKey];if(ve!==void 0){if(he[C.__cacheKey].usedTimes--,ve.usedTimes===0)P(M)}C.__cacheKey=ge,C.__webglTexture=he[ge].texture}return V}function L(C,M,V){return Math.floor(Math.floor(C/V)/M)}function W(C,M,V,Q){let ge=C.updateRanges;if(ge.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,M.width,M.height,V,Q,M.data);else{ge.sort((Ve,Ee)=>Ve.start-Ee.start);let ve=0;for(let Ve=1;Ve<ge.length;Ve++){let Ee=ge[ve],me=ge[Ve],Ge=Ee.start+Ee.count,Xe=L(me.start,M.width,4),_t=L(Ee.start,M.width,4);if(me.start<=Ge+1&&Xe===_t&&L(me.start+me.count-1,M.width,4)===Xe)Ee.count=Math.max(Ee.count,me.start+me.count-Ee.start);else++ve,ge[ve]=me}ge.length=ve+1;let re=n.getParameter(e.UNPACK_ROW_LENGTH),oe=n.getParameter(e.UNPACK_SKIP_PIXELS),Ie=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,M.width);for(let Ve=0,Ee=ge.length;Ve<Ee;Ve++){let me=ge[Ve],Ge=Math.floor(me.start/4),Xe=Math.ceil(me.count/4),_t=Ge%M.width,G=Math.floor(Ge/M.width),ye=Xe,ae=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,_t),n.pixelStorei(e.UNPACK_SKIP_ROWS,G),n.texSubImage2D(e.TEXTURE_2D,0,_t,G,ye,1,V,Q,M.data)}C.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,re),n.pixelStorei(e.UNPACK_SKIP_PIXELS,oe),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ie)}}function te(C,M,V){let Q=e.TEXTURE_2D;if(M.isDataArrayTexture||M.isCompressedArrayTexture)Q=e.TEXTURE_2D_ARRAY;if(M.isData3DTexture)Q=e.TEXTURE_3D;let he=J(C,M),ge=M.source;n.bindTexture(Q,C.__webglTexture,e.TEXTURE0+V);let ve=i.get(ge);if(ge.version!==ve.__version||he===!0){if(n.activeTexture(e.TEXTURE0+V),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){let ae=ot.getPrimaries(ot.workingColorSpace),xe=M.colorSpace===xa?null:ot.getPrimaries(M.colorSpace),Ce=M.colorSpace===xa||ae===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ce)}n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment);let oe=m(M.image,!1,r.maxTextureSize);oe=St(M,oe);let Ie=s.convert(M.format,M.colorSpace),Ve=s.convert(M.type),Ee=x(M.internalFormat,Ie,Ve,M.normalized,M.colorSpace,M.isVideoTexture);pe(Q,M);let me,Ge=M.mipmaps,Xe=M.isVideoTexture!==!0,_t=ve.__version===void 0||he===!0,G=ge.dataReady,ye=E(M,oe);if(M.isDepthTexture){if(Ee=v(M.format===ba,M.type),_t)if(Xe)n.texStorage2D(e.TEXTURE_2D,1,Ee,oe.width,oe.height);else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,null)}else if(M.isDataTexture)if(Ge.length>0){if(Xe&&_t)n.texStorage2D(e.TEXTURE_2D,ye,Ee,Ge[0].width,Ge[0].height);for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data);M.generateMipmaps=!1}else if(Xe){if(_t)n.texStorage2D(e.TEXTURE_2D,ye,Ee,oe.width,oe.height);if(G)W(M,oe,Ie,Ve)}else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,oe.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){if(Xe&&_t)n.texStorage3D(e.TEXTURE_2D_ARRAY,ye,Ee,Ge[0].width,Ge[0].height,oe.depth);for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],M.format!==fr)if(Ie!==null)if(Xe){if(G)if(M.layerUpdates.size>0){let Ce=Dm(me.width,me.height,M.format,M.type);for(let fe of M.layerUpdates){let Ae=me.data.subarray(fe*Ce/me.data.BYTES_PER_ELEMENT,(fe+1)*Ce/me.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,fe,me.width,me.height,1,Ie,Ae)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,me.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,me.data,0,0);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,Ve,me.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,Ie,Ve,me.data);if(M.layerUpdates.size>0)M.clearLayerUpdates()}else{if(Xe&&_t)n.texStorage2D(e.TEXTURE_2D,ye,Ee,Ge[0].width,Ge[0].height);for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],M.format!==fr)if(Ie!==null)if(Xe){if(G)n.compressedTexSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,me.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,me.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data)}else if(M.isDataArrayTexture)if(Xe){if(_t)n.texStorage3D(e.TEXTURE_2D_ARRAY,ye,Ee,oe.width,oe.height,oe.depth);if(G)if(M.layerUpdates.size>0){let ae=Dm(oe.width,oe.height,M.format,M.type);for(let xe of M.layerUpdates){let Ce=oe.data.subarray(xe*ae/oe.data.BYTES_PER_ELEMENT,(xe+1)*ae/oe.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,oe.width,oe.height,1,Ie,Ve,Ce)}M.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isData3DTexture)if(Xe){if(_t)n.texStorage3D(e.TEXTURE_3D,ye,Ee,oe.width,oe.height,oe.depth);if(G)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_3D,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isFramebufferTexture){if(_t)if(Xe)n.texStorage2D(e.TEXTURE_2D,ye,Ee,oe.width,oe.height);else{let ae=oe.width,xe=oe.height;for(let Ce=0;Ce<ye;Ce++)n.texImage2D(e.TEXTURE_2D,Ce,Ee,ae,xe,0,Ie,Ve,null),ae>>=1,xe>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in e){let ae=e.canvas;if(!ae.hasAttribute("layoutsubtree"))ae.setAttribute("layoutsubtree","true");if(oe.parentNode!==ae){ae.appendChild(oe),d.add(M),ae.onpaint=(xe)=>{let Ce=xe.changedElements;for(let fe of d)if(Ce.includes(fe.image))fe.needsUpdate=!0},ae.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,oe);else{let{RGBA:Ce,RGBA:fe,UNSIGNED_BYTE:Ae}=e;e.texElementImage2D(e.TEXTURE_2D,0,Ce,fe,Ae,oe)}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(Ge.length>0){if(Xe&&_t){let ae=Wt(Ge[0]);n.texStorage2D(e.TEXTURE_2D,ye,Ee,ae.width,ae.height)}for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,Ie,Ve,me)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,Ie,Ve,me);M.generateMipmaps=!1}else if(Xe){if(_t){let ae=Wt(oe);n.texStorage2D(e.TEXTURE_2D,ye,Ee,ae.width,ae.height)}if(G)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ie,Ve,oe)}else n.texImage2D(e.TEXTURE_2D,0,Ee,Ie,Ve,oe);if(p(M))b(Q);if(ve.__version=ge.version,M.onUpdate)M.onUpdate(M)}C.__version=M.version}function ie(C,M,V){if(M.image.length!==6)return;let Q=J(C,M),he=M.source;n.bindTexture(e.TEXTURE_CUBE_MAP,C.__webglTexture,e.TEXTURE0+V);let ge=i.get(he);if(he.version!==ge.__version||Q===!0){n.activeTexture(e.TEXTURE0+V);let ve=ot.getPrimaries(ot.workingColorSpace),re=M.colorSpace===xa?null:ot.getPrimaries(M.colorSpace),oe=M.colorSpace===xa||ve===re?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);let Ie=M.isCompressedTexture||M.image[0].isCompressedTexture,Ve=M.image[0]&&M.image[0].isDataTexture,Ee=[];for(let fe=0;fe<6;fe++){if(!Ie&&!Ve)Ee[fe]=m(M.image[fe],!0,r.maxCubemapSize);else Ee[fe]=Ve?M.image[fe].image:M.image[fe];Ee[fe]=St(M,Ee[fe])}let me=Ee[0],Ge=s.convert(M.format,M.colorSpace),Xe=s.convert(M.type),_t=x(M.internalFormat,Ge,Xe,M.normalized,M.colorSpace),G=M.isVideoTexture!==!0,ye=ge.__version===void 0||Q===!0,ae=he.dataReady,xe=E(M,me);pe(e.TEXTURE_CUBE_MAP,M);let Ce;if(Ie){if(G&&ye)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,_t,me.width,me.height);for(let fe=0;fe<6;fe++){Ce=Ee[fe].mipmaps;for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(M.format!==fr)if(Ge!==null)if(G){if(ae)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,it.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,_t,it.width,it.height,0,it.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,Xe,it.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,_t,it.width,it.height,0,Ge,Xe,it.data)}}}else{if(Ce=M.mipmaps,G&&ye){if(Ce.length>0)xe++;let fe=Wt(Ee[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,_t,fe.width,fe.height)}for(let fe=0;fe<6;fe++)if(Ve){if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ee[fe].width,Ee[fe].height,Ge,Xe,Ee[fe].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,_t,Ee[fe].width,Ee[fe].height,0,Ge,Xe,Ee[fe].data);for(let Ae=0;Ae<Ce.length;Ae++){let zt=Ce[Ae].image[fe].image;if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,zt.width,zt.height,Ge,Xe,zt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,_t,zt.width,zt.height,0,Ge,Xe,zt.data)}}else{if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ge,Xe,Ee[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,_t,Ge,Xe,Ee[fe]);for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,Ge,Xe,it.image[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,_t,Ge,Xe,it.image[fe])}}}if(p(M))b(e.TEXTURE_CUBE_MAP);if(ge.__version=he.version,M.onUpdate)M.onUpdate(M)}C.__version=M.version}function ce(C,M,V,Q,he,ge){let ve=s.convert(V.format,V.colorSpace),re=s.convert(V.type),oe=x(V.internalFormat,ve,re,V.normalized,V.colorSpace),Ie=i.get(M),Ve=i.get(V);if(Ve.__renderTarget=M,!Ie.__hasExternalTextures){let Ee=Math.max(1,M.width>>ge),me=Math.max(1,M.height>>ge);if(he===e.TEXTURE_3D||he===e.TEXTURE_2D_ARRAY)n.texImage3D(he,ge,oe,Ee,me,M.depth,0,ve,re,null);else n.texImage2D(he,ge,oe,Ee,me,0,ve,re,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,C),z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,he,Ve.__webglTexture,0,tn(M));else if(he===e.TEXTURE_2D||he>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,Q,he,Ve.__webglTexture,ge);n.bindFramebuffer(e.FRAMEBUFFER,null)}function _e(C,M,V){if(e.bindRenderbuffer(e.RENDERBUFFER,C),M.depthBuffer){let Q=M.depthTexture,he=Q&&Q.isDepthTexture?Q.type:null,ge=v(M.stencilBuffer,he),ve=M.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,tn(M),ge,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,tn(M),ge,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,ge,M.width,M.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,C)}else{let Q=M.textures;for(let he=0;he<Q.length;he++){let ge=Q[he],ve=s.convert(ge.format,ge.colorSpace),re=s.convert(ge.type),oe=x(ge.internalFormat,ve,re,ge.normalized,ge.colorSpace);if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,tn(M),oe,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,tn(M),oe,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,oe,M.width,M.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Re(C,M,V){let Q=M.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,C),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let he=i.get(M.depthTexture);if(he.__renderTarget=M,!he.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0;if(Q){if(he.__webglInit===void 0)he.__webglInit=!0,M.depthTexture.addEventListener("dispose",S);if(he.__webglTexture===void 0){he.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,he.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M.depthTexture);let Ie=s.convert(M.depthTexture.format),Ve=s.convert(M.depthTexture.type),Ee;if(M.depthTexture.format===ga)Ee=e.DEPTH_COMPONENT24;else if(M.depthTexture.format===ba)Ee=e.DEPTH24_STENCIL8;for(let me=0;me<6;me++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,Ee,M.width,M.height,0,Ie,Ve,null)}}else K(M.depthTexture,0);let ge=he.__webglTexture,ve=tn(M),re=Q?e.TEXTURE_CUBE_MAP_POSITIVE_X+V:e.TEXTURE_2D,oe=M.depthTexture.format===ba?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(M.depthTexture.format===ga)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else if(M.depthTexture.format===ba)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Oe(C){let M=i.get(C),V=C.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==C.depthTexture){let Q=C.depthTexture;if(M.__depthDisposeCallback)M.__depthDisposeCallback();if(Q){let he=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Q.removeEventListener("dispose",he)};Q.addEventListener("dispose",he),M.__depthDisposeCallback=he}M.__boundDepthTexture=Q}if(C.depthTexture&&!M.__autoAllocateDepthBuffer)if(V)for(let Q=0;Q<6;Q++)Re(M.__webglFramebuffer[Q],C,Q);else{let Q=C.texture.mipmaps;if(Q&&Q.length>0)Re(M.__webglFramebuffer[0],C,0);else Re(M.__webglFramebuffer,C,0)}else if(V){M.__webglDepthbuffer=[];for(let Q=0;Q<6;Q++)if(n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[Q]),M.__webglDepthbuffer[Q]===void 0)M.__webglDepthbuffer[Q]=e.createRenderbuffer(),_e(M.__webglDepthbuffer[Q],C,!1);else{let he=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer[Q];e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}else{let Q=C.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer);if(M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=e.createRenderbuffer(),_e(M.__webglDepthbuffer,C,!1);else{let he=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function We(C,M,V){let Q=i.get(C);if(M!==void 0)ce(Q.__webglFramebuffer,C,C.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(V!==void 0)Oe(C)}function Ye(C){let M=C.texture,V=i.get(C),Q=i.get(M);C.addEventListener("dispose",T);let he=C.textures,ge=C.isWebGLCubeRenderTarget===!0,ve=he.length>1;if(!ve){if(Q.__webglTexture===void 0)Q.__webglTexture=e.createTexture();Q.__version=M.version,a.memory.textures++}if(ge){V.__webglFramebuffer=[];for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer[re]=[];for(let oe=0;oe<M.mipmaps.length;oe++)V.__webglFramebuffer[re][oe]=e.createFramebuffer()}else V.__webglFramebuffer[re]=e.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer=[];for(let re=0;re<M.mipmaps.length;re++)V.__webglFramebuffer[re]=e.createFramebuffer()}else V.__webglFramebuffer=e.createFramebuffer();if(ve)for(let re=0,oe=he.length;re<oe;re++){let Ie=i.get(he[re]);if(Ie.__webglTexture===void 0)Ie.__webglTexture=e.createTexture(),a.memory.textures++}if(C.samples>0&&z(C)===!1){V.__webglMultisampledFramebuffer=e.createFramebuffer(),V.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let re=0;re<he.length;re++){let oe=he[re];V.__webglColorRenderbuffer[re]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,V.__webglColorRenderbuffer[re]);let Ie=s.convert(oe.format,oe.colorSpace),Ve=s.convert(oe.type),Ee=x(oe.internalFormat,Ie,Ve,oe.normalized,oe.colorSpace,C.isXRRenderTarget===!0),me=tn(C);e.renderbufferStorageMultisample(e.RENDERBUFFER,me,Ee,C.width,C.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+re,e.RENDERBUFFER,V.__webglColorRenderbuffer[re])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),C.depthBuffer)V.__webglDepthRenderbuffer=e.createRenderbuffer(),_e(V.__webglDepthRenderbuffer,C,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ge){n.bindTexture(e.TEXTURE_CUBE_MAP,Q.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M);for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[re][oe],C,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,oe);else ce(V.__webglFramebuffer[re],C,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,0);if(p(M))b(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let re=0,oe=he.length;re<oe;re++){let Ie=he[re],Ve=i.get(Ie),Ee=e.TEXTURE_2D;if(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)Ee=C.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Ee,Ve.__webglTexture),pe(Ee,Ie),ce(V.__webglFramebuffer,C,Ie,e.COLOR_ATTACHMENT0+re,Ee,0),p(Ie))b(Ee)}n.unbindTexture()}else{let re=e.TEXTURE_2D;if(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)re=C.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(re,Q.__webglTexture),pe(re,M),M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[oe],C,M,e.COLOR_ATTACHMENT0,re,oe);else ce(V.__webglFramebuffer,C,M,e.COLOR_ATTACHMENT0,re,0);if(p(M))b(re);n.unbindTexture()}if(C.depthBuffer)Oe(C)}function Kt(C){let M=C.textures;for(let V=0,Q=M.length;V<Q;V++){let he=M[V];if(p(he)){let ge=_(C),ve=i.get(he).__webglTexture;n.bindTexture(ge,ve),b(ge),n.unbindTexture()}}}let lt=[],Dt=[];function Yt(C){if(C.samples>0){if(z(C)===!1){let{textures:M,width:V,height:Q}=C,he=e.COLOR_BUFFER_BIT,ge=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(C),re=M.length>1;if(re)for(let Ie=0;Ie<M.length;Ie++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let oe=C.texture.mipmaps;if(oe&&oe.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ie=0;Ie<M.length;Ie++){if(C.resolveDepthBuffer){if(C.depthBuffer)he|=e.DEPTH_BUFFER_BIT;if(C.stencilBuffer&&C.resolveStencilBuffer)he|=e.STENCIL_BUFFER_BIT}if(re){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ve,0)}if(e.blitFramebuffer(0,0,V,Q,0,0,V,Q,he,e.NEAREST),c===!0){if(lt.length=0,Dt.length=0,lt.push(e.COLOR_ATTACHMENT0+Ie),C.depthBuffer&&C.storeMultisampledDepthBuffer===!1)lt.push(ge),Dt.push(ge),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Dt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,lt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),re)for(let Ie=0;Ie<M.length;Ie++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,Ve,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.storeMultisampledDepthBuffer===!1&&c){let M=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[M])}}}function tn(C){return Math.min(r.maxSamples,C.samples)}function z(C){let M=i.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function xn(C){let M=a.render.frame;if(u.get(C)!==M)u.set(C,M),C.update()}function St(C,M){let{colorSpace:V,format:Q,type:he}=C;if(C.isCompressedTexture===!0||C.isVideoTexture===!0)return M;if(V!==si&&V!==xa)if(ot.getTransfer(V)===Bt){if(Q!==fr||he!==Ui)je("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ze("WebGLTextures: Unsupported texture color space:",V);return M}function Wt(C){if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement)l.width=C.naturalWidth||C.width,l.height=C.naturalHeight||C.height;else if(typeof VideoFrame<"u"&&C instanceof VideoFrame)l.width=C.displayWidth,l.height=C.displayHeight;else l.width=C.width,l.height=C.height;return l}this.allocateTextureUnit=D,this.resetTextureUnits=F,this.getTextureUnits=N,this.setTextureUnits=U,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=X,this.setTextureCube=q,this.rebindTextures=We,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Kt,this.updateMultisampleRenderTarget=Yt,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=z,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function _L(e,t){function n(i,r=xa){let s,a=ot.getTransfer(r);if(i===Ui)return e.UNSIGNED_BYTE;if(i===Mp)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Rp)return e.UNSIGNED_SHORT_5_5_5_1;if(i===uT)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===dT)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===cT)return e.BYTE;if(i===lT)return e.SHORT;if(i===Uc)return e.UNSIGNED_SHORT;if(i===wp)return e.INT;if(i===ds)return e.UNSIGNED_INT;if(i===Fr)return e.FLOAT;if(i===dr)return e.HALF_FLOAT;if(i===fT)return e.ALPHA;if(i===hT)return e.RGB;if(i===fr)return e.RGBA;if(i===ga)return e.DEPTH_COMPONENT;if(i===ba)return e.DEPTH_STENCIL;if(i===pT)return e.RED;if(i===Ip)return e.RED_INTEGER;if(i===ya)return e.RG;if(i===Cp)return e.RG_INTEGER;if(i===Np)return e.RGBA_INTEGER;if(i===Zu||i===Yu||i===Qu||i===ed)if(a===Bt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Zu)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Yu)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Qu)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ed)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Zu)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Yu)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Qu)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ed)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Pp||i===Op||i===kp||i===Dp)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Pp)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Op)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===kp)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Dp)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Lp||i===Fp||i===Up||i===Bp||i===zp||i===td||i===Vp)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Lp||i===Fp)return a===Bt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Up)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Bp)return s.COMPRESSED_R11_EAC;if(i===zp)return s.COMPRESSED_SIGNED_R11_EAC;if(i===td)return s.COMPRESSED_RG11_EAC;if(i===Vp)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===jp||i===Hp||i===Gp||i===$p||i===Kp||i===Wp||i===Xp||i===qp||i===Jp||i===Zp||i===Yp||i===Qp||i===em||i===tm)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===jp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Hp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$p)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Kp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===qp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Jp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Yp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Qp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===em)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===tm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===nm||i===im||i===rm)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===nm)return a===Bt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===im)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===rm)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===sm||i===am||i===nd||i===om)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===sm)return s.COMPRESSED_RED_RGTC1_EXT;if(i===am)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===nd)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===om)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Eo)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}class hA{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new pd(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 _i({vertexShader:vL,fragmentShader:EL,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new jt(new Jc(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}function AL(e,t){function n(m,p){if(m.matrixAutoUpdate===!0)m.updateMatrix();p.value.copy(m.matrix)}function i(m,p){if(p.color.getRGB(m.fogColor.value,xm(e)),p.isFog)m.fogNear.value=p.near,m.fogFar.value=p.far;else if(p.isFogExp2)m.fogDensity.value=p.density}function r(m,p,b,_,x){if(p.isNodeMaterial)p.uniformsNeedUpdate=!1;else if(p.isMeshBasicMaterial)s(m,p);else if(p.isMeshLambertMaterial){if(s(m,p),p.envMap)m.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshToonMaterial)s(m,p),d(m,p);else if(p.isMeshPhongMaterial){if(s(m,p),u(m,p),p.envMap)m.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshStandardMaterial){if(s(m,p),f(m,p),p.isMeshPhysicalMaterial)h(m,p,x)}else if(p.isMeshMatcapMaterial)s(m,p),y(m,p);else if(p.isMeshDepthMaterial)s(m,p);else if(p.isMeshDistanceMaterial)s(m,p),g(m,p);else if(p.isMeshNormalMaterial)s(m,p);else if(p.isLineBasicMaterial){if(a(m,p),p.isLineDashedMaterial)o(m,p)}else if(p.isPointsMaterial)c(m,p,b,_);else if(p.isSpriteMaterial)l(m,p);else if(p.isShadowMaterial)m.color.value.copy(p.color),m.opacity.value=p.opacity;else if(p.isShaderMaterial)p.uniformsNeedUpdate=!1}function s(m,p){if(m.opacity.value=p.opacity,p.color)m.diffuse.value.copy(p.color);if(p.emissive)m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity);if(p.map)m.map.value=p.map,n(p.map,m.mapTransform);if(p.alphaMap)m.alphaMap.value=p.alphaMap,n(p.alphaMap,m.alphaMapTransform);if(p.bumpMap){if(m.bumpMap.value=p.bumpMap,n(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Pn)m.bumpScale.value*=-1}if(p.normalMap){if(m.normalMap.value=p.normalMap,n(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Pn)m.normalScale.value.negate()}if(p.displacementMap)m.displacementMap.value=p.displacementMap,n(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias;if(p.emissiveMap)m.emissiveMap.value=p.emissiveMap,n(p.emissiveMap,m.emissiveMapTransform);if(p.specularMap)m.specularMap.value=p.specularMap,n(p.specularMap,m.specularMapTransform);if(p.alphaTest>0)m.alphaTest.value=p.alphaTest;let b=t.get(p),{envMap:_,envMapRotation:x}=b;if(_){if(m.envMap.value=_,m.envMapRotation.value.setFromMatrix4(TL.makeRotationFromEuler(x)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(mA);m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio}if(p.lightMap)m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,n(p.lightMap,m.lightMapTransform);if(p.aoMap)m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,n(p.aoMap,m.aoMapTransform)}function a(m,p){if(m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map)m.map.value=p.map,n(p.map,m.mapTransform)}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,b,_){if(m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=_*0.5,p.map)m.map.value=p.map,n(p.map,m.uvTransform);if(p.alphaMap)m.alphaMap.value=p.alphaMap,n(p.alphaMap,m.alphaMapTransform);if(p.alphaTest>0)m.alphaTest.value=p.alphaTest}function l(m,p){if(m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map)m.map.value=p.map,n(p.map,m.mapTransform);if(p.alphaMap)m.alphaMap.value=p.alphaMap,n(p.alphaMap,m.alphaMapTransform);if(p.alphaTest>0)m.alphaTest.value=p.alphaTest}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,0.0001)}function d(m,p){if(p.gradientMap)m.gradientMap.value=p.gradientMap}function f(m,p){if(m.metalness.value=p.metalness,p.metalnessMap)m.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,m.metalnessMapTransform);if(m.roughness.value=p.roughness,p.roughnessMap)m.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,m.roughnessMapTransform);if(p.envMap)m.envMapIntensity.value=p.envMapIntensity}function h(m,p,b){if(m.ior.value=p.ior,p.sheen>0){if(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap)m.sheenColorMap.value=p.sheenColorMap,n(p.sheenColorMap,m.sheenColorMapTransform);if(p.sheenRoughnessMap)m.sheenRoughnessMap.value=p.sheenRoughnessMap,n(p.sheenRoughnessMap,m.sheenRoughnessMapTransform)}if(p.clearcoat>0){if(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap)m.clearcoatMap.value=p.clearcoatMap,n(p.clearcoatMap,m.clearcoatMapTransform);if(p.clearcoatRoughnessMap)m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,n(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform);if(p.clearcoatNormalMap){if(m.clearcoatNormalMap.value=p.clearcoatNormalMap,n(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Pn)m.clearcoatNormalScale.value.negate()}}if(p.dispersion>0)m.dispersion.value=p.dispersion;if(p.retroreflectivity>0)m.retroreflectivity.value=p.retroreflectivity;if(p.iridescence>0){if(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap)m.iridescenceMap.value=p.iridescenceMap,n(p.iridescenceMap,m.iridescenceMapTransform);if(p.iridescenceThicknessMap)m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,n(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform)}if(p.transmission>0){if(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap)m.transmissionMap.value=p.transmissionMap,n(p.transmissionMap,m.transmissionMapTransform);if(m.thickness.value=p.thickness,p.thicknessMap)m.thicknessMap.value=p.thicknessMap,n(p.thicknessMap,m.thicknessMapTransform);m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)}if(p.anisotropy>0){if(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap)m.anisotropyMap.value=p.anisotropyMap,n(p.anisotropyMap,m.anisotropyMapTransform)}if(m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap)m.specularColorMap.value=p.specularColorMap,n(p.specularColorMap,m.specularColorMapTransform);if(p.specularIntensityMap)m.specularIntensityMap.value=p.specularIntensityMap,n(p.specularIntensityMap,m.specularIntensityMapTransform)}function y(m,p){if(p.matcap)m.matcap.value=p.matcap}function g(m,p){let b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function SL(e,t,n,i){let r={},s={},a=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,v){let E=v.program;i.uniformBlockBinding(x,E)}function l(x,v){let E=r[x.id];if(E===void 0)m(x),E=u(x),r[x.id]=E,x.addEventListener("dispose",b);let S=v.program;i.updateUBOMapping(x,S);let T=t.render.frame;if(s[x.id]!==T)f(x),s[x.id]=T}function u(x){let v=d();x.__bindingPointIndex=v;let E=e.createBuffer(),{__size:S,usage:T}=x;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,S,T),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,v,E),E}function d(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return Ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(x){let v=r[x.id],{uniforms:E,__cache:S}=x;e.bindBuffer(e.UNIFORM_BUFFER,v);for(let T=0,A=E.length;T<A;T++){let P=E[T];if(Array.isArray(P))for(let w=0,I=P.length;w<I;w++)h(P[w],T,w,S);else h(P,T,0,S)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function h(x,v,E,S){if(g(x,v,E,S)===!0){let{__offset:T,value:A}=x;if(Array.isArray(A)){let P=0;for(let w=0;w<A.length;w++){let I=A[w],F=p(I);if(y(I,x.__data,P),typeof I!=="number"&&typeof I!=="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I))P+=F.storage/Float32Array.BYTES_PER_ELEMENT}}else y(A,x.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,T,x.__data)}}function y(x,v,E){if(typeof x==="number"||typeof x==="boolean")v[0]=x;else if(x.isMatrix3)v[0]=x.elements[0],v[1]=x.elements[1],v[2]=x.elements[2],v[3]=0,v[4]=x.elements[3],v[5]=x.elements[4],v[6]=x.elements[5],v[7]=0,v[8]=x.elements[6],v[9]=x.elements[7],v[10]=x.elements[8],v[11]=0;else if(ArrayBuffer.isView(x))v.set(new x.constructor(x.buffer,x.byteOffset,v.length));else x.toArray(v,E)}function g(x,v,E,S){let T=x.value,A=v+"_"+E;if(S[A]===void 0){if(typeof T==="number"||typeof T==="boolean")S[A]=T;else if(ArrayBuffer.isView(T))S[A]=T.slice();else S[A]=T.clone();return!0}else{let P=S[A];if(typeof T==="number"||typeof T==="boolean"){if(P!==T)return S[A]=T,!0}else if(ArrayBuffer.isView(T))return!0;else if(P.equals(T)===!1)return P.copy(T),!0}return!1}function m(x){let v=x.uniforms,E=0,S=16;for(let A=0,P=v.length;A<P;A++){let w=Array.isArray(v[A])?v[A]:[v[A]];for(let I=0,F=w.length;I<F;I++){let N=w[I],U=Array.isArray(N.value)?N.value:[N.value];for(let D=0,O=U.length;D<O;D++){let K=U[D],B=p(K),X=E%S,q=X%B.boundary,le=X+q;if(E+=q,le!==0&&S-le<B.storage)E+=S-le;N.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=E,E+=B.storage}}}let T=E%S;if(T>0)E+=S-T;return x.__size=E,x.__cache={},this}function p(x){let v={boundary:0,storage:0};if(typeof x==="number"||typeof x==="boolean")v.boundary=4,v.storage=4;else if(x.isVector2)v.boundary=8,v.storage=8;else if(x.isVector3||x.isColor)v.boundary=16,v.storage=12;else if(x.isVector4)v.boundary=16,v.storage=16;else if(x.isMatrix3)v.boundary=48,v.storage=48;else if(x.isMatrix4)v.boundary=64,v.storage=64;else if(x.isTexture)je("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(x))v.boundary=16,v.storage=x.byteLength;else je("WebGLRenderer: Unsupported uniform value type.",x);return v}function b(x){let v=x.target;v.removeEventListener("dispose",b);let E=a.indexOf(v.__bindingPointIndex);a.splice(E,1),e.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function _(){for(let x in r)e.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:c,update:l,dispose:_}}function ML(){if(pr===null)pr=new $c(wL,16,16,ya,dr),pr.name="DFG_LUT",pr.minFilter=En,pr.magFilter=En,pr.wrapS=_o,pr.wrapT=_o,pr.generateMipmaps=!1,pr.needsUpdate=!0;return pr}class Km{constructor(e={}){let{canvas:t=ET(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Ui}=e;this.isWebGLRenderer=!0;let h;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=n.getContextAttributes().alpha}else h=s;let y=f,g=new Set([Np,Cp,Ip]),m=new Set([Ui,ds,Uc,Eo,Mp,Rp]),p=new Uint32Array(4),b=new Int32Array(4),_=new j,x=null,v=null,E=[],S=[],T=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=Li,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let A=this,P=!1,w=null,I=null,F=null,N=null;this._outputColorSpace=fs;let U=0,D=0,O=null,K=-1,B=null,X=new Nt,q=new Nt,le=null,de=new qe(0),Me=0,{width:pe,height:J}=t,L=1,W=null,te=null,ie=new Nt(0,0,pe,J),ce=new Nt(0,0,pe,J),_e=!1,Re=new Wc,Oe=!1,We=!1,Ye=new Qe,Kt=new j,lt=new Nt,Dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Yt=!1;function tn(){return O===null?L:1}let z=n;function xn(R,H){return t.getContext(R,H)}let St,Wt,C,M,V,Q,he,ge,ve,re,oe,Ie,Ve,Ee,me,Ge,Xe,_t,G,ye,ae,xe,Ce;try{let R={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${RE}`);if(t.addEventListener("webglcontextlost",it,!1),t.addEventListener("webglcontextrestored",zt,!1),t.addEventListener("webglcontextcreationerror",wt,!1),z===null){if(z=xn("webgl2",R),z===null)if(xn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}fe()}catch(R){throw t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",wt,!1),Ze("WebGLRenderer: "+R.message),R}function fe(){if(St=new kk(z),St.init(),ae=new _L(z,St),Wt=new Ak(z,St,e,ae),C=new yL(z,St),Wt.reversedDepthBuffer&&d)C.buffers.depth.setReversed(!0);I=z.createFramebuffer(),F=z.createFramebuffer(),N=z.createFramebuffer(),M=new Fk(z),V=new rL,Q=new xL(z,St,C,V,Wt,ae,M),he=new Ok(A),ge=new BN(z),xe=new Ek(z,ge),ve=new Dk(z,ge,M,xe),re=new Bk(z,ve,ge,xe,M),_t=new Uk(z,Wt,Q),me=new Sk(V),oe=new iL(A,he,St,Wt,xe,me),Ie=new AL(A,V),Ve=new aL,Ee=new fL(St),Xe=new vk(A,he,C,re,h,o),Ge=new bL(A,re,Wt),Ce=new SL(z,M,Wt,C),G=new Tk(z,St,M),ye=new Lk(z,St,M),M.programs=oe.programs,A.capabilities=Wt,A.extensions=St,A.properties=V,A.renderLists=Ve,A.shadowMap=Ge,A.state=C,A.info=M}if(y!==Ui)T=new Vk(y,t.width,t.height,a,i,r);let Ae=new pA(A,z);this.xr=Ae,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let R=St.get("WEBGL_lose_context");if(R)R.loseContext()},this.forceContextRestore=function(){let R=St.get("WEBGL_lose_context");if(R)R.restoreContext()},this.getPixelRatio=function(){return L},this.setPixelRatio=function(R){if(R===void 0)return;L=R,this.setSize(pe,J,!1)},this.getSize=function(R){return R.set(pe,J)},this.setSize=function(R,H,ee=!0){if(Ae.isPresenting){je("WebGLRenderer: Can't change size while VR device is presenting.");return}if(pe=R,J=H,t.width=Math.floor(R*L),t.height=Math.floor(H*L),ee===!0)t.style.width=R+"px",t.style.height=H+"px";if(T!==null)T.setSize(t.width,t.height);this.setViewport(0,0,R,H)},this.getDrawingBufferSize=function(R){return R.set(pe*L,J*L).floor()},this.setDrawingBufferSize=function(R,H,ee){pe=R,J=H,L=ee,t.width=Math.floor(R*ee),t.height=Math.floor(H*ee),this.setViewport(0,0,R,H)},this.setEffects=function(R){if(y===Ui){Ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(R){for(let H=0;H<R.length;H++)if(R[H].isOutputPass===!0){je("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(R||[])},this.getCurrentViewport=function(R){return R.copy(X)},this.getViewport=function(R){return R.copy(ie)},this.setViewport=function(R,H,ee,Z){if(R.isVector4)ie.set(R.x,R.y,R.z,R.w);else ie.set(R,H,ee,Z);C.viewport(X.copy(ie).multiplyScalar(L).round())},this.getScissor=function(R){return R.copy(ce)},this.setScissor=function(R,H,ee,Z){if(R.isVector4)ce.set(R.x,R.y,R.z,R.w);else ce.set(R,H,ee,Z);C.scissor(q.copy(ce).multiplyScalar(L).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(R){C.setScissorTest(_e=R)},this.setOpaqueSort=function(R){W=R},this.setTransparentSort=function(R){te=R},this.getClearColor=function(R){return R.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(R=!0,H=!0,ee=!0){let Z=0;if(R){let Y=!1;if(O!==null){let we=O.texture.format;Y=g.has(we)}if(Y){let we=O.texture.type,Pe=m.has(we),Se=Xe.getClearColor(),ke=Xe.getClearAlpha(),{r:ze,g:rt,b:ft}=Se;if(Pe)p[0]=ze,p[1]=rt,p[2]=ft,p[3]=ke,z.clearBufferuiv(z.COLOR,0,p);else b[0]=ze,b[1]=rt,b[2]=ft,b[3]=ke,z.clearBufferiv(z.COLOR,0,b)}else Z|=z.COLOR_BUFFER_BIT}if(H)Z|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(ee)Z|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)z.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(R){R.setRenderer(this),w=R},this.dispose=function(){t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",wt,!1),Xe.dispose(),Ve.dispose(),Ee.dispose(),V.dispose(),he.dispose(),re.dispose(),xe.dispose(),Ce.dispose(),oe.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",rb),Ae.removeEventListener("sessionend",sb),Ys.stop()};function it(R){R.preventDefault(),Oc("WebGLRenderer: Context Lost."),P=!0}function zt(){Oc("WebGLRenderer: Context Restored."),P=!1;let R=M.autoReset,H=Ge.enabled,ee=Ge.autoUpdate,Z=Ge.needsUpdate,Y=Ge.type;fe(),M.autoReset=R,Ge.enabled=H,Ge.autoUpdate=ee,Ge.needsUpdate=Z,Ge.type=Y}function wt(R){Ze("WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function $i(R){let H=R.target;H.removeEventListener("dispose",$i),Tr(H)}function Tr(R){pR(R),V.remove(R)}function pR(R){let H=V.get(R).programs;if(H!==void 0){if(H.forEach(function(ee){oe.releaseProgram(ee)}),R.isShaderMaterial)oe.releaseShaderCache(R)}}this.renderBufferDirect=function(R,H,ee,Z,Y,we){if(H===null)H=Dt;let Pe=Y.isMesh&&Y.matrixWorld.determinantAffine()<0,Se=bR(R,H,ee,Z,Y);C.setMaterial(Z,Pe);let ke=ee.index,ze=1;if(Z.wireframe===!0){if(ke=ve.getWireframeAttribute(ee),ke===void 0)return;ze=2}let rt=ee.drawRange,ft=ee.attributes.position,De=rt.start*ze,Mt=(rt.start+rt.count)*ze;if(we!==null)De=Math.max(De,we.start*ze),Mt=Math.min(Mt,(we.start+we.count)*ze);if(ke!==null)De=Math.max(De,0),Mt=Math.min(Mt,ke.count);else if(ft!==void 0&&ft!==null)De=Math.max(De,0),Mt=Math.min(Mt,ft.count);let an=Mt-De;if(an<0||an===1/0)return;xe.setup(Y,Z,Se,ee,ke);let Ht,Lt=G;if(ke!==null)Ht=ge.get(ke),Lt=ye,Lt.setIndex(Ht);if(Y.isMesh)if(Z.wireframe===!0)C.setLineWidth(Z.wireframeLinewidth*tn()),Lt.setMode(z.LINES);else Lt.setMode(z.TRIANGLES);else if(Y.isLine){let Rn=Z.linewidth;if(Rn===void 0)Rn=1;if(C.setLineWidth(Rn*tn()),Y.isLineSegments)Lt.setMode(z.LINES);else if(Y.isLineLoop)Lt.setMode(z.LINE_LOOP);else Lt.setMode(z.LINE_STRIP)}else if(Y.isPoints)Lt.setMode(z.POINTS);else if(Y.isSprite)Lt.setMode(z.TRIANGLES);if(Y.isBatchedMesh)if(!St.get("WEBGL_multi_draw")){let{_multiDrawStarts:Rn,_multiDrawCounts:Ne,_multiDrawCount:Dn}=Y,bt=ke?ge.get(ke).bytesPerElement:1,fi=V.get(Z).currentProgram.getUniforms();for(let Ki=0;Ki<Dn;Ki++)fi.setValue(z,"_gl_DrawID",Ki),Lt.render(Rn[Ki]/bt,Ne[Ki])}else Lt.renderMultiDraw(Y._multiDrawStarts,Y._multiDrawCounts,Y._multiDrawCount);else if(Y.isInstancedMesh)Lt.renderInstances(De,an,Y.count);else if(ee.isInstancedBufferGeometry){let Rn=ee._maxInstanceCount!==void 0?ee._maxInstanceCount:1/0,Ne=Math.min(ee.instanceCount,Rn);Lt.renderInstances(De,an,Ne)}else Lt.render(De,an)};function ib(R,H,ee,Z){if(w!==null&&R.isNodeMaterial)w.setObject(Z,R);if(Oe===!0)me.setState(R,ee,!1);if(R.transparent===!0&&R.side===xi&&R.forceSinglePass===!1)R.side=Pn,R.needsUpdate=!0,Ml(R,H,Z),R.side=us,R.needsUpdate=!0,Ml(R,H,Z),R.side=xi;else Ml(R,H,Z)}this.compile=function(R,H,ee=null){if(ee===null)ee=R;if(w!==null)w.renderStart(R,H,ee);if(v=Ee.get(ee),v.init(H),S.push(v),ee.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}}),R!==ee)R.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}});if(v.setupLights(),w!==null)w.updateLights(v.state.lightsArray);if(We=this.localClippingEnabled,Oe=me.init(this.clippingPlanes,We),Oe===!0)me.setGlobalState(this.clippingPlanes,H);if(w!==null)Ge.render(v.state.shadowsArray,ee,H);let Z=new Set;if(R.traverse(function(Y){if(!(Y.isMesh||Y.isPoints||Y.isLine||Y.isSprite))return;let we=Y.material;if(we)if(Array.isArray(we))for(let Pe=0;Pe<we.length;Pe++){let Se=we[Pe];ib(Se,ee,H,Y),Z.add(Se)}else ib(we,ee,H,Y),Z.add(we)}),v=S.pop(),w!==null)w.renderEnd();return Z},this.compileAsync=function(R,H,ee=null){let Z=this.compile(R,H,ee);return new Promise((Y)=>{function we(){if(Z.forEach(function(Pe){let ke=V.get(Pe).currentProgram;if(ke===void 0||ke.isReady())Z.delete(Pe)}),Z.size===0){Y(R);return}setTimeout(we,10)}if(St.get("KHR_parallel_shader_compile")!==null)we();else setTimeout(we,10)})};let pf=null;function mR(R){if(pf)pf(R)}function rb(){Ys.stop()}function sb(){Ys.start()}let Ys=new nA;if(Ys.setAnimationLoop(mR),typeof self<"u")Ys.setContext(self);this.setAnimationLoop=function(R){pf=R,Ae.setAnimationLoop(R),R===null?Ys.stop():Ys.start()},Ae.addEventListener("sessionstart",rb),Ae.addEventListener("sessionend",sb),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){Ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(w!==null)w.renderStart(R,H);let ee=Ae.enabled===!0&&Ae.isPresenting===!0,Z=T!==null&&(O===null||ee)&&T.begin(A,O);if(R.matrixWorldAutoUpdate===!0)R.updateMatrixWorld();if(H.parent===null&&H.matrixWorldAutoUpdate===!0)H.updateMatrixWorld();if(Ae.enabled===!0&&Ae.isPresenting===!0&&(T===null||T.isCompositing()===!1)){if(Ae.cameraAutoUpdate===!0)Ae.updateCamera(H);H=Ae.getCamera()}if(R.isScene===!0)R.onBeforeRender(A,R,H,O);if(v=Ee.get(R,S.length),v.init(H),v.state.textureUnits=Q.getTextureUnits(),S.push(v),Ye.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Re.setFromProjectionMatrix(Ye,hm,H.reversedDepth),We=this.localClippingEnabled,Oe=me.init(this.clippingPlanes,We),x=Ve.get(R,E.length),x.init(),E.push(x),Ae.enabled===!0&&Ae.isPresenting===!0){let Pe=A.xr.getDepthSensingMesh();if(Pe!==null)mf(Pe,H,-1/0,A.sortObjects)}if(mf(R,H,0,A.sortObjects),x.finish(),w!==null)w.updateLights(v.state.lightsArray);if(A.sortObjects===!0)x.sort(W,te);if(Yt=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,Yt)Xe.addToRenderList(x,R);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Oe===!0)me.beginShadows();let Y=v.state.shadowsArray;if(Ge.render(Y,R,H),Oe===!0)me.endShadows();if((Z&&T.hasRenderPass())===!1){let Pe=x.opaque,Se=x.transmissive;if(v.setupLights(),H.isArrayCamera){let ke=H.cameras;if(Se.length>0)for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze];ob(Pe,Se,R,ft)}if(Yt)Xe.render(R);for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze];ab(x,R,ft,ft.viewport)}}else{if(Se.length>0)ob(Pe,Se,R,H);if(Yt)Xe.render(R);ab(x,R,H)}}if(O!==null&&D===0)Q.updateMultisampleRenderTarget(O),Q.updateRenderTargetMipmap(O);if(Z)T.end(A);if(R.isScene===!0)R.onAfterRender(A,R,H);if(xe.resetDefaultState(),K=-1,B=null,S.pop(),S.length>0){if(v=S[S.length-1],Q.setTextureUnits(v.state.textureUnits),Oe===!0)me.setGlobalState(A.clippingPlanes,v.state.camera)}else v=null;if(E.pop(),E.length>0)x=E[E.length-1];else x=null;if(w!==null)w.renderEnd()};function mf(R,H,ee,Z){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)ee=R.renderOrder;else if(R.isLOD){if(R.autoUpdate===!0)R.update(H)}else if(R.isLightProbeGrid)v.pushLightProbeGrid(R);else if(R.isLight){if(v.pushLight(R),R.castShadow)v.pushShadow(R)}else if(R.isSprite){if(!R.frustumCulled||R.intersectsFrustum(Re)){if(Z)lt.setFromMatrixPosition(R.matrixWorld).applyMatrix4(Ye);let Pe=re.update(R),Se=R.material;if(Se.visible)x.push(R,Pe,Se,ee,lt.z,null,H)}}else if(R.isMesh||R.isLine||R.isPoints){if(!R.frustumCulled||R.intersectsFrustum(Re)){let Pe=re.update(R),Se=R.material;if(Z){if(R.boundingSphere!==void 0){if(R.boundingSphere===null)R.computeBoundingSphere();lt.copy(R.boundingSphere.center)}else{if(Pe.boundingSphere===null)Pe.computeBoundingSphere();lt.copy(Pe.boundingSphere.center)}lt.applyMatrix4(R.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(Se)){let ke=Pe.groups;for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze],De=Se[ft.materialIndex];if(De&&De.visible)x.push(R,Pe,De,ee,lt.z,ft,H)}}else if(Se.visible)x.push(R,Pe,Se,ee,lt.z,null,H)}}}let we=R.children;for(let Pe=0,Se=we.length;Pe<Se;Pe++)mf(we[Pe],H,ee,Z)}function ab(R,H,ee,Z){let{opaque:Y,transmissive:we,transparent:Pe}=R;if(v.setupLightsView(ee),Oe===!0)me.setGlobalState(A.clippingPlanes,ee);if(Z)C.viewport(X.copy(Z));if(Y.length>0)wl(Y,H,ee);if(we.length>0)wl(we,H,ee);if(Pe.length>0)wl(Pe,H,ee);C.buffers.depth.setTest(!0),C.buffers.depth.setMask(!0),C.buffers.color.setMask(!0),C.setPolygonOffset(!1)}function ob(R,H,ee,Z){if((ee.isScene===!0?ee.overrideMaterial:null)!==null)return;if(v.state.transmissionRenderTarget[Z.id]===void 0){let De=St.has("EXT_color_buffer_half_float")||St.has("EXT_color_buffer_float");v.state.transmissionRenderTarget[Z.id]=new ai(1,1,{generateMipmaps:!0,type:De?dr:Ui,minFilter:ur,samples:Math.max(4,Wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ot.workingColorSpace})}let we=v.state.transmissionRenderTarget[Z.id],Pe=Z.viewport||X;we.setSize(Pe.z*A.transmissionResolutionScale,Pe.w*A.transmissionResolutionScale);let Se=A.getRenderTarget(),ke=A.getActiveCubeFace(),ze=A.getActiveMipmapLevel();if(A.setRenderTarget(we),A.getClearColor(de),Me=A.getClearAlpha(),Me<1)A.setClearColor(16777215,0.5);if(A.clear(),Yt)Xe.render(ee);let rt=A.toneMapping;A.toneMapping=Li;let ft=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(v.setupLightsView(Z),Oe===!0)me.setGlobalState(A.clippingPlanes,Z);if(wl(R,ee,Z),Q.updateMultisampleRenderTarget(we),Q.updateRenderTargetMipmap(we),St.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let Mt=0,an=H.length;Mt<an;Mt++){let Ht=H[Mt],{object:Lt,geometry:Rn,material:Ne,group:Dn}=Ht;if(Ne.side===xi&&Lt.layers.test(Z.layers)){let bt=Ne.side;Ne.side=Pn,Ne.needsUpdate=!0,cb(Lt,ee,Z,Rn,Ne,Dn),Ne.side=bt,Ne.needsUpdate=!0,De=!0}}if(De===!0)Q.updateMultisampleRenderTarget(we),Q.updateRenderTargetMipmap(we)}if(A.setRenderTarget(Se,ke,ze),A.setClearColor(de,Me),ft!==void 0)Z.viewport=ft;A.toneMapping=rt}function wl(R,H,ee){let Z=H.isScene===!0?H.overrideMaterial:null;for(let Y=0,we=R.length;Y<we;Y++){let Pe=R[Y],{object:Se,geometry:ke,group:ze}=Pe,rt=Pe.material;if(rt.allowOverride===!0&&Z!==null)rt=Z;if(Se.layers.test(ee.layers))cb(Se,H,ee,ke,rt,ze)}}function cb(R,H,ee,Z,Y,we){if(w!==null&&Y.isNodeMaterial)w.setObject(R,Y);if(R.onBeforeRender(A,H,ee,Z,Y,we),R.modelViewMatrix.multiplyMatrices(ee.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),Y.onBeforeRender(A,H,ee,Z,R,we),Y.transparent===!0&&Y.side===xi&&Y.forceSinglePass===!1)Y.side=Pn,Y.needsUpdate=!0,A.renderBufferDirect(ee,H,Z,Y,R,we),Y.side=us,Y.needsUpdate=!0,A.renderBufferDirect(ee,H,Z,Y,R,we),Y.side=xi;else A.renderBufferDirect(ee,H,Z,Y,R,we);R.onAfterRender(A,H,ee,Z,Y,we)}function Ml(R,H,ee){if(H.isScene!==!0)H=Dt;let Z=V.get(R),Y=v.state.lights,we=v.state.shadowsArray,Pe=Y.state.version,Se=oe.getParameters(R,Y.state,we,H,ee,v.state.lightProbeGridArray),ke=oe.getProgramCacheKey(Se),ze=Z.programs;Z.environment=R.isMeshStandardMaterial||R.isMeshLambertMaterial||R.isMeshPhongMaterial?H.environment:null,Z.fog=H.fog;let rt=R.isMeshStandardMaterial||R.isMeshLambertMaterial&&!R.envMap||R.isMeshPhongMaterial&&!R.envMap;if(Z.envMap=he.get(R.envMap||Z.environment,rt),Z.envMapRotation=Z.environment!==null&&R.envMap===null?H.environmentRotation:R.envMapRotation,ze===void 0)R.addEventListener("dispose",$i),ze=new Map,Z.programs=ze;let ft=ze.get(ke);if(ft!==void 0){if(Z.currentProgram===ft&&Z.lightsStateVersion===Pe)return ub(R,Se),ft}else{if(Se.uniforms=oe.getUniforms(R),w!==null&&R.isNodeMaterial)w.build(R,ee,Se);R.onBeforeCompile(Se,A),ft=oe.acquireProgram(Se,ke),ze.set(ke,ft),Z.uniforms=Se.uniforms}let De=Z.uniforms;if(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)De.clippingPlanes=me.uniform;if(ub(R,Se),Z.needsLights=xR(R),Z.lightsStateVersion=Pe,Z.needsLights)De.ambientLightColor.value=Y.state.ambient,De.lightProbe.value=Y.state.probe,De.sunLights.value=Y.state.sun,De.sunLightShadows.value=Y.state.sunShadow,De.directionalLights.value=Y.state.directional,De.directionalLightShadows.value=Y.state.directionalShadow,De.spotLights.value=Y.state.spot,De.spotLightShadows.value=Y.state.spotShadow,De.rectAreaLights.value=Y.state.rectArea,De.ltc_1.value=Y.state.rectAreaLTC1,De.ltc_2.value=Y.state.rectAreaLTC2,De.pointLights.value=Y.state.point,De.pointLightShadows.value=Y.state.pointShadow,De.hemisphereLights.value=Y.state.hemi,De.sunShadowMatrix.value=Y.state.sunShadowMatrix,De.sunShadowCascade.value=Y.state.sunShadowCascade,De.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,De.spotLightMatrix.value=Y.state.spotLightMatrix,De.spotLightMap.value=Y.state.spotLightMap,De.pointShadowMatrix.value=Y.state.pointShadowMatrix;return Z.lightProbeGrid=v.state.lightProbeGridArray.length>0,Z.currentProgram=ft,Z.uniformsList=null,ft}function lb(R){if(R.uniformsList===null){let H=R.currentProgram.getUniforms();R.uniformsList=rl.seqWithValue(H.seq,R.uniforms)}return R.uniformsList}function ub(R,H){let ee=V.get(R);ee.outputColorSpace=H.outputColorSpace,ee.batching=H.batching,ee.batchingColor=H.batchingColor,ee.instancing=H.instancing,ee.instancingColor=H.instancingColor,ee.instancingMorph=H.instancingMorph,ee.skinning=H.skinning,ee.morphTargets=H.morphTargets,ee.morphNormals=H.morphNormals,ee.morphColors=H.morphColors,ee.morphTargetsCount=H.morphTargetsCount,ee.numClippingPlanes=H.numClippingPlanes,ee.numIntersection=H.numClipIntersection,ee.vertexAlphas=H.vertexAlphas,ee.vertexTangents=H.vertexTangents,ee.toneMapping=H.toneMapping}function gR(R,H){if(R.length===0)return null;if(R.length===1)return R[0].texture!==null?R[0]:null;_.setFromMatrixPosition(H.matrixWorld);for(let ee=0,Z=R.length;ee<Z;ee++){let Y=R[ee];if(Y.texture!==null&&Y.boundingBox.containsPoint(_))return Y}return null}function bR(R,H,ee,Z,Y){if(H.isScene!==!0)H=Dt;Q.resetTextureUnits();let we=H.fog,Pe=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?H.environment:null,Se=O===null?A.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:ot.workingColorSpace,ke=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,ze=he.get(Z.envMap||Pe,ke),rt=Z.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,ft=!!ee.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),De=!!ee.morphAttributes.position,Mt=!!ee.morphAttributes.normal,an=!!ee.morphAttributes.color,Ht=Li;if(Z.toneMapped){if(O===null||O.isXRRenderTarget===!0)Ht=A.toneMapping}let Lt=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,Rn=Lt!==void 0?Lt.length:0,Ne=V.get(Z),Dn=v.state.lights;if(Oe===!0){if(We===!0||R!==B){let Vt=R===B&&Z.id===K;me.setState(Z,R,Vt)}}let bt=!1;if(Z.version===Ne.__version){if(Ne.needsLights&&Ne.lightsStateVersion!==Dn.state.version)bt=!0;else if(Ne.outputColorSpace!==Se)bt=!0;else if(Y.isBatchedMesh&&Ne.batching===!1)bt=!0;else if(!Y.isBatchedMesh&&Ne.batching===!0)bt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!0&&Y._colorsTexture===null)bt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!1&&Y._colorsTexture!==null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancing===!1)bt=!0;else if(!Y.isInstancedMesh&&Ne.instancing===!0)bt=!0;else if(Y.isSkinnedMesh&&Ne.skinning===!1)bt=!0;else if(!Y.isSkinnedMesh&&Ne.skinning===!0)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!0&&Y.instanceColor===null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!1&&Y.instanceColor!==null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!0&&Y.morphTexture===null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!1&&Y.morphTexture!==null)bt=!0;else if(Ne.envMap!==ze)bt=!0;else if(Z.fog===!0&&Ne.fog!==we)bt=!0;else if(Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==me.numPlanes||Ne.numIntersection!==me.numIntersection))bt=!0;else if(Ne.vertexAlphas!==rt)bt=!0;else if(Ne.vertexTangents!==ft)bt=!0;else if(Ne.morphTargets!==De)bt=!0;else if(Ne.morphNormals!==Mt)bt=!0;else if(Ne.morphColors!==an)bt=!0;else if(Ne.toneMapping!==Ht)bt=!0;else if(Ne.morphTargetsCount!==Rn)bt=!0;else if(!!Ne.lightProbeGrid!==v.state.lightProbeGridArray.length>0)bt=!0}else bt=!0,Ne.__version=Z.version;let fi=Ne.currentProgram;if(bt===!0){if(fi=Ml(Z,H,Y),w&&Z.isNodeMaterial)w.onUpdateProgram(Z,fi,Ne)}let Ki=!1,$r=!1,ka=!1,Ot=fi.getUniforms(),nn=Ne.uniforms;if(C.useProgram(fi.program))Ki=!0,$r=!0,ka=!0;if(Z.id!==K)K=Z.id,$r=!0;if(Ne.needsLights){let Vt=gR(v.state.lightProbeGridArray,Y);if(Ne.lightProbeGrid!==Vt)Ne.lightProbeGrid=Vt,$r=!0}if(Ki||B!==R){if(C.buffers.depth.getReversed()&&R.reversedDepth!==!0)R._reversedDepth=!0,R.updateProjectionMatrix();Ot.setValue(z,"projectionMatrix",R.projectionMatrix),Ot.setValue(z,"viewMatrix",R.matrixWorldInverse);let Wr=Ot.map.cameraPosition;if(Wr!==void 0)Wr.setValue(z,Kt.setFromMatrixPosition(R.matrixWorld));if(Wt.logarithmicDepthBuffer)Ot.setValue(z,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)Ot.setValue(z,"isOrthographic",R.isOrthographicCamera===!0);if(B!==R)B=R,$r=!0,ka=!0}if(Ne.needsLights){if(Dn.state.sunShadowMap.length>0)Ot.setValue(z,"sunShadowMap",Dn.state.sunShadowMap,Q);if(Dn.state.directionalShadowMap.length>0)Ot.setValue(z,"directionalShadowMap",Dn.state.directionalShadowMap,Q);if(Dn.state.spotShadowMap.length>0)Ot.setValue(z,"spotShadowMap",Dn.state.spotShadowMap,Q);if(Dn.state.pointShadowMap.length>0)Ot.setValue(z,"pointShadowMap",Dn.state.pointShadowMap,Q)}if(Y.isSkinnedMesh){Ot.setOptional(z,Y,"bindMatrix"),Ot.setOptional(z,Y,"bindMatrixInverse");let Vt=Y.skeleton;if(Vt){if(Vt.boneTexture===null)Vt.computeBoneTexture();Ot.setValue(z,"boneTexture",Vt.boneTexture,Q)}}if(Y.isBatchedMesh){if(Ot.setOptional(z,Y,"batchingTexture"),Ot.setValue(z,"batchingTexture",Y._matricesTexture,Q),Ot.setOptional(z,Y,"batchingIdTexture"),Ot.setValue(z,"batchingIdTexture",Y._indirectTexture,Q),Ot.setOptional(z,Y,"batchingColorTexture"),Y._colorsTexture!==null)Ot.setValue(z,"batchingColorTexture",Y._colorsTexture,Q)}let Kr=ee.morphAttributes;if(Kr.position!==void 0||Kr.normal!==void 0||Kr.color!==void 0)_t.update(Y,ee,fi);if($r||Ne.receiveShadow!==Y.receiveShadow)Ne.receiveShadow=Y.receiveShadow,Ot.setValue(z,"receiveShadow",Y.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&H.environment!==null)nn.envMapIntensity.value=H.environmentIntensity;if(nn.dfgLUT!==void 0)nn.dfgLUT.value=ML();if($r){if(Ot.setValue(z,"toneMappingExposure",A.toneMappingExposure),Ne.needsLights)yR(nn,ka);if(we&&Z.fog===!0)Ie.refreshFogUniforms(nn,we);if(Ie.refreshMaterialUniforms(nn,Z,L,J,v.state.transmissionRenderTarget[R.id]),Ne.needsLights&&Ne.lightProbeGrid){let Vt=Ne.lightProbeGrid;nn.probesSH.value=Vt.texture,nn.probesMin.value.copy(Vt.boundingBox.min),nn.probesMax.value.copy(Vt.boundingBox.max),nn.probesResolution.value.copy(Vt.resolution)}rl.upload(z,lb(Ne),nn,Q)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)rl.upload(z,lb(Ne),nn,Q),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)Ot.setValue(z,"center",Y.center);if(Ot.setValue(z,"modelViewMatrix",Y.modelViewMatrix),Ot.setValue(z,"normalMatrix",Y.normalMatrix),Ot.setValue(z,"modelMatrix",Y.matrixWorld),Z.uniformsGroups!==void 0){let Vt=Z.uniformsGroups;for(let Wr=0,Da=Vt.length;Wr<Da;Wr++){let fb=Vt[Wr];Ce.update(fb,fi),Ce.bind(fb,fi)}}return fi}function yR(R,H){R.ambientLightColor.needsUpdate=H,R.lightProbe.needsUpdate=H,R.sunLights.needsUpdate=H,R.sunLightShadows.needsUpdate=H,R.directionalLights.needsUpdate=H,R.directionalLightShadows.needsUpdate=H,R.pointLights.needsUpdate=H,R.pointLightShadows.needsUpdate=H,R.spotLights.needsUpdate=H,R.spotLightShadows.needsUpdate=H,R.rectAreaLights.needsUpdate=H,R.hemisphereLights.needsUpdate=H}function xR(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(R,H,ee){let Z=V.get(R);if(Z.__autoAllocateDepthBuffer=R.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;V.get(R.texture).__webglTexture=H,V.get(R.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:ee,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(R,H){let ee=V.get(R);ee.__webglFramebuffer=H,ee.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(R,H=0,ee=0){O=R,U=H,D=ee;let Z=null,Y=!1,we=!1;if(R){let Se=V.get(R);if(Se.__useDefaultFramebuffer!==void 0){C.bindFramebuffer(z.FRAMEBUFFER,Se.__webglFramebuffer),X.copy(R.viewport),q.copy(R.scissor),le=R.scissorTest,C.viewport(X),C.scissor(q),C.setScissorTest(le),K=-1;return}else if(Se.__webglFramebuffer===void 0)Q.setupRenderTarget(R);else if(Se.__hasExternalTextures)Q.rebindTextures(R,V.get(R.texture).__webglTexture,V.get(R.depthTexture).__webglTexture);else if(R.depthBuffer){let rt=R.depthTexture;if(Se.__boundDepthTexture!==rt){if(rt!==null&&V.has(rt)&&(R.width!==rt.image.width||R.height!==rt.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Q.setupDepthRenderbuffer(R)}}let ke=R.texture;if(ke.isData3DTexture||ke.isDataArrayTexture||ke.isCompressedArrayTexture)we=!0;let ze=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget){if(Array.isArray(ze[H]))Z=ze[H][ee];else Z=ze[H];Y=!0}else if(R.samples>0&&Q.useMultisampledRTT(R)===!1)Z=V.get(R).__webglMultisampledFramebuffer;else if(Array.isArray(ze))Z=ze[ee];else Z=ze;X.copy(R.viewport),q.copy(R.scissor),le=R.scissorTest}else X.copy(ie).multiplyScalar(L).floor(),q.copy(ce).multiplyScalar(L).floor(),le=_e;if(ee!==0)Z=I;if(C.bindFramebuffer(z.FRAMEBUFFER,Z))C.drawBuffers(R,Z);if(C.viewport(X),C.scissor(q),C.setScissorTest(le),Y){let Se=V.get(R.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+H,Se.__webglTexture,ee)}else if(we){let Se=H;for(let ke=0;ke<R.textures.length;ke++){let ze=V.get(R.textures[ke]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+ke,ze.__webglTexture,ee,Se)}}else if(R!==null&&ee!==0){let Se=V.get(R.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Se.__webglTexture,ee)}K=-1};function db(R){let H=V.get(R);if(H.__readFormat!==R.format||H.__readType!==R.type)H.__readFormat=R.format,H.__readType=R.type,H.__formatReadable=Wt.textureFormatReadable(R.format),H.__typeReadable=Wt.textureTypeReadable(R.type);return H}if(this.readRenderTargetPixels=function(R,H,ee,Z,Y,we,Pe,Se=0){if(!(R&&R.isWebGLRenderTarget)){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ke=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Pe!==void 0)ke=ke[Pe];if(ke){C.bindFramebuffer(z.FRAMEBUFFER,ke);try{let ze=R.textures[Se],{format:rt,type:ft}=ze;if(R.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+Se);let De=db(ze);if(De.__formatReadable===!1){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(De.__typeReadable===!1){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(H>=0&&H<=R.width-Z&&(ee>=0&&ee<=R.height-Y))z.readPixels(H,ee,Z,Y,ae.convert(rt),ae.convert(ft),we)}finally{let ze=O!==null?V.get(O).__webglFramebuffer:null;C.bindFramebuffer(z.FRAMEBUFFER,ze)}}},this.readRenderTargetPixelsAsync=async function(R,H,ee,Z,Y,we,Pe,Se=0){if(!(R&&R.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ke=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Pe!==void 0)ke=ke[Pe];if(ke)if(H>=0&&H<=R.width-Z&&(ee>=0&&ee<=R.height-Y)){C.bindFramebuffer(z.FRAMEBUFFER,ke);let ze=R.textures[Se],{format:rt,type:ft}=ze;if(R.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+Se);let De=db(ze);if(De.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(De.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Mt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,Mt),z.bufferData(z.PIXEL_PACK_BUFFER,we.byteLength,z.STREAM_READ),z.readPixels(H,ee,Z,Y,ae.convert(rt),ae.convert(ft),0),z.bindBuffer(z.PIXEL_PACK_BUFFER,null);let an=O!==null?V.get(O).__webglFramebuffer:null;C.bindFramebuffer(z.FRAMEBUFFER,an);let Ht=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await AT(z,Ht,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,Mt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,we),z.bindBuffer(z.PIXEL_PACK_BUFFER,null),z.deleteBuffer(Mt),z.deleteSync(Ht),we}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(R,H=null,ee=0){let Z=Math.pow(2,-ee),Y=Math.floor(R.image.width*Z),we=Math.floor(R.image.height*Z),Pe=H!==null?H.x:0,Se=H!==null?H.y:0;Q.setTexture2D(R,0),z.copyTexSubImage2D(z.TEXTURE_2D,ee,0,0,Pe,Se,Y,we),C.unbindTexture()},this.copyTextureToTexture=function(R,H,ee=null,Z=null,Y=0,we=0){let Pe,Se,ke,ze,rt,ft,De,Mt,an,Ht=R.isCompressedTexture?R.mipmaps[we]:R.image;if(ee!==null)Pe=ee.max.x-ee.min.x,Se=ee.max.y-ee.min.y,ke=ee.isBox3?ee.max.z-ee.min.z:1,ze=ee.min.x,rt=ee.min.y,ft=ee.isBox3?ee.min.z:0;else{let nn=Math.pow(2,-Y);if(Pe=Math.floor(Ht.width*nn),Se=Math.floor(Ht.height*nn),R.isDataArrayTexture)ke=Ht.depth;else if(R.isData3DTexture)ke=Math.floor(Ht.depth*nn);else ke=1;ze=0,rt=0,ft=0}if(Z!==null)De=Z.x,Mt=Z.y,an=Z.z;else De=0,Mt=0,an=0;let Lt=ae.convert(H.format),Rn=ae.convert(H.type),Ne;if(H.isData3DTexture)Q.setTexture3D(H,0),Ne=z.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)Q.setTexture2DArray(H,0),Ne=z.TEXTURE_2D_ARRAY;else Q.setTexture2D(H,0),Ne=z.TEXTURE_2D;C.activeTexture(z.TEXTURE0),C.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),C.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),C.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);let Dn=C.getParameter(z.UNPACK_ROW_LENGTH),bt=C.getParameter(z.UNPACK_IMAGE_HEIGHT),fi=C.getParameter(z.UNPACK_SKIP_PIXELS),Ki=C.getParameter(z.UNPACK_SKIP_ROWS),$r=C.getParameter(z.UNPACK_SKIP_IMAGES);C.pixelStorei(z.UNPACK_ROW_LENGTH,Ht.width),C.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Ht.height),C.pixelStorei(z.UNPACK_SKIP_PIXELS,ze),C.pixelStorei(z.UNPACK_SKIP_ROWS,rt),C.pixelStorei(z.UNPACK_SKIP_IMAGES,ft);let ka=R.isDataArrayTexture||R.isData3DTexture,Ot=H.isDataArrayTexture||H.isData3DTexture;if(R.isDepthTexture){let nn=V.get(R),Kr=V.get(H),Vt=V.get(nn.__renderTarget),Wr=V.get(Kr.__renderTarget);C.bindFramebuffer(z.READ_FRAMEBUFFER,Vt.__webglFramebuffer),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,Wr.__webglFramebuffer);for(let Da=0;Da<ke;Da++){if(ka)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(R).__webglTexture,Y,ft+Da),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(H).__webglTexture,we,an+Da);z.blitFramebuffer(ze,rt,Pe,Se,De,Mt,Pe,Se,z.DEPTH_BUFFER_BIT,z.NEAREST)}C.bindFramebuffer(z.READ_FRAMEBUFFER,null),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Y!==0||R.isRenderTargetTexture||V.has(R)){let nn=V.get(R),Kr=V.get(H);C.bindFramebuffer(z.READ_FRAMEBUFFER,F),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,N);for(let Vt=0;Vt<ke;Vt++){if(ka)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,nn.__webglTexture,Y,ft+Vt);else z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,nn.__webglTexture,Y);if(Ot)z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Kr.__webglTexture,we,an+Vt);else z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Kr.__webglTexture,we);if(Y!==0)z.blitFramebuffer(ze,rt,Pe,Se,De,Mt,Pe,Se,z.COLOR_BUFFER_BIT,z.NEAREST);else if(Ot)z.copyTexSubImage3D(Ne,we,De,Mt,an+Vt,ze,rt,Pe,Se);else z.copyTexSubImage2D(Ne,we,De,Mt,ze,rt,Pe,Se)}C.bindFramebuffer(z.READ_FRAMEBUFFER,null),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Ot)if(R.isDataTexture||R.isData3DTexture)z.texSubImage3D(Ne,we,De,Mt,an,Pe,Se,ke,Lt,Rn,Ht.data);else if(H.isCompressedArrayTexture)z.compressedTexSubImage3D(Ne,we,De,Mt,an,Pe,Se,ke,Lt,Ht.data);else z.texSubImage3D(Ne,we,De,Mt,an,Pe,Se,ke,Lt,Rn,Ht);else if(R.isDataTexture)z.texSubImage2D(z.TEXTURE_2D,we,De,Mt,Pe,Se,Lt,Rn,Ht.data);else if(R.isCompressedTexture)z.compressedTexSubImage2D(z.TEXTURE_2D,we,De,Mt,Ht.width,Ht.height,Lt,Ht.data);else z.texSubImage2D(z.TEXTURE_2D,we,De,Mt,Pe,Se,Lt,Rn,Ht);if(C.pixelStorei(z.UNPACK_ROW_LENGTH,Dn),C.pixelStorei(z.UNPACK_IMAGE_HEIGHT,bt),C.pixelStorei(z.UNPACK_SKIP_PIXELS,fi),C.pixelStorei(z.UNPACK_SKIP_ROWS,Ki),C.pixelStorei(z.UNPACK_SKIP_IMAGES,$r),we===0&&H.generateMipmaps)z.generateMipmap(Ne);C.unbindTexture()},this.initRenderTarget=function(R){if(V.get(R).__webglFramebuffer===void 0)Q.setupRenderTarget(R)},this.initTexture=function(R){if(R.isCubeTexture)Q.setTextureCube(R,0);else if(R.isData3DTexture)Q.setTexture3D(R,0);else if(R.isDataArrayTexture||R.isCompressedArrayTexture)Q.setTexture2DArray(R,0);else Q.setTexture2D(R,0);C.unbindTexture()},this.resetState=function(){U=0,D=0,O=null,C.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hm}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=ot._getDrawingBufferColorSpace(e),t.unpackColorSpace=ot._getUnpackColorSpace()}}var zN=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,cT=`#ifdef USE_ALPHAHASH
+#endif`,VN=`#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 ) ) ) );
@@ -104,20 +350,20 @@ ${Ti(a)}`)}`)qe("manifest hash mismatch.");return structuredClone(e)}var GE=(()=
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,lT=`#ifdef USE_ALPHAMAP
+#endif`,jN=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,uT=`#ifdef USE_ALPHAMAP
+#endif`,HN=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,hT=`#ifdef USE_ALPHATEST
+#endif`,GN=`#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`,dT=`#ifdef USE_ALPHATEST
+#endif`,$N=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,fT=`#ifdef USE_AOMAP
+#endif`,KN=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
@@ -130,10 +376,10 @@ ${Ti(a)}`)}`)qe("manifest hash mismatch.");return structuredClone(e)}var GE=(()=
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,pT=`#ifdef USE_AOMAP
+#endif`,WN=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,mT=`#ifdef USE_BATCHING
+#endif`,XN=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
@@ -167,15 +413,15 @@ ${Ti(a)}`)}`)qe("manifest hash mismatch.");return structuredClone(e)}var GE=(()=
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
-#endif`,gT=`#ifdef USE_BATCHING
+#endif`,qN=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,_T=`vec3 transformed = vec3( position );
+#endif`,JN=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,xT=`vec3 objectNormal = vec3( normal );
+#endif`,ZN=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,vT=`float G_BlinnPhong_Implicit( ) {
+#endif`,YN=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -189,7 +435,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`,yT=`#ifdef USE_IRIDESCENCE
+} // validated`,QN=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
@@ -252,7 +498,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
}
return max( I, vec3( 0.0 ) );
}
-#endif`,bT=`#ifdef USE_BUMPMAP
+#endif`,eP=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
@@ -273,7 +519,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`,ST=`#if NUM_CLIPPING_PLANES > 0
+#endif`,tP=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
@@ -319,20 +565,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
if ( clipped ) discard;
#endif
#endif
-#endif`,wT=`#if NUM_CLIPPING_PLANES > 0
+#endif`,nP=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,MT=`#if NUM_CLIPPING_PLANES > 0
+#endif`,iP=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,ET=`#if NUM_CLIPPING_PLANES > 0
+#endif`,rP=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,AT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,sP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,TT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,aP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,RT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,oP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,CT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,cP=`#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
@@ -345,7 +591,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`,IT=`#define PI 3.141592653589793
+#endif`,lP=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
@@ -416,7 +662,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`,PT=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,uP=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
@@ -509,7 +755,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`,LT=`vec3 transformedNormal = objectNormal;
+#endif`,dP=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
@@ -535,21 +781,21 @@ transformedNormal = normalMatrix * transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
-#endif`,NT=`#ifdef USE_DISPLACEMENTMAP
+#endif`,fP=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,DT=`#ifdef USE_DISPLACEMENTMAP
+#endif`,hP=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,OT=`#ifdef USE_EMISSIVEMAP
+#endif`,pP=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,UT=`#ifdef USE_EMISSIVEMAP
+#endif`,mP=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,kT="gl_FragColor = linearToOutputTexel( gl_FragColor );",FT=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,gP="gl_FragColor = linearToOutputTexel( gl_FragColor );",bP=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -557,7 +803,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 );
-}`,zT=`#ifdef USE_ENVMAP
+}`,yP=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
@@ -584,7 +830,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
-#endif`,BT=`#ifdef USE_ENVMAP
+#endif`,xP=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
@@ -592,7 +838,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
uniform sampler2D envMap;
#endif
-#endif`,VT=`#ifdef USE_ENVMAP
+#endif`,_P=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
@@ -603,7 +849,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
varying vec3 vReflect;
#endif
-#endif`,HT=`#ifdef USE_ENVMAP
+#endif`,vP=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
@@ -614,7 +860,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,GT=`#ifdef USE_ENVMAP
+#endif`,EP=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
@@ -631,18 +877,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,$T=`#ifdef USE_FOG
+#endif`,TP=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,WT=`#ifdef USE_FOG
+#endif`,AP=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,ZT=`#ifdef USE_FOG
+#endif`,SP=`#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`,jT=`#ifdef USE_FOG
+#endif`,wP=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
@@ -651,7 +897,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,XT=`#ifdef USE_GRADIENTMAP
+#endif`,MP=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -663,12 +909,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
-}`,qT=`#ifdef USE_LIGHTMAP
+}`,RP=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,YT=`LambertMaterial material;
+#endif`,IP=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,JT=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,CP=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
@@ -682,7 +928,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`,KT=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,NP=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
@@ -811,7 +1057,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return irradiance;
}
#endif
-#include <lightprobes_pars_fragment>`,QT=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,PP=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -868,8 +1114,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
}
#endif
#endif
-#endif`,e1=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,t1=`varying vec3 vViewPosition;
+#endif`,OP=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,kP=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
@@ -881,11 +1127,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`,n1=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,DP=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,i1=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,LP=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
@@ -902,7 +1148,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`,r1=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,FP=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
@@ -995,7 +1241,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`,s1=`uniform sampler2D dfgLUT;
+#endif`,UP=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
@@ -1362,7 +1608,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 );
-}`,o1=`
+}`,BP=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1510,7 +1756,7 @@ IncidentLight directLight;
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,a1=`#if defined( RE_IndirectDiffuse )
+#endif`,zP=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1540,7 +1786,7 @@ IncidentLight directLight;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,c1=`#if defined( RE_IndirectDiffuse )
+#endif`,VP=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
@@ -1548,7 +1794,7 @@ IncidentLight directLight;
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,l1=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,jP=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1593,27 +1839,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,u1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,HP=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,h1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,GP=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,d1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,$P=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,f1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,KP=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,p1=`#ifdef USE_MAP
+#endif`,WP=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,m1=`#ifdef USE_MAP
+#endif`,XP=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,g1=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,qP=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
@@ -1625,7 +1871,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,_1=`#if defined( USE_POINTS_UV )
+#endif`,JP=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1637,19 +1883,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,x1=`float metalnessFactor = metalness;
+#endif`,ZP=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,v1=`#ifdef USE_METALNESSMAP
+#endif`,YP=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,y1=`#ifdef USE_INSTANCING_MORPH
+#endif`,QP=`#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`,b1=`#if defined( USE_MORPHCOLORS )
+#endif`,eO=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
@@ -1658,12 +1904,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,S1=`#ifdef USE_MORPHNORMALS
+#endif`,tO=`#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`,w1=`#ifdef USE_MORPHTARGETS
+#endif`,nO=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1677,12 +1923,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
-#endif`,M1=`#ifdef USE_MORPHTARGETS
+#endif`,iO=`#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`,E1=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,rO=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
@@ -1723,7 +1969,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,A1=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,sO=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
@@ -1741,19 +1987,19 @@ vec3 nonPerturbedNormal = normal;`,A1=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,T1=`#ifndef FLAT_SHADED
+#endif`,aO=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,R1=`#ifndef FLAT_SHADED
+#endif`,oO=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,C1=`#ifndef FLAT_SHADED
+#endif`,cO=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1762,7 +2008,7 @@ vec3 nonPerturbedNormal = normal;`,A1=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,I1=`#ifdef USE_NORMALMAP
+#endif`,lO=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1784,13 +2030,13 @@ vec3 nonPerturbedNormal = normal;`,A1=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,P1=`#ifdef USE_CLEARCOAT
+#endif`,uO=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,L1=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,dO=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,N1=`#ifdef USE_CLEARCOATMAP
+#endif`,fO=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1799,18 +2045,18 @@ vec3 nonPerturbedNormal = normal;`,A1=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,D1=`#ifdef USE_IRIDESCENCEMAP
+#endif`,hO=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,O1=`#ifdef OPAQUE
+#endif`,pO=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,U1=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,mO=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1889,9 +2135,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
-}`,k1=`#ifdef PREMULTIPLIED_ALPHA
+}`,gO=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,F1=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,bO=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
@@ -1899,22 +2145,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,B1=`#ifdef DITHERING
+#endif`,xO=`#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`,V1=`float roughnessFactor = roughness;
+#endif`,_O=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,H1=`#ifdef USE_ROUGHNESSMAP
+#endif`,vO=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,G1=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,EO=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
@@ -2165,7 +2411,7 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
}
#endif
#endif
-#endif`,$1=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,TO=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
@@ -2210,7 +2456,7 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,W1=`#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`,AO=`#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
@@ -2250,7 +2496,7 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,Z1=`float getShadowMask() {
+#endif`,SO=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2291,12 +2537,12 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,j1=`#ifdef USE_SKINNING
+}`,wO=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,X1=`#ifdef USE_SKINNING
+#endif`,MO=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2311,7 +2557,7 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,q1=`#ifdef USE_SKINNING
+#endif`,RO=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2319,7 +2565,7 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,Y1=`#ifdef USE_SKINNING
+#endif`,IO=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2330,17 +2576,17 @@ gl_Position = projectionMatrix * mvPosition;`,z1=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,J1=`float specularStrength;
+#endif`,CO=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,K1=`#ifdef USE_SPECULARMAP
+#endif`,NO=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,Q1=`#if defined( TONE_MAPPING )
+#endif`,PO=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,eR=`#ifndef saturate
+#endif`,OO=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
@@ -2437,7 +2683,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; }`,tR=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2458,7 +2704,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,tR=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,nR=`#ifdef USE_TRANSMISSION
+#endif`,DO=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2584,7 +2830,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,tR=`#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`,iR=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,LO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2654,7 +2900,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,tR=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,rR=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,FO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2748,7 +2994,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,tR=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,sR=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,UO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
@@ -2819,7 +3065,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,tR=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var oR=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`,BO=`#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;
@@ -2828,12 +3074,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,tR=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,aR=`varying vec2 vUv;
+#endif`,zO=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,cR=`uniform sampler2D t2D;
+}`,VO=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
@@ -2845,14 +3091,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,lR=`varying vec3 vWorldDirection;
+}`,jO=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,uR=`#ifdef ENVMAP_TYPE_CUBE
+}`,HO=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
@@ -2874,14 +3120,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,hR=`varying vec3 vWorldDirection;
+}`,GO=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,dR=`uniform samplerCube tCube;
+}`,$O=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
@@ -2891,7 +3137,7 @@ void main() {
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,fR=`#include <common>
+}`,KO=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
@@ -2918,7 +3164,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,pR=`#if DEPTH_PACKING == 3200
+}`,WO=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
@@ -2956,7 +3202,7 @@ void main() {
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,mR=`#define DISTANCE
+}`,XO=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
@@ -2983,7 +3229,7 @@ void main() {
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,gR=`#define DISTANCE
+}`,qO=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
@@ -3006,13 +3252,13 @@ void main() {
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
-}`,_R=`varying vec3 vWorldDirection;
+}`,JO=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,xR=`uniform sampler2D tEquirect;
+}`,ZO=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
@@ -3021,7 +3267,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,vR=`uniform float scale;
+}`,YO=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
@@ -3043,7 +3289,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,yR=`uniform vec3 diffuse;
+}`,QO=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
@@ -3071,7 +3317,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,bR=`#include <common>
+}`,ek=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
@@ -3103,7 +3349,7 @@ void main() {
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,SR=`uniform vec3 diffuse;
+}`,tk=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
@@ -3151,7 +3397,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,wR=`#define LAMBERT
+}`,nk=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3190,7 +3436,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,MR=`#define LAMBERT
+}`,ik=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3248,7 +3494,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,ER=`#define MATCAP
+}`,rk=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3282,7 +3528,7 @@ void main() {
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,AR=`#define MATCAP
+}`,sk=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
@@ -3328,7 +3574,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,TR=`#define NORMAL
+}`,ak=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
@@ -3361,7 +3607,7 @@ void main() {
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,RR=`#define NORMAL
+}`,ok=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
@@ -3382,7 +3628,7 @@ void main() {
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,CR=`#define PHONG
+}`,ck=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3421,7 +3667,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,IR=`#define PHONG
+}`,lk=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
@@ -3481,7 +3727,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,PR=`#define STANDARD
+}`,uk=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3524,7 +3770,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,LR=`#define STANDARD
+}`,dk=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
@@ -3652,7 +3898,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,NR=`#define TOON
+}`,fk=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3689,7 +3935,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,DR=`#define TOON
+}`,hk=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3741,7 +3987,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,OR=`uniform float size;
+}`,pk=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
@@ -3772,7 +4018,7 @@ void main() {
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,UR=`uniform vec3 diffuse;
+}`,mk=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
@@ -3797,7 +4043,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,kR=`#include <common>
+}`,gk=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
@@ -3815,291 +4061,128 @@ void main() {
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
-}`,FR=`uniform vec3 color;
-uniform float opacity;
-#include <common>
-#include <fog_pars_fragment>
-#include <bsdfs>
-#include <lights_pars_begin>
-#include <logdepthbuf_pars_fragment>
-#include <shadowmap_pars_fragment>
-#include <shadowmask_pars_fragment>
-void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
-}`,zR=`uniform float rotation;
-uniform vec2 center;
-#include <common>
-#include <uv_pars_vertex>
-#include <fog_pars_vertex>
-#include <logdepthbuf_pars_vertex>
-#include <clipping_planes_pars_vertex>
-void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
-}`,BR=`uniform vec3 diffuse;
-uniform float opacity;
-#include <common>
-#include <uv_pars_fragment>
-#include <map_pars_fragment>
-#include <alphamap_pars_fragment>
-#include <alphatest_pars_fragment>
-#include <alphahash_pars_fragment>
-#include <fog_pars_fragment>
-#include <logdepthbuf_pars_fragment>
-#include <clipping_planes_pars_fragment>
-void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
-}`,et={alphahash_fragment:aT,alphahash_pars_fragment:cT,alphamap_fragment:lT,alphamap_pars_fragment:uT,alphatest_fragment:hT,alphatest_pars_fragment:dT,aomap_fragment:fT,aomap_pars_fragment:pT,batching_pars_vertex:mT,batching_vertex:gT,begin_vertex:_T,beginnormal_vertex:xT,bsdfs:vT,iridescence_fragment:yT,bumpmap_pars_fragment:bT,clipping_planes_fragment:ST,clipping_planes_pars_fragment:wT,clipping_planes_pars_vertex:MT,clipping_planes_vertex:ET,color_fragment:AT,color_pars_fragment:TT,color_pars_vertex:RT,color_vertex:CT,common:IT,cube_uv_reflection_fragment:PT,defaultnormal_vertex:LT,displacementmap_pars_vertex:NT,displacementmap_vertex:DT,emissivemap_fragment:OT,emissivemap_pars_fragment:UT,colorspace_fragment:kT,colorspace_pars_fragment:FT,envmap_fragment:zT,envmap_common_pars_fragment:BT,envmap_pars_fragment:VT,envmap_pars_vertex:HT,envmap_physical_pars_fragment:QT,envmap_vertex:GT,fog_vertex:$T,fog_pars_vertex:WT,fog_fragment:ZT,fog_pars_fragment:jT,gradientmap_pars_fragment:XT,lightmap_pars_fragment:qT,lights_lambert_fragment:YT,lights_lambert_pars_fragment:JT,lights_pars_begin:KT,lights_toon_fragment:e1,lights_toon_pars_fragment:t1,lights_phong_fragment:n1,lights_phong_pars_fragment:i1,lights_physical_fragment:r1,lights_physical_pars_fragment:s1,lights_fragment_begin:o1,lights_fragment_maps:a1,lights_fragment_end:c1,lightprobes_pars_fragment:l1,logdepthbuf_fragment:u1,logdepthbuf_pars_fragment:h1,logdepthbuf_pars_vertex:d1,logdepthbuf_vertex:f1,map_fragment:p1,map_pars_fragment:m1,map_particle_fragment:g1,map_particle_pars_fragment:_1,metalnessmap_fragment:x1,metalnessmap_pars_fragment:v1,morphinstance_vertex:y1,morphcolor_vertex:b1,morphnormal_vertex:S1,morphtarget_pars_vertex:w1,morphtarget_vertex:M1,normal_fragment_begin:E1,normal_fragment_maps:A1,normal_pars_fragment:T1,normal_pars_vertex:R1,normal_vertex:C1,normalmap_pars_fragment:I1,clearcoat_normal_fragment_begin:P1,clearcoat_normal_fragment_maps:L1,clearcoat_pars_fragment:N1,iridescence_pars_fragment:D1,opaque_fragment:O1,packing:U1,premultiplied_alpha_fragment:k1,project_vertex:F1,dithering_fragment:z1,dithering_pars_fragment:B1,roughnessmap_fragment:V1,roughnessmap_pars_fragment:H1,shadowmap_pars_fragment:G1,shadowmap_pars_vertex:$1,shadowmap_vertex:W1,shadowmask_pars_fragment:Z1,skinbase_vertex:j1,skinning_pars_vertex:X1,skinning_vertex:q1,skinnormal_vertex:Y1,specularmap_fragment:J1,specularmap_pars_fragment:K1,tonemapping_fragment:Q1,tonemapping_pars_fragment:eR,transmission_fragment:tR,transmission_pars_fragment:nR,uv_pars_fragment:iR,uv_pars_vertex:rR,uv_vertex:sR,worldpos_vertex:oR,background_vert:aR,background_frag:cR,backgroundCube_vert:lR,backgroundCube_frag:uR,cube_vert:hR,cube_frag:dR,depth_vert:fR,depth_frag:pR,distance_vert:mR,distance_frag:gR,equirect_vert:_R,equirect_frag:xR,linedashed_vert:vR,linedashed_frag:yR,meshbasic_vert:bR,meshbasic_frag:SR,meshlambert_vert:wR,meshlambert_frag:MR,meshmatcap_vert:ER,meshmatcap_frag:AR,meshnormal_vert:TR,meshnormal_frag:RR,meshphong_vert:CR,meshphong_frag:IR,meshphysical_vert:PR,meshphysical_frag:LR,meshtoon_vert:NR,meshtoon_frag:DR,points_vert:OR,points_frag:UR,shadow_vert:kR,shadow_frag:FR,sprite_vert:zR,sprite_frag:BR},be={common:{diffuse:{value:new Ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ye},alphaMap:{value:null},alphaMapTransform:{value:new Ye},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ye}},envmap:{envMap:{value:null},envMapRotation:{value:new Ye},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ye}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ye}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ye},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ye},normalScale:{value:new Ge(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ye},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ye}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ye}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ye}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Ze(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 Ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ye},alphaTest:{value:0},uvTransform:{value:new Ye}},sprite:{diffuse:{value:new Ze(16777215)},opacity:{value:1},center:{value:new Ge(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ye},alphaMap:{value:null},alphaMapTransform:{value:new Ye},alphaTest:{value:0}}},Bi={basic:{uniforms:_n([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:et.meshbasic_vert,fragmentShader:et.meshbasic_frag},lambert:{uniforms:_n([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 Ze(0)},envMapIntensity:{value:1}}]),vertexShader:et.meshlambert_vert,fragmentShader:et.meshlambert_frag},phong:{uniforms:_n([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 Ze(0)},specular:{value:new Ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:et.meshphong_vert,fragmentShader:et.meshphong_frag},standard:{uniforms:_n([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 Ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag},toon:{uniforms:_n([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new Ze(0)}}]),vertexShader:et.meshtoon_vert,fragmentShader:et.meshtoon_frag},matcap:{uniforms:_n([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:et.meshmatcap_vert,fragmentShader:et.meshmatcap_frag},points:{uniforms:_n([be.points,be.fog]),vertexShader:et.points_vert,fragmentShader:et.points_frag},dashed:{uniforms:_n([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:et.linedashed_vert,fragmentShader:et.linedashed_frag},depth:{uniforms:_n([be.common,be.displacementmap]),vertexShader:et.depth_vert,fragmentShader:et.depth_frag},normal:{uniforms:_n([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:et.meshnormal_vert,fragmentShader:et.meshnormal_frag},sprite:{uniforms:_n([be.sprite,be.fog]),vertexShader:et.sprite_vert,fragmentShader:et.sprite_frag},background:{uniforms:{uvTransform:{value:new Ye},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:et.background_vert,fragmentShader:et.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ye}},vertexShader:et.backgroundCube_vert,fragmentShader:et.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:et.cube_vert,fragmentShader:et.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:et.equirect_vert,fragmentShader:et.equirect_frag},distance:{uniforms:_n([be.common,be.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:et.distance_vert,fragmentShader:et.distance_frag},shadow:{uniforms:_n([be.lights,be.fog,{color:{value:new Ze(0)},opacity:{value:1}}]),vertexShader:et.shadow_vert,fragmentShader:et.shadow_frag}};Bi.physical={uniforms:_n([Bi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ye},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ye},clearcoatNormalScale:{value:new Ge(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ye},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ye},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ye},sheen:{value:0},sheenColor:{value:new Ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ye},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ye},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ye},transmissionSamplerSize:{value:new Ge},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ye},attenuationDistance:{value:0},attenuationColor:{value:new Ze(0)},specularColor:{value:new Ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ye},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ye},anisotropyVector:{value:new Ge},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ye}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag};var Ql={r:0,b:0,g:0},VR=new Ke,hb=new Ye;hb.set(-1,0,0,0,1,0,0,0,1);function HR(e,t,n,i,r,s){let o=new Ze(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(y){let S=y.isScene===!0?y.background:null;if(S&&S.isTexture){let x=y.backgroundBlurriness>0;S=t.get(S,x)}return S}function m(y){let S=!1,x=f(y);if(x===null)p(o,a);else if(x&&x.isColor)p(x,1),S=!0;let b=e.xr.getEnvironmentBlendMode();if(b==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(b==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||S)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(y,S){let x=f(S);if(x&&(x.isCubeTexture||x.mapping===Sa)){if(l===void 0)l=new Pt(new Dr(1,1,1),new Jn({name:"BackgroundCubeMaterial",uniforms:ms(Bi.backgroundCube.uniforms),vertexShader:Bi.backgroundCube.vertexShader,fragmentShader:Bi.backgroundCube.fragmentShader,side:mn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=x,l.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(VR.makeRotationFromEuler(S.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(hb);if(l.material.toneMapped=nt.getTransfer(x.colorSpace)!==Rt,u!==x||h!==x.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=x,h=x.version,d=e.toneMapping;l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null)}else if(x&&x.isTexture){if(c===void 0)c=new Pt(new Oa(2,2),new Jn({name:"BackgroundMaterial",uniforms:ms(Bi.background.uniforms),vertexShader:Bi.background.vertexShader,fragmentShader:Bi.background.fragmentShader,side:Cr,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=x,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=nt.getTransfer(x.colorSpace)!==Rt,x.matrixAutoUpdate===!0)x.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(x.matrix),u!==x||h!==x.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=x,h=x.version,d=e.toneMapping;c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)}}function p(y,S){y.getRGB(Ql,pf(e)),n.buffers.color.setClear(Ql.r,Ql.g,Ql.b,S,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(y,S=1){o.set(y),a=S,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,p(o,a)},render:m,addToRenderList:_,dispose:g}}function GR(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,N,Y,D,W){let z=!1,P=h(C,D,Y,N);if(s!==P)s=P,l(s.object);if(z=f(C,D,Y,W),z)m(C,D,Y,W);if(W!==null)t.update(W,e.ELEMENT_ARRAY_BUFFER);if(z||o){if(o=!1,x(C,N,Y,D),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,N,Y,D){let W=D.wireframe===!0,z=i[N.id];if(z===void 0)z={},i[N.id]=z;let P=C.isInstancedMesh===!0?C.id:0,q=z[P];if(q===void 0)q={},z[P]=q;let H=q[Y.id];if(H===void 0)H={},q[Y.id]=H;let ee=H[W];if(ee===void 0)ee=d(c()),H[W]=ee;return ee}function d(C){let N=[],Y=[],D=[];for(let W=0;W<n;W++)N[W]=0,Y[W]=0,D[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:Y,attributeDivisors:D,object:C,attributes:{},index:null}}function f(C,N,Y,D){let W=s.attributes,z=N.attributes,P=0,q=Y.getAttributes();for(let H in q)if(q[H].location>=0){let J=W[H],de=z[H];if(de===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)de=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)de=C.instanceColor}if(J===void 0)return!0;if(J.attribute!==de)return!0;if(de&&J.data!==de.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==D)return!0;return!1}function m(C,N,Y,D){let W={},z=N.attributes,P=0,q=Y.getAttributes();for(let H in q)if(q[H].location>=0){let J=z[H];if(J===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)J=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)J=C.instanceColor}let de={};if(de.attribute=J,J&&J.data)de.data=J.data;W[H]=de,P++}s.attributes=W,s.attributesNum=P,s.index=D}function _(){let C=s.newAttributes;for(let N=0,Y=C.length;N<Y;N++)C[N]=0}function p(C){g(C,0)}function g(C,N){let Y=s.newAttributes,D=s.enabledAttributes,W=s.attributeDivisors;if(Y[C]=1,D[C]===0)e.enableVertexAttribArray(C),D[C]=1;if(W[C]!==N)e.vertexAttribDivisor(C,N),W[C]=N}function y(){let C=s.newAttributes,N=s.enabledAttributes;for(let Y=0,D=N.length;Y<D;Y++)if(N[Y]!==C[Y])e.disableVertexAttribArray(Y),N[Y]=0}function S(C,N,Y,D,W,z,P){if(P===!0)e.vertexAttribIPointer(C,N,Y,W,z);else e.vertexAttribPointer(C,N,Y,D,W,z)}function x(C,N,Y,D){_();let W=D.attributes,z=Y.getAttributes(),P=N.defaultAttributeValues;for(let q in z){let H=z[q];if(H.location>=0){let ee=W[q];if(ee===void 0){if(q==="instanceMatrix"&&C.instanceMatrix)ee=C.instanceMatrix;if(q==="instanceColor"&&C.instanceColor)ee=C.instanceColor}if(ee!==void 0){let J=ee.normalized,de=ee.itemSize,pe=t.get(ee);if(pe===void 0)continue;let{buffer:Be,type:me,bytesPerElement:X}=pe,L=me===e.INT||me===e.UNSIGNED_INT||ee.gpuType===yd;if(ee.isInterleavedBufferAttribute){let G=ee.data,te=G.stride,se=ee.offset;if(G.isInstancedInterleavedBuffer){for(let ce=0;ce<H.locationSize;ce++)g(H.location+ce,G.meshPerAttribute);if(C.isInstancedMesh!==!0&&D._maxInstanceCount===void 0)D._maxInstanceCount=G.meshPerAttribute*G.count}else for(let ce=0;ce<H.locationSize;ce++)p(H.location+ce);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let ce=0;ce<H.locationSize;ce++)S(H.location+ce,de/H.locationSize,me,J,te*X,(se+de/H.locationSize*ce)*X,L)}else{if(ee.isInstancedBufferAttribute){for(let G=0;G<H.locationSize;G++)g(H.location+G,ee.meshPerAttribute);if(C.isInstancedMesh!==!0&&D._maxInstanceCount===void 0)D._maxInstanceCount=ee.meshPerAttribute*ee.count}else for(let G=0;G<H.locationSize;G++)p(H.location+G);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let G=0;G<H.locationSize;G++)S(H.location+G,de/H.locationSize,me,J,de*X,de/H.locationSize*G*X,L)}}else if(P!==void 0){let J=P[q];if(J!==void 0)switch(J.length){case 2:e.vertexAttrib2fv(H.location,J);break;case 3:e.vertexAttrib3fv(H.location,J);break;case 4:e.vertexAttrib4fv(H.location,J);break;default:e.vertexAttrib1fv(H.location,J)}}}}y()}function b(){A();for(let C in i){let N=i[C];for(let Y in N){let D=N[Y];for(let W in D){let z=D[W];for(let P in z)u(z[P].object),delete z[P];delete D[W]}}delete i[C]}}function M(C){if(i[C.id]===void 0)return;let N=i[C.id];for(let Y in N){let D=N[Y];for(let W in D){let z=D[W];for(let P in z)u(z[P].object),delete z[P];delete D[W]}}delete i[C.id]}function T(C){for(let N in i){let Y=i[N];for(let D in Y){let W=Y[D];if(W[C.id]===void 0)continue;let z=W[C.id];for(let P in z)u(z[P].object),delete z[P];delete W[C.id]}}}function v(C){for(let N in i){let Y=i[N],D=C.isInstancedMesh===!0?C.id:0,W=Y[D];if(W===void 0)continue;for(let z in W){let P=W[z];for(let q in P)u(P[q].object),delete P[q];delete W[z]}if(delete Y[D],Object.keys(Y).length===0)delete i[N]}}function A(){if(V(),o=!0,s===r)return;s=r,l(s.object)}function V(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:A,resetDefaultState:V,dispose:b,releaseStatesOfGeometry:M,releaseStatesOfObject:v,releaseStatesOfProgram:T,initAttributes:_,enableAttribute:p,disableUnusedAttributes:y}}function $R(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 WR(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let T=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(T){if(T!==ki&&i.convert(T)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(T){let v=T===Ui&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(T!==di&&T!==or&&!v&&i.convert(T)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(T){if(T==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";T="mediump"}if(T==="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)ze("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)ze("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),y=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),S=e.getParameter(e.MAX_VARYING_VECTORS),x=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),M=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:y,maxVaryings:S,maxFragmentUniforms:x,maxSamples:b,samples:M}}function ZR(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Xn,a=new Ye,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 y=s?0:i,S=y*4,x=g.clippingState||null;c.value=x,x=u(m,d,S,f);for(let b=0;b!==S;++b)x[b]=n[b];g.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};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,y=d.matrixWorldInverse;if(a.getNormalMatrix(y),p===null||p.length<g)p=new Float32Array(g);for(let S=0,x=f;S!==_;++S,x+=4)o.copy(h[S]).applyMatrix4(y,a),o.normal.toArray(p,x),p[x+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var vo=4,jR=6,XR=20,qR=256,Ba=new _s,Gy=new Ze,Pf=null,Lf=0,Nf=0,Df=!1,YR=new F,xs=new F;class $a{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=YR}=r;Pf=this._renderer.getRenderTarget(),Lf=this._renderer.getActiveCubeFace(),Nf=this._renderer.getActiveMipmapLevel(),Df=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=Zy(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Wy(),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(Pf,Lf,Nf),this._renderer.xr.enabled=Df,e.scissorTest=!1,xo(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===io||e.mapping===cs)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Pf=this._renderer.getRenderTarget(),Lf=this._renderer.getActiveCubeFace(),Nf=this._renderer.getActiveMipmapLevel(),Df=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:sn,minFilter:sn,generateMipmaps:!1,type:Ui,format:ki,colorSpace:Un,depthBuffer:!1},i=$y(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=$y(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=JR(r)),this._blurMaterial=QR(r,e,t),this._ggxMaterial=KR(r,e,t)}return i}_compileMaterial(e){let t=new Pt(new gn,e);this._renderer.compile(t,Ba)}_sceneToCubeUV(e,t,n,i,r){let a=new qt(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(Gy),u.toneMapping=ui,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Pt(new Dr,new Fi({name:"PMREM.Background",side:mn,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(Gy),p=!0;for(let y=0;y<6;y++){let S=y%3;if(S===0)a.up.set(0,c[y],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[y],r.y,r.z);else if(S===1)a.up.set(0,0,c[y]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[y],r.z);else a.up.set(0,c[y],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[y]);let x=this._cubeSize;if(xo(i,S*x,y>2?x:0,x,x),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===io||e.mapping===cs;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Zy();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Wy();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;xo(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Ba)}_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-vo?n-f+vo:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=d,a.mipInt.value=f-t,xo(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,Ba),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,xo(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,Ba)}_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-vo?i-this._lodMax+vo:0),h=4*(this._cubeSize-l);xo(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,Ba)}}function JR(e){let t=[],n=[],i=e,r=e-vo+1+jR;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 y=g%3*2/3-1,S=g>2?0:-1,x=[y,S,0,y+0.6666666666666666,S,0,y+0.6666666666666666,S+1,0,y,S,0,y+0.6666666666666666,S+1,0,y,S+1,0];m.set(x,f*d*g);for(let b=0;b<d;b++){let M=u[b*2]*2-1,T=u[b*2+1]*2-1;if(g===0)xs.set(1,T,M);else if(g===1)xs.set(-M,1,-T);else if(g===2)xs.set(-M,T,1);else if(g===3)xs.set(-1,T,-M);else if(g===4)xs.set(-M,-1,T);else xs.set(M,T,-1);xs.toArray(_,(g*d+b)*f)}}let p=new gn;if(p.setAttribute("position",new rn(m,f)),p.setAttribute("outputDirection",new rn(_,f)),n.push(new Pt(p,null)),i>vo)i--}return{lodMeshes:n,sizeLods:t}}function $y(e,t,n){let i=new kn(e,t,n);return i.texture.mapping=Sa,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xo(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function KR(e,t,n){return new Jn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:qR,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:tu(),fragmentShader:`
-
- precision highp float;
- precision highp int;
-
- varying vec3 vOutputDirection;
-
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
-
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
-
- #define PI 3.14159265359
-
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
-
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
-
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
-
- // Section 4.1: Orthonormal basis
- vec3 T1 = vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(V, T1);
-
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + V.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
-
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
-
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
-
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
-
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
-
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
-
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
-
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
-
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
-
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
-
- float NdotL = max(dot(N, L), 0.0);
-
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
-
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
-
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
-
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:Di,depthTest:!1,depthWrite:!1})}function QR(e,t,n){return new Jn({name:"SphericalGaussianBlur",defines:{SAMPLES:XR,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:tu(),fragmentShader:`
-
- precision highp float;
- precision highp int;
-
- varying vec3 vOutputDirection;
-
- uniform sampler2D envMap;
- uniform float sigma;
- uniform float mipInt;
-
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
-
- #define PI 3.14159265359
- #define GOLDEN_ANGLE 2.39996322973
-
- void main() {
-
- if ( sigma == 0.0 ) {
-
- gl_FragColor = vec4( bilinearCubeUV( envMap, vOutputDirection, mipInt ), 1.0 );
- return;
-
- }
-
- vec3 outputDirection = normalize( vOutputDirection );
-
- vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );
- vec3 tangent = normalize( cross( up, outputDirection ) );
- vec3 bitangent = cross( outputDirection, tangent );
-
- // Truncate the kernel at three standard deviations or at the antipode.
- float thetaMax = min( 3.0 * sigma, PI );
- float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );
-
- vec3 accumColor = vec3( 0.0 );
- float accumWeight = 0.0;
-
- for ( int i = 0; i < SAMPLES; i ++ ) {
-
- // Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral.
- float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );
- float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );
- float phi = float( i ) * GOLDEN_ANGLE;
-
- vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent;
- vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;
-
- // Correct the planar sample density to solid angle.
- float weight = sin( theta ) / theta;
-
- accumColor += weight * bilinearCubeUV( envMap, sampleDirection, mipInt );
- accumWeight += weight;
-
- }
-
- gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
-
- }
- `,blending:Di,depthTest:!1,depthWrite:!1})}function Wy(){return new Jn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:tu(),fragmentShader:`
-
- precision mediump float;
- precision mediump int;
-
- varying vec3 vOutputDirection;
-
- uniform sampler2D envMap;
-
- #include <common>
-
- void main() {
-
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
-
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
-
- }
- `,blending:Di,depthTest:!1,depthWrite:!1})}function Zy(){return new Jn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:tu(),fragmentShader:`
-
- precision mediump float;
- precision mediump int;
-
- uniform float flipEnvMap;
-
- varying vec3 vOutputDirection;
+ #include <project_vertex>
+ #include <logdepthbuf_vertex>
+ #include <worldpos_vertex>
+ #include <shadowmap_vertex>
+ #include <fog_vertex>
+}`,bk=`uniform vec3 color;
+uniform float opacity;
+#include <common>
+#include <fog_pars_fragment>
+#include <bsdfs>
+#include <lights_pars_begin>
+#include <logdepthbuf_pars_fragment>
+#include <shadowmap_pars_fragment>
+#include <shadowmask_pars_fragment>
+void main() {
+ #include <logdepthbuf_fragment>
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
+ #include <tonemapping_fragment>
+ #include <colorspace_fragment>
+ #include <fog_fragment>
+ #include <premultiplied_alpha_fragment>
+}`,yk=`uniform float rotation;
+uniform vec2 center;
+#include <common>
+#include <uv_pars_vertex>
+#include <fog_pars_vertex>
+#include <logdepthbuf_pars_vertex>
+#include <clipping_planes_pars_vertex>
+void main() {
+ #include <uv_vertex>
+ vec4 mvPosition = modelViewMatrix[ 3 ];
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
+ #ifndef USE_SIZEATTENUATION
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
+ if ( isPerspective ) scale *= - mvPosition.z;
+ #endif
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
+ vec2 rotatedPosition;
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
+ mvPosition.xy += rotatedPosition;
+ gl_Position = projectionMatrix * mvPosition;
+ #include <logdepthbuf_vertex>
+ #include <clipping_planes_vertex>
+ #include <fog_vertex>
+}`,xk=`uniform vec3 diffuse;
+uniform float opacity;
+#include <common>
+#include <uv_pars_fragment>
+#include <map_pars_fragment>
+#include <alphamap_pars_fragment>
+#include <alphatest_pars_fragment>
+#include <alphahash_pars_fragment>
+#include <fog_pars_fragment>
+#include <logdepthbuf_pars_fragment>
+#include <clipping_planes_pars_fragment>
+void main() {
+ vec4 diffuseColor = vec4( diffuse, opacity );
+ #include <clipping_planes_fragment>
+ vec3 outgoingLight = vec3( 0.0 );
+ #include <logdepthbuf_fragment>
+ #include <map_fragment>
+ #include <alphamap_fragment>
+ #include <alphatest_fragment>
+ #include <alphahash_fragment>
+ outgoingLight = diffuseColor.rgb;
+ #include <opaque_fragment>
+ #include <tonemapping_fragment>
+ #include <colorspace_fragment>
+ #include <fog_fragment>
+}`,st,Te,mr,Ad,_k,iA,Oo=4,wk=6,Mk=20,Rk=256,tl,DT,Fm=null,Um=0,Bm=0,zm=!1,Ik,Aa,$m,zk,rA,Hm,sA,aA,oA,BT,zT,VT,jT,HT,Vm,ID=37297,CD=0,KT,kD,Sd,zD,VD,HD,$D,WD,qD,ZD,tL=0,lL=0,hL=`void main() {
+ gl_Position = vec4( position, 1.0 );
+}`,pL=`uniform sampler2D shadow_pass;
+uniform vec2 resolution;
+uniform float radius;
+void main() {
+ const float samples = float( VSM_SAMPLES );
+ float mean = 0.0;
+ float squared_mean = 0.0;
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
+ for ( float i = 0.0; i < samples; i ++ ) {
+ float uvOffset = uvStart + i * uvStride;
+ #ifdef HORIZONTAL_PASS
+ vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
+ mean += distribution.x;
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
+ #else
+ float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
+ mean += depth;
+ squared_mean += depth * depth;
+ #endif
+ }
+ mean = mean / samples;
+ 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 );
+}`,mL,gL,tA,nl,jm,vL=`
+void main() {
- uniform samplerCube envMap;
+ gl_Position = vec4( position, 1.0 );
- void main() {
+}`,EL=`
+uniform sampler2DArray depthColor;
+uniform float depthWidth;
+uniform float depthHeight;
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
+void main() {
- }
- `,blending:Di,depthTest:!1,depthWrite:!1})}function tu(){return`
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- precision mediump float;
- precision mediump int;
+ if ( coord.x >= 1.0 ) {
- attribute vec3 outputDirection;
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- varying vec3 vOutputDirection;
+ } else {
- void main() {
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- vOutputDirection = outputDirection;
- gl_Position = vec4( position, 1.0 );
+ }
- }
- `}class zf extends kn{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 Hl(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:`
+}`,pA,TL,mA,wL,pr=null;var zi=Ft(()=>{Lm();Lm();st={alphahash_fragment:zN,alphahash_pars_fragment:VN,alphamap_fragment:jN,alphamap_pars_fragment:HN,alphatest_fragment:GN,alphatest_pars_fragment:$N,aomap_fragment:KN,aomap_pars_fragment:WN,batching_pars_vertex:XN,batching_vertex:qN,begin_vertex:JN,beginnormal_vertex:ZN,bsdfs:YN,iridescence_fragment:QN,bumpmap_pars_fragment:eP,clipping_planes_fragment:tP,clipping_planes_pars_fragment:nP,clipping_planes_pars_vertex:iP,clipping_planes_vertex:rP,color_fragment:sP,color_pars_fragment:aP,color_pars_vertex:oP,color_vertex:cP,common:lP,cube_uv_reflection_fragment:uP,defaultnormal_vertex:dP,displacementmap_pars_vertex:fP,displacementmap_vertex:hP,emissivemap_fragment:pP,emissivemap_pars_fragment:mP,colorspace_fragment:gP,colorspace_pars_fragment:bP,envmap_fragment:yP,envmap_common_pars_fragment:xP,envmap_pars_fragment:_P,envmap_pars_vertex:vP,envmap_physical_pars_fragment:PP,envmap_vertex:EP,fog_vertex:TP,fog_pars_vertex:AP,fog_fragment:SP,fog_pars_fragment:wP,gradientmap_pars_fragment:MP,lightmap_pars_fragment:RP,lights_lambert_fragment:IP,lights_lambert_pars_fragment:CP,lights_pars_begin:NP,lights_toon_fragment:OP,lights_toon_pars_fragment:kP,lights_phong_fragment:DP,lights_phong_pars_fragment:LP,lights_physical_fragment:FP,lights_physical_pars_fragment:UP,lights_fragment_begin:BP,lights_fragment_maps:zP,lights_fragment_end:VP,lightprobes_pars_fragment:jP,logdepthbuf_fragment:HP,logdepthbuf_pars_fragment:GP,logdepthbuf_pars_vertex:$P,logdepthbuf_vertex:KP,map_fragment:WP,map_pars_fragment:XP,map_particle_fragment:qP,map_particle_pars_fragment:JP,metalnessmap_fragment:ZP,metalnessmap_pars_fragment:YP,morphinstance_vertex:QP,morphcolor_vertex:eO,morphnormal_vertex:tO,morphtarget_pars_vertex:nO,morphtarget_vertex:iO,normal_fragment_begin:rO,normal_fragment_maps:sO,normal_pars_fragment:aO,normal_pars_vertex:oO,normal_vertex:cO,normalmap_pars_fragment:lO,clearcoat_normal_fragment_begin:uO,clearcoat_normal_fragment_maps:dO,clearcoat_pars_fragment:fO,iridescence_pars_fragment:hO,opaque_fragment:pO,packing:mO,premultiplied_alpha_fragment:gO,project_vertex:bO,dithering_fragment:yO,dithering_pars_fragment:xO,roughnessmap_fragment:_O,roughnessmap_pars_fragment:vO,shadowmap_pars_fragment:EO,shadowmap_pars_vertex:TO,shadowmap_vertex:AO,shadowmask_pars_fragment:SO,skinbase_vertex:wO,skinning_pars_vertex:MO,skinning_vertex:RO,skinnormal_vertex:IO,specularmap_fragment:CO,specularmap_pars_fragment:NO,tonemapping_fragment:PO,tonemapping_pars_fragment:OO,transmission_fragment:kO,transmission_pars_fragment:DO,uv_pars_fragment:LO,uv_pars_vertex:FO,uv_vertex:UO,worldpos_vertex:BO,background_vert:zO,background_frag:VO,backgroundCube_vert:jO,backgroundCube_frag:HO,cube_vert:GO,cube_frag:$O,depth_vert:KO,depth_frag:WO,distance_vert:XO,distance_frag:qO,equirect_vert:JO,equirect_frag:ZO,linedashed_vert:YO,linedashed_frag:QO,meshbasic_vert:ek,meshbasic_frag:tk,meshlambert_vert:nk,meshlambert_frag:ik,meshmatcap_vert:rk,meshmatcap_frag:sk,meshnormal_vert:ak,meshnormal_frag:ok,meshphong_vert:ck,meshphong_frag:lk,meshphysical_vert:uk,meshphysical_frag:dk,meshtoon_vert:fk,meshtoon_frag:hk,points_vert:pk,points_frag:mk,shadow_vert:gk,shadow_frag:bk,sprite_vert:yk,sprite_frag:xk},Te={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new tt}},envmap:{envMap:{value:null},envMapRotation:{value:new tt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new tt},normalScale:{value:new Ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new qe(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 j},probesMax:{value:new j},probesResolution:{value:new j}},points:{diffuse:{value:new qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0},uvTransform:{value:new tt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new Ke(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}}},mr={basic:{uniforms:kn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:kn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},envMapIntensity:{value:1}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:kn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:kn([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:kn([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new qe(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:kn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:kn([Te.points,Te.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:kn([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:kn([Te.common,Te.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:kn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:kn([Te.sprite,Te.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new tt}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distance:{uniforms:kn([Te.common,Te.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:st.distance_vert,fragmentShader:st.distance_frag},shadow:{uniforms:kn([Te.lights,Te.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};mr.physical={uniforms:kn([mr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new tt},clearcoatNormalScale:{value:new Ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new tt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new tt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new tt},transmissionSamplerSize:{value:new Ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new tt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new tt},anisotropyVector:{value:new Ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new tt}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};Ad={r:0,b:0,g:0},_k=new Qe,iA=new tt;iA.set(-1,0,0,0,1,0,0,0,1);tl=new Ta,DT=new qe,Ik=new j,Aa=new j;$m=class $m extends ai{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 hd(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;
@@ -4134,152 +4217,88 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new Dr(5,5,5),r=new Jn({name:"CubemapFromEquirect",uniforms:ms(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:mn,blending:Di});r.uniforms.tEquirect.value=t;let s=new Pt(i,r),o=t.minFilter;if(t.minFilter===Oi)t.minFilter=sn;return new wf(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 eC(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===Sl||f===wl)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 zf(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===Sl||f===wl,_=f===io||f===cs;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 $a(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 y=d.image;if(m&&y&&y.height>0||_&&y&&c(y)){if(i===null)i=new $a(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===Sl)d.mapping=io;else if(f===wl)d.mapping=cs;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 tC(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)os("WebGLRenderer: "+i+" extension not supported.");return r}}}function nC(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 y=f.array;_=f.version;for(let S=0,x=y.length;S<x;S+=3){let b=y[S+0],M=y[S+1],T=y[S+2];d.push(b,M,M,T,T,b)}}else{let y=m.array;_=m.version;for(let S=0,x=y.length/3-1;S<x;S+=3){let b=S+0,M=S+1,T=S+2;d.push(b,M,M,T,T,b)}}let p=new(m.count>=65535?Fl:kl)(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 iC(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 rC(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:je("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 sC(e,t,n){let i=new WeakMap,r=new yt;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 A=function(){T.dispose(),i.delete(a),a.removeEventListener("dispose",A)};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||[],y=a.morphAttributes.color||[],S=0;if(f===!0)S=1;if(m===!0)S=2;if(_===!0)S=3;let x=a.attributes.position.count*S,b=1;if(x>t.maxTextureSize)b=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize;let M=new Float32Array(x*b*4*h),T=new Ol(M,x,b,h);T.type=or,T.needsUpdate=!0;let v=S*4;for(let V=0;V<h;V++){let C=p[V],N=g[V],Y=y[V],D=x*b*4*V;for(let W=0;W<C.count;W++){let z=W*v;if(f===!0)r.fromBufferAttribute(C,W),M[D+z+0]=r.x,M[D+z+1]=r.y,M[D+z+2]=r.z,M[D+z+3]=0;if(m===!0)r.fromBufferAttribute(N,W),M[D+z+4]=r.x,M[D+z+5]=r.y,M[D+z+6]=r.z,M[D+z+7]=0;if(_===!0)r.fromBufferAttribute(Y,W),M[D+z+8]=r.x,M[D+z+9]=r.y,M[D+z+10]=r.z,M[D+z+11]=Y.itemSize===4?r.w:1}}d={count:h,texture:T,size:new Ge(x,b)},i.set(a,d),a.addEventListener("dispose",A)}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 oC(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 aC={[pd]:"LINEAR_TONE_MAPPING",[md]:"REINHARD_TONE_MAPPING",[gd]:"CINEON_TONE_MAPPING",[ba]:"ACES_FILMIC_TONE_MAPPING",[xd]:"AGX_TONE_MAPPING",[vd]:"NEUTRAL_TONE_MAPPING",[_d]:"CUSTOM_TONE_MAPPING"};function cC(e,t,n,i,r,s){let o=new kn(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 gn;l.setAttribute("position",new An([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new An([0,2,0,0,2,0],2));let u=new mf({uniforms:{tDiffuse:{value:null}},vertexShader:`
- precision highp float;
-
- uniform mat4 modelViewMatrix;
- uniform mat4 projectionMatrix;
-
- attribute vec3 position;
- attribute vec2 uv;
-
- varying vec2 vUv;
-
- void main() {
- vUv = uv;
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,fragmentShader:`
- precision highp float;
-
- uniform sampler2D tDiffuse;
-
- varying vec2 vUv;
-
- #include <tonemapping_pars_fragment>
- #include <colorspace_pars_fragment>
-
- void main() {
- gl_FragColor = texture2D( tDiffuse, vUv );
-
- #ifdef LINEAR_TONE_MAPPING
- gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
- #elif defined( REINHARD_TONE_MAPPING )
- gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
- #elif defined( CINEON_TONE_MAPPING )
- gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
- #elif defined( ACES_FILMIC_TONE_MAPPING )
- gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
- #elif defined( AGX_TONE_MAPPING )
- gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
- #elif defined( NEUTRAL_TONE_MAPPING )
- gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
- #elif defined( CUSTOM_TONE_MAPPING )
- gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
- #endif
-
- #ifdef SRGB_TRANSFER
- gl_FragColor = sRGBTransferOETF( gl_FragColor );
- #endif
- }`,depthTest:!1,depthWrite:!1}),h=new Pt(l,u),d=new _s(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,y=[],S=!1;this.setSize=function(x,b){if(o.setSize(x,b),a!==null)a.setSize(x,b);if(c!==null)c.setSize(x,b);for(let M=0;M<y.length;M++){let T=y[M];if(T.setSize)T.setSize(x,b)}},this.setEffects=function(x){y=x,S=y.length>0&&y[0].isRenderPass===!0;let{width:b,height:M}=o;if(y.length>0&&a===null)a=new kn(b,M,{type:Ui,depthBuffer:!1,stencilBuffer:!1}),c=new kn(b,M,{type:Ui,depthBuffer:!1,stencilBuffer:!1});for(let T=0;T<y.length;T++){let v=y[T];if(v.setSize)v.setSize(b,M)}},this.begin=function(x,b){if(_)return!1;if(x.toneMapping===ui&&y.length===0)return!1;if(g=b,b!==null){let{width:M,height:T}=b;if(o.width!==M||o.height!==T)this.setSize(M,T)}if(S===!1)x.setRenderTarget(o);return p=x.toneMapping,x.toneMapping=ui,!0},this.hasRenderPass=function(){return S},this.end=function(x,b){x.toneMapping=p,_=!0;let M=o,T=a;for(let v=0;v<y.length;v++){let A=y[v];if(A.enabled===!1)continue;if(A.render(x,T,M,b),A.needsSwap!==!1)M=T,T=T===a?c:a}if(f!==x.outputColorSpace||m!==x.toneMapping){if(f=x.outputColorSpace,m=x.toneMapping,u.defines={},nt.getTransfer(f)===Rt)u.defines.SRGB_TRANSFER="";let v=aC[m];if(v)u.defines[v]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=M.texture,x.setRenderTarget(g),x.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 db=new Vt,kf=new ps(1,1),fb=new Ol,pb=new df,mb=new Hl,jy=[],Xy=[],qy=new Float32Array(16),Yy=new Float32Array(9),Jy=new Float32Array(4);function yo(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=jy[r];if(s===void 0)s=new Float32Array(r),jy[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 Jt(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 nu(e,t){let n=Xy[t];if(n===void 0)n=new Int32Array(t),Xy[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function lC(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function uC(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(Jt(n,t))return;e.uniform2fv(this.addr,t),Kt(n,t)}}function hC(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(Jt(n,t))return;e.uniform3fv(this.addr,t),Kt(n,t)}}function dC(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(Jt(n,t))return;e.uniform4fv(this.addr,t),Kt(n,t)}}function fC(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Jt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Kt(n,t)}else{if(Jt(n,i))return;Jy.set(i),e.uniformMatrix2fv(this.addr,!1,Jy),Kt(n,i)}}function pC(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Jt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Kt(n,t)}else{if(Jt(n,i))return;Yy.set(i),e.uniformMatrix3fv(this.addr,!1,Yy),Kt(n,i)}}function mC(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Jt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Kt(n,t)}else{if(Jt(n,i))return;qy.set(i),e.uniformMatrix4fv(this.addr,!1,qy),Kt(n,i)}}function gC(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function _C(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(Jt(n,t))return;e.uniform2iv(this.addr,t),Kt(n,t)}}function xC(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(Jt(n,t))return;e.uniform3iv(this.addr,t),Kt(n,t)}}function vC(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(Jt(n,t))return;e.uniform4iv(this.addr,t),Kt(n,t)}}function yC(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function bC(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(Jt(n,t))return;e.uniform2uiv(this.addr,t),Kt(n,t)}}function SC(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(Jt(n,t))return;e.uniform3uiv(this.addr,t),Kt(n,t)}}function wC(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(Jt(n,t))return;e.uniform4uiv(this.addr,t),Kt(n,t)}}function MC(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)kf.compareFunction=n.isReversedDepthBuffer()?Dl:Nl,s=kf;else s=db;n.setTexture2D(t||s,r)}function EC(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||pb,r)}function AC(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||mb,r)}function TC(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||fb,r)}function RC(e){switch(e){case 5126:return lC;case 35664:return uC;case 35665:return hC;case 35666:return dC;case 35674:return fC;case 35675:return pC;case 35676:return mC;case 5124:case 35670:return gC;case 35667:case 35671:return _C;case 35668:case 35672:return xC;case 35669:case 35673:return vC;case 5125:return yC;case 36294:return bC;case 36295:return SC;case 36296:return wC;case 35678:case 36198:case 36298:case 36306:case 35682:return MC;case 35679:case 36299:case 36307:return EC;case 35680:case 36300:case 36308:case 36293:return AC;case 36289:case 36303:case 36311:case 36292:return TC}}function CC(e,t){e.uniform1fv(this.addr,t)}function IC(e,t){let n=yo(t,this.size,2);e.uniform2fv(this.addr,n)}function PC(e,t){let n=yo(t,this.size,3);e.uniform3fv(this.addr,n)}function LC(e,t){let n=yo(t,this.size,4);e.uniform4fv(this.addr,n)}function NC(e,t){let n=yo(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function DC(e,t){let n=yo(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function OC(e,t){let n=yo(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function UC(e,t){e.uniform1iv(this.addr,t)}function kC(e,t){e.uniform2iv(this.addr,t)}function FC(e,t){e.uniform3iv(this.addr,t)}function zC(e,t){e.uniform4iv(this.addr,t)}function BC(e,t){e.uniform1uiv(this.addr,t)}function VC(e,t){e.uniform2uiv(this.addr,t)}function HC(e,t){e.uniform3uiv(this.addr,t)}function GC(e,t){e.uniform4uiv(this.addr,t)}function $C(e,t,n){let i=this.cache,r=t.length,s=nu(n,r);if(!Jt(i,s))e.uniform1iv(this.addr,s),Kt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=kf;else o=db;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function WC(e,t,n){let i=this.cache,r=t.length,s=nu(n,r);if(!Jt(i,s))e.uniform1iv(this.addr,s),Kt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||pb,s[o])}function ZC(e,t,n){let i=this.cache,r=t.length,s=nu(n,r);if(!Jt(i,s))e.uniform1iv(this.addr,s),Kt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||mb,s[o])}function jC(e,t,n){let i=this.cache,r=t.length,s=nu(n,r);if(!Jt(i,s))e.uniform1iv(this.addr,s),Kt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||fb,s[o])}function XC(e){switch(e){case 5126:return CC;case 35664:return IC;case 35665:return PC;case 35666:return LC;case 35674:return NC;case 35675:return DC;case 35676:return OC;case 5124:case 35670:return UC;case 35667:case 35671:return kC;case 35668:case 35672:return FC;case 35669:case 35673:return zC;case 5125:return BC;case 36294:return VC;case 36295:return HC;case 36296:return GC;case 35678:case 36198:case 36298:case 36306:case 35682:return $C;case 35679:case 36299:case 36307:return WC;case 35680:case 36300:case 36308:case 36293:return ZC;case 36289:case 36303:case 36311:case 36292:return jC}}class gb{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=RC(t.type)}}class _b{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=XC(t.type)}}class xb{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 Of=/(\w+)(\])?(\[|\.)?/g;function Ky(e,t){e.seq.push(t),e.map[t.id]=t}function qC(e,t,n){let i=e.name,r=i.length;Of.lastIndex=0;while(!0){let s=Of.exec(i),o=Of.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Ky(n,l===void 0?new gb(a,e,t):new _b(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new xb(a),Ky(n,h);n=h}}}class Ga{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);qC(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 Qy(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var YC=37297,JC=0;function KC(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 eb=new Ye;function QC(e){nt._getMatrix(eb,nt.workingColorSpace,e);let t=`mat3( ${eb.elements.map((n)=>n.toFixed(4))} )`;switch(nt.getTransfer(e)){case of:return[t,"LinearTransferOETF"];case Rt:return[t,"sRGBTransferOETF"];default:return ze("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function tb(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+`
-
-`+KC(e.getShaderSource(t),a)}else return s}function eI(e,t){let n=QC(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var tI={[pd]:"Linear",[md]:"Reinhard",[gd]:"Cineon",[ba]:"ACESFilmic",[xd]:"AgX",[vd]:"Neutral",[_d]:"Custom"};function nI(e,t){let n=tI[t];if(n===void 0)return ze("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var eu=new F;function iI(){nt.getLuminanceCoefficients(eu);let e=eu.x.toFixed(4),t=eu.y.toFixed(4),n=eu.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function rI(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ha).join(`
-`)}function sI(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 oI(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 nb(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 ib(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var aI=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ff(e){return e.replace(aI,lI)}var cI=new Map;function lI(e,t){let n=et[t];if(n===void 0){let i=cI.get(t);if(i!==void 0)n=et[i],ze('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Ff(n)}var uI=/#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 rb(e){return e.replace(uI,hI)}function hI(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 sb(e){let t=`precision ${e.precision} float;
- precision ${e.precision} int;
- precision ${e.precision} sampler2D;
- precision ${e.precision} samplerCube;
- precision ${e.precision} sampler3D;
- precision ${e.precision} sampler2DArray;
- precision ${e.precision} sampler2DShadow;
- precision ${e.precision} samplerCubeShadow;
- precision ${e.precision} sampler2DArrayShadow;
- precision ${e.precision} isampler2D;
- precision ${e.precision} isampler3D;
- precision ${e.precision} isamplerCube;
- precision ${e.precision} isampler2DArray;
- precision ${e.precision} usampler2D;
- precision ${e.precision} usampler3D;
- precision ${e.precision} usamplerCube;
- precision ${e.precision} usampler2DArray;
- `;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 dI={[va]:"SHADOWMAP_TYPE_PCF",[to]:"SHADOWMAP_TYPE_VSM"};function fI(e){return dI[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var pI={[io]:"ENVMAP_TYPE_CUBE",[cs]:"ENVMAP_TYPE_CUBE",[Sa]:"ENVMAP_TYPE_CUBE_UV"};function mI(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return pI[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var gI={[cs]:"ENVMAP_MODE_REFRACTION"};function _I(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return gI[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var xI={[fy]:"ENVMAP_BLENDING_MULTIPLY",[py]:"ENVMAP_BLENDING_MIX",[my]:"ENVMAP_BLENDING_ADD"};function vI(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return xI[e.combine]||"ENVMAP_BLENDING_NONE"}function yI(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 bI(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=fI(n),l=mI(n),u=_I(n),h=vI(n),d=yI(n),f=rI(n),m=sI(s),_=r.createProgram(),p,g,y=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(Ha).join(`
-`),g.length>0)g+=`
-`}else p=[sb(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=[sb(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!==ui?"#define TONE_MAPPING":"",n.toneMapping!==ui?et.tonemapping_pars_fragment:"",n.toneMapping!==ui?nI("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",et.colorspace_pars_fragment,eI("linearToOutputTexel",n.outputColorSpace),iI(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
-`].filter(Ha).join(`
-`);if(o=Ff(o),o=nb(o,n),o=ib(o,n),a=Ff(a),a=nb(a,n),a=ib(a,n),o=rb(o),a=rb(a),n.isRawShaderMaterial!==!0)y=`#version 300 es
-`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
+ `},i=new ms(5,5,5),r=new _i({name:"CubemapFromEquirect",uniforms:va(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pn,blending:lr});r.uniforms.tEquirect.value=t;let s=new jt(i,r),a=t.minFilter;if(t.minFilter===ur)t.minFilter=En;return new Rm(1,10,this).update(e,s),t.minFilter=a,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)}};zk={[_p]:"LINEAR_TONE_MAPPING",[vp]:"REINHARD_TONE_MAPPING",[Ep]:"CINEON_TONE_MAPPING",[Lc]:"ACES_FILMIC_TONE_MAPPING",[Ap]:"AGX_TONE_MAPPING",[Sp]:"NEUTRAL_TONE_MAPPING",[Tp]:"CUSTOM_TONE_MAPPING"};rA=new Qt,Hm=new _a(1,1),sA=new ad,aA=new bm,oA=new hd,BT=[],zT=[],VT=new Float32Array(16),jT=new Float32Array(9),HT=new Float32Array(4);Vm=/(\w+)(\])?(\[|\.)?/g;KT=new tt;kD={[_p]:"Linear",[vp]:"Reinhard",[Ep]:"Cineon",[Lc]:"ACESFilmic",[Ap]:"AgX",[Sp]:"Neutral",[Tp]:"Custom"};Sd=new j;zD=/^[ \t]*#include +<([\w\d./]+)>/gm;VD=new Map;HD=/#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;$D={[kc]:"SHADOWMAP_TYPE_PCF",[go]:"SHADOWMAP_TYPE_VSM"};WD={[yo]:"ENVMAP_TYPE_CUBE",[pa]:"ENVMAP_TYPE_CUBE",[Fc]:"ENVMAP_TYPE_CUBE_UV"};qD={[pa]:"ENVMAP_MODE_REFRACTION"};ZD={[sT]:"ENVMAP_BLENDING_MULTIPLY",[aT]:"ENVMAP_BLENDING_MIX",[oT]:"ENVMAP_BLENDING_ADD"};mL=[new j(1,0,0),new j(-1,0,0),new j(0,1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1)],gL=[new j(0,-1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1),new j(0,-1,0),new j(0,-1,0)],tA=new Qe,nl=new j,jm=new j;pA=class pA extends Bi{constructor(e,t){super();let n=this,i=null,r=1,s=null,a="local-floor",o=1,c=null,l=null,u=null,d=null,f=null,h=null,y=typeof XRWebGLBinding<"u",g=new hA,m={},p=t.getContextAttributes(),b=null,_=null,x=[],v=[],E=new Ke,S=null,T=null,A=new fn;A.viewport=new Nt;let P=new fn;P.viewport=new Nt;let w=[A,P],I=new Im,F=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let L=x[J];if(L===void 0)L=new jc,x[J]=L;return L.getTargetRaySpace()},this.getControllerGrip=function(J){let L=x[J];if(L===void 0)L=new jc,x[J]=L;return L.getGripSpace()},this.getHand=function(J){let L=x[J];if(L===void 0)L=new jc,x[J]=L;return L.getHandSpace()};function U(J){let L=v.indexOf(J.inputSource);if(L===-1)return;let W=x[L];if(W!==void 0)W.update(J.inputSource,J.frame,c||s),W.dispatchEvent({type:J.type,data:J.inputSource})}function D(){i.removeEventListener("select",U),i.removeEventListener("selectstart",U),i.removeEventListener("selectend",U),i.removeEventListener("squeeze",U),i.removeEventListener("squeezestart",U),i.removeEventListener("squeezeend",U),i.removeEventListener("end",D),i.removeEventListener("inputsourceschange",O);for(let J=0;J<x.length;J++){let L=v[J];if(L===null)continue;v[J]=null,x[J].disconnect(L)}F=null,N=null,g.reset();for(let J in m)delete m[J];if(e.setRenderTarget(b),f=null,d=null,u=null,i=null,_=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(S),e.setSize(E.width,E.height,!1),T!==null){let J=T.camera;J.fov=T.fov,J.zoom=T.zoom,J.updateProjectionMatrix(),T=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){if(r=J,n.isPresenting===!0)je("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){if(a=J,n.isPresenting===!0)je("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){if(u===null&&y)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return h},this.getSession=function(){return i},this.setSession=async function(J){if(i=J,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",U),i.addEventListener("selectstart",U),i.addEventListener("selectend",U),i.addEventListener("squeeze",U),i.addEventListener("squeezestart",U),i.addEventListener("squeezeend",U),i.addEventListener("end",D),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0)await t.makeXRCompatible();if(S=e.getPixelRatio(),e.getSize(E),!(y&&("createProjectionLayer"in XRWebGLBinding.prototype))){let W={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,W),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new ai(f.framebufferWidth,f.framebufferHeight,{format:fr,type:Ui,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}else{let W=null,te=null,ie=null;if(p.depth)ie=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,W=p.stencil?ba:ga,te=p.stencil?Eo:ds;let ce={colorFormat:t.RGBA8,depthFormat:ie,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(ce),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new ai(d.textureWidth,d.textureHeight,{format:fr,type:Ui,depthTexture:new _a(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,W),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(o),c=null,s=await i.requestReferenceSpace(a),pe.setContext(i),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function O(J){for(let L=0;L<J.removed.length;L++){let W=J.removed[L],te=v.indexOf(W);if(te>=0)v[te]=null,x[te].disconnect(W)}for(let L=0;L<J.added.length;L++){let W=J.added[L],te=v.indexOf(W);if(te===-1){for(let ce=0;ce<x.length;ce++)if(ce>=v.length){v.push(W),te=ce;break}else if(v[ce]===null){v[ce]=W,te=ce;break}if(te===-1)break}let ie=x[te];if(ie)ie.connect(W)}}let K=new j,B=new j;function X(J,L,W){K.setFromMatrixPosition(L.matrixWorld),B.setFromMatrixPosition(W.matrixWorld);let te=K.distanceTo(B),ie=L.projectionMatrix.elements,ce=W.projectionMatrix.elements,_e=ie[14]/(ie[10]-1),Re=ie[14]/(ie[10]+1),Oe=(ie[9]+1)/ie[5],We=(ie[9]-1)/ie[5],Ye=(ie[8]-1)/ie[0],Kt=(ce[8]+1)/ce[0],lt=_e*Ye,Dt=_e*Kt,Yt=te/(-Ye+Kt),tn=Yt*-Ye;if(L.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(tn),J.translateZ(Yt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ie[10]===-1)J.projectionMatrix.copy(L.projectionMatrix),J.projectionMatrixInverse.copy(L.projectionMatrixInverse);else{let z=_e+Yt,xn=Re+Yt,St=lt-tn,Wt=Dt+(te-tn),C=Oe*Re/xn*z,M=We*Re/xn*z;J.projectionMatrix.makePerspective(St,Wt,C,M,z,xn),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,L){if(L===null)J.matrixWorld.copy(J.matrix);else J.matrixWorld.multiplyMatrices(L.matrixWorld,J.matrix);J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;let{near:L,far:W}=J;if(g.texture!==null){if(g.depthNear>0)L=g.depthNear;if(g.depthFar>0)W=g.depthFar}if(I.near=P.near=A.near=L,I.far=P.far=A.far=W,F!==I.near||N!==I.far)i.updateRenderState({depthNear:I.near,depthFar:I.far}),F=I.near,N=I.far;I.layers.mask=J.layers.mask|6,A.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;let te=J.parent,ie=I.cameras;q(I,te);for(let ce=0;ce<ie.length;ce++)q(ie[ce],te);if(ie.length===2)X(I,A,P);else I.projectionMatrix.copy(A.projectionMatrix);if(T===null&&J.isPerspectiveCamera)T={camera:J,fov:J.fov,zoom:J.zoom};le(J,I,te)};function le(J,L,W){if(W===null)J.matrix.copy(L.matrixWorld);else J.matrix.copy(W.matrixWorld),J.matrix.invert(),J.matrix.multiply(L.matrixWorld);if(J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(L.projectionMatrix),J.projectionMatrixInverse.copy(L.projectionMatrixInverse),J.isPerspectiveCamera)J.fov=ha*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1}this.getCamera=function(){return I},this.getFoveation=function(){if(d===null&&f===null)return;return o},this.setFoveation=function(J){if(o=J,d!==null)d.fixedFoveation=J;if(f!==null&&f.fixedFoveation!==void 0)f.fixedFoveation=J},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function(J){return m[J]};let de=null;function Me(J,L){if(l=L.getViewerPose(c||s),h=L,l!==null){let W=l.views;if(f!==null)e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_);let te=!1;if(W.length!==I.cameras.length)I.cameras.length=0,te=!0;for(let Re=0;Re<W.length;Re++){let Oe=W[Re],We=null;if(f!==null)We=f.getViewport(Oe);else{let Kt=u.getViewSubImage(d,Oe);if(We=Kt.viewport,Re===0)e.setRenderTargetTextures(_,Kt.colorTexture,Kt.depthStencilTexture),e.setRenderTarget(_)}let Ye=w[Re];if(Ye===void 0)Ye=new fn,Ye.layers.enable(Re),Ye.viewport=new Nt,w[Re]=Ye;if(Ye.matrix.fromArray(Oe.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Oe.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(We.x,We.y,We.width,We.height),Re===0)I.matrix.copy(Ye.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale);if(te===!0)I.cameras.push(Ye)}let ie=i.enabledFeatures;if(ie&&ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){u=n.getBinding();let Re=u.getDepthInformation(W[0]);if(Re&&Re.isValid&&Re.texture)g.init(Re,i.renderState)}if(ie&&ie.includes("camera-access")&&y){e.state.unbindTexture(),u=n.getBinding();for(let Re=0;Re<W.length;Re++){let Oe=W[Re].camera;if(Oe){let We=m[Oe];if(!We)We=new pd,m[Oe]=We;let Ye=u.getCameraImage(Oe);We.sourceTexture=Ye}}}}for(let W=0;W<x.length;W++){let te=v[W],ie=x[W];if(te!==null&&ie!==void 0)ie.update(te,L,c||s)}if(de)de(J,L);if(L.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:L});h=null}let pe=new nA;pe.setAnimationLoop(Me),this.setAnimationLoop=function(J){de=J},this.dispose=function(){}}};TL=new Qe,mA=new tt;mA.set(-1,0,0,0,1,0,0,0,1);wL=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])});var lS=class{_listeners={};addEventListener(e,t){let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t);return this}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let i=n.indexOf(t);if(i!==-1)n.splice(i,1)}return this}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){let n=t.slice(0);for(let i=0,r=n.length;i<r;i++)n[i].call(this,e)}return this}dispose(){for(let e in this._listeners)delete this._listeners[e]}},As=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,n,i={}){if(this._name=e,this._parent=t,this._child=n,this._attributes=i,!t.isOnGraph(n))throw Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}},dg,bn=class{list=[];constructor(e){if(e)for(let t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){let t=this.list.indexOf(e);if(t>=0)this.list.splice(t,1)}removeChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);for(let n of t)this.remove(n);return t}listRefsByChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);return t}values(){return this.list}},Rt=class{set=new Set;map=new Map;constructor(e){if(e)for(let t of e)this.add(t)}add(e){let t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){let t=this.map.get(e)||null;if(t)this.remove(t);return t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},dn=class{map={};constructor(e){if(e)Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}},Tt,Ts,uS;var dS=Ft(()=>{dg=class extends lS{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){let t=new Set;for(let n of this.listParentEdges(e))t.add(n.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){let t=new Set;for(let n of this.listChildEdges(e))t.add(n.getChild());return Array.from(t)}disconnectParents(e,t){for(let n of this.listParentEdges(e))if(!t||t(n.getParent()))n.dispose();return this}_createEdge(e,t,n,i){let r=new As(e,t,n,i);this._edges.add(r);let s=r.getParent();if(!this._parentEdges.has(s))this._parentEdges.set(s,new Set);this._parentEdges.get(s).add(r);let a=r.getChild();if(!this._childEdges.has(a))this._childEdges.set(a,new Set);return this._childEdges.get(a).add(r),r}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},Tt=Symbol("attributes"),Ts=Symbol("immutableKeys"),uS=class e extends lS{_disposed=!1;graph;[Tt];[Ts];constructor(t){super();this.graph=t,this[Ts]=new Set,this[Tt]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let t=this.getDefaults(),n={};for(let i in t){let r=t[i];if(r instanceof e){let s=this.graph._createEdge(i,this,r);this[Ts].add(i),n[i]=s}else n[i]=r}return n}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((t)=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(t,n){for(let i in this[Tt]){let r=this[Tt][i];if(r instanceof As){let s=r;if(s.getChild()===t)this.setRef(i,n,s.getAttributes())}else if(r instanceof bn)for(let s of r.listRefsByChild(t)){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}else if(r instanceof Rt){let s=r.getRefByChild(t);if(s){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}}else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);if(a.getChild()===t)this.setRefMap(i,s,n,a.getAttributes())}}return this}get(t){return this[Tt][t]}set(t,n){return this[Tt][t]=n,this.dispatchEvent({type:"change",attribute:t})}getRef(t){let n=this[Tt][t];return n?n.getChild():null}setRef(t,n,i){if(this[Ts].has(t))throw Error(`Cannot overwrite immutable attribute, "${t}".`);let r=this[Tt][t];if(r)r.dispose();if(!n)return this;let s=this.graph._createEdge(t,this,n,i);return this[Tt][t]=s,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map((n)=>n.getChild())}addRef(t,n,i){let r=this.graph._createEdge(t,this,n,i);return this.assertRefList(t).add(r),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,n){let i=this.assertRefList(t);if(i instanceof bn)for(let r of i.listRefsByChild(n))r.dispose();else{let r=i.getRefByChild(n);if(r)r.dispose()}return this}assertRefList(t){let n=this[Tt][t];if(n instanceof bn||n instanceof Rt)return n;throw Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map((n)=>n.getChild())}getRefMap(t,n){let i=this.assertRefMap(t).get(n);return i?i.getChild():null}setRefMap(t,n,i,r){let s=this.assertRefMap(t),a=s.get(n);if(a)a.dispose();if(!i)return this;r=Object.assign(r||{},{key:n});let o=this.graph._createEdge(t,this,i,{...r,key:n});return s.set(n,o),this.dispatchEvent({type:"change",attribute:t,key:n})}assertRefMap(t){let n=this[Tt][t];if(n instanceof dn)return n;throw Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){let n=t.getName();if(this[Tt][n]===t){if(this[Tt][n]=null,this[Ts].has(n))t.getChild().dispose()}else if(this[Tt][n]instanceof bn)this[Tt][n].remove(t);else if(this[Tt][n]instanceof Rt)this[Tt][n].remove(t);else if(this[Tt][n]instanceof dn){let i=this[Tt][n];for(let r of i.keys())if(i.get(r)===t)i.delete(r)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:n})}}});function n8(e,t){if(t>e.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw TypeError("Invalid JPG, marker table corrupted");return e}function i8(){var e=new pg(3);if(pg!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function fg(e){var t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function r8(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function gg(e){let t=_S(),n=e.propertyType==="Node"?[e]:e.listChildren();for(let i of n)i.traverse((r)=>{let s=r.getMesh();if(!s)return;let a=s8(s,r.getWorldMatrix());if(a.min.every(isFinite)&&a.max.every(isFinite))mg(a.min,t),mg(a.max,t)});return t}function s8(e,t){let n=_S();for(let i of e.listPrimitives()){let r=i.getAttribute("POSITION"),s=i.getIndices();if(!r)continue;let a=[0,0,0],o=[0,0,0];for(let c=0,l=s?s.getCount():r.getCount();c<l;c++){let u=s?s.getScalar(c):c;a=r.getElement(u,a),o=r8(o,a,t),mg(o,n)}}return n}function mg(e,t){for(let n=0;n<3;n++)t.min[n]=Math.min(e[n],t.min[n]),t.max[n]=Math.max(e[n],t.max[n])}function _S(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}function hS(e){return Object.prototype.toString.call(e)==="[object Object]"}function wa(e){if(hS(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;if(hS(n)===!1)return!1;if(Object.hasOwn(n,"isPrototypeOf")===!1)return!1;return!0}function o8(e){var t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],y=e[13],g=e[14],m=e[15],p=t*a-n*s,b=t*o-i*s,_=n*o-i*a,x=l*y-u*h,v=l*g-d*h,E=u*g-d*y,S=t*E-n*v+i*x,T=s*E-a*v+o*x,A=l*_-u*b+d*p,P=h*_-y*b+g*p;return c*S-r*T+m*A-f*P}function c8(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],y=t[11],g=t[12],m=t[13],p=t[14],b=t[15],_=n[0],x=n[1],v=n[2],E=n[3];return e[0]=_*i+x*o+v*d+E*g,e[1]=_*r+x*c+v*f+E*m,e[2]=_*s+x*l+v*h+E*p,e[3]=_*a+x*u+v*y+E*b,_=n[4],x=n[5],v=n[6],E=n[7],e[4]=_*i+x*o+v*d+E*g,e[5]=_*r+x*c+v*f+E*m,e[6]=_*s+x*l+v*h+E*p,e[7]=_*a+x*u+v*y+E*b,_=n[8],x=n[9],v=n[10],E=n[11],e[8]=_*i+x*o+v*d+E*g,e[9]=_*r+x*c+v*f+E*m,e[10]=_*s+x*l+v*h+E*p,e[11]=_*a+x*u+v*y+E*b,_=n[12],x=n[13],v=n[14],E=n[15],e[12]=_*i+x*o+v*d+E*g,e[13]=_*r+x*c+v*f+E*m,e[14]=_*s+x*l+v*h+E*p,e[15]=_*a+x*u+v*y+E*b,e}function l8(e,t){var n=t[0],i=t[1],r=t[2],s=t[4],a=t[5],o=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(s*s+a*a+o*o),e[2]=Math.sqrt(c*c+l*l+u*u),e}function u8(e,t){var n=new pg(3);l8(n,t);var i=1/n[0],r=1/n[1],s=1/n[2],a=t[0]*i,o=t[1]*r,c=t[2]*s,l=t[4]*i,u=t[5]*r,d=t[6]*s,f=t[8]*i,h=t[9]*r,y=t[10]*s,g=a+u+y,m=0;if(g>0)m=Math.sqrt(g+1)*2,e[3]=0.25*m,e[0]=(d-h)/m,e[1]=(f-c)/m,e[2]=(o-l)/m;else if(a>u&&a>y)m=Math.sqrt(1+a-u-y)*2,e[3]=(d-h)/m,e[0]=0.25*m,e[1]=(o+l)/m,e[2]=(f+c)/m;else if(u>y)m=Math.sqrt(1+u-a-y)*2,e[3]=(f-c)/m,e[0]=(o+l)/m,e[1]=0.25*m,e[2]=(d+h)/m;else m=Math.sqrt(1+y-a-u)*2,e[3]=(o-l)/m,e[0]=(f+c)/m,e[1]=(d+h)/m,e[2]=0.25*m;return e}function d8(e,t){if(!!e!==!!t)return!1;let n=e.getChild(),i=t.getChild();return n===i||n.equals(i)}function f8(e,t){if(!!e!==!!t)return!1;let n=e.values(),i=t.values();if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++){let s=n[r],a=i[r];if(s.getChild()===a.getChild())continue;if(!s.getChild().equals(a.getChild()))return!1}return!0}function h8(e,t){if(!!e!==!!t)return!1;let n=e.keys(),i=t.keys();if(n.length!==i.length)return!1;for(let r of n){let s=e.get(r),a=t.get(r);if(!!s!==!!a)return!1;let o=s.getChild(),c=a.getChild();if(o===c)continue;if(!o.equals(c))return!1}return!0}function vS(e,t){if(e===t)return!0;if(!!e!==!!t||!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ES(e,t){if(e===t)return!0;if(!!e!==!!t)return!1;if(!wa(e)||!wa(t))return e===t;let n=e,i=t,r=0,s=0,a;for(a in n)r++;for(a in i)s++;if(r!==s)return!1;for(a in n){let o=n[a],c=i[a];if(Ld(o)&&Ld(c)){if(!vS(o,c))return!1}else if(wa(o)&&wa(c)){if(!ES(o,c))return!1}else if(o!==c)return!1}return!0}function Ld(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function x8(e){switch(e.constructor){case Float32Array:return Be.ComponentType.FLOAT;case Uint32Array:return Be.ComponentType.UNSIGNED_INT;case Uint16Array:return Be.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Be.ComponentType.UNSIGNED_BYTE;case Int16Array:return Be.ComponentType.SHORT;case Int8Array:return Be.ComponentType.BYTE;case Float64Array:return Be.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return Be.ComponentType.FLOAT16;throw Error("Unknown accessor componentType.")}function A8(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=ul[e.componentType],a=Be.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new s(e.count*a),u=new DataView(i.buffer,i.byteOffset,i.byteLength),d=r.byteStride;for(let f=0;f<e.count;f++)for(let h=0;h<a;h++){let y=c+f*d+h*o,g;switch(e.componentType){case Be.ComponentType.FLOAT:g=u.getFloat32(y,!0);break;case Be.ComponentType.UNSIGNED_INT:g=u.getUint32(y,!0);break;case Be.ComponentType.UNSIGNED_SHORT:g=u.getUint16(y,!0);break;case Be.ComponentType.UNSIGNED_BYTE:g=u.getUint8(y);break;case Be.ComponentType.SHORT:g=u.getInt16(y,!0);break;case Be.ComponentType.BYTE:g=u.getInt8(y);break;case Be.ComponentType.FLOAT16:g=u.getFloat16(y,!0);break;case Be.ComponentType.FLOAT64:g=u.getFloat64(y,!0);break;default:throw Error(`Unexpected componentType "${e.componentType}".`)}l[f*a+h]=g}return l}function Dd(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=ul[e.componentType],a=Be.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=a*o;if(r.byteStride!==void 0&&r.byteStride!==c)return A8(e,t);let l=i.byteOffset+(e.byteOffset||0),u=e.count*a*o;return new s(i.buffer.slice(l,l+u))}function S8(e,t){let n=ul[e.componentType],i=Be.getElementSize(e.type),r;if(e.bufferView!==void 0)r=Dd(e,t);else r=new n(e.count*i);let s=e.sparse;if(!s)return r;let a=s.count,o={...e,...s.indices,count:a,type:"SCALAR"},c={...e,...s.values,count:a},l=Dd(o,t),u=Dd(c,t);for(let d=0;d<o.count;d++)for(let f=0;f<i;f++)r[l[d]*i+f]=u[d*i+f];return r}function w8(e,t){let n=e.getGraph().listParentEdges(t).find((i)=>i.getParent()!==e.getRoot());return n?n.getName().replace(/texture$/i,""):""}function P8(e){let t=[];for(let n in e){let i=e[n];if(Array.isArray(i)&&i.length===0)t.push(n);else if(i===null||i==="")t.push(n);else if(i&&typeof i==="object"&&Object.keys(i).length===0)t.push(n)}for(let n of t)delete e[n]}function k8(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function D8(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function bS(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var yS="v4.5.1",ws="@glb.bin",ne,YL,Ei,QL,ul,Je=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){let t=atob(e.split(",")[1]),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}else{let t=e.split(",")[1],n=e.indexOf("base64")>=0;return Buffer.from(t,n?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(let r of e)t+=r.byteLength;let n=new Uint8Array(t),i=0;for(let r of e)n.set(r,i),i+=r.byteLength;return n}static pad(e,t=0){let n=this.padNumber(e.byteLength);if(n===e.byteLength)return e;let i=new Uint8Array(n);if(i.set(e),t!==0)for(let r=e.byteLength;r<n;r++)i[r]=t;return i}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let n=e.byteLength;while(n--)if(e[n]!==t[n])return!1;return!0}static toView(e,t=0,n=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,n))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},xS=class{static hexToFactor(e,t){e=Math.floor(e);let n=t;return n[0]=(e>>16&255)/255,n[1]=(e>>8&255)/255,n[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){let t=[...e],[n,i,r]=this.convertLinearToSRGB(e,t);return n*255<<16^i*255<<8^r*255<<0}static convertSRGBToLinear(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.04045?n[r]*0.0773993808:Math.pow(n[r]*0.9478672986+0.0521327014,2.4);return t}static convertLinearToSRGB(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.0031308?n[r]*12.92:1.055*Math.pow(n[r],0.41666)-0.055;return t}},e8=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),n,i;while(t.byteLength){if(n=t.getUint16(0,!1),n8(t,n),i=t.getUint8(n+1),i===192||i===193||i===194)return[t.getUint16(n+7,!1),t.getUint16(n+5,!1)];t=new DataView(e.buffer,t.byteOffset+n+2)}throw TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},t8=class e{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){let n=new DataView(t.buffer,t.byteOffset);if(Je.decodeText(t.slice(12,16))===e.PNG_FRIED_CHUNK_NAME)return[n.getUint32(32,!1),n.getUint32(36,!1)];return[n.getUint32(16,!1),n.getUint32(20,!1)]}getChannels(t){return 4}},ji,Ma=class{static basename(e){let t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){let t=e.match(/data:(image\/\w+)/)[1];return ji.mimeTypeToExtension(t)}else if(e.startsWith("data:model/gltf+json"))return"gltf";else if(e.startsWith("data:model/gltf-binary"))return"glb";else if(e.startsWith("data:application/"))return"bin";return e.split(/[\\/]/).pop().split(/[.]/).pop()}},pg,fS="https://null.example",hg,a8,Ia,pt=class e{static identity(t){return t}static eq(t,n,i=0.00001){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(Math.abs(t[r]-n[r])>i)return!1;return!0}static clamp(t,n,i){if(t<n)return n;if(t>i)return i;return t}static decodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}static encodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return Math.round(e.clamp(t,0,1)*65535);case 5121:return Math.round(e.clamp(t,0,1)*255);case 5122:return Math.round(e.clamp(t,-1,1)*32767);case 5120:return Math.round(e.clamp(t,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(t,n,i,r){let s=fg([t[0],t[1],t[2]]),a=fg([t[4],t[5],t[6]]),o=fg([t[8],t[9],t[10]]);if(o8(t)<0)s=-s;n[0]=t[12],n[1]=t[13],n[2]=t[14];let c=t.slice(),l=1/s,u=1/a,d=1/o;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=d,c[9]*=d,c[10]*=d,u8(i,c),r[0]=s,r[1]=a,r[2]=o}static compose(t,n,i,r){let s=r,a=n[0],o=n[1],c=n[2],l=n[3],u=a+a,d=o+o,f=c+c,h=a*u,y=a*d,g=a*f,m=o*d,p=o*f,b=c*f,_=l*u,x=l*d,v=l*f,E=i[0],S=i[1],T=i[2];return s[0]=(1-(m+b))*E,s[1]=(y+v)*E,s[2]=(g-x)*E,s[3]=0,s[4]=(y-v)*S,s[5]=(1-(h+b))*S,s[6]=(p+_)*S,s[7]=0,s[8]=(g+x)*T,s[9]=(p-_)*T,s[10]=(1-(h+m))*T,s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=1,s}},p8="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",m8=999,g8=6,pS,b8=function(){let e="";for(let t=0;t<g8;t++)e+=p8.charAt(Math.floor(Math.random()*42));return e},TS=function(){for(let e=0;e<m8;e++){let t=b8();if(!pS.has(t))return pS.add(t),t}return""},Ms=(e)=>e,y8,bg,jn,Be,AS,Ca,dl,SS,Fd,nt,At,Nd,Pd,Od,_8,Ra,yg,Ud,Wn,xg,Bd,wS,zo,Rs,zd,xt=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=(n)=>{let i=n,r=i.target;if(r instanceof nt&&r.extensionName===this.extensionName){if(i.type==="node:create")this._addExtensionProperty(r);if(i.type==="node:dispose")this._removeExtensionProperty(r)}};let t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(let t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},v8=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){if(this.textureInfos.set(e,t),t.texCoord!==void 0)e.setTexCoord(t.texCoord);if(t.extras!==void 0)e.setExtras(t.extras);let n=this.jsonDoc.json.textures[t.index];if(n.sampler===void 0)return;let i=this.jsonDoc.json.samplers[n.sampler];if(i.magFilter!==void 0)e.setMagFilter(i.magFilter);if(i.minFilter!==void 0)e.setMinFilter(i.minFilter);if(i.wrapS!==void 0)e.setWrapS(i.wrapS);if(i.wrapT!==void 0)e.setWrapT(i.wrapT)}},mS,E8,T8=class{static read(e,t=mS){let n={...mS,...t},{json:i}=e,r=new zd().setLogger(n.logger);this.validate(e,n);let s=new v8(e),a=i.asset,o=r.getRoot().getAsset();if(a.copyright)o.copyright=a.copyright;if(a.extras)o.extras=a.extras;if(i.extras!==void 0)r.getRoot().setExtras({...i.extras});let c=i.extensionsUsed||[],l=i.extensionsRequired||[];n.extensions.sort((p,b)=>p.EXTENSION_NAME>b.EXTENSION_NAME?1:-1);for(let p of n.extensions)if(c.includes(p.EXTENSION_NAME)){let b=r.createExtension(p).setRequired(l.includes(p.EXTENSION_NAME)),_=b.prereadTypes.filter((x)=>!E8.has(x));if(_.length)n.logger.warn(`Preread hooks for some types (${_.join()}), requested by extension ${b.extensionName}, are unsupported. Please file an issue or a PR.`);for(let x of b.readDependencies)b.install(x,n.dependencies[x])}let u=i.buffers||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Buffer")).forEach((p)=>p.preread(s,"Buffer")),s.buffers=u.map((p)=>{let b=r.createBuffer(p.name);if(p.extras)b.setExtras(p.extras);if(p.uri&&p.uri.indexOf("__")!==0)b.setURI(p.uri);return b}),s.bufferViewBuffers=(i.bufferViews||[]).map((p,b)=>{if(!s.bufferViews[b]){let _=e.json.buffers[p.buffer],x=_.uri?e.resources[_.uri]:e.resources[ws],v=p.byteOffset||0;s.bufferViews[b]=Je.toView(x,v,p.byteLength)}return s.buffers[p.buffer]});let d=i.accessors||[];s.accessors=d.map((p)=>{let b=s.bufferViewBuffers[p.bufferView],_=r.createAccessor(p.name,b).setType(p.type);if(p.extras)_.setExtras(p.extras);if(p.normalized!==void 0)_.setNormalized(p.normalized);if(p.bufferView===void 0)return _;return _.setArray(Dd(p,s)),_});let f=i.images||[],h=i.textures||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Texture")).forEach((p)=>p.preread(s,"Texture")),s.textures=f.map((p)=>{let b=r.createTexture(p.name);if(p.extras)b.setExtras(p.extras);if(p.bufferView!==void 0){let _=i.bufferViews[p.bufferView],x=e.json.buffers[_.buffer],v=x.uri?e.resources[x.uri]:e.resources[ws],E=_.byteOffset||0,S=_.byteLength,T=v.slice(E,E+S);b.setImage(T)}else if(p.uri!==void 0){if(b.setImage(e.resources[p.uri]),p.uri.indexOf("__")!==0)b.setURI(p.uri)}if(p.mimeType!==void 0)b.setMimeType(p.mimeType);else if(p.uri){let _=Ma.extension(p.uri);b.setMimeType(ji.extensionToMimeType(_))}return b}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Material")).forEach((p)=>p.preread(s,"Material")),s.materials=(i.materials||[]).map((p)=>{let b=r.createMaterial(p.name);if(p.extras)b.setExtras(p.extras);if(p.alphaMode!==void 0)b.setAlphaMode(p.alphaMode);if(p.alphaCutoff!==void 0)b.setAlphaCutoff(p.alphaCutoff);if(p.doubleSided!==void 0)b.setDoubleSided(p.doubleSided);let _=p.pbrMetallicRoughness||{};if(_.baseColorFactor!==void 0)b.setBaseColorFactor(_.baseColorFactor);if(p.emissiveFactor!==void 0)b.setEmissiveFactor(p.emissiveFactor);if(_.metallicFactor!==void 0)b.setMetallicFactor(_.metallicFactor);if(_.roughnessFactor!==void 0)b.setRoughnessFactor(_.roughnessFactor);if(_.baseColorTexture!==void 0){let x=_.baseColorTexture,v=s.textures[h[x.index].source];b.setBaseColorTexture(v),s.setTextureInfo(b.getBaseColorTextureInfo(),x)}if(p.emissiveTexture!==void 0){let x=p.emissiveTexture,v=s.textures[h[x.index].source];b.setEmissiveTexture(v),s.setTextureInfo(b.getEmissiveTextureInfo(),x)}if(p.normalTexture!==void 0){let x=p.normalTexture,v=s.textures[h[x.index].source];if(b.setNormalTexture(v),s.setTextureInfo(b.getNormalTextureInfo(),x),p.normalTexture.scale!==void 0)b.setNormalScale(p.normalTexture.scale)}if(p.occlusionTexture!==void 0){let x=p.occlusionTexture,v=s.textures[h[x.index].source];if(b.setOcclusionTexture(v),s.setTextureInfo(b.getOcclusionTextureInfo(),x),p.occlusionTexture.strength!==void 0)b.setOcclusionStrength(p.occlusionTexture.strength)}if(_.metallicRoughnessTexture!==void 0){let x=_.metallicRoughnessTexture,v=s.textures[h[x.index].source];b.setMetallicRoughnessTexture(v),s.setTextureInfo(b.getMetallicRoughnessTextureInfo(),x)}return b}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Mesh")).forEach((p)=>p.preread(s,"Mesh"));let y=i.meshes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Primitive")).forEach((p)=>p.preread(s,"Primitive")),s.meshes=y.map((p)=>{let b=r.createMesh(p.name);if(p.extras)b.setExtras(p.extras);if(p.weights!==void 0)b.setWeights(p.weights);return(p.primitives||[]).forEach((_)=>{let x=r.createPrimitive();if(_.extras)x.setExtras(_.extras);if(_.material!==void 0)x.setMaterial(s.materials[_.material]);if(_.mode!==void 0)x.setMode(_.mode);for(let[E,S]of Object.entries(_.attributes||{}))x.setAttribute(E,s.accessors[S]);if(_.indices!==void 0)x.setIndices(s.accessors[_.indices]);let v=p.extras&&p.extras.targetNames||[];(_.targets||[]).forEach((E,S)=>{let T=v[S]||S.toString(),A=r.createPrimitiveTarget(T);for(let[P,w]of Object.entries(E))A.setAttribute(P,s.accessors[w]);x.addTarget(A)}),b.addPrimitive(x)}),b}),s.cameras=(i.cameras||[]).map((p)=>{let b=r.createCamera(p.name).setType(p.type);if(p.extras)b.setExtras(p.extras);if(p.type===Fd.Type.PERSPECTIVE){let _=p.perspective;if(b.setYFov(_.yfov),b.setZNear(_.znear),_.zfar!==void 0)b.setZFar(_.zfar);if(_.aspectRatio!==void 0)b.setAspectRatio(_.aspectRatio)}else{let _=p.orthographic;b.setZNear(_.znear).setZFar(_.zfar).setXMag(_.xmag).setYMag(_.ymag)}return b});let g=i.nodes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Node")).forEach((p)=>p.preread(s,"Node")),s.nodes=g.map((p)=>{let b=r.createNode(p.name);if(p.extras)b.setExtras(p.extras);if(p.translation!==void 0)b.setTranslation(p.translation);if(p.rotation!==void 0)b.setRotation(p.rotation);if(p.scale!==void 0)b.setScale(p.scale);if(p.matrix!==void 0){let _=[0,0,0],x=[0,0,0,1],v=[1,1,1];pt.decompose(p.matrix,_,x,v),b.setTranslation(_),b.setRotation(x),b.setScale(v)}if(p.weights!==void 0)b.setWeights(p.weights);return b}),s.skins=(i.skins||[]).map((p)=>{let b=r.createSkin(p.name);if(p.extras)b.setExtras(p.extras);if(p.inverseBindMatrices!==void 0)b.setInverseBindMatrices(s.accessors[p.inverseBindMatrices]);if(p.skeleton!==void 0)b.setSkeleton(s.nodes[p.skeleton]);for(let _ of p.joints)b.addJoint(s.nodes[_]);return b}),g.map((p,b)=>{let _=s.nodes[b];if((p.children||[]).forEach((x)=>_.addChild(s.nodes[x])),p.mesh!==void 0)_.setMesh(s.meshes[p.mesh]);if(p.camera!==void 0)_.setCamera(s.cameras[p.camera]);if(p.skin!==void 0)_.setSkin(s.skins[p.skin])}),s.animations=(i.animations||[]).map((p)=>{let b=r.createAnimation(p.name);if(p.extras)b.setExtras(p.extras);let _=(p.samplers||[]).map((x)=>{let v=r.createAnimationSampler().setInput(s.accessors[x.input]).setOutput(s.accessors[x.output]).setInterpolation(x.interpolation||dl.Interpolation.LINEAR);if(x.extras)v.setExtras(x.extras);return b.addSampler(v),v});return(p.channels||[]).forEach((x)=>{let v=r.createAnimationChannel().setSampler(_[x.sampler]).setTargetPath(x.target.path);if(x.target.node!==void 0)v.setTargetNode(s.nodes[x.target.node]);if(x.extras)v.setExtras(x.extras);b.addChannel(v)}),b});let m=i.scenes||[];if(r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Scene")).forEach((p)=>p.preread(s,"Scene")),s.scenes=m.map((p)=>{let b=r.createScene(p.name);if(p.extras)b.setExtras(p.extras);return(p.nodes||[]).map((_)=>s.nodes[_]).forEach((_)=>b.addChild(_)),b}),i.scene!==void 0)r.getRoot().setDefaultScene(s.scenes[i.scene]);return r.getRoot().listExtensionsUsed().forEach((p)=>p.read(s)),d.forEach((p,b)=>{let _=s.accessors[b],x=!!p.sparse,v=!p.bufferView&&!_.getArray();if(x||v)_.setSparse(!0).setArray(S8(p,s))}),r}static validate(e,t){let n=e.json;if(n.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${n.asset.version}".`);if(n.extensionsRequired){for(let i of n.extensionsRequired)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))throw Error(`Missing required extension, "${i}".`)}if(n.extensionsUsed){for(let i of n.extensionsUsed)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))t.logger.warn(`Missing optional extension, "${i}".`)}}},MS,Ss,gS=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();else if(!this.multiple)return`${this.basename(e)}.${t}`;else{let n=this.basename(e);return this.counter[n]=this.counter[n]||1,`${n}_${this.counter[n]++}.${t}`}}},kd,M8,R8,I8,C8,N8=class{static write(e,t){let n=e.getGraph(),i=e.getRoot(),r={asset:{generator:`glTF-Transform ${yS}`,...i.getAsset()},extras:{...i.getExtras()}},s={json:r,resources:{}},a=new Ss(e,s,t),o=t.logger||Ia.DEFAULT_INSTANCE,c=new Set(t.extensions.map((g)=>g.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter((g)=>c.has(g.extensionName)).sort((g,m)=>g.extensionName>m.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter((g)=>c.has(g.extensionName)).sort((g,m)=>g.extensionName>m.extensionName?1:-1);if(l.length<e.getRoot().listExtensionsUsed().length)o.warn("Some extensions were not registered for I/O, and will not be written.");for(let g of l){let m=g.prewriteTypes.filter((p)=>!C8.has(p));if(m.length)o.warn(`Prewrite hooks for some types (${m.join()}), requested by extension ${g.extensionName}, are unsupported. Please file an issue or a PR.`);for(let p of g.writeDependencies)g.install(p,t.dependencies[p])}function d(g,m,p,b){let _=[],x=0;for(let E of g){let S=a.createAccessorDef(E);S.bufferView=r.bufferViews.length;let T=E.getArray(),A=Je.pad(Je.toView(T));S.byteOffset=x,x+=A.byteLength,_.push(A),a.accessorIndexMap.set(E,r.accessors.length),r.accessors.push(S)}let v={buffer:m,byteOffset:p,byteLength:Je.concat(_).byteLength};if(b)v.target=b;return r.bufferViews.push(v),{buffers:_,byteLength:x}}function f(g,m,p){let b=g[0].getCount(),_=0;for(let T of g){let A=a.createAccessorDef(T);A.bufferView=r.bufferViews.length,A.byteOffset=_;let P=T.getElementSize(),w=T.getComponentSize();_+=Je.padNumber(P*w),a.accessorIndexMap.set(T,r.accessors.length),r.accessors.push(A)}let x=b*_,v=new ArrayBuffer(x),E=new DataView(v);for(let T=0;T<b;T++){let A=0;for(let P of g){let w=P.getElementSize(),I=P.getComponentSize(),F=P.getComponentType(),N=P.getArray();for(let U=0;U<w;U++){let D=T*_+A+U*I,O=N[T*w+U];switch(F){case Be.ComponentType.FLOAT:E.setFloat32(D,O,!0);break;case Be.ComponentType.BYTE:E.setInt8(D,O);break;case Be.ComponentType.SHORT:E.setInt16(D,O,!0);break;case Be.ComponentType.UNSIGNED_BYTE:E.setUint8(D,O);break;case Be.ComponentType.UNSIGNED_SHORT:E.setUint16(D,O,!0);break;case Be.ComponentType.UNSIGNED_INT:E.setUint32(D,O,!0);break;case Be.ComponentType.FLOAT16:E.setFloat16(D,O,!0);break;case Be.ComponentType.FLOAT64:E.setFloat64(D,O,!0);break;default:throw Error("Unexpected component type: "+F)}}A+=Je.padNumber(w*I)}}let S={buffer:m,byteOffset:p,byteLength:x,byteStride:_,target:Ss.BufferViewTarget.ARRAY_BUFFER};return r.bufferViews.push(S),{byteLength:x,buffers:[new Uint8Array(v)]}}function h(g,m,p){let b=[],_=0,x=new Map,v=-1/0,E=!1;for(let F of g){let N=a.createAccessorDef(F);r.accessors.push(N),a.accessorIndexMap.set(F,r.accessors.length-1);let U=[],D=[],O=[],K=Array(F.getElementSize()).fill(0);for(let le=0,de=F.getCount();le<de;le++){if(F.getElement(le,O),pt.eq(O,K,0))continue;v=Math.max(le,v),U.push(le);for(let Me=0;Me<O.length;Me++)D.push(O[Me])}let B=U.length,X={accessorDef:N,count:B};if(x.set(F,X),B===0)continue;if(B>F.getCount()/2)E=!0;let q=ul[F.getComponentType()];X.indices=U,X.values=new q(D)}if(!Number.isFinite(v))return{buffers:b,byteLength:_};if(E)o.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let S=v<255?Uint8Array:v<65535?Uint16Array:Uint32Array,T=v<255?I8:v<65535?R8:M8,A={buffer:m,byteOffset:p+_,byteLength:0};for(let F of g){let N=x.get(F);if(N.count===0)continue;N.indicesByteOffset=A.byteLength;let U=Je.pad(Je.toView(new S(N.indices)));b.push(U),_+=U.byteLength,A.byteLength+=U.byteLength}r.bufferViews.push(A);let P=r.bufferViews.length-1,w={buffer:m,byteOffset:p+_,byteLength:0};for(let F of g){let N=x.get(F);if(N.count===0)continue;N.valuesByteOffset=w.byteLength;let U=Je.pad(Je.toView(N.values));b.push(U),_+=U.byteLength,w.byteLength+=U.byteLength}r.bufferViews.push(w);let I=r.bufferViews.length-1;for(let F of g){let N=x.get(F);if(N.count===0)continue;N.accessorDef.sparse={count:N.count,indices:{bufferView:P,byteOffset:N.indicesByteOffset,componentType:T},values:{bufferView:I,byteOffset:N.valuesByteOffset}}}return{buffers:b,byteLength:_}}if(r.accessors=[],r.bufferViews=[],r.samplers=[],r.textures=[],r.images=i.listTextures().map((g,m)=>{let p=a.createPropertyDef(g);if(g.getMimeType())p.mimeType=g.getMimeType();let b=g.getImage();if(b)a.createImageData(p,b,g);return a.imageIndexMap.set(g,m),p}),l.filter((g)=>g.prewriteTypes.includes("Accessor")).forEach((g)=>g.prewrite(a,"Accessor")),i.listAccessors().forEach((g)=>{let{accessorUsageGroupedByParent:m,accessorParents:p}=a;if(a.accessorIndexMap.has(g))return;let b=a.getAccessorUsage(g);if(a.addAccessorToUsageGroup(g,b),m.has(b)){let _=n.listParents(g).find((x)=>x.propertyType!=="Root");p.set(g,_)}}),l.filter((g)=>g.prewriteTypes.includes("Buffer")).forEach((g)=>g.prewrite(a,"Buffer")),(i.listAccessors().length>0||a.otherBufferViews.size>0||i.listTextures().length>0&&t.format==="GLB")&&i.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(r.buffers=[],i.listBuffers().forEach((g,m)=>{let p=a.createPropertyDef(g),b=a.accessorUsageGroupedByParent,_=g.listParents().filter((P)=>P instanceof Be),x=new Set(_.map((P)=>a.accessorParents.get(P))),v=new Map(Array.from(x).map((P,w)=>[P,w])),E={};for(let P of _){if(a.accessorIndexMap.has(P))continue;let w=a.getAccessorUsage(P),I=w;if(b.has(w)){let F=a.accessorParents.get(P);I+=`:${v.get(F)}`}E[I]||={usage:w,accessors:[]},E[I].accessors.push(P)}let S=[],T=r.buffers.length,A=0;for(let{usage:P,accessors:w}of Object.values(E))if(P===kd.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){let I=f(w,T,A);A+=I.byteLength;for(let F of I.buffers)S.push(F)}else if(P===kd.ARRAY_BUFFER)for(let I of w){let F=f([I],T,A);A+=F.byteLength;for(let N of F.buffers)S.push(N)}else if(P===kd.SPARSE){let I=h(w,T,A);A+=I.byteLength;for(let F of I.buffers)S.push(F)}else if(P===kd.ELEMENT_ARRAY_BUFFER){let I=Ss.BufferViewTarget.ELEMENT_ARRAY_BUFFER,F=d(w,T,A,I);A+=F.byteLength;for(let N of F.buffers)S.push(N)}else{let I=d(w,T,A);A+=I.byteLength;for(let F of I.buffers)S.push(F)}if(a.imageBufferViews.length&&m===0){for(let P=0;P<a.imageBufferViews.length;P++)if(r.bufferViews[r.images[P].bufferView].byteOffset=A,A+=a.imageBufferViews[P].byteLength,S.push(a.imageBufferViews[P]),A%8){let w=8-A%8;A+=w,S.push(new Uint8Array(w))}}if(a.otherBufferViews.has(g))for(let P of a.otherBufferViews.get(g))r.bufferViews.push({buffer:T,byteOffset:A,byteLength:P.byteLength}),a.otherBufferViewsIndexMap.set(P,r.bufferViews.length-1),A+=P.byteLength,S.push(P);if(A){let P;if(t.format==="GLB")P=ws;else P=a.bufferURIGenerator.createURI(g,"bin"),p.uri=P;p.byteLength=A,a.assignResourceURI(P,Je.concat(S),!0)}r.buffers.push(p),a.bufferIndexMap.set(g,m)}),i.listAccessors().find((g)=>!g.getBuffer()))o.warn("Skipped writing one or more Accessors: no Buffer assigned.");l.filter((g)=>g.prewriteTypes.includes("Material")).forEach((g)=>g.prewrite(a,"Material")),r.materials=i.listMaterials().map((g,m)=>{let p=a.createPropertyDef(g);if(g.getAlphaMode()!==Ra.AlphaMode.OPAQUE)p.alphaMode=g.getAlphaMode();if(g.getAlphaMode()===Ra.AlphaMode.MASK)p.alphaCutoff=g.getAlphaCutoff();if(g.getDoubleSided())p.doubleSided=!0;if(p.pbrMetallicRoughness={},!pt.eq(g.getBaseColorFactor(),[1,1,1,1]))p.pbrMetallicRoughness.baseColorFactor=g.getBaseColorFactor();if(!pt.eq(g.getEmissiveFactor(),[0,0,0]))p.emissiveFactor=g.getEmissiveFactor();if(g.getRoughnessFactor()!==1)p.pbrMetallicRoughness.roughnessFactor=g.getRoughnessFactor();if(g.getMetallicFactor()!==1)p.pbrMetallicRoughness.metallicFactor=g.getMetallicFactor();if(g.getBaseColorTexture()){let b=g.getBaseColorTexture(),_=g.getBaseColorTextureInfo();p.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(b,_)}if(g.getEmissiveTexture()){let b=g.getEmissiveTexture(),_=g.getEmissiveTextureInfo();p.emissiveTexture=a.createTextureInfoDef(b,_)}if(g.getNormalTexture()){let b=g.getNormalTexture(),_=g.getNormalTextureInfo(),x=a.createTextureInfoDef(b,_);if(g.getNormalScale()!==1)x.scale=g.getNormalScale();p.normalTexture=x}if(g.getOcclusionTexture()){let b=g.getOcclusionTexture(),_=g.getOcclusionTextureInfo(),x=a.createTextureInfoDef(b,_);if(g.getOcclusionStrength()!==1)x.strength=g.getOcclusionStrength();p.occlusionTexture=x}if(g.getMetallicRoughnessTexture()){let b=g.getMetallicRoughnessTexture(),_=g.getMetallicRoughnessTextureInfo();p.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(b,_)}return a.materialIndexMap.set(g,m),p}),l.filter((g)=>g.prewriteTypes.includes("Mesh")).forEach((g)=>g.prewrite(a,"Mesh")),r.meshes=i.listMeshes().map((g,m)=>{let p=a.createPropertyDef(g),b=null;if(p.primitives=g.listPrimitives().map((_)=>{let x={attributes:{}};x.mode=_.getMode();let v=_.getMaterial();if(v)x.material=a.materialIndexMap.get(v);if(Object.keys(_.getExtras()).length)x.extras=_.getExtras();let E=_.getIndices();if(E)x.indices=a.accessorIndexMap.get(E);for(let S of _.listSemantics())x.attributes[S]=a.accessorIndexMap.get(_.getAttribute(S));for(let S of _.listTargets()){let T={};for(let A of S.listSemantics())T[A]=a.accessorIndexMap.get(S.getAttribute(A));x.targets=x.targets||[],x.targets.push(T)}if(_.listTargets().length&&!b)b=_.listTargets().map((S)=>S.getName());return x}),g.getWeights().length)p.weights=g.getWeights();if(b)p.extras=p.extras||{},p.extras.targetNames=b;return a.meshIndexMap.set(g,m),p}),r.cameras=i.listCameras().map((g,m)=>{let p=a.createPropertyDef(g);if(p.type=g.getType(),p.type===Fd.Type.PERSPECTIVE){p.perspective={znear:g.getZNear(),zfar:g.getZFar(),yfov:g.getYFov()};let b=g.getAspectRatio();if(b!==null)p.perspective.aspectRatio=b}else p.orthographic={znear:g.getZNear(),zfar:g.getZFar(),xmag:g.getXMag(),ymag:g.getYMag()};return a.cameraIndexMap.set(g,m),p}),r.nodes=i.listNodes().map((g,m)=>{let p=a.createPropertyDef(g);if(!pt.eq(g.getTranslation(),[0,0,0]))p.translation=g.getTranslation();if(!pt.eq(g.getRotation(),[0,0,0,1]))p.rotation=g.getRotation();if(!pt.eq(g.getScale(),[1,1,1]))p.scale=g.getScale();if(g.getWeights().length)p.weights=g.getWeights();return a.nodeIndexMap.set(g,m),p}),r.skins=i.listSkins().map((g,m)=>{let p=a.createPropertyDef(g),b=g.getInverseBindMatrices();if(b)p.inverseBindMatrices=a.accessorIndexMap.get(b);let _=g.getSkeleton();if(_)p.skeleton=a.nodeIndexMap.get(_);return p.joints=g.listJoints().map((x)=>a.nodeIndexMap.get(x)),a.skinIndexMap.set(g,m),p}),i.listNodes().forEach((g,m)=>{let p=r.nodes[m],b=g.getMesh();if(b)p.mesh=a.meshIndexMap.get(b);let _=g.getCamera();if(_)p.camera=a.cameraIndexMap.get(_);let x=g.getSkin();if(x)p.skin=a.skinIndexMap.get(x);if(g.listChildren().length>0)p.children=g.listChildren().map((v)=>a.nodeIndexMap.get(v))}),r.animations=i.listAnimations().map((g,m)=>{let p=a.createPropertyDef(g),b=new Map;return p.samplers=g.listSamplers().map((_,x)=>{let v=a.createPropertyDef(_);return v.input=a.accessorIndexMap.get(_.getInput()),v.output=a.accessorIndexMap.get(_.getOutput()),v.interpolation=_.getInterpolation(),b.set(_,x),v}),p.channels=g.listChannels().map((_)=>{let x=a.createPropertyDef(_);return x.sampler=b.get(_.getSampler()),x.target={node:a.nodeIndexMap.get(_.getTargetNode()),path:_.getTargetPath()},x}),a.animationIndexMap.set(g,m),p}),r.scenes=i.listScenes().map((g,m)=>{let p=a.createPropertyDef(g);return p.nodes=g.listChildren().map((b)=>a.nodeIndexMap.get(b)),a.sceneIndexMap.set(g,m),p});let y=i.getDefaultScene();if(y)r.scene=i.listScenes().indexOf(y);return r.extensionsUsed=l.map((g)=>g.extensionName),r.extensionsRequired=u.map((g)=>g.extensionName),l.forEach((g)=>g.write(a)),P8(r),s}},O8=class{_logger=Ia.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(let t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){let t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;let n=bS(t)?this._binaryToJSON(t):{json:JSON.parse(Je.decodeText(t)),resources:{}};return await this._readResourcesExternal(n,this.dirname(e)),this._readResourcesInternal(n),n}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),T8.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){let t=this._binaryToJSON(Je.assertView(e));this._readResourcesInternal(t);let n=t.json;if(n.buffers&&n.buffers.some((i)=>k8(t,i)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(n.images&&n.images.some((i)=>D8(t,i)))throw Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(Je.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return N8.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){let{json:t,resources:n}=await this.writeJSON(e,{format:"GLB"}),i=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),s=Je.pad(Je.encodeText(r),32),a=Je.toView(new Uint32Array([s.byteLength,1313821514])),o=Je.concat([a,s]);i[i.length-1]+=o.byteLength;let c=Object.values(n)[0];if(!c||!c.byteLength)return Je.concat([Je.toView(i),o]);let l=Je.pad(c,0),u=Je.toView(new Uint32Array([l.byteLength,5130562])),d=Je.concat([u,l]);return i[i.length-1]+=d.byteLength,Je.concat([Je.toView(i),o,d])}async _readResourcesExternal(e,t){let n=e.json.images||[],i=e.json.buffers||[],r=[...n,...i].map(async(s)=>{let a=s.uri;if(!a||a.match(/data:/))return Promise.resolve();try{e.resources[a]=await this.readURI(this.resolve(t,a),"view"),this.lastReadBytes+=e.resources[a].byteLength}catch(o){if(!this._strictResources&&n.includes(s))this._logger.warn(`Failed to load image URI, "${a}". ${o}`),e.resources[a]=null;else throw o}});await Promise.all(r)}_readResourcesInternal(e){function t(n){if(!n.uri)return;if(n.uri in e.resources){Je.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){let i=`__${TS()}.${Ma.extension(n.uri)}`;e.resources[i]=Je.createBufferFromDataURI(n.uri),n.uri=i}}(e.json.images||[]).forEach((n)=>{if(n.bufferView===void 0&&n.uri===void 0)throw Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){let{images:t,buffers:n}=e.json;if(e={json:{...e.json},resources:{...e.resources}},t)e.json.images=t.map((i)=>({...i}));if(n)e.json.buffers=n.map((i)=>({...i}));return e}_binaryToJSON(e){if(!bS(e))throw Error("Invalid glTF 2.0 binary.");let t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw Error("Missing required GLB JSON chunk.");let n=20,i=t[0],r=Je.decodeText(Je.toView(e,n,i)),s=JSON.parse(r),a=n+i;if(e.byteLength<=a)return{json:s,resources:{}};let o=new Uint32Array(e.buffer,e.byteOffset+a,2);if(o[1]!==5130562)return{json:s,resources:{}};let c=o[0],l=Je.toView(e,a+8,c);return{json:s,resources:{[ws]:l}}}},RS;var fl=Ft(()=>{dS();ne=function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e}({}),YL=function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e}({}),Ei=function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e}({}),QL=class extends Float32Array{constructor(){super();throw Error("Unsupported typed array instantiation.")}},ul={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5131":typeof Float16Array<"u"?Float16Array:QL,"5126":Float32Array,"5130":Float64Array},ji=class{static impls={"image/jpeg":new e8,"image/png":new t8};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(let t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){if(!this.impls[t])return null;return this.impls[t].getSize(e)}static getChannels(e,t){if(!this.impls[t])return null;return this.impls[t].getChannels(e)}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let n=0,i=4,r=this.getSize(e,t);if(!r)return null;while(r[0]>1||r[1]>1)n+=r[0]*r[1]*i,r[0]=Math.max(Math.floor(r[0]/2),1),r[1]=Math.max(Math.floor(r[1]/2),1);return n+=4,n}static mimeTypeToExtension(e){if(e==="image/jpeg")return"jpg";return e.split("/").pop()}static extensionToMimeType(e){if(e==="jpg")return"image/jpeg";if(!e)return"";return`image/${e}`}};pg=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;(function(){var e=i8();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();hg=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.substring(0,t+1)}static basename(e){return Ma.basename(new URL(e,fS).pathname)}static extension(e){return Ma.extension(new URL(e,fS).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;let n=e.split("/"),i=t.split("/");n.pop();for(let r=0;r<i.length;r++){if(i[r]===".")continue;if(i[r]==="..")n.pop();else n.push(i[r])}return n.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};a8=function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e}({}),Ia=class e{verbosity;static Verbosity=a8;static DEFAULT_INSTANCE=new e(1);constructor(t){this.verbosity=t}debug(t){if(this.verbosity<=0)console.debug(t)}info(t){if(this.verbosity<=1)console.info(t)}warn(t){if(this.verbosity<=2)console.warn(t)}error(t){if(this.verbosity<=3)console.error(t)}};pS=new Set,y8=new Set,bg=class extends uS{constructor(e,t=""){super(e);this[Tt].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){if(Array.isArray(t))t=t.slice();return super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){return new this.constructor(this.graph).copy(this,Ms)}copy(e,t=Ms){for(let n in this[Tt]){let i=this[Tt][n];if(i instanceof As){if(!this[Ts].has(n))i.dispose()}else if(i instanceof bn||i instanceof Rt)for(let r of i.values())r.dispose();else if(i instanceof dn)for(let r of i.values())r.dispose()}for(let n in e[Tt]){let i=this[Tt][n],r=e[Tt][n];if(r instanceof As)if(this[Ts].has(n))i.getChild().copy(t(r.getChild()),t);else this.setRef(n,t(r.getChild()),r.getAttributes());else if(r instanceof Rt||r instanceof bn)for(let s of r.values())this.addRef(n,t(s.getChild()),s.getAttributes());else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);this.setRefMap(n,s,t(a.getChild()),a.getAttributes())}else if(wa(r))this[Tt][n]=JSON.parse(JSON.stringify(r));else if(Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r))this[Tt][n]=r.slice();else this[Tt][n]=r}return this}equals(e,t=y8){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(let n in this[Tt]){if(t.has(n))continue;let i=this[Tt][n],r=e[Tt][n];if(i instanceof As||r instanceof As){if(!d8(i,r))return!1}else if(i instanceof Rt||r instanceof Rt||i instanceof bn||r instanceof bn){if(!f8(i,r))return!1}else if(i instanceof dn||r instanceof dn){if(!h8(i,r))return!1}else if(wa(i)||wa(r)){if(!ES(i,r))return!1}else if(Ld(i)||Ld(r)){if(!vS(i,r))return!1}else if(i!==r)return!1}return!0}detach(){return this.graph.disconnectParents(this,(e)=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},jn=class extends bg{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new dn})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){if(t)t._validateParent(this);return this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},Be=class e extends jn{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:e.Type.SCALAR,componentType:e.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case e.Type.SCALAR:return 1;case e.Type.VEC2:return 2;case e.Type.VEC3:return 3;case e.Type.VEC4:return 4;case e.Type.MAT2:return 4;case e.Type.MAT3:return 9;case e.Type.MAT4:return 16;default:throw Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case e.ComponentType.BYTE:case e.ComponentType.UNSIGNED_BYTE:return 1;case e.ComponentType.SHORT:case e.ComponentType.UNSIGNED_SHORT:return 2;case e.ComponentType.UNSIGNED_INT:case e.ComponentType.FLOAT:return 4;case e.ComponentType.FLOAT16:return 2;case e.ComponentType.FLOAT64:return 8;default:throw Error("Unexpected component type: "+t)}}getMinNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMin(t),n)for(let s=0;s<i;s++)t[s]=pt.decodeNormalizedInt(t[s],r);return t}getMin(t){let n=this.getArray(),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.min(t[a],o)}return t}getMaxNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMax(t),n)for(let s=0;s<i;s++)t[s]=pt.decodeNormalizedInt(t[s],r);return t}getMax(t){let n=this.get("array"),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=-1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.max(t[a],o)}return t}getCount(){let t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return e.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){let n=this.getElementSize(),i=this.getComponentType(),r=this.getArray();if(this.getNormalized())return pt.decodeNormalizedInt(r[t*n],i);return r[t*n]}setScalar(t,n){let i=this.getElementSize(),r=this.getComponentType(),s=this.getArray();if(this.getNormalized())s[t*i]=pt.encodeNormalizedInt(n,r);else s[t*i]=n;return this}getElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)n[o]=pt.decodeNormalizedInt(a[t*r+o],s);else n[o]=a[t*r+o];return n}setElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)a[t*r+o]=pt.encodeNormalizedInt(n[o],s);else a[t*r+o]=n[o];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?x8(t):e.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){let t=this.get("array");return t?t.byteLength:0}};AS=class extends jn{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new Rt,samplers:new Rt})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},Ca=class extends jn{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},dl=class e extends jn{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:e.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},SS=class extends jn{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},Fd=class e extends jn{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:e.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},nt=class extends bg{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},At=class e extends jn{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:e.WrapMode.REPEAT,wrapT:e.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}},{R:Nd,G:Pd,B:Od,A:_8}=Ei,Ra=class e extends jn{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:e.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new At(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new At(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new At(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new At(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new At(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){let n=this.get("baseColorFactor").slice();return n[3]=t,this.set("baseColorFactor",n)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:Nd|Pd|Od|_8,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:Nd|Pd|Od,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:Nd|Pd|Od})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:Nd})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:Pd|Od})}},yg=class extends jn{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new Rt})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},Ud=class extends jn{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new Rt})}copy(e,t=Ms){if(t===Ms)throw Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return pt.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){let t=this.get("translation").slice(),n=this.get("rotation").slice(),i=this.get("scale").slice();return pt.decompose(e,t,n,i),this.set("translation",t).set("rotation",n).set("scale",i)}getWorldTranslation(){let e=[0,0,0];return pt.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){let e=[0,0,0,1];return pt.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){let e=[1,1,1];return pt.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){let e=[];for(let i=this;i!=null;i=i.getParentNode())e.push(i);let t,n=e.pop().getMatrix();while(t=e.pop())c8(n,n,t.getMatrix());return n}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);for(let n of e.listParents())if(n.propertyType==="Scene")n.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(let e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(let t of this.listChildren())t.traverse(e);return this}},Wn=class e extends jn{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:e.Mode.TRIANGLES,material:null,indices:null,attributes:new dn,targets:new Rt})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,n){return this.setRefMap("attributes",t,n,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},xg=class extends bg{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},Bd=class extends jn{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new Rt})}copy(e,t=Ms){if(t===Ms)throw Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(let t of this.listChildren())t.traverse(e);return this}},wS=class extends jn{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new Rt})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},zo=class extends jn{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||ji.extensionToMimeType(Ma.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);let t=ji.extensionToMimeType(Ma.extension(e));if(t)this.set("mimeType",t);return this}getImage(){return this.get("image")}setImage(e){return this.set("image",Je.assertView(e))}getSize(){let e=this.get("image");if(!e)return null;return ji.getSize(e,this.getMimeType())}},Rs=class extends jn{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${yS}`,version:"2.0"},defaultScene:null,accessors:new Rt,animations:new Rt,buffers:new Rt,cameras:new Rt,materials:new Rt,meshes:new Rt,nodes:new Rt,scenes:new Rt,skins:new Rt,textures:new Rt})}constructor(e){super(e);e.addEventListener("node:create",(t)=>{this._addChildOfRoot(t.target)})}clone(){throw Error("Root cannot be cloned.")}copy(e,t=Ms){if(t===Ms)throw Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(let n of e.listRefMapKeys("extensions")){let i=e.getExtension(n);this.setExtension(n,t(i))}return this}_addChildOfRoot(e){if(e instanceof Bd)this.addRef("scenes",e);else if(e instanceof Ud)this.addRef("nodes",e);else if(e instanceof Fd)this.addRef("cameras",e);else if(e instanceof wS)this.addRef("skins",e);else if(e instanceof yg)this.addRef("meshes",e);else if(e instanceof Ra)this.addRef("materials",e);else if(e instanceof zo)this.addRef("textures",e);else if(e instanceof AS)this.addRef("animations",e);else if(e instanceof Be)this.addRef("accessors",e);else if(e instanceof SS)this.addRef("buffers",e);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((e)=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},zd=class e{_graph=new dg;_root=new Rs(this._graph);_logger=Ia.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return e._GRAPH_DOCUMENTS.get(t)||null}constructor(){e._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){let n=t.map((i)=>i.name);for(let i of t)await i(this,{stack:n});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some((n)=>n.extensionName===t)}createExtension(t){let n=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===n)||new t(this)}disposeExtension(t){let n=this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===t);if(n)n.dispose()}createScene(t=""){return new Bd(this._graph,t)}createNode(t=""){return new Ud(this._graph,t)}createCamera(t=""){return new Fd(this._graph,t)}createSkin(t=""){return new wS(this._graph,t)}createMesh(t=""){return new yg(this._graph,t)}createPrimitive(){return new Wn(this._graph)}createPrimitiveTarget(t=""){return new xg(this._graph,t)}createMaterial(t=""){return new Ra(this._graph,t)}createTexture(t=""){return new zo(this._graph,t)}createAnimation(t=""){return new AS(this._graph,t)}createAnimationChannel(t=""){return new Ca(this._graph,t)}createAnimationSampler(t=""){return new dl(this._graph,t)}createAccessor(t="",n=null){if(!n)n=this.getRoot().listBuffers()[0];return new Be(this._graph,t).setBuffer(n)}createBuffer(t=""){return new SS(this._graph,t)}},mS={logger:Ia.DEFAULT_INSTANCE,extensions:[],dependencies:{}},E8=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);MS=function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e}(MS||{}),Ss=class{_doc;jsonDoc;options;static BufferViewTarget=MS;static BufferViewUsage=YL;static USAGE_TO_TARGET={["ARRAY_BUFFER"]:34962,["ELEMENT_ARRAY_BUFFER"]:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,n){this._doc=e,this.jsonDoc=t,this.options=n;let i=e.getRoot(),r=i.listBuffers().length,s=i.listTextures().length;this.bufferURIGenerator=new gS(r>1,()=>n.basename||"buffer"),this.imageURIGenerator=new gS(s>1,(a)=>w8(e,a)||n.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){let n={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},i=JSON.stringify(n);if(!this.samplerDefIndexMap.has(i))this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(n);let r={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(i)},s=JSON.stringify(r);if(!this.textureDefIndexMap.has(s))this.textureDefIndexMap.set(s,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(r);let a={index:this.textureDefIndexMap.get(s)};if(t.getTexCoord()!==0)a.texCoord=t.getTexCoord();if(Object.keys(t.getExtras()).length>0)a.extras=t.getExtras();return this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){let t={};if(e.getName())t.name=e.getName();if(Object.keys(e.getExtras()).length>0)t.extras=e.getExtras();return t}createAccessorDef(e){let t=this.createPropertyDef(e);if(t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some((n)=>n.getName()==="attributes"&&n.getAttributes().key==="POSITION"||n.getName()==="input"))t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround);if(e.getNormalized())t.normalized=e.getNormalized();return t}createImageData(e,t,n){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{let i=ji.mimeTypeToExtension(n.getMimeType());e.uri=this.imageURIGenerator.createURI(n,i),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,n){let i=this.jsonDoc.resources;if(!(e in i)){i[e]=t;return}if(t===i[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}let r=`Resource URI "${e}" already assigned to different data.`;if(!n){this.logger.warn(r);return}throw Error(r)}getAccessorUsage(e){let t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(let n of this._doc.getGraph().listParentEdges(e)){let{usage:i}=n.getAttributes();if(i)return i;if(n.getParent().propertyType!=="Root")this.logger.warn(`Missing attribute ".usage" on edge, "${n.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){let n=this._accessorUsageMap.get(e);if(n&&n!==t)throw Error(`Accessor with usage "${n}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}};({BufferViewUsage:kd}=Ss),{UNSIGNED_INT:M8,UNSIGNED_SHORT:R8,UNSIGNED_BYTE:I8}=Be.ComponentType,C8=new Set(["Accessor","Buffer","Material","Mesh"]);RS=class extends O8{_fetchConfig;constructor(e=hg.DEFAULT_INIT){super();this._fetchConfig=e}async readURI(e,t){let n=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await n.arrayBuffer());case"text":return n.text()}}resolve(e,t){return hg.resolve(e,t)}dirname(e){return hg.dirname(e)}}});function L8(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class Vo{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),n=e+4294967296*t;return this._offset+=8,n}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){let n=this._offset,i=0;while(this._dataView.getUint8(this._offset)!==t&&i<e)i++,this._offset++;if(i<e)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}function IS(e){return new TextDecoder().decode(e)}function Vd(e){let t=new Uint8Array(e.buffer,e.byteOffset,Hn.length);if(t[0]!==Hn[0]||t[1]!==Hn[1]||t[2]!==Hn[2]||t[3]!==Hn[3]||t[4]!==Hn[4]||t[5]!==Hn[5]||t[6]!==Hn[6]||t[7]!==Hn[7]||t[8]!==Hn[8]||t[9]!==Hn[9]||t[10]!==Hn[10]||t[11]!==Hn[11])throw Error("Missing KTX 2.0 identifier.");let n=L8(),i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Vo(e,Hn.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32(),n.levelCount=r._nextUint32(),n.supercompressionScheme=r._nextUint32();let s=r._nextUint32(),a=r._nextUint32(),o=r._nextUint32(),c=r._nextUint32(),l=r._nextUint64(),u=r._nextUint64(),d=Math.max(n.levelCount,1)*3*8,f=new Vo(e,Hn.length+i,d,!0);for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});let h=new Vo(e,s,a,!0);h._skip(4);let y=h._nextUint16(),g=h._nextUint16(),m=h._nextUint16(),p=h._nextUint16(),b=h._nextUint8(),_=h._nextUint8(),x=h._nextUint8(),v=h._nextUint8(),E=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],S=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],A={vendorId:y,descriptorType:g,versionNumber:m,colorModel:b,colorPrimaries:_,transferFunction:x,flags:v,texelBlockDimension:E,bytesPlane:S,samples:[]},P=6,w=4,I=(p/4-P)/w;for(let ie=0;ie<I;ie++){let ce={bitOffset:h._nextUint16(),bitLength:h._nextUint8(),channelType:h._nextUint8(),samplePosition:[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(ce.channelType&64)ce.sampleLower=h._nextInt32(),ce.sampleUpper=h._nextInt32();else ce.sampleLower=h._nextUint32(),ce.sampleUpper=h._nextUint32();A.samples[ie]=ce}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(A);let F=new Vo(e,o,c,!0);while(F._offset<c){let ie=F._nextUint32(),ce=F._scan(ie),_e=IS(ce);if(n.keyValue[_e]=F._nextUint8Array(ie-ce.byteLength-1),_e.match(/^ktx/i)){let Oe=IS(n.keyValue[_e]);n.keyValue[_e]=Oe.substring(0,Oe.lastIndexOf("\x00"))}let Re=ie%4?4-ie%4:0;F._skip(Re)}if(u<=0)return n;let N=new Vo(e,l,u,!0),U=N._nextUint16(),D=N._nextUint16(),O=N._nextUint32(),K=N._nextUint32(),B=N._nextUint32(),X=N._nextUint32(),q=[];for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)q.push({imageFlags:N._nextUint32(),rgbSliceByteOffset:N._nextUint32(),rgbSliceByteLength:N._nextUint32(),alphaSliceByteOffset:N._nextUint32(),alphaSliceByteLength:N._nextUint32()});let le=l+N._offset,de=le+O,Me=de+K,pe=Me+B,J=new Uint8Array(e.buffer,e.byteOffset+le,O),L=new Uint8Array(e.buffer,e.byteOffset+de,K),W=new Uint8Array(e.buffer,e.byteOffset+Me,B),te=new Uint8Array(e.buffer,e.byteOffset+pe,X);return n.globalData={endpointCount:U,selectorCount:D,imageDescs:q,endpointsData:J,selectorsData:L,tablesData:W,extendedData:te},n}var CS=0,NS=163,PS=166,_g=0,OS=123,kS=1000066000,_6,Hn;var DS=Ft(()=>{_6=new Uint8Array([0]),Hn=[171,75,84,88,32,50,48,187,13,10,26,10]});function H8(e,t,n,i){let r=t.createFeatureID().setFeatureCount(i.featureCount);if(i.nullFeatureId!==void 0)r.setNullFeatureID(i.nullFeatureId);if(i.label!==void 0)r.setLabel(i.label);if(i.attribute!==void 0)r.setAttribute(i.attribute);let s=i.texture;if(s!==void 0){let a=G8(t,n,s);r.setTexture(a)}if(i.propertyTable!==void 0){let a=e.getRoot().getExtension(et).listPropertyTables();r.setPropertyTable(a[i.propertyTable])}return r}function G8(e,t,n){let i=e.createFeatureIDTexture(),{json:r}=t.jsonDoc;if(n.channels)i.setChannels(n.channels);if(n.index!==void 0){let s=r.textures[n.index].source;i.setTexture(t.textures[s]),t.setTextureInfo(i.getTextureInfo(),n)}return i}function $8(e,t,n){let i=e.getRoot(),r={featureCount:n.getFeatureCount()};if(n.getNullFeatureID()!=null)r.nullFeatureId=n.getNullFeatureID();if(n.getLabel())r.label=n.getLabel();if(n.getAttribute()!=null)r.attribute=n.getAttribute();if(n.getTexture()){let s=n.getTexture(),a=s.getTexture(),o=s.getTextureInfo();r.texture=t.createTextureInfoDef(a,o);let c=s.getChannels();if(!pt.eq(c,[0]))r.texture.channels=c}if(n.getPropertyTable()){let s=i.getExtension(et),a=n.getPropertyTable();r.propertyTable=s.listPropertyTables().indexOf(a)}return r}function X8(e){if(!e.extensions||!e.extensions.EXT_meshopt_compression)return!1;return!!e.extensions[Xn].fallback}function Z8(e,t,n,i){let{filter:r,bits:s}=i,a={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(n!=="ATTRIBUTES")return a;if(r!=="NONE"){let o=e.getNormalized()?Y8(e):new Float32Array(a.array);switch(r){case"EXPONENTIAL":a.byteStride=e.getElementSize()*4,a.componentType=J8,a.normalized=!1,a.array=t.encodeFilterExp(o,e.getCount(),a.byteStride,s);break;case"OCTAHEDRAL":a.byteStride=s>8?8:4,a.componentType=s>8?US:q8,a.normalized=!0,o=e.getElementSize()===3?eF(o):o,a.array=t.encodeFilterOct(o,e.getCount(),a.byteStride,s);break;case"QUATERNION":a.byteStride=8,a.componentType=US,a.normalized=!0,a.array=t.encodeFilterQuat(o,e.getCount(),a.byteStride,s);break;default:throw Error("Invalid filter.")}if(a.min=e.getMin([]),a.max=e.getMax([]),e.getNormalized())a.min=a.min.map((c)=>Ag(c,e.getComponentType())),a.max=a.max.map((c)=>Ag(c,e.getComponentType()));if(a.normalized)a.min=a.min.map((c)=>BS(c,a.componentType)),a.max=a.max.map((c)=>BS(c,a.componentType))}else if(a.byteStride%4)a.array=Q8(a.array,e.getElementSize()),a.byteStride=a.array.byteLength/e.getCount();return a}function Y8(e){let t=e.getComponentType(),n=e.getArray(),i=new Float32Array(n.length);for(let r=0;r<n.length;r++)i[r]=Ag(n[r],t);return i}function Q8(e,t){let n=Je.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,i=e.length/t,r=new e.constructor(i*n);for(let s=0;s*t<e.length;s++)for(let a=0;a<t;a++)r[s*n+a]=e[s*t+a];return r}function eF(e){let t=new Float32Array(e.length*4/3);for(let n=0,i=e.length/3;n<i;n++)t[n*4]=e[n*3],t[n*4+1]=e[n*3+1],t[n*4+2]=e[n*3+2];return t}function tF(e,t){if(t===Ss.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return e.listParents().some((n)=>n instanceof Wn&&n.getMode()===Wn.Mode.TRIANGLES)?"TRIANGLES":"INDICES";return"ATTRIBUTES"}function nF(e,t){let n=t.getGraph().listParentEdges(e).filter((i)=>!(i.getParent()instanceof Rs));for(let i of n){let r=i.getName(),s=i.getAttributes().key||"",a=i.getParent().propertyType===ne.PRIMITIVE_TARGET;if(r==="indices")return{filter:"NONE"};if(r==="attributes"){if(s==="POSITION")return{filter:"NONE"};if(s==="TEXCOORD_0")return{filter:"NONE"};if(s.startsWith("JOINTS_"))return{filter:"NONE"};if(s.startsWith("WEIGHTS_"))return{filter:"NONE"};if(s==="NORMAL"||s==="TANGENT")return a?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(r==="output"){let o=tw(e);if(o==="rotation")return{filter:"QUATERNION",bits:16};if(o==="translation")return{filter:"EXPONENTIAL",bits:12};if(o==="scale")return{filter:"EXPONENTIAL",bits:12};return{filter:"NONE"}}if(r==="input")return{filter:"NONE"};if(r==="inverseBindMatrices")return{filter:"NONE"}}return{filter:"NONE"}}function tw(e){for(let t of e.listParents()){if(!(t instanceof dl))continue;for(let n of t.listParents()){if(!(n instanceof Ca))continue;return n.getTargetPath()}}return null}function yF(e,t,n){let i=e.createStructuralMetadata();if(n.schema!==void 0){let o=xF(e,n.schema);i.setSchema(o)}else if(n.schemaUri){let o=n.schemaUri;i.setSchemaUri(o)}let r=n.propertyTextures||[];for(let o of r){let c=AF(e,t,o);i.addPropertyTexture(c)}let s=n.propertyTables||[];for(let o of s){let c=wF(e,t,o);i.addPropertyTable(c)}let a=n.propertyAttributes||[];for(let o of a){let c=RF(e,o);i.addPropertyAttribute(c)}return i}function xF(e,t){let n=e.createSchema().setId(t.id);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.version!==void 0)n.setVersion(t.version);let i=t.classes||{};for(let s of Object.keys(i)){let a=i[s];n.setClass(s,_F(e,a))}let r=t.enums||{};for(let s of Object.keys(r))n.setEnum(s,EF(e,r[s]));return n}function _F(e,t){let n=e.createClass();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);let i=t.properties||{};for(let r of Object.keys(i)){let s=vF(e,i[r]);n.setProperty(r,s)}return n}function vF(e,t){let n=e.createClassProperty().setType(t.type);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.componentType!==void 0)n.setComponentType(t.componentType);if(t.enumType!==void 0)n.setEnumType(t.enumType);if(t.array!==void 0)n.setArray(t.array);if(t.count!==void 0)n.setCount(t.count);if(t.normalized!==void 0)n.setNormalized(t.normalized);if(t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);if(t.required!==void 0)n.setRequired(t.required);if(t.noData!==void 0)n.setNoData(t.noData);if(t.default!==void 0)n.setDefault(t.default);return n}function EF(e,t){let n=e.createEnum();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.valueType!==void 0)n.setValueType(t.valueType);let i=t.values||{};for(let r of i)n.addEnumValue(TF(e,r));return n}function TF(e,t){let n=e.createEnumValue();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.value!==void 0)n.setValue(t.value);return n}function AF(e,t,n){let i=e.createPropertyTexture();if(i.setClass(n.class),n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=SF(e,t,r[s]);i.setProperty(s,a)}return i}function SF(e,t,n){let i=e.createPropertyTextureProperty(),r=t.jsonDoc.json.textures||[];if(n.channels)i.setChannels(n.channels);let s=r[n.index].source;if(s!==void 0){let a=t.textures[s];i.setTexture(a);let o=i.getTextureInfo();if(o)t.setTextureInfo(o,n)}if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function wF(e,t,n){let i=e.createPropertyTable().setClass(n.class).setCount(n.count);if(n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=MF(e,t,r[s]);i.setProperty(s,a)}return i}function MF(e,t,n){let i=e.createPropertyTableProperty(),r=vg(t,n.values);if(i.setValues(r),n.arrayOffsets!==void 0){let s=vg(t,n.arrayOffsets);i.setArrayOffsets(s)}if(n.stringOffsets!==void 0){let s=vg(t,n.stringOffsets);i.setStringOffsets(s)}if(n.arrayOffsetType!==void 0)i.setArrayOffsetType(n.arrayOffsetType);if(n.stringOffsetType!==void 0)i.setStringOffsetType(n.stringOffsetType);if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function RF(e,t){let n=e.createPropertyAttribute();if(n.setClass(t.class),t.name!==void 0)n.setName(t.name);let i=t.properties||{};for(let r of Object.keys(i)){let s=IF(e,i[r]);n.setProperty(r,s)}return n}function IF(e,t){let n=e.createPropertyAttributeProperty();if(n.setAttribute(t.attribute),t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);return n}function CF(e,t){let n={},i=t.getSchema();if(i)n.schema=NF(i);let r=t.getSchemaUri();if(r)n.schemaUri=r;let s=t.listPropertyTables();if(s.length>0){let c=[];for(let l of s){let u=LF(e,l);c.push(u)}n.propertyTables=c}let a=t.listPropertyTextures();if(a.length>0){let c=[];for(let l of a){let u=zF(e,l);c.push(u)}n.propertyTextures=c}let o=t.listPropertyAttributes();if(o.length>0){let c=[];for(let l of o){let u=UF(l);c.push(u)}n.propertyAttributes=c}return n}function NF(e){let t={id:e.getId()},n=e.listClassKeys();if(n.length>0){t.classes={};for(let r of n){let s=PF(e.getClass(r));t.classes[r]=s}}let i=e.listEnumKeys();if(i.length>0){t.enums={};for(let r of i){let s=kF(e.getEnum(r));t.enums[r]=s}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getVersion())t.version=e.getVersion();return t}function PF(e){let t={},n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=e.getProperty(i);t.properties[i]=OF(r)}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();return t}function OF(e){let t={type:e.getType()};if(e.getArray())t.array=e.getArray();if(e.getNormalized())t.normalized=e.getNormalized();if(e.getRequired())t.required=e.getRequired();if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getComponentType()!=null)t.componentType=e.getComponentType();if(e.getEnumType()!=null)t.enumType=e.getEnumType();if(e.getCount()!=null)t.count=e.getCount();if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();if(e.getNoData()!=null)t.noData=e.getNoData();if(e.getDefault()!=null)t.default=e.getDefault();return t}function kF(e){let t={values:e.listValues().map(DF)};if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getValueType()!=="UINT16")t.valueType=e.getValueType();return t}function DF(e){let t={name:e.getName(),value:e.getValue()};if(e.getDescription())t.description=e.getDescription();return t}function LF(e,t){let n={class:t.getClass(),count:t.getCount()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=FF(e,t.getProperty(r));n.properties[r]=s}}return n}function FF(e,t){let n=t.getValues(),i={values:e.otherBufferViewsIndexMap.get(n)};if(t.getArrayOffsets()){let r=t.getArrayOffsets();i.arrayOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getStringOffsets()){let r=t.getStringOffsets();i.stringOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getArrayOffsetType()!=null)i.arrayOffsetType=t.getArrayOffsetType();if(t.getStringOffsetType()!=null)i.stringOffsetType=t.getStringOffsetType();if(t.getOffset()!=null)i.offset=t.getOffset();if(t.getScale()!=null)i.scale=t.getScale();if(t.getMax()!=null)i.max=t.getMax();if(t.getMin()!=null)i.min=t.getMin();return i}function UF(e){let t={class:e.getClass()};if(e.getName())t.name=e.getName();let n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=BF(e.getProperty(i));t.properties[i]=r}}return t}function BF(e){let t={attribute:e.getAttribute()};if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();return t}function zF(e,t){let n={class:t.getClass()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=VF(e,t.getProperty(r));n.properties[r]=s}}return n}function VF(e,t){let n=t.getTexture(),i=t.getTextureInfo(),r=t.getChannels(),s=e.createTextureInfoDef(n,i);if(!pt.eq(r,[0]))s.channels=r;if(t.getOffset()!=null)s.offset=t.getOffset();if(t.getScale()!=null)s.scale=t.getScale();if(t.getMax()!=null)s.max=t.getMax();if(t.getMin()!=null)s.min=t.getMin();return s}function vg(e,t){let n=e.jsonDoc,i=n.json.buffers||[],r=(n.json.bufferViews||[])[t],s=i[r.buffer],a=s.uri?n.resources[s.uri]:n.resources[ws],o=r.byteOffset||0,c=r.byteLength;return a.slice(o,o+c)}function jF(e,t){let n=e.getRoot().listBuffers()[0],i=t.otherBufferViews.get(n);if(!i)i=[],t.otherBufferViews.set(n,i);return i}function VS(e,t){if(e.byteLength<4+t)return null;let n=e.getUint32(t);if(e.byteLength<n+t||n<8)return null;return{type:Je.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+n}}function WF(e,t){let n=new yn.DecoderBuffer;try{if(n.Init(t,t.length),e.GetEncodedGeometryType(n)!==yn.TRIANGULAR_MESH)throw Error(`[${en}] Unknown geometry type.`);let i=new yn.Mesh;if(!e.DecodeBufferToMesh(n,i).ok()||i.ptr===0)throw Error(`[${en}] Decoding failure.`);return i}finally{yn.destroy(n)}}function XF(e,t){let n=t.num_faces()*3,i,r;if(t.num_points()<=65534){let s=n*Uint16Array.BYTES_PER_ELEMENT;i=yn._malloc(s),e.GetTrianglesUInt16Array(t,s,i),r=new Uint16Array(yn.HEAPU16.buffer,i,n).slice()}else{let s=n*Uint32Array.BYTES_PER_ELEMENT;i=yn._malloc(s),e.GetTrianglesUInt32Array(t,s,i),r=new Uint32Array(yn.HEAPU32.buffer,i,n).slice()}return yn._free(i),r}function qF(e,t,n,i){let r=sw[i.componentType],s=rw[i.componentType],a=n.num_components(),o=t.num_points()*a,c=o*s.BYTES_PER_ELEMENT,l=yn._malloc(c);e.GetAttributeDataArrayForAllPoints(t,n,r,c,l);let u=new s(yn.HEAPF32.buffer,l,o).slice();return yn._free(l),u}function JF(e){yn=e,rw={[Be.ComponentType.FLOAT]:Float32Array,[Be.ComponentType.UNSIGNED_INT]:Uint32Array,[Be.ComponentType.UNSIGNED_SHORT]:Uint16Array,[Be.ComponentType.UNSIGNED_BYTE]:Uint8Array,[Be.ComponentType.SHORT]:Int16Array,[Be.ComponentType.BYTE]:Int8Array},sw={[Be.ComponentType.FLOAT]:yn.DT_FLOAT32,[Be.ComponentType.UNSIGNED_INT]:yn.DT_UINT32,[Be.ComponentType.UNSIGNED_SHORT]:yn.DT_UINT16,[Be.ComponentType.UNSIGNED_BYTE]:yn.DT_UINT8,[Be.ComponentType.SHORT]:yn.DT_INT16,[Be.ComponentType.BYTE]:yn.DT_INT8}}function YF(e){Ti=e}function QF(e,t=GS){let n={...GS,...t};n.quantizationBits={...aw,...t.quantizationBits};let i=new Ti.MeshBuilder,r=new Ti.Mesh,s=new Ti.ExpertEncoder(r),a={},o=new Ti.DracoInt8Array,c=e.listTargets().length>0,l=!1;for(let g of e.listSemantics()){let m=e.getAttribute(g);if(m.getSparse()){l=!0;continue}let p=e2(g),b=t2(i,m.getComponentType(),r,Ti[p],m.getCount(),m.getElementSize(),m.getArray());if(b===-1)throw Error(`Error compressing "${g}" attribute.`);if(a[g]=b,n.quantizationVolume==="mesh"||g!=="POSITION")s.SetAttributeQuantization(b,n.quantizationBits[p]);else if(typeof n.quantizationVolume==="object"){let{quantizationVolume:_}=n,x=Math.max(_.max[0]-_.min[0],_.max[1]-_.min[1],_.max[2]-_.min[2]);s.SetAttributeExplicitQuantization(b,n.quantizationBits[p],m.getElementSize(),_.min,x)}else throw Error("Invalid quantization volume state.")}let u=e.getIndices();if(!u)throw new Sg("Primitive must have indices.");if(i.AddFacesToMesh(r,u.getCount()/3,u.getArray()),s.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),s.SetTrackEncodedProperties(!0),n.method===0||c||l)s.SetEncodingMethod(Ti.MESH_SEQUENTIAL_ENCODING);else s.SetEncodingMethod(Ti.MESH_EDGEBREAKER_ENCODING);let d=s.EncodeToDracoBuffer(!(c||l),o);if(d<=0)throw new Sg("Error applying Draco compression.");let f=new Uint8Array(d);for(let g=0;g<d;++g)f[g]=o.GetValue(g);let h=s.GetNumberOfEncodedPoints(),y=s.GetNumberOfEncodedFaces()*3;return Ti.destroy(o),Ti.destroy(r),Ti.destroy(i),Ti.destroy(s),{numVertices:h,numIndices:y,data:f,attributeIDs:a}}function e2(e){if(e==="POSITION")return"POSITION";else if(e==="NORMAL")return"NORMAL";else if(e.startsWith("COLOR_"))return"COLOR";else if(e.startsWith("TEXCOORD_"))return"TEX_COORD";return"GENERIC"}function t2(e,t,n,i,r,s,a){switch(t){case Be.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(n,i,r,s,a);case Be.ComponentType.BYTE:return e.AddInt8Attribute(n,i,r,s,a);case Be.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(n,i,r,s,a);case Be.ComponentType.SHORT:return e.AddInt16Attribute(n,i,r,s,a);case Be.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(n,i,r,s,a);case Be.ComponentType.FLOAT:return e.AddFloatAttribute(n,i,r,s,a);default:throw Error(`Unexpected component type, "${t}".`)}}function n2(e){let t=e.getLogger(),n=new Set,i=new Set,r=0,s=0;for(let d of e.getRoot().listMeshes())for(let f of d.listPrimitives())if(!f.getIndices())i.add(f),r++;else if(f.getMode()!==Wn.Mode.TRIANGLES)i.add(f),s++;else n.add(f);if(r>0)t.warn(`[${en}] Skipping Draco compression of ${r} non-indexed primitives.`);if(s>0)t.warn(`[${en}] Skipping Draco compression of ${s} non-TRIANGLES primitives.`);let a=e.getRoot().listAccessors(),o=new Map;for(let d=0;d<a.length;d++)o.set(a[d],d);let c=new Map,l=new Set,u=new Map;for(let d of Array.from(n)){let f=$S(d,o);if(l.has(f)){u.set(d,f);continue}if(c.has(d.getIndices())){let h=d.getIndices(),y=h.clone();o.set(y,e.getRoot().listAccessors().length-1),d.swap(h,y)}for(let h of d.listAttributes())if(c.has(h)){let y=h.clone();o.set(y,e.getRoot().listAccessors().length-1),d.swap(h,y)}f=$S(d,o),l.add(f),u.set(d,f),c.set(d.getIndices(),f);for(let h of d.listAttributes())c.set(h,f)}for(let d of Array.from(c.keys())){let f=new Set(d.listParents().map((h)=>h.propertyType));if(f.size!==2||!f.has(ne.PRIMITIVE)||!f.has(ne.ROOT))throw Error(`[${en}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let d of Array.from(n)){let f=u.get(d),h=d.getIndices();if(c.get(h)!==f||d.listAttributes().some((y)=>c.get(y)!==f))throw Error(`[${en}] Draco primitives must share all, or no, accessors.`)}for(let d of Array.from(i)){let f=d.getIndices();if(c.has(f)||d.listAttributes().some((h)=>c.has(h)))throw Error(`[${en}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function $S(e,t){let n=[],i=e.getIndices();n.push(t.get(i));for(let r of e.listAttributes())n.push(t.get(r));return n.sort().join("|")}function Z2(e){return e.vkFormat>_g&&e.vkFormat<=OS}function ew(e){let t=e.vkFormat===kS&&e.dataFormatDescriptor[0].colorModel===167;return e.vkFormat===_g||t}function Eg(e){return JSON.parse(JSON.stringify(e))}var Is="EXT_mesh_gpu_instancing",jr="EXT_mesh_features",Xn="EXT_meshopt_compression",et="EXT_structural_metadata",jd="EXT_texture_webp",Hd="EXT_texture_avif",F8="KHR_accessor_float16",U8="KHR_accessor_float64",en="KHR_draco_mesh_compression",Vr="KHR_lights_punctual",Cs="KHR_materials_anisotropy",Ns="KHR_materials_clearcoat",Ps="KHR_materials_diffuse_transmission",Os="KHR_materials_dispersion",ks="KHR_materials_emissive_strength",Ds="KHR_materials_ior",Ls="KHR_materials_iridescence",Fs="KHR_materials_pbrSpecularGlossiness",Us="KHR_materials_sheen",Bs="KHR_materials_specular",zs="KHR_materials_transmission",jo="KHR_materials_unlit",Vs="KHR_materials_volume",ui="KHR_materials_variants",LS="KHR_mesh_primitive_restart",FS="KHR_mesh_quantization",js="KHR_node_visibility",Gd="KHR_texture_basisu",Hs="KHR_texture_transform",Hi="KHR_xmp_json_ld",B8,z8,V8,hl,j8,Tg="INSTANCE_ATTRIBUTE",K8,$d,W8,q8,US,J8,BS,Ag,zS,pl,iF,rF,sF,aF,oF,cF,lF,uF,dF,fF,hF,pF,mF,gF,bF,HF=class{match(e){return e.length>=12&&Je.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=VS(t,0);if(!n)return null;let i=n.end;while(n=VS(t,i))if(n.type==="meta")i=n.start+4;else if(n.type==="iprp"||n.type==="ipco")i=n.start;else if(n.type==="ispe")return[t.getUint32(n.start+4),t.getUint32(n.start+8)];else if(n.type==="mdat")break;else i=n.end;return null}getChannels(e){return 4}},nw,GF=class{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){let t=Je.decodeText(e.slice(0,4)),n=Je.decodeText(e.slice(8,12));if(t!=="RIFF"||n!=="WEBP")return null;let i=new DataView(e.buffer,e.byteOffset),r=12;while(r<i.byteLength){let s=Je.decodeText(new Uint8Array([i.getUint8(r),i.getUint8(r+1),i.getUint8(r+2),i.getUint8(r+3)])),a=i.getUint32(r+4,!0);if(s==="VP8 ")return[i.getInt16(r+14,!0)&16383,i.getInt16(r+16,!0)&16383];else if(s==="VP8L"){let o=i.getUint8(r+9),c=i.getUint8(r+10),l=i.getUint8(r+11),u=i.getUint8(r+12);return[1+((c&63)<<8|o),1+((u&15)<<10|l<<2|(c&192)>>6)]}r+=8+a+a%2}return null}getChannels(e){return 4}},iw,jS,$F,HS,KF,yn,rw,sw,Ti,ZF,aw,GS,Sg,ow,KS,i2,r2,s2,a2,o2,c2,WS,XS,l2,u2,d2,f2,h2,p2,m2,g2,b2,y2,x2,_2,v2,E2,cw,T2,A2,S2,w2,qS,JS,ZS,YS,M2,lw,R2,I2,C2,N2,P2,O2,k2,D2,L2,F2,U2,uw,B2,z2,V2,j2,dw,H2,G2,QS,$2,K2,W2,X2,fw,wg,q2,J2,Y2=class{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){let t=Vd(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){let t=Vd(e),n=t.dataFormatDescriptor[0];if(Z2(t))return n.samples.length;if(ew(t))switch(n.colorModel){case NS:return n.samples.length===2&&(n.samples[1].channelType&15)===15?4:3;case PS:return(n.samples[0].channelType&15)===3?4:3;default:throw Error(`Unexpected KTX2 colorModel, "${n.colorModel}".`)}throw Error(`Unexpected KTX2 vkFormat, "${t.vkFormat}".`)}getVRAMByteLength(e){let t=Vd(e),n=0;if(ew(t)){let i=this.getChannels(e)>3;for(let r=0;r<t.levels.length;r++){let s=t.levels[r];if(s.uncompressedByteLength)n+=s.uncompressedByteLength;else{let a=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,r))),o=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,r))),c=i?16:8;n+=a/4*(o/4)*c}}}else for(let i of t.levels)if(t.supercompressionScheme===CS)n+=i.levelData.byteLength;else n+=i.uncompressedByteLength;return n}},Mg,Q2,eU,tU,nU,iU,rU,hw;var Kd=Ft(()=>{fl();DS();B8=class extends nt{static EXTENSION_NAME=jr;init(){this.extensionName=jr,this.propertyType="FeatureID",this.parentTypes=["Features"]}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(e){return this.set("featureCount",e)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(e){return this.set("nullFeatureId",e)}getLabel(){return this.get("label")}setLabel(e){return this.set("label",e)}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(e){return this.setRef("propertyTable",e)}},z8=class extends nt{static EXTENSION_NAME=jr;init(){this.extensionName=jr,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"]}getDefaults(){let e=new At(this.graph,"textureInfo");return e.setMinFilter(At.MagFilter.NEAREST),e.setMagFilter(At.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},V8=class extends nt{static EXTENSION_NAME=jr;init(){this.extensionName=jr,this.propertyType="Features",this.parentTypes=[ne.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new Rt([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(e){return this.addRef("featureIds",e)}removeFeatureID(e){return this.removeRef("featureIds",e)}},hl=jr,j8=class extends xt{extensionName=jr;static EXTENSION_NAME=jr;createFeatures(){return new V8(this.document.getGraph())}createFeatureID(){return new B8(this.document.getGraph())}createFeatureIDTexture(){return new z8(this.document.getGraph())}read(e){return(e.jsonDoc.json.meshes||[]).forEach((t,n)=>{(t.primitives||[]).forEach((i,r)=>{this._readPrimitive(e,n,i,r)})}),this}_readPrimitive(e,t,n,i){if(!n.extensions||!n.extensions[hl])return;let r=this.createFeatures(),s=n.extensions[hl];for(let a of s.featureIds){let o=H8(this.document,this,e,a);r.addFeatureID(o)}e.meshes[t].listPrimitives()[i].setExtension(hl,r)}write(e){let t=e.jsonDoc.json.meshes;if(!t)return this;for(let n of this.document.getRoot().listMeshes()){let i=t[e.meshIndexMap.get(n)];n.listPrimitives().forEach((r,s)=>{let a=i.primitives[s];this._writePrimitive(e,r,a)})}return this}_writePrimitive(e,t,n){let i=t.getExtension(hl);if(!i)return;let r={featureIds:[]};i.listFeatureIDs().forEach((s)=>{r.featureIds.push($8(this.document,e,s))}),n.extensions=n.extensions||{},n.extensions[hl]=r}};K8=class extends nt{static EXTENSION_NAME=Is;init(){this.extensionName=Is,this.propertyType="InstancedMesh",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:Tg})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},$d=class extends xt{static EXTENSION_NAME=Is;extensionName=Is;prewriteTypes=[ne.ACCESSOR];createInstancedMesh(){return new K8(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions.EXT_mesh_gpu_instancing)return;let i=t.extensions[Is],r=this.createInstancedMesh();for(let s in i.attributes)r.setAttribute(s,e.accessors[i.attributes[s]]);e.nodes[n].setExtension(Is,r)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(Tg);for(let t of this.properties)for(let n of t.listAttributes())e.addAccessorToUsageGroup(n,Tg);return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listNodes().forEach((n)=>{let i=n.getExtension(Is);if(i){let r=e.nodeIndexMap.get(n),s=t.json.nodes[r],a={attributes:{}};i.listSemantics().forEach((o)=>{let c=i.getAttribute(o);a.attributes[o]=e.accessorIndexMap.get(c)}),s.extensions=s.extensions||{},s.extensions[Is]=a}}),this}},W8=function(e){return e.QUANTIZE="quantize",e.FILTER="filter",e}({});({BYTE:q8,SHORT:US,FLOAT:J8}=Be.ComponentType),{encodeNormalizedInt:BS,decodeNormalizedInt:Ag}=pt;zS={method:"quantize"},pl=class extends xt{extensionName=Xn;prereadTypes=[ne.BUFFER,ne.PRIMITIVE];prewriteTypes=[ne.BUFFER,ne.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=Xn;static EncoderMethod=W8;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=zS;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(e,t){if(e==="meshopt.decoder")this._decoder=t;if(e==="meshopt.encoder")this._encoder=t;return this}setEncoderOptions(e){return this._encoderOptions={...zS,...e},this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${Xn}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${Xn}]: Missing WASM support.`)}if(t===ne.BUFFER)this._prereadBuffers(e);else if(t===ne.PRIMITIVE)this._prereadPrimitives(e);return this}_prereadBuffers(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n,i)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let r=n.extensions[Xn],s=r.byteOffset||0,a=r.byteLength||0,{count:o,byteStride:c}=r,l=new Uint8Array(o*c),u=t.json.buffers[r.buffer],d=u.uri?t.resources[u.uri]:t.resources[ws],f=Je.toView(d,s,a);this._decoder.decodeGltfBuffer(l,o,c,f,r.mode,r.filter),e.bufferViews[i]=l})}_prereadPrimitives(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let i=n.extensions[Xn],r=e.buffers[i.buffer],s=e.buffers[n.buffer],a=t.json.buffers[n.buffer];if(X8(a))this._decoderFallbackBufferMap.set(s,r)})}read(e){if(!this.isRequired())return this;for(let[t,n]of this._decoderFallbackBufferMap){for(let i of t.listParents())if(i instanceof Be)i.swap(t,n);t.dispose()}return this}prewrite(e,t){if(t===ne.ACCESSOR)this._prewriteAccessors(e);else if(t===ne.BUFFER)this._prewriteBuffers(e);return this}_prewriteAccessors(e){let t=e.jsonDoc.json,n=this._encoder,i=this._encoderOptions,r=this.document.getGraph(),s=this.document.createBuffer(),a=this.document.getRoot().listBuffers().indexOf(s),o=1,c=new Map,l=(u)=>{for(let d of r.listParents(u)){if(d.propertyType===ne.ROOT)continue;let f=c.get(u);if(f===void 0)c.set(u,f=o++);return f}return-1};this._encoderFallbackBuffer=s,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let u of this.document.getRoot().listAccessors()){if(tw(u)==="weights")continue;if(u.getSparse())continue;let d=e.getAccessorUsage(u),f=e.accessorUsageGroupedByParent.has(d)?l(u):null,h=tF(u,d),y=i.method==="filter"?nF(u,this.document):{filter:"NONE"},g=Z8(u,n,h,y),{array:m,byteStride:p}=g,b=u.getBuffer();if(!b)throw Error(`${Xn}: Missing buffer for accessor.`);let _=this.document.getRoot().listBuffers().indexOf(b),x=[d,f,h,y.filter,p,_].join(":"),v=this._encoderBufferViews[x],E=this._encoderBufferViewData[x],S=this._encoderBufferViewAccessors[x];if(!v||!E)S=this._encoderBufferViewAccessors[x]=[],E=this._encoderBufferViewData[x]=[],v=this._encoderBufferViews[x]={buffer:a,target:Ss.USAGE_TO_TARGET[d],byteOffset:0,byteLength:0,byteStride:d===Ss.BufferViewUsage.ARRAY_BUFFER?p:void 0,extensions:{[Xn]:{buffer:_,byteOffset:0,byteLength:0,mode:h,filter:y.filter!=="NONE"?y.filter:void 0,byteStride:p,count:0}}};let T=e.createAccessorDef(u);if(T.componentType=g.componentType,T.normalized=g.normalized,T.byteOffset=v.byteLength,T.min&&g.min)T.min=g.min;if(T.max&&g.max)T.max=g.max;e.accessorIndexMap.set(u,t.accessors.length),t.accessors.push(T),S.push(T),E.push(new Uint8Array(m.buffer,m.byteOffset,m.byteLength)),v.byteLength+=m.byteLength,v.extensions.EXT_meshopt_compression.count+=u.getCount()}}_prewriteBuffers(e){let t=this._encoder;for(let n in this._encoderBufferViews){let i=this._encoderBufferViews[n],r=this._encoderBufferViewData[n],s=this.document.getRoot().listBuffers()[i.extensions[Xn].buffer],a=e.otherBufferViews.get(s)||[],{count:o,byteStride:c,mode:l}=i.extensions[Xn],u=Je.concat(r),d=t.encodeGltfBuffer(u,o,c,l),f=Je.pad(d);i.extensions[Xn].byteLength=d.byteLength,r.length=0,r.push(f),a.push(f),e.otherBufferViews.set(s,a)}}write(e){let t=0;for(let s in this._encoderBufferViews){let a=this._encoderBufferViews[s],o=this._encoderBufferViewData[s][0],c=e.otherBufferViewsIndexMap.get(o),l=this._encoderBufferViewAccessors[s];for(let h of l)h.bufferView=c;let u=e.jsonDoc.json.bufferViews[c],d=u.byteOffset||0;Object.assign(u,a),u.byteOffset=t;let f=u.extensions[Xn];f.byteOffset=d,t+=Je.padNumber(a.byteLength)}let n=this._encoderFallbackBuffer,i=e.bufferIndexMap.get(n),r=e.jsonDoc.json.buffers[i];return r.byteLength=t,r.extensions={[Xn]:{fallback:!0}},n.dispose(),this}},iF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="StructuralMetadata",this.parentTypes=[ne.ROOT]}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new bn,propertyTextures:new bn,propertyAttributes:new bn})}getSchema(){return this.getRef("schema")}setSchema(e){return this.setRef("schema",e)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(e){return this.set("schemaUri",e)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(e){return this.addRef("propertyTables",e)}removePropertyTable(e){return this.removeRef("propertyTables",e)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},rF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new dn,enums:new dn})}getId(){return this.get("id")}setId(e){return this.set("id",e)}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getVersion(){return this.get("version")}setVersion(e){return this.set("version",e)}setClass(e,t){return this.setRefMap("classes",e,t)}getClass(e){return this.getRefMap("classes",e)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(e,t){return this.setRefMap("enums",e,t)}getEnum(e){return this.getRefMap("enums",e)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},sF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Class",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new dn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},aF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="ClassProperty",this.parentTypes=["Class"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getComponentType(){return this.get("componentType")}setComponentType(e){return this.set("componentType",e)}getEnumType(){return this.get("enumType")}setEnumType(e){return this.set("enumType",e)}getArray(){return this.get("array")}setArray(e){return this.set("array",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}getRequired(){return this.get("required")}setRequired(e){return this.set("required",e)}getNoData(){return this.get("noData")}setNoData(e){return this.set("noData",e)}getDefault(){return this.get("default")}setDefault(e){return this.set("default",e)}},oF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Enum",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new bn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValueType(){return this.get("valueType")}setValueType(e){return this.set("valueType",e)}listValues(){return this.listRefs("values")}addEnumValue(e){return this.addRef("values",e)}removeEnumValue(e){return this.removeRef("values",e)}},cF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="EnumValue",this.parentTypes=["Enum"]}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValue(){return this.get("value")}setValue(e){return this.set("value",e)}},lF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},uF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"]}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(e){return this.set("values",e)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(e){return this.set("arrayOffsets",e)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(e){return this.set("stringOffsets",e)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(e){return this.set("arrayOffsetType",e)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(e){return this.set("stringOffsetType",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},dF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},fF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"]}getDefaults(){let e=new At(this.graph,"textureInfo");return e.setMinFilter(At.MagFilter.NEAREST),e.setMagFilter(At.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},hF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},pF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"]}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},mF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="NodeStructuralMetadata",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getProperties(){return this.get("properties")}setProperties(e){return this.set("properties",e)}},gF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[ne.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new bn,propertyAttributes:new bn})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},bF=class extends xt{extensionName=et;static EXTENSION_NAME=et;prewriteTypes=[ne.BUFFER];prereadTypes=[ne.SCENE];createStructuralMetadata(){return new iF(this.document.getGraph())}createSchema(){return new rF(this.document.getGraph())}createClass(){return new sF(this.document.getGraph())}createClassProperty(){return new aF(this.document.getGraph())}createEnum(){return new oF(this.document.getGraph())}createEnumValue(){return new cF(this.document.getGraph())}createPropertyTable(){return new lF(this.document.getGraph())}createPropertyTableProperty(){return new uF(this.document.getGraph())}createPropertyTexture(){return new dF(this.document.getGraph())}createPropertyTextureProperty(){return new fF(this.document.getGraph())}createPropertyAttribute(){return new hF(this.document.getGraph())}createPropertyAttributeProperty(){return new pF(this.document.getGraph())}createNodeStructuralMetadata(){return new mF(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new gF(this.document.getGraph())}read(e){return this}preread(e){let t=this.document.getRoot(),{json:n}=e.jsonDoc,i=n.extensions[et],r=yF(this,e,i);return t.setExtension(et,r),(n.meshes||[]).forEach((s,a)=>{let o=e.meshes[a].listPrimitives();(s.primitives||[]).forEach((c,l)=>{let u=o[l];this._readPrimitive(r,u,c)})}),(n.nodes||[]).forEach((s,a)=>{this._readNode(e.nodes[a],s)}),this}_readPrimitive(e,t,n){if(!n.extensions||!n.extensions.EXT_structural_metadata)return;let i=this.createMeshPrimitiveStructuralMetadata(),r=n.extensions[et],s=e.listPropertyTextures(),a=r.propertyTextures||[];for(let l of a){let u=s[l];i.addPropertyTexture(u)}let o=e.listPropertyAttributes(),c=r.propertyAttributes||[];for(let l of c){let u=o[l];i.addPropertyAttribute(u)}t.setExtension(et,i)}_readNode(e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;let n=t.extensions[et],i=this.createNodeStructuralMetadata().setClass(n.class).setProperties(n.properties);e.setExtension(et,i)}write(e){let t=this.document.getRoot(),n=t.getExtension(et);if(!n)return this;let i=e.jsonDoc.json,r=CF(e,n);i.extensions=i.extensions||{},i.extensions[et]=r;let s=t.listMeshes(),a=i.meshes;if(a)for(let l of s){let u=a[e.meshIndexMap.get(l)];l.listPrimitives().forEach((d,f)=>{let h=u.primitives[f];this._writePrimitive(n,d,h)})}let o=t.listNodes(),c=i.nodes;if(c)for(let l of o){let u=e.nodeIndexMap.get(l);this._writeNode(l,c[u])}return this}_writePrimitive(e,t,n){let i=t.getExtension(et);if(!i)return;let r=e.listPropertyTextures(),s=e.listPropertyAttributes(),a,o,c=i.listPropertyTextures();if(c.length>0){a=[];for(let d of c){let f=r.indexOf(d);if(f>=0)a.push(f);else throw Error(`${et}: Invalid property texture in mesh primitive`)}}let l=i.listPropertyAttributes();if(l.length>0){o=[];for(let d of l){let f=s.indexOf(d);if(f>=0)o.push(f);else throw Error(`${et}: Invalid property attribute in mesh primitive`)}}let u={propertyTextures:a,propertyAttributes:o};n.extensions=n.extensions||{},n.extensions[et]=u}_writeNode(e,t){let n=e.getExtension("EXT_structural_metadata");if(!n)return;t.extensions=t.extensions||{},t.extensions[et]={class:n.getClass(),properties:n.getProperties()}}prewrite(e,t){if(t===ne.BUFFER)this._prewriteBuffers(e);return this}_prewriteBuffers(e){let t=this.document,n=t.getRoot().getExtension(et);e.jsonDoc.json.bufferViews||=[];for(let i of n.listPropertyTables())for(let r of i.listPropertyValues()){let s=jF(t,e);s.push(r.getValues());let a=r.getArrayOffsets();if(a)s.push(a);let o=r.getStringOffsets();if(o)s.push(o)}}};nw=class extends xt{extensionName=Hd;prereadTypes=[ne.TEXTURE];static EXTENSION_NAME=Hd;static register(){ji.registerFormat("image/avif",new HF)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_avif)t.source=t.extensions[Hd].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/avif"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[Hd]={source:r.source},delete r.source})}}),this}};iw=class extends xt{extensionName=jd;prereadTypes=[ne.TEXTURE];static EXTENSION_NAME=jd;static register(){ji.registerFormat("image/webp",new GF)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_webp)t.source=t.extensions[jd].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/webp"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[jd]={source:r.source},delete r.source})}}),this}},jS=F8,$F=class extends xt{extensionName=jS;static EXTENSION_NAME=jS;read(e){return this}write(e){return this}},HS=U8,KF=class extends xt{extensionName=HS;static EXTENSION_NAME=HS;read(e){return this}write(e){return this}};ZF=function(e){return e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL",e}({}),aw={["POSITION"]:14,["NORMAL"]:10,["COLOR"]:8,["TEX_COORD"]:12,["GENERIC"]:12},GS={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:aw,quantizationVolume:"mesh"};Sg=class extends Error{},ow=class extends xt{extensionName=en;prereadTypes=[ne.PRIMITIVE];prewriteTypes=[ne.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=en;static EncoderMethod=ZF;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(e,t){if(e==="draco3d.decoder")this._decoderModule=t,JF(this._decoderModule);if(e==="draco3d.encoder")this._encoderModule=t,YF(this._encoderModule);return this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw Error(`[${en}] Please install extension dependency, "draco3d.decoder".`);let t=this.document.getLogger(),n=e.jsonDoc,i=new Map;try{let r=n.json.meshes||[];for(let s of r)for(let a of s.primitives){if(!a.extensions||!a.extensions.KHR_draco_mesh_compression)continue;let o=a.extensions[en],[c,l]=i.get(o.bufferView)||[];if(!l||!c){let u=n.json.bufferViews[o.bufferView],d=n.json.buffers[u.buffer],f=d.uri?n.resources[d.uri]:n.resources[ws],h=u.byteOffset||0,y=u.byteLength,g=Je.toView(f,h,y);c=new this._decoderModule.Decoder,l=WF(c,g),i.set(o.bufferView,[c,l]),t.debug(`[${en}] Decompressed ${g.byteLength} bytes.`)}for(let u in o.attributes){let d=e.jsonDoc.json.accessors[a.attributes[u]],f=c.GetAttributeByUniqueId(l,o.attributes[u]),h=qF(c,l,f,d);e.accessors[a.attributes[u]].setArray(h)}if(a.indices!==void 0)e.accessors[a.indices].setArray(XF(c,l))}}finally{for(let[r,s]of Array.from(i.values()))this._decoderModule.destroy(r),this._decoderModule.destroy(s)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw Error(`[${en}] Please install extension dependency, "draco3d.encoder".`);let n=this.document.getLogger();n.debug(`[${en}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let i=n2(this.document),r=new Map,s="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)n.warn(`[${en}]: quantizationVolume=scene requires exactly 1 scene.`);else s=gg(this.document.getRoot().listScenes().pop());for(let a of Array.from(i.keys())){let o=i.get(a);if(!o)throw Error("Unexpected primitive.");if(r.has(o)){r.set(o,r.get(o));continue}let c=a.getIndices(),l=e.jsonDoc.json.accessors,u;try{u=QF(a,{...this._encoderOptions,quantizationVolume:s})}catch(h){if(h instanceof Sg){n.warn(`[${en}]: ${h.message} Skipping primitive compression.`);continue}throw h}r.set(o,u);let d=e.createAccessorDef(c);if(d.count=u.numIndices,e.accessorIndexMap.set(c,l.length),l.push(d),u.numVertices>65534&&Be.getComponentSize(d.componentType)<=2)d.componentType=Be.ComponentType.UNSIGNED_INT;else if(u.numVertices>254&&Be.getComponentSize(d.componentType)<=1)d.componentType=Be.ComponentType.UNSIGNED_SHORT;for(let h of a.listSemantics()){let y=a.getAttribute(h);if(u.attributeIDs[h]===void 0)continue;let g=e.createAccessorDef(y);g.count=u.numVertices,e.accessorIndexMap.set(y,l.length),l.push(g)}let f=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!e.otherBufferViews.has(f))e.otherBufferViews.set(f,[]);e.otherBufferViews.get(f).push(u.data)}return n.debug(`[${en}] Compressed ${i.size} primitives.`),e.extensionData[en]={primitiveHashMap:i,primitiveEncodingMap:r},this}write(e){let t=e.extensionData[en];for(let n of this.document.getRoot().listMeshes()){let i=e.jsonDoc.json.meshes[e.meshIndexMap.get(n)];for(let r=0;r<n.listPrimitives().length;r++){let s=n.listPrimitives()[r],a=i.primitives[r],o=t.primitiveHashMap.get(s);if(!o)continue;let c=t.primitiveEncodingMap.get(o);if(!c)continue;a.extensions=a.extensions||{},a.extensions[en]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){let n=e.jsonDoc.json;n.extensionsUsed=(n.extensionsUsed||[]).filter((i)=>i!==en),n.extensionsRequired=(n.extensionsRequired||[]).filter((i)=>i!==en)}return this}};KS=class e extends nt{static EXTENSION_NAME=Vr;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=Vr,this.propertyType="Light",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:e.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(t){return this.set("color",t)}getIntensity(){return this.get("intensity")}setIntensity(t){return this.set("intensity",t)}getType(){return this.get("type")}setType(t){return this.set("type",t)}getRange(){return this.get("range")}setRange(t){return this.set("range",t)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(t){return this.set("innerConeAngle",t)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(t){return this.set("outerConeAngle",t)}},i2=class extends xt{extensionName=Vr;static EXTENSION_NAME=Vr;createLight(e=""){return new KS(this.document.getGraph(),e)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_lights_punctual)return this;let n=(t.json.extensions.KHR_lights_punctual.lights||[]).map((i)=>{let r=this.createLight().setName(i.name||"").setType(i.type);if(i.extras)r.setExtras(i.extras);if(i.color!==void 0)r.setColor(i.color);if(i.intensity!==void 0)r.setIntensity(i.intensity);if(i.range!==void 0)r.setRange(i.range);if(i.spot?.innerConeAngle!==void 0)r.setInnerConeAngle(i.spot.innerConeAngle);if(i.spot?.outerConeAngle!==void 0)r.setOuterConeAngle(i.spot.outerConeAngle);return r});return t.json.nodes.forEach((i,r)=>{if(!i.extensions||!i.extensions.KHR_lights_punctual)return;let s=i.extensions[Vr];e.nodes[r].setExtension(Vr,n[s.light])}),this}write(e){let t=e.jsonDoc;if(this.properties.size===0)return this;let n=[],i=new Map;for(let r of this.properties){let s=r,a=e.createPropertyDef(r);if(a.type=s.getType(),!pt.eq(s.getColor(),[1,1,1]))a.color=s.getColor();if(s.getIntensity()!==1)a.intensity=s.getIntensity();if(s.getRange()!=null)a.range=s.getRange();if(s.getName())a.name=s.getName();if(s.getType()===KS.Type.SPOT)a.spot={innerConeAngle:s.getInnerConeAngle(),outerConeAngle:s.getOuterConeAngle()};n.push(a),i.set(s,n.length-1)}return this.document.getRoot().listNodes().forEach((r)=>{let s=r.getExtension(Vr);if(s){let a=e.nodeIndexMap.get(r),o=t.json.nodes[a];o.extensions=o.extensions||{},o.extensions[Vr]={light:i.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[Vr]={lights:n},this}},{R:r2,G:s2,B:a2}=Ei,o2=class extends nt{static EXTENSION_NAME=Cs;init(){this.extensionName=Cs,this.propertyType="Anisotropy",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new At(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:r2|s2|a2})}},c2=class extends xt{static EXTENSION_NAME=Cs;extensionName=Cs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createAnisotropy(){return new o2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_anisotropy){let a=this.createAnisotropy();e.materials[s].setExtension(Cs,a);let o=r.extensions[Cs];if(o.extras)a.setExtras(o.extras);if(o.anisotropyStrength!==void 0)a.setAnisotropyStrength(o.anisotropyStrength);if(o.anisotropyRotation!==void 0)a.setAnisotropyRotation(o.anisotropyRotation);if(o.anisotropyTexture!==void 0){let c=o.anisotropyTexture,l=e.textures[i[c.index].source];a.setAnisotropyTexture(l),e.setTextureInfo(a.getAnisotropyTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Cs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Cs]=a,i.getAnisotropyStrength()>0)a.anisotropyStrength=i.getAnisotropyStrength();if(i.getAnisotropyRotation()!==0)a.anisotropyRotation=i.getAnisotropyRotation();if(i.getAnisotropyTexture()){let o=i.getAnisotropyTexture(),c=i.getAnisotropyTextureInfo();a.anisotropyTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:WS,G:XS,B:l2}=Ei,u2=class extends nt{static EXTENSION_NAME=Ns;init(){this.extensionName=Ns,this.propertyType="Clearcoat",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new At(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new At(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new At(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:WS})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:XS})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:WS|XS|l2})}},d2=class extends xt{static EXTENSION_NAME=Ns;extensionName=Ns;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createClearcoat(){return new u2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_clearcoat){let a=this.createClearcoat();e.materials[s].setExtension(Ns,a);let o=r.extensions[Ns];if(o.extras)a.setExtras(o.extras);if(o.clearcoatFactor!==void 0)a.setClearcoatFactor(o.clearcoatFactor);if(o.clearcoatRoughnessFactor!==void 0)a.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor);if(o.clearcoatTexture!==void 0){let c=o.clearcoatTexture,l=e.textures[i[c.index].source];a.setClearcoatTexture(l),e.setTextureInfo(a.getClearcoatTextureInfo(),c)}if(o.clearcoatRoughnessTexture!==void 0){let c=o.clearcoatRoughnessTexture,l=e.textures[i[c.index].source];a.setClearcoatRoughnessTexture(l),e.setTextureInfo(a.getClearcoatRoughnessTextureInfo(),c)}if(o.clearcoatNormalTexture!==void 0){let c=o.clearcoatNormalTexture,l=e.textures[i[c.index].source];if(a.setClearcoatNormalTexture(l),e.setTextureInfo(a.getClearcoatNormalTextureInfo(),c),c.scale!==void 0)a.setClearcoatNormalScale(c.scale)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ns);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ns]=a,a.clearcoatFactor=i.getClearcoatFactor(),a.clearcoatRoughnessFactor=i.getClearcoatRoughnessFactor(),i.getClearcoatTexture()){let o=i.getClearcoatTexture(),c=i.getClearcoatTextureInfo();a.clearcoatTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatRoughnessTexture()){let o=i.getClearcoatRoughnessTexture(),c=i.getClearcoatRoughnessTextureInfo();a.clearcoatRoughnessTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatNormalTexture()){let o=i.getClearcoatNormalTexture(),c=i.getClearcoatNormalTextureInfo();if(a.clearcoatNormalTexture=e.createTextureInfoDef(o,c),i.getClearcoatNormalScale()!==1)a.clearcoatNormalTexture.scale=i.getClearcoatNormalScale()}}}),this}},{R:f2,G:h2,B:p2,A:m2}=Ei,g2=class extends nt{static EXTENSION_NAME=Ps;init(){this.extensionName=Ps,this.propertyType="DiffuseTransmission",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new At(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new At(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:m2})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:f2|h2|p2})}},b2=class extends xt{extensionName=Ps;static EXTENSION_NAME=Ps;createDiffuseTransmission(){return new g2(this.document.getGraph())}read(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_diffuse_transmission){let a=this.createDiffuseTransmission();e.materials[s].setExtension(Ps,a);let o=r.extensions[Ps];if(o.extras)a.setExtras(o.extras);if(o.diffuseTransmissionFactor!==void 0)a.setDiffuseTransmissionFactor(o.diffuseTransmissionFactor);if(o.diffuseTransmissionColorFactor!==void 0)a.setDiffuseTransmissionColorFactor(o.diffuseTransmissionColorFactor);if(o.diffuseTransmissionTexture!==void 0){let c=o.diffuseTransmissionTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionTexture(l),e.setTextureInfo(a.getDiffuseTransmissionTextureInfo(),c)}if(o.diffuseTransmissionColorTexture!==void 0){let c=o.diffuseTransmissionColorTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionColorTexture(l),e.setTextureInfo(a.getDiffuseTransmissionColorTextureInfo(),c)}}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listMaterials()){let i=n.getExtension(Ps);if(!i)continue;let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ps]=a,a.diffuseTransmissionFactor=i.getDiffuseTransmissionFactor(),a.diffuseTransmissionColorFactor=i.getDiffuseTransmissionColorFactor(),i.getDiffuseTransmissionTexture()){let o=i.getDiffuseTransmissionTexture(),c=i.getDiffuseTransmissionTextureInfo();a.diffuseTransmissionTexture=e.createTextureInfoDef(o,c)}if(i.getDiffuseTransmissionColorTexture()){let o=i.getDiffuseTransmissionColorTexture(),c=i.getDiffuseTransmissionColorTextureInfo();a.diffuseTransmissionColorTexture=e.createTextureInfoDef(o,c)}}return this}},y2=class extends nt{static EXTENSION_NAME=Os;init(){this.extensionName=Os,this.propertyType="Dispersion",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}},x2=class extends xt{static EXTENSION_NAME=Os;extensionName=Os;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createDispersion(){return new y2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_dispersion){let i=this.createDispersion();e.materials[n].setExtension(Os,i);let r=t.extensions[Os];if(r.extras)i.setExtras(r.extras);if(r.dispersion!==void 0)i.setDispersion(r.dispersion)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Os);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Os]=a,a.dispersion=i.getDispersion()}}),this}},_2=class extends nt{static EXTENSION_NAME=ks;init(){this.extensionName=ks,this.propertyType="EmissiveStrength",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}},v2=class extends xt{static EXTENSION_NAME=ks;extensionName=ks;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createEmissiveStrength(){return new _2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_emissive_strength){let i=this.createEmissiveStrength();e.materials[n].setExtension(ks,i);let r=t.extensions[ks];if(r.extras)i.setExtras(r.extras);if(r.emissiveStrength!==void 0)i.setEmissiveStrength(r.emissiveStrength)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(ks);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[ks]=a,a.emissiveStrength=i.getEmissiveStrength()}}),this}},E2=class extends nt{static EXTENSION_NAME=Ds;init(){this.extensionName=Ds,this.propertyType="IOR",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}},cw=class extends xt{static EXTENSION_NAME=Ds;extensionName=Ds;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createIOR(){return new E2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_ior){let i=this.createIOR();e.materials[n].setExtension(Ds,i);let r=t.extensions[Ds];if(r.extras)i.setExtras(r.extras);if(r.ior!==void 0)i.setIOR(r.ior)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ds);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Ds]=a,a.ior=i.getIOR()}}),this}},{R:T2,G:A2}=Ei,S2=class extends nt{static EXTENSION_NAME=Ls;init(){this.extensionName=Ls,this.propertyType="Iridescence",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new At(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new At(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:T2})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:A2})}},w2=class extends xt{static EXTENSION_NAME=Ls;extensionName=Ls;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createIridescence(){return new S2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_iridescence){let a=this.createIridescence();e.materials[s].setExtension(Ls,a);let o=r.extensions[Ls];if(o.extras)a.setExtras(o.extras);if(o.iridescenceFactor!==void 0)a.setIridescenceFactor(o.iridescenceFactor);if(o.iridescenceIor!==void 0)a.setIridescenceIOR(o.iridescenceIor);if(o.iridescenceThicknessMinimum!==void 0)a.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum);if(o.iridescenceThicknessMaximum!==void 0)a.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum);if(o.iridescenceTexture!==void 0){let c=o.iridescenceTexture,l=e.textures[i[c.index].source];a.setIridescenceTexture(l),e.setTextureInfo(a.getIridescenceTextureInfo(),c)}if(o.iridescenceThicknessTexture!==void 0){let c=o.iridescenceThicknessTexture,l=e.textures[i[c.index].source];a.setIridescenceThicknessTexture(l),e.setTextureInfo(a.getIridescenceThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ls);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ls]=a,i.getIridescenceFactor()>0)a.iridescenceFactor=i.getIridescenceFactor();if(i.getIridescenceIOR()!==1.3)a.iridescenceIor=i.getIridescenceIOR();if(i.getIridescenceThicknessMinimum()!==100)a.iridescenceThicknessMinimum=i.getIridescenceThicknessMinimum();if(i.getIridescenceThicknessMaximum()!==400)a.iridescenceThicknessMaximum=i.getIridescenceThicknessMaximum();if(i.getIridescenceTexture()){let o=i.getIridescenceTexture(),c=i.getIridescenceTextureInfo();a.iridescenceTexture=e.createTextureInfoDef(o,c)}if(i.getIridescenceThicknessTexture()){let o=i.getIridescenceThicknessTexture(),c=i.getIridescenceThicknessTextureInfo();a.iridescenceThicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:qS,G:JS,B:ZS,A:YS}=Ei,M2=class extends nt{static EXTENSION_NAME=Fs;init(){this.extensionName=Fs,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new At(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new At(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:qS|JS|ZS|YS,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:qS|JS|ZS|YS})}},lw=class extends xt{static EXTENSION_NAME=Fs;extensionName=Fs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createPBRSpecularGlossiness(){return new M2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_pbrSpecularGlossiness){let a=this.createPBRSpecularGlossiness();e.materials[s].setExtension(Fs,a);let o=r.extensions[Fs];if(o.extras)a.setExtras(o.extras);if(o.diffuseFactor!==void 0)a.setDiffuseFactor(o.diffuseFactor);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.glossinessFactor!==void 0)a.setGlossinessFactor(o.glossinessFactor);if(o.diffuseTexture!==void 0){let c=o.diffuseTexture,l=e.textures[i[c.index].source];a.setDiffuseTexture(l),e.setTextureInfo(a.getDiffuseTextureInfo(),c)}if(o.specularGlossinessTexture!==void 0){let c=o.specularGlossinessTexture,l=e.textures[i[c.index].source];a.setSpecularGlossinessTexture(l),e.setTextureInfo(a.getSpecularGlossinessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Fs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Fs]=a,a.diffuseFactor=i.getDiffuseFactor(),a.specularFactor=i.getSpecularFactor(),a.glossinessFactor=i.getGlossinessFactor(),i.getDiffuseTexture()){let o=i.getDiffuseTexture(),c=i.getDiffuseTextureInfo();a.diffuseTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularGlossinessTexture()){let o=i.getSpecularGlossinessTexture(),c=i.getSpecularGlossinessTextureInfo();a.specularGlossinessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:R2,G:I2,B:C2,A:N2}=Ei,P2=class extends nt{static EXTENSION_NAME=Us;init(){this.extensionName=Us,this.propertyType="Sheen",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new At(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new At(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:R2|I2|C2,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:N2})}},O2=class extends xt{static EXTENSION_NAME=Us;extensionName=Us;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createSheen(){return new P2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_sheen){let a=this.createSheen();e.materials[s].setExtension(Us,a);let o=r.extensions[Us];if(o.extras)a.setExtras(o.extras);if(o.sheenColorFactor!==void 0)a.setSheenColorFactor(o.sheenColorFactor);if(o.sheenRoughnessFactor!==void 0)a.setSheenRoughnessFactor(o.sheenRoughnessFactor);if(o.sheenColorTexture!==void 0){let c=o.sheenColorTexture,l=e.textures[i[c.index].source];a.setSheenColorTexture(l),e.setTextureInfo(a.getSheenColorTextureInfo(),c)}if(o.sheenRoughnessTexture!==void 0){let c=o.sheenRoughnessTexture,l=e.textures[i[c.index].source];a.setSheenRoughnessTexture(l),e.setTextureInfo(a.getSheenRoughnessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Us);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Us]=a,a.sheenColorFactor=i.getSheenColorFactor(),a.sheenRoughnessFactor=i.getSheenRoughnessFactor(),i.getSheenColorTexture()){let o=i.getSheenColorTexture(),c=i.getSheenColorTextureInfo();a.sheenColorTexture=e.createTextureInfoDef(o,c)}if(i.getSheenRoughnessTexture()){let o=i.getSheenRoughnessTexture(),c=i.getSheenRoughnessTextureInfo();a.sheenRoughnessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:k2,G:D2,B:L2,A:F2}=Ei,U2=class extends nt{static EXTENSION_NAME=Bs;init(){this.extensionName=Bs,this.propertyType="Specular",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new At(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new At(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:F2})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:k2|D2|L2,isColor:!0})}},uw=class extends xt{static EXTENSION_NAME=Bs;extensionName=Bs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createSpecular(){return new U2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_specular){let a=this.createSpecular();e.materials[s].setExtension(Bs,a);let o=r.extensions[Bs];if(o.extras)a.setExtras(o.extras);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.specularColorFactor!==void 0)a.setSpecularColorFactor(o.specularColorFactor);if(o.specularTexture!==void 0){let c=o.specularTexture,l=e.textures[i[c.index].source];a.setSpecularTexture(l),e.setTextureInfo(a.getSpecularTextureInfo(),c)}if(o.specularColorTexture!==void 0){let c=o.specularColorTexture,l=e.textures[i[c.index].source];a.setSpecularColorTexture(l),e.setTextureInfo(a.getSpecularColorTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Bs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Bs]=a,i.getSpecularFactor()!==1)a.specularFactor=i.getSpecularFactor();if(!pt.eq(i.getSpecularColorFactor(),[1,1,1]))a.specularColorFactor=i.getSpecularColorFactor();if(i.getSpecularTexture()){let o=i.getSpecularTexture(),c=i.getSpecularTextureInfo();a.specularTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularColorTexture()){let o=i.getSpecularColorTexture(),c=i.getSpecularColorTextureInfo();a.specularColorTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:B2}=Ei,z2=class extends nt{static EXTENSION_NAME=zs;init(){this.extensionName=zs,this.propertyType="Transmission",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new At(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:B2})}},V2=class extends xt{static EXTENSION_NAME=zs;extensionName=zs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createTransmission(){return new z2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_transmission){let a=this.createTransmission();e.materials[s].setExtension(zs,a);let o=r.extensions[zs];if(o.extras)a.setExtras(o.extras);if(o.transmissionFactor!==void 0)a.setTransmissionFactor(o.transmissionFactor);if(o.transmissionTexture!==void 0){let c=o.transmissionTexture,l=e.textures[i[c.index].source];a.setTransmissionTexture(l),e.setTextureInfo(a.getTransmissionTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(zs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[zs]=a,a.transmissionFactor=i.getTransmissionFactor(),i.getTransmissionTexture()){let o=i.getTransmissionTexture(),c=i.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(o,c)}}}),this}},j2=class extends nt{static EXTENSION_NAME=jo;init(){this.extensionName=jo,this.propertyType="Unlit",this.parentTypes=[ne.MATERIAL]}},dw=class extends xt{static EXTENSION_NAME=jo;extensionName=jo;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createUnlit(){return new j2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_unlit)e.materials[n].setExtension(jo,this.createUnlit())}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{if(n.getExtension("KHR_materials_unlit")){let i=e.materialIndexMap.get(n),r=t.json.materials[i];r.extensions=r.extensions||{},r.extensions[jo]={}}}),this}},H2=class extends nt{static EXTENSION_NAME=ui;init(){this.extensionName=ui,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new Rt})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}},G2=class extends nt{static EXTENSION_NAME=ui;init(){this.extensionName=ui,this.propertyType="MappingList",this.parentTypes=[ne.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new Rt})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}},QS=class extends nt{static EXTENSION_NAME=ui;init(){this.extensionName=ui,this.propertyType="Variant",this.parentTypes=["MappingList"]}},$2=class extends xt{extensionName=ui;static EXTENSION_NAME=ui;createMappingList(){return new G2(this.document.getGraph())}createVariant(e=""){return new QS(this.document.getGraph(),e)}createMapping(){return new H2(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((e)=>e instanceof QS)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_materials_variants)return this;let n=(t.json.extensions.KHR_materials_variants.variants||[]).map((i)=>this.createVariant().setName(i.name||""));return(t.json.meshes||[]).forEach((i,r)=>{let s=e.meshes[r];(i.primitives||[]).forEach((a,o)=>{if(!a.extensions||!a.extensions.KHR_materials_variants)return;let c=this.createMappingList(),l=a.extensions[ui];for(let u of l.mappings){let d=this.createMapping();if(u.material!==void 0)d.setMaterial(e.materials[u.material]);for(let f of u.variants||[])d.addVariant(n[f]);c.addMapping(d)}s.listPrimitives()[o].setExtension(ui,c)})}),this}write(e){let t=e.jsonDoc,n=this.listVariants();if(!n.length)return this;let i=[],r=new Map;for(let s of n)r.set(s,i.length),i.push(e.createPropertyDef(s));for(let s of this.document.getRoot().listMeshes()){let a=e.meshIndexMap.get(s);s.listPrimitives().forEach((o,c)=>{let l=o.getExtension(ui);if(!l)return;let u=e.jsonDoc.json.meshes[a].primitives[c],d=l.listMappings().map((f)=>{let h=e.createPropertyDef(f),y=f.getMaterial();if(y)h.material=e.materialIndexMap.get(y);return h.variants=f.listVariants().map((g)=>r.get(g)),h});u.extensions=u.extensions||{},u.extensions[ui]={mappings:d}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ui]={variants:i},this}},{G:K2}=Ei,W2=class extends nt{static EXTENSION_NAME=Vs;init(){this.extensionName=Vs,this.propertyType="Volume",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new At(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:K2})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}},X2=class extends xt{static EXTENSION_NAME=Vs;extensionName=Vs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createVolume(){return new W2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_volume){let a=this.createVolume();e.materials[s].setExtension(Vs,a);let o=r.extensions[Vs];if(o.extras)a.setExtras(o.extras);if(o.thicknessFactor!==void 0)a.setThicknessFactor(o.thicknessFactor);if(o.attenuationDistance!==void 0)a.setAttenuationDistance(o.attenuationDistance);if(o.attenuationColor!==void 0)a.setAttenuationColor(o.attenuationColor);if(o.thicknessTexture!==void 0){let c=o.thicknessTexture,l=e.textures[i[c.index].source];a.setThicknessTexture(l),e.setTextureInfo(a.getThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Vs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Vs]=a,i.getThicknessFactor()>0)a.thicknessFactor=i.getThicknessFactor();if(Number.isFinite(i.getAttenuationDistance()))a.attenuationDistance=i.getAttenuationDistance();if(!pt.eq(i.getAttenuationColor(),[1,1,1]))a.attenuationColor=i.getAttenuationColor();if(i.getThicknessTexture()){let o=i.getThicknessTexture(),c=i.getThicknessTextureInfo();a.thicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},fw=class extends xt{extensionName=LS;static EXTENSION_NAME=LS;read(e){return this}write(e){return this}},wg=class extends xt{extensionName=FS;static EXTENSION_NAME=FS;read(e){return this}write(e){return this}},q2=class extends nt{static EXTENSION_NAME=js;init(){this.extensionName=js,this.propertyType="Visibility",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{visible:!0})}getVisible(){return this.get("visible")}setVisible(e){return this.set("visible",e)}},J2=class extends xt{static EXTENSION_NAME=js;extensionName=js;createVisibility(){return new q2(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_node_visibility){let i=this.createVisibility();e.nodes[n].setExtension(js,i);let r=t.extensions[js];if(r.visible!==void 0)i.setVisible(r.visible)}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listNodes()){let i=n.getExtension(js);if(!i)continue;let r=e.nodeIndexMap.get(n),s=t.json.nodes[r];s.extensions=s.extensions||{},s.extensions[js]={visible:i.getVisible()}}return this}};Mg=class extends xt{static EXTENSION_NAME=Gd;extensionName=Gd;prereadTypes=[ne.TEXTURE];static register(){ji.registerFormat("image/ktx2",new Y2)}preread(e){if(e.jsonDoc.json.textures)e.jsonDoc.json.textures.forEach((t)=>{if(t.extensions&&t.extensions.KHR_texture_basisu)t.source=t.extensions[Gd].source});return this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/ktx2"){let i=e.imageIndexMap.get(n);t.json.textures.forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[Gd]={source:r.source},delete r.source})}}),this}},Q2=class extends nt{static EXTENSION_NAME=Hs;init(){this.extensionName=Hs,this.propertyType="Transform",this.parentTypes=[ne.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}},eU=class extends xt{extensionName=Hs;static EXTENSION_NAME=Hs;createTransform(){return new Q2(this.document.getGraph())}read(e){for(let[t,n]of Array.from(e.textureInfos.entries())){if(!n.extensions||!n.extensions.KHR_texture_transform)continue;let i=this.createTransform(),r=n.extensions[Hs];if(r.offset!==void 0)i.setOffset(r.offset);if(r.rotation!==void 0)i.setRotation(r.rotation);if(r.scale!==void 0)i.setScale(r.scale);if(r.texCoord!==void 0)i.setTexCoord(r.texCoord);t.setExtension(Hs,i)}return this}write(e){let t=Array.from(e.textureInfoDefMap.entries());for(let[n,i]of t){let r=n.getExtension(Hs);if(!r)continue;i.extensions=i.extensions||{};let s={},a=pt.eq;if(!a(r.getOffset(),[0,0]))s.offset=r.getOffset();if(r.getRotation()!==0)s.rotation=r.getRotation();if(!a(r.getScale(),[1,1]))s.scale=r.getScale();if(r.getTexCoord()!=null)s.texCoord=r.getTexCoord();i.extensions[Hs]=s}return this}},tU=[ne.ROOT,ne.SCENE,ne.NODE,ne.MESH,ne.MATERIAL,ne.TEXTURE,ne.ANIMATION],nU=class extends nt{static EXTENSION_NAME=Hi;init(){this.extensionName=Hi,this.propertyType="Packet",this.parentTypes=tU}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",{...e})}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){let t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);let n={...this.get("properties")};if(t)n[e]=t;else delete n[e];return this.set("properties",n)}toJSONLD(){return{"@context":Eg(this.get("context")),...Eg(this.get("properties"))}}fromJSONLD(e){e=Eg(e);let t=e["@context"];if(t)this.set("context",t);return delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw Error(`${Hi}: Missing context for term, "${e}".`)}};iU=class extends xt{extensionName=Hi;static EXTENSION_NAME=Hi;createPacket(){return new nU(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){let t=e.jsonDoc.json.extensions?.[Hi];if(!t||!t.packets)return this;let n=e.jsonDoc.json,i=this.document.getRoot(),r=t.packets.map((o)=>this.createPacket().fromJSONLD(o)),s=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],a=[[i],i.listScenes(),i.listNodes(),i.listMeshes(),i.listMaterials(),i.listTextures(),i.listAnimations()];for(let o=0;o<s.length;o++){let c=s[o]||[];for(let l=0;l<c.length;l++){let u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){let d=u.extensions[Hi];a[o][l].setExtension(Hi,r[d.packet])}}}return this}write(e){let{json:t}=e.jsonDoc,n=[];for(let i of this.properties){n.push(i.toJSONLD());for(let r of i.listParents()){let s;switch(r.propertyType){case ne.ROOT:s=t.asset;break;case ne.SCENE:s=t.scenes[e.sceneIndexMap.get(r)];break;case ne.NODE:s=t.nodes[e.nodeIndexMap.get(r)];break;case ne.MESH:s=t.meshes[e.meshIndexMap.get(r)];break;case ne.MATERIAL:s=t.materials[e.materialIndexMap.get(r)];break;case ne.TEXTURE:s=t.images[e.imageIndexMap.get(r)];break;case ne.ANIMATION:s=t.animations[e.animationIndexMap.get(r)];break;default:s=null,this.document.getLogger().warn(`[${Hi}]: Unsupported parent property, "${r.propertyType}"`)}if(!s)continue;s.extensions=s.extensions||{},s.extensions[Hi]={packet:n.length-1}}}if(n.length>0)t.extensions=t.extensions||{},t.extensions[Hi]={packets:n};return this}},rU=[$F,KF,ow,i2,c2,d2,b2,x2,v2,cw,w2,lw,uw,O2,V2,dw,$2,X2,fw,wg,J2,Mg,eU,iU],hw=[$d,j8,pl,bF,nw,iw,...rU]});var mw=Xr(function(j$,pw){function sU(e){var t=Array(e);for(var n=0;n<e;++n)t[n]=n;return t}pw.exports=sU});var yw=Xr(function(H$,bw){/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh <https://feross.org>
+ * @license MIT
+ */bw.exports=function(e){return e!=null&&(gw(e)||aU(e)||!!e._isBuffer)};function gw(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function aU(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&gw(e.slice(0,0))}});var Rg=Xr(function(G$,xw){var oU=mw(),cU=yw(),lU=typeof Float64Array<"u";function uU(e,t){return e[0]-t[0]}function dU(){var e=this.stride,t=Array(e.length),n;for(n=0;n<t.length;++n)t[n]=[Math.abs(e[n]),n];t.sort(uU);var i=Array(t.length);for(n=0;n<i.length;++n)i[n]=t[n][1];return i}function fU(e,t){var n=["View",t,"d",e].join("");if(t<0)n="View_Nil"+e;var i=e==="generic";if(t===-1){var r="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",g=Function(r);return g()}else if(t===0){var r="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",g=Function("TrivialArray",r);return g(Wd[e][0])}var r=["'use strict'"],s=oU(t),a=s.map(function(m){return"i"+m}),o="this.offset+"+s.map(function(m){return"this.stride["+m+"]*i"+m}).join("+"),c=s.map(function(m){return"b"+m}).join(","),l=s.map(function(m){return"c"+m}).join(",");if(r.push("function "+n+"(a,"+c+","+l+",d){this.data=a","this.shape=["+c+"]","this.stride=["+l+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+s.map(function(m){return"this.shape["+m+"]"}).join("*"),"}})"),t===1)r.push("proto.order=[0]");else if(r.push("Object.defineProperty(proto,'order',{get:"),t<4){if(r.push("function "+n+"_order(){"),t===2)r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})");else if(t===3)r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")}else r.push("ORDER})");if(r.push("proto.set=function "+n+"_set("+a.join(",")+",v){"),i)r.push("return this.data.set("+o+",v)}");else r.push("return this.data["+o+"]=v}");if(r.push("proto.get=function "+n+"_get("+a.join(",")+"){"),i)r.push("return this.data.get("+o+")}");else r.push("return this.data["+o+"]}");r.push("proto.index=function "+n+"_index(",a.join(),"){return "+o+"}"),r.push("proto.hi=function "+n+"_hi("+a.join(",")+"){return new "+n+"(this.data,"+s.map(function(m){return["(typeof i",m,"!=='number'||i",m,"<0)?this.shape[",m,"]:i",m,"|0"].join("")}).join(",")+","+s.map(function(m){return"this.stride["+m+"]"}).join(",")+",this.offset)}");var u=s.map(function(m){return"a"+m+"=this.shape["+m+"]"}),d=s.map(function(m){return"c"+m+"=this.stride["+m+"]"});r.push("proto.lo=function "+n+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+u.join(",")+","+d.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+n+"(this.data,"+s.map(function(m){return"a"+m}).join(",")+","+s.map(function(m){return"c"+m}).join(",")+",b)}"),r.push("proto.step=function "+n+"_step("+a.join(",")+"){var "+s.map(function(m){return"a"+m+"=this.shape["+m+"]"}).join(",")+","+s.map(function(m){return"b"+m+"=this.stride["+m+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+n+"(this.data,"+s.map(function(m){return"a"+m}).join(",")+","+s.map(function(m){return"b"+m}).join(",")+",c)}");var h=Array(t),y=Array(t);for(var f=0;f<t;++f)h[f]="a[i"+f+"]",y[f]="b[i"+f+"]";r.push("proto.transpose=function "+n+"_transpose("+a+"){"+a.map(function(m,p){return m+"=("+m+"===undefined?"+p+":"+m+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+h.join(",")+","+y.join(",")+",this.offset)}"),r.push("proto.pick=function "+n+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+s.map(function(m){return"shape["+m+"]"}).join(",")+","+s.map(function(m){return"stride["+m+"]"}).join(",")+",offset)}");var g=Function("CTOR_LIST","ORDER",r.join(`
+`));return g(Wd[e],dU)}function hU(e){if(cU(e))return"buffer";if(lU)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}if(Array.isArray(e))return"array";return"generic"}var Wd={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function pU(e,t,n,i){if(e===void 0){var l=Wd.array[0];return l([])}else if(typeof e==="number")e=[e];if(t===void 0)t=[e.length];var r=t.length;if(n===void 0){n=Array(r);for(var s=r-1,a=1;s>=0;--s)n[s]=a,a*=t[s]}if(i===void 0){i=0;for(var s=0;s<r;++s)if(n[s]<0)i-=(t[s]-1)*n[s]}var o=hU(e),c=Wd[o];while(c.length<=r+1)c.push(fU(o,c.length-1));var l=c[r+1];return l(e,t,n,i)}xw.exports=pU});var vw=Xr(function($$,_w){function mU(e,t){var n=1,i=e.length,r=e[0],s=e[0];for(var a=1;a<i;++a)if(s=r,r=e[a],t(r,s)){if(a===n){n++;continue}e[n++]=r}return e.length=n,e}function gU(e){var t=1,n=e.length,i=e[0],r=e[0];for(var s=1;s<n;++s,r=i)if(r=i,i=e[s],i!==r){if(s===t){t++;continue}e[t++]=i}return e.length=t,e}function bU(e,t,n){if(e.length===0)return e;if(t){if(!n)e.sort(t);return mU(e,t)}if(!n)e.sort();return gU(e)}_w.exports=bU});var Aw=Xr(function(K$,Tw){var yU=vw();function Ew(e,t,n){var i=e.length,r=t.arrayArgs.length,s=t.indexArgs.length>0,a=[],o=[],c=0,l=0,u,d;for(u=0;u<i;++u)o.push(["i",u,"=0"].join(""));for(d=0;d<r;++d)for(u=0;u<i;++u)if(l=c,c=e[u],u===0)o.push(["d",d,"s",u,"=t",d,"p",c].join(""));else o.push(["d",d,"s",u,"=(t",d,"p",c,"-s",l,"*t",d,"p",l,")"].join(""));if(o.length>0)a.push("var "+o.join(","));for(u=i-1;u>=0;--u)c=e[u],a.push(["for(i",u,"=0;i",u,"<s",c,";++i",u,"){"].join(""));a.push(n);for(u=0;u<i;++u){l=c,c=e[u];for(d=0;d<r;++d)a.push(["p",d,"+=d",d,"s",u].join(""));if(s){if(u>0)a.push(["index[",l,"]-=s",l].join(""));a.push(["++index[",c,"]"].join(""))}a.push("}")}return a.join(`
+`)}function xU(e,t,n,i){var r=t.length,s=n.arrayArgs.length,a=n.blockSize,o=n.indexArgs.length>0,c=[];for(var l=0;l<s;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;l<r;++l)if(c.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",a,"){"].join("")),c.push(["s",t[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",t[l],"=",a].join("")),c.push(["j",l,"-=",a,"}"].join("")),o)c.push(["index[",t[l],"]=j",l].join(""));for(var l=0;l<s;++l){var u=["offset"+l];for(var d=e;d<r;++d)u.push(["j",d,"*t",l,"p",t[d]].join(""));c.push(["p",l,"=(",u.join("+"),")"].join(""))}c.push(Ew(t,n,i));for(var l=e;l<r;++l)c.push("}");return c.join(`
+`)}function _U(e){var t=0,n=e[0].length;while(t<n){for(var i=1;i<e.length;++i)if(e[i][t]!==e[0][t])return t;++t}return t}function Ig(e,t,n){var i=e.body,r=[],s=[];for(var a=0;a<e.args.length;++a){var o=e.args[a];if(o.count<=0)continue;var c=new RegExp(o.name,"g"),l="",u=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),f=t.offsetArgs[d];u=f.array,l="+q"+d;case"array":l="p"+u+l;var h="l"+a,y="a"+u;if(t.arrayBlockIndices[u]===0){if(o.count===1)if(n[u]==="generic")if(o.lvalue)r.push(["var ",h,"=",y,".get(",l,")"].join("")),i=i.replace(c,h),s.push([y,".set(",l,",",h,")"].join(""));else i=i.replace(c,[y,".get(",l,")"].join(""));else i=i.replace(c,[y,"[",l,"]"].join(""));else if(n[u]==="generic"){if(r.push(["var ",h,"=",y,".get(",l,")"].join("")),i=i.replace(c,h),o.lvalue)s.push([y,".set(",l,",",h,")"].join(""))}else if(r.push(["var ",h,"=",y,"[",l,"]"].join("")),i=i.replace(c,h),o.lvalue)s.push([y,"[",l,"]=",h].join(""))}else{var g=[o.name],m=[l];for(var p=0;p<Math.abs(t.arrayBlockIndices[u]);p++)g.push("\\s*\\[([^\\]]+)\\]"),m.push("$"+(p+1)+"*t"+u+"b"+p);if(c=new RegExp(g.join(""),"g"),l=m.join("+"),n[u]==="generic")throw Error("cwise: Generic arrays not supported in combination with blocks!");else i=i.replace(c,[y,"[",l,"]"].join(""))}break;case"scalar":i=i.replace(c,"Y"+t.scalarArgs.indexOf(a));break;case"index":i=i.replace(c,"index");break;case"shape":i=i.replace(c,"shape");break}}return[r.join(`
+`),i,s.join(`
+`)].join(`
+`).trim()}function vU(e){var t=Array(e.length),n=!0;for(var i=0;i<e.length;++i){var r=e[i],s=r.match(/\d+/);if(!s)s="";else s=s[0];if(r.charAt(0)===0)t[i]="u"+r.charAt(1)+s;else t[i]=r.charAt(0)+s;if(i>0)n=n&&t[i]===t[i-1]}if(n)return t[0];return t.join("")}function EU(e,t){var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,i=Array(e.arrayArgs.length),r=Array(e.arrayArgs.length);for(var s=0;s<e.arrayArgs.length;++s)r[s]=t[2*s],i[s]=t[2*s+1];var a=[],o=[],c=[],l=[],u=[];for(var s=0;s<e.arrayArgs.length;++s){if(e.arrayBlockIndices[s]<0)c.push(0),l.push(n),a.push(n),o.push(n+e.arrayBlockIndices[s]);else c.push(e.arrayBlockIndices[s]),l.push(e.arrayBlockIndices[s]+n),a.push(0),o.push(e.arrayBlockIndices[s]);var d=[];for(var f=0;f<i[s].length;f++)if(c[s]<=i[s][f]&&i[s][f]<l[s])d.push(i[s][f]-c[s]);u.push(d)}var h=["SS"],y=["'use strict'"],g=[];for(var f=0;f<n;++f)g.push(["s",f,"=SS[",f,"]"].join(""));for(var s=0;s<e.arrayArgs.length;++s){h.push("a"+s),h.push("t"+s),h.push("p"+s);for(var f=0;f<n;++f)g.push(["t",s,"p",f,"=t",s,"[",c[s]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[s]);++f)g.push(["t",s,"b",f,"=t",s,"[",a[s]+f,"]"].join(""))}for(var s=0;s<e.scalarArgs.length;++s)h.push("Y"+s);if(e.shapeArgs.length>0)g.push("shape=SS.slice(0)");if(e.indexArgs.length>0){var m=Array(n);for(var s=0;s<n;++s)m[s]="0";g.push(["index=[",m.join(","),"]"].join(""))}for(var s=0;s<e.offsetArgs.length;++s){var p=e.offsetArgs[s],b=[];for(var f=0;f<p.offset.length;++f)if(p.offset[f]===0)continue;else if(p.offset[f]===1)b.push(["t",p.array,"p",f].join(""));else b.push([p.offset[f],"*t",p.array,"p",f].join(""));if(b.length===0)g.push("q"+s+"=0");else g.push(["q",s,"=",b.join("+")].join(""))}var _=yU([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));if(g=g.concat(_),g.length>0)y.push("var "+g.join(","));for(var s=0;s<e.arrayArgs.length;++s)y.push("p"+s+"|=0");if(e.pre.body.length>3)y.push(Ig(e.pre,e,r));var x=Ig(e.body,e,r),v=_U(u);if(v<n)y.push(xU(v,u[0],e,x));else y.push(Ew(u[0],e,x));if(e.post.body.length>3)y.push(Ig(e.post,e,r));if(e.debug)console.log("-----Generated cwise routine for ",t,`:
+`+y.join(`
`)+`
-`+p,g=["#define varying in",n.glslVersion===af?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===af?"":"#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(`
+----------`);var E=[e.funcName||"unnamed","_cwise_loop_",i[0].join("s"),"m",v,vU(r)].join(""),S=Function(["function ",E,"(",h.join(","),"){",y.join(`
+`),"} return ",E].join(""));return S()}Tw.exports=EU});var ww=Xr(function(W$,Sw){var TU=Aw();function AU(e){var t=["'use strict'","var CACHED={}"],n=[],i=e.funcName+"_cwise_thunk";t.push(["return function ",i,"(",e.shimArgs.join(","),"){"].join(""));var r=[],s=[],a=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],o=[],c=[];for(var l=0;l<e.arrayArgs.length;++l){var u=e.arrayArgs[l];if(n.push(["t",u,"=array",u,".dtype,","r",u,"=array",u,".order"].join("")),r.push("t"+u),r.push("r"+u),s.push("t"+u),s.push("r"+u+".join()"),a.push("array"+u+".data"),a.push("array"+u+".stride"),a.push("array"+u+".offset|0"),l>0)o.push("array"+e.arrayArgs[0]+".shape.length===array"+u+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+u+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]")}if(e.arrayArgs.length>1)t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}");for(var l=0;l<e.scalarArgs.length;++l)a.push("scalar"+e.scalarArgs[l]);if(n.push(["type=[",s.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),t.push("var "+n.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",a.join(","),")}"].join("")),e.debug)console.log(`-----Generated thunk:
+`+t.join(`
`)+`
-`+g;let S=y+p+o,x=y+g+a,b=Qy(r,r.VERTEX_SHADER,S),M=Qy(r,r.FRAGMENT_SHADER,x);if(r.attachShader(_,b),r.attachShader(_,M),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function T(C){if(e.debug.checkShaderErrors){let N=r.getProgramInfoLog(_)||"",Y=r.getShaderInfoLog(b)||"",D=r.getShaderInfoLog(M)||"",W=N.trim(),z=Y.trim(),P=D.trim(),q=!0,H=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(q=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,b,M);else{let ee=tb(r,b,"vertex"),J=tb(r,M,"fragment");je("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
-
-Material Name: `+C.name+`
-Material Type: `+C.type+`
-
-Program Info Log: `+W+`
-`+ee+`
-`+J)}else if(W!=="")ze("WebGLProgram: Program Info Log:",W);else if(z===""||P==="")H=!1;if(H)C.diagnostics={runnable:q,programLog:W,vertexShader:{log:z,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(b),r.deleteShader(M),v=new Ga(r,_),A=oI(r,_)}let v;this.getUniforms=function(){if(v===void 0)T(this);return v};let A;this.getAttributes=function(){if(A===void 0)T(this);return A};let V=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(V===!1)V=r.getProgramParameter(_,YC);return V},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=JC++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=b,this.fragmentShader=M,this}var SI=0;class vb{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 yb(e),t.set(e,n);return n}}class yb{constructor(e){this.id=SI++,this.code=e,this.usedTimes=0}}function wI(e){return e===ds||e===Il||e===Pl}function MI(e,t,n,i,r,s){let o=new Ul,a=new vb,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(v){if(c.add(v),v===0)return"uv";return`uv${v}`}function _(v,A,V,C,N,Y){let D=C.fog,W=N.geometry,z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?C.environment:null,P=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,q=t.get(v.envMap||z,P),H=!!q&&q.mapping===Sa?q.image.height:null,ee=f[v.type];if(v.precision!==null){if(d=i.getMaxPrecision(v.precision),d!==v.precision)ze("WebGLProgram.getParameters:",v.precision,"not supported, using",d,"instead.")}let J=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,de=J!==void 0?J.length:0,pe=0;if(W.morphAttributes.position!==void 0)pe=1;if(W.morphAttributes.normal!==void 0)pe=2;if(W.morphAttributes.color!==void 0)pe=3;let Be,me,X,L;if(ee){let Ct=Bi[ee];Be=Ct.vertexShader,me=Ct.fragmentShader}else{Be=v.vertexShader,me=v.fragmentShader;let Ct=a.getVertexShaderStage(v),_t=a.getFragmentShaderStage(v);a.update(v,Ct,_t),X=Ct.id,L=_t.id}let G=e.getRenderTarget(),te=e.state.buffers.depth.getReversed(),se=N.isInstancedMesh===!0,ce=N.isBatchedMesh===!0,Ae=!!v.map,Te=!!v.matcap,Ue=!!q,$e=!!v.aoMap,Xe=!!v.lightMap,Ot=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,Mt=!!v.displacementMap,Bt=!!v.emissiveMap,Ht=!!v.metalnessMap,O=!!v.roughnessMap,en=v.anisotropy>0,gt=v.clearcoat>0,Ut=v.dispersion>0,R=v.retroreflectivity>0,w=v.iridescence>0,U=v.sheen>0,K=v.transmission>0,ue=en&&!!v.anisotropyMap,fe=gt&&!!v.clearcoatMap,ve=gt&&!!v.clearcoatNormalMap,ne=gt&&!!v.clearcoatRoughnessMap,oe=w&&!!v.iridescenceMap,Ee=w&&!!v.iridescenceThicknessMap,Fe=U&&!!v.sheenColorMap,ye=U&&!!v.sheenRoughnessMap,he=!!v.specularMap,Ve=!!v.specularColorMap,We=!!v.specularIntensityMap,ft=K&&!!v.transmissionMap,B=K&&!!v.thicknessMap,ge=!!v.gradientMap,re=!!v.alphaMap,xe=v.alphaTest>0,Re=!!v.alphaHash,le=!!v.extensions,Se=ui;if(v.toneMapped){if(G===null||G.isXRRenderTarget===!0)Se=e.toneMapping}let Je={shaderID:ee,shaderType:v.type,shaderName:v.name,vertexShader:Be,fragmentShader:me,defines:v.defines,customVertexShaderID:X,customFragmentShaderID:L,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:d,batching:ce,batchingColor:ce&&N._colorsTexture!==null,instancing:se,instancingColor:se&&N.instanceColor!==null,instancingMorph:se&&N.morphTexture!==null,outputColorSpace:G===null?e.outputColorSpace:G.isXRRenderTarget===!0?G.texture.colorSpace:nt.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Ae,matcap:Te,envMap:Ue,envMapMode:Ue&&q.mapping,envMapCubeUVHeight:H,aoMap:$e,lightMap:Xe,bumpMap:Ot,normalMap:rt,displacementMap:Mt,emissiveMap:Bt,normalMapObjectSpace:rt&&v.normalMapType===wy,normalMapTangentSpace:rt&&v.normalMapType===sf,packedNormalMap:rt&&v.normalMapType===sf&&wI(v.normalMap.format),metalnessMap:Ht,roughnessMap:O,anisotropy:en,anisotropyMap:ue,clearcoat:gt,clearcoatMap:fe,clearcoatNormalMap:ve,clearcoatRoughnessMap:ne,dispersion:Ut,retroreflection:R,iridescence:w,iridescenceMap:oe,iridescenceThicknessMap:Ee,sheen:U,sheenColorMap:Fe,sheenRoughnessMap:ye,specularMap:he,specularColorMap:Ve,specularIntensityMap:We,transmission:K,transmissionMap:ft,thicknessMap:B,gradientMap:ge,opaque:v.transparent===!1&&v.blending===ya&&v.alphaToCoverage===!1,alphaMap:re,alphaTest:xe,alphaHash:Re,combine:v.combine,mapUv:Ae&&m(v.map.channel),aoMapUv:$e&&m(v.aoMap.channel),lightMapUv:Xe&&m(v.lightMap.channel),bumpMapUv:Ot&&m(v.bumpMap.channel),normalMapUv:rt&&m(v.normalMap.channel),displacementMapUv:Mt&&m(v.displacementMap.channel),emissiveMapUv:Bt&&m(v.emissiveMap.channel),metalnessMapUv:Ht&&m(v.metalnessMap.channel),roughnessMapUv:O&&m(v.roughnessMap.channel),anisotropyMapUv:ue&&m(v.anisotropyMap.channel),clearcoatMapUv:fe&&m(v.clearcoatMap.channel),clearcoatNormalMapUv:ve&&m(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&m(v.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&m(v.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&m(v.iridescenceThicknessMap.channel),sheenColorMapUv:Fe&&m(v.sheenColorMap.channel),sheenRoughnessMapUv:ye&&m(v.sheenRoughnessMap.channel),specularMapUv:he&&m(v.specularMap.channel),specularColorMapUv:Ve&&m(v.specularColorMap.channel),specularIntensityMapUv:We&&m(v.specularIntensityMap.channel),transmissionMapUv:ft&&m(v.transmissionMap.channel),thicknessMapUv:B&&m(v.thicknessMap.channel),alphaMapUv:re&&m(v.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(rt||en),vertexNormals:!!W.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!W.attributes.uv&&(Ae||re),fog:!!D,useFog:v.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||W.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:te,skinning:N.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:de,morphTextureStride:pe,numSunLights:A.sun.length,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numSunLightShadows:A.sunShadowMap.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:Y.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:v.dithering,shadowMapEnabled:e.shadowMap.enabled&&V.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,decodeVideoTexture:Ae&&v.map.isVideoTexture===!0&&nt.getTransfer(v.map.colorSpace)===Rt,decodeVideoTextureEmissive:Bt&&v.emissiveMap.isVideoTexture===!0&&nt.getTransfer(v.emissiveMap.colorSpace)===Rt,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===Yn,flipSided:v.side===mn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:le&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(le&&v.extensions.multiDraw===!0||ce)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Je.vertexUv1s=c.has(1),Je.vertexUv2s=c.has(2),Je.vertexUv3s=c.has(3),c.clear(),Je}function p(v){let A=[];if(v.shaderID)A.push(v.shaderID);else A.push(v.customVertexShaderID),A.push(v.customFragmentShaderID);if(v.defines!==void 0)for(let V in v.defines)A.push(V),A.push(v.defines[V]);if(v.isRawShaderMaterial===!1)g(A,v),y(A,v),A.push(e.outputColorSpace);return A.push(v.customProgramCacheKey),A.join()}function g(v,A){v.push(A.precision),v.push(A.outputColorSpace),v.push(A.envMapMode),v.push(A.envMapCubeUVHeight),v.push(A.mapUv),v.push(A.alphaMapUv),v.push(A.lightMapUv),v.push(A.aoMapUv),v.push(A.bumpMapUv),v.push(A.normalMapUv),v.push(A.displacementMapUv),v.push(A.emissiveMapUv),v.push(A.metalnessMapUv),v.push(A.roughnessMapUv),v.push(A.anisotropyMapUv),v.push(A.clearcoatMapUv),v.push(A.clearcoatNormalMapUv),v.push(A.clearcoatRoughnessMapUv),v.push(A.iridescenceMapUv),v.push(A.iridescenceThicknessMapUv),v.push(A.sheenColorMapUv),v.push(A.sheenRoughnessMapUv),v.push(A.specularMapUv),v.push(A.specularColorMapUv),v.push(A.specularIntensityMapUv),v.push(A.transmissionMapUv),v.push(A.thicknessMapUv),v.push(A.combine),v.push(A.fogExp2),v.push(A.sizeAttenuation),v.push(A.morphTargetsCount),v.push(A.morphAttributeCount),v.push(A.numSunLights),v.push(A.numDirLights),v.push(A.numPointLights),v.push(A.numSpotLights),v.push(A.numSpotLightMaps),v.push(A.numHemiLights),v.push(A.numRectAreaLights),v.push(A.numSunLightShadows),v.push(A.numDirLightShadows),v.push(A.numPointLightShadows),v.push(A.numSpotLightShadows),v.push(A.numSpotLightShadowsWithMaps),v.push(A.numLightProbes),v.push(A.shadowMapType),v.push(A.toneMapping),v.push(A.numClippingPlanes),v.push(A.numClipIntersection),v.push(A.depthPacking)}function y(v,A){if(o.disableAll(),A.instancing)o.enable(0);if(A.instancingColor)o.enable(1);if(A.instancingMorph)o.enable(2);if(A.matcap)o.enable(3);if(A.envMap)o.enable(4);if(A.normalMapObjectSpace)o.enable(5);if(A.normalMapTangentSpace)o.enable(6);if(A.clearcoat)o.enable(7);if(A.iridescence)o.enable(8);if(A.alphaTest)o.enable(9);if(A.vertexColors)o.enable(10);if(A.vertexAlphas)o.enable(11);if(A.vertexUv1s)o.enable(12);if(A.vertexUv2s)o.enable(13);if(A.vertexUv3s)o.enable(14);if(A.vertexTangents)o.enable(15);if(A.anisotropy)o.enable(16);if(A.alphaHash)o.enable(17);if(A.batching)o.enable(18);if(A.dispersion)o.enable(19);if(A.retroreflection)o.enable(24);if(A.batchingColor)o.enable(20);if(A.gradientMap)o.enable(21);if(A.packedNormalMap)o.enable(22);if(A.vertexNormals)o.enable(23);if(v.push(o.mask),o.disableAll(),A.fog)o.enable(0);if(A.useFog)o.enable(1);if(A.flatShading)o.enable(2);if(A.logarithmicDepthBuffer)o.enable(3);if(A.reversedDepthBuffer)o.enable(4);if(A.skinning)o.enable(5);if(A.morphTargets)o.enable(6);if(A.morphNormals)o.enable(7);if(A.morphColors)o.enable(8);if(A.premultipliedAlpha)o.enable(9);if(A.shadowMapEnabled)o.enable(10);if(A.doubleSided)o.enable(11);if(A.flipSided)o.enable(12);if(A.useDepthPacking)o.enable(13);if(A.dithering)o.enable(14);if(A.transmission)o.enable(15);if(A.sheen)o.enable(16);if(A.opaque)o.enable(17);if(A.pointsUvs)o.enable(18);if(A.decodeVideoTexture)o.enable(19);if(A.decodeVideoTextureEmissive)o.enable(20);if(A.alphaToCoverage)o.enable(21);if(A.numLightProbeGrids>0)o.enable(22);if(A.hasPositionAttribute)o.enable(23);v.push(o.mask)}function S(v){let A=f[v.type],V;if(A){let C=Bi[A];V=Oy.clone(C.uniforms)}else V=v.uniforms;return V}function x(v,A){let V=u.get(A);if(V!==void 0)++V.usedTimes;else V=new bI(e,A,v,r),l.push(V),u.set(A,V);return V}function b(v){if(--v.usedTimes===0){let A=l.indexOf(v);l[A]=l[l.length-1],l.pop(),u.delete(v.cacheKey),v.destroy()}}function M(v){a.remove(v)}function T(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:S,acquireProgram:x,releaseProgram:b,releaseShaderCache:M,programs:l,dispose:T}}function EI(){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 AI(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 ob(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 ab(){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 y=e[t];if(y===void 0)y={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=y;else y.id=d.id,y.object=d,y.geometry=f,y.material=m,y.materialVariant=o(d),y.groupOrder=_,y.renderOrder=d.renderOrder,y.z=p,y.group=g;return t++,y}function c(d,f,m,_,p,g,y){if(y.reversedDepth===!0)p=-p;let S=a(d,f,m,_,p,g);if(m.transmission>0)i.push(S);else if(m.transparent===!0)r.push(S);else n.push(S)}function l(d,f,m,_,p,g){let y=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(y);else if(m.transparent===!0)r.unshift(y);else n.unshift(y)}function u(d,f){if(n.length>1)n.sort(d||AI);if(i.length>1)i.sort(f||ob);if(r.length>1)r.sort(f||ob)}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 TI(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new ab,e.set(i,[o]);else if(r>=s.length)o=new ab,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function RI(){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 Ze};break;case"SpotLight":n={position:new F,direction:new F,color:new Ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new F,color:new Ze,distance:0,decay:0};break;case"HemisphereLight":n={direction:new F,skyColor:new Ze,groundColor:new Ze};break;case"RectAreaLight":n={color:new Ze,position:new F,halfWidth:new F,halfHeight:new F};break}return e[t.id]=n,n}}}function CI(){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 Ge};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ge};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ge,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var II=0;function PI(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function LI(e){let t=new RI,n=CI(),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 Ke,o=new Ke;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,y=0,S=0,x=0,b=0,M=0,T=0,v=0,A=0,V=0;l.sort(PI);for(let N=0,Y=l.length;N<Y;N++){let D=l[N],{color:W,intensity:z,distance:P}=D,q=null;if(D.shadow&&D.shadow.map)if(D.shadow.map.texture.format===ds)q=D.shadow.map.texture;else q=D.shadow.map.depthTexture||D.shadow.map.texture;if(D.isAmbientLight)u+=W.r*z,h+=W.g*z,d+=W.b*z;else if(D.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(D.sh.coefficients[H],z);V++}else if(D.isSunLight){let H=t.get(D);if(H.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){let ee=D.shadow,J=n.get(D);J.shadowIntensity=ee.intensity,J.shadowBias=ee.bias,J.shadowNormalBias=ee.normalBias,J.shadowRadius=ee.radius,J.shadowMapSize.copy(ee.mapSize).multiply(ee.getFrameExtents()),i.sunShadow[m]=J,i.sunShadowMap[m]=q;let de=ee.getViewportCount();for(let pe=0;pe<de;pe++)i.sunShadowMatrix[_+pe]=ee.getMatrix(pe),i.sunShadowCascade[_+pe]=ee._cascadeData[pe];_+=de,m++}i.sun[f]=H,f++}else if(D.isDirectionalLight){let H=t.get(D);if(H.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){let ee=D.shadow,J=n.get(D);J.shadowIntensity=ee.intensity,J.shadowBias=ee.bias,J.shadowNormalBias=ee.normalBias,J.shadowRadius=ee.radius,J.shadowMapSize=ee.mapSize,i.directionalShadow[p]=J,i.directionalShadowMap[p]=q,i.directionalShadowMatrix[p]=D.shadow.matrix,b++}i.directional[p]=H,p++}else if(D.isSpotLight){let H=t.get(D);H.position.setFromMatrixPosition(D.matrixWorld),H.color.copy(W).multiplyScalar(z),H.distance=P,H.coneCos=Math.cos(D.angle),H.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),H.decay=D.decay,i.spot[y]=H;let ee=D.shadow;if(D.map){if(i.spotLightMap[v]=D.map,v++,ee.updateMatrices(D),D.castShadow)A++}if(i.spotLightMatrix[y]=ee.matrix,D.castShadow){let J=n.get(D);J.shadowIntensity=ee.intensity,J.shadowBias=ee.bias,J.shadowNormalBias=ee.normalBias,J.shadowRadius=ee.radius,J.shadowMapSize=ee.mapSize,i.spotShadow[y]=J,i.spotShadowMap[y]=q,T++}y++}else if(D.isRectAreaLight){let H=t.get(D);H.color.copy(W).multiplyScalar(z),H.halfWidth.set(D.width*0.5,0,0),H.halfHeight.set(0,D.height*0.5,0),i.rectArea[S]=H,S++}else if(D.isPointLight){let H=t.get(D);if(H.color.copy(D.color).multiplyScalar(D.intensity),H.distance=D.distance,H.decay=D.decay,D.castShadow){let ee=D.shadow,J=n.get(D);J.shadowIntensity=ee.intensity,J.shadowBias=ee.bias,J.shadowNormalBias=ee.normalBias,J.shadowRadius=ee.radius,J.shadowMapSize=ee.mapSize,J.shadowCameraNear=ee.camera.near,J.shadowCameraFar=ee.camera.far,i.pointShadow[g]=J,i.pointShadowMap[g]=q,i.pointShadowMatrix[g]=D.shadow.matrix,M++}i.point[g]=H,g++}else if(D.isHemisphereLight){let H=t.get(D);H.skyColor.copy(D.color).multiplyScalar(z),H.groundColor.copy(D.groundColor).multiplyScalar(z),i.hemi[x]=H,x++}}if(S>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!==y||C.rectAreaLength!==S||C.hemiLength!==x||C.numSunShadows!==m||C.numDirectionalShadows!==b||C.numPointShadows!==M||C.numSpotShadows!==T||C.numSpotMaps!==v||C.numLightProbes!==V)i.sun.length=f,i.directional.length=p,i.spot.length=y,i.rectArea.length=S,i.point.length=g,i.hemi.length=x,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=M,i.pointShadowMap.length=M,i.pointShadowMatrix.length=M,i.spotShadow.length=T,i.spotShadowMap.length=T,i.spotLightMatrix.length=T+v-A,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=V,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=y,C.rectAreaLength=S,C.hemiLength=x,C.numSunShadows=m,C.numDirectionalShadows=b,C.numPointShadows=M,C.numSpotShadows=T,C.numSpotMaps=v,C.numLightProbes=V,i.version=II++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let y=0,S=l.length;y<S;y++){let x=l[y];if(x.isSunLight){let b=i.sun[h];b.direction.setFromMatrixPosition(x.matrixWorld),b.direction.transformDirection(g),h++}else if(x.isDirectionalLight){let b=i.directional[d];b.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(g),d++}else if(x.isSpotLight){let b=i.spot[m];b.position.setFromMatrixPosition(x.matrixWorld),b.position.applyMatrix4(g),b.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(g),m++}else if(x.isRectAreaLight){let b=i.rectArea[_];b.position.setFromMatrixPosition(x.matrixWorld),b.position.applyMatrix4(g),o.identity(),s.copy(x.matrixWorld),s.premultiply(g),o.extractRotation(s),b.halfWidth.set(x.width*0.5,0,0),b.halfHeight.set(0,x.height*0.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),_++}else if(x.isPointLight){let b=i.point[f];b.position.setFromMatrixPosition(x.matrixWorld),b.position.applyMatrix4(g),f++}else if(x.isHemisphereLight){let b=i.hemi[p];b.direction.setFromMatrixPosition(x.matrixWorld),b.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function cb(e){let t=new LI(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 NI(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new cb(e),t.set(r,[a]);else if(s>=o.length)a=new cb(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var DI=`void main() {
- gl_Position = vec4( position, 1.0 );
-}`,OI=`uniform sampler2D shadow_pass;
-uniform vec2 resolution;
-uniform float radius;
-void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- 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 );
-}`,UI=[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)],kI=[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)],lb=new Ke,Va=new F,Uf=new F;function FI(e,t,n){let i=new La,r=new Ge,s=new Ge,o=new yt,a=new gf,c=new _f,l={},u=n.maxTextureSize,h={[Cr]:mn,[mn]:Cr,[Yn]:Yn},d=new Jn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ge},radius:{value:4}},vertexShader:DI,fragmentShader:OI}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new gn;m.setAttribute("position",new rn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Pt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=va;let g=this.type;this.render=function(M,T,v){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(M.length===0)return;if(this.type===zv)ze("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=va;let A=e.getRenderTarget(),V=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),N=e.state;if(N.setBlending(Di),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 Y=g!==this.type;if(Y)T.traverse(function(D){if(D.material)if(Array.isArray(D.material))D.material.forEach((W)=>W.needsUpdate=!0);else D.material.needsUpdate=!0});for(let D=0,W=M.length;D<W;D++){let z=M[D],P=z.shadow;if(P===void 0){ze("WebGLShadowMap:",z,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let q=P.getFrameExtents();if(r.multiply(q),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/q.x),r.x=s.x*q.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/q.y),r.y=s.y*q.y,P.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=H,P.map===null||Y===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===to){if(z.isPointLight){ze("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new kn(r.x,r.y,{format:ds,type:Ui,minFilter:sn,magFilter:sn,generateMipmaps:!1}),P.map.texture.name=z.name+".shadowMap",P.map.depthTexture=new ps(r.x,r.y,or),P.map.depthTexture.name=z.name+".shadowMapDepth",P.map.depthTexture.format=us,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=hi,P.map.depthTexture.magFilter=hi}else{if(z.isPointLight)P.map=new zf(r.x),P.map.depthTexture=new ff(r.x,Ir);else P.map=new kn(r.x,r.y),P.map.depthTexture=new ps(r.x,r.y,Ir);if(P.map.depthTexture.name=z.name+".shadowMap",P.map.depthTexture.format=us,this.type===va)P.map.depthTexture.compareFunction=H?Dl:Nl,P.map.depthTexture.minFilter=sn,P.map.depthTexture.magFilter=sn;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=hi,P.map.depthTexture.magFilter=hi}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 ee=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(z.isPointLight!==!0)P.updateMatrices(z,v);for(let J=0;J<ee;J++){let de=P.getCamera(J);if(z.isPointLight){let{camera:pe,matrix:Be}=P,me=z.distance||pe.far;if(me!==pe.far)pe.far=me,pe.updateProjectionMatrix();Va.setFromMatrixPosition(z.matrixWorld),pe.position.copy(Va),Uf.copy(pe.position),Uf.add(UI[J]),pe.up.copy(kI[J]),pe.lookAt(Uf),pe.updateMatrixWorld(),Be.makeTranslation(-Va.x,-Va.y,-Va.z),lb.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),P._frustum.setFromProjectionMatrix(lb,pe.coordinateSystem,pe.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,J),e.clear();else{if(J===0)e.setRenderTarget(P.map),e.clear();let pe=P.getViewport(J);o.set(s.x*pe.x,s.y*pe.y,s.x*pe.z,s.y*pe.w),N.viewport(o)}i=P.getFrustum(J),x(T,v,de,z,this.type)}if(P.isPointLightShadow!==!0&&this.type===to)y(P,v);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(A,V,C)};function y(M,T){let v=t.update(_);if(d.defines.VSM_SAMPLES!==M.blurSamples)d.defines.VSM_SAMPLES=M.blurSamples,f.defines.VSM_SAMPLES=M.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(M.mapPass===null)M.mapPass=new kn(r.x,r.y,{format:ds,type:Ui});else if(M.mapPass.width!==M.map.width||M.mapPass.height!==M.map.height)M.mapPass.setSize(M.map.width,M.map.height);d.uniforms.shadow_pass.value=M.map.depthTexture,d.uniforms.resolution.value.set(M.map.width,M.map.height),d.uniforms.radius.value=M.radius,e.setRenderTarget(M.mapPass),e.clear(),e.renderBufferDirect(T,null,v,d,_,null),f.uniforms.shadow_pass.value=M.mapPass.texture,f.uniforms.resolution.value.set(M.map.width,M.map.height),f.uniforms.radius.value=M.radius,e.setRenderTarget(M.map),e.clear(),e.renderBufferDirect(T,null,v,f,_,null)}function S(M,T,v,A){let V=null,C=v.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(C!==void 0)V=C;else if(V=v.isPointLight===!0?c:a,e.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){let N=V.uuid,Y=T.uuid,D=l[N];if(D===void 0)D={},l[N]=D;let W=D[Y];if(W===void 0)W=V.clone(),D[Y]=W,T.addEventListener("dispose",b);V=W}if(V.visible=T.visible,V.wireframe=T.wireframe,A===to)V.side=T.shadowSide!==null?T.shadowSide:T.side;else V.side=T.shadowSide!==null?T.shadowSide:h[T.side];if(V.alphaMap=T.alphaMap,V.alphaTest=T.alphaToCoverage===!0?0.5:T.alphaTest,V.map=T.map,V.clipShadows=T.clipShadows,V.clippingPlanes=T.clippingPlanes,V.clipIntersection=T.clipIntersection,V.displacementMap=T.displacementMap,V.displacementScale=T.displacementScale,V.displacementBias=T.displacementBias,V.wireframeLinewidth=T.wireframeLinewidth,V.linewidth=T.linewidth,v.isPointLight===!0&&V.isMeshDistanceMaterial===!0){let N=e.properties.get(V);N.light=v}return V}function x(M,T,v,A,V){if(M.visible===!1)return;if(M.layers.test(T.layers)&&(M.isMesh||M.isLine||M.isPoints)){if((M.castShadow||M.receiveShadow&&V===to)&&(!M.frustumCulled||M.intersectsFrustum(i))){M.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,M.matrixWorld);let Y=t.update(M),D=M.material;if(Array.isArray(D)){let W=Y.groups;for(let z=0,P=W.length;z<P;z++){let q=W[z],H=D[q.materialIndex];if(H&&H.visible){let ee=S(M,H,A,V);M.onBeforeShadow(e,M,T,v,Y,ee,q),e.renderBufferDirect(v,null,Y,ee,M,q),M.onAfterShadow(e,M,T,v,Y,ee,q)}}}else if(D.visible){let W=S(M,D,A,V);M.onBeforeShadow(e,M,T,v,Y,W,null),e.renderBufferDirect(v,null,Y,W,M,null),M.onAfterShadow(e,M,T,v,Y,W,null)}}}let N=M.children;for(let Y=0,D=N.length;Y<D;Y++)x(N[Y],T,v,A,V)}function b(M){M.target.removeEventListener("dispose",b);for(let v in l){let A=l[v],V=M.target.uuid;if(V in A)A[V].dispose(),delete A[V]}}}function zI(e,t){function n(){let B=!1,ge=new yt,re=null,xe=new yt(0,0,0,0);return{setMask:function(Re){if(re!==Re&&!B)e.colorMask(Re,Re,Re,Re),re=Re},setLocked:function(Re){B=Re},setClear:function(Re,le,Se,Je,Ct){if(Ct===!0)Re*=Je,le*=Je,Se*=Je;if(ge.set(Re,le,Se,Je),xe.equals(ge)===!1)e.clearColor(Re,le,Se,Je),xe.copy(ge)},reset:function(){B=!1,re=null,xe.set(-1,0,0,0)}}}function i(){let B=!1,ge=!1,re=null,xe=null,Re=null;return{setReversed:function(le){if(ge!==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);ge=le;let Je=Re;Re=null,this.setClear(Je)}},getReversed:function(){return ge},setTest:function(le){if(le)G(e.DEPTH_TEST);else te(e.DEPTH_TEST)},setMask:function(le){if(re!==le&&!B)e.depthMask(le),re=le},setFunc:function(le){if(ge)le=Ny[le];if(xe!==le){switch(le){case oy:e.depthFunc(e.NEVER);break;case ay:e.depthFunc(e.ALWAYS);break;case cy:e.depthFunc(e.LESS);break;case fd:e.depthFunc(e.LEQUAL);break;case ly:e.depthFunc(e.EQUAL);break;case uy:e.depthFunc(e.GEQUAL);break;case hy:e.depthFunc(e.GREATER);break;case dy:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=le}},setLocked:function(le){B=le},setClear:function(le){if(Re!==le){if(Re=le,ge)le=1-le;e.clearDepth(le)}},reset:function(){B=!1,re=null,xe=null,Re=null,ge=!1}}}function r(){let B=!1,ge=null,re=null,xe=null,Re=null,le=null,Se=null,Je=null,Ct=null;return{setTest:function(_t){if(!B)if(_t)G(e.STENCIL_TEST);else te(e.STENCIL_TEST)},setMask:function(_t){if(ge!==_t&&!B)e.stencilMask(_t),ge=_t},setFunc:function(_t,gi,ji){if(re!==_t||xe!==gi||Re!==ji)e.stencilFunc(_t,gi,ji),re=_t,xe=gi,Re=ji},setOp:function(_t,gi,ji){if(le!==_t||Se!==gi||Je!==ji)e.stencilOp(_t,gi,ji),le=_t,Se=gi,Je=ji},setLocked:function(_t){B=_t},setClear:function(_t){if(Ct!==_t)e.clearStencil(_t),Ct=_t},reset:function(){B=!1,ge=null,re=null,xe=null,Re=null,le=null,Se=null,Je=null,Ct=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,y=null,S=null,x=null,b=null,M=null,T=null,v=new Ze(0,0,0),A=0,V=!1,C=null,N=null,Y=null,D=null,W=null,z=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,q=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)q=parseFloat(/^WebGL (\d)/.exec(H)[1]),P=q>=1;else if(H.indexOf("OpenGL ES")!==-1)q=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),P=q>=2;let ee=null,J={},de=e.getParameter(e.SCISSOR_BOX),pe=e.getParameter(e.VIEWPORT),Be=new yt().fromArray(de),me=new yt().fromArray(pe);function X(B,ge,re,xe){let Re=new Uint8Array(4),le=e.createTexture();e.bindTexture(B,le),e.texParameteri(B,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(B,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Se=0;Se<re;Se++)if(B===e.TEXTURE_3D||B===e.TEXTURE_2D_ARRAY)e.texImage3D(ge,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Re);else e.texImage2D(ge+Se,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Re);return le}let L={};L[e.TEXTURE_2D]=X(e.TEXTURE_2D,e.TEXTURE_2D,1),L[e.TEXTURE_CUBE_MAP]=X(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),L[e.TEXTURE_2D_ARRAY]=X(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),L[e.TEXTURE_3D]=X(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),G(e.DEPTH_TEST),o.setFunc(fd),Ot(!1),rt(ld),G(e.CULL_FACE),$e(Di);function G(B){if(u[B]!==!0)e.enable(B),u[B]=!0}function te(B){if(u[B]!==!1)e.disable(B),u[B]=!1}function se(B,ge){if(d[B]!==ge){if(e.bindFramebuffer(B,ge),d[B]=ge,B===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=ge;if(B===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=ge;return!0}return!1}function ce(B,ge){let re=m,xe=!1;if(B){if(re=f.get(ge),re===void 0)re=[],f.set(ge,re);let Re=B.textures;if(re.length!==Re.length||re[0]!==e.COLOR_ATTACHMENT0){for(let le=0,Se=Re.length;le<Se;le++)re[le]=e.COLOR_ATTACHMENT0+le;re.length=Re.length,xe=!0}}else if(re[0]!==e.BACK)re[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(re)}function Ae(B){if(_!==B)return e.useProgram(B),_=B,!0;return!1}let Te={[no]:e.FUNC_ADD,[Vv]:e.FUNC_SUBTRACT,[Hv]:e.FUNC_REVERSE_SUBTRACT};Te[Gv]=e.MIN,Te[$v]=e.MAX;let Ue={[Wv]:e.ZERO,[Zv]:e.ONE,[jv]:e.SRC_COLOR,[qv]:e.SRC_ALPHA,[ty]:e.SRC_ALPHA_SATURATE,[Qv]:e.DST_COLOR,[Jv]:e.DST_ALPHA,[Xv]:e.ONE_MINUS_SRC_COLOR,[Yv]:e.ONE_MINUS_SRC_ALPHA,[ey]:e.ONE_MINUS_DST_COLOR,[Kv]:e.ONE_MINUS_DST_ALPHA,[ny]:e.CONSTANT_COLOR,[iy]:e.ONE_MINUS_CONSTANT_COLOR,[ry]:e.CONSTANT_ALPHA,[sy]:e.ONE_MINUS_CONSTANT_ALPHA};function $e(B,ge,re,xe,Re,le,Se,Je,Ct,_t){if(B===Di){if(p===!0)te(e.BLEND),p=!1;return}if(p===!1)G(e.BLEND),p=!0;if(B!==Bv){if(B!==g||_t!==V){if(y!==no||b!==no)e.blendEquation(e.FUNC_ADD),y=no,b=no;if(_t)switch(B){case ya:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ud:e.blendFunc(e.ONE,e.ONE);break;case hd:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case dd:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:je("WebGLState: Invalid blending: ",B);break}else switch(B){case ya:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ud:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case hd:je("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case dd:je("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:je("WebGLState: Invalid blending: ",B);break}S=null,x=null,M=null,T=null,v.set(0,0,0),A=0,g=B,V=_t}return}if(Re=Re||ge,le=le||re,Se=Se||xe,ge!==y||Re!==b)e.blendEquationSeparate(Te[ge],Te[Re]),y=ge,b=Re;if(re!==S||xe!==x||le!==M||Se!==T)e.blendFuncSeparate(Ue[re],Ue[xe],Ue[le],Ue[Se]),S=re,x=xe,M=le,T=Se;if(Je.equals(v)===!1||Ct!==A)e.blendColor(Je.r,Je.g,Je.b,Ct),v.copy(Je),A=Ct;g=B,V=!1}function Xe(B,ge){B.side===Yn?te(e.CULL_FACE):G(e.CULL_FACE);let re=B.side===mn;if(ge)re=!re;Ot(re),B.blending===ya&&B.transparent===!1?$e(Di):$e(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),o.setFunc(B.depthFunc),o.setTest(B.depthTest),o.setMask(B.depthWrite),s.setMask(B.colorWrite);let xe=B.stencilWrite;if(a.setTest(xe),xe)a.setMask(B.stencilWriteMask),a.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),a.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass);Bt(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?G(e.SAMPLE_ALPHA_TO_COVERAGE):te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Ot(B){if(C!==B){if(B)e.frontFace(e.CW);else e.frontFace(e.CCW);C=B}}function rt(B){if(B!==kv){if(G(e.CULL_FACE),B!==N)if(B===ld)e.cullFace(e.BACK);else if(B===Fv)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else te(e.CULL_FACE);N=B}function Mt(B){if(B!==Y){if(P)e.lineWidth(B);Y=B}}function Bt(B,ge,re){if(B){if(G(e.POLYGON_OFFSET_FILL),D!==ge||W!==re){if(D=ge,W=re,o.getReversed())ge=-ge;e.polygonOffset(ge,re)}}else te(e.POLYGON_OFFSET_FILL)}function Ht(B){if(B)G(e.SCISSOR_TEST);else te(e.SCISSOR_TEST)}function O(B){if(B===void 0)B=e.TEXTURE0+z-1;if(ee!==B)e.activeTexture(B),ee=B}function en(B,ge,re){if(re===void 0)if(ee===null)re=e.TEXTURE0+z-1;else re=ee;let xe=J[re];if(xe===void 0)xe={type:void 0,texture:void 0},J[re]=xe;if(xe.type!==B||xe.texture!==ge){if(ee!==re)e.activeTexture(re),ee=re;e.bindTexture(B,ge||L[B]),xe.type=B,xe.texture=ge}}function gt(){let B=J[ee];if(B!==void 0&&B.type!==void 0)e.bindTexture(B.type,null),B.type=void 0,B.texture=void 0}function Ut(){try{e.compressedTexImage2D(...arguments)}catch(B){je("WebGLState:",B)}}function R(){try{e.compressedTexImage3D(...arguments)}catch(B){je("WebGLState:",B)}}function w(){try{e.texSubImage2D(...arguments)}catch(B){je("WebGLState:",B)}}function U(){try{e.texSubImage3D(...arguments)}catch(B){je("WebGLState:",B)}}function K(){try{e.compressedTexSubImage2D(...arguments)}catch(B){je("WebGLState:",B)}}function ue(){try{e.compressedTexSubImage3D(...arguments)}catch(B){je("WebGLState:",B)}}function fe(){try{e.texStorage2D(...arguments)}catch(B){je("WebGLState:",B)}}function ve(){try{e.texStorage3D(...arguments)}catch(B){je("WebGLState:",B)}}function ne(){try{e.texImage2D(...arguments)}catch(B){je("WebGLState:",B)}}function oe(){try{e.texImage3D(...arguments)}catch(B){je("WebGLState:",B)}}function Ee(B){if(h[B]!==void 0)return h[B];else return e.getParameter(B)}function Fe(B,ge){if(h[B]!==ge)e.pixelStorei(B,ge),h[B]=ge}function ye(B){if(Be.equals(B)===!1)e.scissor(B.x,B.y,B.z,B.w),Be.copy(B)}function he(B){if(me.equals(B)===!1)e.viewport(B.x,B.y,B.z,B.w),me.copy(B)}function Ve(B,ge){let re=l.get(ge);if(re===void 0)re=new WeakMap,l.set(ge,re);let xe=re.get(B);if(xe===void 0)xe=e.getUniformBlockIndex(ge,B.name),re.set(B,xe)}function We(B,ge){let xe=l.get(ge).get(B);if(c.get(ge)!==xe)e.uniformBlockBinding(ge,xe,B.__bindingPointIndex),c.set(ge,xe)}function ft(){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={},ee=null,J={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,y=null,S=null,x=null,b=null,M=null,T=null,v=new Ze(0,0,0),A=0,V=!1,C=null,N=null,Y=null,D=null,W=null,Be.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:G,disable:te,bindFramebuffer:se,drawBuffers:ce,useProgram:Ae,setBlending:$e,setMaterial:Xe,setFlipSided:Ot,setCullFace:rt,setLineWidth:Mt,setPolygonOffset:Bt,setScissorTest:Ht,activeTexture:O,bindTexture:en,unbindTexture:gt,compressedTexImage2D:Ut,compressedTexImage3D:R,texImage2D:ne,texImage3D:oe,pixelStorei:Fe,getParameter:Ee,updateUBOMapping:Ve,uniformBlockBinding:We,texStorage2D:fe,texStorage3D:ve,texSubImage2D:w,texSubImage3D:U,compressedTexSubImage2D:K,compressedTexSubImage3D:ue,scissor:ye,viewport:he,reset:ft}}function BI(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 Ge,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(R){}function _(R,w){return m?new OffscreenCanvas(R,w):Ks("canvas")}function p(R,w,U){let K=1,ue=Ut(R);if(ue.width>U||ue.height>U)K=U/Math.max(ue.width,ue.height);if(K<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){let fe=Math.floor(K*ue.width),ve=Math.floor(K*ue.height);if(d===void 0)d=_(fe,ve);let ne=w?_(fe,ve):d;return ne.width=fe,ne.height=ve,ne.getContext("2d").drawImage(R,0,0,fe,ve),ze("WebGLRenderer: Texture has been resized from ("+ue.width+"x"+ue.height+") to ("+fe+"x"+ve+")."),ne}else{if("data"in R)ze("WebGLRenderer: Image in DataTexture is too big ("+ue.width+"x"+ue.height+").");return R}return R}function g(R){return R.generateMipmaps}function y(R){e.generateMipmap(R)}function S(R){if(R.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(R.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function x(R,w,U,K,ue,fe=!1){if(R!==null){if(e[R]!==void 0)return e[R];ze("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let ve;if(K){if(ve=t.get("EXT_texture_norm16"),!ve)ze("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let ne=w;if(w===e.RED){if(U===e.FLOAT)ne=e.R32F;if(U===e.HALF_FLOAT)ne=e.R16F;if(U===e.UNSIGNED_BYTE)ne=e.R8;if(U===e.UNSIGNED_SHORT&&ve)ne=ve.R16_EXT;if(U===e.SHORT&&ve)ne=ve.R16_SNORM_EXT}if(w===e.RED_INTEGER){if(U===e.UNSIGNED_BYTE)ne=e.R8UI;if(U===e.UNSIGNED_SHORT)ne=e.R16UI;if(U===e.UNSIGNED_INT)ne=e.R32UI;if(U===e.BYTE)ne=e.R8I;if(U===e.SHORT)ne=e.R16I;if(U===e.INT)ne=e.R32I}if(w===e.RG){if(U===e.FLOAT)ne=e.RG32F;if(U===e.HALF_FLOAT)ne=e.RG16F;if(U===e.UNSIGNED_BYTE)ne=e.RG8;if(U===e.UNSIGNED_SHORT&&ve)ne=ve.RG16_EXT;if(U===e.SHORT&&ve)ne=ve.RG16_SNORM_EXT}if(w===e.RG_INTEGER){if(U===e.UNSIGNED_BYTE)ne=e.RG8UI;if(U===e.UNSIGNED_SHORT)ne=e.RG16UI;if(U===e.UNSIGNED_INT)ne=e.RG32UI;if(U===e.BYTE)ne=e.RG8I;if(U===e.SHORT)ne=e.RG16I;if(U===e.INT)ne=e.RG32I}if(w===e.RGB_INTEGER){if(U===e.UNSIGNED_BYTE)ne=e.RGB8UI;if(U===e.UNSIGNED_SHORT)ne=e.RGB16UI;if(U===e.UNSIGNED_INT)ne=e.RGB32UI;if(U===e.BYTE)ne=e.RGB8I;if(U===e.SHORT)ne=e.RGB16I;if(U===e.INT)ne=e.RGB32I}if(w===e.RGBA_INTEGER){if(U===e.UNSIGNED_BYTE)ne=e.RGBA8UI;if(U===e.UNSIGNED_SHORT)ne=e.RGBA16UI;if(U===e.UNSIGNED_INT)ne=e.RGBA32UI;if(U===e.BYTE)ne=e.RGBA8I;if(U===e.SHORT)ne=e.RGBA16I;if(U===e.INT)ne=e.RGBA32I}if(w===e.RGB){if(U===e.UNSIGNED_SHORT&&ve)ne=ve.RGB16_EXT;if(U===e.SHORT&&ve)ne=ve.RGB16_SNORM_EXT;if(U===e.UNSIGNED_INT_5_9_9_9_REV)ne=e.RGB9_E5;if(U===e.UNSIGNED_INT_10F_11F_11F_REV)ne=e.R11F_G11F_B10F}if(w===e.RGBA){let oe=fe?of:nt.getTransfer(ue);if(U===e.FLOAT)ne=e.RGBA32F;if(U===e.HALF_FLOAT)ne=e.RGBA16F;if(U===e.UNSIGNED_BYTE)ne=oe===Rt?e.SRGB8_ALPHA8:e.RGBA8;if(U===e.UNSIGNED_SHORT&&ve)ne=ve.RGBA16_EXT;if(U===e.SHORT&&ve)ne=ve.RGBA16_SNORM_EXT;if(U===e.UNSIGNED_SHORT_4_4_4_4)ne=e.RGBA4;if(U===e.UNSIGNED_SHORT_5_5_5_1)ne=e.RGB5_A1}if(ne===e.R16F||ne===e.R32F||ne===e.RG16F||ne===e.RG32F||ne===e.RGBA16F||ne===e.RGBA32F)t.get("EXT_color_buffer_float");return ne}function b(R,w){let U;if(R){if(w===null||w===Ir||w===ao)U=e.DEPTH24_STENCIL8;else if(w===or)U=e.DEPTH32F_STENCIL8;else if(w===wa)U=e.DEPTH24_STENCIL8,ze("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(w===null||w===Ir||w===ao)U=e.DEPTH_COMPONENT24;else if(w===or)U=e.DEPTH_COMPONENT32F;else if(w===wa)U=e.DEPTH_COMPONENT16;return U}function M(R,w){if(g(R)===!0||R.isFramebufferTexture&&R.minFilter!==hi&&R.minFilter!==sn)return Math.log2(Math.max(w.width,w.height))+1;else if(R.mipmaps!==void 0&&R.mipmaps.length>0)return R.mipmaps.length;else if(R.isCompressedTexture&&Array.isArray(R.image))return w.mipmaps.length;else return 1}function T(R){let w=R.target;if(w.removeEventListener("dispose",T),A(w),w.isVideoTexture)u.delete(w);if(w.isHTMLTexture)h.delete(w)}function v(R){let w=R.target;w.removeEventListener("dispose",v),C(w)}function A(R){let w=i.get(R);if(w.__webglInit===void 0)return;let U=R.source,K=f.get(U);if(K){let ue=K[w.__cacheKey];if(ue.usedTimes--,ue.usedTimes===0)V(R);if(Object.keys(K).length===0)f.delete(U)}i.remove(R)}function V(R){let w=i.get(R);e.deleteTexture(w.__webglTexture);let U=R.source,K=f.get(U);delete K[w.__cacheKey],o.memory.textures--}function C(R){let w=i.get(R);if(R.depthTexture)R.depthTexture.dispose(),i.remove(R.depthTexture);if(R.isWebGLCubeRenderTarget)for(let K=0;K<6;K++){if(Array.isArray(w.__webglFramebuffer[K]))for(let ue=0;ue<w.__webglFramebuffer[K].length;ue++)e.deleteFramebuffer(w.__webglFramebuffer[K][ue]);else e.deleteFramebuffer(w.__webglFramebuffer[K]);if(w.__webglDepthbuffer)e.deleteRenderbuffer(w.__webglDepthbuffer[K])}else{if(Array.isArray(w.__webglFramebuffer))for(let K=0;K<w.__webglFramebuffer.length;K++)e.deleteFramebuffer(w.__webglFramebuffer[K]);else e.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer)e.deleteRenderbuffer(w.__webglDepthbuffer);if(w.__webglMultisampledFramebuffer)e.deleteFramebuffer(w.__webglMultisampledFramebuffer);if(w.__webglColorRenderbuffer){for(let K=0;K<w.__webglColorRenderbuffer.length;K++)if(w.__webglColorRenderbuffer[K])e.deleteRenderbuffer(w.__webglColorRenderbuffer[K])}if(w.__webglDepthRenderbuffer)e.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let U=R.textures;for(let K=0,ue=U.length;K<ue;K++){let fe=i.get(U[K]);if(fe.__webglTexture)e.deleteTexture(fe.__webglTexture),o.memory.textures--;i.remove(U[K])}i.remove(R)}let N=0;function Y(){N=0}function D(){return N}function W(R){N=R}function z(){let R=N;if(R>=r.maxTextures)ze("WebGLTextures: Trying to use "+(R+1)+" texture units while this GPU supports only "+r.maxTextures);return N+=1,R}function P(R){let w=[];return w.push(R.wrapS),w.push(R.wrapT),w.push(R.wrapR||0),w.push(R.magFilter),w.push(R.minFilter),w.push(R.anisotropy),w.push(R.internalFormat),w.push(R.format),w.push(R.type),w.push(R.generateMipmaps),w.push(R.premultiplyAlpha),w.push(R.flipY),w.push(R.unpackAlignment),w.push(R.colorSpace),w.join()}function q(R,w){let U=i.get(R);if(R.isVideoTexture)en(R);if(R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&U.__version!==R.version){let K=R.image;if(K===null)ze("WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)ze("WebGLRenderer: Texture marked for update but image is incomplete");else{te(U,R,w);return}}else if(R.isExternalTexture)U.__webglTexture=R.sourceTexture?R.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,U.__webglTexture,e.TEXTURE0+w)}function H(R,w){let U=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&U.__version!==R.version){te(U,R,w);return}else if(R.isExternalTexture)U.__webglTexture=R.sourceTexture?R.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,U.__webglTexture,e.TEXTURE0+w)}function ee(R,w){let U=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&U.__version!==R.version){te(U,R,w);return}n.bindTexture(e.TEXTURE_3D,U.__webglTexture,e.TEXTURE0+w)}function J(R,w){let U=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&U.__version!==R.version){se(U,R,w);return}n.bindTexture(e.TEXTURE_CUBE_MAP,U.__webglTexture,e.TEXTURE0+w)}let de={[ro]:e.REPEAT,[so]:e.CLAMP_TO_EDGE,[Ml]:e.MIRRORED_REPEAT},pe={[hi]:e.NEAREST,[El]:e.NEAREST_MIPMAP_NEAREST,[ls]:e.NEAREST_MIPMAP_LINEAR,[sn]:e.LINEAR,[oo]:e.LINEAR_MIPMAP_NEAREST,[Oi]:e.LINEAR_MIPMAP_LINEAR},Be={[My]:e.NEVER,[Cy]:e.ALWAYS,[Ey]:e.LESS,[Nl]:e.LEQUAL,[Ay]:e.EQUAL,[Dl]:e.GEQUAL,[Ty]:e.GREATER,[Ry]:e.NOTEQUAL};function me(R,w){if(w.type===or&&t.has("OES_texture_float_linear")===!1&&(w.magFilter===sn||w.magFilter===oo||w.magFilter===ls||w.magFilter===Oi||w.minFilter===sn||w.minFilter===oo||w.minFilter===ls||w.minFilter===Oi))ze("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(R,e.TEXTURE_WRAP_S,de[w.wrapS]),e.texParameteri(R,e.TEXTURE_WRAP_T,de[w.wrapT]),R===e.TEXTURE_3D||R===e.TEXTURE_2D_ARRAY)e.texParameteri(R,e.TEXTURE_WRAP_R,de[w.wrapR]);if(e.texParameteri(R,e.TEXTURE_MAG_FILTER,pe[w.magFilter]),e.texParameteri(R,e.TEXTURE_MIN_FILTER,pe[w.minFilter]),w.compareFunction)e.texParameteri(R,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(R,e.TEXTURE_COMPARE_FUNC,Be[w.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===hi)return;if(w.minFilter!==ls&&w.minFilter!==Oi)return;if(w.type===or&&t.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||i.get(w).__currentAnisotropy){let U=t.get("EXT_texture_filter_anisotropic");e.texParameterf(R,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,r.getMaxAnisotropy())),i.get(w).__currentAnisotropy=w.anisotropy}}}function X(R,w){let U=!1;if(R.__webglInit===void 0)R.__webglInit=!0,w.addEventListener("dispose",T);let K=w.source,ue=f.get(K);if(ue===void 0)ue={},f.set(K,ue);let fe=P(w);if(fe!==R.__cacheKey){if(ue[fe]===void 0)ue[fe]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,U=!0;ue[fe].usedTimes++;let ve=ue[R.__cacheKey];if(ve!==void 0){if(ue[R.__cacheKey].usedTimes--,ve.usedTimes===0)V(w)}R.__cacheKey=fe,R.__webglTexture=ue[fe].texture}return U}function L(R,w,U){return Math.floor(Math.floor(R/U)/w)}function G(R,w,U,K){let fe=R.updateRanges;if(fe.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,w.width,w.height,U,K,w.data);else{fe.sort((Fe,ye)=>Fe.start-ye.start);let ve=0;for(let Fe=1;Fe<fe.length;Fe++){let ye=fe[ve],he=fe[Fe],Ve=ye.start+ye.count,We=L(he.start,w.width,4),ft=L(ye.start,w.width,4);if(he.start<=Ve+1&&We===ft&&L(he.start+he.count-1,w.width,4)===We)ye.count=Math.max(ye.count,he.start+he.count-ye.start);else++ve,fe[ve]=he}fe.length=ve+1;let ne=n.getParameter(e.UNPACK_ROW_LENGTH),oe=n.getParameter(e.UNPACK_SKIP_PIXELS),Ee=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,w.width);for(let Fe=0,ye=fe.length;Fe<ye;Fe++){let he=fe[Fe],Ve=Math.floor(he.start/4),We=Math.ceil(he.count/4),ft=Ve%w.width,B=Math.floor(Ve/w.width),ge=We,re=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,ft),n.pixelStorei(e.UNPACK_SKIP_ROWS,B),n.texSubImage2D(e.TEXTURE_2D,0,ft,B,ge,1,U,K,w.data)}R.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,ne),n.pixelStorei(e.UNPACK_SKIP_PIXELS,oe),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ee)}}function te(R,w,U){let K=e.TEXTURE_2D;if(w.isDataArrayTexture||w.isCompressedArrayTexture)K=e.TEXTURE_2D_ARRAY;if(w.isData3DTexture)K=e.TEXTURE_3D;let ue=X(R,w),fe=w.source;n.bindTexture(K,R.__webglTexture,e.TEXTURE0+U);let ve=i.get(fe);if(fe.version!==ve.__version||ue===!0){if(n.activeTexture(e.TEXTURE0+U),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){let re=nt.getPrimaries(nt.workingColorSpace),xe=w.colorSpace===fs?null:nt.getPrimaries(w.colorSpace),Re=w.colorSpace===fs||re===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,w.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re)}n.pixelStorei(e.UNPACK_ALIGNMENT,w.unpackAlignment);let oe=p(w.image,!1,r.maxTextureSize);oe=gt(w,oe);let Ee=s.convert(w.format,w.colorSpace),Fe=s.convert(w.type),ye=x(w.internalFormat,Ee,Fe,w.normalized,w.colorSpace,w.isVideoTexture);me(K,w);let he,Ve=w.mipmaps,We=w.isVideoTexture!==!0,ft=ve.__version===void 0||ue===!0,B=fe.dataReady,ge=M(w,oe);if(w.isDepthTexture){if(ye=b(w.format===hs,w.type),ft)if(We)n.texStorage2D(e.TEXTURE_2D,1,ye,oe.width,oe.height);else n.texImage2D(e.TEXTURE_2D,0,ye,oe.width,oe.height,0,Ee,Fe,null)}else if(w.isDataTexture)if(Ve.length>0){if(We&&ft)n.texStorage2D(e.TEXTURE_2D,ge,ye,Ve[0].width,Ve[0].height);for(let re=0,xe=Ve.length;re<xe;re++)if(he=Ve[re],We){if(B)n.texSubImage2D(e.TEXTURE_2D,re,0,0,he.width,he.height,Ee,Fe,he.data)}else n.texImage2D(e.TEXTURE_2D,re,ye,he.width,he.height,0,Ee,Fe,he.data);w.generateMipmaps=!1}else if(We){if(ft)n.texStorage2D(e.TEXTURE_2D,ge,ye,oe.width,oe.height);if(B)G(w,oe,Ee,Fe)}else n.texImage2D(e.TEXTURE_2D,0,ye,oe.width,oe.height,0,Ee,Fe,oe.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){if(We&&ft)n.texStorage3D(e.TEXTURE_2D_ARRAY,ge,ye,Ve[0].width,Ve[0].height,oe.depth);for(let re=0,xe=Ve.length;re<xe;re++)if(he=Ve[re],w.format!==ki)if(Ee!==null)if(We){if(B)if(w.layerUpdates.size>0){let Re=If(he.width,he.height,w.format,w.type);for(let le of w.layerUpdates){let Se=he.data.subarray(le*Re/he.data.BYTES_PER_ELEMENT,(le+1)*Re/he.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,re,0,0,le,he.width,he.height,1,Ee,Se)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,re,0,0,0,he.width,he.height,oe.depth,Ee,he.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,re,ye,he.width,he.height,oe.depth,0,he.data,0,0);else ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(We){if(B)n.texSubImage3D(e.TEXTURE_2D_ARRAY,re,0,0,0,he.width,he.height,oe.depth,Ee,Fe,he.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,re,ye,he.width,he.height,oe.depth,0,Ee,Fe,he.data);if(w.layerUpdates.size>0)w.clearLayerUpdates()}else{if(We&&ft)n.texStorage2D(e.TEXTURE_2D,ge,ye,Ve[0].width,Ve[0].height);for(let re=0,xe=Ve.length;re<xe;re++)if(he=Ve[re],w.format!==ki)if(Ee!==null)if(We){if(B)n.compressedTexSubImage2D(e.TEXTURE_2D,re,0,0,he.width,he.height,Ee,he.data)}else n.compressedTexImage2D(e.TEXTURE_2D,re,ye,he.width,he.height,0,he.data);else ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(We){if(B)n.texSubImage2D(e.TEXTURE_2D,re,0,0,he.width,he.height,Ee,Fe,he.data)}else n.texImage2D(e.TEXTURE_2D,re,ye,he.width,he.height,0,Ee,Fe,he.data)}else if(w.isDataArrayTexture)if(We){if(ft)n.texStorage3D(e.TEXTURE_2D_ARRAY,ge,ye,oe.width,oe.height,oe.depth);if(B)if(w.layerUpdates.size>0){let re=If(oe.width,oe.height,w.format,w.type);for(let xe of w.layerUpdates){let Re=oe.data.subarray(xe*re/oe.data.BYTES_PER_ELEMENT,(xe+1)*re/oe.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,oe.width,oe.height,1,Ee,Fe,Re)}w.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ee,Fe,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ye,oe.width,oe.height,oe.depth,0,Ee,Fe,oe.data);else if(w.isData3DTexture)if(We){if(ft)n.texStorage3D(e.TEXTURE_3D,ge,ye,oe.width,oe.height,oe.depth);if(B)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ee,Fe,oe.data)}else n.texImage3D(e.TEXTURE_3D,0,ye,oe.width,oe.height,oe.depth,0,Ee,Fe,oe.data);else if(w.isFramebufferTexture){if(ft)if(We)n.texStorage2D(e.TEXTURE_2D,ge,ye,oe.width,oe.height);else{let re=oe.width,xe=oe.height;for(let Re=0;Re<ge;Re++)n.texImage2D(e.TEXTURE_2D,Re,ye,re,xe,0,Ee,Fe,null),re>>=1,xe>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in e){let re=e.canvas;if(!re.hasAttribute("layoutsubtree"))re.setAttribute("layoutsubtree","true");if(oe.parentNode!==re){re.appendChild(oe),h.add(w),re.onpaint=(xe)=>{let Re=xe.changedElements;for(let le of h)if(Re.includes(le.image))le.needsUpdate=!0},re.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,oe);else{let{RGBA:Re,RGBA:le,UNSIGNED_BYTE:Se}=e;e.texElementImage2D(e.TEXTURE_2D,0,Re,le,Se,oe)}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(Ve.length>0){if(We&&ft){let re=Ut(Ve[0]);n.texStorage2D(e.TEXTURE_2D,ge,ye,re.width,re.height)}for(let re=0,xe=Ve.length;re<xe;re++)if(he=Ve[re],We){if(B)n.texSubImage2D(e.TEXTURE_2D,re,0,0,Ee,Fe,he)}else n.texImage2D(e.TEXTURE_2D,re,ye,Ee,Fe,he);w.generateMipmaps=!1}else if(We){if(ft){let re=Ut(oe);n.texStorage2D(e.TEXTURE_2D,ge,ye,re.width,re.height)}if(B)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ee,Fe,oe)}else n.texImage2D(e.TEXTURE_2D,0,ye,Ee,Fe,oe);if(g(w))y(K);if(ve.__version=fe.version,w.onUpdate)w.onUpdate(w)}R.__version=w.version}function se(R,w,U){if(w.image.length!==6)return;let K=X(R,w),ue=w.source;n.bindTexture(e.TEXTURE_CUBE_MAP,R.__webglTexture,e.TEXTURE0+U);let fe=i.get(ue);if(ue.version!==fe.__version||K===!0){n.activeTexture(e.TEXTURE0+U);let ve=nt.getPrimaries(nt.workingColorSpace),ne=w.colorSpace===fs?null:nt.getPrimaries(w.colorSpace),oe=w.colorSpace===fs||ve===ne?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,w.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,w.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);let Ee=w.isCompressedTexture||w.image[0].isCompressedTexture,Fe=w.image[0]&&w.image[0].isDataTexture,ye=[];for(let le=0;le<6;le++){if(!Ee&&!Fe)ye[le]=p(w.image[le],!0,r.maxCubemapSize);else ye[le]=Fe?w.image[le].image:w.image[le];ye[le]=gt(w,ye[le])}let he=ye[0],Ve=s.convert(w.format,w.colorSpace),We=s.convert(w.type),ft=x(w.internalFormat,Ve,We,w.normalized,w.colorSpace),B=w.isVideoTexture!==!0,ge=fe.__version===void 0||K===!0,re=ue.dataReady,xe=M(w,he);me(e.TEXTURE_CUBE_MAP,w);let Re;if(Ee){if(B&&ge)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ft,he.width,he.height);for(let le=0;le<6;le++){Re=ye[le].mipmaps;for(let Se=0;Se<Re.length;Se++){let Je=Re[Se];if(w.format!==ki)if(Ve!==null)if(B){if(re)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,0,0,Je.width,Je.height,Ve,Je.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,ft,Je.width,Je.height,0,Je.data);else ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(B){if(re)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,0,0,Je.width,Je.height,Ve,We,Je.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,ft,Je.width,Je.height,0,Ve,We,Je.data)}}}else{if(Re=w.mipmaps,B&&ge){if(Re.length>0)xe++;let le=Ut(ye[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ft,le.width,le.height)}for(let le=0;le<6;le++)if(Fe){if(B){if(re)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,ye[le].width,ye[le].height,Ve,We,ye[le].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ft,ye[le].width,ye[le].height,0,Ve,We,ye[le].data);for(let Se=0;Se<Re.length;Se++){let Ct=Re[Se].image[le].image;if(B){if(re)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,0,0,Ct.width,Ct.height,Ve,We,Ct.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,ft,Ct.width,Ct.height,0,Ve,We,Ct.data)}}else{if(B){if(re)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,Ve,We,ye[le])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ft,Ve,We,ye[le]);for(let Se=0;Se<Re.length;Se++){let Je=Re[Se];if(B){if(re)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,0,0,Ve,We,Je.image[le])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,ft,Ve,We,Je.image[le])}}}if(g(w))y(e.TEXTURE_CUBE_MAP);if(fe.__version=ue.version,w.onUpdate)w.onUpdate(w)}R.__version=w.version}function ce(R,w,U,K,ue,fe){let ve=s.convert(U.format,U.colorSpace),ne=s.convert(U.type),oe=x(U.internalFormat,ve,ne,U.normalized,U.colorSpace),Ee=i.get(w),Fe=i.get(U);if(Fe.__renderTarget=w,!Ee.__hasExternalTextures){let ye=Math.max(1,w.width>>fe),he=Math.max(1,w.height>>fe);if(ue===e.TEXTURE_3D||ue===e.TEXTURE_2D_ARRAY)n.texImage3D(ue,fe,oe,ye,he,w.depth,0,ve,ne,null);else n.texImage2D(ue,fe,oe,ye,he,0,ve,ne,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,R),O(w))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,K,ue,Fe.__webglTexture,0,Ht(w));else if(ue===e.TEXTURE_2D||ue>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ue<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,K,ue,Fe.__webglTexture,fe);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Ae(R,w,U){if(e.bindRenderbuffer(e.RENDERBUFFER,R),w.depthBuffer){let K=w.depthTexture,ue=K&&K.isDepthTexture?K.type:null,fe=b(w.stencilBuffer,ue),ve=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(O(w))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ht(w),fe,w.width,w.height);else if(U)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ht(w),fe,w.width,w.height);else e.renderbufferStorage(e.RENDERBUFFER,fe,w.width,w.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,R)}else{let K=w.textures;for(let ue=0;ue<K.length;ue++){let fe=K[ue],ve=s.convert(fe.format,fe.colorSpace),ne=s.convert(fe.type),oe=x(fe.internalFormat,ve,ne,fe.normalized,fe.colorSpace);if(O(w))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ht(w),oe,w.width,w.height);else if(U)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ht(w),oe,w.width,w.height);else e.renderbufferStorage(e.RENDERBUFFER,oe,w.width,w.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Te(R,w,U){let K=w.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,R),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ue=i.get(w.depthTexture);if(ue.__renderTarget=w,!ue.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0;if(K){if(ue.__webglInit===void 0)ue.__webglInit=!0,w.depthTexture.addEventListener("dispose",T);if(ue.__webglTexture===void 0){ue.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ue.__webglTexture),me(e.TEXTURE_CUBE_MAP,w.depthTexture);let Ee=s.convert(w.depthTexture.format),Fe=s.convert(w.depthTexture.type),ye;if(w.depthTexture.format===us)ye=e.DEPTH_COMPONENT24;else if(w.depthTexture.format===hs)ye=e.DEPTH24_STENCIL8;for(let he=0;he<6;he++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,ye,w.width,w.height,0,Ee,Fe,null)}}else q(w.depthTexture,0);let fe=ue.__webglTexture,ve=Ht(w),ne=K?e.TEXTURE_CUBE_MAP_POSITIVE_X+U:e.TEXTURE_2D,oe=w.depthTexture.format===hs?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(w.depthTexture.format===us)if(O(w))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,ne,fe,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,ne,fe,0);else if(w.depthTexture.format===hs)if(O(w))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,ne,fe,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,ne,fe,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ue(R){let w=i.get(R),U=R.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==R.depthTexture){let K=R.depthTexture;if(w.__depthDisposeCallback)w.__depthDisposeCallback();if(K){let ue=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,K.removeEventListener("dispose",ue)};K.addEventListener("dispose",ue),w.__depthDisposeCallback=ue}w.__boundDepthTexture=K}if(R.depthTexture&&!w.__autoAllocateDepthBuffer)if(U)for(let K=0;K<6;K++)Te(w.__webglFramebuffer[K],R,K);else{let K=R.texture.mipmaps;if(K&&K.length>0)Te(w.__webglFramebuffer[0],R,0);else Te(w.__webglFramebuffer,R,0)}else if(U){w.__webglDepthbuffer=[];for(let K=0;K<6;K++)if(n.bindFramebuffer(e.FRAMEBUFFER,w.__webglFramebuffer[K]),w.__webglDepthbuffer[K]===void 0)w.__webglDepthbuffer[K]=e.createRenderbuffer(),Ae(w.__webglDepthbuffer[K],R,!1);else{let ue=R.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,fe=w.__webglDepthbuffer[K];e.bindRenderbuffer(e.RENDERBUFFER,fe),e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,fe)}}else{let K=R.texture.mipmaps;if(K&&K.length>0)n.bindFramebuffer(e.FRAMEBUFFER,w.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,w.__webglFramebuffer);if(w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=e.createRenderbuffer(),Ae(w.__webglDepthbuffer,R,!1);else{let ue=R.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,fe=w.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,fe),e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,fe)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function $e(R,w,U){let K=i.get(R);if(w!==void 0)ce(K.__webglFramebuffer,R,R.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(U!==void 0)Ue(R)}function Xe(R){let w=R.texture,U=i.get(R),K=i.get(w);R.addEventListener("dispose",v);let ue=R.textures,fe=R.isWebGLCubeRenderTarget===!0,ve=ue.length>1;if(!ve){if(K.__webglTexture===void 0)K.__webglTexture=e.createTexture();K.__version=w.version,o.memory.textures++}if(fe){U.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)if(w.mipmaps&&w.mipmaps.length>0){U.__webglFramebuffer[ne]=[];for(let oe=0;oe<w.mipmaps.length;oe++)U.__webglFramebuffer[ne][oe]=e.createFramebuffer()}else U.__webglFramebuffer[ne]=e.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){U.__webglFramebuffer=[];for(let ne=0;ne<w.mipmaps.length;ne++)U.__webglFramebuffer[ne]=e.createFramebuffer()}else U.__webglFramebuffer=e.createFramebuffer();if(ve)for(let ne=0,oe=ue.length;ne<oe;ne++){let Ee=i.get(ue[ne]);if(Ee.__webglTexture===void 0)Ee.__webglTexture=e.createTexture(),o.memory.textures++}if(R.samples>0&&O(R)===!1){U.__webglMultisampledFramebuffer=e.createFramebuffer(),U.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let ne=0;ne<ue.length;ne++){let oe=ue[ne];U.__webglColorRenderbuffer[ne]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,U.__webglColorRenderbuffer[ne]);let Ee=s.convert(oe.format,oe.colorSpace),Fe=s.convert(oe.type),ye=x(oe.internalFormat,Ee,Fe,oe.normalized,oe.colorSpace,R.isXRRenderTarget===!0),he=Ht(R);e.renderbufferStorageMultisample(e.RENDERBUFFER,he,ye,R.width,R.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ne,e.RENDERBUFFER,U.__webglColorRenderbuffer[ne])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),R.depthBuffer)U.__webglDepthRenderbuffer=e.createRenderbuffer(),Ae(U.__webglDepthRenderbuffer,R,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(fe){n.bindTexture(e.TEXTURE_CUBE_MAP,K.__webglTexture),me(e.TEXTURE_CUBE_MAP,w);for(let ne=0;ne<6;ne++)if(w.mipmaps&&w.mipmaps.length>0)for(let oe=0;oe<w.mipmaps.length;oe++)ce(U.__webglFramebuffer[ne][oe],R,w,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,oe);else ce(U.__webglFramebuffer[ne],R,w,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0);if(g(w))y(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let ne=0,oe=ue.length;ne<oe;ne++){let Ee=ue[ne],Fe=i.get(Ee),ye=e.TEXTURE_2D;if(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)ye=R.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ye,Fe.__webglTexture),me(ye,Ee),ce(U.__webglFramebuffer,R,Ee,e.COLOR_ATTACHMENT0+ne,ye,0),g(Ee))y(ye)}n.unbindTexture()}else{let ne=e.TEXTURE_2D;if(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)ne=R.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ne,K.__webglTexture),me(ne,w),w.mipmaps&&w.mipmaps.length>0)for(let oe=0;oe<w.mipmaps.length;oe++)ce(U.__webglFramebuffer[oe],R,w,e.COLOR_ATTACHMENT0,ne,oe);else ce(U.__webglFramebuffer,R,w,e.COLOR_ATTACHMENT0,ne,0);if(g(w))y(ne);n.unbindTexture()}if(R.depthBuffer)Ue(R)}function Ot(R){let w=R.textures;for(let U=0,K=w.length;U<K;U++){let ue=w[U];if(g(ue)){let fe=S(R),ve=i.get(ue).__webglTexture;n.bindTexture(fe,ve),y(fe),n.unbindTexture()}}}let rt=[],Mt=[];function Bt(R){if(R.samples>0){if(O(R)===!1){let{textures:w,width:U,height:K}=R,ue=e.COLOR_BUFFER_BIT,fe=R.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(R),ne=w.length>1;if(ne)for(let Ee=0;Ee<w.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 oe=R.texture.mipmaps;if(oe&&oe.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ee=0;Ee<w.length;Ee++){if(R.resolveDepthBuffer){if(R.depthBuffer)ue|=e.DEPTH_BUFFER_BIT;if(R.stencilBuffer&&R.resolveStencilBuffer)ue|=e.STENCIL_BUFFER_BIT}if(ne){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Fe=i.get(w[Ee]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Fe,0)}if(e.blitFramebuffer(0,0,U,K,0,0,U,K,ue,e.NEAREST),c===!0){if(rt.length=0,Mt.length=0,rt.push(e.COLOR_ATTACHMENT0+Ee),R.depthBuffer&&R.storeMultisampledDepthBuffer===!1)rt.push(fe),Mt.push(fe),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Mt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,rt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),ne)for(let Ee=0;Ee<w.length;Ee++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Fe=i.get(w[Ee]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,Fe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.storeMultisampledDepthBuffer===!1&&c){let w=R.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[w])}}}function Ht(R){return Math.min(r.maxSamples,R.samples)}function O(R){let w=i.get(R);return R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function en(R){let w=o.render.frame;if(u.get(R)!==w)u.set(R,w),R.update()}function gt(R,w){let{colorSpace:U,format:K,type:ue}=R;if(R.isCompressedTexture===!0||R.isVideoTexture===!0)return w;if(U!==Un&&U!==fs)if(nt.getTransfer(U)===Rt){if(K!==ki||ue!==di)ze("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else je("WebGLTextures: Unsupported texture color space:",U);return w}function Ut(R){if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement)l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height;else if(typeof VideoFrame<"u"&&R instanceof VideoFrame)l.width=R.displayWidth,l.height=R.displayHeight;else l.width=R.width,l.height=R.height;return l}this.allocateTextureUnit=z,this.resetTextureUnits=Y,this.getTextureUnits=D,this.setTextureUnits=W,this.setTexture2D=q,this.setTexture2DArray=H,this.setTexture3D=ee,this.setTextureCube=J,this.rebindTextures=$e,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=Ot,this.updateMultisampleRenderTarget=Bt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=O,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function VI(e,t){function n(i,r=fs){let s,o=nt.getTransfer(r);if(i===di)return e.UNSIGNED_BYTE;if(i===bd)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Sd)return e.UNSIGNED_SHORT_5_5_5_1;if(i===xy)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===vy)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===gy)return e.BYTE;if(i===_y)return e.SHORT;if(i===wa)return e.UNSIGNED_SHORT;if(i===yd)return e.INT;if(i===Ir)return e.UNSIGNED_INT;if(i===or)return e.FLOAT;if(i===Ui)return e.HALF_FLOAT;if(i===yy)return e.ALPHA;if(i===by)return e.RGB;if(i===ki)return e.RGBA;if(i===us)return e.DEPTH_COMPONENT;if(i===hs)return e.DEPTH_STENCIL;if(i===Sy)return e.RED;if(i===wd)return e.RED_INTEGER;if(i===ds)return e.RG;if(i===Md)return e.RG_INTEGER;if(i===Ed)return e.RGBA_INTEGER;if(i===Al||i===Tl||i===Rl||i===Cl)if(o===Rt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Al)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Tl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Rl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Cl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Al)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Tl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Rl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Cl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ad||i===Td||i===Rd||i===Cd)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ad)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Td)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Rd)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Cd)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Id||i===Pd||i===Ld||i===Nd||i===Dd||i===Il||i===Od)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Id||i===Pd)return o===Rt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ld)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Nd)return s.COMPRESSED_R11_EAC;if(i===Dd)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Il)return s.COMPRESSED_RG11_EAC;if(i===Od)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Ud||i===kd||i===Fd||i===zd||i===Bd||i===Vd||i===Hd||i===Gd||i===$d||i===Wd||i===Zd||i===jd||i===Xd||i===qd)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Ud)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Fd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===zd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Bd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Vd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Hd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Gd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===$d)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Wd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Zd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===jd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Xd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===qd)return o===Rt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Yd||i===Jd||i===Kd)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Yd)return o===Rt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Jd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Kd)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Qd||i===ef||i===Pl||i===tf)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Qd)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ef)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Pl)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===tf)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===ao)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var HI=`
-void main() {
-
- gl_Position = vec4( position, 1.0 );
-
-}`,GI=`
-uniform sampler2DArray depthColor;
-uniform float depthWidth;
-uniform float depthHeight;
-
-void main() {
-
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
-
- if ( coord.x >= 1.0 ) {
+----------`);var d=Function("compile",t.join(`
+`));return d(TU.bind(void 0,e))}Sw.exports=AU});var Rw=Xr(function(X$,Mw){var SU=ww();function wU(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function MU(e){var t=new wU;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var i=0;i<n.length;++i){var r=n[i];if(r==="array"||typeof r==="object"&&r.blockIndices){if(t.argTypes[i]="array",t.arrayArgs.push(i),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array args");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(i),t.shimArgs.push("scalar"+i);else if(r==="index"){if(t.indexArgs.push(i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array index");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array index");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(i),i<t.pre.args.length&&t.pre.args[i].lvalue)throw Error("cwise: pre() block may not write to array shape");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array shape");if(i<t.post.args.length&&t.post.args[i].lvalue)throw Error("cwise: post() block may not write to array shape")}else if(typeof r==="object"&&r.offset)t.argTypes[i]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(i);else throw Error("cwise: Unknown argument type "+n[i])}if(t.arrayArgs.length<=0)throw Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,SU(t)}Mw.exports=MU});var Dw=Xr(function(sn){var qn=Rw(),Xd={body:"",args:[],thisVars:[],localVars:[]};function Cg(e){if(!e)return Xd;for(var t=0;t<e.args.length;++t){var n=e.args[t];if(t===0)e.args[t]={name:n,lvalue:!0,rvalue:!!e.rvalue,count:e.count||1};else e.args[t]={name:n,lvalue:!1,rvalue:!0,count:1}}if(!e.thisVars)e.thisVars=[];if(!e.localVars)e.localVars=[];return e}function RU(e){return qn({args:e.args,pre:Cg(e.pre),body:Cg(e.body),post:Cg(e.proc),funcName:e.funcName})}function Zt(e){var t=[];for(var n=0;n<e.args.length;++n)t.push("a"+n);var i=Function("P",["return function ",e.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return i(RU(e))}var Iw={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var e in Iw){var t=Iw[e];sn[e]=Zt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),sn[e+"eq"]=Zt({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),sn[e+"s"]=Zt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),sn[e+"seq"]=Zt({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}})();var Cw={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var e in Cw){var t=Cw[e];sn[e]=Zt({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),sn[e+"eq"]=Zt({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}})();var Nw={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var e in Nw){var t=Nw[e];sn[e]=Zt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),sn[e+"s"]=Zt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),sn[e+"eq"]=Zt({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),sn[e+"seq"]=Zt({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}})();var Pw=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var e=0;e<Pw.length;++e){var t=Pw[e];sn[t]=Zt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),sn[t+"eq"]=Zt({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var Ow=["max","min","atan2","pow"];(function(){for(var e=0;e<Ow.length;++e){var t=Ow[e];sn[t]=Zt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),sn[t+"s"]=Zt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),sn[t+"eq"]=Zt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),sn[t+"seq"]=Zt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var kw=["atan2","pow"];(function(){for(var e=0;e<kw.length;++e){var t=kw[e];sn[t+"op"]=Zt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),sn[t+"ops"]=Zt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),sn[t+"opeq"]=Zt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),sn[t+"opseq"]=Zt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();sn.any=qn({args:["array"],pre:Xd,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});sn.all=qn({args:["array"],pre:Xd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});sn.sum=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});sn.prod=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});sn.norm2squared=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});sn.norm2=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});sn.norminf=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});sn.norm1=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});sn.sup=qn({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});sn.inf=qn({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});sn.argmin=qn({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});sn.argmax=qn({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});sn.random=Zt({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});sn.assign=Zt({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});sn.assigns=Zt({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});sn.equals=qn({args:["array","array"],pre:Xd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});function KU(e,t){if(!(e instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let n=new Blob([e],{type:t});return createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((i)=>{let r=new OffscreenCanvas(i.width,i.height).getContext("2d");r.drawImage(i,0,0);let s=r.getImageData(0,0,i.width,i.height);return Lw.default(new Uint8Array(s.data),[i.width,i.height,4],[4,4*i.width,1],0)})}async function Fw(e,t){return KU(e,t)}var Lw,$U;var Uw=Ft(()=>{Lw=bf(Rg(),1),$U=bf(Dw(),1)});function rf(e,t){return Object.defineProperty(t,"name",{value:e}),t}function sf(e,t){let n={...e};for(let i in t)if(t[i]!==void 0)n[i]=t[i];return n}function eM(e){let t=[];for(let n of e.listAttributes())t.push(n);for(let n of e.listTargets())for(let i of n.listAttributes())t.push(i);return Array.from(new Set(t))}function XU(e,t){if(e==null&&t==null)return!0;if(e==null||t==null)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Yd(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function qU(e,t=e){let n=tM(e,t);for(let i=0;i<n.length;i++)n[i]=i;return n}function tM(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function nM(e){for(let t in e)return!1;return!0}function JU(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],h=t[11],y=t[12],g=t[13],m=t[14],p=t[15],b=n*o-i*a,_=n*c-r*a,x=n*l-s*a,v=i*c-r*o,E=i*l-s*o,S=r*l-s*c,T=u*g-d*y,A=u*m-f*y,P=u*p-h*y,w=d*m-f*g,I=d*p-h*g,F=f*p-h*m,N=b*F-_*I+x*w+v*P-E*A+S*T;if(!N)return null;return N=1/N,e[0]=(o*F-c*I+l*w)*N,e[1]=(r*I-i*F-s*w)*N,e[2]=(g*S-m*E+p*v)*N,e[3]=(f*E-d*S-h*v)*N,e[4]=(c*P-a*F-l*A)*N,e[5]=(n*F-r*P+s*A)*N,e[6]=(m*x-y*S-p*_)*N,e[7]=(u*S-f*x+h*_)*N,e[8]=(a*I-o*P+l*T)*N,e[9]=(i*P-n*I-s*T)*N,e[10]=(y*E-g*x+p*b)*N,e[11]=(d*x-u*E-h*b)*N,e[12]=(o*A-a*w-c*T)*N,e[13]=(n*w-i*A+r*T)*N,e[14]=(g*_-y*v-m*b)*N,e[15]=(u*v-d*_+f*b)*N,e}function Fg(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],y=t[11],g=t[12],m=t[13],p=t[14],b=t[15],_=n[0],x=n[1],v=n[2],E=n[3];return e[0]=_*i+x*o+v*d+E*g,e[1]=_*r+x*c+v*f+E*m,e[2]=_*s+x*l+v*h+E*p,e[3]=_*a+x*u+v*y+E*b,_=n[4],x=n[5],v=n[6],E=n[7],e[4]=_*i+x*o+v*d+E*g,e[5]=_*r+x*c+v*f+E*m,e[6]=_*s+x*l+v*h+E*p,e[7]=_*a+x*u+v*y+E*b,_=n[8],x=n[9],v=n[10],E=n[11],e[8]=_*i+x*o+v*d+E*g,e[9]=_*r+x*c+v*f+E*m,e[10]=_*s+x*l+v*h+E*p,e[11]=_*a+x*u+v*y+E*b,_=n[12],x=n[13],v=n[14],E=n[15],e[12]=_*i+x*o+v*d+E*g,e[13]=_*r+x*c+v*f+E*m,e[14]=_*s+x*l+v*h+E*p,e[15]=_*a+x*u+v*y+E*b,e}function ZU(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function YU(e,t,n,i){var r=t[0],s=t[1],a=t[2],o=t[3],c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,y=s*l,g=s*u,m=a*u,p=o*c,b=o*l,_=o*u,x=i[0],v=i[1],E=i[2];return e[0]=(1-(y+m))*x,e[1]=(f+_)*x,e[2]=(h-b)*x,e[3]=0,e[4]=(f-_)*v,e[5]=(1-(d+m))*v,e[6]=(g+p)*v,e[7]=0,e[8]=(h+b)*E,e[9]=(g-p)*E,e[10]=(1-(d+y))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function ef(e,t){let n=e.getAttribute("POSITION"),i=e.getIndices();if(!n)return 0;switch(t){case"render":return i?i.getCount():n.getCount();case"render-cached":return i?new Set(i.getArray()).size:n.getCount();case"upload-naive":case"upload":return n.getCount();case"distinct":case"distinct-position":return QU(t);case"unused":return i?n.getCount()-new Set(i.getArray()).size:0;default:return e3(t)}}function QU(e){throw Error(`Not implemented: ${e}`)}function e3(e){throw Error(`Unexpected value: ${e}`)}function t3(e,t,n){let i=zd.fromGraph(e.getGraph());if(!t||!n)[t,n]=n3(e);let r=e.getIndices(),s=r?r.getArray():null,a=ef(e,"render"),o=i.createAccessor(),c=a,l=tM(c,n);for(let d=0;d<c;d++)l[d]=t[s?s[d]:d];e.setIndices(o.setArray(l));let u=eM(e);for(let d of e.listAttributes()){let f=Yd(i,d);Og(d,r,t,f,n),e.swap(d,f)}for(let d of e.listTargets())for(let f of d.listAttributes()){let h=Yd(i,f);Og(f,r,t,h,n),d.swap(f,h)}if(r&&r.listParents().length===1)r.dispose();for(let d of u)if(d.listParents().length===1)d.dispose();return e}function Og(e,t,n,i,r){let s=e.getElementSize(),a=e.getArray(),o=t?t.getArray():null,c=t?t.getCount():e.getCount(),l=new a.constructor(r*s),u=new Uint8Array(r);for(let d=0;d<c;d++){let f=o?o[d]:d,h=n[f];if(u[h])continue;for(let y=0;y<s;y++)l[h*s+y]=a[f*s+y];u[h]=1}return i.setArray(l)}function n3(e){let t=ef(e,"upload"),n=e.getIndices(),i=n?n.getArray():null;if(!n||!i)return[qU(t,1e6),t];let r=new Uint32Array(t).fill(Bw),s=0;for(let a=0;a<i.length;a++){let o=i[a];if(r[o]===Bw)r[o]=s++}return[r,s]}function i3(){var e=new Qd(3);if(Qd!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function r3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function kg(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function Dg(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function zw(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function s3(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function Ug(e=Pg){let t=sf(Pg,e),n=new Set(t.propertyTypes);for(let i of t.propertyTypes)if(!Pg.propertyTypes.includes(i))throw Error(`${$s}: Unsupported deduplication on type "${i}".`);return rf($s,(i)=>{let r=i.getLogger();if(n.has(ne.ACCESSOR))o3(i);if(n.has(ne.TEXTURE))l3(i,t);if(n.has(ne.MATERIAL))u3(i,t);if(n.has(ne.MESH))c3(i,t);if(n.has(ne.SKIN))d3(i,t);r.debug(`${$s}: Complete.`)})}function o3(e){let t=e.getLogger(),n=new Map,i=new Map,r=new Map,s=new Map,a=e.getRoot().listMeshes();a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((h)=>o(h,i)),o(f.getIndices(),n)})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers())o(f.getInput(),r),o(f.getOutput(),s);function o(d,f){if(!d)return;let h=[d.getCount(),d.getType(),d.getComponentType(),d.getNormalized(),d.getSparse()].join(":"),y=f.get(h);if(!y)f.set(h,y=new Set);y.add(d)}function c(d,f){for(let h=0;h<d.length;h++){let y=d[h],g=Je.toView(y.getArray());if(f.has(y))continue;for(let m=h+1;m<d.length;m++){let p=d[m];if(f.has(p))continue;if(Je.equals(g,Je.toView(p.getArray())))f.set(p,y)}}}let l=0,u=new Map;for(let d of[i,n,r,s])for(let f of d.values())l+=f.size,c(Array.from(f),u);t.debug(`${$s}: Merged ${u.size} of ${l} accessors.`),a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((y)=>{if(u.has(y))f.swap(y,u.get(y))});let h=f.getIndices();if(h&&u.has(h))f.swap(h,u.get(h))})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers()){let h=f.getInput(),y=f.getOutput();if(h&&u.has(h))f.swap(h,u.get(h));if(y&&u.has(y))f.swap(y,u.get(y))}Array.from(u.keys()).forEach((d)=>d.dispose())}function c3(e,t){let n=e.getLogger(),i=e.getRoot(),r=new Map;i.listAccessors().forEach((o,c)=>r.set(o,c)),i.listMaterials().forEach((o,c)=>r.set(o,c));let s=i.listMeshes().length,a=new Map;for(let o of i.listMeshes()){let c=[];for(let u of o.listPrimitives())c.push(iM(u,r));let l="";if(t.keepUniqueNames)l+=o.getName()+";";if(l+=c.join(";"),a.has(l)){let u=a.get(l);o.listParents().forEach((d)=>{if(d.propertyType!==ne.ROOT)d.swap(o,u)}),o.dispose()}else a.set(l,o)}n.debug(`${$s}: Merged ${s-a.size} of ${s} meshes.`)}function l3(e,t){let n=e.getLogger(),i=e.getRoot(),r=i.listTextures(),s=new Map;for(let a=0;a<r.length;a++){let o=r[a],c=o.getImage();if(s.has(o))continue;for(let l=a+1;l<r.length;l++){let u=r[l],d=u.getImage();if(s.has(u))continue;if(o.getMimeType()!==u.getMimeType())continue;if(t.keepUniqueNames&&o.getName()!==u.getName())continue;let f=o.getSize(),h=u.getSize();if(!f||!h)continue;if(f[0]!==h[0])continue;if(f[1]!==h[1])continue;if(!c||!d)continue;if(Je.equals(c,d))s.set(u,o)}}n.debug(`${$s}: Merged ${s.size} of ${i.listTextures().length} textures.`),Array.from(s.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Rs))c.swap(a,o)}),a.dispose()})}function u3(e,t){let n=e.getLogger(),i=e.getRoot().listMaterials(),r=new Map,s=new Map,a=new Set;if(!t.keepUniqueNames)a.add("name");for(let o=0;o<i.length;o++){let c=i[o];if(r.has(c))continue;if(Vw(c,s))continue;for(let l=o+1;l<i.length;l++){let u=i[l];if(r.has(u))continue;if(Vw(u,s))continue;if(c.equals(u,a))r.set(u,c)}}n.debug(`${$s}: Merged ${r.size} of ${i.length} materials.`),Array.from(r.entries()).forEach(([o,c])=>{o.listParents().forEach((l)=>{if(!(l instanceof Rs))l.swap(o,c)}),o.dispose()})}function d3(e,t){let n=e.getLogger(),i=e.getRoot().listSkins(),r=new Map,s=new Set(["joints"]);if(!t.keepUniqueNames)s.add("name");for(let a=0;a<i.length;a++){let o=i[a];if(r.has(o))continue;for(let c=a+1;c<i.length;c++){let l=i[c];if(r.has(l))continue;if(o.equals(l,s)&&XU(o.listJoints(),l.listJoints()))r.set(l,o)}}n.debug(`${$s}: Merged ${r.size} of ${i.length} skins.`),Array.from(r.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Rs))c.swap(a,o)}),a.dispose()})}function iM(e,t){let n=[];for(let i of e.listSemantics()){let r=e.getAttribute(i);n.push(i+":"+t.get(r))}if(e instanceof Wn){let i=e.getIndices();if(i)n.push("indices:"+t.get(i));let r=e.getMaterial();if(r)n.push("material:"+t.get(r));n.push("mode:"+e.getMode());for(let s of e.listTargets())n.push("target:"+iM(s,t))}return n.join(",")}function Vw(e,t){if(t.has(e))return t.get(e);let n=e.getGraph(),i=new Set,r=n.listParentEdges(e);while(r.length>0){let s=r.pop();if(s.getAttributes().modifyChild===!0)return t.set(e,!0),!0;let a=s.getChild();if(i.has(a))continue;for(let o of n.listChildEdges(a))r.push(o)}return t.set(e,!1),!1}function rM(){var e=new Qd(4);if(Qd!=Float32Array)e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e}function f3(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function h3(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function p3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function m3(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function g3(e){var t=e[0],n=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+n*n+i*i+r*r)}function x3(e){return e.getGraph().listParentEdges(e).some((t)=>t.getAttributes().isColor||y3.test(t.getName()))?"srgb":null}function _3(e){let t=e.getGraph(),n=new Set,i=new Set;function r(s){let a=new Set;for(let o of t.listChildEdges(s))if(o.getChild()instanceof zo)a.add(o.getName()+"Info");for(let o of t.listChildEdges(s)){let c=o.getChild();if(n.has(c))continue;if(n.add(c),c instanceof At&&a.has(o.getName()))i.add(c);else if(c instanceof nt)r(c)}}return r(e),Array.from(i)}function v3(e){let t=zd.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter((i)=>i.getParent()!==t).map((i)=>i.getName());return Array.from(new Set(n))}function oM(e=jw){let t=sf(jw,e),n=new Set(t.propertyTypes),i=t.keepExtras;return rf(Ho,async(r)=>{let s=r.getLogger(),a=r.getRoot(),o=r.getGraph(),c=new E3,l=(u)=>c.dispose(u.target);if(o.addEventListener("node:dispose",l),n.has(ne.MESH))for(let u of a.listMeshes()){if(u.listPrimitives().length>0)continue;u.dispose()}if(n.has(ne.NODE)){if(!t.keepLeaves)for(let u of a.listScenes())cM(o,u,i);for(let u of a.listNodes())Ai(u,i)}if(n.has(ne.SKIN))for(let u of a.listSkins())Ai(u,i);if(n.has(ne.MESH))for(let u of a.listMeshes())Ai(u,i);if(n.has(ne.CAMERA))for(let u of a.listCameras())Ai(u,i);if(n.has(ne.PRIMITIVE))Hw(o,ne.PRIMITIVE,i);if(n.has(ne.PRIMITIVE_TARGET))Hw(o,ne.PRIMITIVE_TARGET,i);if(!t.keepAttributes&&n.has(ne.ACCESSOR)){let u=new Map;for(let d of a.listMeshes())for(let f of d.listPrimitives()){let h=f.getMaterial();if(!h)continue;let y=T3(f,lM(r,f,h));Gw(f,y),f.listTargets().forEach((g)=>Gw(g,y)),u.has(h)?u.get(h).add(f):u.set(h,new Set([f]))}for(let[d,f]of u)A3(d,Array.from(f))}if(n.has(ne.ANIMATION))for(let u of a.listAnimations()){for(let d of u.listChannels())if(!d.getTargetNode())d.dispose();if(!u.listChannels().length){let d=u.listSamplers();Ai(u,i),d.forEach((f)=>Ai(f,i))}else u.listSamplers().forEach((d)=>Ai(d,i))}if(n.has(ne.MATERIAL))a.listMaterials().forEach((u)=>Ai(u,i));if(n.has(ne.TEXTURE)){if(a.listTextures().forEach((u)=>Ai(u,i)),!t.keepSolidTextures)await S3(r)}if(n.has(ne.ACCESSOR))a.listAccessors().forEach((u)=>Ai(u,i));if(n.has(ne.BUFFER))a.listBuffers().forEach((u)=>Ai(u,i));if(o.removeEventListener("node:dispose",l),!c.empty()){let u=c.entries().map(([d,f])=>`${d} (${f})`).join(", ");s.info(`${Ho}: Removed types... ${u}`)}else s.debug(`${Ho}: No unused properties found.`);s.debug(`${Ho}: Complete.`)})}function Ai(e,t){let n=e.listParents().filter((r)=>!(r instanceof Rs||r instanceof Ca)),i=t&&!nM(e.getExtras());if(!n.length&&!i)e.dispose()}function Hw(e,t,n){for(let i of e.listEdges()){let r=i.getParent();if(r.propertyType===t)Ai(r,n)}}function cM(e,t,n){if(t.listChildren().forEach((a)=>cM(e,a,n)),t instanceof Bd)return;let i=e.listParentEdges(t).some((a)=>{let o=a.getParent().propertyType;return o!==ne.ROOT&&o!==ne.SCENE&&o!==ne.NODE}),r=e.listChildren(t).length===0,s=n&&!nM(t.getExtras());if(r&&!i&&!s)t.dispose()}function Gw(e,t){for(let n of t)e.setAttribute(n,null)}function T3(e,t){let n=[];for(let i of e.listSemantics())if(i==="NORMAL"&&!t.has(i))n.push(i);else if(i==="TANGENT"&&!t.has(i))n.push(i);else if(i.startsWith("TEXCOORD_")&&!t.has(i))n.push(i);else if(i.startsWith("COLOR_")&&i!=="COLOR_0")n.push(i);return n}function lM(e,t,n,i=new Set){let r=e.getGraph().listChildEdges(n),s=new Set;for(let c of r)if(c.getChild()instanceof zo)s.add(c.getName());for(let c of r){let l=c.getName(),u=c.getChild();if(u instanceof At){if(s.has(l.replace(/Info$/,"")))i.add(`TEXCOORD_${u.getTexCoord()}`)}if(u instanceof zo&&l.match(/normalTexture/i))i.add("TANGENT");if(u instanceof nt)lM(e,t,u,i)}let a=n instanceof Ra&&!n.getExtension("KHR_materials_unlit"),o=t.getMode()===Wn.Mode.POINTS;if(a&&!o)i.add("NORMAL");return i}function A3(e,t){let n=_3(e),i=new Set(n.map((c)=>c.getTexCoord())),r=Array.from(i).sort(),s=new Map(r.map((c,l)=>[c,l])),a=new Map(r.map((c,l)=>[`TEXCOORD_${c}`,`TEXCOORD_${l}`]));for(let c of n){let l=c.getTexCoord();c.setTexCoord(s.get(l))}for(let c of t){let l=c.listSemantics().filter((u)=>u.startsWith("TEXCOORD_")).sort();o(c,l),c.listTargets().forEach((u)=>o(u,l))}function o(c,l){for(let u of l){let d=c.getAttribute(u);if(!d)continue;let f=a.get(u);if(f===u)continue;c.setAttribute(f,d),c.setAttribute(u,null)}}}async function S3(e){let t=e.getRoot(),n=e.getGraph(),i=e.getLogger(),r=t.listTextures().map(async(s)=>{let a=await M3(s);if(!a)return;if(x3(s)==="srgb")xS.convertSRGBToLinear(a,a);let o=s.getName()||s.getURI(),c=s.getSize()?.join("x"),l=v3(s);for(let u of n.listParentEdges(s)){let d=u.getParent();if(d!==t&&w3(d,a,u.getName(),i))u.dispose()}if(s.listParents().length===1)s.dispose(),i.debug(`${Ho}: Removed solid-color texture "${o}" (${c}px ${l.join(", ")})`)});await Promise.all(r)}function w3(e,t,n,i){if(e instanceof Ra)switch(n){case"baseColorTexture":return e.setBaseColorFactor(b3(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(a3([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Lg;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return aM(sM(rM(),t,[0.5,0.5,1,1]))<=Lg}return i.warn(`${Ho}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function M3(e){let t=await R3(e);if(!t)return null;let n=[1/0,1/0,1/0,1/0],i=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[s,a]=t.shape;for(let o=0;o<s;o++){for(let c=0;c<a;c++)for(let l=0;l<4;l++)n[l]=Math.min(n[l],t.get(o,c,l)),i[l]=Math.max(i[l],t.get(o,c,l));if(aM(sM(r,i,n))/255>Lg)return null}return m3(r,f3(r,i,n),0.00196078431372549)}async function R3(e){try{return await Fw(e.getImage(),e.getMimeType())}catch{return null}}function I3(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw Error("Limit must be positive multiple of four.");let n=e.getAttribute("POSITION").getCount(),i=e.listSemantics().filter((l)=>l.startsWith("WEIGHTS_")).length,r=new Uint16Array(i*4),s=new Float32Array(i*4),a=new Float32Array(i*4),o=new Uint32Array(i*4),c=new Uint32Array(i*4);for(let l=0;l<n;l++){tf(e,l,"WEIGHTS",s),tf(e,l,"JOINTS",o);for(let u=0;u<i*4;u++)r[u]=u;r.sort((u,d)=>s[u]>s[d]?-1:1);for(let u=0;u<r.length;u++)a[u]=s[r[u]],c[u]=o[r[u]];nf(e,l,"WEIGHTS",a),nf(e,l,"JOINTS",c)}for(let l=i;l*4>t;l--){let u=e.getAttribute(`WEIGHTS_${l-1}`),d=e.getAttribute(`JOINTS_${l-1}`);if(e.setAttribute(`WEIGHTS_${l-1}`,null),e.setAttribute(`JOINTS_${l-1}`,null),u.listParents().length===1)u.dispose();if(d.listParents().length===1)d.dispose()}C3(e)}function C3(e){if(!N3(e))return;let t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter((d)=>d.startsWith("WEIGHTS_")).length,i=e.getAttribute("WEIGHTS_0"),r=i.getArray(),s=i.getComponentType(),a=i.getNormalized(),o=a?s:void 0,c=a?pt.decodeNormalizedInt(1,s):Number.EPSILON,l=new Uint32Array(n*4).fill(0),u=r.slice(0,n*4).fill(0);for(let d=0;d<t;d++){tf(e,d,"JOINTS",l),tf(e,d,"WEIGHTS",u,o);let f=$w(u,o);if(f!==0&&f!==1){if(Math.abs(1-f)>c)for(let h=0;h<u.length;h++)if(a){let y=pt.decodeNormalizedInt(u[h],s);u[h]=pt.encodeNormalizedInt(y/f,s)}else u[h]/=f;if(f=$w(u,o),a&&f!==1){for(let h=u.length-1;h>=0;h--)if(u[h]>0){let y=1-f;u[h]+=Math.sign(y)*pt.encodeNormalizedInt(Math.abs(y),s);break}}}for(let h=u.length-1;h>=0;h--)if(u[h]===0)l[h]=0;nf(e,d,"JOINTS",l),nf(e,d,"WEIGHTS",u,o)}}function tf(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){s.getElement(t,a);for(let c=0;c<4;c++)if(r)i[o*4+c]=pt.encodeNormalizedInt(a[c],r);else i[o*4+c]=a[c]}return i}function nf(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){for(let c=0;c<4;c++)if(r)a[c]=pt.decodeNormalizedInt(i[o*4+c],r);else a[c]=i[o*4+c];s.setElement(t,a)}}function $w(e,t){let n=0;for(let i=0;i<e.length;i++)if(t)n+=pt.decodeNormalizedInt(e[i],t);else n+=e[i];return n}function N3(e){let t=e.listSemantics().filter((r)=>r.startsWith("WEIGHTS_")).map((r)=>e.getAttribute(r)),n=t.map((r)=>r.getNormalized()),i=t.map((r)=>r.getComponentType());return new Set(n).size===1&&new Set(i).size===1}function uM(e=Zd){let t=sf(Zd,{patternTargets:e.pattern||Zd.pattern,...e});return rf(Gs,async(n)=>{let i=n.getLogger(),r=n.getRoot();if(n.hasExtension("KHR_mesh_primitive_restart"))throw Error("quantize: Missing support for KHR_mesh_primitive_restart.");let s;if(t.quantizationVolume==="scene")s=Ww($3(r.listMeshes().map(Xw)));for(let a of n.getRoot().listMeshes()){if(t.quantizationVolume==="mesh")s=Ww(Xw(a));if(s&&t.pattern.test("POSITION"))U3(n,a,s),V3(a,1/s.scale);for(let o of a.listPrimitives()){if(ef(o,"render")<ef(o,"upload")/2)t3(o);Kw(n,o,s,t);for(let c of o.listTargets())Kw(n,c,s,t)}}if(r.listMeshes().flatMap((a)=>a.listPrimitives()).some(dM))n.createExtension(wg).setRequired(!0);if(t.cleanup)await n.transform(oM({propertyTypes:[ne.ACCESSOR,ne.SKIN,ne.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),Ug({propertyTypes:[ne.ACCESSOR,ne.MATERIAL,ne.SKIN],keepUniqueNames:!0}));i.debug(`${Gs}: Complete.`)})}function Kw(e,t,n,i){let r=t instanceof xg,s=e.getLogger();for(let a of t.listSemantics()){if(!r&&!i.pattern.test(a))continue;if(r&&!i.patternTargets.test(a))continue;let o=t.getAttribute(a),{bits:c,ctor:l}=H3(a,o,s,i);if(!l)continue;if(c<8||c>16)throw Error(`${Gs}: Requires bits = 8–16.`);if(o.getComponentSize()<=c/8)continue;let u=o.clone();if(a==="POSITION"){let d=n.scale,f=[];t instanceof Wn?JU(f,af(n)):ZU(f,[1/d,1/d,1/d]);for(let h=0,y=[0,0,0],g=u.getCount();h<g;h++)u.getElement(h,y),u.setElement(h,s3(y,y,f))}j3(u,l,c),t.setAttribute(a,u)}if(i.normalizeWeights&&t.getAttribute("WEIGHTS_0"))I3(t,1/0);if(t instanceof Wn&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){let a=t.getIndices();a.setArray(new Uint16Array(a.getArray()))}}function Ww(e){let{min:t,max:n}=e,i=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:i}}function U3(e,t,n){let i=af(n);for(let r of t.listParents()){if(!(r instanceof Ud))continue;let s=r.listParents().filter((f)=>f instanceof Ca),a=s.some((f)=>F3.includes(f.getTargetPath())),o=r.listChildren().length>0,c=r.getSkin();if(c){r.setSkin(B3(c,n));continue}let l=r.getExtension("EXT_mesh_gpu_instancing");if(l){r.setExtension("EXT_mesh_gpu_instancing",z3(e,l,n));continue}let u;if(o||a)u=e.createNode("").setMesh(t),r.addChild(u).setMesh(null),s.filter((f)=>f.getTargetPath()===L3).forEach((f)=>f.setTargetNode(u));else u=r;let d=u.getMatrix();Fg(d,d,i),u.setMatrix(d)}}function B3(e,t){e=e.clone();let n=af(t),i=e.getInverseBindMatrices().clone(),r=[];for(let s=0,a=i.getCount();s<a;s++)i.getElement(s,r),Fg(r,r,n),i.setElement(s,r);return e.setInverseBindMatrices(i)}function z3(e,t,n){if(!t.getAttribute("TRANSLATION")&&!t.getAttribute("ROTATION")&&!t.getAttribute("SCALE"))return t;t=t.clone();let i=t.getAttribute("TRANSLATION")?.clone(),r=t.getAttribute("ROTATION")?.clone(),s=t.getAttribute("SCALE")?.clone(),a=i||r||s,o=[0,0,0],c=[0,0,0,1],l=[1,1,1];if(!i&&n.offset)i=e.createAccessor().setType("VEC3").setArray(Jw(a.getCount(),o));if(!s&&n.scale)s=e.createAccessor().setType("VEC3").setArray(Jw(a.getCount(),l));let u=[0,0,0],d=[0,0,0,1],f=[1,1,1],h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=af(n);for(let g=0,m=a.getCount();g<m;g++){if(pt.compose(i?i.getElement(g,u):o,r?r.getElement(g,d):c,s?s.getElement(g,f):l,h),Fg(h,h,y),pt.decompose(h,u,d,f),i)i.setElement(g,u);if(r)r.setElement(g,d);if(s)s.setElement(g,f)}if(i)t.setAttribute("TRANSLATION",i);if(r)t.setAttribute("ROTATION",r);if(s)t.setAttribute("SCALE",s);return t}function V3(e,t){for(let n of e.listPrimitives()){let i=n.getMaterial();if(!i)continue;let r=i.getExtension("KHR_materials_volume");if(!r||r.getThicknessFactor()<=0)continue;r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),i=i.clone().setExtension("KHR_materials_volume",r),n.setMaterial(i)}}function j3(e,t,n){let i=new t(e.getArray().length),r=P3.includes(t)?1:0,s=n-r,a=t.BYTES_PER_ELEMENT*8-r,o=Math.pow(2,s)-1,c=a-s,l=2*s-a,u=[r>0?-1:0,1];for(let d=0,f=0,h=[];d<e.getCount();d++){e.getElement(d,h);for(let y=0;y<h.length;y++){let g=K3(h[y],u);g=Math.round(Math.abs(g)*o),g=g<<c|g>>l,i[f++]=g*Math.sign(h[y])}}e.setArray(i).setNormalized(!0).setSparse(!1)}function H3(e,t,n,i){let r=t.getMinNormalized([]),s=t.getMaxNormalized([]),a,o;if(e==="POSITION")a=i.quantizePosition,o=a<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")a=i.quantizeNormal,o=a<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))a=i.quantizeColor,o=a<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Gs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeTexcoord,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("JOINTS_")){if(a=Math.max(...t.getMax([]))<=255?8:16,o=a<=8?Uint8Array:Uint16Array,t.getComponentSize()>a/8)t.setArray(new o(t.getArray()));return{bits:-1}}else if(e.startsWith("WEIGHTS_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Gs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeWeight,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some((c)=>c<-1)||s.some((c)=>c>1))return n.warn(`${Gs}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};a=i.quantizeGeneric,o=r.some((c)=>c<0)?o=a<=8?Int8Array:Int16Array:o=a<=8?Uint8Array:Uint16Array}else throw Error(`${Gs}: Unexpected semantic, "${e}".`);return{bits:a,ctor:o}}function Xw(e){let t=[],n=[];for(let r of e.listPrimitives()){let s=r.getAttribute("POSITION");if(s)t.push(s);for(let a of r.listTargets()){let o=a.getAttribute("POSITION");if(o)n.push(o)}}if(t.length===0)throw Error(`${Gs}: Missing "POSITION" attribute.`);let i=qw(t,3);if(n.length>0){let{min:r,max:s}=qw(n,3);kg(i.min,i.min,kg(r,zw(r,r,2),[0,0,0])),Dg(i.max,i.max,Dg(s,zw(s,s,2),[0,0,0]))}return i}function G3(e,t){let n=t.getComponentSize();if(e==="POSITION")return n<4;if(e==="NORMAL")return n<4;if(e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){let i=t.getComponentType(),r=t.getNormalized();return n<4&&!(r&&i===Be.ComponentType.UNSIGNED_BYTE)&&!(r&&i===Be.ComponentType.UNSIGNED_SHORT)}return!1}function dM(e){for(let t of e.listSemantics())if(G3(t,e.getAttribute("POSITION")))return!0;if(e.propertyType===ne.PRIMITIVE)return e.listTargets().some(dM);return!1}function qw(e,t){let n=Array(t).fill(1/0),i=Array(t).fill(-1/0),r=[],s=[];for(let a of e){a.getMinNormalized(r),a.getMaxNormalized(s);for(let o=0;o<t;o++)n[o]=Math.min(n[o],r[o]),i[o]=Math.max(i[o],s[o])}return{min:n,max:i}}function $3(e){let t=e[0];for(let n of e)kg(t.min,t.min,n.min),Dg(t.max,t.max,n.max);return t}function af(e){return YU([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function K3(e,t){return Math.min(Math.max(e,t[0]),t[1])}function Jw(e,t){let n=t.length,i=new Float32Array(e*n);for(let r=0;r<e;r++)i.set(t,r*n);return i}function fM(e){let t=sf(W3,e),n=t.encoder;if(!n)throw Error(`${qd}: encoder dependency required — install "meshoptimizer".`);return rf(qd,async(i)=>{let r=i.getLogger();if(i.hasExtension("KHR_mesh_primitive_restart"))throw Error("reorder: Missing support for KHR_mesh_primitive_restart.");await n.ready;let s=X3(i);for(let a of s.indicesToAttributes.keys()){let o=a.getArray();if(!(o instanceof Uint32Array))o=new Uint32Array(o);else o=o.slice();let[c,l]=n.reorderMesh(o,s.indicesToMode.get(a)===Wn.Mode.TRIANGLES,t.target==="size"),u=Yd(i,a);u.setArray(l<=65534?new Uint16Array(o):o);for(let d of s.indicesToAttributes.get(a)){let f=Yd(i,d);Og(d,a,c,f,l);for(let h of s.indicesToPrimitives.get(a)){if(h.getIndices()===a)h.swap(a,u);h.swap(d,f);for(let y of h.listTargets())y.swap(d,f)}}}if(t.cleanup)await i.transform(oM({propertyTypes:[ne.ACCESSOR],keepAttributes:!0,keepIndices:!0}));if(!s.indicesToAttributes.size)r.warn(`${qd}: No qualifying primitives found; may need to weld first.`);else r.debug(`${qd}: Complete.`)})}function X3(e){let t=new Map,n=new Ng,i=new Ng,r=new Ng;for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives()){let o=a.getIndices();if(!o)continue;t.set(o,a.getMode()),n.add(o,a);for(let c of eM(a))i.add(o,c),r.add(c,a)}return{indicesToPrimitives:n,indicesToAttributes:i,indicesToMode:t,attributesToPrimitives:r}}function J3(e,t,n,i=0.0001){let r=t.length/e.length,s=Array(r).fill(0),a=Array(r).fill(0),o=Array(r).fill(0),c=Array(r).fill(0),l=e.length-1,u=1;for(let d=1;d<l;++d){let f=e[u-1],h=e[d],y=e[d+1],g=(h-f)/(y-f),m=!1;if(h!==y&&(d!==1||h!==e[0])){if(ml(t,u-1,c),ml(t,d,a),ml(t,d+1,o),n==="slerp"){let p=Q3(s,c,o,g),b=Qw(c,a)+Qw(a,o);m=!Jd(a,p,i)||b+Number.EPSILON>=Math.PI}else if(n==="lerp")m=!Jd(a,Y3(s,c,o,g),i);else if(n==="step")m=!Jd(a,c)||!Jd(a,o)}if(m){if(d!==u)e[u]=e[d],Yw(t,u,ml(t,d,s));u++}}if(l>0)e[u]=e[l],Yw(t,u,ml(t,l,s)),u++;return u}function ml(e,t,n){for(let i=0,r=n.length;i<r;i++)n[i]=e[t*r+i];return n}function Yw(e,t,n){for(let i=0,r=n.length;i<r;i++)e[t*r+i]=n[i]}function Jd(e,t,n=0){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(Math.abs(e[i]-t[i])>n)return!1;return!0}function Z3(e,t,n){return e*(1-n)+t*n}function Y3(e,t,n,i){for(let r=0;r<t.length;r++)e[r]=Z3(t[r],n[r],i);return e}function Q3(e,t,n,i){let r=t[0],s=t[1],a=t[2],o=t[3],c=n[0],l=n[1],u=n[2],d=n[3],f,h,y,g,m;if(h=r*c+s*l+a*u+o*d,h<0)h=-h,c=-c,l=-l,u=-u,d=-d;if(1-h>q3)f=Math.acos(h),y=Math.sin(f),g=Math.sin((1-i)*f)/y,m=Math.sin(i*f)/y;else g=1-i,m=i;return e[0]=g*r+m*c,e[1]=g*s+m*l,e[2]=g*a+m*u,e[3]=g*o+m*d,e}function Qw(e,t){let n=e9(e,t);return Math.acos(2*n*n-1)}function e9(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}var WU,t5,n5,i5,r5,s5,a5,o5,Ng=class{_map=new Map;get size(){return this._map.size}has(e){return this._map.has(e)}add(e,t){let n=this._map.get(e);if(!n)n=new Set,this._map.set(e,n);return n.add(t),this}get(e){return this._map.get(e)||new Set}keys(){return this._map.keys()}},c5,Qd,Bw=4294967295,a3,l5,u5,d5,f5,h5,p5,m5,$s="dedup",Pg,g5,b5,sM,b3,aM,y3,Ho="prune",Lg=0.011764705882352941,jw,E3=class{disposed={};empty(){for(let e in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(e){this.disposed[e.propertyType]=this.disposed[e.propertyType]||0,this.disposed[e.propertyType]++}},y5,x5,_5,v5,E5,Gs="quantize",P3,O3,k3,D3,L3,F3,Zd,qd="reorder",W3,T5,Zw,q3=0.000001,A5,S5,w5,M5,R5,I5,C5,N5;var hM=Ft(()=>{fl();Uw();Kd();WU=bf(Rg(),1),{POINTS:t5,LINES:n5,LINE_STRIP:i5,LINE_LOOP:r5,TRIANGLES:s5,TRIANGLE_STRIP:a5,TRIANGLE_FAN:o5}=Wn.Mode;c5=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});Qd=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;a3=r3;(function(){var e=i3();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();({FLOAT:l5}=Be.ComponentType),{LINES:u5,LINE_STRIP:d5,LINE_LOOP:f5,TRIANGLES:h5,TRIANGLE_STRIP:p5,TRIANGLE_FAN:m5}=Wn.Mode,Pg={keepUniqueNames:!1,propertyTypes:[ne.ACCESSOR,ne.MESH,ne.TEXTURE,ne.MATERIAL,ne.SKIN]};({TEXTURE_INFO:g5,ROOT:b5}=ne);sM=h3,b3=p3,aM=g3;(function(){var e=rM();return function(t,n,i,r,s,a){var o,c;if(!n)n=4;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();y3=/color|emissive|diffuse/i;jw={propertyTypes:[ne.NODE,ne.SKIN,ne.MESH,ne.CAMERA,ne.PRIMITIVE,ne.PRIMITIVE_TARGET,ne.ANIMATION,ne.MATERIAL,ne.TEXTURE,ne.ACCESSOR,ne.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};({ROOT:y5,NODE:x5,MESH:_5,PRIMITIVE:v5,ACCESSOR:E5}=ne);P3=[Int8Array,Int16Array,Int32Array],{TRANSLATION:O3,ROTATION:k3,SCALE:D3,WEIGHTS:L3}=Ca.TargetPath,F3=[O3,k3,D3],Zd={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};W3={target:"size",cleanup:!0};T5={level:"high",...Zd};(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(Zw||(Zw={}));A5={ready:Promise.resolve(),resample:J3,tolerance:0.0001,cleanup:!0},{POINTS:S5,LINES:w5,LINE_STRIP:M5,LINE_LOOP:R5,TRIANGLES:I5,TRIANGLE_STRIP:C5,TRIANGLE_FAN:N5}=Wn.Mode});function mM(e,t,n,i={}){if(!Array.isArray(t))return e.push({code:"EXPECTED_ARRAY",path:n,message:`${n} must be an array.`}),!1;if(!i.allowEmpty&&t.length===0)e.push({code:"EXPECTED_NONEMPTY_ARRAY",path:n,message:`${n} must not be empty.`});let r=new Set;for(let s=0;s<t.length;s++){let a=t[s];if(!Hr(a)){e.push({code:"EXPECTED_NONEMPTY_STRING",path:`${n}[${s}]`,message:`${n}[${s}] must be a trimmed non-empty string.`});continue}if(r.has(a))e.push({code:"DUPLICATE_VALUE",path:`${n}[${s}]`,message:`${n} contains duplicate value ${JSON.stringify(a)}.`});r.add(a)}return!0}function i9(e,t,n){let i=`frames[${t}]`;if(!Ks(e))return n.push({code:"INVALID_FRAME",path:i,message:`${i} must be an object.`}),!1;if(!Hr(e.id))n.push({code:"INVALID_FRAME_ID",path:`${i}.id`,message:"Frame ID is required."});if(!pM(e.translation,3))n.push({code:"INVALID_FRAME_TRANSLATION",path:`${i}.translation`,message:"Frame translation must be three finite meters."});if(!pM(e.rotation,4))n.push({code:"INVALID_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation must be a finite quaternion."});else{let r=Math.hypot(...e.rotation);if(Math.abs(r-1)>0.000001)n.push({code:"NON_UNIT_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation quaternion must be normalized within 1e-6."})}return!0}function r9(e,t,n){let i=`relationships[${t}]`;if(!Ks(e))return n.push({code:"INVALID_RELATIONSHIP",path:i,message:`${i} must be an object.`}),!1;for(let r of["kind","target"])if(!Hr(e[r]))n.push({code:"INVALID_RELATIONSHIP_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(e.targetType!=="node"&&e.targetType!=="role"&&e.targetType!=="socket")n.push({code:"INVALID_RELATIONSHIP_TARGET_TYPE",path:`${i}.targetType`,message:"Relationship targetType must be node, role, or socket."});for(let r of["sourceFrame","targetFrame"])if(e[r]!==void 0&&!Hr(e[r]))n.push({code:"INVALID_RELATIONSHIP_FRAME",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});return!0}function s9(e,t,n){let i=`sockets[${t}]`;if(!Ks(e))return n.push({code:"INVALID_SOCKET",path:i,message:`${i} must be an object.`}),!1;for(let r of["id","type","frame"])if(!Hr(e[r]))n.push({code:"INVALID_SOCKET_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(mM(n,e.compatibleTypes,`${i}.compatibleTypes`,{allowEmpty:!0}),e.allowedRotationsDegrees!==void 0){if(!Array.isArray(e.allowedRotationsDegrees)||e.allowedRotationsDegrees.some((r)=>typeof r!=="number"||!Number.isFinite(r)))n.push({code:"INVALID_ALLOWED_ROTATIONS",path:`${i}.allowedRotationsDegrees`,message:"Allowed rotations must be finite degree values."})}return!0}function a9(e){let t=[];if(!Ks(e))return{valid:!1,issues:[{code:"EXPECTED_OBJECT",path:"",message:"SemanticMetadataV1 must be an object."}]};if(e.schemaVersion!==1)t.push({code:"UNSUPPORTED_SCHEMA_VERSION",path:"schemaVersion",message:"schemaVersion must be 1."});mM(t,e.roles,"roles");let n=Array.isArray(e.frames)?e.frames:[];if(!Array.isArray(e.frames))t.push({code:"EXPECTED_ARRAY",path:"frames",message:"frames must be an array."});let i=new Set;n.forEach((o,c)=>{if(i9(o,c,t),Ks(o)&&Hr(o.id)){if(i.has(o.id))t.push({code:"DUPLICATE_FRAME_ID",path:`frames[${c}].id`,message:`Duplicate frame ID ${JSON.stringify(o.id)}.`});i.add(o.id)}});let r=Array.isArray(e.relationships)?e.relationships:[];if(!Array.isArray(e.relationships))t.push({code:"EXPECTED_ARRAY",path:"relationships",message:"relationships must be an array."});r.forEach((o,c)=>{if(r9(o,c,t),Ks(o))for(let l of["sourceFrame","targetFrame"]){let u=o[l];if(Hr(u)&&!i.has(u))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`relationships[${c}].${l}`,message:`Unknown frame ${JSON.stringify(u)}.`})}});let s=Array.isArray(e.sockets)?e.sockets:[];if(!Array.isArray(e.sockets))t.push({code:"EXPECTED_ARRAY",path:"sockets",message:"sockets must be an array."});let a=new Set;if(s.forEach((o,c)=>{if(s9(o,c,t),Ks(o)&&Hr(o.id)){if(a.has(o.id))t.push({code:"DUPLICATE_SOCKET_ID",path:`sockets[${c}].id`,message:`Duplicate socket ID ${JSON.stringify(o.id)}.`});a.add(o.id)}if(Ks(o)&&Hr(o.frame)&&!i.has(o.frame))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`sockets[${c}].frame`,message:`Unknown frame ${JSON.stringify(o.frame)}.`})}),t.length>0)return{valid:!1,issues:t};return{valid:!0,value:o9(e),issues:t}}function o9(e){return{schemaVersion:1,roles:[...e.roles],relationships:e.relationships.map((t)=>({kind:t.kind,target:t.target,targetType:t.targetType,...t.sourceFrame?{sourceFrame:t.sourceFrame}:{},...t.targetFrame?{targetFrame:t.targetFrame}:{}})),frames:e.frames.map((t)=>({id:t.id,translation:t9(t.translation),rotation:n9(t.rotation)})),sockets:e.sockets.map((t)=>({id:t.id,type:t.type,frame:t.frame,compatibleTypes:[...t.compatibleTypes],...t.allowedRotationsDegrees?{allowedRotationsDegrees:[...t.allowedRotationsDegrees]}:{}}))}}function Bg(e){let t=e.kilnSemantic;if(t===void 0)return;let n=a9(t);return n.valid?n.value:void 0}var Na,Ks=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Hr=(e)=>typeof e==="string"&&e.trim().length>0&&e===e.trim(),pM=(e,t)=>Array.isArray(e)&&e.length===t&&e.every((n)=>typeof n==="number"&&Number.isFinite(n)),t9=(e)=>[e[0],e[1],e[2]],n9=(e)=>[e[0],e[1],e[2],e[3]];var of=Ft(()=>{Na=Object.freeze({vehicleFrame:"vehicle.frame",vehicleForward:"vehicle.front.+x",socket:"socket",chassis:"chassis",chassisMain:"chassis.main",axle:"axle",seat:"seat",contact:"contact",steering:"steering",propulsion:"propulsion",wheelAssembly:"wheel.assembly",wheelPivot:"wheel.pivot",wheelLoadBearing:"wheel.load-bearing",wheelTire:"wheel.tire",wheelRim:"wheel.rim",wheelHub:"wheel.hub",wheelContact:"wheel.contact",steeringPivot:"steering.pivot",roof:"roof",architectureRoof:"architecture.roof",collider:"collider",colliderBox:"collider.box",colliderCapsule:"collider.capsule",colliderHull:"collider.hull",anchor:"anchor",kitModule:"kit.module",kitPort:"kit.port",lodImpostor:"lod.impostor"})});function yM(){return new RS().registerExtensions([...hw,bM])}var di="MSFT_lod",gM,bM;var zg=Ft(()=>{fl();Kd();gM=class gM extends nt{static EXTENSION_NAME=di;init(){this.extensionName=di,this.propertyType="Lod",this.parentTypes=[ne.NODE,ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{levels:new bn})}addLevel(e){return this.addRef("levels",e)}listLevels(){return this.listRefs("levels")}};bM=class bM extends xt{extensionName=di;static EXTENSION_NAME=di;createLod(e=""){return new gM(this.document.getGraph(),e)}read(e){let t=e.jsonDoc.json;return this.readLevels(t.nodes,e.nodes),this.readLevels(t.materials,e.materials),this}readLevels(e,t){(e??[]).forEach((n,i)=>{let r=n.extensions?.[di]?.ids,s=t[i];if(!s||!Array.isArray(r))return;let a=this.createLod();for(let o of r){let c=typeof o==="number"?t[o]:void 0;if(c&&c!==s)a.addLevel(c)}s.setExtension(di,a)})}write(e){let t=e.jsonDoc.json,n=this.document.getRoot();for(let i of n.listNodes()){let r=e.nodeIndexMap.get(i),s=i.getExtension(di)?.listLevels().filter((o)=>o.propertyType===ne.NODE).map((o)=>e.nodeIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.nodes?.[r];if(a&&s?.length)a.extensions={...a.extensions,[di]:{ids:s}}}for(let i of n.listMaterials()){let r=e.materialIndexMap.get(i),s=i.getExtension(di)?.listLevels().filter((o)=>o.propertyType===ne.MATERIAL).map((o)=>e.materialIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.materials?.[r];if(a&&s?.length)a.extensions={...a.extensions,[di]:{ids:s}}}return this}}});var c9;var Vg=Ft(()=>{c9=Object.freeze([1,1,1])});var G5,$5;var xM=Ft(()=>{Vg();G5=Object.freeze({units:"m",forward:"+X",up:"+Y",right:"+Z",groundY:0}),$5=Math.PI/180});var _M=()=>{};var vM=()=>{};var EM=Ft(()=>{xM();Vg();_M();vM();of()});var l9;var TM=Ft(()=>{l9=Object.freeze({parametricSamples:262144,subdivisionTriangles:1e6,subdivisionAttributeBytes:134217728,subdivisionIterations:10,repeatedMeshes:1e4,primitiveSegments:4096,primitiveGridVertices:262144,unwrapVertices:65536,unwrapTriangles:1e6,unwrapAttributeBytes:134217728,unwrapResolution:4096,skinBones:1024,skinVertices:262144,skinAttributeBytes:134217728,colliderHullVertices:65536,surfaceBakeVertices:262144,surfaceBakeTriangles:1e6,surfaceBakeRays:8388608,surfaceBakeRayDirections:256})});var jg="kilnRepeatInstances";var Hg=Ft(()=>{EM();ou();TM()});function gl(e){return e.getExtension("KHR_node_visibility")?.getVisible?.()===!1}var lK;var cf=Ft(()=>{lK=[{grade:"A",max:1,range:"0-1"},{grade:"B",max:3,range:"2-3"},{grade:"C",max:6,range:"4-6"},{grade:"D",max:12,range:"7-12"},{grade:"F",max:Number.POSITIVE_INFINITY,range:"13+"}]});var AM=Ft(()=>{cf()});function wM(e){let t=new Map,n=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!n)return t;let i=(r,s)=>{let a=new Map;for(let o of r){let c=o.getName(),l=a.get(c)??0;a.set(c,l+1);let u=`${s}${SM(c,l)}`;t.set(o,u),i(o.listChildren(),u)}};return i(n.listChildren(),SM(n.getName()||"Scene",0)),t}var SM=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var MM=Ft(()=>{zg();of();Hg();cf();AM()});var NM={};pb(NM,{deliverRuntimeThreeGlb:()=>m9});function d9(e,t){let n=(i)=>{if(!i)return-1;if(!t.has(i))t.set(i,t.size);return t.get(i)};return e.listPrimitives().map((i)=>`${i.getMode()}:${n(i.getMaterial())}:${n(i.getIndices())}:${i.listSemantics().sort().map((r)=>`${r}=${n(i.getAttribute(r))}`).join(",")}:${i.listTargets().length}`).join("|")}function f9(e){let t=[],n=new Map,i=e.getRoot().listNodes().filter((s)=>s.getExtras()[jg]!==void 0),r;for(let s of i){let a=new Map;for(let l of s.listChildren()){let u=l.getMesh();if(!u||l.listChildren().length||l.getSkin()||l.listExtensions().length||gl(l)||bl(l).length||Object.keys(l.getExtras()).length||l.getWeights().length)continue;let d=d9(u,n);a.set(d,[...a.get(d)??[],l])}let o=0;for(let l of a.values()){if(l.length<2)continue;let u=l[0].getMesh();r??=e.createExtension($d).setRequired(!0);let d=e.getRoot().listBuffers()[0],f=(_,x)=>e.createAccessor().setType(_).setArray(new Float32Array(x)).setBuffer(d??null),h=[],y=[],g=[];for(let _ of l)h.push(..._.getTranslation()),y.push(..._.getRotation()),g.push(..._.getScale());let m=r.createInstancedMesh().setAttribute("TRANSLATION",f("VEC3",h)).setAttribute("ROTATION",f("VEC4",y)).setAttribute("SCALE",f("VEC3",g)),p=`${s.getName()||"Node"}_Instances${o?`_${o}`:""}`;o++;let b=e.createNode(p).setMesh(u).setExtension("EXT_mesh_gpu_instancing",m);s.addChild(b),t.push({node:b,mesh:u.getName(),count:l.length,instances:l.map((_)=>_.getName())});for(let _ of l){let x=_.getMesh();if(_.dispose(),x&&x!==u&&!x.listParents().some((v)=>v.propertyType===ne.NODE))x.dispose()}}let c={...s.getExtras()};delete c[jg],s.setExtras(c)}return t}function h9(e){let t=[];for(let n of e.getRoot().listNodes()){let i=n.getMesh();if(!i||!CM(n))continue;let r=e.createNode(`${n.getName()}_Proxy`).setMesh(i);n.setMesh(null).addChild(r),t.push({collider:n,proxy:r})}return t}async function p9(e,t){let n=e.getRoot().listTextures().filter((r)=>r.getMimeType()!=="image/ktx2"&&r.getImage());if(!t)return{status:"skipped",textures:n.length,reason:"No KTX2 encoder was supplied; textures stay PNG or JPEG."};let i=new Set;for(let r of e.getRoot().listMaterials())for(let s of[r.getBaseColorTexture(),r.getEmissiveTexture()])if(s)i.add(s);for(let r of n){let s=await t({image:r.getImage(),mimeType:r.getMimeType(),name:r.getName(),colorSpace:i.has(r)?"srgb":"linear"});if(!(s instanceof Uint8Array)||s.byteLength<12)throw Error("ktx2Encoder must return KTX2 bytes");r.setImage(s).setMimeType("image/ktx2");let a=r.getURI();if(a)r.setURI(a.replace(/\.(png|jpe?g)$/i,".ktx2"))}if(n.length)e.createExtension(Mg).setRequired(!0);return{status:"encoded",textures:n.length}}function IM(e,t){let n=new Qe().fromArray(e).invert().multiply(new Qe().fromArray(t)),i=new j,r=new ln,s=new j;return n.decompose(i,r,s),{scale:s.x,offset:[i.x,i.y,i.z]}}async function m9(e,t,n={}){let i=yM().registerDependencies({"meshopt.encoder":t}),r=await i.readBinary(e);r.setLogger(new Ia(Ia.Verbosity.SILENT)),await r.transform(Ug({propertyTypes:[ne.ACCESSOR],keepUniqueNames:!0}));let s=f9(r),a=h9(r),o=new Map;for(let b of r.getRoot().listNodes())if(b.getMesh())o.set(b,[...b.getMatrix()]);await r.transform(fM({encoder:t,target:"size"}),uM({pattern:RM,patternTargets:RM,quantizationVolume:"mesh",quantizePosition:yr.position,quantizeNormal:yr.normal,quantizeTexcoord:yr.texcoord,quantizeColor:yr.color,quantizeWeight:yr.weight})),r.createExtension(pl).setRequired(!0).setEncoderOptions({method:pl.EncoderMethod.QUANTIZE});let c=await p9(r,n.ktx2Encoder);for(let b of r.getRoot().listNodes()){if(!b.getMesh()||o.has(b)||b.getName())continue;let x=b.getParentNode();b.setName(`${x?.getName()||"Node"}_Mesh`)}let l=wM(r),u=(b)=>l.get(b)??`#${encodeURIComponent(b.getName())}`,d=new Set(a.map((b)=>b.proxy)),f=[];for(let b of r.getRoot().listNodes()){let _=b.getMesh();if(!_||b.getExtension("EXT_mesh_gpu_instancing"))continue;let x=l.get(b);if(x===void 0)continue;let v=o.get(b),E=v===void 0,S=E||d.has(b),T=E?new Qe().identity().toArray():v,A=[...b.getMatrix()],{scale:P,offset:w}=IM(T,A);if(!E&&Math.abs(P-1)<0.000000000001&&w.every((F)=>F===0))continue;let I=b.getParentNode();f.push({node:x,mesh:_.getName(),meshMovedToChild:S,...S&&I?{authoredNode:u(I)}:{},dequantization:{scale:P,offset:w},localScale:[...b.getScale()]})}for(let b of r.getRoot().listNodes()){let _=b.getMesh();if(!_||l.has(b)||!o.has(b))continue;let{scale:x,offset:v}=IM(o.get(b),[...b.getMatrix()]);f.push({node:`#lod/${encodeURIComponent(b.getName())}`,mesh:_.getName(),meshMovedToChild:!1,dequantization:{scale:x,offset:v},localScale:[...b.getScale()]})}let h=new Map;for(let b of r.getRoot().listMeshes())for(let _ of b.listPrimitives())for(let x of _.listSemantics())if(x.startsWith("_"))h.set(x,(h.get(x)??new Set).add(b));let y=r.getRoot().listNodes(),g=await i.writeBinary(r),m=(await i.binaryToJSON(g)).json,p={target:"three",extensionsUsed:[...m.extensionsUsed??[]].sort(),extensionsRequired:[...m.extensionsRequired??[]].sort(),compression:{extension:"EXT_meshopt_compression",method:"quantize"},quantization:{extension:"KHR_mesh_quantization",volume:"mesh",bits:{position:yr.position,normal:yr.normal,texcoord:yr.texcoord,color:yr.color,weight:yr.weight},customAttributes:"float32"},nodeScale:f,colliderProxies:a.map(({collider:b,proxy:_})=>({collider:u(b),proxy:u(_)})),customAttributes:[...h].sort(([b],[_])=>b==="_EDGE"?-1:_==="_EDGE"?1:b<_?-1:b>_?1:0).map(([b,_])=>({name:b,meshes:_.size,componentType:"FLOAT",normalized:!1})),instancing:s.map(({node:b,..._})=>({node:u(b),..._})),ktx2:c,preserved:{lodChains:y.filter((b)=>b.getExtension(di)).length,hiddenNodes:y.filter((b)=>gl(b)).length,colliders:y.filter(CM).length,anchors:y.filter((b)=>bl(b).some((_)=>_.startsWith(`${Na.anchor}.`))).length,ports:y.filter((b)=>bl(b).some((_)=>_.startsWith(`${Na.kitPort}.`))).length,kitModules:y.filter((b)=>bl(b).includes(Na.kitModule)).length}};return{glb:g,delivery:p}}var yr,RM,bl=(e)=>Bg(e.getExtras())?.roles??[],CM=(e)=>bl(e).some((t)=>t.startsWith(`${Na.collider}.`));var PM=Ft(()=>{fl();Kd();hM();zi();of();zg();MM();Hg();cf();yr=Object.freeze({volume:"mesh",position:14,normal:10,texcoord:12,color:8,weight:8}),RM=/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/});var g9;var OM=Ft(()=>{g9=function(){var e="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:8f8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkaraHcd4faAcdVaoaocdSE86bbaHclfgHal6mbkkabaefhgabcefhoalcd4g8McbaDEhkadcefh8Narc;abfceVhecbhmdndninaiam9nmearc;qofcbcjdz:xjjjb8Aagao9Rak6mdadamal2gwfhxcbhHa8Nawfhzaocbakz:xjjjbg8Fakfh3aqaiam9Ramaqfai6Egscsfgocl4cifcd4hOaoc9WGg8JThPindndndndndndndndndndnaDTmbaraHcd4fRbbgQciGPlbedlbkasTmdaxaHfhoarc;abfaHfRbbhQarc;qofhwashCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaCcufgCmbxikkasTmiaHcitcwGh8Aarc;abfaHceVfRbbcwtarc;abfaHc9:GgofRbbVhQaxaofhoarc;qofhwashCinawao8VbbgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbawcefhwaoalfhoaYhQaCcufgCmbxikkaeaHc98Gg8Afhoaza8AfhYarc;abfa8AfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbkasTmdaQcl4hKaHcitcKGhEaxa8Afh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aK93aE486bbaYalfhYa8Aalfh8AaQhCaLcefgLas9hmbkkaDmbcbhoxlka8JTmbcbhodninarc;qofaofgwcwf8Pibaw8Pib:e9qTmeaoczfgoa8J9pmdxbkkdnavmbcehoxikcbh8AaOhLaOhKinarc;qofa8Afgocwf8Pibhyao8Pibh8PcdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgoaYaoaY6Egoczaocz6EaKfhKaocucbaya8P:e9cb9sEgwaoaw6EaLfhLa8Aczfg8Aa8J9pmdxbkka8FaHcd4fgoaoRbbcdaHcetcoGtV86bbxikdnaLas6mbaKas6mba8FaHcd4fgoaoRbbciaHcetcoGtV86bbaga39Ras6mra3arc;qofasz:wjjjbasfh3xikaLaK9phoka8FaHcd4fgwawRbbaoaHcetcoGtV86bbkaga39RaO6mla3cbaOz:xjjjbgaaOfhKdndna8JmbaPhoxekdnagaK9RcK9pmbaPhoxekaocdtc:q:G:cjbfcj:G:cjbaDEg3ydxghcetc;:FFFeGhAcuhEcuahtcu7cFeGh8Ecbh8Karc;qofhQinarc;qofa8KfhXczh8AdndndnahPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEh8AxekcbhoaAh8Aina8Aa8EaQaofRbb9nfh8Aaocefgocz9hmbkkcih5cbhYinczhwdndndna3aYcdtfydbgLPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEhwxekaLcetc;:FFFeGhwcuaLtcu7cFeGhCcbhoinawaCaQaofRbb9nfhwaocefgocz9hmbkkdndnawa8A6mbaLaE9hmeawa8A9hmea3a5cdtfydbcwSmekaYh5awh8AkaYcefgYci9hmbkaaa8Kco4fgoaoRbba5a8Kci4coGtV86bbdndndna3a5cdtfydbgEPDdbbbbbbbebkdncwaE9Tg5TmbcuaEtcu7hwdndnaEceSmbcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCaEtVhCaocefhoaYcufgYmbkaKaC86bbaXa5fhXaKcefhKa8La5fg8Lcz6mbxdkkcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCcetVhCaocefhoaYcufgYmbkaKaC:T9cFe:d9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:9ca188bbaXa5fhXaKcefhKa8La5fg8Lcz6mbkkcbhoinaKaQaofRbbgC86bbaKaCawcFeG9pfhKaocefgocz9hmbxikkdnaEceSmbinaKcb86bbaKcefhKxbkkinaKcb86bbaKcefhKxbkkaKaX8Pbw83bwaKaX8Pbb83bbaKczfhKka8Kczfg8Ka8J9pgomeaQczfhQagaK9RcK9pmbkkaoTmlaKh3aKTmlkaHcefgHal9hmbkarc;abfaxascufal2falz:wjjjb8Aasamfhma3hoa3mbkcbhwxdkdnagao9RakalfgwcKcaaDEgQawaQ0EgC9pmbcbhwxdkdnawaQ9pmbaocbaCaw9Rgwz:xjjjbawfhokaoarc;adfalz:wjjjbalfhodnaDTmbaoara8Mz:wjjjba8Mfhokaoab9Rhwxekcbhwkarc;qwf8Kjjjjbawk5babaeadaialcdcbyd;i:I:cjbz:bjjjbk9reduaecd4gdaefgicaaica0Eabcj;abae9Uc;WFbGcjdaeca0Egifcufai9Uae2aiadfaicl4cifcd4f2fcefkmbcbabBd;i:I:cjbk;HPeLu8Jjjjjbc;ae9Rgl8Kjjjjbcbhvdnaeaici9UgocHf6mbabcbyd;m:I:cjbgrc;GeV86bbalc;abfcFecjez:xjjjb8Aal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibabaefc9WfhwabcefgDaofhednaiTmbcmcsarcb9kgqEhkcbhxcbhmcbhPcbhscbhzindnaeaw9nmbcbhvxikazcufhvadaPcdtfgHydbhOaHcwfydbhAaHclfydbhCcbhXdndndninalc;abfavcsGcitfgoydlhQdndndnaoydbgoaO9hmbaQaCSmekdnaoaC9hmbaQaA9hmbaXcefhXxekaoaA9hmeaQaO9hmeaXcdfhXkaXc870mdascufhvaHaXcdtgAcxGgoyd:4:G:cjbcdtfydbhQaHaoyd:0:G:cjbcdtfydbhCaHaoyd:W:G:cjbcdtfydbhOcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaQaxSgvaXce9iaXak9oVgoGfhxdndndncbcsavEaXaoEgvcs9hmbarce9imbaQaQamaQcefamSgvEgmcefSmecmcsavEhvkaDavaAc;WeGV86bbavcs9hmeaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmxvkcPhvaDaAcPV86bbaQhmkavTmiavak9omicdhocehXazhAxlkavcufhvaXclfgXc;ab9hmbkkdnaHcecdcbaAaxSEaCaxSEcdtgvyd:W:G:cjbcdtfydbgOTaHavyd:0:G:cjbcdtfydbgCceSGaHavyd:4:G:cjbcdtfydbgQcdSGaxcb9hGaqGgLce9hmbal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibcbhxkcbhXascufgvhodnindnalaocsGcdtfydbaC9hmbaXhAxdkcuhAaocufhoaXcefgXcz9hmbkkcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaOaxSgKfhHdndnaAcm0mbaAcefhAxekcbcsaCaHSgvEhAaHavfhHkdndnaXcm0mbaXcefhXxekcbcsaQaHSgvEhXaHavfhHkc9:cuaKEhYcbhvaXaAcltVg8AcFeGhodndndninavc;q:G:cjbfRbbaoSmeavcefgvcz9hmbxdkkaLaOax9havcm0VVmbaDavc;WeV86bbxekaDaY86bbaea8A86bbaecefhekdnaKmbaOam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaOhmkdnaAcs9hmbaCam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaChmkdnaXcs9hmbaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmkalascdtfaOBdbascefcsGhvdndnaAPzbeeeeeeeeeeeeeebekalavcdtfaCBdbascdfcsGhvkdndnaXPzbeeeeeeeeeeeeeebekalavcdtfaQBdbavcefcsGhvkcihoalc;abfazcitfgXaOBdlaXaCBdbazcefcsGhAcdhXavhsaHhxxekcdhoalascdtfaQBdbcehXascefcsGhsazhAkalc;abfaAcitfgvaCBdlavaQBdbalc;abfazaXfcsGcitfgvaQBdlavaOBdbaDcefhDazaofcsGhzaPcifgPai6mbkkdnaeaw9nmbcbhvxekcbhvinaeavfavc;q:G:cjbfRbb86bbavcefgvcz9hmbkaeab9Ravfhvkalc;aef8KjjjjbavkZeeucbhddninadcefgdc8F0meaeceadt0mbkkadcrfcFeGcr9Uci2cdfabci9U2cHfkmbcbabBd;m:I:cjbk:zderu8Jjjjjbcz9Rhlcbhvdnaeaicvf6mbabcbRb;m:I:cjbc;qeV86bbal9cb83iwabcefhvabaefc98fhodnaiTmbcbhecbhrcbhwindnavao6mbcbskadawcdtfydbgDalcwfaraDae9Rgeaec8F91ge7ae9Rc507grcdtfgqydb9Rgec8E91c9:Gaecdt7arVheinavcbcjeaecje6EaecFbGV86bbavcefhvaecr4gembkaqaDBdbaDheawcefgwai9hmbkkdnavao9nmbcbskavcbBbbavab9RclfhvkavkBeeucbhddninadcefgdc8F0meaeceadt0mbkkabadcwfcFeGcr9U2cvfk:dvli99dui99ludnaeTmbcuadcetcuftcu7:Zhvdndncuaicuftcu7:ZgoJbbbZMgr:lJbbb9p9DTmbar:Ohwxekcjjjj94hwkcbhicbhDinalclfIdbgrJbbbbJbbjZalIdbgq:lar:lMalcwfIdbgk:lMgr:varJbbbb9BEgrNhxaqarNhralcxfIdbhqdndnakJbbbb9GTmbaxhkxekJbbjZar:l:tgkak:maxJbbbb9GEhkJbbjZax:l:tgxax:marJbbbb9GEhrkdndnaqJbbj:;aqJbbj:;9GEgxJbbjZaxJbbjZ9FEavNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohmxekcjjjj94hmkdndnakJbbj:;akJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;akJbbbb9GEMgq:lJbbb9p9DTmbaq:OhPxekcjjjj94hPkdndnarJbbj:;arJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;arJbbbb9GEMgr:lJbbb9p9DTmbar:Ohsxekcjjjj94hskdndnadcl9hmbabaDfgzas86bbazcifam86bbazcdfaw86bbazcefaP86bbxekabaifgzas87ebazcofam87ebazclfaw87ebazcdfaP87ebkaicwfhiaDclfhDalczfhlaecufgembkkk;hlld99eud99eudnaeTmbdndncuaicuftcu7:ZgvJbbbZMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikaic;8FiGhrinabcofcicdalclfIdb:lalIdb:l9EgialcwfIdb:lalaicdtfIdb:l9EEgialcxfIdb:lalaicdtfIdb:l9EEgiarV87ebdndnJbbj:;JbbjZalaicdtfIdbJbbbb9DEgoalaicd7cdtfIdbJ;Zl:1ZNNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabcdfaq87ebdndnalaicefciGcdtfIdbJ;Zl:1ZNaoNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabaq87ebdndnaoalaicufciGcdtfIdbJ;Zl:1ZNNgoJbbj:;aoJbbj:;9GEgwJbbjZawJbbjZ9FEavNJbbbZJbbb:;aoJbbbb9GEMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikabclfai87ebabcwfhbalczfhlaecufgembkkk;Pviwue99eu8Jjjjjbcjd9Rgo8Kjjjjbadcd4hrdndndnavcd9hmbarTmbaohdarhwinadc:CuBdbadclfhdawcufgwmbkaeTmdarcdthDalhqcbhkinaohdaqhwarhxinadadydbgmcbawIdbgP:8cL4cFeGc:cufaPJbbbb9BEgsamas9kEBdbawclfhwadclfhdaxcufgxmbkaqaDfhqakcefgkae9hmbxdkkaeTmekarcdthqavce9hhDcbhkindndndnaDmbarTmdc:CuhwalhdarhxinawcbadIdbgP:8cL4cFeGc:cufaPJbbbb9BEgmawam9kEhwadclfhdaxcufgxmbxdkkdndndndnavPleddbdkarTmlaohdalhwarhxinadcbcbawIdbgP:8cL4cFeGgmc:cufgsasam0EaPJbbbb9BEBdbadclfhdawclfhwaxcufgxmbxikkarTmicbhdarhwinaoadfcbaladfIdbgP:8cL4cFeGgxc8Aaxc8A0Ec:cufaPJbbbb9BEBdbadclfhdawcufgwmbxdkkarTmdkc:CuhwkcbhdarhminawhxdnavceSmbaoadfydbhxkdndnaladfIdbgPcjjj;8iaxai9RcefgxcLt9R::NJbbbZJbbb:;aPJbbbb9GEMgP:lJbbb9p9DTmbaP:Ohsxekcjjjj94hskabadfascFFFrGaxcKtVBdbadclfhdamcufgmmbkkabaqfhbalaqfhlakcefgkae9hmbkkaocjdf8Kjjjjbk:Olveue99iue99iudnaeTmbceaicufthvcuaitcu7:Zhocbhradcl9hhwcbhDindndnalcwfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohixekcjjjj94hikdndnalIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9TgkaifhidndnalclfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9ThddndnalcxfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohxxekcjjjj94hxkadaifhiaxce91avVhxdndnawmbabaDfgmai86bbamcifax86bbamcdfad86bbamcefak86bbxekabarfgmai87ebamcofax87ebamclfad87ebamcdfak87ebkarcwfhraDclfhDalczfhlaecufgembkkk;mqdQui998Jjjjjbc:qd9Rgv8Kjjjjbavc:Sefcbc;Kbz:xjjjb8AdnadTmbaiTmbdndnabaeSmbaehoxekavcuadcdtgradcFFFFi0Ecbyd;q:I:cjbHjjjjbbgoBd:SeavceBd:mdaoaearz:wjjjb8AkavcbBd:Oeav9cb83i:Geavc:Gefaoadaiavc:Sefz:pjjjbavyd:Gehwadci9UgDcbyd;q:I:cjbHjjjjbbheavc:Sefavyd:mdgqcdtfaeBdbavaqcefgrBd:mdaecbaDz:xjjjbhkavc:SefarcdtfcuaicdtaicFFFFi0Ecbyd;q:I:cjbHjjjjbbgxBdbavaqcdfgmBd:mdalc;ebfhPawheaxhrinaralIdbaPaeydbgscwascw6EcdtfIdbMUdbaeclfhearclfhraicufgimbkavc:SefamcdtfcuaDcdtadcFFFF970Ecbyd;q:I:cjbHjjjjbbgmBdbdnadci6mbaoheamhraDhiinaraxaeydbcdtfIdbaxaeclfydbcdtfIdbMaxaecwfydbcdtfIdbMUdbaecxfhearclfhraicufgimbkkaqcifhzalc;ebfhHavc;qbfhOavheavyd:KehAavyd:OehCcbhscbhrcbhXcehQinaehLaoarcx2fgKydbhPaKclfydbhdabaXcx2fgecwfaKcwfydbgYBdbaeclfadBdbaeaPBdbakarfce86bbaOaYBdwaOadBdlaOaPBdbamarcdtfcbBdbcih8AdnasTmbaLhiinaOa8AcdtfaiydbgeBdba8AaeaY9haeaP9haead9hGGfh8AaiclfhiascufgsmbkkaXcefhXcbhsinaCaAaKascdtfydbcdtgifydbcdtfgYheawaifgdydbgPhidnaPTmbdninaeydbarSmeaeclfheaicufgiTmdxbkkaeaYaPcdtfc98fydbBdbadadydbcufBdbkascefgsci9hmbkdndndna8ATmbcuhrJbbbbhEcbhdavyd:KehYavyd:OehKindnawaOadcdtfydbcdtgsfydbgeTmbaxasfgiIdbh3aialcuadadcs0EcdtfclfIdbaHaecwaecw6EcdtfIdbMg5Udba5a3:th5aecdthiaKaYasfydbcdtfheinamaeydbgscdtfgPa5aPIdbMg3Udba3aEaEa39DgPEhEasaraPEhraeclfheaic98fgimbkkadcefgda8A9hmbkarcu9hmekaQaD9pmeindnakaQfRbbmbaQhrxdkaDaQcefgQ9hmbxdkka8Acza8Acz6EhsaOheaLhOarcu9hmekkazTmbaqcdtavc:Seffcwfheinaeydbcbyd;u:I:cjbH:bjjjbbaec98fheazcufgzmbkkavc:qdf8Kjjjjbk:0leoucuaicdtgvaicFFFFi0Egocbyd;q:I:cjbHjjjjbbhralalyd9GgwcdtfarBdbalawcefBd9GabarBdbaocbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdlcuadcdtadcFFFFi0Ecbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdwabydbcbavz:xjjjb8AabydbhraehladhvinaralydbcdtfgoaoydbcefBdbalclfhlavcufgvmbkcbhvabydlglhoarhwaihDinaoavBdbaoclfhoawydbavfhvawclfhwaDcufgDmbkadci9Uhqdnadcd9nmbabydwhocbhvinaecwfydbhwaeclfydbhDalaeydbcdtfgbabydbgbcefBdbaoabcdtfavBdbalaDcdtfgDaDydbgDcefBdbaoaDcdtfavBdbalawcdtfgwawydbgwcefBdbaoawcdtfavBdbaecxfheaqavcefgv9hmbkkinalalydbarydb9RBdbarclfhralclfhlaicufgimbkkQbabaeadaic;G:G:cjbz:ojjjbkQbabaeadaic;i:H:cjbz:ojjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk:3vioud9:du8Jjjjjbc;Wa9Rgl8Kjjjjbcbhvalcxfcbc;Kbz:xjjjb8AalcuadcitgoadcFFFFe0Ecbyd;q:I:cjbHjjjjbbgrBdxalceBd2araeadaicezNjjjbalcuaoadcjjjjoGEcbyd;q:I:cjbHjjjjbbgwBdzadcdthednadTmbabhiinaiavBdbaiclfhiadavcefgv9hmbkkawaefhDalabBdwalawBdl9cbhqindnadTmbaq9cq9:hkarhvaDhiadheinaiav8Pibak1:NcFrG87ebavcwfhvaicdfhiaecufgembkkalclfaq:NceGcdtfydbhxalclfaq9ce98gq:NceGcdtfydbhmalc;Wbfcbcjaz:xjjjb8AaDhvadhidnadTmbinalc;Wbfav8VebcdtfgeaeydbcefBdbavcdfhvaicufgimbkkcbhvcbhiinalc;WbfavfgeydbhoaeaiBdbaoaifhiavclfgvcja9hmbkadhvdndnadTmbinalc;WbfaDamydbgicetf8VebcdtfgeaeydbgecefBdbaxaecdtfaiBdbamclfhmavcufgvmbkaq9cv9smdcbhvinabawydbcdtfavBdbawclfhwadavcefgv9hmbxdkkaq9cv9smekkcwhvcbhiinalcxfavfc98fydbcbyd;u:I:cjbH:bjjjbbaiceGheclhvcehiaeTmbkalc;Waf8Kjjjjbk:Awliuo99iud9:cbhv8Jjjjjbca9Rgocbyd:4:I:cjbBdKaocb8Pd:W:I:cjb83izaocbyd;e:I:cjbBdwaocb8Pd:8:I:cjb83ibaicd4hrdndnadmbJFFuFhwJFFuuhDJFFuuhqJFFuFhkJFFuuhxJFFuFhmxekarcdthPaehsincbhiinaoczfaifgzasaifIdbgwazIdbgDaDaw9EEUdbaoaifgzawazIdbgDaDaw9DEUdbaiclfgicx9hmbkasaPfhsavcefgvad9hmbkaoIdKhDaoIdwhwaoIdChqaoIdlhkaoIdzhxaoIdbhmkdnadTmbJbbbbJbFu9hJbbbbamax:tgmamJbbbb9DEgmakaq:tgkakam9DEgkawaD:tgwawak9DEgw:vawJbbbb9BEhwdnalmbarcdthoindndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:S9cC:ghHdndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikaHai:S:ehHdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaHai:T9cy:g:e83ibaeaofheabcwfhbadcufgdmbxdkkarcdthoindndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cv9:9c;j:KM;j:KM;j:Kd:dhOdndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cq9:9cM;j:KM;j:KM;jl:daO:ehOdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaOai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cC9:9c:KM;j:KM;j:KMD:d:e83ibaeaofheabcwfhbadcufgdmbkkk9teiucbcbyd;y:I:cjbgeabcifc98GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;y:I:cjbgeabcrfc94GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;y:I:cjbge9Rcifc98GaefgbBd;y:I:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk;Sddbcj:Gdk;idbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbbbbbbbbbbbbbbbbebbbdbbbbbbbebbbbbbbbbbbbbbbb4:h9w9N94:P:gW:j9O:ye9Pbbbbbb:l29hZ;69:9kZ;N;76Z;rg97Z;z;o9xZ8J;B85Z;:;u9yZ;b;k9HZ:2;Z9DZ9e:l9mZ59A8KZ:r;T3Z:A:zYZ79OHZ;j4::8::Y:D9V8:bbbb9s:49:Z8R:hBZ9M9M;M8:L;z;o8:;8:PG89q;x:J878R:hQ8::M:B;e87bbbbbbjZbbjZbbjZ:E;V;N8::Y:DsZ9i;H;68:xd;R8:;h0838:;W:NoZbbbb:WV9O8:uf888:9i;H;68:9c9G;L89;n;m9m89;D8Ko8:bbbbf:8tZ9m836ZS:2AZL;zPZZ818EZ9e:lxZ;U98F8:819E;68:FFuuFFuuFFuuFFuFFFuFFFuFbc;i:IdkCebbbebbbebbbdbbb9G:rbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(h){n=h.instance,n.exports.__wasm_call_ctors(),n.exports.meshopt_encodeVertexVersion(1),n.exports.meshopt_encodeIndexVersion(1)});function r(h){var y=new Uint8Array(h.length);for(var g=0;g<h.length;++g){var m=h.charCodeAt(g);y[g]=m>96?m-97:m>64?m-39:m+4}var p=0;for(var g=0;g<h.length;++g)y[p++]=y[g]<60?t[y[g]]:(y[g]-60)*64+y[++g];return y.buffer.slice(0,p)}function s(h){if(!h)throw Error("Assertion failed")}function a(h){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}function o(h,y,g,m){var p=n.exports.sbrk,b=p(y.length*4),_=p(g*4),x=new Uint8Array(n.exports.memory.buffer),v=a(y);if(x.set(v,b),m)m(b,b,y.length,g);var E=h(_,b,y.length,g);x=new Uint8Array(n.exports.memory.buffer);var S=new Uint32Array(g);new Uint8Array(S.buffer).set(x.subarray(_,_+g*4)),v.set(x.subarray(b,b+y.length*4)),p(b-p(0));for(var T=0;T<y.length;++T)y[T]=S[y[T]];return[S,E]}function c(h,y,g,m){var p=n.exports.sbrk,b=p(g*4),_=p(g*m),x=new Uint8Array(n.exports.memory.buffer);x.set(a(y),_),h(b,_,g,m),x=new Uint8Array(n.exports.memory.buffer);var v=new Uint32Array(g);return new Uint8Array(v.buffer).set(x.subarray(b,b+g*4)),p(b-p(0)),v}function l(h,y,g,m,p,b,_){var x=n.exports.sbrk,v=x(y),E=x(m*p),S=new Uint8Array(n.exports.memory.buffer);S.set(a(g),E);var T=h(v,y,E,m,p,b,_),A=new Uint8Array(T);return A.set(S.subarray(v,v+T)),x(v-x(0)),A}function u(h){var y=0;for(var g=0;g<h.length;++g){var m=h[g];y=y<m?m:y}return y}function d(h,y){if(s(y==2||y==4),y==4)return new Uint32Array(h.buffer,h.byteOffset,h.byteLength/4);else{var g=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/2);return new Uint32Array(g)}}function f(h,y,g,m,p,b,_){var x=n.exports.sbrk,v=x(g*m),E=x(g*b),S=new Uint8Array(n.exports.memory.buffer);S.set(a(y),E),h(v,g,m,p,E,_);var T=new Uint8Array(g*m);return T.set(S.subarray(v,v+g*m)),x(v-x(0)),T}return{ready:i,supported:!0,reorderMesh:function(h,y,g){s(h instanceof Uint32Array||h instanceof Int32Array),s(!y||h.length%3==0);var m=y?g?n.exports.meshopt_optimizeVertexCacheStrip:n.exports.meshopt_optimizeVertexCache:void 0;return o(n.exports.meshopt_optimizeVertexFetchRemap,h,u(h)+1,m)},reorderPoints:function(h,y){return s(h instanceof Float32Array),s(h.length%y==0),s(y>=3),c(n.exports.meshopt_spatialSortRemap,h,h.length/y,y*4)},encodeVertexBuffer:function(h,y,g){s(g>0&&g<=256),s(g%4==0);var m=n.exports.meshopt_encodeVertexBufferBound(y,g);return l(n.exports.meshopt_encodeVertexBuffer,m,h,y,g)},encodeVertexBufferLevel:function(h,y,g,m,p){s(g>0&&g<=256),s(g%4==0),s(m>=0&&m<=3),s(p===void 0||p==0||p==1);var b=n.exports.meshopt_encodeVertexBufferBound(y,g);return l(n.exports.meshopt_encodeVertexBufferLevel,b,h,y,g,m,p===void 0?-1:p)},encodeIndexBuffer:function(h,y,g){s(g==2||g==4),s(y%3==0);var m=d(h,g),p=n.exports.meshopt_encodeIndexBufferBound(y,u(m)+1);return l(n.exports.meshopt_encodeIndexBuffer,p,m,y,4)},encodeIndexSequence:function(h,y,g){s(g==2||g==4);var m=d(h,g),p=n.exports.meshopt_encodeIndexSequenceBound(y,u(m)+1);return l(n.exports.meshopt_encodeIndexSequence,p,m,y,4)},encodeGltfBuffer:function(h,y,g,m,p){var b={ATTRIBUTES:this.encodeVertexBufferLevel,TRIANGLES:this.encodeIndexBuffer,INDICES:this.encodeIndexSequence};return s(b[m]),b[m](h,y,g,2,p===void 0?0:p)},encodeFilterOct:function(h,y,g,m){return s(g==4||g==8),s(m>=2&&m<=16),f(n.exports.meshopt_encodeFilterOct,h,y,g,m,16)},encodeFilterQuat:function(h,y,g,m){return s(g==8),s(m>=4&&m<=16),f(n.exports.meshopt_encodeFilterQuat,h,y,g,m,16)},encodeFilterExp:function(h,y,g,m,p){s(g>0&&g%4==0),s(m>=1&&m<=24);var b={Separate:0,SharedVector:1,SharedComponent:2,Clamped:3};return s(!p||p in b),f(n.exports.meshopt_encodeFilterExp,h,y,g,m,g,p?b[p]:1)},encodeFilterColor:function(h,y,g,m){return s(g==4||g==8),s(m>=2&&m<=16),f(n.exports.meshopt_encodeFilterColor,h,y,g,m,16)}}}()});var DK;var kM=Ft(()=>{DK=function(){var e="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",t="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var r=WebAssembly.validate(n)?o(t):o(e),s,a=WebAssembly.instantiate(r,{}).then(function(p){s=p.instance,s.exports.__wasm_call_ctors()});function o(p){var b=new Uint8Array(p.length);for(var _=0;_<p.length;++_){var x=p.charCodeAt(_);b[_]=x>96?x-97:x>64?x-39:x+4}var v=0;for(var _=0;_<p.length;++_)b[v++]=b[_]<60?i[b[_]]:(b[_]-60)*64+b[++_];return b.buffer.slice(0,v)}function c(p,b,_,x,v,E,S){var T=p.exports.sbrk,A=x+3&-4,P=T(A*v),w=T(E.length),I=new Uint8Array(p.exports.memory.buffer);I.set(E,w);var F=b(P,x,v,w,E.length);if(F==0&&S)S(P,A,v);if(_.set(I.subarray(P,P+x*v)),T(P-T(0)),F!=0)throw Error("Malformed buffer data: "+F)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function h(p){var b={object:new Worker(p),pending:0,requests:{}};return b.object.onmessage=function(_){var x=_.data;b.pending-=x.count,b.requests[x.id][x.action](x.value),delete b.requests[x.id]},b}function y(p){var b="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+m.name+";"+c.toString()+m.toString(),_=new Blob([b],{type:"text/javascript"}),x=URL.createObjectURL(_);for(var v=d.length;v<p;++v)d[v]=h(x);for(var v=p;v<d.length;++v)d[v].object.postMessage({});d.length=p,URL.revokeObjectURL(x)}function g(p,b,_,x,v){var E=d[0];for(var S=1;S<d.length;++S)if(d[S].pending<E.pending)E=d[S];return new Promise(function(T,A){var P=new Uint8Array(_),w=++f;E.pending+=p,E.requests[w]={resolve:T,reject:A},E.object.postMessage({id:w,count:p,size:b,source:P,mode:x,filter:v},[P.buffer])})}function m(p){var b=p.data;self.ready.then(function(_){if(!b.id)return self.close();try{var x=new Uint8Array(b.count*b.size);c(_,_.exports[b.mode],x,b.count,b.size,b.source,_.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:x},[x.buffer])}catch(v){self.postMessage({id:b.id,count:b.count,action:"reject",value:v})}})}return{ready:a,supported:!0,useWorkers:function(p){y(p)},decodeVertexBuffer:function(p,b,_,x,v){c(s,s.exports.meshopt_decodeVertexBuffer,p,b,_,x,s.exports[l[v]])},decodeIndexBuffer:function(p,b,_,x){c(s,s.exports.meshopt_decodeIndexBuffer,p,b,_,x)},decodeIndexSequence:function(p,b,_,x){c(s,s.exports.meshopt_decodeIndexSequence,p,b,_,x)},decodeGltfBuffer:function(p,b,_,x,v,E){c(s,s.exports[u[v]],p,b,_,x,s.exports[l[E]])},decodeGltfBufferAsync:function(p,b,_,x,v){if(d.length>0)return g(p,b,_,u[x],l[v]);return a.then(function(){var E=new Uint8Array(p*b);return c(s,s.exports[u[x]],E,p,b,_,s.exports[l[v]]),E})}}}()});var FK;var DM=Ft(()=>{FK=function(){var e="b9H79Tebbbe:6eO9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gzuuuuuuuuuuu99uuuub9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999Gluuuueu9Gluuuub9GiuuueuiLQdilvorlwDiqkxmPszbHHbelve9Weiiviebeoweuecj:Gdkr:Bdxo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95bw8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bD8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbqQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bkX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbxQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bmX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2WbPa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9Wbs59TW79O9V9Wt9F9NW9UWV9HtW9q9V79Pt9P9V9U9sW9T9H9Wbzl79IV9RbHDwebcekdCXq;y;WeQdbk;r:herYue99iuY99Xue9:D998Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkdnamcdGTmbalcrfci4cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egecdtfaHBdbasaecefBd;8ecbhlcbhednadTmbabheadhOinaHaeydbci4fcb86bbaeclfheaOcufgOmbkcbhlabheadhOinaHaeydbgAci4fgCaCRbbgCceaAcrGgAtV86bbaCcu7aA4ceGalfhlaeclfheaOcufgOmbkcualcdtalcFFFFi0Ehekaecbyd1:H:cjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8eaHcFeaOz:tjjjbhQdnadTmbaecufhLcbhKindndnaQabaKcdtfgYydbgAc:v;t;h;Ev2aLGgOcdtfgCydbgHcuSmbceheinazaHcdtfydbaASmdaOaefhHaecefheaQaHaLGgOcdtfgCydbgHcu9hmbkkazaXcdtfaABdbaCaXBdbaXhHaXcefhXkaYaHBdbaKcefgKad9hmbkkaQcbyd:m:H:cjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbhLasc:Cefasyd;8egecdtfaLBdbasaLBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd1:H:cjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd1:H:cjbHjjjjbbhOasc:Cefasyd;8egHcdtfaOBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhQasc:Cefasyd;8egHcdtfaQBdbasaHcefBd;8eaOaQaialavazasc:Cefz:djjjbalcbyd1:H:cjbHjjjjbbhYasc:Cefasyd;8egHcdtfaYBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8ea3cbyd1:H:cjbHjjjjbbhAasc:Cefasyd;8egCcdtfaABdbasaCcefBd;8eaHcFeaez:tjjjbh5aAcFeaez:tjjjbh8EdnalTmbindnaLa8AgAcefg8AcdtfydbgCaLaAcdtgefydbgHSmbaCaH9Rh8FaEaHcitfhaa8Eaefhha5aefhKcbhCindndnaaaCcitfydbgXaA9hmbaKaABdbahaABdbxekdnaLaXcdtggfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheinaeydbaASmdaecwfheaHcufgHmbkka8EagfgeaAaXaeydbcuSEBdbaKaXaAaKydbcuSEBdbkaCcefgCa8F9hmbkka8Aal9hmbkaOhHaQhAa5hXa8EhCcbheindndnaeaHydbgK9hmbdnaeaAydbgK9hmbaXydbhKdnaCydbg8Fcu9hmbaKcu9hmbaYaefcb86bbxikdna8FcuSmbaKcuSmbaea8FSmbaOa8FcdtfydbaOaKcdtfydb9hmbaYaefcd86bbxikaYaefhadnaea8FSmbaeaKSmbaace86bbxikaacl86bbxdkdnaeaQaKcdtg8Ffydb9hmbdnaCydbgacuSmbaeaaSmbaXydbggcuSmbaeagSmba8Ea8FfydbghcuSmbahaKSmba5a8Ffydbg8FcuSmba8FaKSmbdnaOaacdtfydbgKaOa8Fcdtfydb9hmbaKaOagcdtfydbg8FSmba8FaOahcdtfydb9hmbaYaefcd86bbxlkaYaefcl86bbxikaYaefcl86bbxdkaYaefcl86bbxekaYaefaYaKfRbb86bbkaHclfhHaAclfhAaXclfhXaCclfhCalaecefge9hmbkdnamcaGTmbcbh8JindndnaYa8Jfg8KRbbg8Lc9:fPibebekdndndnaOa8Jcdtfydbgea8J9hmbdnaqmbcbh8FxdkdnazTmbcbh8Fa8JheinaqazaecdtgefydbfRbbce4a8FVceGh8FaQaefydbgea8J9hmbxikkcbh8Fa8JheinaqaefRbbce4a8FVceGh8FaQaecdtfydbgea8J9hmbxdkkaYaefRbbhexeka8JheindnaLaecdtg8AfgeclfydbgHaeydbgeSmbaHae9RhgaEaecitfhhaOa8AfhacbhKinahaKcitfydbgXhednindnaLaecdtgCfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheaaydbhAdninaOaeydbcdtfydbaASmeaecwfheaHcufgHTmdxbkkcbhexdkaQaCfydbgeaX9hmbkceheka8FaeVh8FaKcefgKag9hmbkkaQa8Afydbgea8J9hmbka8Lcia8FceGEheka8Kae86bbka8Jcefg8Jal9hmbkkdnaqTmbdndnazTmbazheaOhHalhAindnaqaeydbfRbbceGTmbaYaHydbfcl86bbkaeclfheaHclfhHaAcufgAmbxdkkaqheaOhHalhAindnaeRbbceGTmbaYaHydbfcl86bbkaecefheaHclfhHaAcufgAmbkkaOhealhAaYhHindnaYaeydbfRbbcl9hmbaHcl86bbkaeclfheaHcefhHaAcufgAmbkkamceGTmbaYhealhHindnaeRbbce9hmbaecl86bbkaecefheaHcufgHmbkkcbh8Mcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh8Nasc:Cefasyd;8egecdtfa8NBdbasaecefBd;8eascbBd:qeas9cb83i1ea8Naialavazasc1efz:ejjjbhydndnaDmbcbh8PcbhCxekcbhCawhecbhHindnaeIdbJbbbb9ETmbasaCcdtfaHBdbaCcefhCkaeclfheaDaHcefgH9hmbkcuaCal2gecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbh8Pasc:Cefasyd;8egecdtfa8PBdbasaecefBd;8ealTmbdnaCmbcbhCxekarcd4hgdnazTmbaCcdthhcbh8Fa8Phainaoaza8Fcdtfydbag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbxdkkaCcdthhcbh8Fa8Phainaoa8Fag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbkkcualc8S2gHalc;D;O;f8U0EgXcbyd1:H:cjbHjjjjbbheasc:Cefasyd;8egAcdtfaeBdbasaAcefBd;8eaecbaHz:tjjjbhIcbh8RcbhgdnaCTmbcbh8MaXcbyd1:H:cjbHjjjjbbhgasc:Cefasyd;8egecdtfagBdbasaecefBd;8eagcbaHz:tjjjb8AcuaCal2gecltgHaecFFFFb0Ecbyd1:H:cjbHjjjjbbh8Rasc:Cefasyd;8egecdtfa8RBdbasaecefBd;8ea8RcbaHz:tjjjb8AamcjjjjdGTmbcualcltgealcFFFFb0Ecbyd1:H:cjbHjjjjbbh8Masc:Cefasyd;8egHcdtfa8MBdbasaHcefBd;8ea8Mcbaez:tjjjb8AkdnadTmbcbhKabhHina8NaHclfydbg8Fcx2fgeIdba8NaHydbgacx2fgAIdbg8S:tgRa8NaHcwfydbghcx2fgXIdlaAIdlg8U:tg8VNaeIdla8U:tg8WaXIdba8S:tg8XN:tg8Ya8YNa8WaXIdwaAIdwg8Z:tg80NaeIdwa8Z:tg8Wa8VN:tg81a81Na8Wa8XNaRa80N:tg80a80NMMg8V:rhBa8Yh8Xa80h8Wa81hRdna8VJbbbb9EgATmba8YaB:vh8Xa80aB:vh8Wa81aB:vhRkaIaOaacdtfydbgXc8S2fgeaRaB:rg8VaRNNg83aeIdbMUdbaea8Wa8Va8WNgUNg85aeIdlMUdlaea8Xa8Va8XNg86Ng87aeIdwMUdwaeaRaUNgUaeIdxMUdxaea86aRNg88aeIdzMUdzaea8Wa86Ng89aeIdCMUdCaeaRa8Va8Xa8ZNaRa8SNa8Ua8WNMM:mg8:Ng86NgRaeIdKMUdKaea8Wa86Ng8WaeId3MUd3aea8Xa86Ng8XaeIdaMUdaaea86a8:Ng86aeId8KMUd8Kaea8VaeIdyMUdyaIaOa8Fcdtfydbg8Fc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdyaIaOahcdtfydbgac8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdydna8MTmbdnaATmba8YaB:vh8Ya80aB:vh80a81aB:vh81ka8MaXcltfgeaBJbbbZNgRa80Ng8VaeIdlMUdlaeaRa8YNg8WaeIdwMUdwaeaRa81Ng8XaeIdbMUdbaeaRa8S:ma81Na8Ua80N:ta8Za8YN:tNgRaeIdxMUdxa8Ma8Fcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxa8Maacltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxkaHcxfhHaKcifgKad6mbkkdnalTmbJq;x8J88J;n;m;m89J:v:;;w8ZamczGEamc;abGEh80cbhHaOhXazhKaIhea8NhAindnaHaXydb9hmbaHh8FdnazTmbaKydbh8Fka80hRdnaqTmbJbbjZa80aqa8FfRbbclGEhRkaecxfg8Fa8FIdbJbbbbMUdbaeczfg8Fa8FIdbJbbbbMUdbaecCfg8Fa8FIdbJbbbbMUdbaeaRaecyfg8FIdbg8YNgRaeIdbMUdbaeclfgaaRaaIdbMUdbaecwfgaaRaaIdbMUdbaecKfgaaaIdbaAIdbg8WaRN:tUdbaAcwfIdbh8Vaec3fgaaaIdbaRaAclfIdbg8XN:tUdbaecafgaaaIdbaRa8VN:tUdbaec8KfgaIdbh81a8Fa8YaRMUdbaaa81aRa8Va8VNa8Wa8WNa8Xa8XNMMNMUdbkaXclfhXaKclfhKaec8SfheaAcxfhAalaHcefgH9hmbkkdnadTmbcbh8Aabhainaba8Acdtfh8FcbhHinaYa8FaHc:G:G:cjbfydbcdtfydbgAfRbbhedndnaYaaaHfydbgXfRbbgKc99fcFeGcpe0mbaec99fcFeGc;:e6mekdnaKcufcFeGce0mba5aXcdtfydbaA9hmekdnaecufcFeGce0mba8EaAcdtfydbaX9hmekJbbacJbbacJbbbZaecFeGceSEaKcFeGceSEhUdna8Na8FaHc:K:G:cjbfydbcdtfydbcx2fgeIdwa8NaXcx2fgKIdwg86:tg8Sa8NaAcx2fghIdwa86:tg8Xa8XNahIdbaKIdbg8U:tg80a80NahIdlaKIdlg8Z:tg8Va8VNMMg81Na8Xa8Sa8XNaeIdba8U:tg83a80Na8VaeIdla8Z:tg85NMMg8WN:tg8Ya8YNa83a81Na80a8WN:tgRaRNa85a81Na8Va8WN:tg8Wa8WNMMgBJbbbb9ETmba8YaB:rgB:vh8Ya8WaB:vh8WaRaB:vhRkaUa81:rNgBa8Ya86NaRa8UNa8Za8WNMM:mg81Ng87a81Nh88a80a85Na8Va83N:tg81a81Na8Va8SNa8Xa85N:tg8Va8VNa8Xa83Na80a8SN:tg8Xa8XNMMg83:rh80a8Ya87Nh85a8Wa87Nh89aRa87Nh87a8WaBa8YNg8SNh8:a8SaRNhZaRaBa8WNgnNhca8Ya8SNh8Ya8WanNh8WaRaBaRNNh8Sdna83Jbbbb9ETmba81a80:vh81a8Xa80:vh8Xa8Va80:vh8VkaIaOaXcdtfydbc8S2fgeaeIdba8Sa8VaUa80:rNgRa8VNNMg80MUdbaea8Wa8XaRa8XNg8SNMg83aeIdlMUdlaea8Ya81aRa81Ng8WNMg8YaeIdwMUdwaeaca8Va8SNMg8SaeIdxMUdxaeaZa8Wa8VNMgUaeIdzMUdzaea8:a8Xa8WNMg8WaeIdCMUdCaea87a8VaRa81a86Na8Va8UNa8Za8XNMMg86:mNgRNMg8VaeIdKMUdKaea89a8XaRNMg8XaeId3MUd3aea85a81aRNMg81aeIdaMUdaaea88a86aRN:tgRaeId8KMUd8KaeaBaeIdyMUdyaIaOaAcdtfydbc8S2fgea80aeIdbMUdbaea83aeIdlMUdlaea8YaeIdwMUdwaea8SaeIdxMUdxaeaUaeIdzMUdzaea8WaeIdCMUdCaea8VaeIdKMUdKaea8XaeId3MUd3aea81aeIdaMUdaaeaRaeId8KMUd8KaeaBaeIdyMUdykaHclfgHcx9hmbkaacxfhaa8Acifg8Aad6mbkaCTmbcbhainJbbbbh80a8Nabaacdtfgeclfydbg8Fcx2fgHIdwa8Naeydbghcx2fgAIdwg8Z:tg8Va8VNaHIdbaAIdbg83:tg8Wa8WNaHIdlaAIdlg85:tg8Xa8XNMMg8Sa8Naecwfydbg8Acx2fgeIdwa8Z:tg8YNa8Va8YNa8WaeIdba83:tg81Na8XaeIdla85:tgBNMMgRa8VN:tJbbbbJbbjZa8Sa8Ya8YNa81a81NaBaBNMMg8UNaRaRN:tg86:va86Jbbbb9BEg86Nh88a8Ua8VNaRa8YN:ta86Nh89a8SaBNaRa8XN:ta86Nh8:a8Ua8XNaRaBN:ta86NhZa8Sa81NaRa8WN:ta86Nhna8Ua8WNaRa81N:ta86Nhca8WaBNa8Xa81N:tgRaRNa8Xa8YNa8VaBN:tgRaRNa8Va81Na8Wa8YN:tgRaRNMM:rJbbbZNhRa8PahaC2g8JcdtfhHa8Pa8AaC2gDcdtfhAa8Pa8FaC2g8KcdtfhXa8Z:mh9ca85:mhJa83:mh9eascjdfheaChKJbbbbhBJbbbbh86Jbbbbh8SJbbbbh8UJbbbbh8ZJbbbbh83Jbbbbh85Jbbbbh87JbbbbhUinaecwfaRa89aXIdbaHIdbg8Y:tg8XNa88aAIdba8Y:tg81NMg8VNUdbaeclfaRaZa8XNa8:a81NMg8WNUdbaeaRaca8XNana81NMg8XNUdbaecxfaRa9ca8VNaJa8WNa8Ya9ea8XNMMMg8YNUdbaRa8Va8WNNa8ZMh8ZaRa8Va8XNNa8UMh8UaRa8Wa8XNNa8SMh8SaRa8Ya8YNNaUMhUaRa8Va8YNNa87Mh87aRa8Wa8YNNa85Mh85aRa8Xa8YNNa83Mh83aRa8Va8VNNa86Mh86aRa8Wa8WNNaBMhBaRa8Xa8XNNa80Mh80aHclfhHaXclfhXaAclfhAaeczfheaKcufgKmbkagahc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Fc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Ac8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdya8Ra8Jcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8Ra8Kcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8RaDcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbkaacifgaad6mbkkcbhAdndnamcwGgTmbJbbbbh8ScbhScbh9hcbh9ixekcbhSa3cbyd1:H:cjbHjjjjbbh9iasc:Cefasyd;8egecdtfa9iBdbasaecefBd;8ecua9ialabadaOz:fjjjbgXcltaXcjjjjiGEcbyd1:H:cjbHjjjjbbh9hasc:Cefasyd;8egecdtfa9hBdbasaecefBd;8ea9haXa9ia8Nalz:gjjjbJFFuuh8SaXTmba9hheaXhHinaeIdbgRa8Sa8SaR9EEh8SaeclfheaHcufgHmbkaXhSkdnalTmbaLclfheaLydbhXaYhHalhKcbhAincbaeydbg8FaX9RaHRbbcpeGEaAfhAaHcefhHaeclfhea8FhXaKcufgKmbkaAce4hAkcuadaA9Rcifg6cx2a6c;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh9kasc:Cefasyd;8egecdtfa9kBdbasaecefBd;8ecua6cdta6cFFFFi0Ecbyd1:H:cjbHjjjjbbh0asc:Cefasyd;8egecdtfa0BdbasaecefBd;8ea3cbyd1:H:cjbHjjjjbbh9masc:Cefasyd;8egecdtfa9mBdbasaecefBd;8ealcbyd1:H:cjbHjjjjbbh9nasc:Cefasyd;8egecdtfa9nBdbasaecefBd;8eaxaxNayJbbjZamclGEgZaZN:vh87JbbbbhUdnadak9nmbdna6ci6mbaCclth9oa9kcwfh9pJbbbbh85JbbbbhUinascNefabadalaOz:cjjjbabh8Acbh9qcbh9rinaba9rcdtfhDcbheindnaOa8AaefydbgAcdtghfydbgXaOaDaec:W:G:cjbfydbcdtfydbgHcdtg8JfydbgKSmbaYaHfRbbgacv2aYaAfRbbg8FfRb;a:G:cjbg8La8Fcv2aafg8KRb;a:G:cjbg3VcFeGTmbdnaKaX9nmba8KRb;G:G:cjbcFeGmekdna8FcufcFeGce0mbaaTmba5ahfydbaH9hmekdna8FTmbaacufcFeGce0mba8Ea8JfydbaA9hmeka9ka9qcx2fgXaHaAa3cFeGgKEBdlaXaAaHaKEBdbaXaKa8LGcb9hBdwa9qcefh9qkaeclfgecx9hmbkdna9rcifg9rad9pmba8Acxfh8Aa9qcifa69nmekka9qTmdcbh8KinaIaOa9ka8Kcx2fghydbgKcdtgXfydbg8Ac8S2fgeIdwa8Nahydlg8Fcx2fgHIdwg8WNaeIdzaHIdbg8XNaeIdaMgRaRMMa8WNaeIdlaHIdlg8YNaeIdCa8WNaeId3MgRaRMMa8YNaeIdba8XNaeIdxa8YNaeIdKMgRaRMMa8XNaeId8KMMM:lhRJbbbbJbbjZaeIdyg8V:va8VJbbbb9BEh8VdndnahydwgDmbJFFuuh86xekJbbbbJbbjZaIaOa8Fcdtfydbc8S2fgeIdyg81:va81Jbbbb9BEaeIdwa8NaKcx2fgHIdwg81NaeIdzaHIdbg80NaeIdaMgBaBMMa81NaeIdlaHIdlgBNaeIdCa81NaeId3Mg81a81MMaBNaeIdba80NaeIdxaBNaeIdKMg81a81MMa80NaeId8KMMM:lNh86ka8VaRNhBdnaCTmbagaKc8S2fgAIdwa8WNaAIdza8XNaAIdaMgRaRMMa8WNaAIdla8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8FaC2gacdtfhHa8RaKaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8Vxekaga8Fc8S2fgAIdwa8NaKcx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8RaacltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86dndndnaYaKfRbbc9:fPddbekaQaXfydbgXaKSmbaOa8Fcdtfydbh8Jindndna5aXcdtgafydbgecuSmbaOaecdtfydba8JSmekdna8EaafydbgecuSmbaOaecdtfydba8JSmeka8FhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkaBaR:lMhBaQaafydbgXaK9hmbkkaYa8FfRbbci9hmeaDTmeaQa8FcdtfydbgXa8FSmeindndna5aXcdtgafydbgecuSmbaOaecdtfydba8ASmekdna8EaafydbgecuSmbaOaecdtfydba8ASmekaKhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbka86aR:lMh86aQaafydbgXa8F9hmbxdkkdna8Ea5a5aXfydba8FSEaQaXfydbgacdtfydbgXcu9hmbaQa8FcdtfydbhXkagaac8S2fgAIdwa8NaXcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaXaC2g8AcdtfhHa8RaaaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8VxekagaXc8S2fgAIdwa8Naacx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8Ra8AcltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86kaha86aBa86aB9DgeEUdwahaKa8FaeaDcb9hGgeEBdlaha8FaKaeEBdba8Kcefg8Ka9q9hmbkascjdfcbcj;qbz:tjjjb8Aa9phea9qhHinascjdfaeydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbcefBdbaecxfheaHcufgHmbkcbhecbhHinascjdfaefgAydbhXaAaHBdbaXaHfhHaeclfgecj;qb9hmbkcbhea9phHinascjdfaHydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbgAcefBdba0aAcdtfaeBdbaHcxfhHa9qaecefge9hmbkadak9RgAci9Uh9sdnalTmbcbhea9mhHinaHaeBdbaHclfhHalaecefge9hmbkkcbh9ta9ncbalz:tjjjbh3aAcO9Uh9ua9sce4h9rcbh8Lcbh8Kdnina9ka0a8Kcdtfydbcx2fg8JIdwgRa879Emea8La9s9pmeJFFuuh8Vdna9ra9q9pmba9ka0a9rcdtfydbcx2fIdwJbb;aZNh8VkdnaRa8V9ETmbaRaU9ETmba8La9u0mdkdna3aOa8JydlgDcdtg9vfg8AydbgAfg9wRbba3aOa8Jydbghcdtg9xfydbgefg9yRbbVmbaYahfRbbh9zdndnaLaecdtfgHclfydbgXaHydbgHSmbaXaH9RhXa8NaAcx2fh8Fa8Naecx2fhaaEaHcitfheindna9maeydbcdtfydbgHaASmba9maeclfydbcdtfydbgKaASmbaHaKSmba8NaKcx2fgKIdba8NaHcx2fgHIdbg8W:tgRaaIdlaHIdlg8X:tg80NaKIdla8X:tg8VaaIdba8W:tgBN:tg8YaRa8FIdla8X:tg86Na8Va8FIdba8W:tg8UN:tg8XNa8VaaIdwaHIdwg81:tg8ZNaKIdwa81:tg8Wa80N:tg80a8Va8FIdwa81:tg83Na8Wa86N:tg8VNa8WaBNaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmikaecwfheaXcufgXmbkkdndndndna9zc9:fPdebdkahheina8AydbhAdndna5aecdtgHfydbgecuSmbaOaecdtfydbaASmekdna8EaHfydbgecuSmbaOaecdtfydbaASmekaDheka9maHfaeBdbaQaHfydbgeah9hmbxikkdna8Ea5a5a9xfydbaDSEaQa9xfydbghcdtfydbgecu9hmbaQa9vfydbheka9ma9xfaDBdbaehDka9mahcdtfaDBdbka9yce86bba9wce86bba8JIdwgRaUaUaR9DEhUa9tcefh9tcecda9zceSEa8Lfh8Lxeka9rcefh9rka8Kcefg8Ka9q9hmbkka9tTmddnalTmbcbh8Fcbhhindna9mahcdtgefydbgAahSmbaOaAcdtfydbh8AdnahaOaefydb9hg8JmbaIa8Ac8S2fgeaIahc8S2fgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya8MTmba8Ma8Acltfgea8MahcltfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxkaCTmbagaAc8S2fgeagahc8S2gDfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya9oaA2haa8RhHaChXinaHaafgeaHa8FfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8JmbJbbbbJbbjZaIaDfgeIdygR:vaRJbbbb9BEaeIdwa8Na8Acx2fgHIdwgRNaeIdzaHIdbg8VNaeIdaMg8Wa8WMMaRNaeIdlaHIdlg8WNaeIdCaRNaeId3MgRaRMMa8WNaeIdba8VNaeIdxa8WNaeIdKMgRaRMMa8VNaeId8KMMM:lNgRa85a85aR9DEh85ka8Fa9ofh8Fahcefghal9hmbkcbhHa5heindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa5aXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkcbhHa8EheindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa8EaXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkka85aUaCEh85cbhHabhecbhAindnaOa9maeydbcdtfydbg8FcdtfydbgXaOa9maeclfydbcdtfydbgacdtfydbgKSmbaXaOa9maecwfydbcdtfydbg8AcdtfydbghSmbaKahSmbabaHcdtfgXa8FBdbaXcwfa8ABdbaXclfaaBdbaHcifhHkaecxfheaAcifgAad6mbkdndnaTmbaHhdxekdnaHak0mbaHhdxekdna8Sa859FmbaHhdxekJFFuuh8ScbhdabhecbhAindna9ha9iaeydbgXcdtfydbcdtfIdbgRa859ETmbaeclf8Pdbh9AabadcdtfgKaXBdbaKclfa9A83dbaRa8Sa8SaR9EEh8SadcifhdkaecxfheaAcifgAaH6mbkkadak0mbxdkkascNefabadalaOz:cjjjbkdndnadak0mbadhaxekdnaTmbadhaxekdna8Sa879FmbadhaxekcehKina8SJbb;aZNgRa87aRa879DEh8WJbbbbhRdnaSTmba9hheaShHinaeIdbg8VaRa8Va8W9FEaRa8VaR9EEhRaeclfheaHcufgHmbkkJFFuuh8ScbhaabhecbhHindna9ha9iaeydbgAcdtfydbcdtfIdbg8Va8W9ETmbaeclf8Pdbh9AabaacdtfgXaABdbaXclfa9A83dba8Va8Sa8Sa8V9EEh8SaacifhakaecxfheaHcifgHad6mbkdnaKaaad9hVceGmbadhaxdkaRaUaUaR9DEhUaaak9nmecbhKaahda8Sa879FmbkkdnamcjjjjdGTmba9ncbalz:tjjjbh8AdnaaTmbabheaahHina8AaeydbgAfce86bba8AaOaAcdtfydbfce86bbaeclfheaHcufgHmbkkascNefabaaalaOz:cjjjbdndnalTmbcbhXindna8AaXfRbbTmbdnaYaXfRbbgecl0mbceaetcQGmekdnaOaXcdtg8FfydbgeaXSmba8NaXcx2fgHa8Naecx2fgeydwBdwaHae8Pdb83dbxekaIaXc8S2fgKIdygcacJL:3;rUNgRMh87aKIdwg9BaRMh8SaKIdlg9CaRMh8UaKIdbg9DaRMh81aKIdag9EaRa8NaXcx2fg8JIdwg88N:th8ZaKId3g9FaRa8JIdlg89N:th83aKIdKg9Ga8JIdbg8:aRN:th80JbbbbhnaKIdCg9HJbbbbMh85aKIdzg9IJbbbbMhBaKIdxg9JJbbbbMh86dndnaCTmbaXhAinJbbbba87agaAc8S2fgHIdygR:vaRJbbbb9BEhRa8RaAaC2cltfheaHIdaa87Na8ZMh8ZaHId3a87Na83Mh83aHIdKa87Na80Mh80aHIdCa87Na85Mh85aHIdza87NaBMhBaHIdxa87Na86Mh86aHIdwa87Na8SMh8SaHIdla87Na8UMh8UaHIdba87Na81Mh81aChHina8ZaecwfIdbg8VaecxfIdbg8YNaRN:th8Za83aeclfIdbg8Wa8YNaRN:th83a85a8Wa8VNaRN:th85a81aeIdbg8Xa8XNaRN:th81a80a8Xa8YNaRN:th80aBa8Xa8VNaRN:thBa86a8Xa8WNaRN:th86a8Sa8Va8VNaRN:th8Sa8Ua8Wa8WNaRN:th8UaeczfheaHcufgHmbkaQaAcdtfydbgAaX9hmbka8MTmba8MaXcltfgeIdxhxaeIdwh9caeIdlhJaeIdbhRxekJbbbbhxJbbbbh9cJbbbbhJJbbbbhRkaBa81:vg8Wa80Na8Z:ta85aBa86a81:vg8VN:tg8Za8Ua86a8VN:tg8Y:vg8Xa8Va80Na83:tg8UN:th83a9caRa8WN:taJaRa8VN:tg86a8XN:tg85a8SaBa8WN:ta8Za8XN:tgB:vg8S:mh8Za86a8Y:vg9c:mhJdnJbbbbaRaRa81:vg9eN:ta86a9cN:ta85a8SN:tg86:la87J:983:g81NgR9ETmba8Za83NaJa8UNa9ea80Nax:tMMa86:vhnka81:laR9ETmba8Y:laR9ETmbaB:laR9ETmba9e:manNa8W:ma8ZanNa83aB:vMgBNa8V:maJanNa8X:maBNa8Ua8Y:vMMg85Na80:ma81:vMMMh87aLa8FfgeclfydbgHaeydbge9RhhaEaecitfh8FJbbbbhRdnaHaeSgDmbJbbbbhRa8FheahhAina8Naeclfydbcx2fgHIdwa88:tg8Va8VNaHIdba8::tg8Va8VNaHIdla89:tg8Va8VNMMg8Va8Naeydbcx2fgHIdwa88:tg8Wa8WNaHIdba8::tg8Wa8WNaHIdla89:tg8Wa8WNMMg8WaRaRa8W9DEgRaRa8V9DEhRaecwfheaAcufgAmbkaR:rgRaRNhRkaBa88:tg8Va8VNa87a8::tg8Va8VNa85a89:tg8Va8VNMMaR9EmbaKId8KhndnaDmbina8Na8Fclfydbcx2fgeIdba8Na8Fydbcx2fgHIdbg8W:tgRa89aHIdlg8X:tg80NaeIdla8X:tg8Va8:a8W:tg86N:tg8YaRa85a8X:tg8SNa8Va87a8W:tg8UN:tg8XNa8Va88aHIdwg81:tg8ZNaeIdwa81:tg8Wa80N:tg80a8VaBa81:tg83Na8Wa8SN:tg8VNa8Wa86NaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9Fmda8Fcwfh8FahcufghmbkkJbbbbJbbjZac:vacJbbbb9BEgRa9BaBNa9Ia87Na9EMg8Va8VMMaBNa9Ca85Na9HaBNa9FMg8Va8VMMa85Na9Da87Na9Ja85Na9GMg8Va8VMMa87NanMMM:lNaRa9Ba88Na9Ia8:Na9EMg8Va8VMMa88Na9Ca89Na9Ha88Na9FMg8Va8VMMa89Na9Da8:Na9Ja89Na9GMg8Va8VMMa8:NanMMM:lNJbb;aZNJ:983:g81M9Emba8JaBUdwa8Ja85Udla8Ja87UdbkaXcefgXal9hmbkdnaCmbcbhCxdkcbhXindna8AaXfRbbTmbaOaXcdtgefydbaX9hmbaYaXfhhaQaefh8Ja8NaXcx2fhAa8PaXaC2cdtfhDcbhEincuhLdnahRbbci9hmbaXhLa8JydbgeaXSmba8PaEcdtgHfhKaDaHfIdbhRaXhLinaLhHcuhLdnaKaeaC2cdtfIdbaR9CmbaHcuSmbaHhLagaec8S2fIdyagaHc8S2fIdy9ETmbaehLkaQaecdtfydbgeaX9hmbkka8PaEcdtfhKa8RaEcltfh8FaXheinaKaeaC2cdtfJbbbbJbbjZagaeaLaLcuSEgHc8S2fIdygR:vaRJbbbb9BEa8FaHaC2cltfgHIdwaAIdwNaHIdbaAIdbNaHIdlaAIdlNMMaHIdxMNUdbaQaecdtfydbgeaX9hmbkaEcefgEaC9hmbkkaXcefgXal9hmbxdkkaCmbcbhCkaiavaoarawaCala8Na8Pazasayasc1efaYa8Aaqz:hjjjbkdnamcjjjjlGTmbazmbaaTmbabhecbhLinaYaeydbgAfRbbc3thQaecwfgXydbhHcjjjj94hCdna5aAcdtgEfydbaeclfgKydbgOSmbcjjjj94cba8EaOcdtfydbaASEhCkaeaQaCVaAVBdbaYaOfRbbc3th8Fcjjjj94hCcjjjj94hQdna5aOcdtfydbaHSmbcjjjj94cba8EaHcdtfydbaOSEhQkaKa8FaQVaOVBdbaYaHfRbbc3thOdna5aHcdtfydbaASmbcjjjj94cba8EaEfydbaHSEhCkaXaOaCVaHVBdbaecxfheaLcifgLaa6mbkkdnazTmbaaTmbaaheinabazabydbcdtfydbBdbabclfhbaecufgembkkdnaPTmbaPaZaU:rNUdbkdnasyd;8egHTmbaHcdtasc:Ceffc98fheinaeydbcbyd:m:H:cjbH:bjjjbbaec98fheaHcufgHmbkkascj;sbf8Kjjjjbaak;Yieouabydlhvabydbclfcbaicdtz:tjjjbhoadci9UhrdnadTmbdnalTmbaehwadhDinaoalawydbcdtfydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbxdkkaehwadhDinaoawydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbkkdnaiTmbcbhDaohwinawydbhqawaDBdbawclfhwaqaDfhDaicufgimbkkdnadci6mbinaecwfydbhwaeclfydbhDaeydbhidnalTmbalawcdtfydbhwalaDcdtfydbhDalaicdtfydbhikavaoaicdtfgqydbcitfaDBdbavaqydbcitfawBdlaqaqydbcefBdbavaoaDcdtfgqydbcitfawBdbavaqydbcitfaiBdlaqaqydbcefBdbavaoawcdtfgwydbcitfaiBdbavawydbcitfaDBdlawawydbcefBdbaecxfhearcufgrmbkkabydbcbBdbk:todDue99aicd4aifhrcehwinawgDcethwaDar6mbkcuaDcdtgraDcFFFFi0Ecbyd1:H:cjbHjjjjbbhwaoaoyd9GgqcefBd9GaoaqcdtfawBdbawcFearz:tjjjbhkdnaiTmbalcd4hlaDcufhxcbhminamhDdnavTmbavamcdtfydbhDkcbadaDal2cdtfgDydlgwawcjjjj94SEgwcH4aw7c:F:b:DD2cbaDydbgwawcjjjj94SEgwcH4aw7c;D;O:B8J27cbaDydwgDaDcjjjj94SEgDcH4aD7c:3F;N8N27axGhwamcdthPdndndnavTmbakawcdtfgrydbgDcuSmeadavaPfydbal2cdtfgsIdbhzcehqinaqhrdnadavaDcdtfydbal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmlkarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbxdkkakawcdtfgrydbgDcuSmbadamal2cdtfgsIdbhzcehqinaqhrdnadaDal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmikarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbkkaramBdbamhDkabaPfaDBdbamcefgmai9hmbkkakcbyd:m:H:cjbH:bjjjbbaoaoyd9GcufBd9GdnaeTmbaiTmbcbhDaehwinawaDBdbawclfhwaiaDcefgD9hmbkcbhDaehwindnaDabydbgrSmbawaearcdtfgrydbBdbaraDBdbkabclfhbawclfhwaiaDcefgD9hmbkkk;:odvuv998Jjjjjbca9Rgocbyd1:G:cjbBdKaocb8Pdj:G:cjb83izaocbydN:G:cjbBdwaocb8Pd:m:G:cjb83ibdnadTmbaicd4hrdnabmbdnalTmbcbhwinaealawcdtfydbar2cdtfhDcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxikkarcdthwcbhDincbhiinaoczfaifgqaeaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaeawfheaDcefgDad9hmbxdkkdnalTmbcbhwinabawcx2fgiaealawcdtfydbar2cdtfgDIdbUdbaiaDIdlUdlaiaDIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxdkkarcdthlcbhwaehDinabawcx2fgiaeawar2cdtfgqIdbUdbaiaqIdlUdlaiaqIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaDalfhDawcefgwad9hmbkkJbbbbaoIdbaoIdzgx:tgkakJbbbb9DEgkaoIdlaoIdCgm:tgPaPak9DEgkaoIdwaoIdKgP:tgsasak9DEhsdnabTmbadTmbJbbbbJbbjZas:vasJbbbb9BEhkinabakabIdbax:tNUdbabclfgoakaoIdbam:tNUdbabcwfgoakaoIdbaP:tNUdbabcxfhbadcufgdmbkkdnavTmbavaPUdwavamUdlavaxUdbkask:WlewudnaeTmbcbhvabhoinaoavBdbaoclfhoaeavcefgv9hmbkkdnaiTmbcbhrinadarcdtfhwcbhDinalawaDcdtgvyd:G:G:cjbcdtfydbcdtfydbhodnalawavfydbcdtfydbgqabaqcdtfgkydbgvSmbinakabavgqcdtfgxydbgvBdbaxhkaqav9hmbkkdnaoabaocdtfgkydbgvSmbinakabavgocdtfgxydbgvBdbaxhkaoav9hmbkkdnaqaoSmbabaqaoaqao0Ecdtfaqaoaqao6EBdbkaDcefgDci9hmbkarcifgrai6mbkkdnaembcbskcbhxindnalaxcdtgvfydbax9hmbaxhodnaxabavfgDydbgvSmbaDhqinaqabavgocdtfgkydbgvBdbakhqaoav9hmbkkaDaoBdbkaxcefgxae9hmbkcbhkabhvcbhoindndnaoalydbgq9hmbdnaoavydbgq9hmbavakBdbakcefhkxdkavabaqcdtfydbBdbxekavabaqcdtfydbBdbkalclfhlavclfhvaeaocefgo9hmbkakk;jiilud99euabcbaecltz:tjjjbhvdnalTmbadhoaihralhwinarcwfIdbhDarclfIdbhqavaoydbcltfgkarIdbakIdbMUdbakaqakIdlMUdlakaDakIdwMUdwakakIdxJbbjZMUdxaoclfhoarcxfhrawcufgwmbkkdnaeTmbavhkaehrinakcxfgoIdbhDaocbBdbakakIdbJbbbbJbbjZaD:vaDJbbbb9BEgDNUdbakclfgoaDaoIdbNUdbakcwfgoaDaoIdbNUdbakczfhkarcufgrmbkkdnalTmbinavadydbcltfgkaicwfIdbakIdw:tgDaDNaiIdbakIdb:tgDaDNaiclfIdbakIdl:tgDaDNMMgDakIdxgqaqaD9DEUdxadclfhdaicxfhialcufglmbkkdnaeTmbavcxfhkinabakIdbUdbakczfhkabclfhbaecufgembkkk:moerudnaoTmbaecd4hzdnavTmbaicd4hHavcdthOcbhAindnaPaAfRbbTmbaAhednaDTmbaDaAcdtfydbhekdnasTmbasaefRbbceGmekdnamaAfRbbclSmbabaeaz2cdtfgiaraAcx2fgCIdbakNaxIdbMUdbaiaCIdlakNaxIdlMUdlaiaCIdwakNaxIdwMUdwkadaeaH2cdtfhXaqheawhiavhCinaXaeydbcdtgQfaiIdbalaQfIdb:vUdbaeclfheaiclfhiaCcufgCmbkkawaOfhwaAcefgAao9hmbxdkkdnasmbcbheaDhiindnaPaefRbbTmbaehCdnaDTmbaiydbhCkamaefRbbclSmbabaCaz2cdtfgCarIdbakNaxIdbMUdbaCarclfIdbakNaxIdlMUdlaCarcwfIdbakNaxIdwMUdwkaiclfhiarcxfhraoaecefge9hmbxdkkdnaDTmbindnaPRbbTmbasaDydbgefRbbceGmbamRbbclSmbabaeaz2cdtfgearIdbakNaxIdbMUdbaearclfIdbakNaxIdlMUdlaearcwfIdbakNaxIdwMUdwkaPcefhPaDclfhDamcefhmarcxfhraocufgombxdkkazcdthicbheindnaPaefRbbTmbasaefRbbceGmbamaefRbbclSmbabarIdbakNaxIdbMUdbabclfarclfIdbakNaxIdlMUdbabcwfarcwfIdbakNaxIdwMUdbkarcxfhrabaifhbaoaecefge9hmbkkk8MbabaeadaialavcbcbcbcbcbaoarawaDz:bjjjbk8MbabaeadaialavaoarawaDaqakaxamaPz:bjjjbkRbababaeadaialavaoarawaDaqakaxcjjjjdVamz:bjjjbk:g8Koque99due99duq998Jjjjjbc;Wb9Rgq8Kjjjjbcbhkaqcxfcbc;Kbz:tjjjb8Aaqcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgxBdxaqceBd2axaialavcbcbz:ejjjb8AaqcualcdtalcFFFFi0Egmcbyd1:H:cjbHjjjjbbgiBdzaqcdBd2dndnJFF959eJbbjZawJbbjZawJbbjZ9DE:vawJ9VO:d869DEgw:lJbbb9p9DTmbaw:OhPxekcjjjj94hPkadci9Uhsarco9UhzdndnaombaPcd9imekdnalTmbaPcuf:YhwdnaoTmbcbhvaihHaxhOindndnaoavfRbbceGTmbavcjjjjlVhAxekdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHaOcxfhOalavcefgv9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkadTmbcbhkaehvcbhOinakaiavclfydbcdtfydbgHaiavcwfydbcdtfydbgA9haiavydbcdtfydbgXaH9haXaA9hGGfhkavcxfhvaOcifgOad6mbkkarci9UhQdndnaz:Z:rJbbbZMgw:lJbbb9p9DTmbaw:Ohvxekcjjjj94hvkaQ:ZhLcbhKc:bwhzdninakaQ9pmeazaP9Rcd9imeavazcufgOavaO9iEaPcefavaP9kEhYdnalTmbaYcuf:YhwdnaoTmbcbhOaihHaxhvindndnaoaOfRbbceGTmbaOcjjjjlVhAxekdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHavcxfhvalaOcefgO9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkcbhOdnadTmbaehvcbhHinaOaiavclfydbcdtfydbgAaiavcwfydbcdtfydbgX9haiavydbcdtfydbgraA9haraX9hGGfhOavcxfhvaHcifgHad6mbkkdnas:ZgCaL:taY:Ygwaz:Y:tg8ANak:ZgEaO:Zg3:tNaEaL:tawaP:Y:tg5Na3aC:tNMg8EJbbbb9BmbaCaE:ta5a8Aa3aL:tNNNa8E:vawMhwkdndnaOaQ0mbaOhkaYhPxekaOhsaYhzkdndnaKcl0mbdnawJbbbZMgw:lJbbb9p9DTmbaw:Ohvxdkcjjjj94hvxekaPazfcd9ThvkaKcefgKcs9hmbkkdndndnakmbJbbjZhwcbhOcdhvaDmexdkalcd4alfhHcehOinaOgvcethOavaH6mbkcbhOaqcuavcdtgYavcFFFFi0Ecbyd1:H:cjbHjjjjbbgKBdCaqciBd2aqamcbyd1:H:cjbHjjjjbbgzBdKaqclBd2dndndndnalTmbaPcuf:YhwaoTmecbhOaihAaxhHindndnaoaOfRbbceGTmbaOcjjjjlVhXxekdndnaHclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqthXdndnaHcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarVhXdndnaHIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarcCtVhXkaAaXBdbaAclfhAaHcxfhHalaOcefgO9hmbxikkaKcFeaYz:tjjjb8AcbhPcbhvxdkaxhOaihHalhAindndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcCthXdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkarcqtaXVhXdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaHaXarVBdbaOcxfhOaHclfhHaAcufgAmbkkaKcFeaYz:tjjjbhravcufhocbhPcbhYindndndnaraiaYcdtgKfydbgAcm4aA7c:v;t;h;Ev2gvcs4av7aoGgHcdtfgXydbgOcuSmbcehvinaiaOcdtgOfydbaASmdaHavfhOavcefhvaraOaoGgHcdtfgXydbgOcu9hmbkkaXaYBdbaPhvaPcefhPxekazaOfydbhvkazaKfavBdbaYcefgYal9hmbkcuaPc8S2gOaPc;D;O;f8U0EhvkcbhXaqavcbyd1:H:cjbHjjjjbbgvBd3aqcvBd2avcbaOz:tjjjbhOdnadTmbaehiinaxaiclfydbgrcx2fgvIdbaxaiydbgocx2fgHIdbg3:tgCaxaicwfydbgYcx2fgAIdlaHIdlg8A:tgwNavIdla8A:tgEaAIdba3:tg8EN:tgLaLNaEaAIdwaHIdwg5:tg8FNavIdwa5:tgEawN:tgwawNaEa8ENaCa8FN:tgCaCNMMg8E:rhEJbbnnJbbjZazaocdtfydbgvazarcdtfydbgASavazaYcdtfydbgrSGgHEh8Fdna8EJbbbb9ETmbaLaE:vhLaCaE:vhCawaE:vhwkaOavc8S2fgvavIdbawa8FaE:rNgEawNNg8FMUdbavaCaEaCNgaNghavIdlMUdlavaLaEaLNg8ENggavIdwMUdwavawaaNgaavIdxMUdxava8EawNg8JavIdzMUdzavaCa8ENg8EavIdCMUdCavawaEaLa5Nawa3Na8AaCNMM:mg8ANg3NgwavIdKMUdKavaCa3NgCavId3MUd3avaLa3NgLavIdaMUdaava3a8ANg3avId8KMUd8KavaEavIdyMUdydnaHmbaOaAc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdyaOarc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdykaicxfhiaXcifgXad6mbkkcbhAaqcuaPcdtgvaPcFFFFi0Egicbyd1:H:cjbHjjjjbbgHBdaaqcoBd2aqaicbyd1:H:cjbHjjjjbbgiBd8KaqcrBd2aHcFeavz:tjjjbhYdnalTmbazhHinJbbbbJbbjZaOaHydbgXc8S2fgvIdygw:vawJbbbb9BEavIdwaxcwfIdbgwNavIdzaxIdbgCNavIdaMgLaLMMawNavIdlaxclfIdbgLNavIdCawNavId3MgwawMMaLNavIdbaCNavIdxaLNavIdKMgwawMMaCNavId8KMMM:lNhwdndnaYaXcdtgvfgXydbcuSmbaiavfIdbaw9ETmekaXaABdbaiavfawUdbkaHclfhHaxcxfhxalaAcefgA9hmbkkdndnaPmbJbbbbhwxekJbbbbhwinaiIdbgCawawaC9DEhwaiclfhiaPcufgPmbkaw:rhwkakcd4akfhOcehiinaigvcethiavaO6mbkcbhOaqcuavcdtgiavcFFFFi0Ecbyd1:H:cjbHjjjjbbgHBdyaHcFeaiz:tjjjbhXdnadTmbavcufhrcbhPcbhxindnazaeaxcdtfgvydbcdtfydbgiazavclfydbcdtfydbgOSmbaiazavcwfydbcdtfydbgvSmbaOavSmbaYavcdtfydbhAdndnaYaOcdtfydbgvaYaicdtfydbgi9pmbavaA9pmbaAhlaihoavhAxekdnaAai9pmbaAav9pmbaihlavhoxekavhlaAhoaihAkabaPcx2fgvaABdbavcwfaoBdbavclfalBdbdnaXaoc:3F;N8N2alc:F:b:DD27aAc;D;O:B8J27arGgOcdtfgvydbgicuSmbcehHinaHhvdnabaicx2fgiydbaA9hmbaiydlal9hmbaiydwaoSmikavcefhHaXaOavfarGgOcdtfgvydbgicu9hmbkkavaPBdbaPcefhPkaxcifgxad6mbkaPci2hOkcwhvaDTmekaDawUdbkavcdthvaqcxfc98fhiinaiavfydbcbyd:m:H:cjbH:bjjjbbavc98fgvmbkaqc;Wbf8KjjjjbaOk:3ldrue9:8Jjjjjbc;Wb9Rgr8Kjjjjbcbhwarcxfcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkarcualcdtalcFFFFi0EgDcbyd1:H:cjbHjjjjbbgqBdxarceBd2aqcbaialavcbarcxfz:djjjbcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbhkarcxfaryd2gxcdtfakBdbaraxcefgmBd2akaialavcbcbz:ejjjb8AarcxfamcdtfaDcbyd1:H:cjbHjjjjbbgiBdbaraxcdfgvBd2arcxfavcdtfcuaialaeadaqz:fjjjbgecltaecjjjjiGEcbyd1:H:cjbHjjjjbbgqBdbaqaeaiakalz:gjjjbaxcifhkdnadTmbaoaoNhocbhwabhlcbheindnaqaialydbgvcdtfydbcdtfIdbao9ETmbalclf8PdbhPabawcdtfgDavBdbaDclfaP83dbawcifhwkalcxfhlaecifgead6mbkkdnakTmbaxcdtarcxffcwfhlinalydbcbyd:m:H:cjbH:bjjjbbalc98fhlakcufgkmbkkarc;Wbf8Kjjjjbawk:WCoDud99vue99vuv998Jjjjjbc;Wb9Rgw8KjjjjbdndnarmbcbhDxekawcxfcbc;Kbz:tjjjb8Aawcuadcx2adc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgqBdxawceBd2aqaeadaicbcbz:ejjjb8AawcuadcdtadcFFFFi0Egkcbyd1:H:cjbHjjjjbbgxBdzawcdBd2adcd4adfhmceheinaegicetheaiam6mbkcbhPawcuaicdtgsaicFFFFi0Ecbyd1:H:cjbHjjjjbbgzBdCawciBd2dndnar:ZgH:rJbbbZMgO:lJbbb9p9DTmbaO:Ohexekcjjjj94hekaicufhAc:bwhCcbhXadhQcbhLinaeaCcufgiaeai9iEaPcefaeaP9kEhDdndnadTmbaDcuf:YhOaqhiaxheadhmindndnaiIdbaONJbbbZMgK:lJbbb9p9DTmbaK:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbh3cbh5indnaEaxa5cdtfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbaeaYSmbcehiinaEamaifaAGgmcdtfg8AydbgecuSmeaicefhiaeaY9hmbkka8AaYBdba3aecuSfh3a5cefg5ad9hmbxdkkazcFeasz:tjjjb8Acbh3kdnaQ:ZgKaH:taD:YgOaC:Y:tg8ENaX:Zg8Fa3:Zga:tNa8FaH:taOaP:Y:tghNaaaK:tNMggJbbbb9BmbaKa8F:taha8EaaaH:tNNNag:vaOMhOkaPaDa3ar0giEhPaXa3aiEhXdna3arSmbaDaCaiEgCaP9Rcd9imbdndnaLcl0mbdnaOJbbbZMgO:lJbbb9p9DTmbaO:Ohexdkcjjjj94hexekaPaCfcd9Theka3aQaiEhQaLcefgLcs9hmekkdndnaXmbcihicbhDxekcbhiawakcbyd1:H:cjbHjjjjbbg5BdKawclBd2aPcuf:YhKdndnadTmbaqhiaxheadhmindndnaiIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbhDcbh3indndndnaEaxa3cdtgCfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbcehiinaxaecdtgefydbaYSmdamaifheaicefhiaEaeaAGgmcdtfg8Aydbgecu9hmbkka8Aa3BdbaDhiaDcefhDxeka5aefydbhika5aCfaiBdba3cefg3ad9hmbkcuaDc32giaDc;j:KM;jb0EhexekazcFeasz:tjjjb8AcbhDcbhekawaecbyd1:H:cjbHjjjjbbgeBd3awcvBd2aecbaiz:tjjjbh8Aavcd4hxdnadTmbdnalTmbaxcdthEa5hYaqhealhmadhAina8AaYydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiamIdbaiIdxMUdxaiamclfIdbaiIdzMUdzaiamcwfIdbaiIdCMUdCaiaiIdKJbbjZMUdKaYclfhYaecxfheamaEfhmaAcufgAmbxdkka5hmaqheadhYina8Aamydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaiIdxJbbbbMUdxaiaiIdzJbbbbMUdzaiaiIdCJbbbbMUdCaiaiIdKJbbjZMUdKamclfhmaecxfheaYcufgYmbkkdnaDTmba8AhiaDheinaiaiIdbJbbbbJbbjZaicKfIdbgO:vaOJbbbb9BEgONUdbaiclfgmaOamIdbNUdbaicwfgmaOamIdbNUdbaicxfgmaOamIdbNUdbaiczfgmaOamIdbNUdbaicCfgmaOamIdbNUdbaic3fhiaecufgembkkcbhYawcuaDcdtgCaDcFFFFi0Egicbyd1:H:cjbHjjjjbbgeBdaawcoBd2awaicbyd1:H:cjbHjjjjbbgEBd8KaecFeaCz:tjjjbh3dnadTmbaoJbbjZJbbjZaK:vaPceSENgOaONhKaxcdthxalheinaKaec;8:G:cjbalEgmIdwa8Aa5ydbgAc32fgiIdC:tgOaONamIdbaiIdx:tgOaONamIdlaiIdz:tgOaONMMNaqcwfIdbaiIdw:tgOaONaqIdbaiIdb:tgOaONaqclfIdbaiIdl:tgOaONMMMhOdndna3aAcdtgifgmydbcuSmbaEaifIdbaO9ETmekamaYBdbaEaifaOUdbka5clfh5aqcxfhqaeaxfheadaYcefgY9hmbkkaba3aCzMjjjb8Acrhikaicdthiawcxfc98fheinaeaifydbcbyd:m:H:cjbH:bjjjbbaic98fgimbkkawc;Wbf8KjjjjbaDk:Pdidui99ducbhi8Jjjjjbca9Rglcbyd1:G:cjbBdKalcb8Pdj:G:cjb83izalcbydN:G:cjbBdwalcb8Pd:m:G:cjb83ibdndnaembJbbjFhvJbbjFhoJbbjFhrxekadcd4cdthwincbhdinalczfadfgDabadfIdbgvaDIdbgoaoav9EEUdbaladfgDavaDIdbgoaoav9DEUdbadclfgdcx9hmbkabawfhbaicefgiae9hmbkalIdwalIdK:thralIdlalIdC:thoalIdbalIdz:thvkJbbbbavavJbbbb9DEgvaoaoav9DEgvararav9DEk9DeeuabcFeaicdtz:tjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk;Bidqui998Jjjjjbc;Wb9Rgl8Kjjjjbalcxfcbc;Kbz:tjjjb8Aadcd4adfhvcehoinaogrcethoarav6mbkalcuarcdtgoarcFFFFi0Ecbyd1:H:cjbHjjjjbbgvBdxavcFeaoz:tjjjbhwdnadTmbaicd4hDarcufhqcbhkindndnawcbaeakaD2cdtfgrydlgiaicjjjj94SEgocH4ao7c:F:b:DD2cbarydbgxaxcjjjj94SEgocH4ao7c;D;O:B8J27cbarydwgmamcjjjj94SEgrcH4ar7c:3F;N8N27aqGgvcdtfgrydbgocuSmbam::hPai::hsax::hzcehiinaihrdnaeaoaD2cdtfgiIdbaz9CmbaiIdlas9CmbaiIdwaP9BmikarcefhiawavarfaqGgvcdtfgrydbgocu9hmbkkarakBdbakhokabakcdtfaoBdbakcefgkad9hmbkkalydxcbyd:m:H:cjbH:bjjjbbalc;Wbf8Kjjjjbk9teiucbcbyd:q:H:cjbgeabcifc98GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd:q:H:cjbgeabcrfc94GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd:q:H:cjbge9Rcifc98GaefgbBd:q:H:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk:Kedbcj:Gdk1eFFuuFFuuFFuuFFuFFFuFFFuFbbbbbbbbebbbdbbbbbbbebbbebbbdbbbbbbbbbbbeeeeebebbebbebebbbeebbbbbbbbbbbbeeeeeebebbeeebeebbbbebebbbbbbbbbbbbbbbbbbc1:Hdkxebbbdbbb:G:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(b){n=b.instance,n.exports.__wasm_call_ctors()});function r(b){var _=new Uint8Array(b.length);for(var x=0;x<b.length;++x){var v=b.charCodeAt(x);_[x]=v>96?v-97:v>64?v-39:v+4}var E=0;for(var x=0;x<b.length;++x)_[E++]=_[x]<60?t[_[x]]:(_[x]-60)*64+_[++x];return _.buffer.slice(0,E)}function s(b){if(!b)throw Error("Assertion failed")}function a(b){return new Uint8Array(b.buffer,b.byteOffset,b.byteLength)}function o(b,_,x,v){var E=n.exports.sbrk,S=E(x*4),T=E(x*v*4),A=new Uint8Array(n.exports.memory.buffer);A.set(a(_),T),b(S,T,x,v*4),A=new Uint8Array(n.exports.memory.buffer);var P=new Uint32Array(x);return new Uint8Array(P.buffer).set(A.subarray(S,S+x*4)),E(S-E(0)),P}function c(b,_,x){var v=n.exports.sbrk,E=v(_.length*4),S=v(x*4),T=new Uint8Array(n.exports.memory.buffer),A=a(_);T.set(A,E);var P=b(S,E,_.length,x);T=new Uint8Array(n.exports.memory.buffer);var w=new Uint32Array(x);new Uint8Array(w.buffer).set(T.subarray(S,S+x*4)),v(E-v(0));for(var I=0;I<_.length;++I)_[I]=w[_[I]];return[w,P]}function l(b){var _=0;for(var x=0;x<b.length;++x){var v=b[x];_=_<v?v:_}return _}function u(b,_,x,v,E,S,T,A,P){var w=n.exports.sbrk,I=w(4),F=w(x*4),N=w(E*S),U=w(x*4),D=new Uint8Array(n.exports.memory.buffer);D.set(a(v),N),D.set(a(_),U);var O=b(F,U,x,N,E,S,T,A,P,I);D=new Uint8Array(n.exports.memory.buffer);var K=new Uint32Array(O);a(K).set(D.subarray(F,F+O*4));var B=new Float32Array(1);return a(B).set(D.subarray(I,I+4)),w(I-w(0)),[K,B[0]]}function d(b,_,x,v,E,S,T,A,P,w,I,F,N){var U=n.exports.sbrk,D=U(4),O=U(x*4),K=U(E*S),B=U(E*A),X=U(P.length*4),q=U(x*4),le=w?U(E):0,de=new Uint8Array(n.exports.memory.buffer);if(de.set(a(v),K),de.set(a(T),B),de.set(a(P),X),de.set(a(_),q),w)de.set(a(w),le);var Me=b(O,q,x,K,E,S,B,A,X,P.length,le,I,F,N,D);de=new Uint8Array(n.exports.memory.buffer);var pe=new Uint32Array(Me);a(pe).set(de.subarray(O,O+Me*4));var J=new Float32Array(1);return a(J).set(de.subarray(D,D+4)),U(D-U(0)),[pe,J[0]]}function f(b,_,x,v,E,S,T,A,P,w,I,F,N){var U=n.exports.sbrk,D=U(4),O=U(E*S),K=U(E*A),B=U(P.length*4),X=U(x*4),q=w?U(E):0,le=new Uint8Array(n.exports.memory.buffer);if(le.set(a(v),O),le.set(a(T),K),le.set(a(P),B),le.set(a(_),X),w)le.set(a(w),q);var de=b(X,x,O,E,S,K,A,B,P.length,q,I,F,N,D);le=new Uint8Array(n.exports.memory.buffer),a(_).set(le.subarray(X,X+de*4)),a(v).set(le.subarray(O,O+E*S)),a(T).set(le.subarray(K,K+E*A));var Me=new Float32Array(1);return a(Me).set(le.subarray(D,D+4)),U(D-U(0)),[de,Me[0]]}function h(b,_,x,v){var E=n.exports.sbrk,S=E(x*v),T=new Uint8Array(n.exports.memory.buffer);T.set(a(_),S);var A=b(S,x,v);return E(S-E(0)),A}function y(b,_,x,v,E,S,T,A){var P=n.exports.sbrk,w=P(A*4),I=P(x*v),F=E?P(x*S):0,N=new Uint8Array(n.exports.memory.buffer);if(N.set(a(_),I),E)N.set(a(E),F);var U=b(w,I,x,v,F,S,T,A);N=new Uint8Array(n.exports.memory.buffer);var D=new Uint32Array(U);return a(D).set(N.subarray(w,w+U*4)),P(w-P(0)),D}function g(b,_,x,v,E,S,T,A,P){var w=n.exports.sbrk,I=w(4),F=w(x*4),N=w(E*S),U=w(x*4),D=T?w(E):0,O=new Uint8Array(n.exports.memory.buffer);if(O.set(a(v),N),O.set(a(_),U),T)O.set(a(T),D);var K=b(F,U,x,N,E,S,D,A,P,I);O=new Uint8Array(n.exports.memory.buffer);var B=new Uint32Array(K);a(B).set(O.subarray(F,F+K*4));var X=new Float32Array(1);return a(X).set(O.subarray(I,I+4)),w(I-w(0)),[B,X[0]]}function m(b,_,x,v,E,S,T){var A=n.exports.sbrk,P=A(x*4),w=A(E*S),I=A(x*4),F=new Uint8Array(n.exports.memory.buffer);F.set(a(v),w),F.set(a(_),I);var N=b(P,I,x,w,E,S,T);F=new Uint8Array(n.exports.memory.buffer);var U=new Uint32Array(N);return a(U).set(F.subarray(P,P+N*4)),A(P-A(0)),U}var p={LockBorder:1,Sparse:2,ErrorAbsolute:4,Prune:8,Regularize:16,Permissive:32,_InternalDebug:1073741824};return{ready:i,supported:!0,compactMesh:function(b){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0);var _=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),x=c(n.exports.meshopt_optimizeVertexFetchRemap,_,l(b)+1);if(b!==_)for(var v=0;v<_.length;++v)b[v]=_[v];return x},generatePositionRemap:function(b,_){return s(b instanceof Float32Array),s(b.length%_==0),s(_>=3),o(n.exports.meshopt_generatePositionRemap,b,b.length/_,_)},simplify:function(b,_,x,v,E,S){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v>=0&&v<=b.length),s(v%3==0),s(E>=0);var T=0;for(var A=0;A<(S?S.length:0);++A)s(S[A]in p),T|=p[S[A]];var P=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),w=u(n.exports.meshopt_simplify,P,b.length,_,_.length/x,x*4,v,E,T);return w[0]=b instanceof Uint32Array?w[0]:new b.constructor(w[0]),w},simplifyWithAttributes:function(b,_,x,v,E,S,T,A,P,w){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v instanceof Float32Array),s(v.length==E*(_.length/x)),s(E>=0),s(T==null||T instanceof Uint8Array),s(T==null||T.length==_.length/x),s(A>=0&&A<=b.length),s(A%3==0),s(P>=0),s(Array.isArray(S)),s(E>=S.length),s(S.length<=32);for(var I=0;I<S.length;++I)s(S[I]>=0);var F=0;for(var I=0;I<(w?w.length:0);++I)s(w[I]in p),F|=p[w[I]];var N=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),U=d(n.exports.meshopt_simplifyWithAttributes,N,b.length,_,_.length/x,x*4,v,E*4,new Float32Array(S),T,A,P,F);return U[0]=b instanceof Uint32Array?U[0]:new b.constructor(U[0]),U},simplifyWithUpdate:function(b,_,x,v,E,S,T,A,P,w){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v instanceof Float32Array),s(v.length==E*(_.length/x)),s(E>=0),s(T==null||T instanceof Uint8Array),s(T==null||T.length==_.length/x),s(A>=0&&A<=b.length),s(A%3==0),s(P>=0),s(Array.isArray(S)),s(E>=S.length),s(S.length<=32);for(var I=0;I<S.length;++I)s(S[I]>=0);var F=0;for(var I=0;I<(w?w.length:0);++I)s(w[I]in p),F|=p[w[I]];var N=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),U=f(n.exports.meshopt_simplifyWithUpdate,N,b.length,_,_.length/x,x*4,v,E*4,new Float32Array(S),T,A,P,F);if(b!==N)for(var I=0;I<U[0];++I)b[I]=N[I];return U},getScale:function(b,_){return s(b instanceof Float32Array),s(b.length%_==0),s(_>=3),h(n.exports.meshopt_simplifyScale,b,b.length/_,_*4)},simplifyPoints:function(b,_,x,v,E,S){if(s(b instanceof Float32Array),s(b.length%_==0),s(_>=3),s(x>=0&&x<=b.length/_),v)return s(v instanceof Float32Array),s(v.length%E==0),s(E>=3),s(b.length/_==v.length/E),y(n.exports.meshopt_simplifyPoints,b,b.length/_,_*4,v,E*4,S||0,x);else return y(n.exports.meshopt_simplifyPoints,b,b.length/_,_*4,void 0,0,0,x)},simplifySloppy:function(b,_,x,v,E,S){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v==null||v instanceof Uint8Array),s(v==null||v.length==_.length/x),s(E>=0&&E<=b.length),s(E%3==0),s(S>=0);var T=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),A=g(n.exports.meshopt_simplifySloppy,T,b.length,_,_.length/x,x*4,v,E,S);return A[0]=b instanceof Uint32Array?A[0]:new b.constructor(A[0]),A},simplifyPrune:function(b,_,x,v){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v>=0);var E=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),S=m(n.exports.meshopt_simplifyPrune,E,b.length,_,_.length/x,x*4,v);return S=b instanceof Uint32Array?S:new b.constructor(S),S}}}()});var BK;var LM=Ft(()=>{BK=function(){var e="b9H79Tebbbe:neP9Geueu9Geub9Gbb9Giuuueu9Gmuuuuuuuuuuu9999eu9Gouuuuuueu9Gruuuuuuub9Gxuuuuuuuuuuuueu9Gxuuuuuuuuuuu99eu9GPuuuuuuuuuuuuu99b9Gouuuuuub9Gwuuuuuuuub9Gvuuuuub9GluuuubiQXdilvorwDqokoqxmbiibeilve9Weiiviebeoweuecj:Gdkr;Zeqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9I919P29K9nW79O2Wt79c9V919U9KbeY9TW79O9V9Wt9F9I919P29K9nW79O2Wt7S2W94bd39TW79O9V9Wt9F9I919P29K9nW79O2Wt79t9W9Ht9P9H2bo39TW79O9V9Wt9F9J9V9T9W91tWJ2917tWV9c9V919U9K7bw39TW79O9V9Wt9F9J9V9T9W91tW9nW79O2Wt9c9V919U9K7bkE9TW79O9V9Wt9F9J9V9T9W91tW9t9W9OWVW9c9V919U9K7bxL9TW79O9V9Wt9F9V9Wt9P9T9P96W9nW79O2WtbPl79IV9RbsDwebcekdOAq;W:leXdbkIbabaec9:fgefcufae9Ugeabci9Uadfcufad9Ugbaeab0Ek:88JDPue99eux99due99euo99iu8Jjjjjbc:WD9Rgm8KjjjjbdndnalmbcbhPxekamc:Cwfcbc;Kbz:rjjjb8AcuaocdtgsaocFFFFi0Ehzcbyd;0:G:cjbhHdndnalcb9imbaoal9nmbamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waihzalhsinaHazydbcdtfcbBdbazclfhzascufgsmbkaihzalhsinaHazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkaihzalhCcbhXindnaHazydbcdtgQfgsydbcb9imbaOaQfaXBdbasasydbgQcjjjj94VBdbaQaXfhXkazclfhzaCcufgCmbkalci9UhLdnalci6mbcbhzaihsinascwfydbhCasclfydbhXaOasydbcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaXcdtfgXaXydbgXcefBdbaAaXcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaihzalhsindnaHazydbcdtgCfgXydbgQcu9kmbaXaQcFFFFrGgQBdbaOaCfgCaCydbaQ9RBdbkazclfhzascufgsmbxdkkamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waHcbasz:rjjjbhXaihzalhsinaXazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkalci9UhLdnaoTmbcbhzaOhsaXhCaohQinasazBdbasclfhsaCydbazfhzaCclfhCaQcufgQmbkkdnalci6mbcbhzaihsinascwfydbhCasclfydbhQaOasydbcdtfgKaKydbgKcefBdbaAaKcdtfazBdbaOaQcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaoTmbcbhzaohsinaOazfgCaCydbaXazfydb9RBdbazclfhzascufgsmbkkamaLcbyd;0:G:cjbHjjjjbbgzBd:OwamclBd;8wazcbaLz:rjjjbhYamcuaLcK2alcjjjjd0Ecbyd;0:G:cjbHjjjjbbg8ABd:SwamcvBd;8wJbbbbhEdnalci6g3mbarcd4hKaihsa8AhzaLhrJbbbbh5inavasclfydbaK2cdtfgCIdlh8EavasydbaK2cdtfgXIdlhEavascwfydbaK2cdtfgQIdlh8FaCIdwhaaXIdwhhaQIdwhgazaCIdbg8JaXIdbg8KMaQIdbg8LMJbbnn:vUdbazclfaXIdlaCIdlMaQIdlMJbbnn:vUdbaQIdwh8MaCIdwh8NaXIdwhyazcxfa8EaE:tg8Eagah:tggNaaah:tgaa8FaE:tghN:tgEJbbbbJbbjZa8Ja8K:tg8FahNa8Ea8La8K:tg8KN:tghahNaEaENaaa8KNa8FagN:tgEaENMMg8K:rg8E:va8KJbbbb9BEg8KNUdbazczfaEa8KNUdbazcCfaha8KNUdbazcwfa8Maya8NMMJbbnn:vUdba5a8EMh5ascxfhsazcKfhzarcufgrmbka5aL:Z:vJbbbZNhEkamcuaLcdtalcFFFF970Ecbyd;0:G:cjbHjjjjbbgCBd:WwamcoBd;8waq:Zhhdna3mbcbhzaChsinasazBdbasclfhsaLazcefgz9hmbkkaEahNhhamcuaLcltalcFFFFd0Ecbyd;0:G:cjbHjjjjbbg8PBd:0wamcrBd;8wcba8Pa8AaCaLcbz:djjjb8AJFFuuh8MJFFuuh8NJFFuuhydnalci6mbJFFuuhya8AhzaLhsJFFuuh8NJFFuuh8MinazcwfIdbgEa8Ma8MaE9EEh8MazclfIdbgEa8Na8NaE9EEh8NazIdbgEayayaE9EEhyazcKfhzascufgsmbkkah:rhEamaocetgzcuaocu9kEcbyd;0:G:cjbHjjjjbbgCBd:4wdndnaoal9nmbaihzalhsinaCazydbcetfcFFi87ebazclfhzascufgsmbxdkkaCcFeazz:rjjjb8AkaEJbbbZNh8JcuhIdnalci6mbcbhsJFFuuhEa8AhzcuhIinazcwfIdba8M:tghahNazIdbay:tghahNazclfIdba8N:tghahNMM:rghaEaIcuSahaE9DVgXEhEasaIaXEhIazcKfhzaLascefgs9hmbkkamczfcbcjwz:rjjjb8Aam9cb83iwam9cb83ibaxa8JNh8RJbbjZak:th8Lcbh8SJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8Ycbh8ZcbhPinJbbbbhEdna8STmbJbbjZa8S:Z:vhEkJbbbbhhdna8Ya8YNa8Wa8WNa8Xa8XNMMg8KJbbbb9BmbJbbjZa8K:r:vhhka8VaENh8Ka8UaENh5aRaENh8EaIhLdndndndndna8SaPVTmbamydwg80Tmea8YahNh8Fa8XahNhaa8WahNhgaeamydbcdtfh81cbh3JFFuuhEcvhQcuhLindnaHa81a3cdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhsindndnaCaiasydbgKcx2fgzclfydbgrcetf8Vebcs4aCazydbgXcetf8Vebcs4faCazcwfydbglcetf8Vebcs4fgombcbhzxekcehzaHaXcdtfydbgXceSmbcehzaHarcdtfydbgrceSmbcehzaHalcdtfydbglceSmbdnarcdSaXcdSfalcdSfcd6mbaocefhzxekaocdfhzkdnazaQ9kmba8AaKcK2fgXIdwa8K:tghahNaXIdba8E:tghahNaXIdla5:tghahNMM:ra8J:va8LNJbbjZMJ9VO:d86JbbjZaXIdCa8FNaXIdxagNaaaXIdzNMMakN:tghahJ9VO:d869DENghaEazaQ6ahaE9DVgXEhEaKaLaXEhLazaQaXEhQkasclfhsavcufgvmbkka3cefg3a809hmbkkaLcu9hmekama8KUd:ODama5Ud:KDama8EUd:GDamcuBd:qDamcFFF;7rBdjDa8Pcba8AaYamc:GDfamc:qDfamcjDfz:ejjjbamyd:qDhLdndnaxJbbbb9ETmba8SaD6mbaLcuSmeceh3amIdjDa8R9EmixdkaLcu9hmekdna8STmbabaPcltfgHam8Piw83dwaHam8Pib83dbaPcefhPkc3hHinamc:CwfaHfydbcbyd;4:G:cjbH:bjjjbbaHc98fgHc989hmbxvkkcbh3a8Saq9pmbamydwaCaiaLcx2fgzydbcetf8Vebcs4aCazcwfydbcetf8Vebcs4faCazclfydbcetf8Vebcs4ffaw9nmekcbhzcbhsdna8ZTmbcbhsamczfhXinamczfascdtfaXydbgQBdbaXclfhXasaYaQfRbbTfhsa8Zcufg8ZmbkkamydwhlamydbhXam9cu83i:GDam9cu83i:ODam9cu83i:qDam9cu83i:yDinamcjDfazfcFFF;7rBdbazclfgzcz9hmbkasc;8easclfc:bd6Eg8Zcdth80dnalTmbaeaXcdtfhocbhrindnaHaoarcdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhscuhQcuhzinaHaiasydbgKcx2fgXclfydbcdtfydbaHaXydbcdtfydbfaHaXcwfydbcdtfydbfgXazaXaz6gXEhzaKaQaXEhQasclfhsavcufgvmbkaQcuSmba8AaQcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEcbhsindndnazamc:qDfasfgvydbgX6mbazaX9hmeaEamcjDfasfIdb9FTmekavazBdbamc:GDfasfaQBdbamcjDfasfaEUdbxdkasclfgscz9hmbkkarcefgral9hmbkkamczfa80fhQcbhzcbhsindnamc:GDfazfydbgXcuSmbaQascdtfaXBdbascefhskazclfgzcz9hmbkasa8Zfg8ZTmbJFFuuhhcuhKamczfhza8ZhvcuhQina8AazydbgXcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEdndnaHaiaXcx2fgsclfydbcdtfydbaHasydbcdtfydbfaHascwfydbcdtfydbfgsaQ6mbasaQ9hmeaEah9DTmekaEhhashQaXhKkazclfhzavcufgvmbkaKcuSmbaKhLkdnamaiaLcx2fgrydbarclfydbarcwfydbaCabaeadaPawaqa3z:fjjjbTmbaPcefhPJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8YkcbhXinaAaOaraXcdtfydbcdtgsfydbcdtfgKhzaHasfgvydbgQhsdnaQTmbdninazydbaLSmeazclfhzascufgsTmdxbkkazaKaQcdtfc98fydbBdbavavydbcufBdbkaXcefgXci9hmbka8AaLcK2fgzIdbhEazIdlhhazIdwh8KazIdxh5azIdzh8EazIdCh8FaYaLfce86bba8Ya8FMh8Ya8Xa8EMh8Xa8Wa5Mh8Wa8Va8KMh8Va8UahMh8UaRaEMhRamydxh8Sxbkkamc:WDf8KjjjjbaPkjoivuv99lu8Jjjjjbca9Rgo8Kjjjjbdndnalcw0mbaiydbhraeabcitfgwalcdtciVBdlawarBdbdnalcd6mbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkkalabfhwxekcbhqaocbBdKao9cb83izaocbBdwao9cb83ibJbbjZhkJbbjZhxinadaiaqcdtfydbcK2fhDcbhwinaoczfawfgraDawfIdbgmarIdbgP:tgsaxNaPMgPUdbaoawfgrasamaP:tNarIdbMUdbawclfgwcx9hmbkJbbjZakJbbjZMgk:vhxaqcefgqal9hmbkcbhradcbcecdaoIdlgmaoIdwgP9GEgwaoIdbgsaP9GEawasam9GEgzcdtgwfhHaoczfawfIdbhmaihwalhDinaiarcdtfgqydbhOaqawydbgABdbawaOBdbawclfhwaraHaAcK2fIdbam9DfhraDcufgDmbkdndnarcv6mbavc8X9kmbaralc98f6mekaiydbhraeabcitfgwalcdtciVBdlawarBdbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkalabfhwxekaeabcitfgwamUdbawawydlc98GazVBdlabcefaeadaiaravcefgqz:djjjbhDawawydlciGaDabcu7fcdtVBdlaDaeadaiarcdtfalar9Raqz:djjjbhwkaocaf8Kjjjjbawk;Oddvue99dninabaecitfgrydlgwcd4gDTmednawciGgqci9hmbcihqdnawcl6mbabaecitfhbcbheawhqcehkindnaiabydbgDfRbbmbcbhkadaDcK2fgwIdwalIdw:tgxaxNawIdbalIdb:tgxaxNawIdlalIdl:tgxaxNMM:rgxaoIdb9DTmbaoaxUdbavaDBdbarydlhqkabcwfhbaecefgeaqcd46mbkakceGTmikaraqciGBdlskdnabcbaDalaqcdtfIdbarIdb:tgxJbbbb9FEgwaD7aecefgDfgecitfydlabawaDfgDcitfydlVci0mbaraqBdlkabaDadaialavaoz:ejjjbax:laoIdb9Fmbkkkjlevudndnabydwgxaladcetfgm8Vebcs4alaecetfgP8Vebgscs4falaicetfgz8Vebcs4ffaD0mbakmbcbhDabydxaq6mekavawcltfgxab8Pdw83dwaxab8Pdb83dbabydbhDdnabydwgwTmbaoaDcdtfhxawhsinalaxydbcetfcFFi87ebaxclfhxascufgsmbkkabaDawfBdbabydxhxab9cb83dwababydlaxci2fBdlaP8VebhscehDcbhxkdnascztcz91cu9kmbabaxcefBdwaPax87ebaoabydbcdtfaxcdtfaeBdbkdnam8Uebcu9kmbababydwgxcefBdwamax87ebaoabydbcdtfaxcdtfadBdbkdnaz8Uebcu9kmbababydwgxcefBdwazax87ebaoabydbcdtfaxcdtfaiBdbkarabydlfabydxci2faPRbb86bbarabydlfabydxci2fcefamRbb86bbarabydlfabydxci2fcdfazRbb86bbababydxcefBdxaDk:mPrHue99eue99eue99iu8Jjjjjbc;W;Gb9Rgx8KjjjjbdndnalmbcbhmxekcbhPaxc:m;Gbfcbc;Kbz:rjjjb8Aaxcualci9UgscltascjjjjiGEcbyd;0:G:cjbHjjjjbbgzBd:m9GaxceBd;S9GaxcuascK2gHcKfalcpFFFe0Ecbyd;0:G:cjbHjjjjbbgOBd:q9GaxcdBd;S9Gdnalci6gAmbarcd4hCascdthXaOhQazhLinavaiaPcx2fgrydwaC2cdtfhKavarydlaC2cdtfhYavarydbaC2cdtfh8AcbhraLhEinaQarfgma8Aarfg3Idbg5aYarfg8EIdbg8Fa5a8F9DEg5UdbamaKarfgaIdbg8Fa5a8Fa59DEg8FUdbamcxfgma3Idbg5a8EIdbgha5ah9EEg5UdbamaaIdbgha5aha59EEg5UdbaEa8Fa5MJbbbZNUdbaEaXfhEarclfgrcx9hmbkaQcKfhQaLclfhLaPcefgPas9hmbkkaOaHfgr9cb83dbar9cb83dzar9cb83dwaxcuascx2gralc:bjjjl0Ecbyd;0:G:cjbHjjjjbbgHBdN9GaxciBd;S9GascdthgazarfhvaxcwVhPaxclVhCaHh8Jazh8KcbhLinaxcbcj;Gbz:rjjjbhEaLas2cdthadnaAmba8Khrash3inaEarydbgmc8F91cjjjj94Vam7gmcQ4cx2fg8Ea8EydwcefBdwaEamcd4cFrGcx2fg8Ea8EydbcefBdbaEamcx4cFrGcx2fgmamydlcefBdlarclfhra3cufg3mbkkazaafh8AaHaafhXcbhmcbh3cbh8EcbhainaEamfgrydbhQara3BdbarcwfgKydbhYaKaaBdbarclfgrydbhKara8EBdbaQa3fh3aYaafhaaKa8Efh8Eamcxfgmcj;Gb9hmbkdnaAmbcbhravhminamarBdbamclfhmasarcefgr9hmbkavhrashminaEa8Aarydbg3cdtfydbg8Ec8F91a8E7cd4cFrGcx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbka8JhrashminaCa8Aarydbg3cdtfydbg8Ec8F91a8E7cx4cFrGcx2fg8Ea8Eydbg8EcefBdbava8Ecdtfa3BdbarclfhramcufgmmbkavhrashminaPa8Aarydbg3cdtfydbg8Ec8F91cjjjj94Va8E7cQ4cx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbkka8Jagfh8Ja8Kagfh8KaLcefgLci9hmbkaEaocetgrcuaocu9kEcbyd;0:G:cjbHjjjjbbgKBd:y9GaEclBd;S9Gdndnaoal9nmbaihralhminaKarydbcetfcFFi87ebarclfhramcufgmmbxdkkaKcFearz:rjjjb8Akcbh8EaEascbyd;0:G:cjbHjjjjbbg8ABd:C9GaOaHaHascdtfaHascitfa8AascbazaKaiawaDaqakz:hjjjbdndnalci6mba8Ahrashmina8EarRbbfh8EarcefhramcufgmmbkaE9cb83iwaE9cb83ibalawc9:fgrfcufar9UgrasaDfcufaD9Ugmaram0EhYcbhmcbhra8Ehaincbh3dnarTmba8AarfRbbceSh3kamaEaiaHydbcx2fgQydbaQclfydbaQcwfydbaKabaeadamawaqa3a3ce7a8EaY9nVaaamfaY6VGz:fjjjbfhmaHclfhHaaa8AarfRbb9Rhaasarcefgr9hmbkaEydxTmeabamcltfgraE8Piw83dwaraE8Pib83dbamcefhmxekaE9cb83iwaE9cb83ibcbhmkczhrinaEc:m;Gbfarfydbcbyd;4:G:cjbH:bjjjbbarc98fgrc989hmbkkaxc;W;Gbf8Kjjjjbamk:wKDQue99iue99iul9:euw99iu8Jjjjjbc;qb9RgP8Kjjjjbaxhsaxhzdndnavax0gHmbdnavTmbcbhOaehzavhAinawaDazydbcx2fgCcwfydbcetfgX8VebhQawaCclfydbcetfgL8VebhKawaCydbcetfgC8VebhYaXce87ebaLce87ebaCce87ebaOaKcs4aYcs4faQcs4ffhOazclfhzaAcufgAmbkaehzavhAinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaAcufgAmbkcehzaqhsaOaq0mekalce86bbalcefcbavcufz:rjjjb8AxekaPaiBdxaPadBdwaPaeBdlavakaqci9Ug8Aaka8Aak6EaHEgK9RhEaxaK9Rh3aKcufh5aKceth8EaKcdtgCc98fh8FavcitgOaC9Rarfc98fhaascufhhavcufhgaraOfh8JJbbjZas:Y:vh8KcbazceakaxSEg8Lcdtg8M9Rh8NJFFuuhycuh8PcbhIcbh8RinaPclfa8RcdtfydbhQaPcb8Pd:y:G:cjbg8S83i9iaPcb8Pd:q:G:cjbgR83inaPcb8Pd1:G:cjbg8U83iUaPcb8Pdj:G:cjbg8V83i8WaPa8S83iyaPaR83iaaPa8U83iKaPa8V83izaQavcdtgYfh8WcbhXinabaQaXcdtgLfydbcK2fhAcbhzinaPc8WfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaba8WaXcu7cdtfydbcK2fhAcbhzaPIdUh8ZaPId9ih80aPId80h81aPId9ehBaPId8Wh83aPIdnhUinaPczfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaraLfgzaBa81:tg8Xa80a8Z:tg8YNaUa83:tg8Za8XNa8Za8YNMMUdbazaYfaPId8KaPIdC:tg8XaPIdyaPIdK:tg8YNaPIdaaPIdz:tg8Za8XNa8Za8YNMMUdbaXcefgXav9hmbkcbh85dnaHmbcbhAaQhza8JhCavhXinawaDazydbcx2fgOcwfydbcetfgL8Vebh8WawaOclfydbcetfg858Vebh86awaOydbcetfgO8Vebh87aLce87eba85ce87ebaOce87ebaCaAa86cs4a87cs4fa8Wcs4ffgABdbazclfhzaCclfhCaXcufgXmbkavhCinawaDaQydbcx2fgzcwfydbcetfcFFi87ebawazclfydbcetfcFFi87ebawazydbcetfcFFi87ebaQclfhQaCcufgCmbka8Jh85kdndndndndndndndndndndnava8E6mba8Eax9nmeavavaK9UgzaK29Raza320mda5aE9pmqa85Th87ceh8WaEhQxwka5ag9pmDa8Eax9nmixokavaK6mea5aE9pmwcehQaEhXa85Tmixlka5ag6mlxrka5ag9pmokcbhQaghXa85mekJFFuuh8XcbhLa5hzindnazcefgCaK6mbaQavaC9RgOaK6GmbarazcdtfIdbg8YaC:YNaravaz9RcdtfaYfc94fIdbg8ZaO:YNMg80a8X9Embdndna8KaOahf:YNg81:lJbbb9p9DTmba81:OhAxekcjjjj94hAka8ZasaA2aO9R:YNh8Zdndna8Kazasf:YNg81:lJbbb9p9DTmba81:OhOxekcjjjj94hOkamasaO2aC9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgOEh8XaCaLaOEhLkaza8LfgzaX6mbxlkkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazaK6mbaQaCaK6GmbaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9Embdndna8Ka85aOfydbgYahf:YNg81:lJbbb9p9DTmba81:Oh8Wxekcjjjj94h8Wkamasa8W2aY9R:Yg81a8YNa8Za81NMNa80Mg8Ya8Xa8Ya8X9DgYEh8XazaLaYEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaX6mbxikka85Th87cbh8WaghQkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazazaK9UgXaK29RaXa320mbdna8WTmbaCaCaK9UgXaK29RaXa320mekaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9EmbazhXaChYdna87mba85aOfydbgXhYkdndna8KaYahf:YNg81:lJbbb9p9DTmba81:Oh86xekcjjjj94h86ka8Zasa862aY9R:YNh8Zdndna8KaXahf:YNg81:lJbbb9p9DTmba81:OhYxekcjjjj94hYkamasaY2aX9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgXEh8XazaLaXEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaQ6mbkkaLTmba8Xay9DTmba8XhyaLhIa8Rh8Pka8Rcefg8Rci9hmbkdndnaoc8X9kmba8Pcb9omeka8Acufh85cbhYindndndnavaY9RaxaYaxfav0Eg8WTmbcbhAaeaYcdtfgzhCa8WhXinawaDaCydbcx2fgOcwfydbcetfgQ8VebhbawaOclfydbcetfgL8VebhrawaOydbcetfgO8VebhKaQce87ebaLce87ebaOce87ebaAarcs4aKcs4fabcs4ffhAaCclfhCaXcufgXmbka8WhOinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaOcufgOmbkaAaq0mekalaYfgzce86bbazcefcba8Wcufz:rjjjb8AxekalaYfgzce86bbazcefcba85z:rjjjb8Aa8Ah8Wka8WaYfgYav9pmdxbkkaravcdtg8WfhLdnaITmbaPclfa8PcdtfydbhzaIhCinaLazydbfcb86bbazclfhzaCcufgCmbkkdnavaI9nmbaPclfa8PcdtfydbaIcdtfhzavaI9RhCinaLazydbfce86bbazclfhzaCcufgCmbkkcbhYindnaYa8PSmbcbhzaraPclfaYcdtfydbgKa8Wz:qjjjbhCavhXaIhOinaKaOazaLaCydbgQfRbbgAEcdtfaQBdbaCclfhCaOaAfhOazaA9RcefhzaXcufgXmbkkaYcefgYci9hmbkabaeadaialaIaocefgCarawaDaqakaxamz:hjjjbabaeaIcdtgzfadazfaiazfalaIfavaI9RaCarawaDaqakaxamz:hjjjbkaPc;qbf8Kjjjjbk:Seeru8Jjjjjbc:q;ab9Rgo8Kjjjjbaoc:q8WfcFecjzz:rjjjb8AcbhrdnadTmbaehwadhDinaoarcdtfawydbgqBdbaoc:q8WfaqcFiGcdtfgkydbhxakaqBdbawclfhwaraxaq9hfhraDcufgDmbkkabaeadaoaraiavz:jjjjbaoc:q;abf8Kjjjjbk;Sqloud99euD998Jjjjjbc:W;ab9Rgr8KjjjjbdndnadTmbaocd4hwcbhDcbhqindnavaeclfydbaw2cdtfgkIdbavaeydbaw2cdtfgxIdbgm:tgPavaecwfydbaw2cdtfgsIdlaxIdlgz:tgHNakIdlaz:tgOasIdbam:tgAN:tgCaCNaOasIdwaxIdwgX:tgQNakIdwaX:tgOaHN:tgHaHNaOaANaPaQN:tgPaPNMMgOJbbbb9Bmbarc8WfaDcltfgkaCaO:rgO:vgCUdwakaPaO:vgPUdlakaHaO:vgHUdbakaCaXNaHamNazaPNMM:mUdxaDcefhDkaecxfheaqcifgqad6mbkab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbaDTmearcbBd8Sar9cb83iKar9cb83izarczfavalaoarc8Sfcbcraiz:kjjjbarIdKhQarIdChLarIdzhKar9cb83iwar9cb83ibararc8WfaDczarc8Sfcbcicbz:kjjjbJbbbbhmdnarIdwgzazNarIdbgHaHNarIdlgXaXNMMgCJbbbb9BmbJbbjZaC:r:vhmkazamNhCaXamNhXaHamNhHJbbjZhmarc8WfheaDhvinaecwfIdbaCNaeIdbaHNaXaeclfIdbNMMgzamazam9DEhmaeczfheavcufgvmbkabaQUdwabaLUdlabaKUdbabarId3UdxdndnamJ;n;m;m899FmbJbbbbhzarc8WfheinaecxfIdbaQaecwfIdbgPNaKaeIdbgONaLaeclfIdbgANMMMaCaPNaHaONaXaANMM:vgPazaPaz9EEhzaeczfheaDcufgDmbkabaCUd8KabaXUdaabaHUd3abaQaCazN:tUdKabaLaXazN:tUdCabaKaHazN:tUdzabJbbjZamamN:t:rgmUdydndnaCJbbj:;aCJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aCJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohexekcjjjj94hekabae86b8UdndnaXJbbj:;aXJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aXJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohvxekcjjjj94hvkabav86bRdndnaHJbbj:;aHJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aHJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohwxekcjjjj94hwkabaw86b8SdndnaecKtcK91:YJbb;:9c:vaC:t:lavcKtcK91:YJbb;:9c:vaX:t:lawcKtcK91:YJbb;:9c:vaH:t:lamMMMJbb;:9cNJbbjZMgm:lJbbb9p9DTmbam:Ohexekcjjjj94hekaecFbaecFb9iEhexekabcjjj;8iBdycFbhekabae86b8Vxekab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbkarc:W;abf8Kjjjjbk;7woDuo99eue99euv998Jjjjjbcje9Rgw8Kjjjjbawc;abfcbaocdtgDz:rjjjb8Aawc;GbfcbaDz:rjjjb8AawcafhDawhqaohkinaqcFFF97BdbaDcFFF;7rBdbaqclfhqaDclfhDakcufgkmbkavcd4hxaicd4hmdnadTmbaocx2hPcbhsinashzdnarTmbarascdtfydbhzkaeazam2cdtfgDIdwhHaDIdlhOaDIdbhAalazax2cdtfIdbhCcbhDawcafhqawc;Gbfhvawhkawc;abfhiinaCaDc:O:G:cjbfIdbaHNaDc:G:G:cjbfIdbaANaDc:K:G:cjbfIdbaONMMgXMhQazhLdnaXaC:tgXaqIdbgK9DgYmbavydbhLkavaLBdbazhLdnaQakIdbg8A9EmbaiydbhLa8AhQkaiaLBdbakaQUdbaqaXaKaYEUdbaiclfhiakclfhkavclfhvaqclfhqaPaDcxfgD9hmbkascefgsad9hmbkkJbbbbhQcbhLawc;GbfhDawc;abfhqcbhkinalaqydbgvax2cdtfIdbalaDydbgiax2cdtfIdbaeavam2cdtfgvIdwaeaiam2cdtfgiIdw:tgCaCNavIdbaiIdb:tgCaCNavIdlaiIdl:tgCaCNMM:rMMgCaQaCaQ9EgvEhQakaLavEhLaqclfhqaDclfhDaoakcefgk9hmbkJbbbbhCdnaeawc;abfaLcdtgqfydbgkam2cdtfgDIdwaeawc;Gbfaqfydbgvam2cdtfgqIdwgH:tgXaXNaDIdbaqIdbgA:tg8Aa8ANaDIdlaqIdlgE:tgOaONMMgKJbbbb9ETmbaK:rgCalakax2cdtfIdbMalavax2cdtfIdb:taCaCM:vhCkaQJbbbZNhKaXaCNaHMhHaOaCNaEMhOa8AaCNaAMhAdnadTmbcbhqarhkinaqhDdnarTmbakydbhDkdnalaDax2cdtfIdbg3aeaDam2cdtfgDIdwaH:tgQaQNaDIdbaA:tgCaCNaDIdlaO:tgXaXNMMg5:rgEMg8EaK9ETmbJbbbbh8Adna5Jbbbb9ETmba8EaK:taEaEM:vh8Aka8AaQNaHMhHa8AaXNaOMhOa8AaCNaAMhAa3aKaEMMJbbbZNhKkakclfhkadaqcefgq9hmbkkabaKUdxabaHUdwabaOUdlabaAUdbawcjef8Kjjjjbk:reevu8Jjjjjbcj8W9Rgr8Kjjjjbaici2hwcbhDdnaiTmbarhiawhqinaiaeadRbbgkcdtfydbBdbaDakcefgkaDak0EhDaiclfhiadcefhdaqcufgqmbkkabarawaeaDalaoz:jjjjbarcj8Wf8Kjjjjbk:Eeeeu8Jjjjjbca9Rgo8Kjjjjbab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbdnadTmbaocbBd3ao9cb83iwao9cb83ibaoaeadaialaoc3falEavcbalEcrcbz:kjjjbabao8Pib83dbabao8Piw83dwkaocaf8Kjjjjbk::meQu8Jjjjjbcjz9Rgv8KjjjjbcbhoavcjPfcbaez:rjjjb8Aavcjxfcbaez:rjjjb8AdnaiTmbadhoaihrinavcjxfaoRbbfgwawRbbcef86bbavcjxfaocefRbbfgwawRbbcef86bbavcjxfaocdfRbbfgwawRbbcef86bbaocifhoarcufgrmbkcbhDcjehoadhqcehkindndnalTmbcbhxcuhmaqhrakhwcuhPinawcufamaoavcjPfarcefRbbgsfRbb9RcFeGgzci6aoavcjPfarRbbgHfRbb9RcFeGgOci6faoavcjPfarcdfRbbgAfRbb9RcFeGgCci6fgXcOtaOcFr7azaCf9RcwtVavcjxfaAfRbbgzavcjxfaHfRbbgHavcjxfasfRbbgsaHas6Egsazas6EcFe7VgsaP9kgzEhmaXcd6gHaxcefgOal9iVce9hmdasaPazEhPaxaOaHEhxarcifhrawai6hsawcefhwasmbxdkkcuhmaqhrakhwcuhxinawcufamaoavcjPfarcefRbbfRbb9RcFeGci6aoavcjPfarRbbfRbb9RcFeGci6faoavcjPfarcdfRbbfRbb9RcFeGci6fgPax9kgsEhmaPce0meaPaxasEhxarcifhrawai6hPawcefhwaPmbkkadamci2fgrcdfRbbhwarcefRbbhxarRbbhPadaDci2fgrcifaramaD9Rci2zNjjjb8AaPavcjPffaocefgo86bbaPavcjxffgmamRbbcuf86bbaxavcjPffao86bbaxavcjxffgmamRbbcuf86bbarcdfaw86bbarcefax86bbaraP86bbawavcjPffao86bbawavcjxffgrarRbbcuf86bbaqcifhqakcefhkaDcefgDai9hmbkcbhzdnalcb9mmbcbhsavcjPfcbaez:rjjjb8Aadcvfhlinadasci2fgxcefgDRbbhoaxcdfgqRbbhrdndnavcjPfaxRbbgmfRbbmbavcjPfarfRbbhwdndndnavcjPfaofRbbTmbawcFeGTmexikawcFeGmdascefgAai9pmdasc980mdascifhQcbhLarcFeGhCamcFeGhXalhwcbhKcbhYinawcufRbbhPawRbbhOcehkdndnawc9:fRbbgHao9hmbaPcFeGamSmekdnaPcFeGao9hmbaOcFeGamSmekaHamSaOcFeGaoSGhkkceh8AaYceGhYdndnaHar9hmbaPcFeGaoSmekdnaPcFeGar9hmbaOcFeGaoSmekaHaoSaOcFeGarSGh8AkakaYVhYaLaHcFeGgHaXSaPcFeGgPaCSGaPaXSaOcFeGgPaCSGVaHaCSaPaXSGVVhLa8AaKceGVhKdnaAcefgPai9pmbawcifhwaAaQ6hHaPhAaHmekkaYTmeaKmekarhwaohPaohHarhOamhrxdkdnaYTaLVceGTmbaYaKTVaLVceGmekamhwarhParhHamhOaohrxekaohwamhPamhHaohOkavcjPfarfce86bbavcjPfawfce86bbaxaH86bbaqar86bbaDaO86bbavcjPfaPfce86bbalcifhlascefgsai9hmbkkavcFeaecetz:rjjjbhwaici2hrindnawadRbbgmcetfgx8Uebgocu9kmbaxaz87ebawcjlfazcdtfabamcdtfydbBdbazhoazcefhzkadao86bbadcefhdarcufgrmbkazcdthokabavcjlfaoz:qjjjb8Aavcjzf8KjjjjbkObabaiaeadcbz:njjjbk9teiucbcbyd;8:G:cjbgeabcifc98GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;8:G:cjbgeabcrfc94GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;8:G:cjbge9Rcifc98GaefgbBd;8:G:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk:3qeludndnadch6mbadTmeabaead;8qbbabskabaeSmbdnaeadabfgi9Rcbadcet9R0mbadTmeabaead;8qbbabskaeab7ciGhldndndnabae9pmbdnalTmbadhvabhixikdnabciGmbadhvabhixdkadTmiabaeRbb86bbadcufhvdnabcefgiciGmbaecefhexdkavTmiabaeRbe86beadc9:fhvdnabcdfgiciGmbaecdfhexdkavTmiabaeRbd86bdadc99fhvdnabcifgiciGmbaecifhexdkavTmiabaeRbi86biabclfhiaeclfheadc98fhvxekdnalmbdnaiciGTmbadTmlabadcufgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc9:fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc99fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc98fgdfaeadfRbb86bbkadcl6mbdnadc98fgocxGcxSmbaocd4cefciGhiaec98fhlabc98fhvinavadfaladfydbBdbadc98fhdaicufgimbkkaocx6mbaec9Wfhvabc9WfhoinaoadfgicxfavadfglcxfydbBdbaicwfalcwfydbBdbaiclfalclfydbBdbaialydbBdbadc9Wfgdci0mbkkadTmdadhidnadciGglTmbaecufhvabcufhoadhiinaoaifavaifRbb86bbaicufhialcufglmbkkadcl6mdaec98fhlabc98fhvinavaifgecifalaifgdcifRbb86bbaecdfadcdfRbb86bbaecefadcefRbb86bbaeadRbb86bbaic98fgimbxikkavcl6mbdnavc98fglc3Gc3Smbavalcd4cefcrGgdcdt9RhvinaiaeydbBdbaeclfheaiclfhiadcufgdmbkkalc36mbinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfaeczfydbBdbaicCfaecCfydbBdbaicKfaecKfydbBdbaic3faec3fydbBdbaecafheaicafhiavc9Gfgvci0mbkkavTmbdndnavcrGgdmbavhlxekavc94GhlinaiaeRbb86bbaicefhiaecefheadcufgdmbkkavcw6mbinaiaeRbb86bbaicefaecefRbb86bbaicdfaecdfRbb86bbaicifaecifRbb86bbaiclfaeclfRbb86bbaicvfaecvfRbb86bbaicofaecofRbb86bbaicrfaecrfRbb86bbaicwfhiaecwfhealc94fglmbkkabkk:pedbcj:GdktFFuuFFuuFFuubbbbFFuFFFuFFFuFbbbbbbjZbbbbbbbbbbbbbbjZbbbbbbbbbbbbbbjZ86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;bc;0:Gdkxebbbdbbbj:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(g){n=g.instance,n.exports.__wasm_call_ctors()});function r(g){var m=new Uint8Array(g.length);for(var p=0;p<g.length;++p){var b=g.charCodeAt(p);m[p]=b>96?b-97:b>64?b-39:b+4}var _=0;for(var p=0;p<g.length;++p)m[_++]=m[p]<60?t[m[p]]:(m[p]-60)*64+m[++p];return m.buffer.slice(0,_)}function s(g){if(!g)throw Error("Assertion failed")}function a(g){return new Uint8Array(g.buffer,g.byteOffset,g.byteLength)}var o=48,c=16;function l(g,m){var p=g.meshlets[m*4+0],b=g.meshlets[m*4+1],_=g.meshlets[m*4+2],x=g.meshlets[m*4+3];return{vertices:g.vertices.subarray(p,p+_),triangles:g.triangles.subarray(b,b+x*3)}}function u(g,m,p,b,_,x,v,E,S,T){var A=n.exports.sbrk,P=n.exports.meshopt_buildMeshletsBound(m.length,x,v),w=A(P*c),I=A(m.length*4),F=A(m.length),N=A(m.byteLength),U=A(p.byteLength),D=new Uint8Array(n.exports.memory.buffer);D.set(a(m),N),D.set(a(p),U);var O=g(w,I,F,N,m.length,U,b,_,x,v,E,S,T);D=new Uint8Array(n.exports.memory.buffer);var K=D.subarray(w,w+O*c),B=new Uint32Array(K.buffer,K.byteOffset,K.byteLength/4).slice();for(var X=0;X<O;++X){var q=B[X*4+0],le=B[X*4+1],b=B[X*4+2],de=B[X*4+3];n.exports.meshopt_optimizeMeshlet(I+q*4,F+le,de,b)}var Me=O?B[(O-1)*4+0]+B[(O-1)*4+2]:0,pe=O?B[(O-1)*4+1]+B[(O-1)*4+3]*3:0,J={meshlets:B,vertices:new Uint32Array(D.buffer,I,Me).slice(),triangles:new Uint8Array(D.buffer,F,pe).slice(),meshletCount:O};return A(w-A(0)),J}function d(g){var m=new Float32Array(n.exports.memory.buffer,g,o/4);return{centerX:m[0],centerY:m[1],centerZ:m[2],radius:m[3],coneApexX:m[4],coneApexY:m[5],coneApexZ:m[6],coneAxisX:m[7],coneAxisY:m[8],coneAxisZ:m[9],coneCutoff:m[10]}}function f(g,m,p,b){var _=n.exports.sbrk,x=[],v=_(m.byteLength),E=_(g.vertices.byteLength),S=_(g.triangles.byteLength),T=_(o),A=new Uint8Array(n.exports.memory.buffer);A.set(a(m),v),A.set(a(g.vertices),E),A.set(a(g.triangles),S);for(var P=0;P<g.meshletCount;++P){var w=g.meshlets[P*4+0],I=g.meshlets[P*4+1],F=g.meshlets[P*4+3];n.exports.meshopt_computeMeshletBounds(T,E+w*4,S+I,F,v,p,b),x.push(d(T))}return _(v-_(0)),x}function h(g,m,p,b){var _=n.exports.sbrk,x=_(o),v=_(g.byteLength),E=_(m.byteLength),S=new Uint8Array(n.exports.memory.buffer);S.set(a(g),v),S.set(a(m),E),n.exports.meshopt_computeClusterBounds(x,v,g.length,E,p,b);var T=d(x);return _(x-_(0)),T}function y(g,m,p,b,_){var x=n.exports.sbrk,v=x(o),E=x(g.byteLength),S=b?x(b.byteLength):0,T=new Uint8Array(n.exports.memory.buffer);if(T.set(a(g),E),b)T.set(a(b),S);n.exports.meshopt_computeSphereBounds(v,E,m,p,S,b?_:0);var A=d(v);return x(v-x(0)),A}return{ready:i,supported:!0,buildMeshlets:function(g,m,p,b,_,x){s(g.length%3==0),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),s(b>=3&&b<=256),s(_>=1&&_<=512),x=x||0;var v=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return u(n.exports.meshopt_buildMeshletsFlex,v,m,m.length/p,p*4,b,_,_,x,0)},buildMeshletsFlex:function(g,m,p,b,_,x,v,E){s(g.length%3==0),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),s(b>=3&&b<=256),s(_>=1&&x<=512),s(_<=x),v=v||0,E=E||0;var S=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return u(n.exports.meshopt_buildMeshletsFlex,S,m,m.length/p,p*4,b,_,x,v,E)},buildMeshletsSpatial:function(g,m,p,b,_,x,v){s(g.length%3==0),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),s(b>=3&&b<=256),s(_>=1&&x<=512),s(_<=x),v=v||0;var E=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return u(n.exports.meshopt_buildMeshletsSpatial,E,m,m.length/p,p*4,b,_,x,v)},extractMeshlet:function(g,m){return s(m>=0&&m<g.meshletCount),l(g,m)},computeClusterBounds:function(g,m,p){s(g.length%3==0),s(g.length/3<=512),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3);var b=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return h(b,m,m.length/p,p*4)},computeMeshletBounds:function(g,m,p){return s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),f(g,m,m.length/p,p*4)},computeSphereBounds:function(g,m,p,b){return s(g instanceof Float32Array),s(g.length%m==0),s(m>=3),s(!p||p instanceof Float32Array),s(!p||p.length%b==0),s(!p||b>=1),s(!p||g.length/m==p.length/b),b=b||0,y(g,g.length/m,m*4,p,b*4)}}}()});var FM={};pb(FM,{MeshoptEncoder:()=>g9});var UM=Ft(()=>{OM();kM();DM();LM()});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 xf(e,t="|"){return e.map((n)=>Ef(n)).join(t)}function qo(e,t){if(typeof t==="bigint")return t.toString();return t}class mb{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 Jo(e){return new mb(e)}function gb(e){return e===null||e===void 0}function Jr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function bb(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 hi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Zo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ar(e){return Zo(e._zod.def)??e._zod.def.shape}function yb(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return hi(this,t,i),i},enumerable:!0,configurable:!0})}function xb(e,t,n){if(t in e)hi(e,t,n);else e[t]=n}function Qs(e,t,n,i){let r=Ar(t);for(let s of n){let a=Object.getOwnPropertyDescriptor(r,s);if(!a.enumerable)continue;if(a.get)yb(e,s,()=>{let o=t._zod.def.shape[s];return i?i(o,s):o});else xb(e,s,i?i(a.value,s):a.value)}}function RR(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)yb(e,n,()=>t[n]);else xb(e,n,i.value)}}function Jn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function _b(e){return JSON.stringify(e)}function vb(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var _f="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function La(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Eb=Jo(()=>{if(Ln.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ea(e){if(La(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(La(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function vf(e){if(ea(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 Tb=new Set(["string","number","symbol"]),Ab=new Set(["string","number","bigint","boolean","symbol","undefined"]);function wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Fe(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 Ef(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Sb(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Rl=(()=>({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]}))(),Tf={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function IR(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 Qs(s,e,Il(e,t)),Wi(e,Jn(n,{shape:s,checks:[]}))}function Il(e,t){let n=Ar(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 CR(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(Il(e,t)),a={};return Qs(a,e,Reflect.ownKeys(Ar(e)).filter((o)=>!s.has(o))),Wi(e,Jn(n,{shape:a,checks:[]}))}function NR(e,t){if(!ea(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Ar(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 Wi(e,Jn(e._zod.def,{shape:wb(e,t)}))}function wb(e,t){let n={};return Qs(n,e,Reflect.ownKeys(Ar(e))),RR(n,t),n}function PR(e,t){if(!ea(t))throw Error("Invalid input to safeExtend: expected a plain object");return Wi(e,Jn(e._zod.def,{shape:wb(e,t)}))}function OR(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={};Qs(n,e,Reflect.ownKeys(Ar(e))),Qs(n,t,Reflect.ownKeys(Ar(t)));let i=Jn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Wi(e,i)}function Mb(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 o=n?new Set(Il(t,n)):void 0,c={};return Qs(c,t,Reflect.ownKeys(Ar(t)),e&&((l,u)=>o&&!o.has(u)?l:new e({type:"optional",innerType:l}))),Wi(t,Jn(t._zod.def,{shape:c,checks:[]}))}function kR(e,t,n){let i=n?new Set(Il(t,n)):void 0,r={};return Qs(r,t,Reflect.ownKeys(Ar(t)),(s,a)=>i&&!i.has(a)?s:new e({type:"nonoptional",innerType:s})),Wi(t,Jn(t._zod.def,{shape:r}))}function pi(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 Rb(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 Xi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Wo(e){return typeof e==="string"?e:e?.message}function Af(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function qi(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,a=e.message?e.message:Wo(e.inst?._zod.def?.error?.(e))??Wo(s?.(e))??Wo(t?.error?.(e))??Wo(n.customError?.(e))??Wo(n.localeError?.(e))??"Invalid input",o={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;o[c]=e[c]}if(o.path??(o.path=[]),o.message=a,t?.reportInput)o.input=e.input;return o}var DR=/[\uD800-\uDBFF]/;function Cl(e){let t=e.length;if(!DR.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 Nl(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ib(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 ta(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Cb(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else LR(e,n,i.value)}}function Sr(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Pl(e,t,n){return Sr(e,t,n,!1)}function Nb(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Sr(this,n,i(this))},set(r){Sr(this,n,r)}})}return t}function LR(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Sr(this,t,n.bind(this))},set(i){Sr(this,t,i)}})}function FR(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var yf,qr=!1,UR={configurable:!0,get(){qr=!0;return}};function vt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&yf!==e._zod){yf=void 0;return}yf=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,UR);let r=qr;qr=!1;try{let s=n(this);if(qr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return qr=qr||r,s}catch(s){throw delete this[t],qr=qr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function BR(e,t,n,i){let r=FR(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 zR="~constantCatch";function Pb(e){let t=()=>e;return t[zR]=!0,t}var Ob;var Sf={value:void 0,enumerable:!1},kb="captureStackTrace"in Error?Error:null;function VR(e){let t=kb;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return kb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function se(e,t,n,i){let r={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=r;let a=n,o=a&&new WeakSet;function c(f,h){if(!f._zod){Sf.value=new s(h);try{Object.defineProperty(f,"_zod",Sf)}finally{Sf.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,h),o){let g=Object.getPrototypeOf(f),m=f._zod.constr.prototype,p=g;while(p&&p!==m)p=Object.getPrototypeOf(p);let b=p??g;if(!o.has(b))o.add(b),Cb(b,a)}let y=d.prototype;for(let g in y){if(!Object.prototype.hasOwnProperty.call(y,g))continue;if(!(g in f))f[g]=y[g].bind(f)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(f){let h=i?.Parent?VR(u):this;c(h,f);let y=h._zod.deferred;if(y){for(let m of y)m();h._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(h);return h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(f)=>{if(i?.Parent&&f instanceof i.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Ji extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Yo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Ob=globalThis).__zod_globalConfig??(Ob.__zod_globalConfig={});var Ln=globalThis.__zod_globalConfig;function Zn(e){if(e)Object.assign(Ln,e);return Ln}function jR(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,qo,2)),e.message}function HR(e){this._zod.message=e}var GR={get:jR,set:HR,enumerable:!0,configurable:!0},Mf={value:void 0,enumerable:!1},Db=new WeakSet([Object.prototype,Error.prototype]),Lb=(e,t)=>{e.name="$ZodError",Mf.value=t,Object.defineProperty(e,"issues",Mf),Mf.value=void 0,Object.defineProperty(e,"message",GR);let n=Object.getPrototypeOf(e);if(!Db.has(n))Db.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})}})},Fb=se("$ZodError",Lb),P9=se("$ZodError",Lb,void 0,{Parent:Error});function $R(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 Ub(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)$R(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Bb(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let a of r.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((o)=>i({issues:o},[...s,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...s,...a.path]);else{let o=[...s,...a.path];if(o.length===0)n._errors.push(t(a));else{let c=n,l=0;while(l<o.length){let u=o[l],d=l===o.length-1;if(u==="_errors"){if(d)c._errors.push(t(a));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[u];if(d)f._errors.push(t(a));c=f,l++}}}};return i(e),n}function Ol(e,t){return{callee:t?.callee??e,Err:t?.Err}}var kl=(e)=>{let t=(n,i,r,s)=>{let a=r?{...r,async:!1}:{async:!1},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)throw new Ji;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>qi(l,a,Zn())));throw _f(c,s?.callee??t),c}return o.value};return t};var Dl=(e)=>{let t=async(n,i,r,s)=>{let a=r?{...r,async:!0}:{async:!0},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)o=await o;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>qi(l,a,Zn())));throw _f(c,s?.callee??t),c}return o.value};return t};var Ll=(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 Ji;return s.issues.length?zb(e,s.issues,r):{success:!0,data:s.value}};function zb(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>qi(r,n,Zn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Fl=(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?zb(e,s.issues,r):{success:!0,data:s.value}};var KR=Symbol.for("zod.compile.invalid"),WR=Symbol.for("zod.compile.fallback"),Rf=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==KR)return!0;if(i.definite===!0&&n===void 0)return!1}return XR(e,t,n)};function XR(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[WR]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Ji;return s.issues.length===0}var If=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},Vb=(e)=>{let t=kl(e),n=(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,o,Ol(n,a))};return n};var jb=(e)=>{let t=kl(e),n=(i,r,s,a)=>t(i,r,s,Ol(n,a));return n};var Hb=(e)=>{let t=Dl(e),n=async(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,o,Ol(n,a))};return n};var Gb=(e)=>{let t=Dl(e),n=async(i,r,s,a)=>await t(i,r,s,Ol(n,a));return n};var $b=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Ll(e)(t,n,r)};var Kb=(e)=>(t,n,i)=>Ll(e)(t,n,i);var Wb=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Fl(e)(t,n,r)};var Xb=(e)=>async(t,n,i)=>Fl(e)(t,n,i);var qb=/^[cC][0-9a-z]{6,}$/,Jb=/^[0-9a-z]+$/,Zb=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Yb=/^[0-9a-vA-V]{20}$/,Qb=/^[A-Za-z0-9]{27}$/,ey=/^[a-zA-Z0-9_-]{21}$/;function ty(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ny=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var iy=/^([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})$/,Nf=(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 ry=/^(?:[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 qR="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function sy(){return new RegExp(qR,"u")}var ay=/^(?:(?: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])$/,oy=/^(([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 cy=/^((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])$/,ly=/^(([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])$/,uy=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dy=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var fy=/^https?$/,hy=/^\+[1-9]\d{6,14}$/;var py="(?:(?:\\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 JR(e){return new RegExp(`^${e}$`)}var my=JR(py);function Cf(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 gy(e){return new RegExp(`^${Cf(e)}$`)}function by(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Cf({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Cf({precision:e.precision})}`:n;return new RegExp(`^${py}T(?:${i})$`)}var yy=/^[\s\S]{0,}$/,xy=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ul=/^-?\d+$/,Fa=/^-?\d+(?:\.\d+)?$/,_y=/^(?:true|false)$/i;var vy=/^[^A-Z]*$/,Ey=/^[^a-z]*$/;var Sn=se("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Pf=(e)=>{let t=e.value;return!gb(t)&&t.length!==void 0},Bl={number:"number",bigint:"bigint",object:"date"},Of=se("$ZodCheckLessThan",(e,t)=>{Sn.init(e,t);let n=Bl[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Bl[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})}}),kf=se("$ZodCheckGreaterThan",(e,t)=>{Sn.init(e,t);let n=Bl[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Bl[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})}}),Ty=se("$ZodCheckMultipleOf",(e,t)=>{Sn.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):bb(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})}}),Ay=se("$ZodCheckNumberFormat",(e,t)=>{Sn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Rl[t.format];e._zod.check=(a)=>{let o=a.value;if(n){if(!Number.isInteger(o)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){if(o>0)a.issues.push({input:o,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 a.issues.push({input:o,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(o<r)a.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(o>s)a.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Sy=se("$ZodCheckMaxLength",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=Pf),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Cl(r):s)<=t.maximum)return;let o=Nl(r);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wy=se("$ZodCheckMinLength",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=Pf),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Cl(r):s)>=t.minimum)return;let o=Nl(r);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),My=se("$ZodCheckLengthEquals",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=Pf),e._zod.check=(i)=>{let r=i.value,s=r.length,a=typeof r==="string"&&s>=t.length&&s<=t.length*2?Cl(r):s;if(a===t.length)return;let o=Nl(r),c=a>t.length;i.issues.push({origin:o,...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})}}),ec=se("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Sn.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=()=>{})}),Ry=se("$ZodCheckRegex",(e,t)=>{ec.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})}}),Iy=se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vy),ec.init(e,t)}),Cy=se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ey),ec.init(e,t)}),Ny=se("$ZodCheckIncludes",(e,t)=>{Sn.init(e,t);let n=wr(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})}}),Py=se("$ZodCheckStartsWith",(e,t)=>{Sn.init(e,t);let n=new RegExp(`^${wr(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})}}),Oy=se("$ZodCheckEndsWith",(e,t)=>{Sn.init(e,t);let n=new RegExp(`.*${wr(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 ky=se("$ZodCheckOverwrite",(e,t)=>{Sn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Df{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 Ly={major:4,minor:6,patch:5};var Ut=se("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ly;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(o,c,l)=>{if(o.memo)return o;let u=pi(o),d;for(let f of c){if(f._zod.def.when){if(Rb(o))continue;if(!f._zod.def.when(o))continue}else if(u)continue;let h=o.issues.length,y=f._zod.check(o);if(y instanceof Promise&&l?.async===!1)throw new Ji;if(d||y instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await y,o.issues.length===h)return;if(Af(o.issues,h,e),!u)u=pi(o,h)});else{if(o.issues.length===h)continue;if(Af(o.issues,h,e),!u)u=pi(o,h)}}if(d)return d.then(()=>o);return o},a=(o,c,l)=>{if(pi(o))return o.aborted=!0,o;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Ji;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>a(d,o,c));return a(u,o,c)}let l=e._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new Ji;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Pl(this,"~standard",Uf(this))},set "~standard"(e){Sr(this,"~standard",e)}}),Jy=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>qi(n,t,Zn()))}:{value:e.value};async function ZR(e,t){let n={async:!0};return Jy(await e._zod.run({value:t,issues:[]},n),n)}function Uf(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return Jy(i,n)}catch(i){}return ZR(e,t)},vendor:"zod",version:1}}var Hl=se("$ZodString",(e,t)=>{Ut.init(e,t),e._zod.pattern=t.pattern??yy,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}}),Gt=se("$ZodStringFormat",(e,t)=>{ec.init(e,t),Hl.init(e,t)}),Zy=se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=iy),Gt.init(e,t)}),Yy=se("$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=Nf(i))}else t.pattern??(t.pattern=Nf());Gt.init(e,t)}),Qy=se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ry),Gt.init(e,t)}),ex=1,Vl=2;function tx(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function YR(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return tx(e)||Vl;return QR(e,t)}function QR(e,t){if(!t.normalize&&t.protocol?.source===fy.source&&!/^https?:\/\//i.test(e))return ex;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Vl}return new URL(e)}catch{return Vl}}var eI=/[\t\n\r]/g;function Fy(e){return e.replace(eI,"")}function tI(e,t){return t.lastIndex=0,t.test(e.hostname)}function nI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var nx=se("$ZodURL",(e,t)=>{Gt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=YR(i,t);if(r===ex){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Vl){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Fy(i);return}if(t.hostname&&!tI(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&&!nI(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:Fy(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ix=se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sy()),Gt.init(e,t)}),rx=se("$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?ey:ty(t.length)),Gt.init(e,t)}),sx=se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qb),Gt.init(e,t)}),ax=se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jb),Gt.init(e,t)}),ox=se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Zb),Gt.init(e,t)}),cx=se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yb),Gt.init(e,t)}),lx=se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qb),Gt.init(e,t)}),ux=se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=by(t)),Gt.init(e,t)}),dx=se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=my),Gt.init(e,t)}),fx=se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=gy(t)),Gt.init(e,t)}),hx=se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ny),Gt.init(e,t)}),px=se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ay),Gt.init(e,t)}),iI=/^[0-9a-fA-F:.]+$/;function mx(e){if(!iI.test(e))return!1;return tx(`http://[${e}]`)}var gx=se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=oy),Gt.init(e,t),e._zod.check=(n)=>{if(!mx(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var bx=se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cy),Gt.init(e,t)});function rI(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 mx(n)}var yx=se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ly),Gt.init(e,t),e._zod.check=(n)=>{if(!rI(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function xx(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 Bf=/^[0-9a-zA-Z+/]*={0,2}$/,_x=se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Bf),Gt.init(e,t),e._zod.check=(n)=>{if(xx(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Gl=/^[A-Za-z0-9_-]*$/;function sI(e){if(!Gl.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return xx(n)}var vx=se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Gl),Gt.init(e,t),e._zod.check=(n)=>{if(sI(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ex=se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hy),Gt.init(e,t)});function aI(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 Tx=se("$ZodJWT",(e,t)=>{Gt.init(e,t),e._zod.check=(n)=>{if(aI(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var zf=se("$ZodNumber",(e,t)=>{Ut.init(e,t),e._zod.pattern=Fa,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}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}}),Ax=se("$ZodNumberFormat",(e,t)=>{Ay.init(e,t),zf.init(e,t)}),Sx=se("$ZodBoolean",(e,t)=>{Ut.init(e,t),e._zod.pattern=_y,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 wx=se("$ZodUnknown",(e,t)=>{Ut.init(e,t),e._zod.parse=(n)=>n}),Mx=se("$ZodNever",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Uy(e,t,n){if(e.issues.length)t.issues.push(...Xi(n,e.issues));t.value[n]=e.value}var Rx=se("$ZodArray",(e,t)=>{Ut.init(e,t);let n=Ln.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 a=[],o=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)a.push(u.then((d)=>Uy(d,i,c)));else if(Uy(u,i,c),o&&u.issues.length!==0&&pi(u))break}if(a.length)return Promise.all(a).then(()=>i);return i}});function jl(e,t,n,i,r,s){let a=n in i,o=s==="optional";if(!a&&o&&r==="optional")return;if(e.issues.length){if(r!==void 0&&o&&!a)return;t.issues.push(...Xi(n,e.issues))}if(!a&&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(a||r==="defaulted"&&!o)t.value[n]=void 0}else t.value[n]=e.value}var oI=[];function Ix(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:oI,r=i.length?[...t,...i]:t;for(let a of r)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let s=Sb(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Cx(e,t,n,i,r,s,a){let o=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:f}=l,h=0;for(let y in t){if(a&&n.issues.length!==h){if(pi(n,h))break;h=n.issues.length}if(c.has(y))continue;if(y==="__proto__"){if(u==="never")o.push(y);continue}if(u==="never"){o.push(y);continue}let g=l.run({value:t[y],issues:[]},i);if(g instanceof Promise)e.push(g.then((m)=>jl(m,n,y,t,d,f)));else jl(g,n,y,t,d,f)}if(o.length)n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var cI=se("$ZodObject",(e,t)=>{Ut.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=Jo(()=>Ix(t));vt(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let f in u){let h=u[f]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(d,f))hi(d,f,new Set);for(let y of h.values)d[f].add(y);if(h.optin!==void 0)d[f].add(void 0)}}return d});let s=La,a=t.catchall,o,c=Ln.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{o??(o=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let f=[],h=o.shape,y=u?.abortEarly,g=l.issues.length;for(let m of o.allKeys){if(y&&l.issues.length!==g){if(pi(l,g))break;g=l.issues.length}if(m==="__proto__")continue;let p=h[m],b=p._zod.optin,_=p._zod.optout,x=p._zod.run({value:d[m],issues:[]},u);if(x instanceof Promise)f.push(x.then((v)=>jl(v,l,m,d,b,_)));else jl(x,l,m,d,b,_)}if(!a)return f.length?Promise.all(f).then(()=>l):l;return Cx(f,d,l,u,r.value,e,y===!0)}}),Nx=se("$ZodObjectJIT",(e,t)=>{cI.init(e,t);let n=e._zod.parse,i=Jo(()=>Ix(t)),r=Ln.memoizer,s=(h)=>{let y=i.value,g=y.symbolKeys,m=new Df(["payload","ctx"],{shape:h,inst:e,memo:r,syms:g}),p=(v)=>`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`,b=(v,E)=>`
+ let ${v}_ab = false;
+ for (let i = 0; i < ${v}.issues.length; i++) {
+ const iss = ${v}.issues[i];
+ iss.path = iss.path ? [${E}, ...iss.path] : [${E}];
+ payload.issues.push(iss);
+ if (iss.continue !== true) ${v}_ab = true;
+ }
+ if (${v}_ab && ctx && ctx.abortEarly) {
+ payload.value = newResult;
+ return payload;
+ }`;m.write("const input = payload.value;");let _=Object.create(null),x=0;for(let v of y.allKeys)_[v]=`key_${x++}`;m.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let v of y.allKeys){if(v==="__proto__")continue;let E=_[v],S=typeof v==="symbol"?`syms[${g.indexOf(v)}]`:_b(v),T=`${S} in input`,A=h[v],P=A?._zod?.optin,w=P!==void 0,I=A?._zod?.optout==="optional";if(m.write(`const ${E} = ${p(S)};`),w&&I){let F=P==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;m.write(`
+ const ${E}_present = ${T};
+ if (!${E}.issues.length || ${E}_present) {
+ if (${E}.issues.length) {${b(E,S)}
+ }
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
+ if (${F}) {
+ newResult[${S}] = ${E}.value;
+ }
+ }
- } else {
+ `)}else if(!w)m.write(`
+ const ${E}_present = ${T};
+ if (${E}.issues.length) {${b(E,S)}
+ }
+ if (!${E}_present && !${E}.issues.length) {
+ payload.issues.push({
+ code: "invalid_type",
+ expected: "nonoptional",
+ input: undefined,
+ path: [${S}]
+ });
+ if (ctx && ctx.abortEarly) {
+ payload.value = newResult;
+ return payload;
+ }
+ }
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
+ if (${E}_present) {
+ newResult[${S}] = ${E}.value;
+ }
- }
+ `);else if(m.write(`
+ if (${E}.issues.length) {${b(E,S)}
+ }
+ `),P==="defaulted")m.write(`newResult[${S}] = ${E}.value;`);else m.write(`
+ if (${E}.value !== undefined || ${T}) {
+ newResult[${S}] = ${E}.value;
+ }
+ `)}return m.write("payload.value = newResult;"),m.write("return payload;"),m.compile()},a,o=La,c=!Ln.jitless,u=c&&Eb.value,d=t.catchall,f;e._zod.parse=(h,y)=>{f??(f=i.value);let g=h.value;if(!o(g))return h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h;if(c&&u&&y?.async===!1&&y.jitless!==!0){if(!a)a=s(t.shape);if(h=a(h,y),!d)return h;return Cx([],g,h,y,f,e,y?.abortEarly===!0)}return n(h,y)}});function By(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)=>!pi(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((a)=>qi(a,i,Zn())))}),t}var Vf=se("$ZodUnion",(e,t)=>{Ut.init(e,t),vt(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),vt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),vt(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}),vt(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)=>Jr(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,a=[];for(let o of t.options){let c=o._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}if(!s)return By(a,i,e,r);return Promise.all(a).then((o)=>By(o,i,e,r))}});function lI(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 Px=se("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Vf.init(e,t);let n=e._zod.parse;vt(e,"propValues",(r)=>{let s={},a=0;for(let o of r.def.options){let c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(o)}"`);if(c[r.def.discriminator]?.has(void 0))a++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))hi(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&a>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let a=Zo(r._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Jo(()=>lI(t));e._zod.parse=(r,s)=>{let a=r.value;if(!La(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let o=a?.[t.discriminator],c=i.value.get(o);if(c&&(o!==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:a,path:[t.discriminator],inst:e}),r}}),Ox=se("$ZodIntersection",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),a=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||a instanceof Promise)return Promise.all([s,a]).then(([c,l])=>zy(n,c,l));return zy(n,s,a)}});function Lf(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(ea(e)&&ea(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 a=Lf(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};r[s]=a.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],a=Lf(r,s);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function zy(e,t,n){let i=new Map,r,s=new Map,a=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);if(!s.has(f))s.set(f,l);d=[f]}else return!1;for(let f of d){if(!i.has(f))i.set(f,{});i.get(f)[u]=!0}return!0};for(let l of t.issues)if(!a(l,"l"))e.issues.push(l);for(let l of n.issues)if(!a(l,"r"))e.issues.push(l);let o=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length){let l=r?o.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of o)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Lf(t.value,n.value);if(!c.valid){if(pi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var kx=se("$ZodTuple",(e,t)=>{Ut.init(e,t);let n=t.items,i=Ln.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let o=[],c=Vy(n,"optin"),l=Vy(n,"optout");if(!t.rest){if(a.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:a,inst:e,origin:"array"}),r;if(a.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,f=!1;for(let h=0;h<n.length;h++){let y=n[h]._zod.run({value:a[h],issues:[]},s);if(y instanceof Promise)o.push(y.then((g)=>{u[h]=g}));else if(u[h]=y,d&&!f&&y.issues.length)f=pi(y)}if(t.rest&&!f){let h=n.length-1,y=a.slice(n.length),g=r.issues.length;for(let m of y){if(d&&r.issues.length!==g){if(pi(r,g))break;g=r.issues.length}h++;let p=t.rest._zod.run({value:m,issues:[]},s);if(p instanceof Promise)o.push(p.then((b)=>jy(b,r,h)));else jy(p,r,h)}}if(o.length)return Promise.all(o).then(()=>Hy(u,r,n,a,l));return Hy(u,r,n,a,l)}});function Vy(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function jy(e,t,n){if(e.issues.length)t.issues.push(...Xi(n,e.issues));t.value[n]=e.value}function Hy(e,t,n,i,r){for(let s=0;s<n.length;s++){let a=e[s],o=s<i.length;if(!o&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!o&&s>=r){t.value.length=s;break}t.issues.push(...Xi(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Dx=se("$ZodRecord",(e,t)=>{Ut.init(e,t);let n=Ln.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!ea(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let a=[],o=t.keyType._zod.values;if(o&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of o)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((y)=>qi(y,r,Zn())),input:u,path:[u],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},r);if(h instanceof Promise)a.push(h.then((y)=>{if(y.issues.length)i.issues.push(...Xi(u,y.issues));i.value[f]=y.value}));else{if(h.issues.length)i.issues.push(...Xi(u,h.issues));i.value[f]=h.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"&&Fa.test(l)&&u.issues.length){let y=t.keyType._zod.run({value:Number(l),issues:[]},r);if(y instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(y.issues.length===0)u=y}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(o)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((y)=>qi(y,r,Zn())),input:l,path:[l],inst:e});continue}let f=u.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[l],issues:[]},r);if(h instanceof Promise)a.push(h.then((y)=>{if(y.issues.length)i.issues.push(...Xi(l,y.issues));i.value[f]=y.value}));else{if(h.issues.length)i.issues.push(...Xi(l,h.issues));i.value[f]=h.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(a.length)return Promise.all(a).then(()=>i);return i}});var Lx=se("$ZodEnum",(e,t)=>{Ut.init(e,t);let n=Xo(t.entries),i=new Set(n);e._zod.values=i,vt(e,"pattern",(r)=>{let s=Xo(r.def.entries).filter((a)=>Tb.has(typeof a));return new RegExp(s.length?`^(${s.map((a)=>wr(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let a=r.value;if(i.has(a))return r;return r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),Fx=se("$ZodLiteral",(e,t)=>{Ut.init(e,t);let n=new Set(t.values);e._zod.values=n,vt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?wr(s):s?wr(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 Ux=se("$ZodTransform",(e,t)=>{Ut.init(e,t),e._zod.optin="optional",Ln.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Yo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((a)=>(n.value=a,n));if(r instanceof Promise)throw new Ji;return n.value=r,n}});function Gy(e,t){return e.value=t.issues.length?void 0:t.value,e}var jf=se("$ZodOptional",(e,t)=>{Ut.init(e,t),vt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",vt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),vt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Jr(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)=>Gy(n,s));return Gy(n,r)}return t.innerType._zod.run(n,i)}}),Bx=se("$ZodExactOptional",(e,t)=>{jf.init(e,t),vt(e,"values",(n)=>n.def.innerType._zod.values),vt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),zx=se("$ZodNullable",(e,t)=>{Ut.init(e,t),vt(e,"optin",(n)=>n.def.innerType._zod.optin),vt(e,"optout",(n)=>n.def.innerType._zod.optout),vt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Jr(i.source)}|null)$`):void 0}),vt(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)}}),Vx=se("$ZodDefault",(e,t)=>{Ut.init(e,t),e._zod.optin="defaulted",vt(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)=>$y(s,t));return $y(r,t)}});function $y(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var jx=se("$ZodPrefault",(e,t)=>{Ut.init(e,t),e._zod.optin="defaulted",vt(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)}}),Hx=se("$ZodNonOptional",(e,t)=>{Ut.init(e,t),vt(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)=>Ky(s,e));return Ky(r,e)}});function Ky(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 Wy(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)=>qi(r,i,Zn()))},input:e.value}),e}var Gx=se("$ZodCatch",(e,t)=>{Ut.init(e,t),vt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),vt(e,"optout",(n)=>n.def.innerType._zod.optout),vt(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)=>Wy(n,s,t,i));return Wy(n,r,t,i)}});var $x=se("$ZodPipe",(e,t)=>{Ut.init(e,t),vt(e,"values",(n)=>n.def.in._zod.values),vt(e,"optin",(n)=>n.def.in._zod.optin),vt(e,"optout",(n)=>n.def.out._zod.optout),vt(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((a)=>zl(a,t.in,i));return zl(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>zl(s,t.out,i));return zl(r,t.out,i)}});function zl(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 Kx=se("$ZodReadonly",(e,t)=>{Ut.init(e,t),vt(e,"propValues",(n)=>n.def.innerType._zod.propValues),vt(e,"values",(n)=>n.def.innerType._zod.values),vt(e,"optin",(n)=>n.def.innerType?._zod?.optin),vt(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(Xy);return Xy(r)}});function Xy(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function uI(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let o of t.checks??[]){let c=o._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return xy({minimum:r,maximum:s}).source;let a=e._zod.pattern;return(i&&a===Fa?Ul:a)?.source}function Ff(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=Ff(i);if(n&&r&&s&&s!==r)return n.replace(Jr(r),()=>Jr(s));return n}if(t.options){let r=t.options.map(Ff);if(r.every(Boolean))return`^(${r.map((s)=>Jr(s)).join("|")})$`}return uI(e)}var Wx=se("$ZodTemplateLiteral",(e,t)=>{Ut.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=Ff(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Jr(r))}else if(i===null||Ab.has(typeof i))n.push(wr(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var Xx=se("$ZodCustom",(e,t)=>{Sn.init(e,t),Ut.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)=>qy(s,n,i,e));qy(r,n,i,e);return}});function qy(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(ta(r))}}class Jx extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Gf="~memo",qx=[];function Zx(e){return e!==null&&typeof e==="object"}function Hf(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Yx=new WeakMap,tc=0,Wl=1,nc=2;function Xl(e,t,n){let i=Yx.get(e);if(i!==void 0)return i?nc:tc;if(t.has(e))return nc;t.add(e);let r=tc,s=(u)=>{if(r!==nc&&u?._zod){let d=Xl(u,t,n);if(d>r)r=d}},a=(u,d)=>{let f=tc;for(let h of Reflect.ownKeys(u)){let y=Object.getOwnPropertyDescriptor(u,h);if(d&&!y.enumerable)continue;let g=y.get?Wl:y.value?._zod?Xl(y.value,t,n):tc;if(g>f)f=g}return f},o=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Zo(c);o(u?a(u,!0):Wl),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);o(u?Xl(u,t,!1):Wl);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 d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let f=d.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let h of f)s(h)}}return t.delete(e),dI(e,r)}function dI(e,t){if(t!==Wl)Yx.set(e,t===nc);return t}function fI(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var $l,Kl=[],hI={alloc(e,t,n){let i=$l;if(!i)return n;$l=void 0;let r={value:n,issues:null};return i.set(t.value,r),Kl.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"&&pI(s,r.value))throw new Jx;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 a=e._zod.parse,o=(c,l)=>{if(n===void 0){let p=Xl(e,new Set,!1);if(p===tc){if(e._zod.parse=a,e._zod.run===o)e._zod.run=a;return a(c,l)}if(p===nc||i)n=!0;else i=!0}let u=c.value;if(!Zx(u))return a(c,l);let d=l[Gf];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[Gf]=d;let f;if(r===l)f=s;else f=fI(d,e),r=l,s=f;let h=f.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Hf(h.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value);return c}$l=f;let y=Kl.length,g=a(c,l);$l=void 0;let m=Kl.length>y?Kl.pop():void 0;if(g instanceof Promise)return g.then((p)=>{if(m)m.issues=p.issues.length?Hf(p.issues):qx;return p});if(m)m.issues=g.issues.length?Hf(g.issues):qx;return g};if(e._zod.parse=o,e._zod.run===a)e._zod.run=o})}};function Qx(){return hI}function pI(e,t){let n=e[Gf]?.backEdges;return n!==void 0&&Zx(t)&&n.has(t)}var mI=()=>{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,a){if(s==="number"&&typeof a==="number"&&!Number.isFinite(a))return String(a);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let a=r(s.expected),o=Ib(s.input),c=r(o,s.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Ef(s.values[0])}`;return`Invalid option: expected one of ${xf(s.values,"|")}`;case"too_big":{let a=s.exact?"exactly ":s.inclusive?"<=":"<",o=t(s.origin);if(o)return`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{let a=s.exact?"exactly ":s.inclusive?">=":">",o=t(s.origin);if(o)return`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${o.unit}`;return`Too small: expected ${s.origin} to be ${a}${s.minimum.toString()}`}case"invalid_format":{let a=s;if(a.format==="starts_with")return`Invalid string: must start with "${a.prefix}"`;if(a.format==="ends_with")return`Invalid string: must end with "${a.suffix}"`;if(a.format==="includes")return`Invalid string: must include "${a.includes}"`;if(a.format==="regex")return`Invalid string: must match pattern ${a.pattern}`;return`Invalid ${n[a.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":""}: ${xf(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((o)=>`'${o}'`).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 $f(){return{localeError:mI()}}var e_;class t_{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 gI(){return new t_}(e_=globalThis).__zod_globalRegistry??(e_.__zod_globalRegistry=gI());var na=globalThis.__zod_globalRegistry;function n_(e){if(e.checks)e.checks=[...e.checks];return e}function i_(e,t){return new e(n_({type:"string",...Fe(t)}))}function r_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Fe(t)})}function s_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Fe(t)})}function a_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Fe(t)})}function o_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Fe(t)})}function c_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Fe(t)})}function l_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Fe(t)})}function u_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Fe(t)})}function d_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Fe(t)})}function f_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Fe(t)})}function h_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Fe(t)})}function p_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Fe(t)})}function m_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Fe(t)})}function g_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Fe(t)})}function b_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Fe(t)})}function y_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Fe(t)})}function x_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Fe(t)})}function __(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Fe(t)})}function v_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Fe(t)})}function E_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Fe(t)})}function T_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Fe(t)})}function A_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Fe(t)})}function S_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Fe(t)})}function w_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Fe(t)})}function M_(e,t){return new e({type:"string",format:"date",check:"string_format",...Fe(t)})}function R_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Fe(t)})}function I_(e,t){return new e({type:"string",format:"duration",check:"string_format",...Fe(t)})}function C_(e,t){return new e(n_({type:"number",checks:[],...Fe(t)}))}function N_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Fe(t)})}function P_(e,t){return new e({type:"boolean",...Fe(t)})}function O_(e){return new e({type:"unknown"})}function k_(e,t){return new e({type:"never",...Fe(t)})}function ql(e,t){return new Of({check:"less_than",...Fe(t),value:e,inclusive:!1})}function ic(e,t){return new Of({check:"less_than",...Fe(t),value:e,inclusive:!0})}function Jl(e,t){return new kf({check:"greater_than",...Fe(t),value:e,inclusive:!1})}function rc(e,t){return new kf({check:"greater_than",...Fe(t),value:e,inclusive:!0})}function Zl(e,t){return new Ty({check:"multiple_of",...Fe(t),value:e})}function Yl(e,t){return new Sy({check:"max_length",...Fe(t),maximum:e})}function Ua(e,t){return new wy({check:"min_length",...Fe(t),minimum:e})}function Ql(e,t){return new My({check:"length_equals",...Fe(t),length:e})}function Kf(e,t){return new Ry({check:"string_format",format:"regex",...Fe(t),pattern:e})}function Wf(e){return new Iy({check:"string_format",format:"lowercase",...Fe(e)})}function Xf(e){return new Cy({check:"string_format",format:"uppercase",...Fe(e)})}function qf(e,t){return new Ny({check:"string_format",format:"includes",...Fe(t),includes:e})}function Jf(e,t){return new Py({check:"string_format",format:"starts_with",...Fe(t),prefix:e})}function Zf(e,t){return new Oy({check:"string_format",format:"ends_with",...Fe(t),suffix:e})}function Zr(e){return new ky({check:"overwrite",tx:e})}function Yf(e){return Zr((t)=>t.normalize(e))}function Qf(){return Zr((e)=>e.trim())}function eh(){return Zr((e)=>e.toLowerCase())}function th(){return Zr((e)=>e.toUpperCase())}function nh(){return Zr((e)=>vb(e))}function D_(e,t,n){return new e({type:"array",element:t,...Fe(n)})}function L_(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Fe(n)})}function F_(e,t){let n=bI((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(ta(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(ta(s))}},e(i.value,i)),t);return n}function bI(e,t){let n=new Sn({check:"custom",...Fe(t)});return n._zod.check=e,n}function sc(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))hi(e,i,n[i]);return e}function rh(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??na,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 Mr(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 Xt(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 a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let f=a.schema,h=t.processors[r.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,f,u)}let d=e._zod.parent;if(d){if(!a.ref)a.ref=d;Xt(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)sc(a.schema,c);if(t.io==="input"&&Fn(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&"_prefault"in a.schema)(i=a.schema).default??(i.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function U_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function sh(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 a of e.seen.entries()){let o=e.metadataRegistry.get(a[0])?.id;if(o){let c=i.get(o);if(c&&c!==a[0])throw Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(o,a[0])}}let r=(a)=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??((y)=>y);if(d)return{ref:f(d)};let h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${f("__shared")}#/${o}/${U_(h)}`}}let c="#",l=`${c}/${o}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+U_(u)}},s=(a)=>{if(a[1].schema.$ref)return;let o=a[1],{ref:c,defId:l}=r(a);if(o.def={...o.schema},l)o.defId=l;let u=o.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let o=a[1];if(o.cycle)throw Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
-}`;class bb{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Gl(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 Jn({vertexShader:HI,fragmentShader:GI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Pt(new Oa(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Sb extends fi{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 bb,p={},g=t.getContextAttributes(),y=null,S=null,x=[],b=[],M=new Ge,T=null,v=null,A=new qt;A.viewport=new yt;let V=new qt;V.viewport=new yt;let C=[A,V],N=new Mf,Y=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let L=x[X];if(L===void 0)L=new Ta,x[X]=L;return L.getTargetRaySpace()},this.getControllerGrip=function(X){let L=x[X];if(L===void 0)L=new Ta,x[X]=L;return L.getGripSpace()},this.getHand=function(X){let L=x[X];if(L===void 0)L=new Ta,x[X]=L;return L.getHandSpace()};function W(X){let L=b.indexOf(X.inputSource);if(L===-1)return;let G=x[L];if(G!==void 0)G.update(X.inputSource,X.frame,c||s),G.dispatchEvent({type:X.type,data:X.inputSource})}function z(){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",z),i.removeEventListener("inputsourceschange",P);for(let X=0;X<x.length;X++){let L=b[X];if(L===null)continue;b[X]=null,x[X].disconnect(L)}Y=null,D=null,_.reset();for(let X in p)delete p[X];if(e.setRenderTarget(y),d=null,h=null,u=null,i=null,S=null,me.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(M.width,M.height,!1),v!==null){let X=v.camera;X.fov=v.fov,X.zoom=v.zoom,X.updateProjectionMatrix(),v=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){if(r=X,n.isPresenting===!0)ze("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){if(o=X,n.isPresenting===!0)ze("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(X){c=X},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(X){if(i=X,i!==null){if(y=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",z),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(T=e.getPixelRatio(),e.getSize(M),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let G={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,G),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),S=new kn(d.framebufferWidth,d.framebufferHeight,{format:ki,type:di,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let G=null,te=null,se=null;if(g.depth)se=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,G=g.stencil?hs:us,te=g.stencil?ao:Ir;let ce={colorFormat:t.RGBA8,depthFormat:se,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(ce),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),S=new kn(h.textureWidth,h.textureHeight,{format:ki,type:di,depthTexture:new ps(h.textureWidth,h.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,G),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})}S.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 _.getDepthTexture()};function P(X){for(let L=0;L<X.removed.length;L++){let G=X.removed[L],te=b.indexOf(G);if(te>=0)b[te]=null,x[te].disconnect(G)}for(let L=0;L<X.added.length;L++){let G=X.added[L],te=b.indexOf(G);if(te===-1){for(let ce=0;ce<x.length;ce++)if(ce>=b.length){b.push(G),te=ce;break}else if(b[ce]===null){b[ce]=G,te=ce;break}if(te===-1)break}let se=x[te];if(se)se.connect(G)}}let q=new F,H=new F;function ee(X,L,G){q.setFromMatrixPosition(L.matrixWorld),H.setFromMatrixPosition(G.matrixWorld);let te=q.distanceTo(H),se=L.projectionMatrix.elements,ce=G.projectionMatrix.elements,Ae=se[14]/(se[10]-1),Te=se[14]/(se[10]+1),Ue=(se[9]+1)/se[5],$e=(se[9]-1)/se[5],Xe=(se[8]-1)/se[0],Ot=(ce[8]+1)/ce[0],rt=Ae*Xe,Mt=Ae*Ot,Bt=te/(-Xe+Ot),Ht=Bt*-Xe;if(L.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Ht),X.translateZ(Bt),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),se[10]===-1)X.projectionMatrix.copy(L.projectionMatrix),X.projectionMatrixInverse.copy(L.projectionMatrixInverse);else{let O=Ae+Bt,en=Te+Bt,gt=rt-Ht,Ut=Mt+(te-Ht),R=Ue*Te/en*O,w=$e*Te/en*O;X.projectionMatrix.makePerspective(gt,Ut,R,w,O,en),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function J(X,L){if(L===null)X.matrixWorld.copy(X.matrix);else X.matrixWorld.multiplyMatrices(L.matrixWorld,X.matrix);X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let{near:L,far:G}=X;if(_.texture!==null){if(_.depthNear>0)L=_.depthNear;if(_.depthFar>0)G=_.depthFar}if(N.near=V.near=A.near=L,N.far=V.far=A.far=G,Y!==N.near||D!==N.far)i.updateRenderState({depthNear:N.near,depthFar:N.far}),Y=N.near,D=N.far;N.layers.mask=X.layers.mask|6,A.layers.mask=N.layers.mask&-5,V.layers.mask=N.layers.mask&-3;let te=X.parent,se=N.cameras;J(N,te);for(let ce=0;ce<se.length;ce++)J(se[ce],te);if(se.length===2)ee(N,A,V);else N.projectionMatrix.copy(A.projectionMatrix);if(v===null&&X.isPerspectiveCamera)v={camera:X,fov:X.fov,zoom:X.zoom};de(X,N,te)};function de(X,L,G){if(G===null)X.matrix.copy(L.matrixWorld);else X.matrix.copy(G.matrixWorld),X.matrix.invert(),X.matrix.multiply(L.matrixWorld);if(X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(L.projectionMatrix),X.projectionMatrixInverse.copy(L.projectionMatrixInverse),X.isPerspectiveCamera)X.fov=as*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1}this.getCamera=function(){return N},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(X){if(a=X,h!==null)h.fixedFoveation=X;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=X},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(N)},this.getCameraTexture=function(X){return p[X]};let pe=null;function Be(X,L){if(l=L.getViewerPose(c||s),f=L,l!==null){let G=l.views;if(d!==null)e.setRenderTargetFramebuffer(S,d.framebuffer),e.setRenderTarget(S);let te=!1;if(G.length!==N.cameras.length)N.cameras.length=0,te=!0;for(let Te=0;Te<G.length;Te++){let Ue=G[Te],$e=null;if(d!==null)$e=d.getViewport(Ue);else{let Ot=u.getViewSubImage(h,Ue);if($e=Ot.viewport,Te===0)e.setRenderTargetTextures(S,Ot.colorTexture,Ot.depthStencilTexture),e.setRenderTarget(S)}let Xe=C[Te];if(Xe===void 0)Xe=new qt,Xe.layers.enable(Te),Xe.viewport=new yt,C[Te]=Xe;if(Xe.matrix.fromArray(Ue.transform.matrix),Xe.matrix.decompose(Xe.position,Xe.quaternion,Xe.scale),Xe.projectionMatrix.fromArray(Ue.projectionMatrix),Xe.projectionMatrixInverse.copy(Xe.projectionMatrix).invert(),Xe.viewport.set($e.x,$e.y,$e.width,$e.height),Te===0)N.matrix.copy(Xe.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);if(te===!0)N.cameras.push(Xe)}let se=i.enabledFeatures;if(se&&se.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Te=u.getDepthInformation(G[0]);if(Te&&Te.isValid&&Te.texture)_.init(Te,i.renderState)}if(se&&se.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Te=0;Te<G.length;Te++){let Ue=G[Te].camera;if(Ue){let $e=p[Ue];if(!$e)$e=new Gl,p[Ue]=$e;let Xe=u.getCameraImage(Ue);$e.sourceTexture=Xe}}}}for(let G=0;G<x.length;G++){let te=b[G],se=x[G];if(te!==null&&se!==void 0)se.update(te,L,c||s)}if(pe)pe(X,L);if(L.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:L});f=null}let me=new ub;me.setAnimationLoop(Be),this.setAnimationLoop=function(X){pe=X},this.dispose=function(){}}}var $I=new Ke,wb=new Ye;wb.set(-1,0,0,0,1,0,0,0,1);function WI(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,pf(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,y,S,x){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,x)}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,y,S);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===mn)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===mn)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 y=t.get(g),{envMap:S,envMapRotation:x}=y;if(S){if(p.envMap.value=S,p.envMapRotation.value.setFromMatrix4($I.makeRotationFromEuler(x)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(wb);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,y,S){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=S*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,y){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===mn)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=y.texture,p.transmissionSamplerSize.value.set(y.width,y.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 y=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ZI(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,b){let M=b.program;i.uniformBlockBinding(x,M)}function l(x,b){let M=r[x.id];if(M===void 0)p(x),M=u(x),r[x.id]=M,x.addEventListener("dispose",y);let T=b.program;i.updateUBOMapping(x,T);let v=t.render.frame;if(s[x.id]!==v)d(x),s[x.id]=v}function u(x){let b=h();x.__bindingPointIndex=b;let M=e.createBuffer(),{__size:T,usage:v}=x;return e.bindBuffer(e.UNIFORM_BUFFER,M),e.bufferData(e.UNIFORM_BUFFER,T,v),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,M),M}function h(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return je("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let b=r[x.id],{uniforms:M,__cache:T}=x;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let v=0,A=M.length;v<A;v++){let V=M[v];if(Array.isArray(V))for(let C=0,N=V.length;C<N;C++)f(V[C],v,C,T);else f(V,v,0,T)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(x,b,M,T){if(_(x,b,M,T)===!0){let{__offset:v,value:A}=x;if(Array.isArray(A)){let V=0;for(let C=0;C<A.length;C++){let N=A[C],Y=g(N);if(m(N,x.__data,V),typeof N!=="number"&&typeof N!=="boolean"&&!N.isMatrix3&&!ArrayBuffer.isView(N))V+=Y.storage/Float32Array.BYTES_PER_ELEMENT}}else m(A,x.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,v,x.__data)}}function m(x,b,M){if(typeof x==="number"||typeof x==="boolean")b[0]=x;else if(x.isMatrix3)b[0]=x.elements[0],b[1]=x.elements[1],b[2]=x.elements[2],b[3]=0,b[4]=x.elements[3],b[5]=x.elements[4],b[6]=x.elements[5],b[7]=0,b[8]=x.elements[6],b[9]=x.elements[7],b[10]=x.elements[8],b[11]=0;else if(ArrayBuffer.isView(x))b.set(new x.constructor(x.buffer,x.byteOffset,b.length));else x.toArray(b,M)}function _(x,b,M,T){let v=x.value,A=b+"_"+M;if(T[A]===void 0){if(typeof v==="number"||typeof v==="boolean")T[A]=v;else if(ArrayBuffer.isView(v))T[A]=v.slice();else T[A]=v.clone();return!0}else{let V=T[A];if(typeof v==="number"||typeof v==="boolean"){if(V!==v)return T[A]=v,!0}else if(ArrayBuffer.isView(v))return!0;else if(V.equals(v)===!1)return V.copy(v),!0}return!1}function p(x){let b=x.uniforms,M=0,T=16;for(let A=0,V=b.length;A<V;A++){let C=Array.isArray(b[A])?b[A]:[b[A]];for(let N=0,Y=C.length;N<Y;N++){let D=C[N],W=Array.isArray(D.value)?D.value:[D.value];for(let z=0,P=W.length;z<P;z++){let q=W[z],H=g(q),ee=M%T,J=ee%H.boundary,de=ee+J;if(M+=J,de!==0&&T-de<H.storage)M+=T-de;D.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),D.__offset=M,M+=H.storage}}}let v=M%T;if(v>0)M+=T-v;return x.__size=M,x.__cache={},this}function g(x){let b={boundary:0,storage:0};if(typeof x==="number"||typeof x==="boolean")b.boundary=4,b.storage=4;else if(x.isVector2)b.boundary=8,b.storage=8;else if(x.isVector3||x.isColor)b.boundary=16,b.storage=12;else if(x.isVector4)b.boundary=16,b.storage=16;else if(x.isMatrix3)b.boundary=48,b.storage=48;else if(x.isMatrix4)b.boundary=64,b.storage=64;else if(x.isTexture)ze("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(x))b.boundary=16,b.storage=x.byteLength;else ze("WebGLRenderer: Unsupported uniform value type.",x);return b}function y(x){let b=x.target;b.removeEventListener("dispose",y);let M=o.indexOf(b.__bindingPointIndex);o.splice(M,1),e.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function S(){for(let x in r)e.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:c,update:l,dispose:S}}var jI=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]),zi=null;function XI(){if(zi===null)zi=new Ia(jI,16,16,ds,Ui),zi.name="DFG_LUT",zi.minFilter=sn,zi.magFilter=sn,zi.wrapS=so,zi.wrapT=so,zi.generateMipmaps=!1,zi.needsUpdate=!0;return zi}class Bf{constructor(e={}){let{canvas:t=Iy(),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=di}=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([Ed,Md,wd]),p=new Set([di,Ir,wa,ao,bd,Sd]),g=new Uint32Array(4),y=new Int32Array(4),S=new F,x=null,b=null,M=[],T=[],v=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=ui,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let A=this,V=!1,C=null,N=null,Y=null,D=null;this._outputColorSpace=Pr;let W=0,z=0,P=null,q=-1,H=null,ee=new yt,J=new yt,de=null,pe=new Ze(0),Be=0,{width:me,height:X}=t,L=1,G=null,te=null,se=new yt(0,0,me,X),ce=new yt(0,0,me,X),Ae=!1,Te=new La,Ue=!1,$e=!1,Xe=new Ke,Ot=new F,rt=new yt,Mt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Bt=!1;function Ht(){return P===null?L:1}let O=n;function en(E,k){return t.getContext(E,k)}let gt,Ut,R,w,U,K,ue,fe,ve,ne,oe,Ee,Fe,ye,he,Ve,We,ft,B,ge,re,xe,Re;try{let E={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${Uv}`);if(t.addEventListener("webglcontextlost",Je,!1),t.addEventListener("webglcontextrestored",Ct,!1),t.addEventListener("webglcontextcreationerror",_t,!1),O===null){if(O=en("webgl2",E),O===null)if(en("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}le()}catch(E){throw t.removeEventListener("webglcontextlost",Je,!1),t.removeEventListener("webglcontextrestored",Ct,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),je("WebGLRenderer: "+E.message),E}function le(){if(gt=new tC(O),gt.init(),re=new VI(O,gt),Ut=new WR(O,gt,e,re),R=new zI(O,gt),Ut.reversedDepthBuffer&&h)R.buffers.depth.setReversed(!0);N=O.createFramebuffer(),Y=O.createFramebuffer(),D=O.createFramebuffer(),w=new rC(O),U=new EI,K=new BI(O,gt,R,U,Ut,re,w),ue=new eC(A),fe=new oT(O),xe=new GR(O,fe),ve=new nC(O,fe,w,xe),ne=new oC(O,ve,fe,xe,w),ft=new sC(O,Ut,K),he=new ZR(U),oe=new MI(A,ue,gt,Ut,xe,he),Ee=new WI(A,U),Fe=new TI,ye=new NI(gt),We=new HR(A,ue,R,ne,f,a),Ve=new FI(A,ne,Ut),Re=new ZI(O,w,Ut,R),B=new $R(O,gt,w),ge=new iC(O,gt,w),w.programs=oe.programs,A.capabilities=Ut,A.extensions=gt,A.properties=U,A.renderLists=Fe,A.shadowMap=Ve,A.state=R,A.info=w}if(m!==di)v=new cC(m,t.width,t.height,o,i,r);let Se=new Sb(A,O);this.xr=Se,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){let E=gt.get("WEBGL_lose_context");if(E)E.loseContext()},this.forceContextRestore=function(){let E=gt.get("WEBGL_lose_context");if(E)E.restoreContext()},this.getPixelRatio=function(){return L},this.setPixelRatio=function(E){if(E===void 0)return;L=E,this.setSize(me,X,!1)},this.getSize=function(E){return E.set(me,X)},this.setSize=function(E,k,Q=!0){if(Se.isPresenting){ze("WebGLRenderer: Can't change size while VR device is presenting.");return}if(me=E,X=k,t.width=Math.floor(E*L),t.height=Math.floor(k*L),Q===!0)t.style.width=E+"px",t.style.height=k+"px";if(v!==null)v.setSize(t.width,t.height);this.setViewport(0,0,E,k)},this.getDrawingBufferSize=function(E){return E.set(me*L,X*L).floor()},this.setDrawingBufferSize=function(E,k,Q){me=E,X=k,L=Q,t.width=Math.floor(E*Q),t.height=Math.floor(k*Q),this.setViewport(0,0,E,k)},this.setEffects=function(E){if(m===di){je("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let k=0;k<E.length;k++)if(E[k].isOutputPass===!0){ze("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}v.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(ee)},this.getViewport=function(E){return E.copy(se)},this.setViewport=function(E,k,Q,Z){if(E.isVector4)se.set(E.x,E.y,E.z,E.w);else se.set(E,k,Q,Z);R.viewport(ee.copy(se).multiplyScalar(L).round())},this.getScissor=function(E){return E.copy(ce)},this.setScissor=function(E,k,Q,Z){if(E.isVector4)ce.set(E.x,E.y,E.z,E.w);else ce.set(E,k,Q,Z);R.scissor(J.copy(ce).multiplyScalar(L).round())},this.getScissorTest=function(){return Ae},this.setScissorTest=function(E){R.setScissorTest(Ae=E)},this.setOpaqueSort=function(E){G=E},this.setTransparentSort=function(E){te=E},this.getClearColor=function(E){return E.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor(...arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha(...arguments)},this.clear=function(E=!0,k=!0,Q=!0){let Z=0;if(E){let j=!1;if(P!==null){let Me=P.texture.format;j=_.has(Me)}if(j){let Me=P.texture.type,Ie=p.has(Me),we=We.getClearColor(),Pe=We.getClearAlpha(),{r:ke,g:Qe,b:at}=we;if(Ie)g[0]=ke,g[1]=Qe,g[2]=at,g[3]=Pe,O.clearBufferuiv(O.COLOR,0,g);else y[0]=ke,y[1]=Qe,y[2]=at,y[3]=Pe,O.clearBufferiv(O.COLOR,0,y)}else Z|=O.COLOR_BUFFER_BIT}if(k)Z|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(Q)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(E){E.setRenderer(this),C=E},this.dispose=function(){t.removeEventListener("webglcontextlost",Je,!1),t.removeEventListener("webglcontextrestored",Ct,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),We.dispose(),Fe.dispose(),ye.dispose(),U.dispose(),ue.dispose(),ne.dispose(),xe.dispose(),Re.dispose(),oe.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",xp),Se.removeEventListener("sessionend",vp),jr.stop()};function Je(E){E.preventDefault(),xa("WebGLRenderer: Context Lost."),V=!0}function Ct(){xa("WebGLRenderer: Context Restored."),V=!1;let E=w.autoReset,k=Ve.enabled,Q=Ve.autoUpdate,Z=Ve.needsUpdate,j=Ve.type;le(),w.autoReset=E,Ve.enabled=k,Ve.autoUpdate=Q,Ve.needsUpdate=Z,Ve.type=j}function _t(E){je("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function gi(E){let k=E.target;k.removeEventListener("dispose",gi),ji(k)}function ji(E){WS(E),U.remove(E)}function WS(E){let k=U.get(E).programs;if(k!==void 0){if(k.forEach(function(Q){oe.releaseProgram(Q)}),E.isShaderMaterial)oe.releaseShaderCache(E)}}this.renderBufferDirect=function(E,k,Q,Z,j,Me){if(k===null)k=Mt;let Ie=j.isMesh&&j.matrixWorld.determinantAffine()<0,we=XS(E,k,Q,Z,j);R.setMaterial(Z,Ie);let Pe=Q.index,ke=1;if(Z.wireframe===!0){if(Pe=ve.getWireframeAttribute(Q),Pe===void 0)return;ke=2}let Qe=Q.drawRange,at=Q.attributes.position,Le=Qe.start*ke,xt=(Qe.start+Qe.count)*ke;if(Me!==null)Le=Math.max(Le,Me.start*ke),xt=Math.min(xt,(Me.start+Me.count)*ke);if(Pe!==null)Le=Math.max(Le,0),xt=Math.min(xt,Pe.count);else if(at!==void 0&&at!==null)Le=Math.max(Le,0),xt=Math.min(xt,at.count);let Wt=xt-Le;if(Wt<0||Wt===1/0)return;xe.setup(j,Z,we,Q,Pe);let Lt,Et=B;if(Pe!==null)Lt=fe.get(Pe),Et=ge,Et.setIndex(Lt);if(j.isMesh)if(Z.wireframe===!0)R.setLineWidth(Z.wireframeLinewidth*Ht()),Et.setMode(O.LINES);else Et.setMode(O.TRIANGLES);else if(j.isLine){let hn=Z.linewidth;if(hn===void 0)hn=1;if(R.setLineWidth(hn*Ht()),j.isLineSegments)Et.setMode(O.LINES);else if(j.isLineLoop)Et.setMode(O.LINE_LOOP);else Et.setMode(O.LINE_STRIP)}else if(j.isPoints)Et.setMode(O.POINTS);else if(j.isSprite)Et.setMode(O.TRIANGLES);if(j.isBatchedMesh)if(!gt.get("WEBGL_multi_draw")){let{_multiDrawStarts:hn,_multiDrawCounts:Ce,_multiDrawCount:xn}=j,ht=Pe?fe.get(Pe).bytesPerElement:1,Vn=U.get(Z).currentProgram.getUniforms();for(let _i=0;_i<xn;_i++)Vn.setValue(O,"_gl_DrawID",_i),Et.render(hn[_i]/ht,Ce[_i])}else Et.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else if(j.isInstancedMesh)Et.renderInstances(Le,Wt,j.count);else if(Q.isInstancedBufferGeometry){let hn=Q._maxInstanceCount!==void 0?Q._maxInstanceCount:1/0,Ce=Math.min(Q.instanceCount,hn);Et.renderInstances(Le,Wt,Ce)}else Et.render(Le,Wt)};function _p(E,k,Q,Z){if(C!==null&&E.isNodeMaterial)C.setObject(Z,E);if(Ue===!0)he.setState(E,Q,!1);if(E.transparent===!0&&E.side===Yn&&E.forceSinglePass===!1)E.side=mn,E.needsUpdate=!0,rc(E,k,Z),E.side=Cr,E.needsUpdate=!0,rc(E,k,Z),E.side=Yn;else rc(E,k,Z)}this.compile=function(E,k,Q=null){if(Q===null)Q=E;if(C!==null)C.renderStart(E,k,Q);if(b=ye.get(Q),b.init(k),T.push(b),Q.traverseVisible(function(j){if(j.isLight&&j.layers.test(k.layers)){if(b.pushLight(j),j.castShadow)b.pushShadow(j)}}),E!==Q)E.traverseVisible(function(j){if(j.isLight&&j.layers.test(k.layers)){if(b.pushLight(j),j.castShadow)b.pushShadow(j)}});if(b.setupLights(),C!==null)C.updateLights(b.state.lightsArray);if($e=this.localClippingEnabled,Ue=he.init(this.clippingPlanes,$e),Ue===!0)he.setGlobalState(this.clippingPlanes,k);if(C!==null)Ve.render(b.state.shadowsArray,Q,k);let Z=new Set;if(E.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 Ie=0;Ie<Me.length;Ie++){let we=Me[Ie];_p(we,Q,k,j),Z.add(we)}else _p(Me,Q,k,j),Z.add(Me)}),b=T.pop(),C!==null)C.renderEnd();return Z},this.compileAsync=function(E,k,Q=null){let Z=this.compile(E,k,Q);return new Promise((j)=>{function Me(){if(Z.forEach(function(Ie){let Pe=U.get(Ie).currentProgram;if(Pe===void 0||Pe.isReady())Z.delete(Ie)}),Z.size===0){j(E);return}setTimeout(Me,10)}if(gt.get("KHR_parallel_shader_compile")!==null)Me();else setTimeout(Me,10)})};let hu=null;function ZS(E){if(hu)hu(E)}function xp(){jr.stop()}function vp(){jr.start()}let jr=new ub;if(jr.setAnimationLoop(ZS),typeof self<"u")jr.setContext(self);this.setAnimationLoop=function(E){hu=E,Se.setAnimationLoop(E),E===null?jr.stop():jr.start()},Se.addEventListener("sessionstart",xp),Se.addEventListener("sessionend",vp),this.render=function(E,k){if(k!==void 0&&k.isCamera!==!0){je("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(V===!0)return;if(C!==null)C.renderStart(E,k);let Q=Se.enabled===!0&&Se.isPresenting===!0,Z=v!==null&&(P===null||Q)&&v.begin(A,P);if(E.matrixWorldAutoUpdate===!0)E.updateMatrixWorld();if(k.parent===null&&k.matrixWorldAutoUpdate===!0)k.updateMatrixWorld();if(Se.enabled===!0&&Se.isPresenting===!0&&(v===null||v.isCompositing()===!1)){if(Se.cameraAutoUpdate===!0)Se.updateCamera(k);k=Se.getCamera()}if(E.isScene===!0)E.onBeforeRender(A,E,k,P);if(b=ye.get(E,T.length),b.init(k),b.state.textureUnits=K.getTextureUnits(),T.push(b),Xe.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Te.setFromProjectionMatrix(Xe,cf,k.reversedDepth),$e=this.localClippingEnabled,Ue=he.init(this.clippingPlanes,$e),x=Fe.get(E,M.length),x.init(),M.push(x),Se.enabled===!0&&Se.isPresenting===!0){let Ie=A.xr.getDepthSensingMesh();if(Ie!==null)du(Ie,k,-1/0,A.sortObjects)}if(du(E,k,0,A.sortObjects),x.finish(),C!==null)C.updateLights(b.state.lightsArray);if(A.sortObjects===!0)x.sort(G,te);if(Bt=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Bt)We.addToRenderList(x,E);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ue===!0)he.beginShadows();let j=b.state.shadowsArray;if(Ve.render(j,E,k),Ue===!0)he.endShadows();if((Z&&v.hasRenderPass())===!1){let Ie=x.opaque,we=x.transmissive;if(b.setupLights(),k.isArrayCamera){let Pe=k.cameras;if(we.length>0)for(let ke=0,Qe=Pe.length;ke<Qe;ke++){let at=Pe[ke];bp(Ie,we,E,at)}if(Bt)We.render(E);for(let ke=0,Qe=Pe.length;ke<Qe;ke++){let at=Pe[ke];yp(x,E,at,at.viewport)}}else{if(we.length>0)bp(Ie,we,E,k);if(Bt)We.render(E);yp(x,E,k)}}if(P!==null&&z===0)K.updateMultisampleRenderTarget(P),K.updateRenderTargetMipmap(P);if(Z)v.end(A);if(E.isScene===!0)E.onAfterRender(A,E,k);if(xe.resetDefaultState(),q=-1,H=null,T.pop(),T.length>0){if(b=T[T.length-1],K.setTextureUnits(b.state.textureUnits),Ue===!0)he.setGlobalState(A.clippingPlanes,b.state.camera)}else b=null;if(M.pop(),M.length>0)x=M[M.length-1];else x=null;if(C!==null)C.renderEnd()};function du(E,k,Q,Z){if(E.visible===!1)return;if(E.layers.test(k.layers)){if(E.isGroup)Q=E.renderOrder;else if(E.isLOD){if(E.autoUpdate===!0)E.update(k)}else if(E.isLightProbeGrid)b.pushLightProbeGrid(E);else if(E.isLight){if(b.pushLight(E),E.castShadow)b.pushShadow(E)}else if(E.isSprite){if(!E.frustumCulled||E.intersectsFrustum(Te)){if(Z)rt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Xe);let Ie=ne.update(E),we=E.material;if(we.visible)x.push(E,Ie,we,Q,rt.z,null,k)}}else if(E.isMesh||E.isLine||E.isPoints){if(!E.frustumCulled||E.intersectsFrustum(Te)){let Ie=ne.update(E),we=E.material;if(Z){if(E.boundingSphere!==void 0){if(E.boundingSphere===null)E.computeBoundingSphere();rt.copy(E.boundingSphere.center)}else{if(Ie.boundingSphere===null)Ie.computeBoundingSphere();rt.copy(Ie.boundingSphere.center)}rt.applyMatrix4(E.matrixWorld).applyMatrix4(Xe)}if(Array.isArray(we)){let Pe=Ie.groups;for(let ke=0,Qe=Pe.length;ke<Qe;ke++){let at=Pe[ke],Le=we[at.materialIndex];if(Le&&Le.visible)x.push(E,Ie,Le,Q,rt.z,at,k)}}else if(we.visible)x.push(E,Ie,we,Q,rt.z,null,k)}}}let Me=E.children;for(let Ie=0,we=Me.length;Ie<we;Ie++)du(Me[Ie],k,Q,Z)}function yp(E,k,Q,Z){let{opaque:j,transmissive:Me,transparent:Ie}=E;if(b.setupLightsView(Q),Ue===!0)he.setGlobalState(A.clippingPlanes,Q);if(Z)R.viewport(ee.copy(Z));if(j.length>0)ic(j,k,Q);if(Me.length>0)ic(Me,k,Q);if(Ie.length>0)ic(Ie,k,Q);R.buffers.depth.setTest(!0),R.buffers.depth.setMask(!0),R.buffers.color.setMask(!0),R.setPolygonOffset(!1)}function bp(E,k,Q,Z){if((Q.isScene===!0?Q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[Z.id]===void 0){let Le=gt.has("EXT_color_buffer_half_float")||gt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[Z.id]=new kn(1,1,{generateMipmaps:!0,type:Le?Ui:di,minFilter:Oi,samples:Math.max(4,Ut.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:nt.workingColorSpace})}let Me=b.state.transmissionRenderTarget[Z.id],Ie=Z.viewport||ee;Me.setSize(Ie.z*A.transmissionResolutionScale,Ie.w*A.transmissionResolutionScale);let we=A.getRenderTarget(),Pe=A.getActiveCubeFace(),ke=A.getActiveMipmapLevel();if(A.setRenderTarget(Me),A.getClearColor(pe),Be=A.getClearAlpha(),Be<1)A.setClearColor(16777215,0.5);if(A.clear(),Bt)We.render(Q);let Qe=A.toneMapping;A.toneMapping=ui;let at=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(b.setupLightsView(Z),Ue===!0)he.setGlobalState(A.clippingPlanes,Z);if(ic(E,Q,Z),K.updateMultisampleRenderTarget(Me),K.updateRenderTargetMipmap(Me),gt.has("WEBGL_multisampled_render_to_texture")===!1){let Le=!1;for(let xt=0,Wt=k.length;xt<Wt;xt++){let Lt=k[xt],{object:Et,geometry:hn,material:Ce,group:xn}=Lt;if(Ce.side===Yn&&Et.layers.test(Z.layers)){let ht=Ce.side;Ce.side=mn,Ce.needsUpdate=!0,Sp(Et,Q,Z,hn,Ce,xn),Ce.side=ht,Ce.needsUpdate=!0,Le=!0}}if(Le===!0)K.updateMultisampleRenderTarget(Me),K.updateRenderTargetMipmap(Me)}if(A.setRenderTarget(we,Pe,ke),A.setClearColor(pe,Be),at!==void 0)Z.viewport=at;A.toneMapping=Qe}function ic(E,k,Q){let Z=k.isScene===!0?k.overrideMaterial:null;for(let j=0,Me=E.length;j<Me;j++){let Ie=E[j],{object:we,geometry:Pe,group:ke}=Ie,Qe=Ie.material;if(Qe.allowOverride===!0&&Z!==null)Qe=Z;if(we.layers.test(Q.layers))Sp(we,k,Q,Pe,Qe,ke)}}function Sp(E,k,Q,Z,j,Me){if(C!==null&&j.isNodeMaterial)C.setObject(E,j);if(E.onBeforeRender(A,k,Q,Z,j,Me),E.modelViewMatrix.multiplyMatrices(Q.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),j.onBeforeRender(A,k,Q,Z,E,Me),j.transparent===!0&&j.side===Yn&&j.forceSinglePass===!1)j.side=mn,j.needsUpdate=!0,A.renderBufferDirect(Q,k,Z,j,E,Me),j.side=Cr,j.needsUpdate=!0,A.renderBufferDirect(Q,k,Z,j,E,Me),j.side=Yn;else A.renderBufferDirect(Q,k,Z,j,E,Me);E.onAfterRender(A,k,Q,Z,j,Me)}function rc(E,k,Q){if(k.isScene!==!0)k=Mt;let Z=U.get(E),j=b.state.lights,Me=b.state.shadowsArray,Ie=j.state.version,we=oe.getParameters(E,j.state,Me,k,Q,b.state.lightProbeGridArray),Pe=oe.getProgramCacheKey(we),ke=Z.programs;Z.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?k.environment:null,Z.fog=k.fog;let Qe=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;if(Z.envMap=ue.get(E.envMap||Z.environment,Qe),Z.envMapRotation=Z.environment!==null&&E.envMap===null?k.environmentRotation:E.envMapRotation,ke===void 0)E.addEventListener("dispose",gi),ke=new Map,Z.programs=ke;let at=ke.get(Pe);if(at!==void 0){if(Z.currentProgram===at&&Z.lightsStateVersion===Ie)return Mp(E,we),at}else{if(we.uniforms=oe.getUniforms(E),C!==null&&E.isNodeMaterial)C.build(E,Q,we);E.onBeforeCompile(we,A),at=oe.acquireProgram(we,Pe),ke.set(Pe,at),Z.uniforms=we.uniforms}let Le=Z.uniforms;if(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)Le.clippingPlanes=he.uniform;if(Mp(E,we),Z.needsLights=YS(E),Z.lightsStateVersion=Ie,Z.needsLights)Le.ambientLightColor.value=j.state.ambient,Le.lightProbe.value=j.state.probe,Le.sunLights.value=j.state.sun,Le.sunLightShadows.value=j.state.sunShadow,Le.directionalLights.value=j.state.directional,Le.directionalLightShadows.value=j.state.directionalShadow,Le.spotLights.value=j.state.spot,Le.spotLightShadows.value=j.state.spotShadow,Le.rectAreaLights.value=j.state.rectArea,Le.ltc_1.value=j.state.rectAreaLTC1,Le.ltc_2.value=j.state.rectAreaLTC2,Le.pointLights.value=j.state.point,Le.pointLightShadows.value=j.state.pointShadow,Le.hemisphereLights.value=j.state.hemi,Le.sunShadowMatrix.value=j.state.sunShadowMatrix,Le.sunShadowCascade.value=j.state.sunShadowCascade,Le.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Le.spotLightMatrix.value=j.state.spotLightMatrix,Le.spotLightMap.value=j.state.spotLightMap,Le.pointShadowMatrix.value=j.state.pointShadowMatrix;return Z.lightProbeGrid=b.state.lightProbeGridArray.length>0,Z.currentProgram=at,Z.uniformsList=null,at}function wp(E){if(E.uniformsList===null){let k=E.currentProgram.getUniforms();E.uniformsList=Ga.seqWithValue(k.seq,E.uniforms)}return E.uniformsList}function Mp(E,k){let Q=U.get(E);Q.outputColorSpace=k.outputColorSpace,Q.batching=k.batching,Q.batchingColor=k.batchingColor,Q.instancing=k.instancing,Q.instancingColor=k.instancingColor,Q.instancingMorph=k.instancingMorph,Q.skinning=k.skinning,Q.morphTargets=k.morphTargets,Q.morphNormals=k.morphNormals,Q.morphColors=k.morphColors,Q.morphTargetsCount=k.morphTargetsCount,Q.numClippingPlanes=k.numClippingPlanes,Q.numIntersection=k.numClipIntersection,Q.vertexAlphas=k.vertexAlphas,Q.vertexTangents=k.vertexTangents,Q.toneMapping=k.toneMapping}function jS(E,k){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;S.setFromMatrixPosition(k.matrixWorld);for(let Q=0,Z=E.length;Q<Z;Q++){let j=E[Q];if(j.texture!==null&&j.boundingBox.containsPoint(S))return j}return null}function XS(E,k,Q,Z,j){if(k.isScene!==!0)k=Mt;K.resetTextureUnits();let Me=k.fog,Ie=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?k.environment:null,we=P===null?A.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:nt.workingColorSpace,Pe=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,ke=ue.get(Z.envMap||Ie,Pe),Qe=Z.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,at=!!Q.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),Le=!!Q.morphAttributes.position,xt=!!Q.morphAttributes.normal,Wt=!!Q.morphAttributes.color,Lt=ui;if(Z.toneMapped){if(P===null||P.isXRRenderTarget===!0)Lt=A.toneMapping}let Et=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,hn=Et!==void 0?Et.length:0,Ce=U.get(Z),xn=b.state.lights;if(Ue===!0){if($e===!0||E!==H){let It=E===H&&Z.id===q;he.setState(Z,E,It)}}let ht=!1;if(Z.version===Ce.__version){if(Ce.needsLights&&Ce.lightsStateVersion!==xn.state.version)ht=!0;else if(Ce.outputColorSpace!==we)ht=!0;else if(j.isBatchedMesh&&Ce.batching===!1)ht=!0;else if(!j.isBatchedMesh&&Ce.batching===!0)ht=!0;else if(j.isBatchedMesh&&Ce.batchingColor===!0&&j._colorsTexture===null)ht=!0;else if(j.isBatchedMesh&&Ce.batchingColor===!1&&j._colorsTexture!==null)ht=!0;else if(j.isInstancedMesh&&Ce.instancing===!1)ht=!0;else if(!j.isInstancedMesh&&Ce.instancing===!0)ht=!0;else if(j.isSkinnedMesh&&Ce.skinning===!1)ht=!0;else if(!j.isSkinnedMesh&&Ce.skinning===!0)ht=!0;else if(j.isInstancedMesh&&Ce.instancingColor===!0&&j.instanceColor===null)ht=!0;else if(j.isInstancedMesh&&Ce.instancingColor===!1&&j.instanceColor!==null)ht=!0;else if(j.isInstancedMesh&&Ce.instancingMorph===!0&&j.morphTexture===null)ht=!0;else if(j.isInstancedMesh&&Ce.instancingMorph===!1&&j.morphTexture!==null)ht=!0;else if(Ce.envMap!==ke)ht=!0;else if(Z.fog===!0&&Ce.fog!==Me)ht=!0;else if(Ce.numClippingPlanes!==void 0&&(Ce.numClippingPlanes!==he.numPlanes||Ce.numIntersection!==he.numIntersection))ht=!0;else if(Ce.vertexAlphas!==Qe)ht=!0;else if(Ce.vertexTangents!==at)ht=!0;else if(Ce.morphTargets!==Le)ht=!0;else if(Ce.morphNormals!==xt)ht=!0;else if(Ce.morphColors!==Wt)ht=!0;else if(Ce.toneMapping!==Lt)ht=!0;else if(Ce.morphTargetsCount!==hn)ht=!0;else if(!!Ce.lightProbeGrid!==b.state.lightProbeGridArray.length>0)ht=!0}else ht=!0,Ce.__version=Z.version;let Vn=Ce.currentProgram;if(ht===!0){if(Vn=rc(Z,k,j),C&&Z.isNodeMaterial)C.onUpdateProgram(Z,Vn,Ce)}let _i=!1,hr=!1,Ss=!1,St=Vn.getUniforms(),Gt=Ce.uniforms;if(R.useProgram(Vn.program))_i=!0,hr=!0,Ss=!0;if(Z.id!==q)q=Z.id,hr=!0;if(Ce.needsLights){let It=jS(b.state.lightProbeGridArray,j);if(Ce.lightProbeGrid!==It)Ce.lightProbeGrid=It,hr=!0}if(_i||H!==E){if(R.buffers.depth.getReversed()&&E.reversedDepth!==!0)E._reversedDepth=!0,E.updateProjectionMatrix();St.setValue(O,"projectionMatrix",E.projectionMatrix),St.setValue(O,"viewMatrix",E.matrixWorldInverse);let fr=St.map.cameraPosition;if(fr!==void 0)fr.setValue(O,Ot.setFromMatrixPosition(E.matrixWorld));if(Ut.logarithmicDepthBuffer)St.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)St.setValue(O,"isOrthographic",E.isOrthographicCamera===!0);if(H!==E)H=E,hr=!0,Ss=!0}if(Ce.needsLights){if(xn.state.sunShadowMap.length>0)St.setValue(O,"sunShadowMap",xn.state.sunShadowMap,K);if(xn.state.directionalShadowMap.length>0)St.setValue(O,"directionalShadowMap",xn.state.directionalShadowMap,K);if(xn.state.spotShadowMap.length>0)St.setValue(O,"spotShadowMap",xn.state.spotShadowMap,K);if(xn.state.pointShadowMap.length>0)St.setValue(O,"pointShadowMap",xn.state.pointShadowMap,K)}if(j.isSkinnedMesh){St.setOptional(O,j,"bindMatrix"),St.setOptional(O,j,"bindMatrixInverse");let It=j.skeleton;if(It){if(It.boneTexture===null)It.computeBoneTexture();St.setValue(O,"boneTexture",It.boneTexture,K)}}if(j.isBatchedMesh){if(St.setOptional(O,j,"batchingTexture"),St.setValue(O,"batchingTexture",j._matricesTexture,K),St.setOptional(O,j,"batchingIdTexture"),St.setValue(O,"batchingIdTexture",j._indirectTexture,K),St.setOptional(O,j,"batchingColorTexture"),j._colorsTexture!==null)St.setValue(O,"batchingColorTexture",j._colorsTexture,K)}let dr=Q.morphAttributes;if(dr.position!==void 0||dr.normal!==void 0||dr.color!==void 0)ft.update(j,Q,Vn);if(hr||Ce.receiveShadow!==j.receiveShadow)Ce.receiveShadow=j.receiveShadow,St.setValue(O,"receiveShadow",j.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&k.environment!==null)Gt.envMapIntensity.value=k.environmentIntensity;if(Gt.dfgLUT!==void 0)Gt.dfgLUT.value=XI();if(hr){if(St.setValue(O,"toneMappingExposure",A.toneMappingExposure),Ce.needsLights)qS(Gt,Ss);if(Me&&Z.fog===!0)Ee.refreshFogUniforms(Gt,Me);if(Ee.refreshMaterialUniforms(Gt,Z,L,X,b.state.transmissionRenderTarget[E.id]),Ce.needsLights&&Ce.lightProbeGrid){let It=Ce.lightProbeGrid;Gt.probesSH.value=It.texture,Gt.probesMin.value.copy(It.boundingBox.min),Gt.probesMax.value.copy(It.boundingBox.max),Gt.probesResolution.value.copy(It.resolution)}Ga.upload(O,wp(Ce),Gt,K)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)Ga.upload(O,wp(Ce),Gt,K),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)St.setValue(O,"center",j.center);if(St.setValue(O,"modelViewMatrix",j.modelViewMatrix),St.setValue(O,"normalMatrix",j.normalMatrix),St.setValue(O,"modelMatrix",j.matrixWorld),Z.uniformsGroups!==void 0){let It=Z.uniformsGroups;for(let fr=0,ws=It.length;fr<ws;fr++){let Ap=It[fr];Re.update(Ap,Vn),Re.bind(Ap,Vn)}}return Vn}function qS(E,k){E.ambientLightColor.needsUpdate=k,E.lightProbe.needsUpdate=k,E.sunLights.needsUpdate=k,E.sunLightShadows.needsUpdate=k,E.directionalLights.needsUpdate=k,E.directionalLightShadows.needsUpdate=k,E.pointLights.needsUpdate=k,E.pointLightShadows.needsUpdate=k,E.spotLights.needsUpdate=k,E.spotLightShadows.needsUpdate=k,E.rectAreaLights.needsUpdate=k,E.hemisphereLights.needsUpdate=k}function YS(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(E,k,Q){let Z=U.get(E);if(Z.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;U.get(E.texture).__webglTexture=k,U.get(E.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:Q,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,k){let Q=U.get(E);Q.__webglFramebuffer=k,Q.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(E,k=0,Q=0){P=E,W=k,z=Q;let Z=null,j=!1,Me=!1;if(E){let we=U.get(E);if(we.__useDefaultFramebuffer!==void 0){R.bindFramebuffer(O.FRAMEBUFFER,we.__webglFramebuffer),ee.copy(E.viewport),J.copy(E.scissor),de=E.scissorTest,R.viewport(ee),R.scissor(J),R.setScissorTest(de),q=-1;return}else if(we.__webglFramebuffer===void 0)K.setupRenderTarget(E);else if(we.__hasExternalTextures)K.rebindTextures(E,U.get(E.texture).__webglTexture,U.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){let Qe=E.depthTexture;if(we.__boundDepthTexture!==Qe){if(Qe!==null&&U.has(Qe)&&(E.width!==Qe.image.width||E.height!==Qe.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(E)}}let Pe=E.texture;if(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)Me=!0;let ke=U.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget){if(Array.isArray(ke[k]))Z=ke[k][Q];else Z=ke[k];j=!0}else if(E.samples>0&&K.useMultisampledRTT(E)===!1)Z=U.get(E).__webglMultisampledFramebuffer;else if(Array.isArray(ke))Z=ke[Q];else Z=ke;ee.copy(E.viewport),J.copy(E.scissor),de=E.scissorTest}else ee.copy(se).multiplyScalar(L).floor(),J.copy(ce).multiplyScalar(L).floor(),de=Ae;if(Q!==0)Z=N;if(R.bindFramebuffer(O.FRAMEBUFFER,Z))R.drawBuffers(E,Z);if(R.viewport(ee),R.scissor(J),R.setScissorTest(de),j){let we=U.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+k,we.__webglTexture,Q)}else if(Me){let we=k;for(let Pe=0;Pe<E.textures.length;Pe++){let ke=U.get(E.textures[Pe]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Pe,ke.__webglTexture,Q,we)}}else if(E!==null&&Q!==0){let we=U.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,we.__webglTexture,Q)}q=-1};function Ep(E){let k=U.get(E);if(k.__readFormat!==E.format||k.__readType!==E.type)k.__readFormat=E.format,k.__readType=E.type,k.__formatReadable=Ut.textureFormatReadable(E.format),k.__typeReadable=Ut.textureTypeReadable(E.type);return k}if(this.readRenderTargetPixels=function(E,k,Q,Z,j,Me,Ie,we=0){if(!(E&&E.isWebGLRenderTarget)){je("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=U.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ie!==void 0)Pe=Pe[Ie];if(Pe){R.bindFramebuffer(O.FRAMEBUFFER,Pe);try{let ke=E.textures[we],{format:Qe,type:at}=ke;if(E.textures.length>1)O.readBuffer(O.COLOR_ATTACHMENT0+we);let Le=Ep(ke);if(Le.__formatReadable===!1){je("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Le.__typeReadable===!1){je("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(k>=0&&k<=E.width-Z&&(Q>=0&&Q<=E.height-j))O.readPixels(k,Q,Z,j,re.convert(Qe),re.convert(at),Me)}finally{let ke=P!==null?U.get(P).__webglFramebuffer:null;R.bindFramebuffer(O.FRAMEBUFFER,ke)}}},this.readRenderTargetPixelsAsync=async function(E,k,Q,Z,j,Me,Ie,we=0){if(!(E&&E.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=U.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ie!==void 0)Pe=Pe[Ie];if(Pe)if(k>=0&&k<=E.width-Z&&(Q>=0&&Q<=E.height-j)){R.bindFramebuffer(O.FRAMEBUFFER,Pe);let ke=E.textures[we],{format:Qe,type:at}=ke;if(E.textures.length>1)O.readBuffer(O.COLOR_ATTACHMENT0+we);let Le=Ep(ke);if(Le.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Le.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let xt=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,xt),O.bufferData(O.PIXEL_PACK_BUFFER,Me.byteLength,O.STREAM_READ),O.readPixels(k,Q,Z,j,re.convert(Qe),re.convert(at),0),O.bindBuffer(O.PIXEL_PACK_BUFFER,null);let Wt=P!==null?U.get(P).__webglFramebuffer:null;R.bindFramebuffer(O.FRAMEBUFFER,Wt);let Lt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await Ly(O,Lt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,xt),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,Me),O.bindBuffer(O.PIXEL_PACK_BUFFER,null),O.deleteBuffer(xt),O.deleteSync(Lt),Me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,k=null,Q=0){let Z=Math.pow(2,-Q),j=Math.floor(E.image.width*Z),Me=Math.floor(E.image.height*Z),Ie=k!==null?k.x:0,we=k!==null?k.y:0;K.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,Q,0,0,Ie,we,j,Me),R.unbindTexture()},this.copyTextureToTexture=function(E,k,Q=null,Z=null,j=0,Me=0){let Ie,we,Pe,ke,Qe,at,Le,xt,Wt,Lt=E.isCompressedTexture?E.mipmaps[Me]:E.image;if(Q!==null)Ie=Q.max.x-Q.min.x,we=Q.max.y-Q.min.y,Pe=Q.isBox3?Q.max.z-Q.min.z:1,ke=Q.min.x,Qe=Q.min.y,at=Q.isBox3?Q.min.z:0;else{let Gt=Math.pow(2,-j);if(Ie=Math.floor(Lt.width*Gt),we=Math.floor(Lt.height*Gt),E.isDataArrayTexture)Pe=Lt.depth;else if(E.isData3DTexture)Pe=Math.floor(Lt.depth*Gt);else Pe=1;ke=0,Qe=0,at=0}if(Z!==null)Le=Z.x,xt=Z.y,Wt=Z.z;else Le=0,xt=0,Wt=0;let Et=re.convert(k.format),hn=re.convert(k.type),Ce;if(k.isData3DTexture)K.setTexture3D(k,0),Ce=O.TEXTURE_3D;else if(k.isDataArrayTexture||k.isCompressedArrayTexture)K.setTexture2DArray(k,0),Ce=O.TEXTURE_2D_ARRAY;else K.setTexture2D(k,0),Ce=O.TEXTURE_2D;R.activeTexture(O.TEXTURE0),R.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,k.flipY),R.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),R.pixelStorei(O.UNPACK_ALIGNMENT,k.unpackAlignment);let xn=R.getParameter(O.UNPACK_ROW_LENGTH),ht=R.getParameter(O.UNPACK_IMAGE_HEIGHT),Vn=R.getParameter(O.UNPACK_SKIP_PIXELS),_i=R.getParameter(O.UNPACK_SKIP_ROWS),hr=R.getParameter(O.UNPACK_SKIP_IMAGES);R.pixelStorei(O.UNPACK_ROW_LENGTH,Lt.width),R.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Lt.height),R.pixelStorei(O.UNPACK_SKIP_PIXELS,ke),R.pixelStorei(O.UNPACK_SKIP_ROWS,Qe),R.pixelStorei(O.UNPACK_SKIP_IMAGES,at);let Ss=E.isDataArrayTexture||E.isData3DTexture,St=k.isDataArrayTexture||k.isData3DTexture;if(E.isDepthTexture){let Gt=U.get(E),dr=U.get(k),It=U.get(Gt.__renderTarget),fr=U.get(dr.__renderTarget);R.bindFramebuffer(O.READ_FRAMEBUFFER,It.__webglFramebuffer),R.bindFramebuffer(O.DRAW_FRAMEBUFFER,fr.__webglFramebuffer);for(let ws=0;ws<Pe;ws++){if(Ss)O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,U.get(E).__webglTexture,j,at+ws),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,U.get(k).__webglTexture,Me,Wt+ws);O.blitFramebuffer(ke,Qe,Ie,we,Le,xt,Ie,we,O.DEPTH_BUFFER_BIT,O.NEAREST)}R.bindFramebuffer(O.READ_FRAMEBUFFER,null),R.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(j!==0||E.isRenderTargetTexture||U.has(E)){let Gt=U.get(E),dr=U.get(k);R.bindFramebuffer(O.READ_FRAMEBUFFER,Y),R.bindFramebuffer(O.DRAW_FRAMEBUFFER,D);for(let It=0;It<Pe;It++){if(Ss)O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Gt.__webglTexture,j,at+It);else O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Gt.__webglTexture,j);if(St)O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,dr.__webglTexture,Me,Wt+It);else O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,dr.__webglTexture,Me);if(j!==0)O.blitFramebuffer(ke,Qe,Ie,we,Le,xt,Ie,we,O.COLOR_BUFFER_BIT,O.NEAREST);else if(St)O.copyTexSubImage3D(Ce,Me,Le,xt,Wt+It,ke,Qe,Ie,we);else O.copyTexSubImage2D(Ce,Me,Le,xt,ke,Qe,Ie,we)}R.bindFramebuffer(O.READ_FRAMEBUFFER,null),R.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(St)if(E.isDataTexture||E.isData3DTexture)O.texSubImage3D(Ce,Me,Le,xt,Wt,Ie,we,Pe,Et,hn,Lt.data);else if(k.isCompressedArrayTexture)O.compressedTexSubImage3D(Ce,Me,Le,xt,Wt,Ie,we,Pe,Et,Lt.data);else O.texSubImage3D(Ce,Me,Le,xt,Wt,Ie,we,Pe,Et,hn,Lt);else if(E.isDataTexture)O.texSubImage2D(O.TEXTURE_2D,Me,Le,xt,Ie,we,Et,hn,Lt.data);else if(E.isCompressedTexture)O.compressedTexSubImage2D(O.TEXTURE_2D,Me,Le,xt,Lt.width,Lt.height,Et,Lt.data);else O.texSubImage2D(O.TEXTURE_2D,Me,Le,xt,Ie,we,Et,hn,Lt);if(R.pixelStorei(O.UNPACK_ROW_LENGTH,xn),R.pixelStorei(O.UNPACK_IMAGE_HEIGHT,ht),R.pixelStorei(O.UNPACK_SKIP_PIXELS,Vn),R.pixelStorei(O.UNPACK_SKIP_ROWS,_i),R.pixelStorei(O.UNPACK_SKIP_IMAGES,hr),Me===0&&k.generateMipmaps)O.generateMipmap(Ce);R.unbindTexture()},this.initRenderTarget=function(E){if(U.get(E).__webglFramebuffer===void 0)K.setupRenderTarget(E)},this.initTexture=function(E){if(E.isCubeTexture)K.setTextureCube(E,0);else if(E.isData3DTexture)K.setTexture3D(E,0);else if(E.isDataArrayTexture||E.isCompressedArrayTexture)K.setTexture2DArray(E,0);else K.setTexture2D(E,0);R.unbindTexture()},this.resetState=function(){W=0,z=0,P=null,R.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return cf}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=nt._getDrawingBufferColorSpace(e),t.unpackColorSpace=nt._getUnpackColorSpace()}}var Eb={type:"change"},Hf={type:"start"},Tb={type:"end"},iu=new Lr,Ab=new Xn,qI=Math.cos(70*Ea.DEG2RAD),Qt=new F,Rn=2*Math.PI,bt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Vf=0.000001;class Gf extends Kl{constructor(e,t=null){super(e,t);if(this.state=bt.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:Tr.ROTATE,MIDDLE:Tr.DOLLY,RIGHT:Tr.PAN},this.touches={ONE:Rr.ROTATE,TWO:Rr.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 nn,this._lastTargetPosition=new F,this._quat=new nn().setFromUnitVectors(e.up,new F(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new za,this._sphericalDelta=new za,this._scale=1,this._panOffset=new F,this._rotateStart=new Ge,this._rotateEnd=new Ge,this._rotateDelta=new Ge,this._panStart=new Ge,this._panEnd=new Ge,this._panDelta=new Ge,this._dollyStart=new Ge,this._dollyEnd=new Ge,this._dollyDelta=new Ge,this._dollyDirection=new F,this._mouse=new Ge,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=JI.bind(this),this._onPointerDown=YI.bind(this),this._onPointerUp=KI.bind(this),this._onContextMenu=sP.bind(this),this._onMouseWheel=tP.bind(this),this._onKeyDown=nP.bind(this),this._onTouchStart=iP.bind(this),this._onTouchMove=rP.bind(this),this._onMouseDown=QI.bind(this),this._onMouseMove=eP.bind(this),this._interceptControlDown=oP.bind(this),this._interceptControlUp=aP.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=bt.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(Eb),this.update(),this.state=bt.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(Qt.copy(t).sub(this.target),Qt.applyQuaternion(this._quat),this._spherical.setFromVector3(Qt),this.autoRotate&&this.state===bt.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+=Rn;else if(n>Math.PI)n-=Rn;if(i<-Math.PI)i+=Rn;else if(i>Math.PI)i-=Rn;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(Qt.setFromSpherical(this._spherical),Qt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Qt),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=Qt.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=Qt.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(iu.origin.copy(this.object.position),iu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(iu.direction))<qI)this.object.lookAt(this.target);else Ab.setFromNormalAndCoplanarPoint(this.object.up,this.target),iu.intersectPlane(Ab,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)>Vf||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Vf||this._lastTargetPosition.distanceToSquared(this.target)>Vf)return this.dispatchEvent(Eb),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 Rn/60*this.autoRotateSpeed*e;else return Rn/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){Qt.setFromMatrixColumn(t,0),Qt.multiplyScalar(-e),this._panOffset.add(Qt)}_panUp(e,t){if(this.screenSpacePanning===!0)Qt.setFromMatrixColumn(t,1);else Qt.setFromMatrixColumn(t,0),Qt.crossVectors(this.object.up,Qt);Qt.multiplyScalar(e),this._panOffset.add(Qt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Qt.copy(i).sub(this.target);let r=Qt.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(Rn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Rn*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(Rn*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(-Rn*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(Rn*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(-Rn*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(Rn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Rn*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 Ge,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 YI(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 JI(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function KI(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(Tb),this.state=bt.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 QI(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 Tr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=bt.DOLLY;break;case Tr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=bt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=bt.ROTATE}break;case Tr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=bt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=bt.PAN}break;default:this.state=bt.NONE}if(this.state!==bt.NONE)this.dispatchEvent(Hf)}function eP(e){switch(this.state){case bt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case bt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case bt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function tP(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==bt.NONE)return;e.preventDefault(),this.dispatchEvent(Hf),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Tb)}function nP(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function iP(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Rr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=bt.TOUCH_ROTATE;break;case Rr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=bt.TOUCH_PAN;break;default:this.state=bt.NONE}break;case 2:switch(this.touches.TWO){case Rr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=bt.TOUCH_DOLLY_PAN;break;case Rr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=bt.TOUCH_DOLLY_ROTATE;break;default:this.state=bt.NONE}break;default:this.state=bt.NONE}if(this.state!==bt.NONE)this.dispatchEvent(Hf)}function rP(e){switch(this._trackPointer(e),this.state){case bt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case bt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case bt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case bt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=bt.NONE}}function sP(e){if(this.enabled===!1)return;e.preventDefault()}function oP(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function aP(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class $f extends lo{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Dr;e.deleteAttribute("uv");let t=new ar({side:mn}),n=new ar,i=new go(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Pt(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 ho(e,n,6),o=new wt;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 Pt(e,bo(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 Pt(e,bo(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 Pt(e,bo(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 Pt(e,bo(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 Pt(e,bo(20));h.position.set(3.235,11.486,-12.541),h.scale.set(2.5,2,0.1),this.add(h);let d=new Pt(e,bo(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 bo(e){return new $l({color:0,emissive:16777215,emissiveIntensity:e})}function Wf(e,t){if(t===rf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===co||t===Ma){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===co)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 Rb(e){let t=new Map,n=new Map,i=e.clone();return Cb(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 Cb(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)Cb(e.children[i],t.children[i],n)}class Kf extends lr{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new kb(t)}),this.register(function(t){return new Fb(t)}),this.register(function(t){return new jb(t)}),this.register(function(t){return new Xb(t)}),this.register(function(t){return new qb(t)}),this.register(function(t){return new Bb(t)}),this.register(function(t){return new Vb(t)}),this.register(function(t){return new Hb(t)}),this.register(function(t){return new Gb(t)}),this.register(function(t){return new Ub(t)}),this.register(function(t){return new $b(t)}),this.register(function(t){return new zb(t)}),this.register(function(t){return new Zb(t)}),this.register(function(t){return new Wb(t)}),this.register(function(t){return new Db(t)}),this.register(function(t){return new qf(t,st.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new qf(t,st.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Yb(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=zr.extractUrlBase(e);s=zr.resolveURL(c,this.path)}else s=zr.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 ka(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))===Jb){try{s[st.KHR_BINARY_GLTF]=new Kb(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[st.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 iS(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 st.KHR_MATERIALS_UNLIT:s[u]=new Ob;break;case st.KHR_DRACO_MESH_COMPRESSION:s[u]=new Qb(r,this.dracoLoader);break;case st.KHR_TEXTURE_TRANSFORM:s[u]=new eS;break;case st.KHR_MESH_QUANTIZATION:s[u]=new tS;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 cP(){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 $t(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var st={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 Db{constructor(e){this.parser=e,this.name=st.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 Ze(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Un);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new _o(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new go(l),c.distance=u;break;case"spot":c=new ql(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),Vi(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 Ob{constructor(){this.name=st.KHR_MATERIALS_UNLIT}getMaterialType(){return Fi}extendParams(e,t,n){let i=[];e.color=new Ze(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],Un),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Pr))}return Promise.all(i)}}class Ub{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=$t(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class kb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 Ge(r,r)}}return Promise.all(i)}}class Fb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_DISPERSION}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class zb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 Bb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_SHEEN}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Ze(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],Un)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Pr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Vb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 Hb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_VOLUME}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 Ze().setRGB(r[0],r[1],r[2],Un),Promise.all(i)}}class Gb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_IOR}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 $b{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_SPECULAR}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 Ze().setRGB(r[0],r[1],r[2],Un),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Pr));return Promise.all(i)}}class Wb{constructor(e){this.parser=e,this.name=st.EXT_MATERIALS_BUMP}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 Zb{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return $t(this.parser,e,this.name)!==null?zn:null}extendMaterialParams(e,t){let n=$t(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 jb{constructor(e){this.parser=e,this.name=st.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 Xb{constructor(e){this.parser=e,this.name=st.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 qb{constructor(e){this.parser=e,this.name=st.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 qf{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 Yb{constructor(e){this.name=st.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!==Kn.TRIANGLES&&c.mode!==Kn.TRIANGLE_STRIP&&c.mode!==Kn.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 Ke,_=new F,p=new nn,g=new F(1,1,1),y=new ho(f.geometry,f.material,h);for(let x=0;x<h;x++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,x);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,x);if(a.SCALE)g.fromBufferAttribute(a.SCALE,x);y.setMatrixAt(x,m.compose(_,p,g))}let S=null;for(let x in a)if(x==="_COLOR_0"){let b=a[x];y.instanceColor=new Ar(b.array,b.itemSize,b.normalized)}else if(x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"){if(S===null){let M=y.geometry;S=new gn,S.name=M.name;for(let T in M.attributes)S.setAttribute(T,M.attributes[T]);for(let T in M.morphAttributes)S.morphAttributes[T]=M.morphAttributes[T];if(M.index!==null)S.setIndex(M.index);S.morphTargetsRelative=M.morphTargetsRelative;for(let T of M.groups)S.addGroup(T.start,T.count,T.materialIndex);if(M.boundingBox!==null)S.boundingBox=M.boundingBox.clone();if(M.boundingSphere!==null)S.boundingSphere=M.boundingSphere.clone();S.drawRange.start=M.drawRange.start,S.drawRange.count=M.drawRange.count,S.userData=Object.assign({},M.userData),y.geometry=S}let b=a[x];S.setAttribute(x,new Ar(b.array,b.itemSize,b.normalized))}wt.prototype.copy.call(y,f),this.parser.assignFinalMaterial(y),d.push(y)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var Jb="glTF",Wa=12,Ib={JSON:1313821514,BIN:5130562};class Kb{constructor(e){this.name=st.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Wa),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!==Jb)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-Wa,r=new DataView(e,Wa),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===Ib.JSON){let c=new Uint8Array(e,Wa+s,o);this.content=n.decode(c)}else if(a===Ib.BIN){let c=Wa+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Qb{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=st.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=Yf[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Yf[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=So[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,Un,h)})})}}class eS{constructor(){this.name=st.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 tS{constructor(){this.name=st.KHR_MESH_QUANTIZATION}}class Qf extends cr{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-_,y=p-h+u;for(let S=0;S!==o;S++){let x=s[m+S+o],b=s[m+S+a]*l,M=s[f+S+o],T=s[f+S]*l;r[S]=g*x+y*b+_*M+p*T}return r}}var lP=new nn;class nS extends Qf{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return lP.fromArray(r).normalize().toArray(r),r}}var Kn={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},So={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pb={9728:hi,9729:sn,9984:El,9985:oo,9986:ls,9987:Oi},Lb={33071:so,33648:Ml,10497:ro},Zf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yf={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"},Br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},uP={CUBICSPLINE:void 0,LINEAR:Ll,STEP:nf},jf={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function hP(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new ar({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Cr});return e.DefaultMaterial}function vs(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 Vi(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 dP(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 fP(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 pP(e){let t,n=e.extensions&&e.extensions[st.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Xf(n.attributes);else t=e.indices+":"+Xf(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Xf(e.targets[i]);return t}function Xf(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 Jf(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 mP(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 gP=new Ke;class iS{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new cP,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 po(this.options.manager);else this.textureLoader=new Yl(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ka(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 vs(r,o,i),Vi(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[st.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(zr.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=Zf[i.type],o=So[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new rn(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=Zf[i.type],c=So[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,y=t.cache.get(g);if(!y)m=new c(o,p*d,i.count*d/l),y=new Ra(m,d/l),t.cache.add(g,y);_=new uo(y,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 rn(m,a,f)}if(i.sparse!==void 0){let p=Zf.SCALAR,g=So[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,S=i.sparse.values.byteOffset||0,x=new g(s[1],y,i.sparse.count*p),b=new c(s[2],S,i.sparse.count*a);if(o!==null)_=new rn(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let M=0,T=x.length;M<T;M++){let v=x[M];if(_.setX(v,b[M*a]),a>=2)_.setY(v,b[M*a+1]);if(a>=3)_.setZ(v,b[M*a+2]);if(a>=4)_.setW(v,b[M*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=Pb[h.magFilter]||sn,l.minFilter=Pb[h.minFilter]||Oi,l.wrapS=Lb[h.wrapS]||ro,l.wrapT=Lb[h.wrapT]||ro,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==hi&&l.minFilter!==sn,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 Vt(m);_.needsUpdate=!0,h(_)};t.load(zr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return Vi(u,s),u.userData.mimeType=s.mimeType||mP(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[st.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[st.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[st.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 Da,Tn.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,Tn.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 ar}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[st.KHR_MATERIALS_UNLIT]){let u=i[st.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Ze(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],Un),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Pr));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=Yn;let l=r.alphaMode||jf.OPAQUE;if(l===jf.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===jf.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==Fi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ge(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==Fi){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!==Fi){let u=r.emissiveFactor;o.emissive=new Ze().setRGB(u[0],u[1],u[2],Un)}if(r.emissiveTexture!==void 0&&s!==Fi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Pr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(Vi(u,r),t.associations.set(u,{materials:e}),r.extensions)vs(i,u,r);return u})}createUniqueName(e){let t=mt.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[st.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return Nb(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=pP(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[st.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=Nb(new gn,c,t);if(c.mode===Kn.TRIANGLE_STRIP)h=h.then((d)=>Wf(d,Ma));else if(c.mode===Kn.TRIANGLE_FAN)h=h.then((d)=>Wf(d,co));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?hP(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===Kn.TRIANGLES||_.mode===Kn.TRIANGLE_STRIP||_.mode===Kn.TRIANGLE_FAN||_.mode===void 0){let y=r.isSkinnedMesh===!0,S=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(y&&S===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=y&&S?new zl(m,g):new Pt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Kn.LINES)p=new Bl(m,g);else if(_.mode===Kn.LINE_STRIP)p=new Nr(m,g);else if(_.mode===Kn.LINE_LOOP)p=new Vl(m,g);else if(_.mode===Kn.POINTS)p=new fo(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)fP(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),Vi(p,r),_.extensions)vs(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)vs(i,u[0],r);return u[0]}let h=new Pi;if(r.extensions)vs(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 qt(Ea.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new _s(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return Vi(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 Ke;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 Pa(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 y=0,S=h.length;y<S;y++){let x=h[y],b=d[y],M=f[y],T=m[y],v=_[y];if(x===void 0)continue;if(x.updateMatrix)x.updateMatrix();let A=n._createAnimationTracks(x,b,M,T,v);if(A)for(let V=0;V<A.length;V++)p.push(A[V])}let g=new eo(r,void 0,p);return Vi(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,gP)});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 Ca;else if(c.length>1)l=new Pi;else if(c.length===1)l=c[0];else l=new wt;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(Vi(l,r),r.extensions)vs(n,l,r);if(r.matrix!==void 0){let u=new Ke;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 Pi;if(n.name)r.name=i.createUniqueName(n.name);if(Vi(r,n),n.extensions)vs(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(Rb(h));else r.add(h)}let c=(l)=>{let u=new Map;for(let[h,d]of i.associations)if(h instanceof Tn||h instanceof Vt)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(Br[r.path]===Br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Br[r.path]){case Br.weights:l=Ur;break;case Br.rotation:l=kr;break;case Br.translation:case Br.scale:l=gs;break;default:switch(n.itemSize){case 1:l=Ur;break;case 2:case 3:default:l=gs;break}break}let u=i.interpolation!==void 0?uP[i.interpolation]:Ll,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+Br[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=Jf(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 kr?nS:Qf)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function _P(e,t,n){let i=t.attributes,r=new Yt;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=Jf(So[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 _=Jf(So[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 Fn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function Nb(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=Yf[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(nt.workingColorSpace!==Un&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${nt.workingColorSpace}" not supported.`);return Vi(e,t),_P(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?dP(e,t.targets,n):e})}function Hi(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 Vt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function rS(e){Uh(e);let t=new Ua,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new po(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new Kf(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)Hi(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 sS(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 y of i.length?i:[e])for(let S of[y.min.x,y.max.x])for(let x of[y.min.y,y.max.y])for(let b of[y.min.z,y.max.z])l.push(new F(S,x,b));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let y of l){let S=y.clone().sub(r),x=S.dot(a),b=S.dot(c);u=Math.min(u,x),h=Math.max(h,x),d=Math.min(d,b),f=Math.max(f,b)}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 y of l){let S=y.clone().sub(r),x=S.dot(o);p=Math.max(p,x+Math.abs(S.dot(a))*1.12/_,x+Math.abs(S.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function ep(e,t){return{position:e.position.clone(),target:t.clone()}}function tp(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 oS(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 aS(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 cS(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 lS(e,t,n){if(t())return e;n(e);return}function ru(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 su(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Yt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Yt,i=new Yt,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 Yt().setFromObject(e,!0):n}function Za(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 uS(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));ru(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=Za(e.scene)-r.reduce((c,l)=>c+np(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+np(h,l),0));return{chains:r,triangles:a}}var hS=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function np(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return Za(hS(e,t))}function dS(e,t){let n=hS(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 fS(e,t){for(let n of e.chains)dS(n,t)}function pS(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return dS(i,n),!0}function mS(e,t){if(!e)return;return{triangles:Za(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)=>np(n,r))}))}}function wo(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function ip(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function ja(e){let t=new Bf({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=ba,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new lo,i=new qt(40,1,0.01,1000),r=new Gf(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 $a(t),f=new $f,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new _o(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new jl(14806490,5065021,1.7));let p,g,y,S=[],x=!0,b=performance.now(),M=0,T=0,v=!1,A,V,C,N=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},Y=(P)=>{let q=t.getContext(),H=q.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:aS(C.samples),...V===void 0?{}:{loadToFirstFrameMs:V},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(q.getParameter(q.VERSION)),vendor:String(q.getParameter(q.VENDOR)),renderer:String(q.getParameter(q.RENDERER)),browser:navigator.userAgent,...H?{unmaskedVendor:String(q.getParameter(H.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(q.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."]}},D=()=>{if(!p)return;let P=su(p),q=[];p.traverseVisible((pe)=>{if(pe instanceof Pt||pe instanceof Nr||pe instanceof fo){let Be=new Yt().setFromObject(pe,!0);if(!Be.isEmpty())q.push(Be)}});let{center:H,radius:ee,distance:J,position:de}=sS(P,i.aspect,i.fov,q);if(r.target.copy(H),i.position.copy(de),i.near=Math.max(ee/1000,0.0001),i.far=J+ee*100,r.minDistance=ee*0.1,r.maxDistance=ee*80,a=Math.max(ee*0.35,0.01),o)r.minDistance=ee*0.00001;i.updateProjectionMatrix(),r.update()},W=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:q}=e;if(!P||!q)return;t.setSize(P,q),i.aspect=P/q,i.updateProjectionMatrix()});W.observe(e);let z=(P)=>{if(v)return;let q=Math.min((P-b)/1000,0.1);if(b=P,e.clientWidth&&e.clientHeight){if(x)y?.update(q);if(o&&s.size){let H=oS(i,s,q*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(H),r.target.add(H)}if(r.update(),t.render(n,i),A!==void 0)V=performance.now()-A,A=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=Y(P);clearTimeout(C.timeout),C.resolve(H),C=void 0}}}else s.clear(),N("Keep the measured viewport visible for the complete sampling window.");M=requestAnimationFrame(z)};return M=requestAnimationFrame(z),{async load(P,q={}){let H=performance.now(),ee=++T;N("The artifact changed during measurement. Measure the new revision again.");let J=await rS(P);ru(J,[J.scene]);let de=await uS(J);try{J.assertTexturesLoaded()}catch(te){Hi(J.scene);for(let se of wo(de))Hi(se);throw te}let pe=lS(J,()=>!v&&ee===T&&q.isCurrent?.()!==!1,(te)=>{Hi(te.scene);for(let se of wo(de))Hi(se)});if(!pe)return;let Be=p&&q.preserveView?ep(i,r.target):void 0;if(p){y?.stopAllAction(),y?.uncacheRoot(p),n.remove(p),Hi(p);for(let te of wo(g))Hi(te)}p=pe.scene,g=de,A=H,V=void 0,n.add(p),S=pe.animations,y=new Jl(p),x=!0;let{clientWidth:me,clientHeight:X}=e;if(t.setSize(me,X),i.aspect=me&&X?me/X:i.aspect,D(),Be)tp(i,r.target,Be,su(p)),r.update();let L=0,G=new Set;return p.traverseVisible((te)=>{let se=te;if(!se.isMesh)return;L++;for(let ce of Array.isArray(se.material)?se.material:[se.material])G.add(ce)}),q.onCommit?.(),{triangles:Za(p),meshes:L,materials:G.size,clips:S.map((te)=>te.name),...g?{levels:g.triangles}:{}}},level(P){if(N("The level of detail changed. Measure the displayed combination again."),g)fS(g,P)},partLevel(P,q){if(N("The level of detail changed. Measure the displayed combination again."),g)pS(g,P,q)},lod(){return p?mS(g,p):void 0},reset:D,cancelMeasurement:N,measure(P=3000){if(v||!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((q,H)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:q,reject:H,timeout:setTimeout(()=>N("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return ep(i,r.target)},setView(P){if(!p)return;tp(i,r.target,P,su(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 q of p?[p,...wo(g)]:[])q.traverse((H)=>{let ee=H;if(ee.isMesh){for(let J of Array.isArray(ee.material)?ee.material:[ee.material])if("wireframe"in J)J.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(y?.stopAllAction(),S[P])y?.clipAction(S[P]).play()},pause(P){x=!P},dispose(){if(N("The viewport closed before measurement finished."),v=!0,T++,cancelAnimationFrame(M),W.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)Hi(p);for(let P of wo(g))Hi(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var ae=(e)=>document.getElementById(e);function I(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function un(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 Mo(e,t){let n=I("div",void 0,"empty");return n.append(I("b",e),I("p",t)),n}function pi(e,t){try{localStorage.setItem(e,t)}catch{}}function Vr(e){try{return localStorage.getItem(e)}catch{return null}}function on(e){return e?e.slice(0,15):"Unspecified"}function Eo(e,t){let n=I("details",void 0,"record-details");return n.append(I("summary",e),I("pre",JSON.stringify(t,null,2))),n}function Xa(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(...ip(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=I("p","","lod-total");o.setAttribute("role","status"),t.append(o);let a=new Map;if(r.chains.length>1){let l=I("details",void 0,"lod-parts");l.append(I("summary","Per-part levels")),l.append(I("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=I("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,_=I("label",m,"inline-field"),p=I("select");p.setAttribute("aria-label",`${m} level of detail`),p.append(...ip(f.triangles).map((g,y)=>new Option(g,String(y)))),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 gS=/^[a-z][a-z0-9_-]{0,79}$/u,xP=/^r_[a-z0-9_-]{1,77}$/u;function _S(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!gS.test(n)||!gS.test(i)||!xP.test(r))return;return{collection:n,assetId:i,revisionId:r}}var xS=new TextEncoder,vP=new TextDecoder,Ao=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),rp=(e,t)=>Object.hasOwn(e,t);async function vS(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 yP(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 yS(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");jc(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";yP(r);for(let[y,S]of Object.entries(e.files))if(await vS(S)!==e.manifest.files[y].sha256)throw Error(`Asset integrity mismatch: ${y}`);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 y=s.getUint32(o,!0);if(y%4||o+8+y>i.length)throw Error("Invalid GLB chunk length");o+=8+y}let a=20+s.getUint32(12,!0),c=JSON.parse(vP.decode(i.subarray(20,a)));if(!Ao(c)||!Ao(c.asset)||c.asset.version!=="2.0")throw Error("Invalid glTF asset");let l=c.asset;if(rp(l,"extras")&&!Ao(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(rp(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[y,S]of(c.scenes??[]).entries()){if(!Ao(S)||!Ao(S.extras)||!rp(S.extras,"kilnReviewClipsV1"))continue;let x=S.extras.kilnReviewClipsV1;if(!Ao(x)||x.version!==1&&x.version!==2||!Array.isArray(x.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");h.push({index:y,kilnReviewClipsV1:x}),delete S.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=xS.encode(JSON.stringify(d));l.extras={...u,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",metadata:{uri:r,sha256:await vS(f)}}};let m=xS.encode(JSON.stringify(c)),_=Math.ceil(m.length/4)*4,p=new Uint8Array(20+_+i.length-a);if(p.length>Zn||f.length>Zn)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 mi=Ne().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"),sp=Ne().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),wS=Ne().regex(/^sha256:[a-f0-9]{64}$/),To=Ne().max(4000),MS=Ne().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),bS=_e({collectionId:mi,assetId:mi,revisionId:mi}).strict(),SS=_e({style:To.default(""),scale:Ne().max(1000).default(""),palette:tt(_e({role:Ne().min(1).max(100),color:Ne().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:tt(_e({role:Ne().min(1).max(100),description:To.default(""),resourceId:MS.optional()}).strict()).max(128).default([]),conventions:tt(Ne().max(1000)).max(100).default([]),exceptions:tt(Ne().max(1000)).max(100).default([])}).strict(),bP=_e({resourceId:MS,revisionId:Ne().min(1).max(200),sha256:wS,role:Ne().max(100).optional()}).strict(),SP=tt(bP).max(512),Gi={name:Ne().trim().min(1).max(200),brief:Ne().max(16000).default(""),design:SS.default(()=>SS.parse({})),inventory:tt(_e({id:mi,name:Ne().trim().min(1).max(200),kind:Tt(["asset","environment"]).default("asset"),brief:To.default(""),references:tt(mi).max(64).default([]),asset:bS.optional()}).strict()).max(1000).default([]),deliveryProfiles:tt(_e({id:mi,target:Tt(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:To.default(""),performanceIntent:Ne().max(1000).default(""),constraints:tt(Ne().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:SP.default([]),references:tt(_e({id:mi,title:Ne().min(1).max(200),uri:Ne().min(1).max(2048),description:To.default(""),sha256:wS.optional()}).strict()).max(256).default([]),reviews:tt(_e({id:mi,inventoryId:mi,projectRevisionId:sp,asset:bS,reviewer:Ne().trim().min(1).max(200),verdict:Tt(["comment","changes-requested","accepted"]),notes:To}).strict()).max(2000).default([])};function ES(e,t){let n=(o,a)=>{if(new Set(o).size!==o.length)t.addIssue({code:Dc.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:Dc.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((o)=>!r.has(o.inventoryId)))t.addIssue({code:Dc.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((o)=>o.resourceId&&!s.has(o.resourceId)))t.addIssue({code:Dc.custom,path:["design"],message:"Material role requires a locked resource"})}var AS=_e({projectId:mi.optional(),...Gi}).strict().superRefine(ES),B3=_e({name:Gi.name.optional(),brief:Gi.brief.removeDefault().optional(),design:Gi.design.removeDefault().optional(),inventory:Gi.inventory.removeDefault().optional(),deliveryProfiles:Gi.deliveryProfiles.removeDefault().optional(),materialDependencies:Gi.materialDependencies.removeDefault().optional(),references:Gi.references.removeDefault().optional(),reviews:Gi.reviews.removeDefault().optional()}).strict(),V3=_e({version:He("kiln.project.v1"),projectId:mi,revisionId:sp,parentRevision:sp.optional(),createdAt:Ne().datetime(),...Gi}).strict().superRefine(ES);function TS(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 RS(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 AS.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function CS(e){let t=[],n=Vr("kiln.project")??"",i,r=()=>{let c=ae("project-list");c.replaceChildren();for(let S of t){let x=I("button",void 0,S.projectId===n?"active":"");if(x.append(I("strong",S.name),I("small",`${S.inventory.length} inventory items · ${S.materialDependencies.length} resources`)),S.projectId===n)x.setAttribute("aria-current","true");x.onclick=()=>{n=S.projectId,pi("kiln.project",n),r()},c.append(x)}let l=t.find((S)=>S.projectId===n),u=ae("project-detail");if(u.replaceChildren(),!l){u.append(Mo("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=I("div",void 0,"project-summary"),d=I("div");d.append(I("h2",l.name),I("p",l.brief||"Add a brief to describe what this project should deliver."));let f=I("button","Edit project","secondary");f.onclick=()=>o(l),h.append(d,f),u.append(h);let m=I("p",`${l.projectId} · ${on(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(m);let _=I("div",void 0,"project-metrics");for(let[S,x]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let b=I("div");b.append(I("strong",String(S)),I("span",String(x))),_.append(b)}u.append(_);let p=I("div",void 0,"profile-grid");for(let[S,x]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let b=I("div");b.append(I("span",S,"label"),I("p",x)),p.append(b)}u.append(p);let g=I("div",void 0,"palette");for(let S of l.design.palette){let x=I("div",void 0,"swatch"),b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("viewBox","0 0 24 24"),b.setAttribute("aria-hidden","true");let M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("width","24"),M.setAttribute("height","24"),M.setAttribute("fill",S.color),b.append(M);let T=I("span",S.role);T.append(I("small",S.color)),x.append(b,T),g.append(x)}if(g.childElementCount)u.append(g);for(let[S,x]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!x.length)continue;u.append(I("h3",S));let b=I("ul",void 0,"subtle");for(let M of x)b.append(I("li",M));u.append(b)}if(u.append(I("h3","Inventory")),!l.inventory.length)u.append(I("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let S=I("div",void 0,"table-wrap"),x=I("table"),b=I("thead"),M=I("tr");for(let v of["Item","Kind","Saved revision","Review"])M.append(I("th",v));b.append(M),x.append(b);let T=I("tbody");for(let v of l.inventory){let A=I("tr"),V=I("td",v.name);V.append(I("small",v.brief));let C=I("td"),N=I("td");if(v.asset){let Y=I("button",on(v.asset.revisionId),"secondary");Y.onclick=()=>e.openAsset(v.asset),C.append(Y);let D=[...l.reviews].reverse().find((z)=>z.inventoryId===v.id&&z.asset.revisionId===v.asset.revisionId&&z.asset.assetId===v.asset.assetId&&z.asset.collectionId===v.asset.collectionId);N.append(I("small",D?`${D.verdict} · ${D.reviewer}`:"Unreviewed"));let W=I("button","Record review","secondary");W.onclick=()=>a(l,v),N.append(W)}else C.textContent="Not linked",N.textContent="No saved revision";A.append(V,I("td",v.kind),C,N),T.append(A)}x.append(T),S.append(x),u.append(S)}if(l.design.materialRoles.length){u.append(I("h3","Material roles"));for(let S of l.design.materialRoles)u.append(I("p",`${S.role}: ${S.description||"No description"}${S.resourceId?` · ${S.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(I("h3","Delivery intent"));for(let S of l.deliveryProfiles){if(u.append(I("p",`${S.target} · ${S.description||S.id}`,"subtle")),S.performanceIntent)u.append(I("p",S.performanceIntent,"subtle"));for(let x of S.constraints)u.append(I("p",x,"subtle"))}u.append(I("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(I("h3","Reference records"));for(let S of l.references){let x=I("p",`${S.title}: ${S.uri}`,"subtle");if(S.description)x.append(I("small",` · ${S.description}`));u.append(x)}}u.append(I("h3","Project downloads"));let y=I("div",void 0,"downloads");for(let S of["editable","runtime"]){let x=I("a",S==="editable"?"Download editable project bundle":"Download runtime project bundle"),b=new URLSearchParams({profile:S,revision:l.revisionId});x.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${b}`,x.download=`${l.projectId}-${S}.zip`,y.append(x)}y.append(I("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(y),u.append(Eo("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(TS(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=I("dialog"),h=I("form"),d=I("div",void 0,"editor-content"),f=I("h2",`Review ${l.name}`);f.id="review-dialog-title",u.setAttribute("aria-labelledby",f.id),d.append(f,I("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),I("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let m=I("input");m.required=!0,m.value=Vr("kiln.reviewer")??"",m.maxLength=200;let _=I("label","Reviewer","field");_.append(m);let p=I("select");for(let[T,v]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])p.append(new Option(v,T));let g=I("label","Assessment","field");g.append(p);let y=I("textarea");y.rows=4,y.maxLength=4000;let S=I("label","Notes","field");S.append(y);let x=I("p");x.setAttribute("role","status");let b=I("button","Save review");b.type="submit";let M=I("button","Cancel","secondary");M.type="button",M.onclick=()=>u.close(),d.append(_,g,S,x,b,M),h.append(d),u.append(h),document.body.append(u),u.addEventListener("close",()=>u.remove()),h.onsubmit=async(T)=>{T.preventDefault(),b.disabled=!0,x.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:y.value}]}}}),pi("kiln.reviewer",m.value.trim()),u.close(),await s()}catch(v){x.textContent=v instanceof Error?v.message:String(v)}finally{b.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=RS(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,pi("kiln.project",n),ae("project-editor").close(),un("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}}var wP="Raw map pixels · unshaded · not GPU capture evidence",op=/^[a-z][a-z0-9_-]{0,79}$/,ap=/^sha256:[a-f0-9]{64}$/;function qa(e){let t=new URLSearchParams(e.startsWith("?")?e:e.slice(e.indexOf("?")+1)),n=t.get("material"),i=t.get("materialRevision");if(t.getAll("material").length!==1||t.getAll("materialRevision").length!==1||!n||!i||!op.test(n)||!ap.test(i))return;return{materialId:n,revisionId:i}}function ou(e){if(!op.test(e.materialId)||!ap.test(e.revisionId))throw Error("Invalid exact material selection");return`/?${new URLSearchParams({material:e.materialId,materialRevision:e.revisionId})}`}function cp(e){if(!op.test(e.materialId)||!ap.test(e.revisionId))throw Error("Invalid exact material selection");return`/api/materials/${encodeURIComponent(e.materialId)}/${encodeURIComponent(e.revisionId)}`}function IS(e){let t=Us(e),n=cp(t),i=t.maps.map((r)=>{let s="recipe"in r?r:void 0,o=s?.recipe?.kind==="atlas"?s.recipe:void 0;return{slot:r.slot,file:r.file,url:`${n}/${encodeURIComponent(r.file)}`,width:r.width,height:r.height,colorSpace:r.colorSpace,imageSha256:r.sha256,..."pixelHash"in r?{pixelHash:r.pixelHash}:{},..."sampler"in r?{sampler:{...r.sampler}}:{},atlas:!!o,...s?.recipe?{compilerId:s.recipe.compilerId}:{},...o?{manifestHash:o.manifest.manifestHash}:{},regions:o?o.manifest.regions.map((a)=>({name:a.name,content:{...a.content},allocation:{...a.allocation},leftPercent:a.content.x/r.width*100,topPercent:a.content.y/r.height*100,widthPercent:a.content.width/r.width*100,heightPercent:a.content.height/r.height*100})):[]}});return{materialId:t.materialId,revisionId:t.revisionId,name:t.name,fidelity:wP,maps:i}}function PS(e,t){if(!e||typeof e!=="object"||Array.isArray(e)||e.artifactGlbSha256!==t)throw Error("Retained evaluation does not identify the displayed artifact");let n=e.materialLibraryDependencies;if(n===void 0)return[];if(!Array.isArray(n)||n.length>16)throw Error("Invalid retained material dependency list");let i=new Map;for(let r of n){let s=Us(r),o=`${s.materialId}/${s.revisionId}`,a=i.get(o);if(a&&Zt(a)!==Zt(s))throw Error("Conflicting retained material identity");i.set(o,s)}return[...i.values()]}function au(e){let t=IS(e),n=I("section",void 0,"material-inspection");n.setAttribute("aria-label",`${t.name}: exact material maps`),n.append(I("p",`${t.materialId} · ${t.revisionId}`,"mono"),I("p",t.fidelity,"subtle"));let i=I("div",void 0,"material-inspection-controls"),r=(b,M)=>{let T=I("label",b,"inline-field");return T.append(M),i.append(T),M},s=r("Map",I("select"));for(let b of t.maps)s.append(new Option(`${b.slot}${b.atlas?" · atlas":""}`,b.slot));let o=r("Backdrop",I("select"));for(let b of["checker","light","dark"])o.append(new Option(b[0].toUpperCase()+b.slice(1),b));let a=r("Pixel zoom",I("select"));for(let b of[1,2,4])a.append(new Option(`${b}×`,String(b)));let c=I("div",void 0,"material-pixel-frame"),l=I("div",void 0,"material-pixel-sheet");c.dataset.backdrop="checker",c.tabIndex=0;let u=I("img");u.className="material-pixel-image",u.loading="lazy",u.draggable=!1;let h=I("div",void 0,"material-region-overlay"),d=I("label","Region overlays","inline-field"),f=I("input");f.type="checkbox",f.checked=!1,d.append(f),i.append(d),f.onchange=()=>{h.hidden=!f.checked},l.append(u,h),c.append(l);let m=I("p",void 0,"subtle");m.setAttribute("role","status");let _=I("dl"),p=I("div",void 0,"material-region-list"),g=I("a","Open this saved material revision");g.href=ou(t),g.target="_blank",g.rel="noopener",n.append(i,c,m,_,p,g);let y=t.maps[0],S=()=>{l.style.width=`${y.width*Number(a.value)}px`,l.style.height=`${y.height*Number(a.value)}px`},x=()=>{y=t.maps.find((M)=>M.slot===s.value)??t.maps[0],d.hidden=!y.atlas,h.hidden=!y.atlas||!f.checked,m.textContent="Loading exact saved map…",u.alt=`${t.name}: ${y.slot}${y.atlas?" atlas sheet":""}, raw unshaded pixels`,u.width=y.width,u.height=y.height,u.src=y.url,S(),_.replaceChildren();let b=(M,T)=>_.append(I("dt",M),I("dd",T));if(b("Image",`${y.width} × ${y.height} · ${y.colorSpace} · nearest pixel display`),b("Sampling declaration",y.sampler?`${y.sampler.minFilter} / ${y.sampler.magFilter} · ${y.sampler.wrapS} / ${y.sampler.wrapT}`:"Not recorded in V1"),b("PNG hash",y.imageSha256),y.pixelHash)b("Decoded RGBA hash",y.pixelHash);if(y.compilerId)b("Compiler",y.compilerId);if(y.manifestHash)b("Atlas manifest hash",y.manifestHash);if(h.replaceChildren(),p.replaceChildren(),y.atlas){p.append(I("h4","Atlas regions · top-left pixel coordinates"));for(let M of y.regions){let T=I("span",void 0,"material-region-box");T.style.left=`${M.leftPercent}%`,T.style.top=`${M.topPercent}%`,T.style.width=`${M.widthPercent}%`,T.style.height=`${M.heightPercent}%`,T.append(I("span",M.name)),T.setAttribute("aria-hidden","true"),h.append(T);let v=I("button",`${M.name}: content ${M.content.x},${M.content.y} ${M.content.width}×${M.content.height}; allocation ${M.allocation.x},${M.allocation.y} ${M.allocation.width}×${M.allocation.height}`,"secondary");v.type="button",v.setAttribute("aria-pressed","false"),v.onclick=()=>{for(let A of h.children)A.classList.remove("selected");for(let A of p.querySelectorAll("button"))A.setAttribute("aria-pressed","false");if(T.classList.add("selected"),v.setAttribute("aria-pressed","true"),!h.hidden)T.scrollIntoView({block:"nearest",inline:"nearest"})},p.append(v)}}};return u.onload=()=>{m.textContent="Raw map loaded. These pixels are not a shaded capture."},u.onerror=()=>{m.textContent=`Exact ${t.materialId} revision map unavailable. No newer revision was substituted.`},s.onchange=x,o.onchange=()=>{c.dataset.backdrop=o.value},a.onchange=S,x(),n}function LS(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 NS(e){let t=[],n=[],i=[],r=ae("materials-project"),s=I("button","Create from preset");ae("materials-refresh").before(s);let o=I("dialog");o.setAttribute("aria-labelledby","material-preset-heading");let a=I("form"),c=I("div",void 0,"detail-top"),l=I("h2","Create a material resource");l.id="material-preset-heading";let u=I("button","Cancel","secondary");u.type="button",u.onclick=()=>o.close(),c.append(l,u);let h=I("div",void 0,"editor-content");h.append(I("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 Y=I("label",C,"field");return Y.append(N),h.append(Y),N}let f=d("Preset",I("select")),m=I("p",void 0,"subtle");h.append(m);let _=d("Seed",I("input"));_.type="number",_.step="1",_.required=!0,_.min="-2147483648",_.max="2147483647",_.value="0";let p=d("Map size",I("select"));for(let C of[64,128,256,512])p.append(new Option(`${C} × ${C}`,String(C)));p.value="256";let g=d("Creator",I("input"));g.required=!0,g.maxLength=1000;let y=d("License identifier",I("input"));y.required=!0,y.placeholder="For example, CC0-1.0";let S=d("License URL",I("input"));S.type="url",S.required=!0;let x=d("Attribution text",I("textarea"));x.rows=2;let b=I("p");b.setAttribute("role","status");let M=I("button","Create resource");M.type="submit",h.append(b,M),a.append(c,h),o.append(a),document.body.append(o);let T=()=>{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=T,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))),T(),b.textContent="",M.disabled=!i.length,o.showModal()}catch(C){un(C)}finally{s.disabled=!1}},a.onsubmit=async(C)=>{C.preventDefault(),M.disabled=!0,b.textContent="Creating immutable material resource…";try{let N=LS({presetId:f.value,seed:_.value,size:p.value,creator:g.value,spdx:y.value,url:S.value,attribution:x.value}),Y=await Xt("/api/materials/preset",{method:"POST",body:N});await V(),o.close(),un(`${Y.material.name} created at ${Y.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(N){b.textContent=N instanceof Error?N.message:String(N)}finally{M.disabled=!1}};let v=cp;function A(){let C=n.find((z)=>z.projectId===r.value),N=ae("material-dependencies");if(N.replaceChildren(),C)if(N.append(I("h2",`${C.name}: locked resources`)),!C.materialDependencies.length)N.append(I("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let z=I("table"),P=I("thead"),q=I("tr"),H=I("tbody");for(let J of["Resource / role","Exact revision","Local availability"])q.append(I("th",J));P.append(q),z.append(P);for(let J of C.materialDependencies){let de=t.find((me)=>me.materialId===J.resourceId&&me.revisionId===J.revisionId),pe=I("tr"),Be=I("td",J.resourceId);Be.append(I("small",J.role??C.design.materialRoles.filter((me)=>me.resourceId===J.resourceId).map((me)=>me.role).join(", "))),pe.append(Be,I("td",J.revisionId,"mono"),I("td",de&&de.revisionId===J.sha256?"Exact local record available":de?"Dependency hash differs":"Not in local catalog")),H.append(pe)}z.append(H);let ee=I("div",void 0,"table-wrap");ee.append(z),N.append(ee)}let Y=ae("material-list");Y.replaceChildren();let D=ae("material-search").value.trim().toLowerCase(),W=t.filter((z)=>`${z.name} ${z.materialId} ${z.tags.join(" ")} ${z.sources.map((P)=>P.provider).join(" ")}`.toLowerCase().includes(D));if(ae("material-count").textContent=`${W.length} material revision${W.length===1?"":"s"}`,!W.length){Y.append(Mo(D?"No matching materials":"Your material catalog starts here",D?"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 z of W){let P=I("article",void 0,"material-card"),q=z.maps.find((L)=>L.slot==="baseColor")??z.maps[0];if(q){let L=I("img");L.src=`${v(z)}/${encodeURIComponent(q.file)}`,L.alt=`${z.name}: ${q.slot} map, not a shaded material preview`,L.loading="lazy",L.className="material-map",P.append(L,I("p",`${q.slot} map · unshaded`,"subtle"))}P.append(I("h3",z.name),I("p",z.tags.join(" · "),"subtle"));let H=I("dl"),ee=(L,G)=>H.append(I("dt",L),I("dd",G));ee("Revision",z.revisionId),ee("Physical scale",z.physicalSizeMeters?`${z.physicalSizeMeters.width} × ${z.physicalSizeMeters.height} m`:"Not specified"),ee("Tiling",z.tileable?"Declared tileable":"Not declared tileable"),ee("Maps",z.maps.map((L)=>`${L.slot} ${L.width}×${L.height} (${L.colorSpace})`).join(" · ")),ee("Surface factors",`Roughness ×${z.parameters.roughness} · Metalness ×${z.parameters.metalness}${z.maps.some((L)=>L.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),P.append(H);for(let L of z.sources){let G=I("p",`${L.provider} · ${L.creator} · ${L.kind}`,"subtle"),te=I("a",L.license.spdx);if(te.href=L.license.url,te.target="_blank",te.rel="noreferrer",G.append(document.createTextNode(" · "),te),L.assetUrl){let se=I("a","Source");se.href=L.assetUrl,se.target="_blank",se.rel="noreferrer",G.append(document.createTextNode(" · "),se)}if(P.append(G),L.license.attribution)P.append(I("p",L.license.attribution,"subtle"))}let J=I("div",void 0,"material-map-links");for(let L of z.maps){let G=I("a",L.slot);G.href=`${v(z)}/${encodeURIComponent(L.file)}`,G.target="_blank",G.rel="noopener",J.append(G)}P.append(J);let de=I("details",void 0,"material-map-inspection");de.append(I("summary","Inspect maps and atlas regions"));let pe=!1;de.ontoggle=()=>{if(de.open&&!pe)pe=!0,de.append(au(z))};let Be=qa(location.search);if(Be?.materialId===z.materialId&&Be.revisionId===z.revisionId)de.open=!0,P.dataset.selectedMaterial="true";P.append(de);let me=C?.materialDependencies.find((L)=>L.resourceId===z.materialId),X=I("button",me?.revisionId===z.revisionId?"Locked to project":me?"Use this revision":"Add to project","secondary");if(X.disabled=!C||me?.revisionId===z.revisionId,!C)X.title="Select a project to add a material dependency";X.onclick=async()=>{if(!C)return;X.disabled=!0;try{let L=C.materialDependencies.filter((G)=>G.resourceId!==z.materialId);L.push({resourceId:z.materialId,revisionId:z.revisionId,sha256:z.revisionId,...me?.role?{role:me.role}:{}}),await Xt(`/api/projects/${encodeURIComponent(C.projectId)}`,{method:"PATCH",body:{expectedRevision:C.revisionId,patch:{materialDependencies:L}}}),un(`${z.name} is locked to ${C.name} at this exact revision.`),await e()}catch(L){un(L),X.disabled=!1}},P.append(X,Eo("Map recipes, transformations and provenance",z)),Y.append(P)}}let V=async()=>{t=(await Xt("/api/materials")).materials,A();let C=qa(location.search);if(C&&!t.some((N)=>N.materialId===C.materialId&&N.revisionId===C.revisionId))un(`Exact material revision unavailable: ${C.materialId} at ${C.revisionId}. No newer revision was selected.`)};return ae("material-search").oninput=A,r.onchange=A,ae("materials-refresh").onclick=()=>void V().catch(un),{refresh:V,projects(C){n=C;let N=r.value;r.replaceChildren(new Option("All materials",""));for(let Y of n)r.append(new Option(Y.name,Y.projectId));if(n.some((Y)=>Y.projectId===N))r.value=N;A()}}}function lp(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var DS=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function Ya(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(DS),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&&DS(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 up(e,t){return Ya({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Hr(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 OS(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Hr(e,Hr(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 cu(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(I("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(I("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let o=await cS(()=>s.measure(3000),i),a=I("div",void 0,"evidence-card");a.append(I("h3","Exploratory browser measurement"),I("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),I("strong",`p50 ${o.frameMs.p50.toFixed(1)} ms · p95 ${o.frameMs.p95.toFixed(1)} ms`),I("p",`${o.frameMs.samples} frame intervals · ${(o.windowMs/1000).toFixed(2)} s · ${o.drawCalls} draws · ${o.triangles.toLocaleString()} rendered triangles`),I("p",`${o.geometryObjects} geometry objects · ${o.textureObjects} texture objects. These counts are not GPU memory bytes.`),I("p",`GLB parse to first frame submission: ${o.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),I("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=Eo("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=I("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",a.append(c,l),t.replaceChildren(a)}catch(o){t.replaceChildren(I("p",o instanceof Error?o.message:String(o),"subtle"))}finally{e.disabled=!1}}}function hp(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 Ja(e,t,n,i){e.replaceChildren(I("h3","Project membership"));let{projects:r}=await Xt("/api/projects");if(!e.isConnected)return;let s=I("div");e.append(s);let o=I("p");o.setAttribute("role","status");let a=()=>Ja(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=I("div",void 0,"membership-row");g.append(I("span",`${_.name} / ${p.name} · ${on(p.asset.revisionId)}${p.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let y=I("button","Remove membership","secondary");y.onclick=async()=>{y.disabled=!0;try{await Xt(`/api/projects/${encodeURIComponent(_.projectId)}`,{method:"PATCH",body:{expectedRevision:_.revisionId,patch:hp(_,p.id,null,n)}}),await i(),await a()}catch(S){o.textContent=`${S instanceof Error?S.message:S} Reopen membership to load the current project.`,y.disabled=!1}},g.append(y),s.append(g)}if(!s.childElementCount)s.append(I("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(I("p","Create a named project in Projects to organize related assets."));return}let c=I("form"),l=I("select"),u=I("select"),h=I("label","Project","field"),d=I("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=I("button","Link this exact revision");m.type="submit",c.append(h,d,I("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((y)=>y.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:hp(p,g,t,n)}}),await i(),await a()}catch(y){o.textContent=`${y instanceof Error?y.message:y} Reopen membership to load the current project.`,m.disabled=!1}},s.append(c)}function US(){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,y,S=ae("live-project"),x=ae("live-source"),b=(L)=>x.value?`${L}${L.includes("?")?"&":"?"}source=${encodeURIComponent(x.value)}`:L,M=ae("live-run"),T=ae("live-work"),v=()=>`kiln.live.selection.${x.value}.${S.value}.${T.value}.${M.value}`,A=()=>`kiln.live.pin.${x.value}`,V=()=>t.filter((L)=>(!M.value||L.sessionId===M.value)&&(!T.value||(T.value==="ungrouped"?!L.workId:L.workId===T.value))),C=(L,G)=>{let te=ae("live-connection");te.textContent=L?"Connected":"Reconnecting",te.className=`pill ${L?"connected":"warning"}`,ae("connection-status").textContent=G};function N(){let L=T.value,G=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(T.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...G.map((ce)=>new Option(ce,ce))),L==="ungrouped"||G.includes(L))T.value=L;let te=M.value,se=[...new Set(t.map((ce)=>ce.sessionId))];M.replaceChildren(new Option("All runs",""));for(let ce of se){let Ae=t.find((Te)=>Te.sessionId===ce);M.append(new Option(`${Ae.transport} · ${on(ce)}`,ce))}if(se.includes(te))M.value=te}function Y(){let L=ae("live-timeline"),G=L.scrollTop,te=L.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(L.replaceChildren(),!e.operations.length){L.append(Mo("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=I("button",void 0,`timeline-item ${se.status}${e.selected?.operationId===se.operationId?" selected":""}${se.pinned?" pinned":""}`);ce.dataset.operation=se.operationId;let Ae=I("span",void 0,"timeline-meta");if(Ae.append(I("span",se.transport.toUpperCase()),I("time",new Date(se.startedAt).toLocaleTimeString())),ce.append(Ae,I("strong",se.tool.replace(/^kiln_/,"")),I("small",`${se.status} · ${se.artifact?"artifact available":"no artifact"}`),I("small",se.workId?`Item ${se.workId}`:`Ungrouped · run ${on(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=up(e,se.operationId),pi(v(),se.operationId),J()},L.append(ce),te===se.operationId)ce.focus({preventScroll:!0})}L.scrollTop=G}function D(L){let G=I("div",void 0,"evidence-card");G.append(I("h3","Capture fidelity"));let te=L.viewFidelity,se=te&&typeof te==="object"?te:void 0;if(G.append(I("strong",se?String(se.delivered??"Reported"):"No capture receipt yet")),G.append(I("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)G.append(I("p",String(se.degradeReason)));if(se?.rendererId)G.append(I("p",`Renderer: ${String(se.rendererId)}`,"mono"));if(se?.inputGlbSha256)G.append(I("p",`Capture input: ${String(se.inputGlbSha256)}`,"mono"));if(se)G.append(I("p",se.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return G}function W(){let L=ae("live-evidence"),G=ae("live-downloads");L.replaceChildren(),G.replaceChildren();let te=e.displayed;if(!te?.artifact){y=void 0;return}let se=I("div",void 0,"evidence-card");se.append(I("h3","Selected observed artifact"),I("strong",`${(te.artifact.bytes/1024).toFixed(0)} KB GLB`),I("p",te.artifact.sha256,"mono"),I("p",`Source: ${te.programRef??"See authored source download"}`,"mono")),L.append(se,D(te));let ce=`${x.value}/${te.operationId}/${te.artifact.sha256}`;if(y?.key!==ce){let Ae=I("div",void 0,"evidence-card live-material-inspection"),Te=I("button","Inspect exact material inputs","secondary");Ae.append(I("h3","Materials and atlas sheets"),I("p","Declared inputs for this displayed artifact. Raw sheets are unshaded; capture fidelity is reported separately."),Te),y={key:ce,card:Ae},Te.onclick=async()=>{Te.disabled=!0;let Ue=I("p","Reading the displayed artifact evaluation…");Ue.setAttribute("role","status"),Ae.append(Ue);try{let $e=await Xt(b(`/api/live/${encodeURIComponent(te.operationId)}/evaluation.json`));if(y?.key!==ce)return;let Xe=PS($e,te.artifact.sha256);Ue.textContent=Xe.length?"Exact declared revisions. Map images require the matching record in this local material library.":"No saved material resource declarations in this artifact. Embedded textures can still be viewed in the viewport.";for(let Ot of Xe){let rt=I("details");rt.append(I("summary",`${Ot.name} · ${Ot.revisionId}`));let Mt=!1;rt.ontoggle=()=>{if(rt.open&&!Mt)Mt=!0,rt.append(au(Ot))},Ae.append(rt)}}catch($e){if(y?.key!==ce)return;Ue.textContent=`Material inspection unavailable for this exact artifact: ${$e instanceof Error?$e.message:String($e)}`,Te.disabled=!1}}}if(L.append(y.card),te.captures.length)for(let Ae of te.captures){let Te=I("div",void 0,"evidence-card");Te.append(I("h3",Ae.name));let Ue=te.viewFidelity&&typeof te.viewFidelity==="object"?te.viewFidelity:void 0;Te.append(I("p",Ue?.materialFaithful===!0?`Recorded capture · ${String(Ue.delivered??"material-faithful")}`:`Recorded capture · ${String(Ue?.delivered??"fidelity unreported")}. Materials are not verified.`,Ue?.materialFaithful===!0?"subtle":"warning"));let $e=I("a"),Xe=I("img");Xe.src=Ae.url,Xe.alt=`Recorded ${Ae.name} for ${te.tool}`,Xe.loading="lazy",$e.href=Ae.url,$e.target="_blank",$e.rel="noopener",$e.append(Xe),Te.append($e,I("p",Ae.sha256,"mono")),L.append(Te)}else{let Ae=I("div",void 0,"evidence-card");Ae.append(I("h3","Recorded captures"),I("p",te.status==="evaluated"||te.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),L.append(Ae)}for(let[Ae,Te,Ue]of[[te.artifact.url,"Observed GLB","asset.glb"],[b(`/api/live/${encodeURIComponent(te.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let $e=I("a",Te);$e.href=Ae,$e.download=Ue,G.append($e)}G.append(I("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 L=Hr(e.displayed,l);ae("pin-build").disabled=!L,Be.disabled=L?.status!=="complete"}function P(){if(h&&l)ae("live-stage-label").textContent=lp(h,on(l.operationId),a?.lod())}function q(){if(d&&u)ae("compare-stage-label").textContent=`Pinned · ${lp(d,on(u.operationId),c?.lod())}`}async function H(L){if(ae("live-panel").hidden)return;let G=++m;if(!Hr(L,l))a?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!L?.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",z();return}if(l?.artifact?.sha256===L.artifact.sha256){l=L,ae("live-stage-status").textContent="",P(),z();return}ae("live-stage-status").textContent=`Loading ${on(L.operationId)}…${l?` Previous artifact ${on(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let te=await fetch(L.artifact.url);if(!te.ok)throw Error("This retained artifact is no longer available");let se=new Uint8Array(await te.arrayBuffer());if(G!==m)return;a??=ja(ae("live-stage"));let ce=await a.load(se,{isCurrent:()=>G===m,onCommit:()=>{l=L},preserveView:l?.projectId===L.projectId&&(l?.sessionId===L.sessionId||e.following)});if(!ce||G!==m)return;ae("live-performance").replaceChildren(),l=L,h=ce,z();let Ae=ae("live-level");if(ae("live-level-field").hidden=!ce.levels,Xa(Ae,ae("live-lod"),a,(Te)=>{if(Te!==void 0)c?.level(Te),f?.refresh(),q();P()}),a.wire(p),a.navigation(ae("live-navigation").value),ae("live-stage-status").textContent="",P(),c)c.setView(a.view())}catch(te){if(G!==m)return;ae("live-stage-status").textContent=`${te instanceof Error?te.message:te}.${l?` Previous artifact ${on(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,z()}}async function ee(L){if(ae("live-panel").hidden)return;let G=++_;if(ae("compare-viewport").hidden=!L?.artifact,ae("review-viewports").classList.toggle("comparing",!!L?.artifact),!L?.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===L.artifact.sha256){u=L,q(),ae("compare-stage-status").textContent="";return}if(!u)ae("compare-stage-label").textContent="Comparison";ae("compare-stage-status").textContent=`Loading pinned ${on(L.operationId)}…`;try{let te=await fetch(L.artifact.url);if(!te.ok)throw Error("Pinned artifact unavailable");let se=new Uint8Array(await te.arrayBuffer());if(G!==_)return;c??=ja(ae("compare-stage"));let ce=await c.load(se,{preserveView:!0,isCurrent:()=>G===_,onCommit:()=>{u=L}});if(!ce||G!==_)return;if(u=L,d=ce,a)c.setView(a.view());let Ae=Number(ae("live-level").value||0);c.level(Number.isFinite(Ae)?Ae:0),ae("compare-level-field").hidden=!ce.levels,f=Xa(ae("compare-level"),ae("compare-lod"),c,q),q(),c.wire(p),c.navigation(ae("live-navigation").value),ae("compare-stage-status").textContent=""}catch(te){if(G===_)ae("compare-stage-status").textContent=`${te instanceof Error?te.message:String(te)}.${u?` Previous comparison ${on(u.operationId)} remains visible.`:""}`}}function J(){Y();let L=e.selected,G=e.displayed,te=ae("follow-latest");te.textContent=e.following?"Following latest":"Follow latest",te.setAttribute("aria-pressed",String(e.following));let se=ae("live-current-summary");if(se.replaceChildren(),L){se.append(I("h2",L.tool.replace(/^kiln_/,"")),I("p",`${L.status} · ${L.transport} · Run ${on(L.sessionId)} · ${new Date(L.updatedAt).toLocaleString()}`));let Te=I("div",void 0,"tags");if(L.projectId)Te.append(I("span",L.projectId,"tag"));for(let Ue of L.phases)Te.append(I("span",Ue.phase,"tag"));se.append(Te)}else se.append(I("h2","No build selected"),I("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=L&&"observationIssues"in L&&Array.isArray(L.observationIssues)?L.observationIssues.map(String):[],Ae=[L?.error,...ce,L&&G&&L.operationId!==G.operationId?`Current ${L.status} operation has no retained artifact. Showing the last successful artifact ${on(G.operationId)} from run ${on(G.sessionId)}.`:"",L&&!e.operations.some((Te)=>Te.operationId===L.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ae("live-failure").textContent=Ae.join(" "),ae("live-failure").hidden=!Ae.length,z(),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:L,displayedArtifactOperation:G?.operationId,pinnedOperation:e.pinned?.operationId},null,2),W(),H(G),ee(e.pinned)}async function de(){if(r)return;r=!0;let L=i;try{let G=new URLSearchParams;if(S.value)G.set("project",S.value);if(n)G.set("cursor",n);let te=await Xt(b(`/api/live?${G}`));if(L!==i)return;if(o=0,C(!0,"Connected · checks every 2 seconds"),n=te.cursor,ae("live-history-note").textContent=`Up to ${te.retention.maxOperations} operations`,ae("live-history-issues").textContent=te.observationIssues?.join(" ")??"",ae("live-history-issues").hidden=!te.observationIssues?.length,!te.unchanged){if(t=te.operations,N(),e=Ya(e,V()),!g){g=!0;let se=Vr(v());if(se&&e.operations.some((Ae)=>Ae.operationId===se))e=up(e,se);let ce=Vr(A());e.pinned=t.find((Ae)=>Ae.operationId===ce&&Ae.pinned)??[...t].reverse().find((Ae)=>Ae.pinned&&Ae.artifact)}J()}}catch(G){o++,C(!1,`Connection lost. Retrying; retained views remain available. ${G instanceof Error?G.message:G}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void de(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(o,4)))}}S.onchange=()=>{i++,n="",t=[],g=!1,M.replaceChildren(new Option("All runs","")),T.value="",e={following:!0,crossRunContinuity:!0,operations:[]},J(),de()},x.onchange=()=>{S.value="",e.pinned=void 0,S.dispatchEvent(new Event("change"))},Xt("/api/live-sources").then(({sources:L})=>{x.replaceChildren(...L.map((G)=>new Option(G.label,G.id)))}).catch(un),M.onchange=()=>{e=Ya({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!M.value},V()),J()},T.onchange=()=>M.dispatchEvent(new Event("change")),ae("follow-latest").onclick=()=>{e=Ya({...e,following:!e.following},V()),pi(v(),e.following?"":e.selected?.operationId??""),J()},ae("live-refresh").onclick=()=>{n="",de(),J()},ae("pin-build").onclick=async()=>{let L=Hr(e.displayed,l);if(!L?.artifact)return;let G=ae("pin-build");G.disabled=!0;try{await Xt(b(`/api/live/${encodeURIComponent(L.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...L,pinned:!0},pi(A(),L.operationId),n="",J(),de()}catch(te){un(te),z()}},ae("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await Xt(b(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,pi(A(),""),n="",J(),de()}catch(L){un(L)}},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 pe=I("button","Match comparison camera","secondary");pe.onclick=()=>{if(a)c?.setView(a.view())},ae("live-frame").parentElement?.append(pe);let Be=I("button","Save exact artifact");Be.disabled=!0,ae("live-frame").parentElement?.prepend(Be);let me=I("button","Measure 3 s","secondary"),X=I("div");return X.id="live-performance",ae("live-evidence").after(X),ae("live-frame").parentElement?.append(me),cu(me,X,()=>a,()=>Hr(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),Be.onclick=()=>{let L=Hr(e.displayed,l);if(L?.status!=="complete")return;let G=I("dialog"),te=I("form"),se=I("div",void 0,"editor-content"),ce=I("h2","Save reviewed artifact");ce.id="save-review-title",G.setAttribute("aria-labelledby",ce.id),se.append(ce,I("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"),I("p",`${L.operationId} · revision ${L.revision}`,"mono"),I("p",L.artifact.sha256,"mono"));let Ae=I("input");Ae.required=!0,Ae.maxLength=200,Ae.value="";let Te=I("label","Asset name","field");Te.append(Ae);let Ue=I("p");Ue.setAttribute("role","status");let $e=I("button","Save exact artifact");$e.type="submit";let Xe=I("button","Cancel","secondary");Xe.type="button",Xe.onclick=()=>G.close(),se.append(Te,Ue,$e,Xe),te.append(se),G.append(te),document.body.append(G),G.addEventListener("close",()=>G.remove()),te.onsubmit=async(Ot)=>{Ot.preventDefault(),$e.disabled=!0,Ue.textContent="Saving retained bytes…";try{let rt=OS(L,Ae.value,l,e.displayed),Mt=await Xt(b(rt.path),{method:"POST",body:rt.body});Ue.replaceChildren(I("span",`Saved ${Mt.asset.assetId} / ${Mt.asset.revisionId}. `));let Bt=I("a","Open saved revision"),Ht=new URLSearchParams({collection:Mt.collection,asset:Mt.asset.assetId,revision:Mt.asset.revisionId});Bt.href=`/?${Ht}`,Ue.append(Bt);let O=I("div");se.append(O),Ja(O,{collectionId:Mt.collection,assetId:Mt.asset.assetId,revisionId:Mt.asset.revisionId},Mt.asset.name,async()=>{}).catch((en)=>{O.textContent=`Asset saved; membership unavailable: ${en instanceof Error?en.message:en}. Open the saved asset in Library to link it.`}),Ae.disabled=!0,$e.textContent="Saved",Xe.textContent="Close"}catch(rt){Ue.textContent=rt instanceof Error?rt.message:String(rt),$e.disabled=!1}},G.showModal(),Ae.focus()},ae("live-navigation").onchange=(L)=>{let G=L.target.value;a?.navigation(G),c?.navigation(G),ae("live-navigation-help").textContent=G==="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="",de()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)de()}),de(),{activate:J,projects(L){let G=S.value;S.replaceChildren(new Option("All work",""));for(let te of L)S.append(new Option(te.name,te.projectId));if(L.some((te)=>te.projectId===G))S.value=G}}}var dp=["projects","live","library","materials"];function kS(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";if(qa(e))return"materials";return t&&dp.some((i)=>i===t)?t:"library"}function FS(e,t=()=>{}){let n=dp;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(pi("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(un)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ae("open-files").onclick=()=>ae("open").click();let r=US(),s=NS(()=>o.refresh()),o=CS({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(kS(location.search,Vr("kiln.section"))),o.refresh().catch(un),s.refresh().catch(un);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 $i=(e)=>`${e.collection}/${e.manifest.assetId}`;function zS(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($i(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(`${$i(r)}/${r.manifest.revisionId}`))}var Oe=(e)=>document.getElementById(e),ot=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},tc=[],ec=[],Zr=[],ys=[],lu="",$r,Wi,an,Gr=0,BS=0,Ka=!1,Qa=!1,Wr=new Set,gp=[],VS=[],ur=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,pp=(e)=>{Oe("status").textContent=e},Zi=(e)=>pp(e instanceof Error?e.message:String(e)),bs=(e,t,n=gp)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function mp(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function fp(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/${ur(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function MP(e,t){if(e.local){if(t==="editable.zip")return bs(kh([e.local]),"application/zip");return bs(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return bs(e.loose,"model/gltf-binary");return`/files/${ur(e)}/${t}?download`}function HS(e,t){try{localStorage.setItem(e,t)}catch{}}function EP(e){try{return localStorage.getItem(e)}catch{return null}}function AP(){let e=Oe("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...tc,...ys.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=ot("button",t.label,lu===t.id?"active":"");n.onclick=()=>void Ro(t.id).catch(Zi),e.append(n)}}async function Ro(e,t=!0){if(t)$S.library();let n=++BS;lu=e,Wr.clear(),AP(),pp("");let i=e==="all"?await(async()=>{let r=await mp("/api/library");if(r.errors.length)pp(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?ys:(await mp(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==BS)return;Zr=i,HS("kiln.collection",e),Oe("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":tc.find((r)=>r.id===e)?.label??e,Oe("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.",uu()}function TP(){let e=new Map;for(let t of zS(Zr,ec,Oe("library-project").value)){let n=$i(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===EP(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function uu(){for(let i of VS.splice(0))URL.revokeObjectURL(i);let e=Oe("cards");e.replaceChildren();let t=Oe("search").value.toLowerCase(),n=TP().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Oe("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Oe("export-selection").disabled=!Wr.size,!n.length){let i=ot("div",void 0,"empty");if(i.append(ot("b",t?"No matching assets":"Your next idea belongs here."),ot("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(ot("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=ot("article",void 0,"card"),o=ot("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void nc(i).catch(Zi);let a=ot("div",void 0,"thumb");if(r.files["preview.png"]){let m=ot("img");m.loading="lazy",m.alt=r.name,m.src=i.local?bs(i.local.files["preview.png"],"image/png",VS):`/files/${ur(i)}/preview.png`,m.onerror=()=>{m.remove(),a.textContent="◇"},a.append(m)}else a.textContent="◇";let c=ot("div",void 0,"card-content");c.append(ot("span",r.name,"card-title"));let l=Zr.filter((m)=>$i(m)===$i(i)),u=new Set(l.map((m)=>m.manifest.parentRevision)),h=l.filter((m)=>!u.has(m.manifest.revisionId));c.append(ot("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${h.length>1?` · ${h.length} branches`:""}`,"card-meta"));let d=ot("div",void 0,"tags");for(let m of r.tags)d.append(ot("span",m,"tag"));c.append(d),c.append(ot("small",tc.find((m)=>m.id===i.collection)?.label??i.collection,"card-meta"));let f=ec.filter((m)=>m.inventory.some((_)=>_.asset&&_.asset.collectionId===i.collection&&_.asset.assetId===r.assetId));if(c.append(ot("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=ot("input");m.type="checkbox",m.className="selection",m.checked=Wr.has(ur(i)),m.setAttribute("aria-label",`Select ${r.name}`),m.onchange=()=>{if(m.checked)Wr.add(ur(i));else Wr.delete(ur(i));Oe("export-selection").disabled=!Wr.size},s.append(m)}e.append(s)}}async function nc(e){let t=++Gr;$r=e,Wi=void 0,an?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Oe("library-performance").replaceChildren(),HS(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let u of gp.splice(0))URL.revokeObjectURL(u);let n=Oe("detail");if(!n.open)n.showModal();Oe("asset-name").textContent=e.manifest.name;let i=Oe("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let u=ot("div");i.append(u),Ja(u,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,$S.refreshProjects).catch(Zi)}let r=Oe("revisions");r.replaceChildren();for(let u of Zr.filter((h)=>$i(h)===$i(e))){let h=ot("option",`${new Date(u.manifest.createdAt).toLocaleString()} · ${u.manifest.description||u.manifest.revisionId.slice(0,10)}`);h.value=u.manifest.revisionId,h.selected=u.manifest.revisionId===e.manifest.revisionId,r.append(h)}r.onchange=()=>{let u=Zr.find((h)=>$i(h)===$i(e)&&h.manifest.revisionId===r.value);if(u)nc(u).catch(Zi)},Oe("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=Oe("asset-attribution");s.replaceChildren();for(let u of K0(e.manifest)){let h=ot("div");h.append(ot("span",u.label),ot("strong",u.value)),s.append(h)}s.hidden=!s.childElementCount;let o=document.getElementById("asset-material-inputs");if(!o)o=ot("section",void 0,"asset-material-inputs"),o.id="asset-material-inputs",s.after(o);o.replaceChildren();try{let u=Oh({manifest:e.manifest,files:{}});if(u.length){o.append(ot("h3","Exact material build inputs"),ot("p","Open the saved revision to inspect its raw maps, sampling declaration and atlas regions. Declared inputs do not prove every map was used.","subtle"));for(let h of u){let d=ot("a",`${h.name} · ${h.materialId}`);d.href=ou(h),d.target="_blank",d.rel="noopener",o.append(d,ot("p",h.revisionId,"mono"))}}}catch(u){o.append(ot("p",`Material revision links unavailable: ${u instanceof Error?u.message:String(u)}`,"subtle"))}Oe("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let a=Oe("downloads");a.replaceChildren();for(let[u,h]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 d=ot("a",h);d.href=MP(e,u),d.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${u==="asset.glb"?".glb":u==="source.kiln.js"?".kiln.js":".zip"}`,a.append(d)}if(!e.loose){let u=ot("button","Runtime GLB"),h=ot("span");h.setAttribute("role","status"),u.onclick=async()=>{u.disabled=!0,h.textContent="Preparing runtime download…";try{let d=e.local?await yS(e.local,{profile:"runtime"}):void 0,[f,m]=d?.profile==="runtime"?[d.glb,d.metadata.bytes]:await Promise.all([fp(e,"runtime.glb"),fp(e,"runtime.kiln-metadata.json")]);if(t!==Gr)return;let _=ot("a","Runtime GLB");_.href=bs(f,"model/gltf-binary"),_.download="runtime.glb";let p=ot("a","Runtime metadata");p.href=bs(m,"application/json"),p.download="runtime.kiln-metadata.json",u.replaceWith(_,p),h.textContent="Keep the companion metadata for traceability.",_.click()}catch(d){if(t!==Gr)return;h.textContent=`Runtime export unavailable: ${d instanceof Error?d.message:d}`,u.disabled=!1}},a.append(u,h),a.append(ot("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."))}Oe("refine").disabled=!e.manifest.editable,Oe("asset-stats").replaceChildren(),Oe("stage-status").textContent="Loading saved GLB…",Ka=!1,Qa=!1,Oe("wire").setAttribute("aria-pressed","false"),Oe("play").textContent="Pause";let c=Oe("animation");c.replaceChildren(new Option("Rest pose","")),Oe("play").disabled=!0;let l=Oe("level");l.replaceChildren(),l.hidden=!0,Oe("library-lod").replaceChildren(),Oe("library-lod").hidden=!0;try{an??=ja(Oe("stage"));let u=await fp(e,"asset.glb");if(t!==Gr)return;let h=await an.load(u,{isCurrent:()=>t===Gr,onCommit:()=>{Wi=e}});if(!h||t!==Gr)return;Wi=e,an.wire(!1),an.navigation(Oe("library-navigation").value),an.lighting(Oe("lighting").value),Xa(l,Oe("library-lod"),an);for(let[d,f]of[...h.levels?h.levels.map((m,_)=>[m.toLocaleString(),`LOD${_} triangles`]):[[h.triangles.toLocaleString(),"triangles"]],[h.meshes,h.levels?"LOD0 meshes":"meshes"],[h.materials,h.levels?"LOD0 materials":"materials"],[`${(u.length/1024).toFixed(0)} KB`,"GLB"]]){let m=ot("div");m.append(ot("strong",String(d)),ot("span",String(f))),Oe("asset-stats").append(m)}for(let d=0;d<h.clips.length;d++)c.append(new Option(h.clips[d],String(d)));Oe("stage-status").textContent=""}catch(u){if(t===Gr)an?.dispose(),an=void 0,Oe("stage-status").textContent=`3D preview unavailable: ${u instanceof Error?u.message:u}. Downloads remain available.`}}async function GS(e){for(let t of e){if(t.bytes.length>Zn)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of J0(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(!ys.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))ys.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;ys.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 Ro("opened-files")}Oe("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Zn))throw Error("File exceeds 64 MiB");await GS(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Zi(t)}};Oe("refresh").onclick=()=>void Ro(lu).catch(Zi);Oe("search").oninput=uu;Oe("library-project").onchange=()=>void Ro("all").catch(Zi);Oe("close-detail").onclick=()=>Oe("detail").close();Oe("detail").addEventListener("close",()=>{Gr++,Wi=void 0,an?.dispose(),an=void 0;for(let e of gp.splice(0))URL.revokeObjectURL(e);uu()});Oe("frame").onclick=()=>an?.reset();Oe("wire").onclick=()=>{Ka=!Ka,an?.wire(Ka),Oe("wire").setAttribute("aria-pressed",String(Ka))};Oe("lighting").onchange=(e)=>an?.lighting(e.target.value);Oe("library-navigation").onchange=(e)=>{let t=e.target.value;an?.navigation(t),Oe("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"};Oe("animation").onchange=(e)=>{let t=e.target.value;an?.clip(t===""?-1:Number(t)),Oe("play").disabled=t===""};Oe("play").onclick=()=>{Qa=!Qa,an?.pause(Qa),Oe("play").textContent=Qa?"Play":"Pause"};Oe("refine").onclick=async()=>{if(!$r)return;let e=$r.manifest,t=$r.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=${$r.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=${$r.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Oe("refine").textContent="Instructions copied"}catch{Oe("provenance").textContent=t,Oe("provenance").parentElement?.setAttribute("open","")}};Oe("export-selection").onclick=()=>{try{let e=ot("a");if(lu==="opened-files")e.href=bs(kh(Zr.filter((t)=>Wr.has(ur(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Wr)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Zi(e)}};async function RP(){tc=(await mp("/api/collections")).collections;let e=_S(location.search);if(await Ro(tc.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Zr.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 nc(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await GS([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),ys.length===1)await nc(ys[0])}}var $S=FS((e)=>{(async()=>{await Ro(e.collectionId);let t=Zr.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 nc(t)})().catch(Zi)},(e)=>{ec=e;let t=Oe("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of ec)t.append(new Option(i.name,i.projectId));if(n==="standalone"||ec.some((i)=>i.projectId===n))t.value=n;uu()});cu(Oe("measure-library"),Oe("library-performance"),()=>an,()=>Wi&&$r&&ur(Wi)===ur($r)?{collection:Wi.collection,assetId:Wi.manifest.assetId,revisionId:Wi.manifest.revisionId,glbSha256:Wi.manifest.files["asset.glb"]?.sha256}:void 0);RP().catch(Zi);
+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let o=a[1];if(t===a[0]){s(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){s(a);continue}}if(e.metadataRegistry.get(a[0])?.id){s(a);continue}if(o.cycle){s(a);continue}if(o.count>1){if(e.reused==="ref")s(a)}}if(e.external)e.sharedDefsExtractedFor=e.external}function V_(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;V_(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let a of Array.isArray(s)?s:[s]){if(typeof a!=="string")return;if(!n.includes(a))n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var j_=new Set(["type","properties","required","additionalProperties"]),B_=["oneOf","anyOf"];function z_(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 ih(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let a in s)if(!j_.has(a))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let a in s.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let o=[];for(let l of t){let u=l.properties?.[a]??z_(l);if(u===null||u===void 0)continue;if(!o.some((d)=>JSON.stringify(d)===JSON.stringify(u)))o.push(u)}let c=o.length===1?o[0]:ih(o)??{allOf:o};hi(n,a,c)}for(let a of s.required??[])i.add(a)}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 a of t){let o=z_(a);if(o&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(o)))s.push(o)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function yI(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of j_)if(r in e)return;let n=t.filter((r)=>B_.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=ih(t);else{let r=n[0],s=B_.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter((c)=>c!==r),o=r[s].map((c)=>ih([...a,c]));if(o.some((c)=>!c))return;i={[s]:o}}if(!i)return;delete e.allOf,sc(e,i)}function ah(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(o)=>{let c=e.seen.get(o);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let h=e.seen.get(d),y=h.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(y);else sc(l,y);if(sc(l,u),o._zod.parent===d)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(!(m in u))delete l[m]}if(y.$ref&&h.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in h.def&&JSON.stringify(l[m])===JSON.stringify(h.def[m]))delete l[m]}}let f=o._zod.parent;if(f&&f!==d){i(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let y in l){if(y==="$ref"||y==="allOf")continue;if(y in h.def&&JSON.stringify(l[y])===JSON.stringify(h.def[y]))delete l[y]}}}e.override({zodSchema:o,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let o of[...e.seen.entries()].reverse())i(o[0]);if(e.target!=="openapi-3.0")for(let o of e.seen.entries())V_(o[1].def??o[1].schema);for(let o of e.deferred)o();if(e.intersections.length){let o=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 d=o.get(u);if(d)d.push(l);else o.set(u,[l])}for(let c of e.intersections)for(let l of o.get(c)??[])yI(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 o=e.external.registry.get(t)?.id;if(!o)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(o)}sc(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 a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let o of e.seen.entries()){let c=o[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;hi(a,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(a).length>0)if(e.target==="draft-2020-12")r.$defs=a;else r.definitions=a;try{let o=JSON.parse(JSON.stringify(r));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:ac(t,"input",e.processors),output:ac(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch(o){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 H_=(e,t={})=>(n)=>{let i=rh({...n,processors:t});return Xt(e,i),sh(i,e),ah(i,e)},ac=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},a=rh({...r??{},target:s,io:t,processors:n});return Xt(e,a),sh(a,e),ah(a,e)};var Ba=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},za=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},G_=(e,t)=>{Ba(e,"minimum",t),za(e,"maximum",t)},X_=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},q_=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},J_=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Z_=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},$_=(e,t)=>Ba(e,"minimum",t.minimum),K_=(e,t)=>za(e,"maximum",t.maximum),W_=(e)=>(t,n)=>{Z_(t,n.format);let[i,r]=e[n.format];Ba(t,"minimum",i),za(t,"maximum",r)},xI={greater_than:(e,t)=>Ba(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>za(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>X_(e,t.value),number_format:W_(Rl),bigint_format:W_(Tf),min_length:$_,max_length:K_,length_equals:(e,t)=>G_(e,t.length),min_size:$_,max_size:K_,size_equals:(e,t)=>G_(e,t.size),string_format:(e,t)=>{if(Z_(e,t.format),t.pattern)q_(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)=>J_(e,t.mime)};function Yn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)xI[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ba(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ba(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)za(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)za(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)X_(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)J_(t,r.mime);for(let s of r.patterns??[])q_(t,s);return t}var _I={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vI=new Map([[Bf,uy],[Gl,dy]]),Y_=(e)=>vI.get(e)??e,Q_=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:a,format:o,patterns:c,contentEncoding:l,laxFormat:u}=Yn(e);if(typeof s==="number")r.minLength=s;if(typeof a==="number")r.maxLength=a;if(o){if(r.format=_I[o]??o,r.format==="")delete r.format;if(o==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(Y_);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},e0=(e,t,n,i)=>{let r=n,{minimum:s,maximum:a,multipleOf:o,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Yn(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(h)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(f)if(h)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof a==="number")r.maximum=a;if(o){let y=new Set;for(let p of o)if(Number.isFinite(p)&&p!==0)y.add(Math.abs(p));else Mr(e,t,r,i,`A multipleOf divisor of ${p} cannot be represented in JSON Schema`);let[g,...m]=y;if(g!==void 0)r.multipleOf=g;if(m.length)r.allOf=[...r.allOf??[],...m.map((p)=>({multipleOf:p}))]}},t0=(e,t,n,i)=>{n.type="boolean"};var n0=(e,t,n,i)=>{n.not={}};var i0=(e,t,n,i)=>{};var r0=(e,t,n,i)=>{let r=e._zod.def,s=Xo(r.entries);if(s.length===0){n.not={};return}if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";n.enum=s},s0=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let a of r.values)if(a===void 0){if(Mr(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a==="bigint"){if(Mr(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(s.length===0);else if(s.length===1){let a=s[0];if(n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[a];else n.const=a}else{if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";if(s.every((a)=>typeof a==="boolean"))n.type="boolean";if(s.every((a)=>a===null))n.type="null";n.enum=s}};var a0=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var o0=(e,t,n,i)=>{Mr(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var c0=(e,t,n,i)=>{Mr(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var l0=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:a,maximum:o}=Yn(e);if(typeof a==="number")r.minItems=a;if(typeof o==="number")r.maxItems=o;r.type="array",r.items=Xt(s.element,t,{...i,path:[...i.path,"items"]})};function oc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return oc(t.out);if(t.type==="catch")return oc(t.innerType);return e._zod.optin}var u0=(e,t,n,i)=>{let r=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Mr(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in a)hi(r.properties,l,Xt(a[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(a)){let u=s.shape[l];if(t.io==="input"?oc(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=Xt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},d0=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,a=r.options.map((o,c)=>Xt(o,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=a;else n.anyOf=a},f0=(e,t,n,i)=>{let r=e._zod.def,s=Xt(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=Xt(r.right,t,{...i,path:[...i.path,"allOf",1]}),o=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},h0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((g,m)=>Xt(g,t,{...i,path:[...i.path,a,m]})),l=s.rest?Xt(s.rest,t,{...i,path:[...i.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let g=s.items[u-1];if(!(t.io==="input"?oc(g)!==void 0:g._zod.optout==="optional"))break;u--}let d=s.items.length,f=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,f)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(f)r.maxItems=d}else{if(r.items=c,f)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}let{minimum:h,maximum:y}=Yn(e);if(typeof h==="number")r.minItems=h;if(typeof y==="number")r.maxItems=y};function oh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let y=e.get(t)?.def;if(!y)return t;let g=oh(e,y,n);return g===y?t:g}for(let y of["anyOf","oneOf"]){let g=t[y];if(!Array.isArray(g))continue;let m=g.map((p)=>oh(e,p,n));if(m.some((p,b)=>p!==g[b]))t={...t,[y]:m}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((y)=>y==="number"||y==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((y)=>typeof y==="number"))return t;let{minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((y)=>typeof y==="number"?String(y):y);else if(typeof h.const==="number")h.const=String(h.const);if(!r)return h;if(h.type="string",!s)h.pattern=(i.includes("number")?Fa:Ul).source;return h}var ch=new WeakMap;function EI(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 ch.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let a=oh(t,s,new Set);if(a!==s)n.set(s,a)}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 p0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let a=s.keyType,o=Yn(a).patterns;if(s.mode==="loose"&&o&&o.size>0){let u=Xt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of o)hi(r.patternProperties,Y_(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Xt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=ch.get(t);if(!u)u=[],ch.set(t,u),t.deferred.push(()=>EI(t));u.push(e)}r.additionalProperties=Xt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,l=t.io==="input"&&oc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},m0=(e,t,n,i)=>{let r=e._zod.def,s=Xt(r.innerType,t,i),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},g0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},lh=Symbol();function b0(e,t,n,i,r){let s=!1,a=JSON.stringify(e,(o,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(a);return Mr(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),lh}var y0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a=b0(r.defaultValue,e,t,n,i);if(a!==lh)n.default=a},x0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let a=b0(r.defaultValue,e,t,n,i);if(a!==lh)n._prefault=a},_0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{Mr(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},v0=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?r.out:r.in:r.out;Xt(a,t,i);let o=t.seen.get(e);o.ref=a},E0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var uh=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var T0=new WeakSet([Object.prototype,Error.prototype]);function eu(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 CI=(e,t)=>{Fb.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(T0.has(n))return;T0.add(n),eu(n,"format",(i)=>(r)=>Bb(i,r)),eu(n,"flatten",(i)=>(r)=>Ub(i,r)),eu(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,qo,2)}),eu(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,qo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Qn=se("ZodError",CI,void 0,{Parent:Error});var A0=kl(Qn),S0=Dl(Qn),w0=Ll(Qn),M0=Fl(Qn),R0=Vb(Qn),I0=jb(Qn),C0=Hb(Qn),N0=Gb(Qn),P0=$b(Qn),O0=Kb(Qn),k0=Wb(Qn),D0=Xb(Qn);function PI(){if(!Ln.localeError)Zn($f())}function cc(){if(!Ln.memoizer)Zn({memoizer:Qx()})}var $t=se("ZodType",(e,t)=>(PI(),Ut.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Jn(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 Wi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(N1(e,t))},superRefine(e,t){return this.check(P1(e,t))},overwrite(e){return this.check(Zr(e))},optional(){return U0(this)},exactOptional(){return g1(this)},nullable(){return B0(this)},nullish(){return U0(B0(this))},nonoptional(e){return E1(this,e)},array(){return at(this)},or(e){return Va([this,e])},and(e){return d1(this,e)},transform(e){return z0(this,m1(e))},default(e){return x1(this,e)},prefault(e){return v1(this,e)},catch(e){return A1(this,e)},pipe(e){return z0(this,e)},readonly(){return M1(this)},describe(e){let t=this.clone();return na.add(t,{description:e}),t},meta(...e){if(e.length===0)return na.get(this);let t=this.clone();return na.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 Pl(this,"~standard",{...Uf(this),jsonSchema:{input:ac(this,"input"),output:ac(this,"output")}})},set "~standard"(e){Sr(this,"~standard",e)},parse:function e(t,n){return A0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await S0(this,t,n,{callee:e})},safeParse(e,t){return w0(this,e,t)},async safeParseAsync(e,t){return M0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Sr(this,"spa",e)},validate(e,t){return Rf(this,e,t)},validateAsync(e,t){return If(this,e,t)},encode:function e(t,n){return R0(this,t,n,{callee:e})},decode:function e(t,n){return I0(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await C0(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await N0(this,t,n,{callee:e})},safeEncode(e,t){return P0(this,e,t)},safeDecode(e,t){return O0(this,e,t)},async safeEncodeAsync(e,t){return k0(this,e,t)},async safeDecodeAsync(e,t){return D0(this,e,t)},toJSONSchema(e){return H_(this,{})(e)},get description(){return na.get(this)?.description},get _def(){return this._zod.def}}),V0=se("_ZodString",(e,t)=>{Hl.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Q_(e,n,i,r)},Nb({format:(e)=>Yn(e).format??null,minLength:(e)=>Yn(e).minimum??null,maxLength:(e)=>Yn(e).maximum??null},{regex(...e){return this.check(Kf(...e))},includes(...e){return this.check(qf(...e))},startsWith(...e){return this.check(Jf(...e))},endsWith(...e){return this.check(Zf(...e))},min(...e){return this.check(Ua(...e))},max(...e){return this.check(Yl(...e))},length(...e){return this.check(Ql(...e))},nonempty(...e){return this.check(Ua(1,...e))},lowercase(e){return this.check(Wf(e))},uppercase(e){return this.check(Xf(e))},trim(){return this.check(Qf())},normalize(...e){return this.check(Yf(...e))},toLowerCase(){return this.check(eh())},toUpperCase(){return this.check(th())},slugify(){return this.check(nh())}})),OI=se("ZodString",(e,t)=>{Hl.init(e,t),V0.init(e,t)},{email(e){return this.check(r_(UI,e))},url(e){return this.check(u_(zI,e))},jwt(e){return this.check(S_(t1,e))},emoji(e){return this.check(d_(VI,e))},guid(e){return this.check(s_(BI,e))},uuid(e){return this.check(a_(tu,e))},uuidv4(e){return this.check(o_(tu,e))},uuidv6(e){return this.check(c_(tu,e))},uuidv7(e){return this.check(l_(tu,e))},nanoid(e){return this.check(f_(jI,e))},cuid(e){return this.check(h_(HI,e))},cuid2(e){return this.check(p_(GI,e))},ulid(e){return this.check(m_($I,e))},base64(e){return this.check(E_(YI,e))},base64url(e){return this.check(T_(QI,e))},xid(e){return this.check(g_(KI,e))},ksuid(e){return this.check(b_(WI,e))},ipv4(e){return this.check(y_(XI,e))},ipv6(e){return this.check(x_(qI,e))},cidrv4(e){return this.check(__(JI,e))},cidrv6(e){return this.check(v_(ZI,e))},e164(e){return this.check(A_(e1,e))},datetime(e){return this.check(w_(kI,e))},date(e){return this.check(M_(DI,e))},time(e){return this.check(R_(LI,e))},duration(e){return this.check(I_(FI,e))}});function Le(e){return i_(OI,e)}var qt=se("ZodStringFormat",(e,t)=>{Gt.init(e,t),V0.init(e,t)}),kI=se("ZodISODateTime",(e,t)=>{ux.init(e,t),qt.init(e,t)}),DI=se("ZodISODate",(e,t)=>{dx.init(e,t),qt.init(e,t)}),LI=se("ZodISOTime",(e,t)=>{fx.init(e,t),qt.init(e,t)}),FI=se("ZodISODuration",(e,t)=>{hx.init(e,t),qt.init(e,t)}),UI=se("ZodEmail",(e,t)=>{Qy.init(e,t),qt.init(e,t)});var BI=se("ZodGUID",(e,t)=>{Zy.init(e,t),qt.init(e,t)});var tu=se("ZodUUID",(e,t)=>{Yy.init(e,t),qt.init(e,t)});var zI=se("ZodURL",(e,t)=>{nx.init(e,t),qt.init(e,t)});var VI=se("ZodEmoji",(e,t)=>{ix.init(e,t),qt.init(e,t)});var jI=se("ZodNanoID",(e,t)=>{rx.init(e,t),qt.init(e,t)});var HI=se("ZodCUID",(e,t)=>{sx.init(e,t),qt.init(e,t)});var GI=se("ZodCUID2",(e,t)=>{ax.init(e,t),qt.init(e,t)});var $I=se("ZodULID",(e,t)=>{ox.init(e,t),qt.init(e,t)});var KI=se("ZodXID",(e,t)=>{cx.init(e,t),qt.init(e,t)});var WI=se("ZodKSUID",(e,t)=>{lx.init(e,t),qt.init(e,t)});var XI=se("ZodIPv4",(e,t)=>{px.init(e,t),qt.init(e,t)});var qI=se("ZodIPv6",(e,t)=>{gx.init(e,t),qt.init(e,t)});var JI=se("ZodCIDRv4",(e,t)=>{bx.init(e,t),qt.init(e,t)});var ZI=se("ZodCIDRv6",(e,t)=>{yx.init(e,t),qt.init(e,t)});var YI=se("ZodBase64",(e,t)=>{_x.init(e,t),qt.init(e,t)});var QI=se("ZodBase64URL",(e,t)=>{vx.init(e,t),qt.init(e,t)});var e1=se("ZodE164",(e,t)=>{Ex.init(e,t),qt.init(e,t)});var t1=se("ZodJWT",(e,t)=>{Tx.init(e,t),qt.init(e,t)});var j0=se("ZodNumber",(e,t)=>{zf.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>e0(e,n,i,r),e.isFinite=!0},Nb({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Yn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Yn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Yn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Yn(e).format??null},{gt(e,t){return this.check(Jl(e,t))},gte(e,t){return this.check(rc(e,t))},min(e,t){return this.check(rc(e,t))},lt(e,t){return this.check(ql(e,t))},lte(e,t){return this.check(ic(e,t))},max(e,t){return this.check(ic(e,t))},int(e){return this.check(L0(e))},safe(e){return this.check(L0(e))},positive(e){return this.check(Jl(0,e))},nonnegative(e){return this.check(rc(0,e))},negative(e){return this.check(ql(0,e))},nonpositive(e){return this.check(ic(0,e))},multipleOf(e,t){return this.check(Zl(e,t))},step(e,t){return this.check(Zl(e,t))},finite(){return this}}));function mt(e){return C_(j0,e)}var n1=se("ZodNumberFormat",(e,t)=>{Ax.init(e,t),j0.init(e,t)});function L0(e){return N_(n1,e)}var i1=se("ZodBoolean",(e,t)=>{Sx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>t0(e,n,i,r)});function ra(e){return P_(i1,e)}var r1=se("ZodUnknown",(e,t)=>{wx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>i0(e,n,i,r)});function ia(){return O_(r1)}var s1=se("ZodNever",(e,t)=>{Mx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>n0(e,n,i,r)});function a1(e){return k_(s1,e)}var o1=se("ZodArray",(e,t)=>{cc(),Rx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>l0(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Ua(e,t))},nonempty(e){return this.check(Ua(1,e))},max(e,t){return this.check(Yl(e,t))},length(e,t){return this.check(Ql(e,t))},unwrap(){return this.element}});function at(e,t){return D_(o1,e,t)}var c1=se("ZodObject",(e,t)=>{cc(),Nx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u0(e,n,i,r),BR(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return It(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Jn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Jn(this._zod.def,{catchall:ia()}))},loose(){return this.clone(Jn(this._zod.def,{catchall:ia()}))},strict(){return this.clone(Jn(this._zod.def,{catchall:a1()}))},strip(){return this.clone(Jn(this._zod.def,{catchall:void 0}))},extend(e){return NR(this,e)},safeExtend(e){return PR(this,e)},merge(e){return OR(this,e)},pick(e){return IR(this,e)},omit(e){return CR(this,e)},partial(...e){return Mb(hh,this,e[0])},exactPartial(...e){return Mb($0,this,e[0],"exactPartial")},required(...e){return kR(K0,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Fe(t)};return new c1(n)}var H0=se("ZodUnion",(e,t)=>{Vf.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d0(e,n,i,r),e.options=t.options});function Va(e,t){return new H0({type:"union",options:e,...Fe(t)})}var l1=se("ZodDiscriminatedUnion",(e,t)=>{H0.init(e,t),Px.init(e,t)});function wi(e,t,n){return new l1({type:"union",options:t,discriminator:e,...Fe(n)})}var u1=se("ZodIntersection",(e,t)=>{Ox.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f0(e,n,i,r)});function d1(e,t){return new u1({type:"intersection",left:e,right:t})}var f1=se("ZodTuple",(e,t)=>{cc(),kx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h0(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new hh({type:"optional",innerType:t}))})}});function G0(e,t,n){let i=t instanceof Ut,r=i?n:t;return new f1({type:"tuple",items:e,rest:i?t:null,...Fe(r)})}var F0=se("ZodRecord",(e,t)=>{cc(),Dx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p0(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function nu(e,t,n){if(!t||!t._zod)return new F0({type:"record",keyType:Le(),valueType:e,...Fe(t)});return new F0({type:"record",keyType:e,valueType:t,...Fe(n)})}var fh=se("ZodEnum",(e,t)=>{Lx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(i,r,s)=>r0(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 a of i)if(n.has(a))s[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new fh({...t,checks:[],...Fe(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let a of i)if(n.has(a))delete s[a];else throw Error(`Key ${a} not found in enum`);return new fh({...t,checks:[],...Fe(r),entries:s})}});function It(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new fh({type:"enum",entries:n,...Fe(t)})}var h1=se("ZodLiteral",(e,t)=>{Fx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s0(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 $e(e,t){return new h1({type:"literal",values:Array.isArray(e)?e:[e],...Fe(t)})}var p1=se("ZodTransform",(e,t)=>{cc(),Ux.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>c0(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Yo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(ta(s,n.value,t));else{let a=s;if(a.fatal)a.continue=!1;if(a.code??(a.code="custom"),!("input"in a))a.input=n.value;a.inst??(a.inst=e),n.issues.push(ta(a))}};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 m1(e){return new p1({type:"transform",transform:e})}var hh=se("ZodOptional",(e,t)=>{jf.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function U0(e){return new hh({type:"optional",innerType:e})}var $0=se("ZodExactOptional",(e,t)=>{Bx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function g1(e){return new $0({type:"optional",innerType:e})}var b1=se("ZodNullable",(e,t)=>{zx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function B0(e){return new b1({type:"nullable",innerType:e})}var y1=se("ZodDefault",(e,t)=>{Vx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>y0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function x1(e,t){return new y1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():vf(t)}})}var _1=se("ZodPrefault",(e,t)=>{jx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function v1(e,t){return new _1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():vf(t)}})}var K0=se("ZodNonOptional",(e,t)=>{Hx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>g0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function E1(e,t){return new K0({type:"nonoptional",innerType:e,...Fe(t)})}var T1=se("ZodCatch",(e,t)=>{Gx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function A1(e,t){return new T1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Pb(t)})}var S1=se("ZodPipe",(e,t)=>{$x.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v0(e,n,i,r),e.in=t.in,e.out=t.out});function z0(e,t){return new S1({type:"pipe",in:e,out:t})}var w1=se("ZodReadonly",(e,t)=>{Kx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>E0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function M1(e){return new w1({type:"readonly",innerType:e})}var R1=se("ZodTemplateLiteral",(e,t)=>{Wx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a0(e,n,i,r)});function I1(e,t){return new R1({type:"template_literal",parts:e,...Fe(t)})}var C1=se("ZodCustom",(e,t)=>{Xx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o0(e,n,i,r)});function N1(e,t={}){return L_(C1,e,t)}function P1(e,t){return F_(e,t)}var iu={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 W0;(function(e){})(W0||(W0={}));var X0=["neutral","dark","light"];var ph=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),q0=Object.freeze({neutral:ph("neutral",[170,177,188]),dark:ph("dark",[26,26,26]),light:ph("light",[223,227,232])});var Jz=q0.neutral.rgb,Zz=q0.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 Jt=Uint8Array,ei=Uint16Array,Sh=Int32Array,su=new Jt([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]),au=new Jt([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]),xh=new Jt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nv=function(e,t){var n=new ei(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Sh(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}},iv=nv(su,2),{b:rv,r:_h}=iv;rv[28]=258,_h[258]=28;var sv=nv(au,0),{b:O1,r:J0}=sv,vh=new ei(32768);for(ht=0;ht<32768;++ht)Zi=(ht&43690)>>1|(ht&21845)<<1,Zi=(Zi&52428)>>2|(Zi&13107)<<2,Zi=(Zi&61680)>>4|(Zi&3855)<<4,vh[ht]=((Zi&65280)>>8|(Zi&255)<<8)>>1;var Zi,ht,Qi=function(e,t,n){var i=e.length,r=0,s=new ei(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var a=new ei(t);for(r=1;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;var o;if(n){o=new ei(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],d=a[e[r]-1]++<<u;for(var f=d|(1<<u)-1;d<=f;++d)o[vh[d]>>c]=l}}else{o=new ei(i);for(r=0;r<i;++r)if(e[r])o[r]=vh[a[e[r]-1]++]>>15-e[r]}return o},Yr=new Jt(288);for(ht=0;ht<144;++ht)Yr[ht]=8;var ht;for(ht=144;ht<256;++ht)Yr[ht]=9;var ht;for(ht=256;ht<280;++ht)Yr[ht]=7;var ht;for(ht=280;ht<288;++ht)Yr[ht]=8;var ht,dc=new Jt(32);for(ht=0;ht<32;++ht)dc[ht]=5;var ht,k1=Qi(Yr,9,0),D1=Qi(Yr,9,1),L1=Qi(dc,5,0),F1=Qi(dc,5,1),mh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Mi=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},gh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},wh=function(e){return(e+7)/8|0},fc=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Jt(e.subarray(t,n))};var U1=["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||U1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Un);if(!n)throw i;return i},B1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Jt(0);var a=!n,o=a||t.i!=2,c=t.i;if(a)n=new Jt(r*3);var l=function(ce){var _e=n.length;if(ce>_e){var Re=new Jt(Math.max(_e*2,ce));Re.set(n),n=Re}},u=t.f||0,d=t.p||0,f=t.b||0,{l:h,d:y,m:g,n:m}=t,p=r*8;do{if(!h){u=Mi(e,d,1);var b=Mi(e,d+1,3);if(d+=3,!b){var _=wh(d)+4,x=e[_-4]|e[_-3]<<8,v=_+x;if(v>r){if(c)Un(0);break}if(o)l(f+x);n.set(e.subarray(_,v),f),t.b=f+=x,t.p=d=v*8,t.f=u;continue}else if(b==1)h=D1,y=F1,g=9,m=5;else if(b==2){var E=Mi(e,d,31)+257,S=Mi(e,d+10,15)+4,T=E+Mi(e,d+5,31)+1;d+=14;var A=new Jt(T),P=new Jt(19);for(var w=0;w<S;++w)P[xh[w]]=Mi(e,d+w*3,7);d+=S*3;var I=mh(P),F=(1<<I)-1,N=Qi(P,I,1);for(var w=0;w<T;){var U=N[Mi(e,d,F)];d+=U&15;var _=U>>4;if(_<16)A[w++]=_;else{var D=0,O=0;if(_==16)O=3+Mi(e,d,3),d+=2,D=A[w-1];else if(_==17)O=3+Mi(e,d,7),d+=3;else if(_==18)O=11+Mi(e,d,127),d+=7;while(O--)A[w++]=D}}var K=A.subarray(0,E),B=A.subarray(E);g=mh(K),m=mh(B),h=Qi(K,g,1),y=Qi(B,m,1)}else Un(1);if(d>p){if(c)Un(0);break}}if(o)l(f+131072);var X=(1<<g)-1,q=(1<<m)-1,le=d;for(;;le=d){var D=h[gh(e,d)&X],de=D>>4;if(d+=D&15,d>p){if(c)Un(0);break}if(!D)Un(2);if(de<256)n[f++]=de;else if(de==256){le=d,h=null;break}else{var Me=de-254;if(de>264){var w=de-257,pe=su[w];Me=Mi(e,d,(1<<pe)-1)+rv[w],d+=pe}var J=y[gh(e,d)&q],L=J>>4;if(!J)Un(3);d+=J&15;var B=O1[L];if(L>3){var pe=au[L];B+=gh(e,d)&(1<<pe)-1,d+=pe}if(d>p){if(c)Un(0);break}if(o)l(f+131072);var W=f+Me;if(f<B){var te=s-B,ie=Math.min(B,W);if(te+f<0)Un(3);for(;f<ie;++f)n[f]=i[te+f]}for(;f<W;++f)n[f]=n[f-B]}}if(t.l=h,t.p=le,t.b=f,t.f=u,h)u=1,t.m=g,t.d=y,t.n=m}while(!u);return f!=n.length&&a?fc(n,0,f):n.subarray(0,f)},Rr=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},lc=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},bh=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:ov,l:0};if(r==1){var a=new Jt(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(v,E){return v.f-E.f}),n.push({s:-1,f:25001});var o=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:o.f+c.f,l:o,r:c};while(u!=r-1)o=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:o.f+c.f,l:o,r:c};var f=s[0].s;for(var i=1;i<r;++i)if(s[i].s>f)f=s[i].s;var h=new ei(f+1),y=Eh(n[u-1],h,0);if(y>t){var i=0,g=0,m=y-t,p=1<<m;s.sort(function(E,S){return h[S.s]-h[E.s]||E.f-S.f});for(;i<r;++i){var b=s[i].s;if(h[b]>t)g+=p-(1<<y-h[b]),h[b]=t;else break}g>>=m;while(g>0){var _=s[i].s;if(h[_]<t)g-=1<<t-h[_]++-1;else++i}for(;i>=0&&g;--i){var x=s[i].s;if(h[x]==t)--h[x],++g}y=t}return{t:new Jt(h),l:y}},Eh=function(e,t,n){return e.s==-1?Math.max(Eh(e.l,t,n+1),Eh(e.r,t,n+1)):t[e.s]=n},Z0=function(e){var t=e.length;while(t&&!e[--t]);var n=new ei(++t),i=0,r=e[0],s=1,a=function(c){n[i++]=c};for(var o=1;o<=t;++o)if(e[o]==r&&o!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);if(s>2)a(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){a(r),--s;for(;s>6;s-=6)a(8304);if(s>2)a(s-3<<5|8208),s=0}while(s--)a(r);s=1,r=e[o]}return{c:n.subarray(0,i),n:t}},uc=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},av=function(e,t,n){var i=n.length,r=wh(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},Y0=function(e,t,n,i,r,s,a,o,c,l,u){Rr(t,u++,n),++r[256];var d=bh(r,15),{t:f,l:h}=d,y=bh(s,15),{t:g,l:m}=y,p=Z0(f),{c:b,n:_}=p,x=Z0(g),{c:v,n:E}=x,S=new ei(19);for(var T=0;T<b.length;++T)++S[b[T]&31];for(var T=0;T<v.length;++T)++S[v[T]&31];var A=bh(S,7),{t:P,l:w}=A,I=19;for(;I>4&&!P[xh[I-1]];--I);var F=l+5<<3,N=uc(r,Yr)+uc(s,dc)+a,U=uc(r,f)+uc(s,g)+a+14+3*I+uc(S,P)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&F<=N&&F<=U)return av(t,u,e.subarray(c,c+l));var D,O,K,B;if(Rr(t,u,1+(U<N)),u+=2,U<N){D=Qi(f,h,0),O=f,K=Qi(g,m,0),B=g;var X=Qi(P,w,0);Rr(t,u,_-257),Rr(t,u+5,E-1),Rr(t,u+10,I-4),u+=14;for(var T=0;T<I;++T)Rr(t,u+3*T,P[xh[T]]);u+=3*I;var q=[b,v];for(var le=0;le<2;++le){var de=q[le];for(var T=0;T<de.length;++T){var Me=de[T]&31;if(Rr(t,u,X[Me]),u+=P[Me],Me>15)Rr(t,u,de[T]>>5&127),u+=de[T]>>12}}}else D=k1,O=Yr,K=L1,B=dc;for(var T=0;T<o;++T){var pe=i[T];if(pe>255){var Me=pe>>18&31;if(lc(t,u,D[Me+257]),u+=O[Me+257],Me>7)Rr(t,u,pe>>23&31),u+=su[Me];var J=pe&31;if(lc(t,u,K[J]),u+=B[J],J>3)lc(t,u,pe>>5&8191),u+=au[J]}else lc(t,u,D[pe]),u+=O[pe]}return lc(t,u,D[256]),u+O[256]},z1=new Sh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ov=new Jt(0),V1=function(e,t,n,i,r,s){var a=s.z||e.length,o=new Jt(i+a+5*(1+Math.ceil(a/7000))+r),c=o.subarray(i,o.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=z1[t-1],f=d>>13,h=d&8191,y=(1<<n)-1,g=s.p||new ei(32768),m=s.h||new ei(y+1),p=Math.ceil(n/3),b=2*p,_=function(Oe){return(e[Oe]^e[Oe+1]<<p^e[Oe+2]<<b)&y},x=new Sh(25000),v=new ei(288),E=new ei(32),S=0,T=0,A=s.i||0,P=0,w=s.w||0,I=0;for(;A+2<a;++A){var F=_(A),N=A&32767,U=m[F];if(g[N]=U,m[F]=N,w<=A){var D=a-A;if((S>7000||P>24576)&&(D>423||!l)){u=Y0(e,c,0,x,v,E,T,P,I,A-I,u),P=S=T=0,I=A;for(var O=0;O<286;++O)v[O]=0;for(var O=0;O<30;++O)E[O]=0}var K=2,B=0,X=h,q=N-U&32767;if(D>2&&F==_(A-q)){var le=Math.min(f,D)-1,de=Math.min(32767,A),Me=Math.min(258,D);while(q<=de&&--X&&N!=U){if(e[A+K]==e[A+K-q]){var pe=0;for(;pe<Me&&e[A+pe]==e[A+pe-q];++pe);if(pe>K){if(K=pe,B=q,pe>le)break;var J=Math.min(q,pe-2),L=0;for(var O=0;O<J;++O){var W=A-q+O&32767,te=g[W],ie=W-te&32767;if(ie>L)L=ie,U=W}}}N=U,U=g[N],q+=N-U&32767}}if(B){x[P++]=268435456|_h[K]<<18|J0[B];var ce=_h[K]&31,_e=J0[B]&31;T+=su[ce]+au[_e],++v[257+ce],++E[_e],w=A+K,++S}else x[P++]=e[A],++v[e[A]]}}for(A=Math.max(A,w);A<a;++A)x[P++]=e[A],++v[e[A]];if(u=Y0(e,c,l,x,v,E,T,P,I,A-I,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=m,s.p=g,s.i=A,s.w=w}else{for(var A=s.w||0;A<a+l;A+=65535){var Re=A+65535;if(Re>=a)c[u/8|0]=l,Re=a;u=av(c,u+1,e.subarray(A,Re))}s.i=a}return fc(o,0,i+wh(u)+r)},j1=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}(),H1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=j1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var G1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),a=new Jt(s.length+e.length);a.set(s),a.set(e,s.length),e=a,r.w=s.length}}return V1(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)},cv=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 Yi=function(e,t){return e[t]|e[t+1]<<8},Ri=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},yh=function(e,t){return Ri(e,t)+Ri(e,t+4)*4294967296},wn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function $1(e,t){return G1(e,t||{},0,0)}function K1(e,t){return B1(e,{i:2},t&&t.out,t&&t.dictionary)}var lv=function(e,t,n,i){for(var r in e){var s=e[r],a=t+r,o=i;if(Array.isArray(s))o=cv(i,s[1]),s=s[0];if(s instanceof Jt)n[a]=[s,o];else n[a+="/"]=[new Jt(0),o],lv(s,a,n,i)}},Q0=typeof TextEncoder<"u"&&new TextEncoder,Th=typeof TextDecoder<"u"&&new TextDecoder,W1=0;try{Th.decode(ov,{stream:!0}),W1=1}catch(e){}var X1=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:fc(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 ev(e,t){if(t){var n=new Jt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(Q0)return Q0.encode(e);var r=e.length,s=new Jt(e.length+(e.length>>1)),a=0,o=function(u){s[a++]=u};for(var i=0;i<r;++i){if(a+5>s.length){var c=new Jt(a+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)o(l);else if(l<2048)o(192|l>>6),o(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63);else o(224|l>>12),o(128|l>>6&63),o(128|l&63)}return fc(s,0,a)}function q1(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(Th)return Th.decode(e);else{var r=X1(e),{s,r:n}=r;if(n.length)Un(8);return s}}var J1=function(e,t){return t+30+Yi(e,t+26)+Yi(e,t+28)},Z1=function(e,t,n){var i=Yi(e,t+28),r=q1(e.subarray(t+46,t+46+i),!(Yi(e,t+8)&2048)),s=t+46+i,a=Ri(e,t+20),o=n&&a==4294967295?Y1(e,s):[a,Ri(e,t+24),Ri(e,t+42)],c=o[0],l=o[1],u=o[2];return[Yi(e,t+10),c,l,r,s+Yi(e,t+30)+Yi(e,t+32),u]},Y1=function(e,t){for(;Yi(e,t)!=1;t+=4+Yi(e,t+2));return[yh(e,t+12),yh(e,t+4),yh(e,t+20)]},Ah=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},tv=function(e,t,n,i,r,s,a,o){var c=i.length,l=n.extra,u=o&&o.length,d=Ah(l);if(wn(e,t,a!=null?33639248:67324752),t+=4,a!=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 f=new Date(n.mtime==null?Date.now():n.mtime),h=f.getFullYear()-1980;if(h<0||h>119)Un(10);if(wn(e,t,h<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,s!=-1)wn(e,t,n.crc),wn(e,t+4,s<0?-s-2:s),wn(e,t+8,n.size);if(wn(e,t+12,c),wn(e,t+14,d),t+=16,a!=null)wn(e,t,u),wn(e,t+6,n.attrs),wn(e,t+10,a),t+=14;if(e.set(i,t),t+=c,d)for(var y in l){var g=l[y],m=g.length;wn(e,t,+y),wn(e,t+2,m),e.set(g,t+4),t+=4+m}if(u)e.set(o,t),t+=u;return t},Q1=function(e,t,n,i,r){wn(e,t,101010256),wn(e,t+8,n),wn(e,t+10,n),wn(e,t+12,i),wn(e,t+16,r)};function uv(e,t){if(!t)t={};var n={},i=[];lv(e,"",n,t);var r=0,s=0;for(var a in n){var o=n[a],c=o[0],l=o[1],u=l.level==0?0:8,d=ev(a),f=d.length,h=l.comment,y=h&&ev(h),g=y&&y.length,m=Ah(l.extra);if(f>65535)Un(11);var p=u?$1(c,l):c,b=p.length,_=H1();_.p(c),i.push(cv(l,{size:c.length,crc:_.d(),c:p,f:d,m:y,u:f!=a.length||y&&h.length!=g,o:r,compression:u})),r+=30+f+m+b,s+=76+2*(f+m)+(g||0)+b}var x=new Jt(s+22),v=r,E=s-r;for(var S=0;S<i.length;++S){var d=i[S];tv(x,d.o,d,d.f,d.u,d.c.length);var T=30+d.f.length+Ah(d.extra);x.set(d.c,d.o+T),tv(x,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+T+(d.m?d.m.length:0)}return Q1(x,r,i.length,E,v),x}function dv(e,t){var n={},i=e.length-22;for(;Ri(e,i)!=101010256;--i)if(!i||e.length-i>65558)Un(13);var r=Yi(e,i+8);if(!r)return{};var s=Ri(e,i+16),a=s==4294967295||r==65535;if(a){var o=Ri(e,i-12);if(a=Ri(e,o)==101075792,a)r=Ri(e,o+32),s=Ri(e,o+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=Z1(e,s,a),d=u[0],f=u[1],h=u[2],y=u[3],g=u[4],m=u[5],p=J1(e,m);if(s=g,!c||c({name:y,size:f,originalSize:h,compression:d}))if(!d)n[y]=fc(e,p,p+f);else if(d==8)n[y]=K1(e.subarray(p,p+f),{out:new Jt(h)});else Un(14,"unknown compression type "+d)}return n}var er=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];ou();var cu=1024,lu=4,uu=8,Rh=6,fv=80,aa=256;class yt extends ja{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var hv=["solid","checker","stripes","gradient","bricks","noise"],pv=["normal","multiply","screen","overlay"],tC=new Set(["__proto__","prototype","constructor"]);function du(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new yt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new yt(`${t} must not contain symbol keys.`);if(tC.has(i))throw new yt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new yt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new yt(`${t}.${i} must be a plain JSON data field.`)}return e}function nC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new yt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new yt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new yt(`${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 yt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Qr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new yt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Ii(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new yt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function sa(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new yt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function gv(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 yt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Mh(e,t,n){return gv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function iC(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>fv||n)throw new yt(`${t} must be 1..${fv} visible characters.`);return e}function rC(e,t,n){if(e===void 0)return n;if(!er.includes(e))throw new yt(`${t} must be one of ${er.join(", ")}, got ${JSON.stringify(e)}.`);return e}function mv(e,t){let i=(gv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function sC(e,t){let n=e.blend??"normal";if(!pv.includes(n))throw new yt(`${t}.blend ${JSON.stringify(n)} is not one of ${pv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function aC(e,t){let n=`proceduralTexture.layers[${t}]`,i=du(e,n),r=i.op;if(!hv.includes(r))throw new yt(`${n}.op ${JSON.stringify(r)} is not one of ${hv.join(", ")}.`);let s=sC(i,n),a=Mh(i.opacity,`${n}.opacity`,1),o={blend:t===0?"normal":s,opacity:t===0?1:a};switch(r){case"solid":return Qr(i,["op","color","blend","opacity"],n),{op:r,color:Ii(i.color,`${n}.color`),...o};case"checker":return Qr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Ii(i.colorA,`${n}.colorA`),colorB:Ii(i.colorB,`${n}.colorB`),squares:sa(i.squares,`${n}.squares`,8,1,aa),...o};case"stripes":return Qr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Ii(i.colorA,`${n}.colorA`),colorB:Ii(i.colorB,`${n}.colorB`),count:sa(i.count,`${n}.count`,8,1,aa),angleDeg:mv(i.angleDeg,`${n}.angleDeg`),...o};case"gradient":return Qr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Ii(i.from,`${n}.from`),to:Ii(i.to,`${n}.to`),angleDeg:mv(i.angleDeg,`${n}.angleDeg`),...o};case"bricks":return Qr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Ii(i.brick,`${n}.brick`),mortar:Ii(i.mortar,`${n}.mortar`),rows:sa(i.rows,`${n}.rows`,8,1,aa),cols:sa(i.cols,`${n}.cols`,4,1,aa),mortarWidth:Mh(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Mh(i.stagger,`${n}.stagger`,0.5),...o};case"noise":return Qr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Ii(i.colorA,`${n}.colorA`),colorB:Ii(i.colorB,`${n}.colorB`),scale:sa(i.scale,`${n}.scale`,8,1,aa),octaves:sa(i.octaves,`${n}.octaves`,3,1,Rh),seed:sa(i.seed,`${n}.seed`,0,-2147483648,2147483647),...o};default:throw new yt(`${n}.op is unsupported.`)}}function oC(e){let t=du(e,"proceduralTexture");if(Qr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new yt(`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 hc(e){let t=du(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?du(oC(t),"proceduralTexture"):t;if(Qr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new yt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<lu||i>cu||(i&i-1)!==0)throw new yt(`proceduralTexture.size must be a power of two between ${lu} and ${cu}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new yt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=nC(r,"proceduralTexture.layers");if(s.length>uu)throw new yt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${uu}.`);let a=iC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:rC(n.usage,"proceduralTexture.usage","albedo"),...a!==void 0?{name:a}:{},layers:s.map(aC)}}var cC=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]),tr=(e,t)=>e>>>t|e<<32-t;function Ha(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let b=0;b<16;b++)o[b]=s.getUint32(c+b*4,!1);for(let b=16;b<64;b++){let _=o[b-15],x=o[b-2],v=tr(_,7)^tr(_,18)^_>>>3,E=tr(x,17)^tr(x,19)^x>>>10;o[b]=o[b-16]+v+o[b-7]+E>>>0}let[l,u,d,f,h,y,g,m]=a;for(let b=0;b<64;b++){let _=tr(h,6)^tr(h,11)^tr(h,25),x=h&y^~h&g,v=m+_+x+cC[b]+o[b]>>>0,E=tr(l,2)^tr(l,13)^tr(l,22),S=l&u^l&d^u&d,T=E+S>>>0;m=g,g=y,y=h,h=f+v>>>0,f=d,d=u,u=l,l=v+T>>>0}let p=[l,u,d,f,h,y,g,m];for(let b=0;b<8;b++)a[b]=a[b]+p[b]>>>0}return[...a].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Ga="kiln.procedural-rgba.v3.1";var mc=1024,lC=1048576,gc=64,hu=64,pc=256,pu=32,bv=64000000,uC=67108864;function gt(e){throw new yt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var dC=new Set(["__proto__","prototype","constructor"]);function fC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)gt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)gt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))gt(`${r} must be finite.`);return}if(typeof i!=="object")gt(`${r} must contain only JSON data.`);let a=Array.isArray(i),o=Object.getPrototypeOf(i);if(a?o!==Array.prototype:o!==Object.prototype&&o!==null)gt(`${r} must be a plain JSON ${a?"array":"object"}.`);let c=a?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(a&&(typeof c!=="number"||c>1024))gt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)gt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||dC.has(d))gt(`${r} has a forbidden key.`);if(a&&d==="length")continue;let f=u[d];if(!f.enumerable||!("value"in f))gt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(a&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))gt(`${r} has an invalid array key.`)}if(a&&l.length!==c+1)gt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!a)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function mi(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))gt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))gt(`${n} has unknown field ${r}.`);return i}function Bn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)gt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function yv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")gt(`${t} must be boolean.`);return e}function fu(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)gt(`${n} must be a ${t}-element array.`);return e.map((s,a)=>Bn(s,i,r,`${n}[${a}]`))}function xv(e,t){let n=fu(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function _v(e,t,n){let i=mi(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:Bn(i.x,-4096,4096,`${t}.x`),y:Bn(i.y,-4096,4096,`${t}.y`),width:Bn(i.width,1,2048,`${t}.width`),height:Bn(i.height,1,2048,`${t}.height`)}}function hC(e,t){let n=mi(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,..._v(n,t,n.kind)};if(n.kind==="polygon"){mi(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>hu)gt(`${t}.points requires 3..${hu} vertices.`);return{kind:"polygon",points:i.map((r,s)=>fu(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return mi(n,["kind","from","to","width"],t),{kind:"line",from:fu(n.from,2,`${t}.from`,-4096,4096),to:fu(n.to,2,`${t}.to`,-4096,4096),width:Bn(n.width,1,2048,`${t}.width`)};return gt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function vv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function pC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function mC(e,t,n,i=0,r=0){let[s,a,o,c]=vv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(a+r-0.5)),Math.min(t,Math.floor(o+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function mu(e){fC(e);let t=mi(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)gt("schemaVersion must be 3.");let n=Bn(t.width,4,mc,"width"),i=Bn(t.height,4,mc,"height"),r=n*i;if(r>lC)gt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!er.includes(s))gt("usage must be a known texture usage.");let a=s==="albedo"||s==="emissive",o=t.name;if(o!==void 0&&(typeof o!=="string"||!o.length||o.length>80||[...o].some((m)=>m.charCodeAt(0)<32||m.charCodeAt(0)===127)))gt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>gc)gt(`operations must be an array with at most ${gc} entries.`);let l=r,u=0,d=0,f=c.map((m,p)=>{let b=`operations[${p}]`,_=mi(m,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],b);if(_.op==="legacy-v2"){mi(_,["op","spec","alpha","opacity"],b);let K=mi(_.spec,["schemaVersion","size","usage","name","layers"],`${b}.spec`);if(K.schemaVersion!==2)gt(`${b}.spec requires explicit schemaVersion 2.`);let B=hc(K);if(B.size!==n||B.size!==i||B.usage!==s)gt(`${b} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+B.layers.reduce((X,q)=>X+(q.op==="noise"?q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:B,alpha:Bn(_.alpha,0,255,`${b}.alpha`,255),opacity:Bn(_.opacity,0,255,`${b}.opacity`,255)}}let x=hC(_.shape,`${b}.shape`),v=pC(x),[E,S,T,A]=mC(x,n,i),P=Math.max(0,T-E)*Math.max(0,A-S);if(_.op==="mask")return mi(_,["op","shape","alpha","invert"],b),l+=r+P*v,{op:"mask",shape:x,alpha:Bn(_.alpha,0,255,`${b}.alpha`,255),invert:yv(_.invert,`${b}.invert`)};if(_.op!=="paint"&&_.op!=="stamps")return gt(`${b}.op must be paint, mask, stamps or legacy-v2.`);let w={shape:x,rgba:xv(_.rgba,`${b}.rgba`),opacity:Bn(_.opacity,0,255,`${b}.opacity`,255)};if(_.op==="paint")return mi(_,["op","shape","rgba","opacity"],b),l+=P*(v+1),{op:"paint",...w};if(mi(_,["op","shape","rgba","opacity","count","seed","area","periodic"],b),!a)gt("stamps are supported only for color usages albedo and emissive.");let I=Bn(_.count,1,pc,`${b}.count`),F=yv(_.periodic,`${b}.periodic`),[N,U,D,O]=vv(x);if(F&&(D-N>n||O-U>i))gt(`${b} periodic shape bounds must fit one surface period.`);if(u+=I*(F?9:1),u>pc)gt(`expanded stamps budget exceeds ${pc}.`);return l+=I*(F?9:1)*Math.min(n,Math.ceil(D-N)+1)*Math.min(i,Math.ceil(O-U)+1)*(v+1),{op:"stamps",...w,count:I,seed:Bn(_.seed,0,4294967295,`${b}.seed`),area:_v(_.area,`${b}.area`),periodic:F}}),h;if(t.palette!==void 0){if(!a)gt("palette and dither are supported only for color usages albedo and emissive.");let m=mi(t.palette,["colors","dither"],"palette"),p=m.colors;if(!Array.isArray(p)||p.length<1||p.length>pu)gt(`palette.colors requires 1..${pu} entries.`);let b=m.dither===void 0?"none":m.dither;if(b!=="none"&&b!=="bayer4")gt("palette.dither must be none or bayer4.");h={colors:p.map((_,x)=>Bn(_,0,16777215,`palette.colors[${x}]`)),dither:b},l+=r*(p.length+1)}if(l>bv)gt(`estimated work budget ${l} exceeds ${bv}.`);if(r*4+d>uC)gt("transient allocation budget exceeded.");let y={schemaVersion:3,width:n,height:i,usage:s,...o!==void 0?{name:o}:{},background:t.background===void 0?[0,0,0,0]:xv(t.background,"background"),operations:f,...h?{palette:h}:{}},g=JSON.stringify(y);if(g.length>262144)gt("canonical JSON byte budget exceeded.");return{spec:y,canonicalJson:g,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Ih(e){return mu(e).spec}function gC(e){return mu(e).canonicalJson}function Ch(e){return`sha256:${Ha(`${Ga}
+${gC(e)}`)}`}var Nh=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],Ph=["nearest","linear"],bc=["repeat","clamp-to-edge","mirrored-repeat"];function gu(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new yt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new yt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Nh,magFilter:Ph,wrapS:bc,wrapT:bc};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new yt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new yt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}ou();var Av="kiln.texture-atlas.v1.1",Sv="kiln.texture-atlas.v1.2",bu=Object.freeze([Av,Sv]),oa=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Ir=Object.freeze({...oa,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),kh=Object.freeze([1024,2048]);function wv(e){return e.pack===void 0?Av:Sv}function bC(e){return e.pack===void 0?oa:Ir}class Mv extends ja{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function He(e){throw new Mv(e)}function Dh(e){let t=0,n=0,i=new TextEncoder,r=(a)=>{if(n+=a,n>oa.jsonBytes)He("JSON byte budget exceeded.")},s=(a,o)=>{if(++t>65536||o>16)He("JSON node/depth budget exceeded.");if(a===null||typeof a==="boolean"){r(a===!1?5:4);return}if(typeof a==="number"){if(!Number.isFinite(a))He("JSON numbers must be finite.");r(JSON.stringify(a).length);return}if(typeof a==="string"){if(a.length>4096)He("JSON string budget exceeded.");r(i.encode(JSON.stringify(a)).length);return}if(typeof a!=="object")He("plain JSON data is required.");let c=Array.isArray(a),l=Object.getPrototypeOf(a);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)He("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(a,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))He("JSON array budget exceeded.");let d=Reflect.ownKeys(a);if(d.length>1024||c&&d.length!==u+1)He("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let f of d){if(c&&f==="length")continue;if(typeof f!=="string"||["__proto__","prototype","constructor"].includes(f))He("forbidden JSON field.");if(f.length>4096)He("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(f)).length+1);let h=Object.getOwnPropertyDescriptor(a,f);if(!h.enumerable||!("value"in h))He("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(f)||Number(f)>=u))He("invalid JSON array key.");s(h.value,o+1)}};s(e,0)}function zn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))He(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))He(`${n} has an unknown field.`);return i}function ti(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)He(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function es(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))He(`${t} must be an exact SHA-256 hash.`);return e}function Ev(e,t){let n=zn(e,["x","y","width","height"],t);return{x:ti(n.x,0,4096,`${t}.x`),y:ti(n.y,0,4096,`${t}.y`),width:ti(n.width,1,4096,`${t}.width`),height:ti(n.height,1,4096,`${t}.height`)}}function $a(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function Rv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)He("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)He("source crop/content dimensions must match; resampling is unsupported.")}function Oh(e){return e.kind==="procedural"?`procedural:${Ch(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var yC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Tv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function xC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(o)=>{let c=[];for(let l of r){if(!yC(l,o)){c.push(l);continue}if(o.x>l.x)c.push({x:l.x,y:l.y,width:o.x-l.x,height:l.height});if(o.x+o.width<l.x+l.width)c.push({x:o.x+o.width,y:l.y,width:l.x+l.width-o.x-o.width,height:l.height});if(o.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:o.y-l.y});if(o.y+o.height<l.y+l.height)c.push({x:l.x,y:o.y+o.height,width:l.width,height:l.y+l.height-o.y-o.height})}if(r=c.filter((l,u)=>!c.some((d,f)=>f!==u&&Tv(d,l)&&(!Tv(l,d)||f<u))),r.length>16384)He("pack: free-space bookkeeping budget exceeded.")};for(let o of n)s(o);let a=[...i].sort((o,c)=>c.width*c.height-o.width*o.height||(o.region.name<c.region.name?-1:o.region.name>c.region.name?1:0));for(let o of a){let c,l;for(let u of r){if(u.width<o.width||u.height<o.height)continue;let d=u.width-o.width,f=u.height-o.height,h=[Math.min(d,f),Math.max(d,f),u.y,u.x];if(!l||h[0]<l[0]||h[0]===l[0]&&(h[1]<l[1]||h[1]===l[1]&&(h[2]<l[2]||h[2]===l[2]&&h[3]<l[3])))c=u,l=h}if(!c)He(`pack: region ${o.region.name} (${o.width}x${o.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);o.region.content={x:c.x+o.region.gutter,y:c.y+o.region.gutter,width:o.region.content.width,height:o.region.content.height},s({x:c.x,y:c.y,width:o.width,height:o.height})}}function yc(e){Dh(e);let t=zn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)He("schemaVersion must be 1.");let n;if(t.pack!==void 0){let f=zn(t.pack,["edge","gutter","algorithm"],"pack");if(!kh.includes(f.edge))He("pack.edge must be 1024 or 2048.");if(f.algorithm!==void 0&&f.algorithm!=="maxrects")He("pack.algorithm must be 'maxrects'.");n={edge:f.edge,gutter:f.gutter===void 0?2:ti(f.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Ir:oa,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:ti(t.width,4,r,"width"),a=n&&t.height===void 0?n.edge:ti(t.height,4,r,"height");if(s*a>i.outputTexels)He("output texel budget exceeded.");if(!er.includes(t.usage))He("usage must be a texture usage.");let o=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)He(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((f,h)=>{let y=zn(f,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${h}]`);if(typeof y.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(y.name))He("region name must be a stable lowercase identifier.");let g=y.content!==void 0;if(!g&&!n)He(`region ${y.name}: content is required unless the atlas sets pack.`);if(y.packed!==void 0&&(y.packed!==!0||!n||!g))He("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let m=g?Ev(y.content,"content"):void 0,p=y.gutter===void 0?n?.gutter??2:ti(y.gutter,0,32,"gutter"),b=y.edgeMode===void 0?"copy-edge":y.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(b))He("unsupported edgeMode.");if(b==="mask-rgb-dilate"&&o!=="albedo"&&o!=="emissive")He("mask RGB dilation requires color usage.");let _=zn(y.source,["kind","spec","resourceId","pin","expected"],"source"),x,v=y.crop===void 0?void 0:Ev(y.crop,"crop");if(_.kind==="procedural"){zn(_,["kind","spec"],"procedural source");let S=mu(_.spec);if(S.spec.usage!==o)He("source usage does not match atlas usage.");x={kind:"procedural",spec:S.spec},v??={x:0,y:0,width:S.spec.width,height:S.spec.height},m??={x:0,y:0,width:v.width,height:v.height},Rv(v,m,S.spec.width,S.spec.height)}else if(_.kind==="resource"){if(zn(_,["kind","resourceId","pin","expected"],"resource source"),typeof _.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(_.resourceId))He("source resourceId must be an exact returned map ID.");let S=zn(_.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof S.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(S.resourceId))He("pin resourceId must be a material ID.");let T=es(S.revisionId,"pin revisionId"),A=es(S.sha256,"pin sha256");if(T!==A)He("source pin revision/hash mismatch.");let P;if(_.expected!==void 0){let w=zn(_.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");P={...w.width===void 0?{}:{width:ti(w.width,1,4096,"expected.width")},...w.height===void 0?{}:{height:ti(w.height,1,4096,"expected.height")},...w.imageSha256===void 0?{}:{imageSha256:es(w.imageSha256,"expected.imageSha256")},...w.decodedPixelHash===void 0?{}:{decodedPixelHash:es(w.decodedPixelHash,"expected.decodedPixelHash")}}}if(x={kind:"resource",resourceId:_.resourceId,pin:{resourceId:S.resourceId,revisionId:T,sha256:A},...P?{expected:P}:{}},!m){let w=v??(P?.width!==void 0&&P.height!==void 0?{width:P.width,height:P.height}:He(`region ${y.name}: a packed resource region needs a crop or expected width and height (its size).`));m={x:0,y:0,width:w.width,height:w.height}}if(v&&(v.width!==m.width||v.height!==m.height))He("source crop/content dimensions must match; resampling is unsupported.")}else He("source kind must be procedural or pinned resource.");let E={name:y.name,content:m,gutter:p,edgeMode:b,source:x,...v?{crop:v}:{},...n&&(!g||y.packed===!0)?{packed:!0}:{}};if(!g)c.push({region:E,width:E.content.width+2*p,height:E.content.height+2*p});return E}).sort((f,h)=>f.name<h.name?-1:f.name>h.name?1:0);if(new Set(l.map((f)=>f.name)).size!==l.length)He("duplicate region name.");if(c.length){let f=new Set(c.map((h)=>h.region));xC(s,a,l.filter((h)=>!f.has(h)).map((h)=>$a(h)),c)}for(let f of l){let h=$a(f);if(h.x<0||h.y<0||h.x+h.width>s||h.y+h.height>a)He("padded allocation is out of bounds.")}for(let f=0;f<l.length;f++)for(let h=f+1;h<l.length;h++){let y=$a(l[f]),g=$a(l[h]);if(y.x<g.x+g.width&&g.x<y.x+y.width&&y.y<g.y+g.height&&g.y<y.y+y.height)He(`padded allocations overlap: ${l[f].name}, ${l[h].name}.`)}if(new Set(l.map((f)=>Oh(f.source))).size>i.sources)He(`distinct source budget exceeds ${i.sources}.`);let u;try{u=gu(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(f){He(`sampler: ${f.message}`)}let d={schemaVersion:1,width:s,height:a,usage:o,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>oa.jsonBytes)He("canonical JSON byte budget exceeded.");return d}function _C(e){let t=yc(e);return`sha256:${Ha(`${wv(t)}
+${JSON.stringify(t)}`)}`}function nr(e){Dh(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 vC(e){return`sha256:${Ha(`kiln.atlas-layout.v1
+${nr({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:$a(t)}))})}`)}`}function Lh(e,t){Dh(e);let n=yc(t),i=zn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==wv(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")He("manifest version/compiler/dimensions/usage/origin mismatch.");if(nr(i.sampler)!==nr(n.sampler)||i.specHash!==_C(n)||i.layoutHash!==vC(n))He("manifest sampler/spec/layout identity mismatch.");es(i.decodedPixelHash,"manifest decodedPixelHash"),es(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[Oh(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)He("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=zn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))He("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)He("manifest source identity mismatch.");let d=ti(l.width,1,4096,"manifest source width"),f=ti(l.height,1,4096,"manifest source height");if(es(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(zn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||f!==u.spec.height||l.recipeHash!==Ch(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")He("manifest procedural source identity mismatch.")}else{zn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let h=zn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),y={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(h.materialId!==u.pin.resourceId||h.revisionId!==u.pin.revisionId||h.resourceId!==u.resourceId||h.width!==d||h.height!==f||h.usage!==n.usage||typeof h.slot!=="string"||y[h.slot]!==n.usage||h.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))He("manifest pinned resource descriptor mismatch.");if(es(h.imageSha256,"manifest source imageSha256"),ti(h.encodedByteLength,1,bC(n).encodedSourceBytes,"manifest encodedByteLength"),h.decodedPixelHash!==void 0&&h.decodedPixelHash!==l.decodedPixelHash)He("manifest source decodedPixelHash mismatch.");for(let g of["width","height","imageSha256","decodedPixelHash"]){let m=u.expected?.[g];if(m!==void 0&&m!==(g==="decodedPixelHash"?l[g]:h[g]))He("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:f})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=zn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=Oh(l.source),f=s.get(d),h=l.crop??{x:0,y:0,width:f.width,height:f.height};if(Rv(h,l.content,f.width,f.height),u.name!==l.name||u.sourceId!==d||nr(u.content)!==nr(l.content)||nr(u.allocation)!==nr($a(l))||nr(u.crop)!==nr(h))He("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:a,...o}=i;if(a!==`sha256:${Ha(`kiln.atlas-manifest.v1
+${nr(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var EC=(()=>{let e=mt().int().min(0).max(16777215),t=mt().int().min(1).max(aa),n=mt().min(-36000).max(36000),i=mt().min(0).max(1),r={blend:It(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:$e(2),size:mt().int().min(lu).max(cu),usage:It(er),name:Le().min(1).max(80).optional(),layers:at(wi("op",[be({op:$e("solid"),color:e,...r}).strict(),be({op:$e("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:$e("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:$e("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:$e("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:$e("noise"),colorA:e,colorB:e,scale:t,octaves:mt().int().min(1).max(Rh),seed:mt().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(uu)}).strict()})();function Iv(e,t=EC){let n=(X,q)=>mt().int().min(X).max(q),i=n(0,255),r=n(-4096,4096),s=G0([r,r]),a=G0([i,i,i,i]),o=It(er),c=I1(["sha256:",Le().regex(/^[a-f0-9]{64}$/)]),l=Le().min(1).max(80),u=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Le().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),f={width:n(1,4096),height:n(1,4096)},h=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),y=be({x:n(0,4096),y:n(0,4096),...f}).strict(),g=wi("kind",[h.extend({kind:$e("rectangle")}).strict(),h.extend({kind:$e("ellipse")}).strict(),be({kind:$e("polygon"),points:at(s).min(3).max(hu)}).strict(),be({kind:$e("line"),from:s,to:s,width:n(1,2048)}).strict()]),m=be({op:$e("paint"),shape:g,rgba:a,opacity:i}).strict(),p=be({op:$e("mask"),shape:g,alpha:i,invert:ra()}).strict(),b=be({op:$e("stamps"),shape:g,rgba:a,opacity:i,count:n(1,pc),seed:n(0,4294967295),area:h,periodic:ra()}).strict(),_=be({op:$e("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),x=be({colors:at(n(0,16777215)).min(1).max(pu),dither:It(["none","bayer4"])}).strict(),v={schemaVersion:$e(3),width:n(4,mc),height:n(4,mc),usage:o,name:l.optional(),background:a},E=be({...v,operations:at(wi("op",[m,p,b,_.extend({spec:t})])).max(gc),palette:x.optional()}).strict(),S=be({...v,usage:o.optional(),background:a.optional(),operations:at(wi("op",[m.partial({opacity:!0}),p.partial({alpha:!0,invert:!0}),b.partial({opacity:!0,periodic:!0}),_.partial({alpha:!0,opacity:!0})])).max(gc),palette:x.partial({dither:!0}).optional()}).strict(),T=be({minFilter:It(Nh),magFilter:It(Ph),wrapS:It(bc),wrapT:It(bc)}).strict(),A=be({resourceId:u,revisionId:c,sha256:c}).strict(),P=be({kind:$e("resource"),resourceId:d,pin:A,expected:be({...f,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),w=be({name:u,content:y,gutter:n(0,32),edgeMode:It(["copy-edge","mask-rgb-dilate"]),source:wi("kind",[be({kind:$e("procedural"),spec:E}).strict(),P]),crop:y.optional(),packed:$e(!0).optional()}).strict(),I={schemaVersion:$e(1),width:n(4,Ir.edge),height:n(4,Ir.edge),usage:o,sampler:T},F=Va(kh.map((X)=>$e(X))),N=be({...I,regions:at(w).min(1).max(Ir.regions),pack:be({edge:F,gutter:n(0,32),algorithm:$e("maxrects")}).strict().optional()}).strict(),U=be({...I,width:I.width.optional(),height:I.height.optional(),pack:be({edge:F,gutter:n(0,32).optional(),algorithm:$e("maxrects").optional()}).strict().optional(),sampler:T.optional(),regions:at(w.extend({source:wi("kind",[be({kind:$e("procedural"),spec:S}).strict(),P])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Ir.regions)}).strict(),D=be({materialId:u,revisionId:c,resourceId:d,slot:It(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:o,colorSpace:It(["srgb","linear"]),...f,encodedByteLength:n(1,oa.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),O={id:Le().min(1).max(1024),...f,decodedPixelHash:c},K=wi("kind",[be({...O,kind:$e("procedural"),recipeHash:c,compilerId:$e(Ga)}).strict(),be({...O,kind:$e("resource"),descriptor:D}).strict()]),B=be({version:$e("kiln.atlas-manifest.v1"),compilerId:It(bu),width:I.width,height:I.height,usage:o,origin:$e("top-left"),sampler:T,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:at(K).min(1).max(Ir.sources),regions:at(be({name:u,content:y,allocation:y,crop:y,sourceId:Le().min(1).max(1024)}).strict()).min(1).max(Ir.regions),manifestHash:c}).strict();return{portableSamplerSchema:T,proceduralTextureSpecV3Schema:S,canonicalProceduralTextureSpecV3Schema:E,textureAtlasSpecV1Schema:U,canonicalTextureAtlasSpecV1Schema:N,textureAtlasManifestV1Schema:B,materialMapPinSchema:A,verifiedPinnedMaterialMapDescriptorSchema:D}}var In=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Nv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Pv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Wa=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),rr=Le().regex(/^sha256:[a-f0-9]{64}$/),ir=Le().min(1).max(1000),Cv=Le().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Ov=be({id:Wa,kind:It(["external","procedural"]),provider:ir,creator:ir,assetId:ir.optional(),assetUrl:Cv.optional(),accessedAt:Le().datetime().optional(),license:be({spdx:ir,url:Cv,attribution:Le().max(4000)}).strict(),originalFiles:at(be({name:Le().min(1).max(200),sha256:rr,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"})}),kv=be({operation:ir,tool:ir,version:ir,parameters:nu(Le().max(100),Va([Le().max(2000),mt().finite(),ra()])).optional()}).strict(),Ci=mt().int().min(0).max(16777215),xc=mt().int().min(1).max(256),Ka={blend:It(["normal","multiply","screen","overlay"]).default("normal"),opacity:mt().min(0).max(1).default(1)},vc=be({schemaVersion:$e(2),size:mt().int().min(4).max(1024).default(256),usage:It(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Le().min(1).max(80).optional(),layers:at(wi("op",[be({op:$e("solid"),color:Ci,...Ka}).strict(),be({op:$e("checker"),colorA:Ci,colorB:Ci,squares:xc.default(8),...Ka}).strict(),be({op:$e("stripes"),colorA:Ci,colorB:Ci,count:xc.default(8),angleDeg:mt().min(-36000).max(36000).default(0),...Ka}).strict(),be({op:$e("gradient"),from:Ci,to:Ci,angleDeg:mt().min(-36000).max(36000).default(0),...Ka}).strict(),be({op:$e("bricks"),brick:Ci,mortar:Ci,rows:xc.default(8),cols:xc.default(4),mortarWidth:mt().min(0).max(1).default(0.06),stagger:mt().min(0).max(1).default(0.5),...Ka}).strict(),be({op:$e("noise"),colorA:Ci,colorB:Ci,scale:xc.default(8),octaves:mt().int().min(1).max(6).default(3),seed:mt().int().min(-2147483648).max(2147483647).default(0),...Ka}).strict()])).min(1).max(8)}).strict(),Bh=be({kind:$e("normal-from-height"),strength:mt().finite().positive().max(64)}).strict(),TC=be({compiler:$e("kiln.procedural-texture.v2"),spec:vc,derive:Bh.optional(),recipeHash:rr,pixelHash:rr,encoder:be({name:$e("sharp"),version:ir}).strict()}).strict(),Dv=be({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:It(["opaque","mask","blend"]).default("opaque"),alphaCutoff:mt().min(0).max(1).default(0.5),doubleSided:ra().default(!1)}).strict(),_c=be({schemaVersion:$e(1),materialId:Wa,revisionId:rr,name:Le().min(1).max(200),tags:at(Le().min(1).max(80)).max(30),tileable:ra(),physicalSizeMeters:be({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:Dv,sources:at(Ov).min(1).max(20),maps:at(be({slot:It(Nv),file:It(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:rr,bytes:mt().int().positive().max(In.maxMapBytes),width:mt().int().positive().max(In.maxMapEdge),height:mt().int().positive().max(In.maxMapEdge),usage:It(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:It(["srgb","linear"]),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Wa,originalFile:Le().min(1).max(200).optional(),transforms:at(kv).max(30),procedural:TC.optional()}).strict()).min(1).max(5)}).strict(),Fh=be({materialId:Wa,name:Le().min(1).max(200),tags:at(Le().min(1).max(80)).max(30).optional(),tileable:ra(),physicalSizeMeters:be({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:Dv.partial().optional(),sources:at(Ov).min(1).max(20),maps:at(be({slot:It(Nv),sourceId:Wa,transforms:at(kv).max(30),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),procedural:vc,derive:Bh.optional()}).strict()).min(1).max(5)}).strict(),Uh=be({schemaVersion:$e(1),records:at(be({manifest:_c,files:nu(Le().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Le().max(Math.ceil(In.maxMapBytes/3)*4))}).strict()).max(In.maxPayloadRecords)}).strict();function qa(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 a=Object.getOwnPropertyDescriptor(e,s);if(!("value"in a)||!a.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");qa(a.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function on(e){qa(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 AC(e){if(qa(e),new TextEncoder().encode(JSON.stringify(e)).length>In.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=_c.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!==Pv[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 a=t.sources.find((o)=>o.id===r.sourceId);if(!a)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(on(r.procedural.spec)!==on(hc(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(a.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(a.kind!=="external"||!a.originalFiles.some((o)=>o.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>In.maxRecordBytes||i>In.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Xa=Iv(vc),Lv=Xa.portableSamplerSchema.refine((e)=>{try{return on(e)===on(gu(e))}catch{return!1}}),SC=Xa.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return on(e)===on(Ih(e))}catch{return!1}}),wC=Xa.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return on(e)===on(yc(e))}catch{return!1}}),MC=Xa.textureAtlasManifestV1Schema,RC=be({resourceId:Wa,revisionId:rr,sha256:rr}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),IC=wi("kind",[be({kind:$e("procedural"),compilerId:It(["kiln.procedural-texture.v2",Ga]),spec:Va([vc,SC]),recipeHash:rr,pixelHash:rr,encoder:be({name:$e("sharp"),version:ir}).strict(),derive:Bh.optional()}).strict(),be({kind:$e("atlas"),compilerId:It(bu),spec:wC,manifest:MC,encoder:be({name:$e("sharp"),version:ir}).strict()}).strict().superRefine((e,t)=>{try{if(Lh(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error("compiler id")}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),Fv=_c.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:$e(2),dependencies:at(RC).max(16),maps:at(_c.shape.maps.element.omit({procedural:!0}).extend({sampler:Lv,pixelHash:rr,recipe:IC.optional()}).strict()).min(1).max(5)}).strict(),CC=wi("schemaVersion",[_c,Fv]),NC=Uh.extend({schemaVersion:$e(2),records:at(Uh.shape.records.element.extend({manifest:CC}).strict()).max(In.maxPayloadRecords)}).strict(),Uv=wi("schemaVersion",[Uh,NC]);function Bv(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var PC=Fh.extend({schemaVersion:$e(2),maps:at(Fh.shape.maps.element.omit({procedural:!0}).extend({sampler:Lv,procedural:Va([vc,Xa.proceduralTextureSpecV3Schema.refine((e)=>{try{return Ih(e),!0}catch{return!1}})]).optional(),atlas:Xa.textureAtlasSpecV1Schema.refine((e)=>{try{return yc(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),IV=Va([Fh,PC]);function Ja(e){if(qa(e),new TextEncoder().encode(JSON.stringify(e)).length>In.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return AC(e);let t=Fv.parse(e);if(new Set(t.sources.map((a)=>a.id)).size!==t.sources.length||new Set(t.maps.map((a)=>a.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let a of t.maps){let o=t.sources.find((l)=>l.id===a.sourceId);if(!o||a.file!==`${a.slot}.png`||a.usage!==Pv[a.slot]||a.colorSpace!==(a.slot==="baseColor"||a.slot==="emissive"?"srgb":"linear")||a.slot==="normal"!==(a.normalConvention==="opengl")||a.slot==="metallicRoughness"!==(a.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=a.recipe;if(c){if(o.kind!=="procedural"||a.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Ga||c.derive||l.width!==a.width||l.height!==a.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==a.width||a.width!==a.height||on(l)!==on(hc(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==a.usage||c.pixelHash!==a.pixelHash||c.derive&&a.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(Lh(c.manifest,c.spec),c.spec.width!==a.width||c.spec.height!==a.height||c.spec.usage!==a.usage||on(c.spec.sampler)!==on(a.sampler)||c.manifest.decodedPixelHash!==a.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(o.kind!=="external"||!o.originalFiles.some((l)=>l.name===a.originalFile))throw Error("External material source original file missing");n+=a.bytes,i+=a.width*a.height}let s=t.dependencies.map((a)=>`${a.resourceId}/${a.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((a)=>!r.has(a)))throw Error("Material dependency pin inventory mismatch");if(n>In.maxRecordBytes||i>In.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var ni=67108864,zh=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),OC=Le().regex(/^sha256:[a-f0-9]{64}$/),zv=be({version:$e("kiln.asset.v1"),assetId:zh,revisionId:zh,parentRevision:zh.optional(),name:Le().min(1).max(200),tags:at(Le().max(80)).max(30),createdAt:Le().datetime(),description:Le().max(4000).optional(),brief:Le().max(8000).optional(),attribution:be({model:Le().max(200).optional(),harness:Le().max(200).optional(),author:Le().max(200).optional()}).optional(),editable:ra(),files:nu(Le(),be({sha256:OC,bytes:mt().int().nonnegative().max(ni)})),build:be({engine:Le(),options:nu(Le(),ia()),warnings:at(Le()),integration:ia().optional(),qa:ia().optional(),dependencies:at(ia()).optional(),rebuild:It(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:ia().optional(),error:Le().optional(),backdrop:It(X0).optional()}).optional()}),Ec="materials.kiln.json",Vv=25165824;function Vh(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=Ja(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,a=t.get(s);if(a&&on(a)!==on(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>In.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function jv(e,t=!1){let n=Vh(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,on(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}qa(e.materialResources);let r=Uv.parse(e.materialResources),s=0,a=0,o=new Map;for(let d of r.records){let f=Ja(d.manifest),h=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(o.has(h)||i.has(h)&&i.get(h)!==on(f))throw Error("Asset material closure mismatch");if(o.set(h,f),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let y of d.manifest.maps){if(d.files[y.file]?.length!==Math.ceil(y.bytes/3)*4)throw Error("Asset material map size mismatch");s+=y.bytes,a+=y.width*y.height}}if(s>In.maxPayloadBytes||a>In.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let f=o.get(d);if(!f)throw Error("Asset material closure incomplete");l.add(d);for(let h of Bv(f))u(`${h.resourceId}/${h.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==o.size)throw Error("Asset material closure has unrelated records")}var kC=new Set(["asset.glb","source.kiln.js","preview.png"]);function yu(e){let t=zv.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(!kC.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>ni||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");jh(e.files["asset.glb"]),jv(e)}function jh(e){if(e.length<20||e.length>ni)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 Hh(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){yu(i),jv(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,a]of Object.entries(i.files))t[r+s]=a;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>Vv)throw Error("Asset material payload exceeds byte limit");t[r+Ec]=s}}for(let i of Object.values(t))n+=i.length;if(n>ni)throw Error("Bundle exceeds 64 MiB");return uv(t,{level:0})}function Hv(e){if(e.length>ni+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=dv(e,{filter:(a)=>{if(t+=a.originalSize,n++,t>ni||n>500||a.name.endsWith(`/${Ec}`)&&a.originalSize>Vv||!/^[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(a.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[a,o]of Object.entries(i)){if(!a.endsWith("/manifest.json"))continue;if(o.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=zv.parse(JSON.parse(new TextDecoder().decode(o))),l=`${c.assetId}/${c.revisionId}/`;if(a!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(a);for(let d of Object.keys(c.files)){if(!i[l+d])throw Error("Bundle file missing");u.files[d]=i[l+d],s.add(l+d)}if(i[l+Ec])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Ec])),s.add(l+Ec);yu(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function Gv(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)}zi();zi();var gA={type:"change"},qm={type:"start"},yA={type:"end"},Rd=new hs,bA=new bi,RL=Math.cos(70*zc.DEG2RAD),gn=new j,Kn=2*Math.PI,Pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Xm=0.000001;class Jm extends Td{constructor(e,t=null){super(e,t);if(this.state=Pt.NONE,this.target=new j,this.cursor=new j,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:cs.ROTATE,MIDDLE:cs.DOLLY,RIGHT:cs.PAN},this.touches={ONE:ls.ROTATE,TWO:ls.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 j,this._lastQuaternion=new ln,this._lastTargetPosition=new j,this._quat=new ln().setFromUnitVectors(e.up,new j(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new el,this._sphericalDelta=new el,this._scale=1,this._panOffset=new j,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 j,this._mouse=new Ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=CL.bind(this),this._onPointerDown=IL.bind(this),this._onPointerUp=NL.bind(this),this._onContextMenu=UL.bind(this),this._onMouseWheel=kL.bind(this),this._onKeyDown=DL.bind(this),this._onTouchStart=LL.bind(this),this._onTouchMove=FL.bind(this),this._onMouseDown=PL.bind(this),this._onMouseMove=OL.bind(this),this._interceptControlDown=BL.bind(this),this._interceptControlUp=zL.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=Pt.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(gA),this.update(),this.state=Pt.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(gn.copy(t).sub(this.target),gn.applyQuaternion(this._quat),this._spherical.setFromVector3(gn),this.autoRotate&&this.state===Pt.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+=Kn;else if(n>Math.PI)n-=Kn;if(i<-Math.PI)i+=Kn;else if(i>Math.PI)i-=Kn;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(gn.setFromSpherical(this._spherical),gn.applyQuaternion(this._quatInverse),t.copy(this.target).add(gn),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 a=gn.length();s=this._clampDistance(a*this._scale);let o=a-s;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),r=!!o}else if(this.object.isOrthographicCamera){let a=new j(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=o!==this.object.zoom;let c=new j(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),s=gn.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(Rd.origin.copy(this.object.position),Rd.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Rd.direction))<RL)this.object.lookAt(this.target);else bA.setFromNormalAndCoplanarPoint(this.object.up,this.target),Rd.intersectPlane(bA,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)>Xm||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Xm||this._lastTargetPosition.distanceToSquared(this.target)>Xm)return this.dispatchEvent(gA),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 Kn/60*this.autoRotateSpeed*e;else return Kn/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){gn.setFromMatrixColumn(t,0),gn.multiplyScalar(-e),this._panOffset.add(gn)}_panUp(e,t){if(this.screenSpacePanning===!0)gn.setFromMatrixColumn(t,1);else gn.setFromMatrixColumn(t,0),gn.crossVectors(this.object.up,gn);gn.multiplyScalar(e),this._panOffset.add(gn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;gn.copy(i).sub(this.target);let r=gn.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:a}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/a)*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(Kn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kn*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(Kn*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(-Kn*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(Kn*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(-Kn*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(Kn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kn*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,a=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,a)}_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 IL(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 CL(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function NL(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(yA),this.state=Pt.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 PL(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 cs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=Pt.DOLLY;break;case cs.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Pt.ROTATE}break;case cs.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Pt.PAN}break;default:this.state=Pt.NONE}if(this.state!==Pt.NONE)this.dispatchEvent(qm)}function OL(e){switch(this.state){case Pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case Pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case Pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function kL(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==Pt.NONE)return;e.preventDefault(),this.dispatchEvent(qm),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(yA)}function DL(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function LL(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case ls.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=Pt.TOUCH_ROTATE;break;case ls.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=Pt.TOUCH_PAN;break;default:this.state=Pt.NONE}break;case 2:switch(this.touches.TWO){case ls.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=Pt.TOUCH_DOLLY_PAN;break;case ls.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=Pt.TOUCH_DOLLY_ROTATE;break;default:this.state=Pt.NONE}break;default:this.state=Pt.NONE}if(this.state!==Pt.NONE)this.dispatchEvent(qm)}function FL(e){switch(this._trackPointer(e),this.state){case Pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case Pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case Pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case Pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=Pt.NONE}}function UL(e){if(this.enabled===!1)return;e.preventDefault()}function BL(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function zL(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}zi();class Zm extends Ao{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new ms;e.deleteAttribute("uv");let t=new Ur({side:Pn}),n=new Ur,i=new Co(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new jt(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 wo(e,n,6),a=new kt;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-0.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),s.setMatrixAt(0,a.matrix),a.position.set(-5.607,-0.754,-0.758),a.rotation.set(0,0.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),s.setMatrixAt(1,a.matrix),a.position.set(6.167,0.857,7.803),a.rotation.set(0,0.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),s.setMatrixAt(2,a.matrix),a.position.set(-2.017,0.018,6.124),a.rotation.set(0,0.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),s.setMatrixAt(3,a.matrix),a.position.set(2.291,-0.756,-2.621),a.rotation.set(0,-0.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),s.setMatrixAt(4,a.matrix),a.position.set(-2.193,-0.369,-5.547),a.rotation.set(0,0.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),s.setMatrixAt(5,a.matrix),this.add(s);let o=new jt(e,Do(50));o.position.set(-16.116,14.37,8.208),o.scale.set(0.1,2.428,2.739),this.add(o);let c=new jt(e,Do(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 jt(e,Do(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 jt(e,Do(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new jt(e,Do(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let f=new jt(e,Do(100));f.position.set(0,20,0),f.scale.set(1,0.1,1),this.add(f)}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 Do(e){return new md({color:0,emissive:16777215,emissiveIntensity:e})}zi();zi();zi();function Ym(e,t){if(t===lm)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===To||t===Bc){let n=e.getIndex();if(n===null){let s=[],a=e.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)s.push(o);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===To)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 xA(e){let t=new Map,n=new Map,i=e.clone();return _A(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,a=t.get(r),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function _A(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)_A(e.children[i],t.children[i],n)}class sg extends zr{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new RA(t)}),this.register(function(t){return new IA(t)}),this.register(function(t){return new UA(t)}),this.register(function(t){return new BA(t)}),this.register(function(t){return new zA(t)}),this.register(function(t){return new NA(t)}),this.register(function(t){return new PA(t)}),this.register(function(t){return new OA(t)}),this.register(function(t){return new kA(t)}),this.register(function(t){return new MA(t)}),this.register(function(t){return new DA(t)}),this.register(function(t){return new CA(t)}),this.register(function(t){return new FA(t)}),this.register(function(t){return new LA(t)}),this.register(function(t){return new SA(t)}),this.register(function(t){return new ng(t,ut.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new ng(t,ut.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new VA(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=_s.extractUrlBase(e);s=_s.resolveURL(c,this.path)}else s=_s.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},o=new Yc(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},n,a)}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={},a={},o=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===jA){try{s[ut.KHR_BINARY_GLTF]=new HA(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[ut.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.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 XA(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");a[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case ut.KHR_MATERIALS_UNLIT:s[u]=new wA;break;case ut.KHR_DRACO_MESH_COMPRESSION:s[u]=new GA(r,this.dracoLoader);break;case ut.KHR_TEXTURE_TRANSFORM:s[u]=new $A;break;case ut.KHR_MESH_QUANTIZATION:s[u]=new KA;break;default:if(d.indexOf(u)>=0&&a[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function VL(){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 rn(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var ut={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 SA{constructor(e){this.parser=e,this.name=ut.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,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new qe(16777215);if(o.color!==void 0)l.setRGB(o.color[0],o.color[1],o.color[2],si);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new No(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Co(l),c.distance=u;break;case"spot":c=new _d(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}if(c.position.set(0,0,0),gr(c,o),o.intensity!==void 0)c.intensity=o.intensity;return c.name=t.createUniqueName(o.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],a=(r.extensions&&r.extensions[this.name]||{}).light;if(a===void 0)return null;return this._loadLight(a).then(function(o){return n._getNodeRef(t.cache,a,o)})}}class wA{constructor(){this.name=ut.KHR_MATERIALS_UNLIT}getMaterialType(){return hr}extendParams(e,t,n){let i=[];e.color=new qe(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],si),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,fs))}return Promise.all(i)}}class MA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class RA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 IA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_DISPERSION}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class CA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 NA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_SHEEN}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new qe(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],si)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,fs));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class PA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 OA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_VOLUME}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 qe().setRGB(r[0],r[1],r[2],si),Promise.all(i)}}class kA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_IOR}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 DA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_SPECULAR}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 qe().setRGB(r[0],r[1],r[2],si),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,fs));return Promise.all(i)}}class LA{constructor(e){this.parser=e,this.name=ut.EXT_MATERIALS_BUMP}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 FA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(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 UA{constructor(e){this.parser=e,this.name=ut.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 BA{constructor(e){this.parser=e,this.name=ut.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],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class zA{constructor(e){this.parser=e,this.name=ut.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],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class ng{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(a){let o=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(a,o,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(f){return f.buffer});else return s.ready.then(function(){let f=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(f),l,u,d,i.mode,i.filter),f})})}else return null}}class VA{constructor(e){this.name=ut.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!==vi.TRIANGLES&&c.mode!==vi.TRIANGLE_STRIP&&c.mode!==vi.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,a=[],o={};for(let c in s)a.push(this.parser.getDependency("accessor",s[c]).then((l)=>(o[c]=l,o[c])));if(a.length<1)return null;return a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,f=[];for(let h of u){let y=new Qe,g=new j,m=new ln,p=new j(1,1,1),b=new wo(h.geometry,h.material,d);for(let x=0;x<d;x++){if(o.TRANSLATION)g.fromBufferAttribute(o.TRANSLATION,x);if(o.ROTATION)m.fromBufferAttribute(o.ROTATION,x);if(o.SCALE)p.fromBufferAttribute(o.SCALE,x);b.setMatrixAt(x,y.compose(g,m,p))}let _=null;for(let x in o)if(x==="_COLOR_0"){let v=o[x];b.instanceColor=new os(v.array,v.itemSize,v.normalized)}else if(x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"){if(_===null){let E=b.geometry;_=new On,_.name=E.name;for(let S in E.attributes)_.setAttribute(S,E.attributes[S]);for(let S in E.morphAttributes)_.morphAttributes[S]=E.morphAttributes[S];if(E.index!==null)_.setIndex(E.index);_.morphTargetsRelative=E.morphTargetsRelative;for(let S of E.groups)_.addGroup(S.start,S.count,S.materialIndex);if(E.boundingBox!==null)_.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)_.boundingSphere=E.boundingSphere.clone();_.drawRange.start=E.drawRange.start,_.drawRange.count=E.drawRange.count,_.userData=Object.assign({},E.userData),b.geometry=_}let v=o[x];_.setAttribute(x,new os(v.array,v.itemSize,v.normalized))}kt.prototype.copy.call(b,h),this.parser.assignFinalMaterial(b),f.push(b)}if(l.isGroup)return l.clear(),l.add(...f),l;return f[0]})}}var jA="glTF",al=12,vA={JSON:1313821514,BIN:5130562};class HA{constructor(e){this.name=ut.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,al),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!==jA)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-al,r=new DataView(e,al),s=0;while(s<i){let a=r.getUint32(s,!0);s+=4;let o=r.getUint32(s,!0);if(s+=4,o===vA.JSON){let c=new Uint8Array(e,al+s,a);this.content=n.decode(c)}else if(o===vA.BIN){let c=al+s;this.body=e.slice(c,c+a)}s+=a}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class GA{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ut.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,a={},o={},c={};for(let l in s){let u=ig[l]||l.toLowerCase();a[u]=s[l]}for(let l in e.attributes){let u=ig[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],f=Lo[d.componentType];c[u]=f.name,o[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(f){for(let h in f.attributes){let y=f.attributes[h],g=o[h];if(g!==void 0)y.normalized=g}u(f)},a,c,si,d)})})}}class $A{constructor(){this.name=ut.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 KA{constructor(){this.name=ut.KHR_MESH_QUANTIZATION}}class ag extends Br{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,a=this.valueSize,o=a*2,c=a*3,l=i-t,u=(n-t)/l,d=u*u,f=d*u,h=e*c,y=h-c,g=-2*f+3*d,m=f-d,p=1-g,b=m-d+u;for(let _=0;_!==a;_++){let x=s[y+_+a],v=s[y+_+o]*l,E=s[h+_+a],S=s[h+_]*l;r[_]=p*x+b*v+g*E+m*S}return r}}var jL=new ln;class WA extends ag{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return jL.fromArray(r).normalize().toArray(r),r}}var vi={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},Lo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},EA={9728:Fi,9729:En,9984:Ju,9985:vo,9986:ma,9987:ur},TA={33071:_o,33648:qu,10497:xo},Qm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ig={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"},vs={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},HL={CUBICSPLINE:void 0,LINEAR:id,STEP:cm},eg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function GL(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ur({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:us});return e.DefaultMaterial}function Sa(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 gr(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 $L(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let a=[],o=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let f=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(f)}if(r){let f=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(f)}if(s){let f=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(f)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],f=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=f;return e.morphTargetsRelative=!0,e})}function KL(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 WL(e){let t,n=e.extensions&&e.extensions[ut.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+tg(n.attributes);else t=e.indices+":"+tg(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+tg(e.targets[i]);return t}function tg(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 rg(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 XL(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 qL=new Qe;class XA{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new VL,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 a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);i=n&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Ro(this.options.manager);else this.textureLoader=new vd(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Yc(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 a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Sa(r,a,i),gr(a,i),Promise.all(n._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();e(a)})}).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 a=0,o=s.length;a<o;a++)e[s[a]].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,a)=>{let o=this.associations.get(s);if(o!=null)this.associations.set(a,o);for(let[c,l]of s.children.entries())r(l,a.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[ut.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(_s.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=Qm[i.type],a=Lo[i.componentType],o=i.normalized===!0,c=new a(i.count*s);return Promise.resolve(new vn(c,s,o))}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 a=s[0],o=Qm[i.type],c=Lo[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,h=i.normalized===!0,y,g;if(f&&f!==u){let m=Math.floor(d/f),p="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+m+":"+i.count,b=t.cache.get(p);if(!b)y=new c(a,m*f,i.count*f/l),b=new Hc(y,f/l),t.cache.add(p,b);g=new So(b,o,d%f/l,h)}else{if(a===null)y=new c(i.count*o);else y=new c(a,d,i.count*o);g=new vn(y,o,h)}if(i.sparse!==void 0){let m=Qm.SCALAR,p=Lo[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,x=new p(s[1],b,i.sparse.count*m),v=new c(s[2],_,i.sparse.count*o);if(a!==null)g=new vn(g.array.slice(),g.itemSize,g.normalized);g.normalized=!1;for(let E=0,S=x.length;E<S;E++){let T=x[E];if(g.setX(T,v[E*o]),o>=2)g.setY(T,v[E*o+1]);if(o>=3)g.setZ(T,v[E*o+2]);if(o>=4)g.setW(T,v[E*o+3]);if(o>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=h}return g})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],a=this.textureLoader;if(s.uri){let o=n.manager.getHandler(s.uri);if(o!==null)a=o}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||a.name||"",l.name===""&&typeof a.uri==="string"&&a.uri.startsWith("data:image/")===!1)l.name=a.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=EA[d.magFilter]||En,l.minFilter=EA[d.minFilter]||ur,l.wrapS=TA[d.wrapS]||xo,l.wrapT=TA[d.wrapT]||xo,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Fi&&l.minFilter!==En,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=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],a=self.URL||self.webkitURL,o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(d,f){let h=d;if(t.isImageBitmapLoader===!0)h=function(y){let g=new Qt(y);g.needsUpdate=!0,d(g)};t.load(_s.resolveURL(u,r.path),h,void 0,f)})}).then(function(u){if(c===!0)a.revokeObjectURL(o);return gr(u,s),u.userData.mimeType=s.mimeType||XL(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),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[ut.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[ut.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=r.associations.get(s);s=r.extensions[ut.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}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 a="PointsMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new qc,$n.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,o.sizeAttenuation=!1,this.cache.add(a,o);n=o}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new Xc,$n.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,this.cache.add(a,o);n=o}if(i||r||s){let a="ClonedMaterial:"+n.uuid+":";if(i)a+="derivative-tangents:";if(r)a+="vertex-colors:";if(s)a+="flat-shading:";let o=this.cache.get(a);if(!o){if(o=n.clone(),r)o.vertexColors=!0;if(s)o.flatShading=!0;if(i){if(o.normalScale)o.normalScale.y*=-1;if(o.clearcoatNormalScale)o.clearcoatNormalScale.y*=-1}this.cache.add(a,o),this.associations.set(o,this.associations.get(n))}n=o}e.material=n}getMaterialType(){return Ur}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,a={},o=r.extensions||{},c=[];if(o[ut.KHR_MATERIALS_UNLIT]){let u=i[ut.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new qe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],si),a.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(a,"map",u.baseColorTexture,fs));if(a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}if(r.doubleSided===!0)a.side=xi;let l=r.alphaMode||eg.OPAQUE;if(l===eg.BLEND)a.transparent=!0,a.depthWrite=!1;else if(a.transparent=!1,l===eg.MASK)a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==hr){if(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ke(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;a.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==hr){if(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)a.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==hr){let u=r.emissiveFactor;a.emissive=new qe().setRGB(u[0],u[1],u[2],si)}if(r.emissiveTexture!==void 0&&s!==hr)c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,fs));return Promise.all(c).then(function(){let u=new s(a);if(r.name)u.name=r.name;if(gr(u,r),t.associations.set(u,{materials:e}),r.extensions)Sa(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(a){return n[ut.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return AA(o,a,t)})}let s=[];for(let a=0,o=e.length;a<o;a++){let c=e[a],l=WL(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[ut.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=AA(new On,c,t);if(c.mode===vi.TRIANGLE_STRIP)d=d.then((f)=>Ym(f,Bc));else if(c.mode===vi.TRIANGLE_FAN)d=d.then((f)=>Ym(f,To));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,a=[];for(let o=0,c=s.length;o<c;o++){let l=s[o].material===void 0?GL(this.cache):this.getDependency("material",s[o].material);a.push(l)}return a.push(t.loadGeometries(s)),Promise.all(a).then(async function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let f=0,h=l.length;f<h;f++){let y=l[f],g=s[f],m,p=c[f];if(g.mode===vi.TRIANGLES||g.mode===vi.TRIANGLE_STRIP||g.mode===vi.TRIANGLE_FAN||g.mode===void 0){let b=r.isSkinnedMesh===!0,_=y.hasAttribute("skinIndex")&&y.hasAttribute("skinWeight");if(b&&_===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(m=b&&_?new ud(y,p):new jt(y,p),m.isSkinnedMesh===!0)m.normalizeSkinWeights()}else if(g.mode===vi.LINES)m=new dd(y,p);else if(g.mode===vi.LINE_STRIP)m=new ps(y,p);else if(g.mode===vi.LINE_LOOP)m=new fd(y,p);else if(g.mode===vi.POINTS)m=new Mo(y,p);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);if(Object.keys(m.geometry.morphAttributes).length>0)KL(m,r);if(m.name=t.createUniqueName(r.name||"mesh_"+e),gr(m,r),g.extensions)Sa(i,m,g);t.assignFinalMaterial(m),u.push(m)}for(let f=0,h=u.length;f<h;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1){if(r.extensions)Sa(i,u[0],r);return u[0]}let d=new ar;if(r.extensions)Sa(i,d,r);t.associations.set(d,{meshes:e});for(let f=0,h=u.length;f<h;f++)d.add(u[f]);return d})}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 fn(zc.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Ta(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return gr(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,a=[],o=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){a.push(u);let d=new Qe;if(r!==null)d.fromArray(r.array,c*16);o.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Kc(a,o)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],a=[],o=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let f=i.channels[u],h=i.samplers[f.sampler],y=f.target,g=y.node,m=i.parameters!==void 0?i.parameters[h.input]:h.input,p=i.parameters!==void 0?i.parameters[h.output]:h.output;if(y.node===void 0)continue;s.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",m)),o.push(this.getDependency("accessor",p)),c.push(h),l.push(y)}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],f=u[1],h=u[2],y=u[3],g=u[4],m=[];for(let b=0,_=d.length;b<_;b++){let x=d[b],v=f[b],E=h[b],S=y[b],T=g[b];if(x===void 0)continue;if(x.updateMatrix)x.updateMatrix();let A=n._createAnimationTracks(x,v,E,S,T);if(A)for(let P=0;P<A.length;P++)m.push(A[P])}let p=new mo(r,void 0,m);return gr(p,i),p})}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(a){if(!a.isMesh)return;for(let o=0,c=i.weights.length;o<c;o++)a.morphTargetInfluences[o]=i.weights[o]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],a=i.children||[];for(let c=0,l=a.length;c<l;c++)s.push(n.getDependency("node",a[c]));let o=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),o]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(f){if(!f.isSkinnedMesh)return;f.bind(d,qL)});for(let f=0,h=u.length;f<h;f++)l.add(u[f]);if(l.userData.pivot!==void 0&&u.length>0){let f=l.userData.pivot,h=u[0];l.pivot=new j().fromArray(f),l.position.x-=f[0],l.position.y-=f[1],l.position.z-=f[2],h.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):"",a=[],o=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(o)a.push(o);if(r.camera!==void 0)a.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){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0)l=new Gc;else if(c.length>1)l=new ar;else if(c.length===1)l=c[0];else l=new kt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(gr(l,r),r.extensions)Sa(n,l,r);if(r.matrix!==void 0){let u=new Qe;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 ar;if(n.name)r.name=i.createUniqueName(n.name);if(gr(r,n),n.extensions)Sa(t,r,n);let s=n.nodes||[],a=[];for(let o=0,c=s.length;o<c;o++)a.push(i.getDependency("node",s[o]));return Promise.all(a).then(function(o){for(let l=0,u=o.length;l<u;l++){let d=o[l];if(d.parent!==null)r.add(xA(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,f]of i.associations)if(d instanceof $n||d instanceof Qt)u.set(d,f);return l.traverse((d)=>{let f=i.associations.get(d);if(f!=null)u.set(d,f)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],a=e.name?e.name:e.uuid,o=[];function c(f){if(f.morphTargetInfluences)o.push(f.name?f.name:f.uuid)}if(vs[r.path]===vs.weights){if(c(e),e.isGroup)e.children.forEach(c)}else o.push(a);let l;switch(vs[r.path]){case vs.weights:l=bs;break;case vs.rotation:l=ys;break;case vs.translation:case vs.scale:l=Ea;break;default:switch(n.itemSize){case 1:l=bs;break;case 2:case 3:default:l=Ea;break}break}let u=i.interpolation!==void 0?HL[i.interpolation]:id,d=this._getArrayFromAccessor(n);for(let f=0,h=o.length;f<h;f++){let y=new l(o[f]+"."+vs[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(y);s.push(y)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=rg(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 ys?WA:ag)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function JL(e,t,n){let i=t.attributes,r=new hn;if(i.POSITION!==void 0){let o=n.json.accessors[i.POSITION],{min:c,max:l}=o;if(c!==void 0&&l!==void 0){if(r.set(new j(c[0],c[1],c[2]),new j(l[0],l[1],l[2])),o.normalized){let u=rg(Lo[o.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 o=new j,c=new j;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let f=n.json.accessors[d.POSITION],{min:h,max:y}=f;if(h!==void 0&&y!==void 0){if(c.setX(Math.max(Math.abs(h[0]),Math.abs(y[0]))),c.setY(Math.max(Math.abs(h[1]),Math.abs(y[1]))),c.setZ(Math.max(Math.abs(h[2]),Math.abs(y[2]))),f.normalized){let g=rg(Lo[f.componentType]);c.multiplyScalar(g)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}e.boundingBox=r;let a=new oi;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}function AA(e,t,n){let i=t.attributes,r=[];function s(a,o){return n.getDependency("accessor",a).then(function(c){e.setAttribute(o,c)})}for(let a in i){let o=ig[a]||a.toLowerCase();if(o in e.attributes)continue;r.push(s(i[a],o))}if(t.indices!==void 0&&!e.index){let a=n.getDependency("accessor",t.indices).then(function(o){e.setIndex(o)});r.push(a)}if(ot.workingColorSpace!==si&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ot.workingColorSpace}" not supported.`);return gr(e,t),JL(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?$L(e,t.targets,n):e})}function br(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 a of Array.isArray(s.material)?s.material:[s.material]){n.add(a);for(let o of Object.values(a))if(o instanceof Qt)i.add(o)}});for(let r of[...t,...n,...i])r.dispose()}async function qA(e){jh(e);let t=new Zc,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Ro(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new sg(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let a of s.json.images??[]){if(a.bufferView===void 0)continue;let o=new Uint8Array(await s.getDependency("bufferView",a.bufferView)),c="";for(let l=0;l<o.length;l+=8192)c+=String.fromCharCode(...o.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(a.mimeType??""))throw Error("Unsupported embedded image type");a.uri=`data:${a.mimeType};base64,${btoa(c)}`,delete a.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)br(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.")}})}zi();function JA(e,t,n=40,i=[e]){let r=e.getCenter(new j),s=Math.max(e.getSize(new j).length()/2,0.01),a=new j(1,0.65,1.25).normalize(),o=new j().crossVectors(new j(0,1,0),a).normalize(),c=new j().crossVectors(a,o),l=[];for(let b of i.length?i:[e])for(let _ of[b.min.x,b.max.x])for(let x of[b.min.y,b.max.y])for(let v of[b.min.z,b.max.z])l.push(new j(_,x,v));let u=1/0,d=-1/0,f=1/0,h=-1/0;for(let b of l){let _=b.clone().sub(r),x=_.dot(o),v=_.dot(c);u=Math.min(u,x),d=Math.max(d,x),f=Math.min(f,v),h=Math.max(h,v)}r.addScaledVector(o,(u+d)/2),r.addScaledVector(c,(f+h)/2);let y=Math.tan(n*Math.PI/360),g=y*t,m=s;for(let b of l){let _=b.clone().sub(r),x=_.dot(a);m=Math.max(m,x+Math.abs(_.dot(o))*1.12/g,x+Math.abs(_.dot(c))*1.12/y)}let p=r.clone().addScaledVector(a,m);return{center:r,radius:s,distance:m,position:p}}zi();function og(e,t){return{position:e.position.clone(),target:t.clone()}}function cg(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new j).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 j))+r*20,10),e.updateProjectionMatrix()}function ZA(e,t,n){let i=e.getWorldDirection(new j);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new j(0,1,0)),s=new j;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 YA(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 QA(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 eS(e,t,n){if(t())return e;n(e);return}zi();function Id(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,a)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(a)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((a)=>{let o=e.parser.associations.get(a)?.nodes;if(o===void 0||!i.has(o))return;a.visible=!1,r++});return r}function Cd(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new hn().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new hn,i=new hn,r=new j;return e.traverseVisible((s)=>{let a=s,o=a.geometry;if(!o)return;let c=o.getAttribute("position");if(c&&a.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(a.isMesh)a.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(o.boundingBox===null)o.computeBoundingBox();i.copy(o.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new hn().setFromObject(e,!0):n}function ol(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 tS(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((y)=>!Number.isInteger(y)||!t[y]||n.has(y)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let f=[l];for(let y of u)f.push(await e.parser.getDependency("node",y));Id(e,f.slice(1)),i.add(l);let h=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:h,levels:f})}if(r.length===0)return;let s=ol(e.scene)-r.reduce((c,l)=>c+lg(l,0),0),a=Math.max(...r.map((c)=>c.levels.length)),o=Array.from({length:a},(c,l)=>s+r.reduce((u,d)=>u+lg(d,l),0));return{chains:r,triangles:o}}var nS=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function lg(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return ol(nS(e,t))}function iS(e,t){let n=nS(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 rS(e,t){for(let n of e.chains)iS(n,t)}function sS(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return iS(i,n),!0}function aS(e,t){if(!e)return;return{triangles:ol(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)=>lg(n,r))}))}}function Fo(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function ug(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function cl(e){let t=new Km({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Lc,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Ao,i=new fn(40,1,0.01,1000),r=new Jm(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,a=!1,o=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(O)=>{if(!a||!c.has(O.code))return;O.preventDefault(),s.add(O.code)},u=(O)=>s.delete(O.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let f=new sl(t),h=new Zm,y=f.fromScene(h,0.04);n.environment=y.texture,h.dispose(),f.dispose();let g=new No(16773591,2.4);g.position.set(4,8,5),n.add(g),n.add(new yd(14806490,5065021,1.7));let m,p,b,_=[],x=!0,v=performance.now(),E=0,S=0,T=!1,A,P,w,I=(O)=>{if(!w)return;clearTimeout(w.timeout),w.reject(Error(O)),w=void 0},F=(O)=>{let K=t.getContext(),B=K.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:O-w.started,frameMs:YA(w.samples),...P===void 0?{}:{loadToFirstFrameMs:P},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(K.getParameter(K.VERSION)),vendor:String(K.getParameter(K.VENDOR)),renderer:String(K.getParameter(K.RENDERER)),browser:navigator.userAgent,...B?{unmaskedVendor:String(K.getParameter(B.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(K.getParameter(B.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."]}},N=()=>{if(!m)return;let O=Cd(m),K=[];m.traverseVisible((de)=>{if(de instanceof jt||de instanceof ps||de instanceof Mo){let Me=new hn().setFromObject(de,!0);if(!Me.isEmpty())K.push(Me)}});let{center:B,radius:X,distance:q,position:le}=JA(O,i.aspect,i.fov,K);if(r.target.copy(B),i.position.copy(le),i.near=Math.max(X/1000,0.0001),i.far=q+X*100,r.minDistance=X*0.1,r.maxDistance=X*80,o=Math.max(X*0.35,0.01),a)r.minDistance=X*0.00001;i.updateProjectionMatrix(),r.update()},U=new ResizeObserver(()=>{let{clientWidth:O,clientHeight:K}=e;if(!O||!K)return;t.setSize(O,K),i.aspect=O/K,i.updateProjectionMatrix()});U.observe(e);let D=(O)=>{if(T)return;let K=Math.min((O-v)/1000,0.1);if(v=O,e.clientWidth&&e.clientHeight){if(x)b?.update(K);if(a&&s.size){let B=ZA(i,s,K*o*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(B),r.target.add(B)}if(r.update(),t.render(n,i),A!==void 0)P=performance.now()-A,A=void 0;if(w){if(w.previous>0&&w.samples.length<1800)w.samples.push(O-w.previous);if(w.previous=O,O-w.started>=w.duration&&w.samples.length){let B=F(O);clearTimeout(w.timeout),w.resolve(B),w=void 0}}}else s.clear(),I("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(D)};return E=requestAnimationFrame(D),{async load(O,K={}){let B=performance.now(),X=++S;I("The artifact changed during measurement. Measure the new revision again.");let q=await qA(O);Id(q,[q.scene]);let le=await tS(q);try{q.assertTexturesLoaded()}catch(te){br(q.scene);for(let ie of Fo(le))br(ie);throw te}let de=eS(q,()=>!T&&X===S&&K.isCurrent?.()!==!1,(te)=>{br(te.scene);for(let ie of Fo(le))br(ie)});if(!de)return;let Me=m&&K.preserveView?og(i,r.target):void 0;if(m){b?.stopAllAction(),b?.uncacheRoot(m),n.remove(m),br(m);for(let te of Fo(p))br(te)}m=de.scene,p=le,A=B,P=void 0,n.add(m),_=de.animations,b=new Ed(m),x=!0;let{clientWidth:pe,clientHeight:J}=e;if(t.setSize(pe,J),i.aspect=pe&&J?pe/J:i.aspect,N(),Me)cg(i,r.target,Me,Cd(m)),r.update();let L=0,W=new Set;return m.traverseVisible((te)=>{let ie=te;if(!ie.isMesh)return;L++;for(let ce of Array.isArray(ie.material)?ie.material:[ie.material])W.add(ce)}),K.onCommit?.(),{triangles:ol(m),meshes:L,materials:W.size,clips:_.map((te)=>te.name),...p?{levels:p.triangles}:{}}},level(O){if(I("The level of detail changed. Measure the displayed combination again."),p)rS(p,O)},partLevel(O,K){if(I("The level of detail changed. Measure the displayed combination again."),p)sS(p,O,K)},lod(){return m?aS(p,m):void 0},reset:N,cancelMeasurement:I,measure(O=3000){if(T||!m||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(O)||O<1000||O>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(w)return Promise.reject(Error("A measurement is already running."));return new Promise((K,B)=>{w={started:performance.now(),previous:0,duration:O,samples:[],resolve:K,reject:B,timeout:setTimeout(()=>I("Measurement was interrupted or the browser stopped delivering frames."),O+2000)}})},view(){return og(i,r.target)},setView(O){if(!m)return;cg(i,r.target,O,Cd(m)),r.update()},navigation(O){if(a=O==="explore",s.clear(),r.minDistance=a?0.00001:o/3.5,a)i.near=0.0001,i.updateProjectionMatrix()},wire(O){for(let K of m?[m,...Fo(p)]:[])K.traverse((B)=>{let X=B;if(X.isMesh){for(let q of Array.isArray(X.material)?X.material:[X.material])if("wireframe"in q)q.wireframe=O}})},lighting(O){t.toneMappingExposure=O==="bright"?1.65:O==="soft"?0.85:1.15,g.intensity=O==="soft"?0.8:2.4},clip(O){if(b?.stopAllAction(),_[O])b?.clipAction(_[O]).play()},pause(O){x=!O},dispose(){if(I("The viewport closed before measurement finished."),T=!0,S++,cancelAnimationFrame(E),U.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),m)br(m);for(let O of Fo(p))br(O);y.dispose(),t.dispose(),e.replaceChildren()}}}var ue=(e)=>document.getElementById(e);function k(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function Mn(e){let t=ue("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function un(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 Uo(e,t){let n=k("div",void 0,"empty");return n.append(k("b",e),k("p",t)),n}function Vi(e,t){try{localStorage.setItem(e,t)}catch{}}function Es(e){try{return localStorage.getItem(e)}catch{return null}}function Tn(e){return e?e.slice(0,15):"Unspecified"}function Bo(e,t){let n=k("details",void 0,"record-details");return n.append(k("summary",e),k("pre",JSON.stringify(t,null,2))),n}function ll(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(...ug(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 a=k("p","","lod-total");a.setAttribute("role","status"),t.append(a);let o=new Map;if(r.chains.length>1){let l=k("details",void 0,"lod-parts");l.append(k("summary","Per-part levels")),l.append(k("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=k("div",void 0,"lod-part-fields"),d=new Set(r.chains.filter((f,h,y)=>y.findIndex((g)=>g.label===f.label)!==h).map((f)=>f.label));for(let[f,h]of r.chains.entries()){let y=d.has(h.label)?`${h.label} (part ${f+1})`:h.label,g=k("label",y,"inline-field"),m=k("select");m.setAttribute("aria-label",`${y} level of detail`),m.append(...ug(h.triangles).map((p,b)=>new Option(p,String(b)))),m.onchange=()=>{n.partLevel(h.id,Number(m.value)),c(),i?.()},o.set(h.id,m),g.append(m),u.append(g)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((d,f)=>l.chains.every((h)=>h.level===Math.min(f,h.triangles.length-1)));e.value=u<0?"mixed":String(u),a.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let d of l.chains){let f=o.get(d.id);if(f)f.value=String(d.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var oS=/^[a-z][a-z0-9_-]{0,79}$/u,ZL=/^r_[a-z0-9_-]{1,77}$/u;function cS(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!oS.test(n)||!oS.test(i)||!ZL.test(r))return;return{collection:n,assetId:i,revisionId:r}}var jM=new TextEncoder,b9=new TextDecoder,Go=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),Gg=(e,t)=>Object.hasOwn(e,t);async function BM(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 y9(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")}function zM(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=12;while(n<e.length){if(n+8>e.length)throw Error("Invalid GLB chunk header");let s=t.getUint32(n,!0);if(s%4||n+8+s>e.length)throw Error("Invalid GLB chunk length");n+=8+s}let i=20+t.getUint32(12,!0),r=JSON.parse(b9.decode(e.subarray(20,i)));if(!Go(r)||!Go(r.asset)||r.asset.version!=="2.0")throw Error("Invalid glTF asset");return{json:r,jsonEnd:i}}function VM(e,t,n){let i=jM.encode(JSON.stringify(n)),r=Math.ceil(i.length/4)*4,s=new Uint8Array(20+r+e.length-t);if(s.length>ni)throw Error("Runtime export exceeds 64 MiB");s.set(e.subarray(0,20));let a=new DataView(s.buffer);return a.setUint32(8,s.length,!0),a.setUint32(12,r,!0),s.fill(32,20,20+r),s.set(i,20),s.set(e.subarray(t),20+r),s}async function x9(e,t={}){let[{deliverRuntimeThreeGlb:n},{MeshoptEncoder:i}]=await Promise.all([Promise.resolve().then(() => (PM(),NM)),Promise.resolve().then(() => (UM(),FM))]);await i.ready;let r=await n(e,i,t);if(r.glb.byteLength>ni)throw Error("Runtime export exceeds 64 MiB");return r}async function HM(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");if(t.target!==void 0&&t.target!=="three")throw Error("Unknown runtime export target");if(t.target!==void 0&&n!=="runtime")throw Error("A runtime export target requires the runtime profile");yu(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";y9(r);for(let[p,b]of Object.entries(e.files))if(await BM(b)!==e.manifest.files[p].sha256)throw Error(`Asset integrity mismatch: ${p}`);let{json:s,jsonEnd:a}=zM(i),o=s.asset;if(Gg(o,"extras")&&!Go(o.extras))throw Error("Cannot add provenance to non-object asset extras");let c=o.extras??{};if(Gg(c,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let l=[];if(s.scenes!==void 0&&!Array.isArray(s.scenes))throw Error("Invalid glTF scenes");for(let[p,b]of(s.scenes??[]).entries()){if(!Go(b)||!Go(b.extras)||!Gg(b.extras,"kilnReviewClipsV1"))continue;let _=b.extras.kilnReviewClipsV1;if(!Go(_)||_.version!==1&&_.version!==2||!Array.isArray(_.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");l.push({index:p,kilnReviewClipsV1:_}),delete b.extras.kilnReviewClipsV1}let u={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:l},d=i,f=s,h=a;if(t.target==="three"){let p=await x9(VM(i,a,s),{...t.ktx2Encoder?{ktx2Encoder:t.ktx2Encoder}:{}});u.target="three",u.delivery=p.delivery,d=p.glb,{json:f,jsonEnd:h}=zM(d)}let y=jM.encode(JSON.stringify(u));if(y.length>ni)throw Error("Runtime export exceeds 64 MiB");let g=f.asset;g.extras={...g.extras??c,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",...t.target?{target:t.target}:{},metadata:{uri:r,sha256:await BM(y)}}};let m=VM(d,h,f);return{profile:n,glb:m,metadata:{name:r,bytes:y}}}var Gi=Le().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"),$g=Le().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),KM=Le().regex(/^sha256:[a-f0-9]{64}$/),$o=Le().max(4000),WM=Le().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),GM=be({collectionId:Gi,assetId:Gi,revisionId:Gi}).strict(),$M=be({style:$o.default(""),scale:Le().max(1000).default(""),palette:at(be({role:Le().min(1).max(100),color:Le().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:at(be({role:Le().min(1).max(100),description:$o.default(""),resourceId:WM.optional()}).strict()).max(128).default([]),conventions:at(Le().max(1000)).max(100).default([]),exceptions:at(Le().max(1000)).max(100).default([])}).strict(),_9=be({resourceId:WM,revisionId:Le().min(1).max(200),sha256:KM,role:Le().max(100).optional()}).strict(),v9=at(_9).max(512),xr={name:Le().trim().min(1).max(200),brief:Le().max(16000).default(""),design:$M.default(()=>$M.parse({})),inventory:at(be({id:Gi,name:Le().trim().min(1).max(200),kind:It(["asset","environment"]).default("asset"),brief:$o.default(""),references:at(Gi).max(64).default([]),asset:GM.optional()}).strict()).max(1000).default([]),deliveryProfiles:at(be({id:Gi,target:It(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:$o.default(""),performanceIntent:Le().max(1000).default(""),constraints:at(Le().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:v9.default([]),references:at(be({id:Gi,title:Le().min(1).max(200),uri:Le().min(1).max(2048),description:$o.default(""),sha256:KM.optional()}).strict()).max(256).default([]),reviews:at(be({id:Gi,inventoryId:Gi,projectRevisionId:$g,asset:GM,reviewer:Le().trim().min(1).max(200),verdict:It(["comment","changes-requested","accepted"]),notes:$o}).strict()).max(2000).default([])};function XM(e,t){let n=(a,o)=>{if(new Set(a).size!==a.length)t.addIssue({code:iu.custom,path:[o],message:"Duplicate identity"})};n(e.inventory.map((a)=>a.id),"inventory"),n(e.references.map((a)=>a.id),"references"),n(e.deliveryProfiles.map((a)=>a.id),"deliveryProfiles"),n(e.materialDependencies.map((a)=>a.resourceId),"materialDependencies"),n(e.reviews.map((a)=>a.id),"reviews"),n(e.design.palette.map((a)=>a.role),"design.palette"),n(e.design.materialRoles.map((a)=>a.role),"design.materialRoles");let i=new Set(e.references.map((a)=>a.id)),r=new Set(e.inventory.map((a)=>a.id)),s=new Set(e.materialDependencies.map((a)=>a.resourceId));for(let a of e.inventory)if(n(a.references,`inventory.${a.id}.references`),a.references.some((o)=>!i.has(o)))t.addIssue({code:iu.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((a)=>!r.has(a.inventoryId)))t.addIssue({code:iu.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((a)=>a.resourceId&&!s.has(a.resourceId)))t.addIssue({code:iu.custom,path:["design"],message:"Material role requires a locked resource"})}var qM=be({projectId:Gi.optional(),...xr}).strict().superRefine(XM),XK=be({name:xr.name.optional(),brief:xr.brief.removeDefault().optional(),design:xr.design.removeDefault().optional(),inventory:xr.inventory.removeDefault().optional(),deliveryProfiles:xr.deliveryProfiles.removeDefault().optional(),materialDependencies:xr.materialDependencies.removeDefault().optional(),references:xr.references.removeDefault().optional(),reviews:xr.reviews.removeDefault().optional()}).strict(),qK=be({version:$e("kiln.project.v1"),projectId:Gi,revisionId:$g,parentRevision:$g.optional(),createdAt:Le().datetime(),...xr}).strict().superRefine(XM);function JM(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 ZM(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 qM.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function YM(e){let t=[],n=Es("kiln.project")??"",i,r=()=>{let c=ue("project-list");c.replaceChildren();for(let _ of t){let x=k("button",void 0,_.projectId===n?"active":"");if(x.append(k("strong",_.name),k("small",`${_.inventory.length} inventory items · ${_.materialDependencies.length} resources`)),_.projectId===n)x.setAttribute("aria-current","true");x.onclick=()=>{n=_.projectId,Vi("kiln.project",n),r()},c.append(x)}let l=t.find((_)=>_.projectId===n),u=ue("project-detail");if(u.replaceChildren(),!l){u.append(Uo("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 d=k("div",void 0,"project-summary"),f=k("div");f.append(k("h2",l.name),k("p",l.brief||"Add a brief to describe what this project should deliver."));let h=k("button","Edit project","secondary");h.onclick=()=>a(l),d.append(f,h),u.append(d);let y=k("p",`${l.projectId} · ${Tn(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(y);let g=k("div",void 0,"project-metrics");for(let[_,x]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let v=k("div");v.append(k("strong",String(_)),k("span",String(x))),g.append(v)}u.append(g);let m=k("div",void 0,"profile-grid");for(let[_,x]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let v=k("div");v.append(k("span",_,"label"),k("p",x)),m.append(v)}u.append(m);let p=k("div",void 0,"palette");for(let _ of l.design.palette){let x=k("div",void 0,"swatch"),v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("viewBox","0 0 24 24"),v.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",_.color),v.append(E);let S=k("span",_.role);S.append(k("small",_.color)),x.append(v,S),p.append(x)}if(p.childElementCount)u.append(p);for(let[_,x]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!x.length)continue;u.append(k("h3",_));let v=k("ul",void 0,"subtle");for(let E of x)v.append(k("li",E));u.append(v)}if(u.append(k("h3","Inventory")),!l.inventory.length)u.append(k("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let _=k("div",void 0,"table-wrap"),x=k("table"),v=k("thead"),E=k("tr");for(let T of["Item","Kind","Saved revision","Review"])E.append(k("th",T));v.append(E),x.append(v);let S=k("tbody");for(let T of l.inventory){let A=k("tr"),P=k("td",T.name);P.append(k("small",T.brief));let w=k("td"),I=k("td");if(T.asset){let F=k("button",Tn(T.asset.revisionId),"secondary");F.onclick=()=>e.openAsset(T.asset),w.append(F);let N=[...l.reviews].reverse().find((D)=>D.inventoryId===T.id&&D.asset.revisionId===T.asset.revisionId&&D.asset.assetId===T.asset.assetId&&D.asset.collectionId===T.asset.collectionId);I.append(k("small",N?`${N.verdict} · ${N.reviewer}`:"Unreviewed"));let U=k("button","Record review","secondary");U.onclick=()=>o(l,T),I.append(U)}else w.textContent="Not linked",I.textContent="No saved revision";A.append(P,k("td",T.kind),w,I),S.append(A)}x.append(S),_.append(x),u.append(_)}if(l.design.materialRoles.length){u.append(k("h3","Material roles"));for(let _ of l.design.materialRoles)u.append(k("p",`${_.role}: ${_.description||"No description"}${_.resourceId?` · ${_.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(k("h3","Delivery intent"));for(let _ of l.deliveryProfiles){if(u.append(k("p",`${_.target} · ${_.description||_.id}`,"subtle")),_.performanceIntent)u.append(k("p",_.performanceIntent,"subtle"));for(let x of _.constraints)u.append(k("p",x,"subtle"))}u.append(k("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(k("h3","Reference records"));for(let _ of l.references){let x=k("p",`${_.title}: ${_.uri}`,"subtle");if(_.description)x.append(k("small",` · ${_.description}`));u.append(x)}}u.append(k("h3","Project downloads"));let b=k("div",void 0,"downloads");for(let _ of["editable","runtime"]){let x=k("a",_==="editable"?"Download editable project bundle":"Download runtime project bundle"),v=new URLSearchParams({profile:_,revision:l.revisionId});x.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${v}`,x.download=`${l.projectId}-${_}.zip`,b.append(x)}b.append(k("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(b),u.append(Bo("Exact project configuration and review records",l))},s=async()=>{let c=await un("/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 a(c){i=c,ue("project-editor-title").textContent=c?"Edit project":"New project",ue("project-name").value=c?.name??"",ue("project-brief").value=c?.brief??"",ue("project-style").value=c?.design.style??"",ue("project-scale").value=c?.design.scale??"",ue("project-config").value=JSON.stringify(JM(c??{name:""}),null,2),ue("project-save-status").textContent="",ue("project-editor").showModal(),ue("project-name").focus()}function o(c,l){if(!l.asset)return;let u=k("dialog"),d=k("form"),f=k("div",void 0,"editor-content"),h=k("h2",`Review ${l.name}`);h.id="review-dialog-title",u.setAttribute("aria-labelledby",h.id),f.append(h,k("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),k("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let y=k("input");y.required=!0,y.value=Es("kiln.reviewer")??"",y.maxLength=200;let g=k("label","Reviewer","field");g.append(y);let m=k("select");for(let[S,T]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])m.append(new Option(T,S));let p=k("label","Assessment","field");p.append(m);let b=k("textarea");b.rows=4,b.maxLength=4000;let _=k("label","Notes","field");_.append(b);let x=k("p");x.setAttribute("role","status");let v=k("button","Save review");v.type="submit";let E=k("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),f.append(g,p,_,x,v,E),d.append(f),u.append(d),document.body.append(u),u.addEventListener("close",()=>u.remove()),d.onsubmit=async(S)=>{S.preventDefault(),v.disabled=!0,x.textContent="Saving review…";try{await un(`/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:y.value.trim(),verdict:m.value,notes:b.value}]}}}),Vi("kiln.reviewer",y.value.trim()),u.close(),await s()}catch(T){x.textContent=T instanceof Error?T.message:String(T)}finally{v.disabled=!1}},u.showModal(),y.focus()}return ue("new-project").onclick=()=>a(),ue("close-project-editor").onclick=()=>ue("project-editor").close(),ue("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ue("save-project");l.disabled=!0,ue("project-save-status").textContent="Saving revision…";try{let u=ZM(ue("project-config").value,{name:ue("project-name").value,brief:ue("project-brief").value,style:ue("project-style").value,scale:ue("project-scale").value});n=(await un(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,Vi("kiln.project",n),ue("project-editor").close(),Mn("Project revision saved."),await s()}catch(u){ue("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}var E9="Raw map pixels · unshaded · not GPU capture evidence",Kg=/^[a-z][a-z0-9_-]{0,79}$/,Wg=/^sha256:[a-f0-9]{64}$/;function yl(e){let t=new URLSearchParams(e.startsWith("?")?e:e.slice(e.indexOf("?")+1)),n=t.get("material"),i=t.get("materialRevision");if(t.getAll("material").length!==1||t.getAll("materialRevision").length!==1||!n||!i||!Kg.test(n)||!Wg.test(i))return;return{materialId:n,revisionId:i}}function lf(e){if(!Kg.test(e.materialId)||!Wg.test(e.revisionId))throw Error("Invalid exact material selection");return`/?${new URLSearchParams({material:e.materialId,materialRevision:e.revisionId})}`}function Xg(e){if(!Kg.test(e.materialId)||!Wg.test(e.revisionId))throw Error("Invalid exact material selection");return`/api/materials/${encodeURIComponent(e.materialId)}/${encodeURIComponent(e.revisionId)}`}function QM(e){let t=Ja(e),n=Xg(t),i=t.maps.map((r)=>{let s="recipe"in r?r:void 0,a=s?.recipe?.kind==="atlas"?s.recipe:void 0;return{slot:r.slot,file:r.file,url:`${n}/${encodeURIComponent(r.file)}`,width:r.width,height:r.height,colorSpace:r.colorSpace,imageSha256:r.sha256,..."pixelHash"in r?{pixelHash:r.pixelHash}:{},..."sampler"in r?{sampler:{...r.sampler}}:{},atlas:!!a,...s?.recipe?{compilerId:s.recipe.compilerId}:{},...a?{manifestHash:a.manifest.manifestHash}:{},regions:a?a.manifest.regions.map((o)=>({name:o.name,content:{...o.content},allocation:{...o.allocation},leftPercent:o.content.x/r.width*100,topPercent:o.content.y/r.height*100,widthPercent:o.content.width/r.width*100,heightPercent:o.content.height/r.height*100})):[]}});return{materialId:t.materialId,revisionId:t.revisionId,name:t.name,fidelity:E9,maps:i}}function eR(e,t){if(!e||typeof e!=="object"||Array.isArray(e)||e.artifactGlbSha256!==t)throw Error("Retained evaluation does not identify the displayed artifact");let n=e.materialLibraryDependencies;if(n===void 0)return[];if(!Array.isArray(n)||n.length>16)throw Error("Invalid retained material dependency list");let i=new Map;for(let r of n){let s=Ja(r),a=`${s.materialId}/${s.revisionId}`,o=i.get(a);if(o&&on(o)!==on(s))throw Error("Conflicting retained material identity");i.set(a,s)}return[...i.values()]}function uf(e){let t=QM(e),n=k("section",void 0,"material-inspection");n.setAttribute("aria-label",`${t.name}: exact material maps`),n.append(k("p",`${t.materialId} · ${t.revisionId}`,"mono"),k("p",t.fidelity,"subtle"));let i=k("div",void 0,"material-inspection-controls"),r=(v,E)=>{let S=k("label",v,"inline-field");return S.append(E),i.append(S),E},s=r("Map",k("select"));for(let v of t.maps)s.append(new Option(`${v.slot}${v.atlas?" · atlas":""}`,v.slot));let a=r("Backdrop",k("select"));for(let v of["checker","light","dark"])a.append(new Option(v[0].toUpperCase()+v.slice(1),v));let o=r("Pixel zoom",k("select"));for(let v of[1,2,4])o.append(new Option(`${v}×`,String(v)));let c=k("div",void 0,"material-pixel-frame"),l=k("div",void 0,"material-pixel-sheet");c.dataset.backdrop="checker",c.tabIndex=0;let u=k("img");u.className="material-pixel-image",u.loading="lazy",u.draggable=!1;let d=k("div",void 0,"material-region-overlay"),f=k("label","Region overlays","inline-field"),h=k("input");h.type="checkbox",h.checked=!1,f.append(h),i.append(f),h.onchange=()=>{d.hidden=!h.checked},l.append(u,d),c.append(l);let y=k("p",void 0,"subtle");y.setAttribute("role","status");let g=k("dl"),m=k("div",void 0,"material-region-list"),p=k("a","Open this saved material revision");p.href=lf(t),p.target="_blank",p.rel="noopener",n.append(i,c,y,g,m,p);let b=t.maps[0],_=()=>{l.style.width=`${b.width*Number(o.value)}px`,l.style.height=`${b.height*Number(o.value)}px`},x=()=>{b=t.maps.find((E)=>E.slot===s.value)??t.maps[0],f.hidden=!b.atlas,d.hidden=!b.atlas||!h.checked,y.textContent="Loading exact saved map…",u.alt=`${t.name}: ${b.slot}${b.atlas?" atlas sheet":""}, raw unshaded pixels`,u.width=b.width,u.height=b.height,u.src=b.url,_(),g.replaceChildren();let v=(E,S)=>g.append(k("dt",E),k("dd",S));if(v("Image",`${b.width} × ${b.height} · ${b.colorSpace} · nearest pixel display`),v("Sampling declaration",b.sampler?`${b.sampler.minFilter} / ${b.sampler.magFilter} · ${b.sampler.wrapS} / ${b.sampler.wrapT}`:"Not recorded in V1"),v("PNG hash",b.imageSha256),b.pixelHash)v("Decoded RGBA hash",b.pixelHash);if(b.compilerId)v("Compiler",b.compilerId);if(b.manifestHash)v("Atlas manifest hash",b.manifestHash);if(d.replaceChildren(),m.replaceChildren(),b.atlas){m.append(k("h4","Atlas regions · top-left pixel coordinates"));for(let E of b.regions){let S=k("span",void 0,"material-region-box");S.style.left=`${E.leftPercent}%`,S.style.top=`${E.topPercent}%`,S.style.width=`${E.widthPercent}%`,S.style.height=`${E.heightPercent}%`,S.append(k("span",E.name)),S.setAttribute("aria-hidden","true"),d.append(S);let T=k("button",`${E.name}: content ${E.content.x},${E.content.y} ${E.content.width}×${E.content.height}; allocation ${E.allocation.x},${E.allocation.y} ${E.allocation.width}×${E.allocation.height}`,"secondary");T.type="button",T.setAttribute("aria-pressed","false"),T.onclick=()=>{for(let A of d.children)A.classList.remove("selected");for(let A of m.querySelectorAll("button"))A.setAttribute("aria-pressed","false");if(S.classList.add("selected"),T.setAttribute("aria-pressed","true"),!d.hidden)S.scrollIntoView({block:"nearest",inline:"nearest"})},m.append(T)}}};return u.onload=()=>{y.textContent="Raw map loaded. These pixels are not a shaded capture."},u.onerror=()=>{y.textContent=`Exact ${t.materialId} revision map unavailable. No newer revision was substituted.`},s.onchange=x,a.onchange=()=>{c.dataset.backdrop=a.value},o.onchange=_,x(),n}function tR(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 nR(e){let t=[],n=[],i=[],r=ue("materials-project"),s=k("button","Create from preset");ue("materials-refresh").before(s);let a=k("dialog");a.setAttribute("aria-labelledby","material-preset-heading");let o=k("form"),c=k("div",void 0,"detail-top"),l=k("h2","Create a material resource");l.id="material-preset-heading";let u=k("button","Cancel","secondary");u.type="button",u.onclick=()=>a.close(),c.append(l,u);let d=k("div",void 0,"editor-content");d.append(k("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 f(w,I){let F=k("label",w,"field");return F.append(I),d.append(F),I}let h=f("Preset",k("select")),y=k("p",void 0,"subtle");d.append(y);let g=f("Seed",k("input"));g.type="number",g.step="1",g.required=!0,g.min="-2147483648",g.max="2147483647",g.value="0";let m=f("Map size",k("select"));for(let w of[64,128,256,512])m.append(new Option(`${w} × ${w}`,String(w)));m.value="256";let p=f("Creator",k("input"));p.required=!0,p.maxLength=1000;let b=f("License identifier",k("input"));b.required=!0,b.placeholder="For example, CC0-1.0";let _=f("License URL",k("input"));_.type="url",_.required=!0;let x=f("Attribution text",k("textarea"));x.rows=2;let v=k("p");v.setAttribute("role","status");let E=k("button","Create resource");E.type="submit",d.append(v,E),o.append(c,d),a.append(o),document.body.append(a);let S=()=>{let w=i.find((I)=>I.id===h.value);y.textContent=w?`${w.description} Repeat scale: ${w.physicalSizeMeters.width} × ${w.physicalSizeMeters.height} m.`:""};h.onchange=S,s.onclick=async()=>{s.disabled=!0;try{i=(await un("/api/material-presets")).presets,h.replaceChildren(...i.map((w)=>new Option(w.name,w.id))),S(),v.textContent="",E.disabled=!i.length,a.showModal()}catch(w){Mn(w)}finally{s.disabled=!1}},o.onsubmit=async(w)=>{w.preventDefault(),E.disabled=!0,v.textContent="Creating immutable material resource…";try{let I=tR({presetId:h.value,seed:g.value,size:m.value,creator:p.value,spdx:b.value,url:_.value,attribution:x.value}),F=await un("/api/materials/preset",{method:"POST",body:I});await P(),a.close(),Mn(`${F.material.name} created at ${F.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(I){v.textContent=I instanceof Error?I.message:String(I)}finally{E.disabled=!1}};let T=Xg;function A(){let w=n.find((D)=>D.projectId===r.value),I=ue("material-dependencies");if(I.replaceChildren(),w)if(I.append(k("h2",`${w.name}: locked resources`)),!w.materialDependencies.length)I.append(k("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let D=k("table"),O=k("thead"),K=k("tr"),B=k("tbody");for(let q of["Resource / role","Exact revision","Local availability"])K.append(k("th",q));O.append(K),D.append(O);for(let q of w.materialDependencies){let le=t.find((pe)=>pe.materialId===q.resourceId&&pe.revisionId===q.revisionId),de=k("tr"),Me=k("td",q.resourceId);Me.append(k("small",q.role??w.design.materialRoles.filter((pe)=>pe.resourceId===q.resourceId).map((pe)=>pe.role).join(", "))),de.append(Me,k("td",q.revisionId,"mono"),k("td",le&&le.revisionId===q.sha256?"Exact local record available":le?"Dependency hash differs":"Not in local catalog")),B.append(de)}D.append(B);let X=k("div",void 0,"table-wrap");X.append(D),I.append(X)}let F=ue("material-list");F.replaceChildren();let N=ue("material-search").value.trim().toLowerCase(),U=t.filter((D)=>`${D.name} ${D.materialId} ${D.tags.join(" ")} ${D.sources.map((O)=>O.provider).join(" ")}`.toLowerCase().includes(N));if(ue("material-count").textContent=`${U.length} material revision${U.length===1?"":"s"}`,!U.length){F.append(Uo(N?"No matching materials":"Your material catalog starts here",N?"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 D of U){let O=k("article",void 0,"material-card"),K=D.maps.find((L)=>L.slot==="baseColor")??D.maps[0];if(K){let L=k("img");L.src=`${T(D)}/${encodeURIComponent(K.file)}`,L.alt=`${D.name}: ${K.slot} map, not a shaded material preview`,L.loading="lazy",L.className="material-map",O.append(L,k("p",`${K.slot} map · unshaded`,"subtle"))}O.append(k("h3",D.name),k("p",D.tags.join(" · "),"subtle"));let B=k("dl"),X=(L,W)=>B.append(k("dt",L),k("dd",W));X("Revision",D.revisionId),X("Physical scale",D.physicalSizeMeters?`${D.physicalSizeMeters.width} × ${D.physicalSizeMeters.height} m`:"Not specified"),X("Tiling",D.tileable?"Declared tileable":"Not declared tileable"),X("Maps",D.maps.map((L)=>`${L.slot} ${L.width}×${L.height} (${L.colorSpace})`).join(" · ")),X("Surface factors",`Roughness ×${D.parameters.roughness} · Metalness ×${D.parameters.metalness}${D.maps.some((L)=>L.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),O.append(B);for(let L of D.sources){let W=k("p",`${L.provider} · ${L.creator} · ${L.kind}`,"subtle"),te=k("a",L.license.spdx);if(te.href=L.license.url,te.target="_blank",te.rel="noreferrer",W.append(document.createTextNode(" · "),te),L.assetUrl){let ie=k("a","Source");ie.href=L.assetUrl,ie.target="_blank",ie.rel="noreferrer",W.append(document.createTextNode(" · "),ie)}if(O.append(W),L.license.attribution)O.append(k("p",L.license.attribution,"subtle"))}let q=k("div",void 0,"material-map-links");for(let L of D.maps){let W=k("a",L.slot);W.href=`${T(D)}/${encodeURIComponent(L.file)}`,W.target="_blank",W.rel="noopener",q.append(W)}O.append(q);let le=k("details",void 0,"material-map-inspection");le.append(k("summary","Inspect maps and atlas regions"));let de=!1;le.ontoggle=()=>{if(le.open&&!de)de=!0,le.append(uf(D))};let Me=yl(location.search);if(Me?.materialId===D.materialId&&Me.revisionId===D.revisionId)le.open=!0,O.dataset.selectedMaterial="true";O.append(le);let pe=w?.materialDependencies.find((L)=>L.resourceId===D.materialId),J=k("button",pe?.revisionId===D.revisionId?"Locked to project":pe?"Use this revision":"Add to project","secondary");if(J.disabled=!w||pe?.revisionId===D.revisionId,!w)J.title="Select a project to add a material dependency";J.onclick=async()=>{if(!w)return;J.disabled=!0;try{let L=w.materialDependencies.filter((W)=>W.resourceId!==D.materialId);L.push({resourceId:D.materialId,revisionId:D.revisionId,sha256:D.revisionId,...pe?.role?{role:pe.role}:{}}),await un(`/api/projects/${encodeURIComponent(w.projectId)}`,{method:"PATCH",body:{expectedRevision:w.revisionId,patch:{materialDependencies:L}}}),Mn(`${D.name} is locked to ${w.name} at this exact revision.`),await e()}catch(L){Mn(L),J.disabled=!1}},O.append(J,Bo("Map recipes, transformations and provenance",D)),F.append(O)}}let P=async()=>{t=(await un("/api/materials")).materials,A();let w=yl(location.search);if(w&&!t.some((I)=>I.materialId===w.materialId&&I.revisionId===w.revisionId))Mn(`Exact material revision unavailable: ${w.materialId} at ${w.revisionId}. No newer revision was selected.`)};return ue("material-search").oninput=A,r.onchange=A,ue("materials-refresh").onclick=()=>void P().catch(Mn),{refresh:P,projects(w){n=w;let I=r.value;r.replaceChildren(new Option("All materials",""));for(let F of n)r.append(new Option(F.name,F.projectId));if(n.some((F)=>F.projectId===I))r.value=I;A()}}}function qg(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var iR=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function xl(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(iR),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),a=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&iR(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),o=s?.artifact?s:s?i.filter((c)=>c.artifact&&a(c)).at(-1)??(a(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:o,pinned:r(e.pinned)}}function Jg(e,t){return xl({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Ws(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 rR(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Ws(e,Ws(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 df(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(k("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(k("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let a=await QA(()=>s.measure(3000),i),o=k("div",void 0,"evidence-card");o.append(k("h3","Exploratory browser measurement"),k("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),k("strong",`p50 ${a.frameMs.p50.toFixed(1)} ms · p95 ${a.frameMs.p95.toFixed(1)} ms`),k("p",`${a.frameMs.samples} frame intervals · ${(a.windowMs/1000).toFixed(2)} s · ${a.drawCalls} draws · ${a.triangles.toLocaleString()} rendered triangles`),k("p",`${a.geometryObjects} geometry objects · ${a.textureObjects} texture objects. These counts are not GPU memory bytes.`),k("p",`GLB parse to first frame submission: ${a.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),k("p",`${a.viewport.cssWidth}×${a.viewport.cssHeight} CSS pixels · DPR ${a.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Bo("Exact measurement receipt and limitations",a);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(a,null,2)],{type:"application/json"}));let l=k("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",o.append(c,l),t.replaceChildren(o)}catch(a){t.replaceChildren(k("p",a instanceof Error?a.message:String(a),"subtle"))}finally{e.disabled=!1}}}function Zg(e,t,n,i){let r=e.inventory.find((a)=>a.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((a)=>{if(a.id!==t)return a;let{asset:o,...c}=a;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 _l(e,t,n,i){e.replaceChildren(k("h3","Project membership"));let{projects:r}=await un("/api/projects");if(!e.isConnected)return;let s=k("div");e.append(s);let a=k("p");a.setAttribute("role","status");let o=()=>_l(e,t,n,i);for(let g of r)for(let m of g.inventory){if(!m.asset||m.asset.collectionId!==t.collectionId||m.asset.assetId!==t.assetId)continue;let p=k("div",void 0,"membership-row");p.append(k("span",`${g.name} / ${m.name} · ${Tn(m.asset.revisionId)}${m.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let b=k("button","Remove membership","secondary");b.onclick=async()=>{b.disabled=!0;try{await un(`/api/projects/${encodeURIComponent(g.projectId)}`,{method:"PATCH",body:{expectedRevision:g.revisionId,patch:Zg(g,m.id,null,n)}}),await i(),await o()}catch(_){a.textContent=`${_ instanceof Error?_.message:_} Reopen membership to load the current project.`,b.disabled=!1}},p.append(b),s.append(p)}if(!s.childElementCount)s.append(k("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(k("p","Create a named project in Projects to organize related assets."));return}let c=k("form"),l=k("select"),u=k("select"),d=k("label","Project","field"),f=k("label","Inventory item","field");d.append(l),f.append(u);for(let g of r)l.append(new Option(g.name,g.projectId));let h=()=>{let g=r.find((p)=>p.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let p of g.inventory)u.append(new Option(`${p.name}${p.asset?" (replace linked revision)":""}`,p.id));let m=g.inventory.find((p)=>p.asset?.collectionId===t.collectionId&&p.asset.assetId===t.assetId);if(m)u.value=m.id};l.onchange=h,h();let y=k("button","Link this exact revision");y.type="submit",c.append(d,f,k("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),y,a),c.onsubmit=async(g)=>{g.preventDefault(),y.disabled=!0;let m=r.find((b)=>b.projectId===l.value),p=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await un(`/api/projects/${encodeURIComponent(m.projectId)}`,{method:"PATCH",body:{expectedRevision:m.revisionId,patch:Zg(m,p,t,n)}}),await i(),await o()}catch(b){a.textContent=`${b instanceof Error?b.message:b} Reopen membership to load the current project.`,y.disabled=!1}},s.append(c)}function sR(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,a=0,o,c,l,u,d,f,h,y=0,g=0,m=!1,p=!1,b,_=ue("live-project"),x=ue("live-source"),v=(L)=>x.value?`${L}${L.includes("?")?"&":"?"}source=${encodeURIComponent(x.value)}`:L,E=ue("live-run"),S=ue("live-work"),T=()=>`kiln.live.selection.${x.value}.${_.value}.${S.value}.${E.value}`,A=()=>`kiln.live.pin.${x.value}`,P=()=>t.filter((L)=>(!E.value||L.sessionId===E.value)&&(!S.value||(S.value==="ungrouped"?!L.workId:L.workId===S.value))),w=(L,W)=>{let te=ue("live-connection");te.textContent=L?"Connected":"Reconnecting",te.className=`pill ${L?"connected":"warning"}`,ue("connection-status").textContent=W};function I(){let L=S.value,W=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(S.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...W.map((ce)=>new Option(ce,ce))),L==="ungrouped"||W.includes(L))S.value=L;let te=E.value,ie=[...new Set(t.map((ce)=>ce.sessionId))];E.replaceChildren(new Option("All runs",""));for(let ce of ie){let _e=t.find((Re)=>Re.sessionId===ce);E.append(new Option(`${_e.transport} · ${Tn(ce)}`,ce))}if(ie.includes(te))E.value=te}function F(){let L=ue("live-timeline"),W=L.scrollTop,te=L.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(L.replaceChildren(),!e.operations.length){L.append(Uo("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let ie of[...e.operations].reverse()){let ce=k("button",void 0,`timeline-item ${ie.status}${e.selected?.operationId===ie.operationId?" selected":""}${ie.pinned?" pinned":""}`);ce.dataset.operation=ie.operationId;let _e=k("span",void 0,"timeline-meta");if(_e.append(k("span",ie.transport.toUpperCase()),k("time",new Date(ie.startedAt).toLocaleTimeString())),ce.append(_e,k("strong",ie.tool.replace(/^kiln_/,"")),k("small",`${ie.status} · ${ie.artifact?"artifact available":"no artifact"}`),k("small",ie.workId?`Item ${ie.workId}`:`Ungrouped · run ${Tn(ie.sessionId)}`)),ce.setAttribute("aria-label",`${ie.tool}, ${ie.status}, ${new Date(ie.startedAt).toLocaleString()}`),e.selected?.operationId===ie.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=Jg(e,ie.operationId),Vi(T(),ie.operationId),q()},L.append(ce),te===ie.operationId)ce.focus({preventScroll:!0})}L.scrollTop=W}function N(L){let W=k("div",void 0,"evidence-card");W.append(k("h3","Capture fidelity"));let te=L.viewFidelity,ie=te&&typeof te==="object"?te:void 0;if(W.append(k("strong",ie?String(ie.delivered??"Reported"):"No capture receipt yet")),W.append(k("p",ie?.materialFaithful===!0?"Material-faithful capture reported.":ie?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),ie?.degradeReason)W.append(k("p",String(ie.degradeReason)));if(ie?.rendererId)W.append(k("p",`Renderer: ${String(ie.rendererId)}`,"mono"));if(ie?.inputGlbSha256)W.append(k("p",`Capture input: ${String(ie.inputGlbSha256)}`,"mono"));if(ie)W.append(k("p",ie.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return W}function U(){let L=ue("live-evidence"),W=ue("live-downloads");L.replaceChildren(),W.replaceChildren();let te=e.displayed;if(!te?.artifact){b=void 0;return}let ie=k("div",void 0,"evidence-card");ie.append(k("h3","Selected observed artifact"),k("strong",`${(te.artifact.bytes/1024).toFixed(0)} KB GLB`),k("p",te.artifact.sha256,"mono"),k("p",`Source: ${te.programRef??"See authored source download"}`,"mono")),L.append(ie,N(te));let ce=`${x.value}/${te.operationId}/${te.artifact.sha256}`;if(b?.key!==ce){let _e=k("div",void 0,"evidence-card live-material-inspection"),Re=k("button","Inspect exact material inputs","secondary");_e.append(k("h3","Materials and atlas sheets"),k("p","Declared inputs for this displayed artifact. Raw sheets are unshaded; capture fidelity is reported separately."),Re),b={key:ce,card:_e},Re.onclick=async()=>{Re.disabled=!0;let Oe=k("p","Reading the displayed artifact evaluation…");Oe.setAttribute("role","status"),_e.append(Oe);try{let We=await un(v(`/api/live/${encodeURIComponent(te.operationId)}/evaluation.json`));if(b?.key!==ce)return;let Ye=eR(We,te.artifact.sha256);Oe.textContent=Ye.length?"Exact declared revisions. Map images require the matching record in this local material library.":"No saved material resource declarations in this artifact. Embedded textures can still be viewed in the viewport.";for(let Kt of Ye){let lt=k("details");lt.append(k("summary",`${Kt.name} · ${Kt.revisionId}`));let Dt=!1;lt.ontoggle=()=>{if(lt.open&&!Dt)Dt=!0,lt.append(uf(Kt))},_e.append(lt)}}catch(We){if(b?.key!==ce)return;Oe.textContent=`Material inspection unavailable for this exact artifact: ${We instanceof Error?We.message:String(We)}`,Re.disabled=!1}}}if(L.append(b.card),te.captures.length)for(let _e of te.captures){let Re=k("div",void 0,"evidence-card");Re.append(k("h3",_e.name));let Oe=te.viewFidelity&&typeof te.viewFidelity==="object"?te.viewFidelity:void 0;Re.append(k("p",Oe?.materialFaithful===!0?`Recorded capture · ${String(Oe.delivered??"material-faithful")}`:`Recorded capture · ${String(Oe?.delivered??"fidelity unreported")}. Materials are not verified.`,Oe?.materialFaithful===!0?"subtle":"warning"));let We=k("a"),Ye=k("img");Ye.src=_e.url,Ye.alt=`Recorded ${_e.name} for ${te.tool}`,Ye.loading="lazy",We.href=_e.url,We.target="_blank",We.rel="noopener",We.append(Ye),Re.append(We,k("p",_e.sha256,"mono")),L.append(Re)}else{let _e=k("div",void 0,"evidence-card");_e.append(k("h3","Recorded captures"),k("p",te.status==="evaluated"||te.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),L.append(_e)}for(let[_e,Re,Oe]of[[te.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(te.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let We=k("a",Re);We.href=_e,We.download=Oe,W.append(We)}W.append(k("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 D(){let L=Ws(e.displayed,l);ue("pin-build").disabled=!L,Me.disabled=L?.status!=="complete"}function O(){if(d&&l)ue("live-stage-label").textContent=qg(d,Tn(l.operationId),o?.lod())}function K(){if(f&&u)ue("compare-stage-label").textContent=`Pinned · ${qg(f,Tn(u.operationId),c?.lod())}`}async function B(L){if(ue("live-panel").hidden)return;let W=++y;if(!Ws(L,l))o?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!L?.artifact){ue("live-performance").replaceChildren(),o?.dispose(),o=void 0,l=void 0,d=void 0,ue("live-level-field").hidden=!0,ue("live-lod").replaceChildren(),ue("live-lod").hidden=!0,ue("live-stage-status").textContent="No completed artifact available for this run.",ue("live-stage-label").textContent="Current",D();return}if(l?.artifact?.sha256===L.artifact.sha256){l=L,ue("live-stage-status").textContent="",O(),D();return}ue("live-stage-status").textContent=`Loading ${Tn(L.operationId)}…${l?` Previous artifact ${Tn(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let te=await fetch(L.artifact.url);if(!te.ok)throw Error("This retained artifact is no longer available");let ie=new Uint8Array(await te.arrayBuffer());if(W!==y)return;o??=cl(ue("live-stage"));let ce=await o.load(ie,{isCurrent:()=>W===y,onCommit:()=>{l=L},preserveView:l?.projectId===L.projectId&&(l?.sessionId===L.sessionId||e.following)});if(!ce||W!==y)return;ue("live-performance").replaceChildren(),l=L,d=ce,D();let _e=ue("live-level");if(ue("live-level-field").hidden=!ce.levels,ll(_e,ue("live-lod"),o,(Re)=>{if(Re!==void 0)c?.level(Re),h?.refresh(),K();O()}),o.wire(m),o.navigation(ue("live-navigation").value),ue("live-stage-status").textContent="",O(),c)c.setView(o.view())}catch(te){if(W!==y)return;ue("live-stage-status").textContent=`${te instanceof Error?te.message:te}.${l?` Previous artifact ${Tn(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,D()}}async function X(L){if(ue("live-panel").hidden)return;let W=++g;if(ue("compare-viewport").hidden=!L?.artifact,ue("review-viewports").classList.toggle("comparing",!!L?.artifact),!L?.artifact){c?.dispose(),c=void 0,u=void 0,f=void 0,h=void 0,ue("compare-lod").replaceChildren(),ue("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===L.artifact.sha256){u=L,K(),ue("compare-stage-status").textContent="";return}if(!u)ue("compare-stage-label").textContent="Comparison";ue("compare-stage-status").textContent=`Loading pinned ${Tn(L.operationId)}…`;try{let te=await fetch(L.artifact.url);if(!te.ok)throw Error("Pinned artifact unavailable");let ie=new Uint8Array(await te.arrayBuffer());if(W!==g)return;c??=cl(ue("compare-stage"));let ce=await c.load(ie,{preserveView:!0,isCurrent:()=>W===g,onCommit:()=>{u=L}});if(!ce||W!==g)return;if(u=L,f=ce,o)c.setView(o.view());let _e=Number(ue("live-level").value||0);c.level(Number.isFinite(_e)?_e:0),ue("compare-level-field").hidden=!ce.levels,h=ll(ue("compare-level"),ue("compare-lod"),c,K),K(),c.wire(m),c.navigation(ue("live-navigation").value),ue("compare-stage-status").textContent=""}catch(te){if(W===g)ue("compare-stage-status").textContent=`${te instanceof Error?te.message:String(te)}.${u?` Previous comparison ${Tn(u.operationId)} remains visible.`:""}`}}function q(){F();let L=e.selected,W=e.displayed,te=ue("follow-latest");te.textContent=e.following?"Following latest":"Follow latest",te.setAttribute("aria-pressed",String(e.following));let ie=ue("live-current-summary");if(ie.replaceChildren(),L){ie.append(k("h2",L.tool.replace(/^kiln_/,"")),k("p",`${L.status} · ${L.transport} · Run ${Tn(L.sessionId)} · ${new Date(L.updatedAt).toLocaleString()}`));let Re=k("div",void 0,"tags");if(L.projectId)Re.append(k("span",L.projectId,"tag"));for(let Oe of L.phases)Re.append(k("span",Oe.phase,"tag"));ie.append(Re)}else ie.append(k("h2","No build selected"),k("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=L&&"observationIssues"in L&&Array.isArray(L.observationIssues)?L.observationIssues.map(String):[],_e=[L?.error,...ce,L&&W&&L.operationId!==W.operationId?`Current ${L.status} operation has no retained artifact. Showing the last successful artifact ${Tn(W.operationId)} from run ${Tn(W.sessionId)}.`:"",L&&!e.operations.some((Re)=>Re.operationId===L.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ue("live-failure").textContent=_e.join(" "),ue("live-failure").hidden=!_e.length,D(),ue("clear-pin").hidden=!e.pinned,ue("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ue("live-record").textContent=JSON.stringify({selected:L,displayedArtifactOperation:W?.operationId,pinnedOperation:e.pinned?.operationId},null,2),U(),B(W),X(e.pinned)}async function le(){if(r)return;r=!0;let L=i;try{let W=new URLSearchParams;if(_.value)W.set("project",_.value);if(n)W.set("cursor",n);let te=await un(v(`/api/live?${W}`));if(L!==i)return;if(a=0,w(!0,"Connected · checks every 2 seconds"),n=te.cursor,ue("live-history-note").textContent=`Up to ${te.retention.maxOperations} operations`,ue("live-history-issues").textContent=te.observationIssues?.join(" ")??"",ue("live-history-issues").hidden=!te.observationIssues?.length,!te.unchanged){if(t=te.operations,I(),e=xl(e,P()),!p){p=!0;let ie=Es(T());if(ie&&e.operations.some((_e)=>_e.operationId===ie))e=Jg(e,ie);let ce=Es(A());e.pinned=t.find((_e)=>_e.operationId===ce&&_e.pinned)??[...t].reverse().find((_e)=>_e.pinned&&_e.artifact)}q()}}catch(W){a++,w(!1,`Connection lost. Retrying; retained views remain available. ${W instanceof Error?W.message:W}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void le(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(a,4)))}}_.onchange=()=>{i++,n="",t=[],p=!1,E.replaceChildren(new Option("All runs","")),S.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),le()},x.onchange=()=>{_.value="",e.pinned=void 0,_.dispatchEvent(new Event("change"))},un("/api/live-sources").then(({sources:L})=>{x.replaceChildren(...L.map((W)=>new Option(W.label,W.id)))}).catch(Mn),E.onchange=()=>{e=xl({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!E.value},P()),q()},S.onchange=()=>E.dispatchEvent(new Event("change")),ue("follow-latest").onclick=()=>{e=xl({...e,following:!e.following},P()),Vi(T(),e.following?"":e.selected?.operationId??""),q()},ue("live-refresh").onclick=()=>{n="",le(),q()},ue("pin-build").onclick=async()=>{let L=Ws(e.displayed,l);if(!L?.artifact)return;let W=ue("pin-build");W.disabled=!0;try{await un(v(`/api/live/${encodeURIComponent(L.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...L,pinned:!0},Vi(A(),L.operationId),n="",q(),le()}catch(te){Mn(te),D()}},ue("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await un(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,Vi(A(),""),n="",q(),le()}catch(L){Mn(L)}},ue("live-frame").onclick=()=>{if(o?.reset(),o)c?.setView(o.view())},ue("live-wire").onclick=()=>{m=!m,o?.wire(m),c?.wire(m),ue("live-wire").setAttribute("aria-pressed",String(m))};let de=k("button","Match comparison camera","secondary");de.onclick=()=>{if(o)c?.setView(o.view())},ue("live-frame").parentElement?.append(de);let Me=k("button","Save exact artifact");Me.disabled=!0,ue("live-frame").parentElement?.prepend(Me);let pe=k("button","Measure 3 s","secondary"),J=k("div");return J.id="live-performance",ue("live-evidence").after(J),ue("live-frame").parentElement?.append(pe),df(pe,J,()=>o,()=>Ws(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),Me.onclick=()=>{let L=Ws(e.displayed,l);if(L?.status!=="complete")return;let W=k("dialog"),te=k("form"),ie=k("div",void 0,"editor-content"),ce=k("h2","Save reviewed artifact");ce.id="save-review-title",W.setAttribute("aria-labelledby",ce.id),ie.append(ce,k("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"),k("p",`${L.operationId} · revision ${L.revision}`,"mono"),k("p",L.artifact.sha256,"mono"));let _e=k("input");_e.required=!0,_e.maxLength=200,_e.value="";let Re=k("label","Asset name","field");Re.append(_e);let Oe=k("p");Oe.setAttribute("role","status");let We=k("button","Save exact artifact");We.type="submit";let Ye=k("button","Cancel","secondary");Ye.type="button",Ye.onclick=()=>W.close(),ie.append(Re,Oe,We,Ye),te.append(ie),W.append(te),document.body.append(W),W.addEventListener("close",()=>W.remove()),te.onsubmit=async(Kt)=>{Kt.preventDefault(),We.disabled=!0,Oe.textContent="Saving retained bytes…";try{let lt=rR(L,_e.value,l,e.displayed),Dt=await un(v(lt.path),{method:"POST",body:lt.body});Oe.replaceChildren(k("span",`Saved ${Dt.asset.assetId} / ${Dt.asset.revisionId}. `));let Yt=k("a","Open saved revision"),tn=new URLSearchParams({collection:Dt.collection,asset:Dt.asset.assetId,revision:Dt.asset.revisionId});Yt.href=`/?${tn}`,Oe.append(Yt);let z=k("div");ie.append(z),_l(z,{collectionId:Dt.collection,assetId:Dt.asset.assetId,revisionId:Dt.asset.revisionId},Dt.asset.name,async()=>{}).catch((xn)=>{z.textContent=`Asset saved; membership unavailable: ${xn instanceof Error?xn.message:xn}. Open the saved asset in Library to link it.`}),_e.disabled=!0,We.textContent="Saved",Ye.textContent="Close"}catch(lt){Oe.textContent=lt instanceof Error?lt.message:String(lt),We.disabled=!1}},W.showModal(),_e.focus()},ue("live-navigation").onchange=(L)=>{let W=L.target.value;o?.navigation(W),c?.navigation(W),ue("live-navigation-help").textContent=W==="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="",le()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)le()}),le(),{activate:q,projects(L){let W=_.value;_.replaceChildren(new Option("All work",""));for(let te of L)_.append(new Option(te.name,te.projectId));if(L.some((te)=>te.projectId===W))_.value=W}}}var Yg=["projects","live","library","materials"];function aR(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";if(yl(e))return"materials";return t&&Yg.some((i)=>i===t)?t:"library"}function oR(e,t=()=>{}){let n=Yg;function i(c){if(!n.includes(c))return;for(let l of n)ue(`${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(Vi("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(Mn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ue("open-files").onclick=()=>ue("open").click();let r=sR(),s=nR(()=>a.refresh()),a=YM({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(aR(location.search,Es("kiln.section"))),a.refresh().catch(Mn),s.refresh().catch(Mn);let o=!1;return window.setInterval(async()=>{if(document.hidden||o||ue("project-editor").open)return;o=!0;try{await a.refresh()}catch{}finally{o=!1}},5000),{library:()=>i("library"),refreshProjects:a.refresh}}var _r=(e)=>`${e.collection}/${e.manifest.assetId}`;function cR(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((a)=>a.asset?[`${a.asset.collectionId}/${a.asset.assetId}`]:[])));return e.filter((s)=>!r.has(_r(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(`${_r(r)}/${r.manifest.revisionId}`))}var Ue=(e)=>document.getElementById(e),dt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},Al=[],Tl=[],Zs=[],Pa=[],ff="",qs,vr,An,Xs=0,lR=0,vl=!1,El=!1,Js=new Set,nb=[],uR=[],Gr=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,eb=(e)=>{Ue("status").textContent=e},Er=(e)=>eb(e instanceof Error?e.message:String(e)),Oa=(e,t,n=nb)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function tb(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function Qg(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/${Gr(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function T9(e,t){if(e.local){if(t==="editable.zip")return Oa(Hh([e.local]),"application/zip");return Oa(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return Oa(e.loose,"model/gltf-binary");return`/files/${Gr(e)}/${t}?download`}function dR(e,t){try{localStorage.setItem(e,t)}catch{}}function A9(e){try{return localStorage.getItem(e)}catch{return null}}function S9(){let e=Ue("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...Al,...Pa.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=dt("button",t.label,ff===t.id?"active":"");n.onclick=()=>void Ko(t.id).catch(Er),e.append(n)}}async function Ko(e,t=!0){if(t)hR.library();let n=++lR;ff=e,Js.clear(),S9(),eb("");let i=e==="all"?await(async()=>{let r=await tb("/api/library");if(r.errors.length)eb(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?Pa:(await tb(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==lR)return;Zs=i,dR("kiln.collection",e),Ue("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":Al.find((r)=>r.id===e)?.label??e,Ue("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.",hf()}function w9(){let e=new Map;for(let t of cR(Zs,Tl,Ue("library-project").value)){let n=_r(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===A9(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function hf(){for(let i of uR.splice(0))URL.revokeObjectURL(i);let e=Ue("cards");e.replaceChildren();let t=Ue("search").value.toLowerCase(),n=w9().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Ue("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Ue("export-selection").disabled=!Js.size,!n.length){let i=dt("div",void 0,"empty");if(i.append(dt("b",t?"No matching assets":"Your next idea belongs here."),dt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(dt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=dt("article",void 0,"card"),a=dt("button",void 0,"card-open");a.setAttribute("aria-label",`View ${r.name}`),a.onclick=()=>void Sl(i).catch(Er);let o=dt("div",void 0,"thumb");if(r.files["preview.png"]){let y=dt("img");y.loading="lazy",y.alt=r.name,y.src=i.local?Oa(i.local.files["preview.png"],"image/png",uR):`/files/${Gr(i)}/preview.png`,y.onerror=()=>{y.remove(),o.textContent="◇"},o.append(y)}else o.textContent="◇";let c=dt("div",void 0,"card-content");c.append(dt("span",r.name,"card-title"));let l=Zs.filter((y)=>_r(y)===_r(i)),u=new Set(l.map((y)=>y.manifest.parentRevision)),d=l.filter((y)=>!u.has(y.manifest.revisionId));c.append(dt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${d.length>1?` · ${d.length} branches`:""}`,"card-meta"));let f=dt("div",void 0,"tags");for(let y of r.tags)f.append(dt("span",y,"tag"));c.append(f),c.append(dt("small",Al.find((y)=>y.id===i.collection)?.label??i.collection,"card-meta"));let h=Tl.filter((y)=>y.inventory.some((g)=>g.asset&&g.asset.collectionId===i.collection&&g.asset.assetId===r.assetId));if(c.append(dt("small",h.length?h.map((y)=>y.name).join(" · "):"No project membership","card-meta")),a.append(o,c),s.append(a),!i.loose){let y=dt("input");y.type="checkbox",y.className="selection",y.checked=Js.has(Gr(i)),y.setAttribute("aria-label",`Select ${r.name}`),y.onchange=()=>{if(y.checked)Js.add(Gr(i));else Js.delete(Gr(i));Ue("export-selection").disabled=!Js.size},s.append(y)}e.append(s)}}async function Sl(e){let t=++Xs;qs=e,vr=void 0,An?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Ue("library-performance").replaceChildren(),dR(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let u of nb.splice(0))URL.revokeObjectURL(u);let n=Ue("detail");if(!n.open)n.showModal();Ue("asset-name").textContent=e.manifest.name;let i=Ue("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let u=dt("div");i.append(u),_l(u,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,hR.refreshProjects).catch(Er)}let r=Ue("revisions");r.replaceChildren();for(let u of Zs.filter((d)=>_r(d)===_r(e))){let d=dt("option",`${new Date(u.manifest.createdAt).toLocaleString()} · ${u.manifest.description||u.manifest.revisionId.slice(0,10)}`);d.value=u.manifest.revisionId,d.selected=u.manifest.revisionId===e.manifest.revisionId,r.append(d)}r.onchange=()=>{let u=Zs.find((d)=>_r(d)===_r(e)&&d.manifest.revisionId===r.value);if(u)Sl(u).catch(Er)},Ue("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=Ue("asset-attribution");s.replaceChildren();for(let u of Gv(e.manifest)){let d=dt("div");d.append(dt("span",u.label),dt("strong",u.value)),s.append(d)}s.hidden=!s.childElementCount;let a=document.getElementById("asset-material-inputs");if(!a)a=dt("section",void 0,"asset-material-inputs"),a.id="asset-material-inputs",s.after(a);a.replaceChildren();try{let u=Vh({manifest:e.manifest,files:{}});if(u.length){a.append(dt("h3","Exact material build inputs"),dt("p","Open the saved revision to inspect its raw maps, sampling declaration and atlas regions. Declared inputs do not prove every map was used.","subtle"));for(let d of u){let f=dt("a",`${d.name} · ${d.materialId}`);f.href=lf(d),f.target="_blank",f.rel="noopener",a.append(f,dt("p",d.revisionId,"mono"))}}}catch(u){a.append(dt("p",`Material revision links unavailable: ${u instanceof Error?u.message:String(u)}`,"subtle"))}Ue("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Ue("downloads");o.replaceChildren();for(let[u,d]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 f=dt("a",d);f.href=T9(e,u),f.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${u==="asset.glb"?".glb":u==="source.kiln.js"?".kiln.js":".zip"}`,o.append(f)}if(!e.loose){let u=dt("button","Runtime GLB"),d=dt("span");d.setAttribute("role","status"),u.onclick=async()=>{u.disabled=!0,d.textContent="Preparing runtime download…";try{let f=e.local?await HM(e.local,{profile:"runtime"}):void 0,[h,y]=f?.profile==="runtime"?[f.glb,f.metadata.bytes]:await Promise.all([Qg(e,"runtime.glb"),Qg(e,"runtime.kiln-metadata.json")]);if(t!==Xs)return;let g=dt("a","Runtime GLB");g.href=Oa(h,"model/gltf-binary"),g.download="runtime.glb";let m=dt("a","Runtime metadata");m.href=Oa(y,"application/json"),m.download="runtime.kiln-metadata.json",u.replaceWith(g,m),d.textContent="Keep the companion metadata for traceability.",g.click()}catch(f){if(t!==Xs)return;d.textContent=`Runtime export unavailable: ${f instanceof Error?f.message:f}`,u.disabled=!1}},o.append(u,d),o.append(dt("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."))}Ue("refine").disabled=!e.manifest.editable,Ue("asset-stats").replaceChildren(),Ue("stage-status").textContent="Loading saved GLB…",vl=!1,El=!1,Ue("wire").setAttribute("aria-pressed","false"),Ue("play").textContent="Pause";let c=Ue("animation");c.replaceChildren(new Option("Rest pose","")),Ue("play").disabled=!0;let l=Ue("level");l.replaceChildren(),l.hidden=!0,Ue("library-lod").replaceChildren(),Ue("library-lod").hidden=!0;try{An??=cl(Ue("stage"));let u=await Qg(e,"asset.glb");if(t!==Xs)return;let d=await An.load(u,{isCurrent:()=>t===Xs,onCommit:()=>{vr=e}});if(!d||t!==Xs)return;vr=e,An.wire(!1),An.navigation(Ue("library-navigation").value),An.lighting(Ue("lighting").value),ll(l,Ue("library-lod"),An);for(let[f,h]of[...d.levels?d.levels.map((y,g)=>[y.toLocaleString(),`LOD${g} triangles`]):[[d.triangles.toLocaleString(),"triangles"]],[d.meshes,d.levels?"LOD0 meshes":"meshes"],[d.materials,d.levels?"LOD0 materials":"materials"],[`${(u.length/1024).toFixed(0)} KB`,"GLB"]]){let y=dt("div");y.append(dt("strong",String(f)),dt("span",String(h))),Ue("asset-stats").append(y)}for(let f=0;f<d.clips.length;f++)c.append(new Option(d.clips[f],String(f)));Ue("stage-status").textContent=""}catch(u){if(t===Xs)An?.dispose(),An=void 0,Ue("stage-status").textContent=`3D preview unavailable: ${u instanceof Error?u.message:u}. Downloads remain available.`}}async function fR(e){for(let t of e){if(t.bytes.length>ni)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of Hv(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((a)=>a.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!Pa.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))Pa.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Pa.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 Ko("opened-files")}Ue("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>ni))throw Error("File exceeds 64 MiB");await fR(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Er(t)}};Ue("refresh").onclick=()=>void Ko(ff).catch(Er);Ue("search").oninput=hf;Ue("library-project").onchange=()=>void Ko("all").catch(Er);Ue("close-detail").onclick=()=>Ue("detail").close();Ue("detail").addEventListener("close",()=>{Xs++,vr=void 0,An?.dispose(),An=void 0;for(let e of nb.splice(0))URL.revokeObjectURL(e);hf()});Ue("frame").onclick=()=>An?.reset();Ue("wire").onclick=()=>{vl=!vl,An?.wire(vl),Ue("wire").setAttribute("aria-pressed",String(vl))};Ue("lighting").onchange=(e)=>An?.lighting(e.target.value);Ue("library-navigation").onchange=(e)=>{let t=e.target.value;An?.navigation(t),Ue("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"};Ue("animation").onchange=(e)=>{let t=e.target.value;An?.clip(t===""?-1:Number(t)),Ue("play").disabled=t===""};Ue("play").onclick=()=>{El=!El,An?.pause(El),Ue("play").textContent=El?"Play":"Pause"};Ue("refine").onclick=async()=>{if(!qs)return;let e=qs.manifest,t=qs.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=${qs.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=${qs.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Ue("refine").textContent="Instructions copied"}catch{Ue("provenance").textContent=t,Ue("provenance").parentElement?.setAttribute("open","")}};Ue("export-selection").onclick=()=>{try{let e=dt("a");if(ff==="opened-files")e.href=Oa(Hh(Zs.filter((t)=>Js.has(Gr(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Js)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Er(e)}};async function M9(){Al=(await tb("/api/collections")).collections;let e=cS(location.search);if(await Ko(Al.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Zs.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 Sl(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await fR([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),Pa.length===1)await Sl(Pa[0])}}var hR=oR((e)=>{(async()=>{await Ko(e.collectionId);let t=Zs.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 Sl(t)})().catch(Er)},(e)=>{Tl=e;let t=Ue("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of Tl)t.append(new Option(i.name,i.projectId));if(n==="standalone"||Tl.some((i)=>i.projectId===n))t.value=n;hf()});df(Ue("measure-library"),Ue("library-performance"),()=>An,()=>vr&&qs&&Gr(vr)===Gr(qs)?{collection:vr.collection,assetId:vr.manifest.assetId,revisionId:vr.manifest.revisionId,glbSha256:vr.manifest.files["asset.glb"]?.sha256}:void 0);M9().catch(Er);
diff --git a/dist/viewer/chat.html b/dist/viewer/chat.html
index 3d568330..c4df88ee 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 ap="186",cr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},cp=0,ql=1,lp=2;var po=1,up=2,Ss=3,ur=0,sn=1,kn=2,fi=0,mo=1,Yl=2,Jl=3,Kl=4,hp=5;var Ms=100,dp=101,fp=102,pp=103,mp=104,gp=200,_p=201,xp=202,yp=203,vp=204,bp=205,Sp=206,Mp=207,wp=208,Ep=209,Ap=210,Tp=211,Rp=212,Cp=213,Pp=214,Ip=0,Lp=1,Np=2,Ql=3,Dp=4,Op=5,Up=6,Fp=7,zp=0,kp=1,Bp=2,Kn=0,eu=1,tu=2,nu=3,go=4,iu=5,ru=6,su=7;var ws=301,Or=302,Ya=303,Ja=304,_o=306,Es=1000,As=1001,Ka=1002,Qn=1003,Qa=1004;var Ur=1005;var qt=1006,Ts=1007;var pi=1008;var ei=1009,Vp=1010,Gp=1011,xo=1012,ou=1013,hr=1014,Hi=1015,mi=1016,au=1017,cu=1018,Rs=1020,Hp=35902,$p=35899,Wp=1021,Zp=1022,gi=1023,Fr=1026,zr=1027,Xp=1028,lu=1029,kr=1030,uu=1031;var hu=1033,ec=33776,tc=33777,nc=33778,ic=33779,du=35840,fu=35841,pu=35842,mu=35843,gu=36196,_u=37492,xu=37496,yu=37488,vu=37489,rc=37490,bu=37491,Su=37808,Mu=37809,wu=37810,Eu=37811,Au=37812,Tu=37813,Ru=37814,Cu=37815,Pu=37816,Iu=37817,Lu=37818,Nu=37819,Du=37820,Ou=37821,Uu=36492,Fu=36494,zu=36495,ku=36283,Bu=36284,sc=36285,Vu=36286;var Gu=2300,oc=2301;var Hu=0,yo=1,Cs=2;var $u=0,jp=1,Br="",dr="srgb",wn="srgb-linear",Wu="linear",yt="srgb";var qp=512,Yp=513,Jp=514,ac=515,Kp=516,Qp=517,cc=518,em=519;var Zu="300 es",Xu=2000;function Ab(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Tb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ys(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function tm(){let e=ys("canvas");return e.style.display="block",e}var wf={},vs=null;function fo(...e){let t="THREE."+e.shift();if(vs)vs("log",t,...e);else console.log(t,...e)}function nm(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 Le(...e){e=nm(e);let t="THREE."+e.shift();if(vs)vs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function ze(...e){e=nm(e);let t="THREE."+e.shift();if(vs)vs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Nr(...e){let t=e.join(" ");if(t in wf)return;wf[t]=!0,Le(...e)}function im(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 rm={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ti{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 nn=["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"],Ef=1234567,uo=Math.PI/180,Dr=180/Math.PI;function Jn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(nn[e&255]+nn[e>>8&255]+nn[e>>16&255]+nn[e>>24&255]+"-"+nn[t&255]+nn[t>>8&255]+"-"+nn[t>>16&15|64]+nn[t>>24&255]+"-"+nn[n&63|128]+nn[n>>8&255]+"-"+nn[n>>16&255]+nn[n>>24&255]+nn[i&255]+nn[i>>8&255]+nn[i>>16&255]+nn[i>>24&255]).toLowerCase()}function qe(e,t,n){return Math.max(t,Math.min(n,e))}function ju(e,t){return(e%t+t)%t}function Rb(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Cb(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function ho(e,t,n){return(1-n)*e+n*t}function Pb(e,t,n,i){return ho(e,t,1-Math.exp(-n*i))}function Ib(e,t=1){return t-Math.abs(ju(e,t*2)-t)}function Lb(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 Nb(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 Db(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Ob(e,t){return e+Math.random()*(t-e)}function Ub(e){return e*(0.5-Math.random())}function Fb(e){if(e!==void 0)Ef=e;let t=Ef+=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 zb(e){return e*uo}function kb(e){return e*Dr}function Bb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Vb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Gb(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Hb(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:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Yn(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 dt(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 vo={DEG2RAD:uo,RAD2DEG:Dr,generateUUID:Jn,clamp:qe,euclideanModulo:ju,mapLinear:Rb,inverseLerp:Cb,lerp:ho,damp:Pb,pingpong:Ib,smoothstep:Lb,smootherstep:Nb,randInt:Db,randFloat:Ob,randFloatSpread:Ub,seededRandom:Fb,degToRad:zb,radToDeg:kb,isPowerOfTwo:Bb,ceilPowerOfTwo:Vb,floorPowerOfTwo:Gb,setQuaternionFromProperEuler:Hb,normalize:dt,denormalize:Yn};class De{static{De.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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(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(qe(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 Xt{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(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,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:Le("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(qe(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 U{static{U.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(Af.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Af.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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(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 wl.copy(this).projectOnVector(e),this.sub(wl)}reflect(e){return this.sub(wl.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(qe(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 wl=new U,Af=new Xt;class Ve{static{Ve.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],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=h*m+d*g+f*y,r[5]=h*_+d*S+f*w,r[8]=h*p+d*T+f*A,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 Nr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(El.makeScale(e,t)),this}rotate(e){return Nr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(El.makeRotation(-e)),this}translate(e,t){return Nr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(El.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 El=new Ve,Tf=new Ve().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Rf=new Ve().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function $b(){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=Gi(r.r),r.g=Gi(r.g),r.b=Gi(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=xs(r.r),r.g=xs(r.g),r.b=xs(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 Nr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Nr("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:Tf,fromXYZ:Rf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Tf,fromXYZ:Rf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=$b();function Gi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function xs(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var rs;class qu{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(rs===void 0)rs=ys("canvas");rs.width=e.width,rs.height=e.height;let i=rs.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=rs}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=ys("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]=Gi(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(Gi(t[n]/255)*255);else t[n]=Gi(t[n]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Wb=0;class bo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Wb++}),this.uuid=Jn(),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(Al(i[s].image));else r.push(Al(i[s]))}else r=Al(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Al(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return qu.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 Le("Texture: Unable to serialize Texture."),{}}var Zb=0,Tl=new U;class Nt extends ti{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Zb++}),this.uuid=Jn(),this.name="",this.source=new bo(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 De(0,0),this.repeat=new De(1,1),this.center=new De(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,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(Tl).x}get height(){return this.source.getSize(Tl).y}get depth(){return this.source.getSize(Tl).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){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`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++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class ft{static{ft.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 S=(c+1)/2,T=(d+1)/2,y=(p+1)/2,w=(l+h)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(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 Yu extends ti{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 ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(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 bo(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 En extends Yu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class lc extends Nt{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 Ju extends Nt{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 $e{static{$e.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 $e().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/ss.setFromMatrixColumn(e,0).length(),r=1/ss.setFromMatrixColumn(e,1).length(),s=1/ss.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(Xb,e,jb)}lookAt(e,t,n){let i=this.elements;if(Sn.subVectors(e,t),Sn.lengthSq()===0)Sn.z=1;if(Sn.normalize(),tr.crossVectors(n,Sn),tr.lengthSq()===0){if(Math.abs(n.z)===1)Sn.x+=0.0001;else Sn.z+=0.0001;Sn.normalize(),tr.crossVectors(n,Sn)}return tr.normalize(),Sa.crossVectors(Sn,tr),i[0]=tr.x,i[4]=Sa.x,i[8]=Sn.x,i[1]=tr.y,i[5]=Sa.y,i[9]=Sn.y,i[2]=tr.z,i[6]=Sa.z,i[10]=Sn.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],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],z=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],k=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*z+a*I+c*j,r[8]=s*R+o*C+a*G+c*k,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+h*K+d*P,r[5]=l*A+u*z+h*I+d*j,r[9]=l*R+u*C+h*G+d*k,r[13]=l*x+u*L+h*X+d*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*z+_*I+p*j,r[10]=f*R+m*C+_*G+p*k,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*z+T*I+y*j,r[11]=g*R+S*C+T*G+y*k,r[15]=g*x+S*L+T*X+y*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,S=o*d-c*u,T=o*h-a*u,y=s*d-c*l,w=s*h-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}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,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-h*f,M=l*p-d*f,z=u*_-h*m,C=u*p-d*m,L=h*p-d*_,K=g*L-S*C+T*z+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*z)*I,e[1]=(i*C-n*L-r*z)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(h*w-u*A-d*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-h*T+d*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-d*g)*I,e[12]=(o*x-s*z-a*R)*I,e[13]=(t*z-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+h*g)*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,h=r*c,d=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(d+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(d-T)*w,i[5]=(1-(h+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(h+m))*A,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=ss.set(i[0],i[1],i[2]).length(),o=ss.set(i[4],i[5],i[6]).length(),a=ss.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Xn.copy(this);let c=1/s,l=1/o,u=1/a;return Xn.elements[0]*=c,Xn.elements[1]*=c,Xn.elements[2]*=c,Xn.elements[4]*=l,Xn.elements[5]*=l,Xn.elements[6]*=l,Xn.elements[8]*=u,Xn.elements[9]*=u,Xn.elements[10]*=u,t.setFromRotationMatrix(Xn),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 ss=new U,Xn=new $e,Xb=new U(0,0,0),jb=new U(1,1,1),tr=new U,Sa=new U,Sn=new U,Cf=new $e,Pf=new Xt;class di{constructor(e=0,t=0,n=0,i=di.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(qe(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(-qe(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(qe(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(-qe(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(qe(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(-qe(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:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Cf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pf.setFromEuler(this),this.setFromQuaternion(Pf,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}}di.DEFAULT_ORDER="XYZ";class uc{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 qb=0,If=new U,os=new Xt,Ui=new $e,Ma=new U,no=new U,Yb=new U,Jb=new Xt,Lf=new U(1,0,0),Nf=new U(0,1,0),Df=new U(0,0,1),Of={type:"added"},Kb={type:"removed"},as={type:"childadded",child:null},Rl={type:"childremoved",child:null};class gt extends ti{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:qb++}),this.uuid=Jn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let e=new U,t=new di,n=new Xt,i=new U(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 $e},normalMatrix:{value:new Ve}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uc,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 os.setFromAxisAngle(e,t),this.quaternion.multiply(os),this}rotateOnWorldAxis(e,t){return os.setFromAxisAngle(e,t),this.quaternion.premultiply(os),this}rotateX(e){return this.rotateOnAxis(Lf,e)}rotateY(e){return this.rotateOnAxis(Nf,e)}rotateZ(e){return this.rotateOnAxis(Df,e)}translateOnAxis(e,t){return If.copy(e).applyQuaternion(this.quaternion),this.position.add(If.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Lf,e)}translateY(e){return this.translateOnAxis(Nf,e)}translateZ(e){return this.translateOnAxis(Df,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)Ma.copy(e);else Ma.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),no.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Ui.lookAt(no,Ma,this.up);else Ui.lookAt(Ma,no,this.up);if(this.quaternion.setFromRotationMatrix(Ui),i)Ui.extractRotation(i.matrixWorld),os.setFromRotationMatrix(Ui),this.quaternion.premultiply(os.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 ze("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(Of),as.child=e,this.dispatchEvent(as),as.child=null;else ze("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(Kb),Rl.child=e,this.dispatchEvent(Rl),Rl.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(Of),as.child=e,this.dispatchEvent(as),as.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(no,e,Yb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(no,Jb,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"})}}gt.DEFAULT_UP=new U(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ui extends gt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Qb={type:"move"};class So{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ui,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 ui,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ui,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,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(Qb)}}}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 ui;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var sm={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},nr={h:0,s:0,l:0},wa={h:0,s:0,l:0};function Cl(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,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=ju(e,1),t=qe(t,0,1),n=qe(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=Cl(s,r,e+0.3333333333333333),this.g=Cl(s,r,e),this.b=Cl(s,r,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("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:Le("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 Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=sm[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("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=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=xs(e.r),this.g=xs(e.g),this.b=xs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(rn.copy(this),e),Math.round(qe(rn.r*255,0,255))*65536+Math.round(qe(rn.g*255,0,255))*256+Math.round(qe(rn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(rn.copy(this),t);let{r:n,g:i,b:r}=rn,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=je.workingColorSpace){return je.workingToColorSpace(rn.copy(this),t),e.r=rn.r,e.g=rn.g,e.b=rn.b,e}getStyle(e="srgb"){je.workingToColorSpace(rn.copy(this),e);let{r:t,g:n,b:i}=rn;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(nr),this.setHSL(nr.h+e,nr.s+t,nr.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(nr),e.getHSL(wa);let n=ho(nr.h,wa.h,t),i=ho(nr.s,wa.s,t),r=ho(nr.l,wa.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 rn=new Ue;Ue.NAMES=sm;class Ps extends gt{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 di,this.environmentIntensity=1,this.environmentRotation=new di,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 jn=new U,Fi=new U,Pl=new U,zi=new U,cs=new U,ls=new U,Uf=new U,Il=new U,Ll=new U,Nl=new U,Dl=new ft,Ol=new ft,Ul=new ft;class zn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),jn.subVectors(e,t),i.cross(jn);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){jn.subVectors(i,t),Fi.subVectors(n,t),Pl.subVectors(e,t);let s=jn.dot(jn),o=jn.dot(Fi),a=jn.dot(Pl),c=Fi.dot(Fi),l=Fi.dot(Pl),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 Dl.setScalar(0),Ol.setScalar(0),Ul.setScalar(0),Dl.fromBufferAttribute(e,t),Ol.fromBufferAttribute(e,n),Ul.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Dl,r.x),s.addScaledVector(Ol,r.y),s.addScaledVector(Ul,r.z),s}static isFrontFacing(e,t,n,i){return jn.subVectors(n,t),Fi.subVectors(e,t),jn.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 jn.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),jn.cross(Fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.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;cs.subVectors(i,n),ls.subVectors(r,n),Il.subVectors(e,n);let a=cs.dot(Il),c=ls.dot(Il);if(a<=0&&c<=0)return t.copy(n);Ll.subVectors(e,i);let l=cs.dot(Ll),u=ls.dot(Ll);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(cs,s);Nl.subVectors(e,r);let d=cs.dot(Nl),f=ls.dot(Nl);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(ls,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return Uf.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(Uf,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(cs,s).addScaledVector(ls,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-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(qn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qn.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=qn.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,qn);else qn.fromBufferAttribute(r,s);qn.applyMatrix4(e.matrixWorld),this.expandByPoint(qn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Ea.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Ea.copy(n.boundingBox)}Ea.applyMatrix4(e.matrixWorld),this.union(Ea)}}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,qn),qn.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(io),Aa.subVectors(this.max,io),us.subVectors(e.a,io),hs.subVectors(e.b,io),ds.subVectors(e.c,io),ir.subVectors(hs,us),rr.subVectors(ds,hs),Cr.subVectors(us,ds);let t=[0,-ir.z,ir.y,0,-rr.z,rr.y,0,-Cr.z,Cr.y,ir.z,0,-ir.x,rr.z,0,-rr.x,Cr.z,0,-Cr.x,-ir.y,ir.x,0,-rr.y,rr.x,0,-Cr.y,Cr.x,0];if(!Fl(t,us,hs,ds,Aa))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Fl(t,us,hs,ds,Aa))return!1;return Ta.crossVectors(ir,rr),t=[Ta.x,Ta.y,Ta.z],Fl(t,us,hs,ds,Aa)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(qn).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 U,new U,new U,new U,new U,new U,new U,new U],qn=new U,Ea=new Gt,us=new U,hs=new U,ds=new U,ir=new U,rr=new U,Cr=new U,io=new U,Aa=new U,Ta=new U,Pr=new U;function Fl(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 zt=new U,Ra=new De,eS=0;class jt extends ti{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:eS++}),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++)Ra.fromBufferAttribute(this,t),Ra.applyMatrix3(e),this.setXY(t,Ra.x,Ra.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.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=Yn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(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=Yn(t,this.array);return t}setX(e,t){if(this.normalized)t=dt(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=Yn(t,this.array);return t}setY(e,t){if(this.normalized)t=dt(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=Yn(t,this.array);return t}setZ(e,t){if(this.normalized)t=dt(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=Yn(t,this.array);return t}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(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 hc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class dc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class xn extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var tS=new Gt,ro=new U,zl=new U;class An{constructor(e=new U,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 tS.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;ro.subVectors(e,this.center);let t=ro.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(ro,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 zl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ro.copy(e.center).add(zl)),this.expandByPoint(ro.copy(e.center).sub(zl));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 nS=0,Un=new $e,kl=new gt,fs=new U,Mn=new Gt,so=new Gt,Zt=new U;class on extends ti{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nS++}),this.uuid=Jn(),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((Ab(e))?dc:hc)(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 Ve().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 Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return kl.lookAt(e),kl.updateMatrix(),this.applyMatrix4(kl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fs).negate(),this.translate(fs.x,fs.y,fs.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 xn(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)Le("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 Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(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)Zt.addVectors(this.boundingBox.min,Mn.min),this.boundingBox.expandByPoint(Zt),Zt.addVectors(this.boundingBox.max,Mn.max),this.boundingBox.expandByPoint(Zt);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))ze('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 An;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,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(so.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(Mn.min,so.min),Mn.expandByPoint(Zt),Zt.addVectors(Mn.max,so.max),Mn.expandByPoint(Zt);else Mn.expandByPoint(so.min),Mn.expandByPoint(so.max)}Mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Zt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zt));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(Zt.fromBufferAttribute(o,c),a)fs.fromBufferAttribute(e,c),Zt.add(fs);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))ze('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){ze("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 jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,h=new De,d=new De,f=new De,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),h.fromBufferAttribute(r,R),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let z=1/(d.x*f.y-f.x*d.y);if(!isFinite(z))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(z),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(z),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].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 M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let z=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,z)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+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 jt(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 U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;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++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.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 jt(h,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new on,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 Mo{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=Jn()}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=Jn();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=Jn();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 hn=new U;class Is{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++)hn.fromBufferAttribute(this,t),hn.applyMatrix4(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyNormalMatrix(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.transformDirection(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Yn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=dt(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=Yn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Yn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Yn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Yn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(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){fo("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 jt(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 Is(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){fo("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 Bl=new U,iS=new U,rS=new Ve;class Fn{constructor(e=new U(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=Bl.subVectors(n,t).cross(iS.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(Bl),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||rS.getNormalMatrix(e),i=this.coplanarPoint(Bl).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 sS=0;class yn extends ti{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:sS++}),this.uuid=Jn(),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){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`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 Fn().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 De().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 De().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 U,Vl=new U,Ca=new U,Pa=new U;class fr{constructor(e=new U,t=new U(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){Vl.copy(e).add(t).multiplyScalar(0.5),Ca.copy(t).sub(e).normalize(),Pa.copy(this.origin).sub(Vl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ca),o=Pa.dot(this.direction),a=-Pa.dot(Ca),c=Pa.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(Vl).addScaledVector(Ca,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,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,z,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=h,z=d,L=m,K=_,G=g,X=S;else A=l,R=c,M=d,z=h,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=h,I=m,P=g,c>=0)A=l,R=a,M=d,z=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,z=d,L=f,K=_,G=p,X=S;else if(x=l,C=d,I=_,P=S,l>=0)A=a,R=c,M=u,z=h,L=f,K=m,G=p,X=g;else A=c,R=a,M=h,z=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,k=R/x,q=1/x,ee=M-j*C,Se=z-k*C,ue=L-j*I,Be=K-k*I,Me=G-j*P,Z=X-k*P,re=Me*Be-Z*ue,se=ee*Z-Se*Me,xe=ue*Se-Be*ee;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 Ee=re+se+xe;if(Ee===0)return null;let Ae=q*(re*C+se*I+xe*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,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 _i extends yn{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 di,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 Ff=new $e,Ir=new fr,Ia=new An,zf=new U,La=new U,Na=new U,Da=new U,Gl=new U,Oa=new U,kf=new U,Ua=new U;class Mt extends gt{constructor(e=new on,t=new _i){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){Oa.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(Gl.fromBufferAttribute(u,e),s)Oa.addScaledVector(Gl,l);else Oa.addScaledVector(Gl.sub(t),l)}t.add(Oa)}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(Ia.copy(n.boundingSphere),Ia.applyMatrix4(r),Ir.copy(e.ray).recast(e.near),Ia.containsPoint(Ir.origin)===!1){if(Ir.intersectSphere(Ia,zf)===null)return;if(Ir.origin.distanceToSquared(zf)>(e.far-e.near)**2)return}if(Ff.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(Ff),n.boundingBox!==null){if(Ir.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ir)}_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),S=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=Fa(this,p,e,n,c,l,u,w,A,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(_),S=o.getX(_+1),T=o.getX(_+2);if(i=Fa(this,s,e,n,c,l,u,g,S,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),S=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=Fa(this,p,e,n,c,l,u,w,A,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=_,S=_+1,T=_+2;if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function oS(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;Ua.copy(a),Ua.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ua);if(l<n.near||l>n.far)return null;return{distance:l,point:Ua.clone(),object:e}}function Fa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,La),e.getVertexPosition(c,Na),e.getVertexPosition(l,Da);let u=oS(e,t,n,i,La,Na,Da,kf);if(u){let h=new U;if(zn.getBarycoord(kf,La,Na,Da,h),r)u.uv=zn.getInterpolatedAttribute(r,a,c,l,h,new De);if(s)u.uv1=zn.getInterpolatedAttribute(s,a,c,l,h,new De);if(o){if(u.normal=zn.getInterpolatedAttribute(o,a,c,l,h,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let d={a,b:c,c:l,normal:new U,materialIndex:0};zn.getNormal(La,Na,Da,d.normal),u.face=d,u.barycoord=h}return u}var oo=new ft,Bf=new ft,Vf=new ft,aS=new ft,Gf=new $e,za=new U,Hl=new An,Hf=new $e,$l=new fr;class fc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingBox.expandByPoint(za)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new An;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingSphere.expandByPoint(za)}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(Hl.copy(this.boundingSphere),Hl.applyMatrix4(i),e.ray.intersectsSphere(Hl)===!1)return;if(Hf.copy(i).invert(),$l.copy(e.ray).applyMatrix4(Hf),this.boundingBox!==null){if($l.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,$l)}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 ft,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 Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Bf.fromBufferAttribute(i.attributes.skinIndex,e),Vf.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=Vf.getComponent(r);if(s!==0){let o=Bf.getComponent(r);Gf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(aS.copy(oo).applyMatrix4(Gf),s)}}if(t.isVector4)t.w=oo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class wo extends gt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Eo extends Nt{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 $f=new $e,cS=new $e;class Ao{constructor(e=[],t=[]){this.uuid=Jn(),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){Le("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 $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new $e;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:cS;$f.multiplyMatrices(o,t[r]),$f.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ao(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)Le("Skeleton: No bone found with UUID:",r),s=new wo;this.bones.push(s),this.boneInverses.push(new $e().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 ar extends jt{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 ps=new $e,Wf=new $e,ka=[],Zf=new Gt,lS=new $e,ao=new Mt,co=new An;class Ls extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ar(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,lS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ps),Zf.copy(e.boundingBox).applyMatrix4(ps),this.boundingBox.union(Zf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new An;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ps),co.copy(e.boundingSphere).applyMatrix4(ps),this.boundingSphere.union(co)}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(ao.geometry=this.geometry,ao.material=this.material,ao.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(co.copy(this.boundingSphere),co.applyMatrix4(n),e.ray.intersectsSphere(co)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,ps),Wf.multiplyMatrices(n,ps),ao.matrixWorld=Wf,ao.raycast(e,ka);for(let s=0,o=ka.length;s<o;s++){let a=ka[s];a.instanceId=r,a.object=this,t.push(a)}ka.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ar(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 Lr=new An,uS=new De(0.5,0.5),Ba=new U;class To{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,r=new Fn,s=new Fn){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],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,d-l,p-f,y-g).normalize(),i[1].setComponents(c+s,d+l,p+f,y+g).normalize(),i[2].setComponents(c+o,d+u,p+m,y+S).normalize(),i[3].setComponents(c-o,d-u,p-m,y-S).normalize(),n)i[4].setComponents(a,h,_,T).normalize(),i[5].setComponents(c-a,d-h,p-_,y-T).normalize();else if(i[4].setComponents(c-a,d-h,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,y+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();Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){Lr.center.set(0,0,0);let t=uS.distanceTo(e.center);return Lr.radius=0.7071067811865476+t,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}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(Ba.x=i.normal.x>0?e.max.x:e.min.x,Ba.y=i.normal.y>0?e.max.y:e.min.y,Ba.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ba)<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 Ro extends yn{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 ja=new U,qa=new U,Xf=new $e,lo=new fr,Va=new An,Wl=new U,jf=new U;class pr extends gt{constructor(e=new on,t=new Ro){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++)ja.fromBufferAttribute(t,i-1),qa.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ja.distanceTo(qa);e.setAttribute("lineDistance",new xn(n,1))}else Le("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(Va.copy(n.boundingSphere),Va.applyMatrix4(i),Va.radius+=r,e.ray.intersectsSphere(Va)===!1)return;Xf.copy(i).invert(),lo.copy(e.ray).applyMatrix4(Xf);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),S=Ga(this,e,lo,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=Ga(this,e,lo,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=Ga(this,e,lo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ga(this,e,lo,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 Ga(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ja.fromBufferAttribute(a,r),qa.fromBufferAttribute(a,s),n.distanceSqToSegment(ja,qa,Wl,jf)>i)return;Wl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Wl);if(l<t.near||l>t.far)return;return{distance:l,point:jf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var qf=new U,Yf=new U;class pc extends pr{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)qf.fromBufferAttribute(t,i),Yf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+qf.distanceTo(Yf);e.setAttribute("lineDistance",new xn(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mc extends pr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Co extends yn{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 Jf=new $e,jl=new fr,Ha=new An,$a=new U;class Ns extends gt{constructor(e=new on,t=new Co){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;Jf.copy(i).invert(),jl.copy(e.ray).applyMatrix4(Jf);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);$a.fromBufferAttribute(u,_),Kf($a,_,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++)$a.fromBufferAttribute(u,f),Kf($a,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 Kf(e,t,n,i,r,s,o){let a=jl.distanceSqToPoint(e);if(a<n){let c=new U;jl.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 gc extends Nt{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 Vr extends Nt{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 bo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Ku extends Vr{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 _c extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class mr extends on{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 xn(c,3)),this.setAttribute("normal",new xn(l,3)),this.setAttribute("uv",new xn(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,z=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let k=0;k<G;k++){let q=k*z-L;for(let ee=0;ee<I;ee++){let Se=ee*M-C;j[m]=Se*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(ee/A),u.push(1-k/R),X+=1}}for(let k=0;k<R;k++)for(let q=0;q<A;q++){let ee=h+q+I*k,Se=h+q+I*(k+1),ue=h+(q+1)+I*(k+1),Be=h+(q+1)+I*k;a.push(ee,Se,Be),a.push(Se,ue,Be),P+=6}o.addGroup(d,P,x),d+=P,h+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Po extends on{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 S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;d.push(S,T,w),d.push(T,y,w)}this.setIndex(d),this.setAttribute("position",new xn(f,3)),this.setAttribute("normal",new xn(m,3)),this.setAttribute("uv",new xn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Po(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(Qf(r))if(r.isRenderTargetTexture)Le("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(Qf(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 an(e){let t={};for(let n=0;n<e.length;n++){let i=Gr(e[n]);for(let r in i)t[r]=i[r]}return t}function Qf(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function hS(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Qu(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var om={clone:Gr,merge:an},dS=`void main() {
+ var lp="186",cr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},up=0,Yl=1,hp=2;var go=1,dp=2,Ms=3,ur=0,sn=1,kn=2,di=0,_o=1,Jl=2,Kl=3,Ql=4,fp=5;var ws=100,pp=101,mp=102,gp=103,_p=104,xp=200,yp=201,vp=202,bp=203,Sp=204,Mp=205,wp=206,Ep=207,Ap=208,Tp=209,Rp=210,Cp=211,Pp=212,Ip=213,Lp=214,Np=0,Dp=1,Op=2,eu=3,Up=4,Fp=5,zp=6,kp=7,Bp=0,Vp=1,Gp=2,Jn=0,tu=1,nu=2,iu=3,xo=4,ru=5,su=6,ou=7;var Es=301,Or=302,Ya=303,Ja=304,yo=306,As=1000,Ts=1001,Ka=1002,Kn=1003,Qa=1004;var Ur=1005;var qt=1006,Rs=1007;var fi=1008;var Qn=1009,Hp=1010,$p=1011,vo=1012,au=1013,hr=1014,Gi=1015,pi=1016,cu=1017,lu=1018,Cs=1020,Wp=35902,Zp=35899,Xp=1021,jp=1022,mi=1023,Fr=1026,zr=1027,qp=1028,uu=1029,kr=1030,hu=1031;var du=1033,ec=33776,tc=33777,nc=33778,ic=33779,fu=35840,pu=35841,mu=35842,gu=35843,_u=36196,xu=37492,yu=37496,vu=37488,bu=37489,rc=37490,Su=37491,Mu=37808,wu=37809,Eu=37810,Au=37811,Tu=37812,Ru=37813,Cu=37814,Pu=37815,Iu=37816,Lu=37817,Nu=37818,Du=37819,Ou=37820,Uu=37821,Fu=36492,zu=36494,ku=36495,Bu=36283,Vu=36284,sc=36285,Gu=36286;var Hu=2300,oc=2301;var $u=0,bo=1,Ps=2;var Wu=0,Yp=1,Br="",dr="srgb",Mn="srgb-linear",Zu="linear",yt="srgb";var Jp=512,Kp=513,Qp=514,ac=515,em=516,tm=517,cc=518,nm=519;var Xu="300 es",ju=2000;function Lb(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Nb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vs(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function im(){let e=vs("canvas");return e.style.display="block",e}var Af={},bs=null;function mo(...e){let t="THREE."+e.shift();if(bs)bs("log",t,...e);else console.log(t,...e)}function rm(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 Le(...e){e=rm(e);let t="THREE."+e.shift();if(bs)bs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function ke(...e){e=rm(e);let t="THREE."+e.shift();if(bs)bs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Nr(...e){let t=e.join(" ");if(t in Af)return;Af[t]=!0,Le(...e)}function sm(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 om={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ei{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 nn=["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"],Tf=1234567,fo=Math.PI/180,Dr=180/Math.PI;function Yn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(nn[e&255]+nn[e>>8&255]+nn[e>>16&255]+nn[e>>24&255]+"-"+nn[t&255]+nn[t>>8&255]+"-"+nn[t>>16&15|64]+nn[t>>24&255]+"-"+nn[n&63|128]+nn[n>>8&255]+"-"+nn[n>>16&255]+nn[n>>24&255]+nn[i&255]+nn[i>>8&255]+nn[i>>16&255]+nn[i>>24&255]).toLowerCase()}function qe(e,t,n){return Math.max(t,Math.min(n,e))}function qu(e,t){return(e%t+t)%t}function Db(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Ob(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function po(e,t,n){return(1-n)*e+n*t}function Ub(e,t,n,i){return po(e,t,1-Math.exp(-n*i))}function Fb(e,t=1){return t-Math.abs(qu(e,t*2)-t)}function zb(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 kb(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 Bb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Vb(e,t){return e+Math.random()*(t-e)}function Gb(e){return e*(0.5-Math.random())}function Hb(e){if(e!==void 0)Tf=e;let t=Tf+=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 $b(e){return e*fo}function Wb(e){return e*Dr}function Zb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Xb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function jb(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function qb(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),d=s((t-i)/2),h=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*d,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*d,a*l);break;case"ZXZ":e.set(c*d,c*h,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:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qn(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 dt(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 So={DEG2RAD:fo,RAD2DEG:Dr,generateUUID:Yn,clamp:qe,euclideanModulo:qu,mapLinear:Db,inverseLerp:Ob,lerp:po,damp:Ub,pingpong:Fb,smoothstep:zb,smootherstep:kb,randInt:Bb,randFloat:Vb,randFloatSpread:Gb,seededRandom:Hb,degToRad:$b,radToDeg:Wb,isPowerOfTwo:Zb,ceilPowerOfTwo:Xb,floorPowerOfTwo:jb,setQuaternionFromProperEuler:qb,normalize:dt,denormalize:qn};class Ue{static{Ue.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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(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(qe(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 Xt{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],d=r[s+0],h=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==d||c!==h||l!==f){let _=a*d+c*h+l*f+u*m;if(_<0)d=-d,h=-h,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+d*o,c=c*p+h*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],d=r[s+1],h=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*h-c*d,e[t+1]=a*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-a*u,e[t+3]=l*f-o*u-a*d-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),d=a(n/2),h=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:Le("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],d=n+o+u;if(d>0){let h=0.5/Math.sqrt(d+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(qe(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 U{static{U.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(Rf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Rf.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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(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 El.copy(this).projectOnVector(e),this.sub(El)}reflect(e){return this.sub(El.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(qe(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 El=new U,Rf=new Xt;class Ve{static{Ve.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],d=n[2],h=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=d*m+h*g+f*y,r[5]=d*_+h*S+f*w,r[8]=d*p+h*T+f*A,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,d=o*a-l*r,h=c*r-s*a,f=t*u+n*d+i*h;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]=d*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=h*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 Nr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Al.makeScale(e,t)),this}rotate(e){return Nr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Al.makeRotation(-e)),this}translate(e,t){return Nr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Al.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 Al=new Ve,Cf=new Ve().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Pf=new Ve().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Yb(){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=ys(r.r),r.g=ys(r.g),r.b=ys(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 Nr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Nr("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:Cf,fromXYZ:Pf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Cf,fromXYZ:Pf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Yb();function Vi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ys(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ss;class Yu{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(ss===void 0)ss=vs("canvas");ss.width=e.width,ss.height=e.height;let i=ss.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ss}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=vs("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 Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Jb=0;class Mo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Jb++}),this.uuid=Yn(),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(Tl(i[s].image));else r.push(Tl(i[s]))}else r=Tl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Tl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Yu.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 Le("Texture: Unable to serialize Texture."),{}}var Kb=0,Rl=new U;class Nt extends ei{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Kb++}),this.uuid=Yn(),this.name="",this.source=new Mo(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 Ue(0,0),this.repeat=new Ue(1,1),this.center=new Ue(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,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(Rl).x}get height(){return this.source.getSize(Rl).y}get depth(){return this.source.getSize(Rl).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){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`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++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class ft{static{ft.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],d=a[1],h=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-d)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let S=(c+1)/2,T=(h+1)/2,y=(p+1)/2,w=(l+d)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(d-l)*(d-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(d-l)/g,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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(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 Ju extends ei{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 ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(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 Mo(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 wn extends Ju{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class lc extends Nt{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 Ku extends Nt{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 $e{static{$e.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,d,h,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,d,h,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,d,h,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]=d,p[3]=h,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 $e().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/os.setFromMatrixColumn(e,0).length(),r=1/os.setFromMatrixColumn(e,1).length(),s=1/os.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 d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+f*c,t[5]=d-m*c,t[9]=-o*a,t[2]=m-d*c,t[6]=f+h*c,t[10]=s*a}else if(e.order==="YXZ"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d+m*o,t[4]=f*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-f,t[6]=m+d*o,t[10]=s*a}else if(e.order==="ZXY"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d-m*o,t[4]=-s*u,t[8]=f+h*o,t[1]=h+f*o,t[5]=s*l,t[9]=m-d*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-h,t[8]=d*c+m,t[1]=a*u,t[5]=m*c+d,t[9]=h*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-d*u,t[8]=f*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+f,t[10]=d-m*u}else if(e.order==="XZY"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=d*u+m,t[5]=s*l,t[9]=h*u-f,t[2]=f*u-h,t[6]=o*l,t[10]=m*u+d}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(Qb,e,eS)}lookAt(e,t,n){let i=this.elements;if(bn.subVectors(e,t),bn.lengthSq()===0)bn.z=1;if(bn.normalize(),tr.crossVectors(n,bn),tr.lengthSq()===0){if(Math.abs(n.z)===1)bn.x+=0.0001;else bn.z+=0.0001;bn.normalize(),tr.crossVectors(n,bn)}return tr.normalize(),Sa.crossVectors(bn,tr),i[0]=tr.x,i[4]=Sa.x,i[8]=bn.x,i[1]=tr.y,i[5]=Sa.y,i[9]=bn.y,i[2]=tr.z,i[6]=Sa.z,i[10]=bn.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],d=n[9],h=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],z=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],k=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*z+a*I+c*j,r[8]=s*R+o*C+a*G+c*k,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+d*K+h*P,r[5]=l*A+u*z+d*I+h*j,r[9]=l*R+u*C+d*G+h*k,r[13]=l*x+u*L+d*X+h*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*z+_*I+p*j,r[10]=f*R+m*C+_*G+p*k,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*z+T*I+y*j,r[11]=g*R+S*C+T*G+y*k,r[15]=g*x+S*L+T*X+y*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],d=e[10],h=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*h-c*d,S=o*h-c*u,T=o*d-a*u,y=s*h-c*l,w=s*d-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}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],d=e[10],h=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-d*f,M=l*p-h*f,z=u*_-d*m,C=u*p-h*m,L=d*p-h*_,K=g*L-S*C+T*z+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*z)*I,e[1]=(i*C-n*L-r*z)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(d*w-u*A-h*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-d*T+h*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-h*g)*I,e[12]=(o*x-s*z-a*R)*I,e[13]=(t*z-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+d*g)*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,d=r*c,h=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(h+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(h-T)*w,i[5]=(1-(d+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(d+m))*A,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=os.set(i[0],i[1],i[2]).length(),o=os.set(i[4],i[5],i[6]).length(),a=os.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Zn.copy(this);let c=1/s,l=1/o,u=1/a;return Zn.elements[0]*=c,Zn.elements[1]*=c,Zn.elements[2]*=c,Zn.elements[4]*=l,Zn.elements[5]*=l,Zn.elements[6]*=l,Zn.elements[8]*=u,Zn.elements[9]*=u,Zn.elements[10]*=u,t.setFromRotationMatrix(Zn),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),d=(t+e)/(t-e),h=(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]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,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),d=-(t+e)/(t-e),h=-(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]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=h,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 os=new U,Zn=new $e,Qb=new U(0,0,0),eS=new U(1,1,1),tr=new U,Sa=new U,bn=new U,If=new $e,Lf=new Xt;class hi{constructor(e=0,t=0,n=0,i=hi.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],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(qe(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(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-qe(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(qe(d,-1,1)),Math.abs(d)<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(-qe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,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(qe(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(-qe(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return If.makeRotationFromQuaternion(e),this.setFromRotationMatrix(If,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Lf.setFromEuler(this),this.setFromQuaternion(Lf,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}}hi.DEFAULT_ORDER="XYZ";class uc{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 tS=0,Nf=new U,as=new Xt,Oi=new $e,Ma=new U,ro=new U,nS=new U,iS=new Xt,Df=new U(1,0,0),Of=new U(0,1,0),Uf=new U(0,0,1),Ff={type:"added"},rS={type:"removed"},cs={type:"childadded",child:null},Cl={type:"childremoved",child:null};class gt extends ei{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:tS++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let e=new U,t=new hi,n=new Xt,i=new U(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 $e},normalMatrix:{value:new Ve}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uc,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 as.setFromAxisAngle(e,t),this.quaternion.multiply(as),this}rotateOnWorldAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.premultiply(as),this}rotateX(e){return this.rotateOnAxis(Df,e)}rotateY(e){return this.rotateOnAxis(Of,e)}rotateZ(e){return this.rotateOnAxis(Uf,e)}translateOnAxis(e,t){return Nf.copy(e).applyQuaternion(this.quaternion),this.position.add(Nf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Df,e)}translateY(e){return this.translateOnAxis(Of,e)}translateZ(e){return this.translateOnAxis(Uf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Oi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Ma.copy(e);else Ma.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Oi.lookAt(ro,Ma,this.up);else Oi.lookAt(Ma,ro,this.up);if(this.quaternion.setFromRotationMatrix(Oi),i)Oi.extractRotation(i.matrixWorld),as.setFromRotationMatrix(Oi),this.quaternion.premultiply(as.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 ke("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(Ff),cs.child=e,this.dispatchEvent(cs),cs.child=null;else ke("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(rS),Cl.child=e,this.dispatchEvent(Cl),Cl.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),Oi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Oi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Oi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ff),cs.child=e,this.dispatchEvent(cs),cs.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,nS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ro,iS,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),d=s(e.skeletons),h=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(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;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"})}}gt.DEFAULT_UP=new U(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class li extends gt{constructor(){super();this.isGroup=!0,this.type="Group"}}var sS={type:"move"};class wo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new li,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 li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,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"],d=l.position.distanceTo(u.position),h=0.02,f=0.005;if(c.inputState.pinching&&d>h+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=h-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(sS)}}}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 li;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var am={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},nr={h:0,s:0,l:0},wa={h:0,s:0,l:0};function Pl(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 ze{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,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=qu(e,1),t=qe(t,0,1),n=qe(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=Pl(s,r,e+0.3333333333333333),this.g=Pl(s,r,e),this.b=Pl(s,r,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("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:Le("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 Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=am[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("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=ys(e.r),this.g=ys(e.g),this.b=ys(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(rn.copy(this),e),Math.round(qe(rn.r*255,0,255))*65536+Math.round(qe(rn.g*255,0,255))*256+Math.round(qe(rn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(rn.copy(this),t);let{r:n,g:i,b:r}=rn,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=je.workingColorSpace){return je.workingToColorSpace(rn.copy(this),t),e.r=rn.r,e.g=rn.g,e.b=rn.b,e}getStyle(e="srgb"){je.workingToColorSpace(rn.copy(this),e);let{r:t,g:n,b:i}=rn;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(nr),this.setHSL(nr.h+e,nr.s+t,nr.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(nr),e.getHSL(wa);let n=po(nr.h,wa.h,t),i=po(nr.s,wa.s,t),r=po(nr.l,wa.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 rn=new ze;ze.NAMES=am;class Is extends gt{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 hi,this.environmentIntensity=1,this.environmentRotation=new hi,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 Xn=new U,Ui=new U,Il=new U,Fi=new U,ls=new U,us=new U,zf=new U,Ll=new U,Nl=new U,Dl=new U,Ol=new ft,Ul=new ft,Fl=new ft;class zn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Xn.subVectors(e,t),i.cross(Xn);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){Xn.subVectors(i,t),Ui.subVectors(n,t),Il.subVectors(e,t);let s=Xn.dot(Xn),o=Xn.dot(Ui),a=Xn.dot(Il),c=Ui.dot(Ui),l=Ui.dot(Il),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,h=(c*a-o*l)*d,f=(s*l-o*a)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Fi)===null)return!1;return Fi.x>=0&&Fi.y>=0&&Fi.x+Fi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Fi)===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,Fi.x),a.addScaledVector(s,Fi.y),a.addScaledVector(o,Fi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Ol.setScalar(0),Ul.setScalar(0),Fl.setScalar(0),Ol.fromBufferAttribute(e,t),Ul.fromBufferAttribute(e,n),Fl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Ol,r.x),s.addScaledVector(Ul,r.y),s.addScaledVector(Fl,r.z),s}static isFrontFacing(e,t,n,i){return Xn.subVectors(n,t),Ui.subVectors(e,t),Xn.cross(Ui).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 Xn.subVectors(this.c,this.b),Ui.subVectors(this.a,this.b),Xn.cross(Ui).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.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;ls.subVectors(i,n),us.subVectors(r,n),Ll.subVectors(e,n);let a=ls.dot(Ll),c=us.dot(Ll);if(a<=0&&c<=0)return t.copy(n);Nl.subVectors(e,i);let l=ls.dot(Nl),u=us.dot(Nl);if(l>=0&&u<=l)return t.copy(i);let d=a*u-l*c;if(d<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ls,s);Dl.subVectors(e,r);let h=ls.dot(Dl),f=us.dot(Dl);if(f>=0&&h<=f)return t.copy(r);let m=h*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(us,o);let _=l*f-h*u;if(_<=0&&u-l>=0&&h-f>=0)return zf.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(zf,o);let p=1/(_+m+d);return s=m*p,o=d*p,t.copy(n).addScaledVector(ls,s).addScaledVector(us,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-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(jn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(jn.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=jn.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,jn);else jn.fromBufferAttribute(r,s);jn.applyMatrix4(e.matrixWorld),this.expandByPoint(jn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Ea.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Ea.copy(n.boundingBox)}Ea.applyMatrix4(e.matrixWorld),this.union(Ea)}}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,jn),jn.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(so),Aa.subVectors(this.max,so),hs.subVectors(e.a,so),ds.subVectors(e.b,so),fs.subVectors(e.c,so),ir.subVectors(ds,hs),rr.subVectors(fs,ds),Cr.subVectors(hs,fs);let t=[0,-ir.z,ir.y,0,-rr.z,rr.y,0,-Cr.z,Cr.y,ir.z,0,-ir.x,rr.z,0,-rr.x,Cr.z,0,-Cr.x,-ir.y,ir.x,0,-rr.y,rr.x,0,-Cr.y,Cr.x,0];if(!zl(t,hs,ds,fs,Aa))return!1;if(t=[1,0,0,0,1,0,0,0,1],!zl(t,hs,ds,fs,Aa))return!1;return Ta.crossVectors(ir,rr),t=[Ta.x,Ta.y,Ta.z],zl(t,hs,ds,fs,Aa)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(jn).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 zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zi),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 zi=[new U,new U,new U,new U,new U,new U,new U,new U],jn=new U,Ea=new Gt,hs=new U,ds=new U,fs=new U,ir=new U,rr=new U,Cr=new U,so=new U,Aa=new U,Ta=new U,Pr=new U;function zl(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 zt=new U,Ra=new Ue,oS=0;class jt extends ei{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:oS++}),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++)Ra.fromBufferAttribute(this,t),Ra.applyMatrix3(e),this.setXY(t,Ra.x,Ra.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.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=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(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=qn(t,this.array);return t}setX(e,t){if(this.normalized)t=dt(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=qn(t,this.array);return t}setY(e,t){if(this.normalized)t=dt(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=qn(t,this.array);return t}setZ(e,t){if(this.normalized)t=dt(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=qn(t,this.array);return t}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(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 hc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class dc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class xn extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var aS=new Gt,oo=new U,kl=new U;class En{constructor(e=new U,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 aS.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;oo.subVectors(e,this.center);let t=oo.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(oo,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 kl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oo.copy(e.center).add(kl)),this.expandByPoint(oo.copy(e.center).sub(kl));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 cS=0,Un=new $e,Bl=new gt,ps=new U,Sn=new Gt,ao=new Gt,Zt=new U;class on extends ei{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cS++}),this.uuid=Yn(),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((Lb(e))?dc:hc)(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 Ve().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 Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return Bl.lookAt(e),Bl.updateMatrix(),this.applyMatrix4(Bl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ps).negate(),this.translate(ps.x,ps.y,ps.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 xn(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)Le("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 Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(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(Sn.setFromBufferAttribute(r),this.morphTargetsRelative)Zt.addVectors(this.boundingBox.min,Sn.min),this.boundingBox.expandByPoint(Zt),Zt.addVectors(this.boundingBox.max,Sn.max),this.boundingBox.expandByPoint(Zt);else this.boundingBox.expandByPoint(Sn.min),this.boundingBox.expandByPoint(Sn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))ke('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 En;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(Sn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(ao.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(Sn.min,ao.min),Sn.expandByPoint(Zt),Zt.addVectors(Sn.max,ao.max),Sn.expandByPoint(Zt);else Sn.expandByPoint(ao.min),Sn.expandByPoint(ao.max)}Sn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Zt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zt));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(Zt.fromBufferAttribute(o,c),a)ps.fromBufferAttribute(e,c),Zt.add(ps);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))ke('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){ke("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 jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,d=new Ue,h=new Ue,f=new Ue,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(d),f.sub(d);let z=1/(h.x*f.y-f.x*h.y);if(!isFinite(z))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-h.y).multiplyScalar(z),_.copy(u).multiplyScalar(h.x).addScaledVector(l,-f.x).multiplyScalar(z),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].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 M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let z=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,z)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+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 jt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;if(e)for(let d=0,h=e.count;d<h;d+=3){let f=e.getX(d+0),m=e.getX(d+1),_=e.getX(d+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 d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+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++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,d=new c.constructor(a.length*l),h=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)h=a[m]*o.data.stride+o.offset;else h=a[m]*l;for(let p=0;p<l;p++)d[f++]=c[h++]}return new jt(d,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new on,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 d=c[l],h=e(d,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,d=c.length;u<d;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 d=0,h=u.length;d<h;d++)l.push(u[d].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 Eo{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=Yn()}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=Yn();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=Yn();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 hn=new U;class Ls{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++)hn.fromBufferAttribute(this,t),hn.applyMatrix4(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyNormalMatrix(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.transformDirection(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=dt(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=qn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=qn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=qn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=qn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(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=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(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){mo("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 jt(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 Ls(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){mo("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 Vl=new U,lS=new U,uS=new Ve;class Fn{constructor(e=new U(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=Vl.subVectors(n,t).cross(lS.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(Vl),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||uS.getNormalMatrix(e),i=this.coplanarPoint(Vl).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 hS=0;class yn extends ei{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:hS++}),this.uuid=Yn(),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 ze(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){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`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 ze().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 Fn().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 Ue().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 Ue().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 ki=new U,Gl=new U,Ca=new U,Pa=new U;class fr{constructor(e=new U,t=new U(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,ki)),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=ki.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return ki.copy(this.origin).addScaledVector(this.direction,t),ki.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Gl.copy(e).add(t).multiplyScalar(0.5),Ca.copy(t).sub(e).normalize(),Pa.copy(this.origin).sub(Gl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ca),o=Pa.dot(this.direction),a=-Pa.dot(Ca),c=Pa.lengthSq(),l=Math.abs(1-s*s),u,d,h,f;if(l>0)if(u=s*a-o,d=s*o-a,f=r*l,u>=0)if(d>=-f)if(d<=f){let m=1/l;u*=m,d*=m,h=u*(u+s*d+2*o)+d*(s*u+d+2*a)+c}else d=r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else d=-r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else if(d<=-f)u=Math.max(0,-(-s*r+o)),d=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else if(d<=f)u=0,d=Math.min(Math.max(-r,-a),r),h=d*(d+2*a)+c;else u=Math.max(0,-(s*r+o)),d=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Gl).addScaledVector(Ca,d);return h}intersectSphere(e,t){if(e.radius<0)return null;ki.subVectors(e.center,this.origin);let n=ki.dot(this.direction),i=ki.dot(ki)-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,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.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-d.z)*u,a=(e.max.z-d.z)*u;else o=(e.max.z-d.z)*u,a=(e.min.z-d.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,ki)!==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,d=e.y-s.y,h=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,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,z,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=d,z=h,L=m,K=_,G=g,X=S;else A=l,R=c,M=h,z=d,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=d,I=m,P=g,c>=0)A=l,R=a,M=h,z=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,z=h,L=f,K=_,G=p,X=S;else if(x=l,C=h,I=_,P=S,l>=0)A=a,R=c,M=u,z=d,L=f,K=m,G=p,X=g;else A=c,R=a,M=d,z=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,k=R/x,q=1/x,Q=M-j*C,Me=z-k*C,ue=L-j*I,Be=K-k*I,we=G-j*P,Z=X-k*P,re=we*Be-Z*ue,se=Q*Z-Me*we,xe=ue*Me-Be*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 Ee=re+se+xe;if(Ee===0)return null;let Ae=q*(re*C+se*I+xe*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,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 gi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 hi,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 kf=new $e,Ir=new fr,Ia=new En,Bf=new U,La=new U,Na=new U,Da=new U,Hl=new U,Oa=new U,Vf=new U,Ua=new U;class Mt extends gt{constructor(e=new on,t=new gi){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){Oa.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(Hl.fromBufferAttribute(u,e),s)Oa.addScaledVector(Hl,l);else Oa.addScaledVector(Hl.sub(t),l)}t.add(Oa)}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(Ia.copy(n.boundingSphere),Ia.applyMatrix4(r),Ir.copy(e.ray).recast(e.near),Ia.containsPoint(Ir.origin)===!1){if(Ir.intersectSphere(Ia,Bf)===null)return;if(Ir.origin.distanceToSquared(Bf)>(e.far-e.near)**2)return}if(kf.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(kf),n.boundingBox!==null){if(Ir.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ir)}_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:d,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(o.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=Fa(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(o.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(a.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=Fa(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(a.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=_,S=_+1,T=_+2;if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function dS(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;Ua.copy(a),Ua.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ua);if(l<n.near||l>n.far)return null;return{distance:l,point:Ua.clone(),object:e}}function Fa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,La),e.getVertexPosition(c,Na),e.getVertexPosition(l,Da);let u=dS(e,t,n,i,La,Na,Da,Vf);if(u){let d=new U;if(zn.getBarycoord(Vf,La,Na,Da,d),r)u.uv=zn.getInterpolatedAttribute(r,a,c,l,d,new Ue);if(s)u.uv1=zn.getInterpolatedAttribute(s,a,c,l,d,new Ue);if(o){if(u.normal=zn.getInterpolatedAttribute(o,a,c,l,d,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};zn.getNormal(La,Na,Da,h.normal),u.face=h,u.barycoord=d}return u}var co=new ft,Gf=new ft,Hf=new ft,fS=new ft,$f=new $e,za=new U,$l=new En,Wf=new $e,Wl=new fr;class fc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingBox.expandByPoint(za)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new En;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingSphere.expandByPoint(za)}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($l.copy(this.boundingSphere),$l.applyMatrix4(i),e.ray.intersectsSphere($l)===!1)return;if(Wf.copy(i).invert(),Wl.copy(e.ray).applyMatrix4(Wf),this.boundingBox!==null){if(Wl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Wl)}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 ft,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 Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Gf.fromBufferAttribute(i.attributes.skinIndex,e),Hf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)co.copy(t),t.set(0,0,0,0);else co.set(...t,1),t.set(0,0,0);co.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Hf.getComponent(r);if(s!==0){let o=Gf.getComponent(r);$f.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(fS.copy(co).applyMatrix4($f),s)}}if(t.isVector4)t.w=co.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Ao extends gt{constructor(){super();this.isBone=!0,this.type="Bone"}}class To extends Nt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,d){super(null,s,o,a,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var Zf=new $e,pS=new $e;class Ro{constructor(e=[],t=[]){this.uuid=Yn(),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){Le("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 $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new $e;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:pS;Zf.multiplyMatrices(o,t[r]),Zf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ro(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 To(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)Le("Skeleton: No bone found with UUID:",r),s=new Ao;this.bones.push(s),this.boneInverses.push(new $e().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 ar extends jt{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 ms=new $e,Xf=new $e,ka=[],jf=new Gt,mS=new $e,lo=new Mt,uo=new En;class Ns extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ar(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,mS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),jf.copy(e.boundingBox).applyMatrix4(ms),this.boundingBox.union(jf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new En;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),uo.copy(e.boundingSphere).applyMatrix4(ms),this.boundingSphere.union(uo)}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(lo.geometry=this.geometry,lo.material=this.material,lo.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(uo.copy(this.boundingSphere),uo.applyMatrix4(n),e.ray.intersectsSphere(uo)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,ms),Xf.multiplyMatrices(n,ms),lo.matrixWorld=Xf,lo.raycast(e,ka);for(let s=0,o=ka.length;s<o;s++){let a=ka[s];a.instanceId=r,a.object=this,t.push(a)}ka.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ar(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 To(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 Lr=new En,gS=new Ue(0.5,0.5),Ba=new U;class Co{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,r=new Fn,s=new Fn){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],d=r[6],h=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,h-l,p-f,y-g).normalize(),i[1].setComponents(c+s,h+l,p+f,y+g).normalize(),i[2].setComponents(c+o,h+u,p+m,y+S).normalize(),i[3].setComponents(c-o,h-u,p-m,y-S).normalize(),n)i[4].setComponents(a,d,_,T).normalize(),i[5].setComponents(c-a,h-d,p-_,y-T).normalize();else if(i[4].setComponents(c-a,h-d,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,h+d,p+_,y+T).normalize();else if(t===2001)i[5].setComponents(a,d,_,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();Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){Lr.center.set(0,0,0);let t=gS.distanceTo(e.center);return Lr.radius=0.7071067811865476+t,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}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(Ba.x=i.normal.x>0?e.max.x:e.min.x,Ba.y=i.normal.y>0?e.max.y:e.min.y,Ba.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ba)<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 Po extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(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 ja=new U,qa=new U,qf=new $e,ho=new fr,Va=new En,Zl=new U,Yf=new U;class pr extends gt{constructor(e=new on,t=new Po){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++)ja.fromBufferAttribute(t,i-1),qa.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ja.distanceTo(qa);e.setAttribute("lineDistance",new xn(n,1))}else Le("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(Va.copy(n.boundingSphere),Va.applyMatrix4(i),Va.radius+=r,e.ray.intersectsSphere(Va)===!1)return;qf.copy(i).invert(),ho.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,d=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),S=Ga(this,e,ho,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(h),p=Ga(this,e,ho,a,m,_,f-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),f=Math.min(d.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=Ga(this,e,ho,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ga(this,e,ho,a,f-1,h,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 Ga(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ja.fromBufferAttribute(a,r),qa.fromBufferAttribute(a,s),n.distanceSqToSegment(ja,qa,Zl,Yf)>i)return;Zl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Zl);if(l<t.near||l>t.far)return;return{distance:l,point:Yf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Jf=new U,Kf=new U;class pc extends pr{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)Jf.fromBufferAttribute(t,i),Kf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Jf.distanceTo(Kf);e.setAttribute("lineDistance",new xn(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mc extends pr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Io extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ze(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 Qf=new $e,ql=new fr,Ha=new En,$a=new U;class Ds extends gt{constructor(e=new on,t=new Io){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;Qf.copy(i).invert(),ql.copy(e.ray).applyMatrix4(Qf);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 d=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let f=d,m=h;f<m;f++){let _=c.getX(f);$a.fromBufferAttribute(u,_),ep($a,_,a,i,e,t,this)}}else{let d=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let f=d,m=h;f<m;f++)$a.fromBufferAttribute(u,f),ep($a,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 ep(e,t,n,i,r,s,o){let a=ql.distanceSqToPoint(e);if(a<n){let c=new U;ql.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 gc extends Nt{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 Vr extends Nt{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 d={width:e,height:t,depth:u};super(d,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 Mo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Qu extends Vr{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 _c extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class mr extends on{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=[],d=0,h=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 xn(c,3)),this.setAttribute("normal",new xn(l,3)),this.setAttribute("uv",new xn(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,z=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let k=0;k<G;k++){let q=k*z-L;for(let Q=0;Q<I;Q++){let Me=Q*M-C;j[m]=Me*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(Q/A),u.push(1-k/R),X+=1}}for(let k=0;k<R;k++)for(let q=0;q<A;q++){let Q=d+q+I*k,Me=d+q+I*(k+1),ue=d+(q+1)+I*(k+1),Be=d+(q+1)+I*k;a.push(Q,Me,Be),a.push(Me,ue,Be),P+=6}o.addGroup(h,P,x),h+=P,d+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Lo extends on{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,d=t/a,h=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*d-s;for(let S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;h.push(S,T,w),h.push(T,y,w)}this.setIndex(h),this.setAttribute("position",new xn(f,3)),this.setAttribute("normal",new xn(m,3)),this.setAttribute("uv",new xn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lo(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(tp(r))if(r.isRenderTargetTexture)Le("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(tp(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 an(e){let t={};for(let n=0;n<e.length;n++){let i=Gr(e[n]);for(let r in i)t[r]=i[r]}return t}function tp(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function _S(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function eh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var cm={clone:Gr,merge:an},xS=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,fS=`void main() {
+}`,yS=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Bn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=dS,this.fragmentShader=fS,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=Gr(e.uniforms),this.uniformsGroups=hS(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 De().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ve().fromArray(i.value);break;case"m4":this.uniforms[n].value=new $e().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 eh extends Bn{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 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 De(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 di,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 Tn 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 De(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(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 xc extends yn{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 De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new di,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 th 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 nh 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 or(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 Xa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function pS(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 ep(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 mS(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 ih 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,S=(-1-d)*_+(1.5+d)*m+0.5*f,T=d*_-d*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class yc 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 rh extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class sh 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],S=u[p+1],T=e*h+f*2,y=l[T],w=l[T+1],A=_S(n,t,g,y,i);r[f]=am(A,m,S,w,_)}return r}}function am(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 gS(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 _S(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=am(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=gS(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 Rn{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=or(t,this.TimeBufferType),this.values=or(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:or(e.times,Array),values:or(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Array),outTangents:or(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new rh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ih(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new sh(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 Le("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(Xa(this.settings))tp(this.settings.inTangents,e),tp(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)ze("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)ze("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)){ze("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){ze("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Tb(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){ze("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,Xa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function tp(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Rn.prototype.ValueTypeName="";Rn.prototype.TimeBufferType=Float32Array;Rn.prototype.ValueBufferType=Float32Array;Rn.prototype.DefaultInterpolation=2301;class gr extends Rn{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="bool";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=2300;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class vc extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}vc.prototype.ValueTypeName="color";class _r extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}_r.prototype.ValueTypeName="number";class oh 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)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class xr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new oh(this.times,this.values,this.getValueSize(),e)}}xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;class yr extends Rn{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="string";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}Hr.prototype.ValueTypeName="vector";class bs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Jn(),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(yS(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(Rn.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=pS(a);if(a=ep(a,1,l),c=ep(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new _r(".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 xS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return vc;case"quaternion":return xr;case"bool":case"boolean":return gr;case"string":return yr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function yS(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=xS(e.type);if(e.times===void 0){let i=[],r=[];mS(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(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Float32Array),outTangents:or(e.settings.outTangents,Float32Array)};return n}var hi={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(np(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(np(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function np(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Io{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 cm=new Io;class Zi{constructor(e){if(this.manager=e!==void 0?e:cm,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 Vi={};class lm extends Error{constructor(e,t){super(e);this.response=t}}class Lo 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=hi.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Vi[e]!==void 0){Vi[e].push({onLoad:t,onProgress:n,onError:i});return}Vi[e]=[],Vi[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)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Vi[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:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new lm(`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)=>{hi.add(`file:${e}`,c);let l=Vi[e];delete Vi[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=Vi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Vi[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 ms=new WeakMap;class ah 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=hi.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=ms.get(s);if(u===void 0)u=[],ms.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=ys("img");function a(){if(l(),t)t(this);let u=ms.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}ms.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);hi.remove(`image:${e}`);let h=ms.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}ms.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 hi.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Ds extends Zi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new ah(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 Os extends gt{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 bc extends Os{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.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 Zl=new $e,ip=new U,rp=new U;class No{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 De(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new To,this._frameExtents=new De(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ip.setFromMatrixPosition(e.matrixWorld),t.position.copy(ip),rp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rp),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Zl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Zl,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(Zl)}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 Wa=new U,Za=new Xt,li=new U;class Sc extends gt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,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(Wa,Za,li),li.x===1&&li.y===1&&li.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,li.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wa,Za,li),li.x===1&&li.y===1&&li.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,li.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var sr=new U,sp=new De,op=new De;class Vt extends Sc{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=Dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(uo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Dr*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){sr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,sp,op),t.subVectors(op,sp)}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 um extends No{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Dr*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 Mc extends Os{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(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new um}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 hm extends No{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Us extends Os{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 hm}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 $r extends Sc{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 dm extends No{constructor(){super(new $r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Fs extends Os{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new dm}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 vr{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 Xl=new WeakMap;class wc extends Zi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("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=hi.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Xl.has(s)===!0){if(i)i(Xl.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(hi.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Xl.set(a,c),hi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});hi.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var gs=-90,_s=1;class ch extends gt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(gs,_s,e,t);i.layers=this.layers,this.add(i);let r=new Vt(gs,_s,e,t);r.layers=this.layers,this.add(r);let s=new Vt(gs,_s,e,t);s.layers=this.layers,this.add(s);let o=new Vt(gs,_s,e,t);o.layers=this.layers,this.add(o);let a=new Vt(gs,_s,e,t);a.layers=this.layers,this.add(a);let c=new Vt(gs,_s,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 lh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class uh{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){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.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 hh="\\[\\]\\.:\\/",vS=new RegExp("["+hh+"]","g"),dh="[^"+hh+"]",bS="[^"+hh.replace("\\.","")+"]",SS=/((?:WC+[\/:])*)/.source.replace("WC",dh),MS=/(WCOD+)?/.source.replace("WCOD",bS),wS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dh),ES=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dh),AS=new RegExp("^"+SS+MS+wS+ES+"$"),TS=["material","materials","bones","map"];class fm{constructor(e,t,n){let i=n||ot.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 ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.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 ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(vS,"")}static parseTrackName(e){let t=AS.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(TS.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=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ze("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){ze("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){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ze("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){ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ze("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;ze("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){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ze("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}}ot.Composite=fm;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class fh{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 RS=new Float32Array(1);class Ec extends ti{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 uh(ot.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 yc(new Float32Array(2),new Float32Array(2),1,RS),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"?bs.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 fh(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"?bs.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 Do{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=qe(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(qe(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class ph{static{ph.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 Ac extends ti{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 mh(e,t,n,i){let r=CS(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 CS(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__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Om(){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 PS(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 IS=`#ifdef USE_ALPHAHASH
+}`;class Bn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xS,this.fragmentShader=yS,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=Gr(e.uniforms),this.uniformsGroups=_S(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 ze().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ue().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ve().fromArray(i.value);break;case"m4":this.uniforms[n].value=new $e().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 th extends Bn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Hi extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ze(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 ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(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 hi,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 An extends Hi{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 Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(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 ze(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 ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ze(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 xc extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,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 nh 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 ih 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 or(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 Xa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function vS(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 np(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 bS(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 $i{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 rh extends $i{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,d=this._weightPrev,h=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-d*_+2*d*m-d*f,g=(1+d)*_+(-1.5-2*d)*m+(-0.5+d)*f+1,S=(-1-h)*_+(1.5+h)*m+0.5*f,T=h*_-h*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class yc extends $i{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 d=0;d!==o;++d)r[d]=s[c+d]*u+s[a+d]*l;return r}}class sh extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class oh extends $i{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 d=o*2,h=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=h*d+f*2,g=u[p],S=u[p+1],T=e*d+f*2,y=l[T],w=l[T+1],A=MS(n,t,g,y,i);r[f]=lm(A,m,S,w,_)}return r}}function lm(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 SS(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 MS(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=lm(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=SS(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 Tn{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=or(t,this.TimeBufferType),this.values=or(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:or(e.times,Array),values:or(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Array),outTangents:or(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new sh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new rh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new oh(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 Le("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(Xa(this.settings))ip(this.settings.inTangents,e),ip(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)ke("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)ke("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)){ke("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){ke("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Nb(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){ke("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,d=u-n,h=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[d+f]||m!==t[h+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,d=s*n;for(let h=0;h!==n;++h)t[d+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,Xa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function ip(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Tn.prototype.ValueTypeName="";Tn.prototype.TimeBufferType=Float32Array;Tn.prototype.ValueBufferType=Float32Array;Tn.prototype.DefaultInterpolation=2301;class gr extends Tn{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="bool";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=2300;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class vc extends Tn{constructor(e,t,n,i){super(e,t,n,i)}}vc.prototype.ValueTypeName="color";class _r extends Tn{constructor(e,t,n,i){super(e,t,n,i)}}_r.prototype.ValueTypeName="number";class ah extends $i{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)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class xr extends Tn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new ah(this.times,this.values,this.getValueSize(),e)}}xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;class yr extends Tn{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="string";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends Tn{constructor(e,t,n,i){super(e,t,n,i)}}Hr.prototype.ValueTypeName="vector";class Ss{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Yn(),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(ES(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(Tn.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=vS(a);if(a=np(a,1,l),c=np(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new _r(".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],d=i[u];if(!d)i[u]=d=[];d.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 wS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return vc;case"quaternion":return xr;case"bool":case"boolean":return gr;case"string":return yr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function ES(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=wS(e.type);if(e.times===void 0){let i=[],r=[];bS(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(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Float32Array),outTangents:or(e.settings.outTangents,Float32Array)};return n}var ui={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(rp(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(rp(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function rp(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,d=c.length;u<d;u+=2){let h=c[u],f=c[u+1];if(h.global)h.lastIndex=0;if(h.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 um=new No;class Wi{constructor(e){if(this.manager=e!==void 0?e:um,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}}Wi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Bi={};class hm extends Error{constructor(e,t){super(e);this.response=t}}class Do extends Wi{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=ui.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Bi[e]!==void 0){Bi[e].push({onLoad:t,onProgress:n,onError:i});return}Bi[e]=[],Bi[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)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Bi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=d?parseInt(d):0,f=h!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:h});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new hm(`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),d=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(d);return c.arrayBuffer().then((f)=>h.decode(f))}}}).then((c)=>{ui.add(`file:${e}`,c);let l=Bi[e];delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Bi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Bi[e];for(let u=0,d=l.length;u<d;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 gs=new WeakMap;class ch extends Wi{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=ui.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=gs.get(s);if(u===void 0)u=[],gs.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=vs("img");function a(){if(l(),t)t(this);let u=gs.get(this)||[];for(let d=0;d<u.length;d++){let h=u[d];if(h.onLoad)h.onLoad(this)}gs.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ui.remove(`image:${e}`);let d=gs.get(this)||[];for(let h=0;h<d.length;h++){let f=d[h];if(f.onError)f.onError(u)}gs.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 ui.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Os extends Wi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new ch(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 Us extends gt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new ze(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 bc extends Us{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(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 Xl=new $e,sp=new U,op=new U;class Oo{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 Ue(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Co,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;sp.setFromMatrixPosition(e.matrixWorld),t.position.copy(sp),op.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(op),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Xl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Xl,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(Xl)}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 Wa=new U,Za=new Xt,ci=new U;class Sc extends gt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,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(Wa,Za,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,ci.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wa,Za,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,ci.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var sr=new U,ap=new Ue,cp=new Ue;class Vt extends Sc{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=Dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(fo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Dr*2*Math.atan(Math.tan(fo*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){sr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,ap,cp),t.subVectors(cp,ap)}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(fo*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 dm extends Oo{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Dr*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 Mc extends Us{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(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new dm}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 fm extends Oo{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Fs extends Us{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 fm}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 $r extends Sc{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 pm extends Oo{constructor(){super(new $r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class zs extends Us{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new pm}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 vr{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 jl=new WeakMap;class wc extends Wi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("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=ui.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(jl.has(s)===!0){if(i)i(jl.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(ui.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);jl.set(a,c),ui.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ui.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var _s=-90,xs=1;class lh extends gt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(_s,xs,e,t);i.layers=this.layers,this.add(i);let r=new Vt(_s,xs,e,t);r.layers=this.layers,this.add(r);let s=new Vt(_s,xs,e,t);s.layers=this.layers,this.add(s);let o=new Vt(_s,xs,e,t);o.layers=this.layers,this.add(o);let a=new Vt(_s,xs,e,t);a.layers=this.layers,this.add(a);let c=new Vt(_s,xs,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(),d=e.getActiveCubeFace(),h=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,d,h),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class uh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class hh{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){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.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 dh="\\[\\]\\.:\\/",AS=new RegExp("["+dh+"]","g"),fh="[^"+dh+"]",TS="[^"+dh.replace("\\.","")+"]",RS=/((?:WC+[\/:])*)/.source.replace("WC",fh),CS=/(WCOD+)?/.source.replace("WCOD",TS),PS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fh),IS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fh),LS=new RegExp("^"+RS+CS+PS+IS+"$"),NS=["material","materials","bones","map"];class mm{constructor(e,t,n){let i=n||ot.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 ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.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 ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(AS,"")}static parseTrackName(e){let t=LS.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(NS.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=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("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){ke("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){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("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){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ke("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;ke("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){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("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}}ot.Composite=mm;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ph{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 DS=new Float32Array(1);class Ec extends ei{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 d=i[u],h=d.name,f=l[h];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,h);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new hh(ot.create(n,h,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,h),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,d=(e._localRoot||this._root).uuid;if(delete u[d],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 yc(new Float32Array(2),new Float32Array(2),1,DS),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"?Ss.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 ph(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"?Ss.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 Uo{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=qe(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(qe(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class mh{static{mh.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 Ac extends ei{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 gh(e,t,n,i){let r=OS(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 OS(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__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Fm(){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 US(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,d=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),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:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,a),d.length===0)e.bufferSubData(l,0,u);else{d.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<d.length;f++){let m=d[h],_=d[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++h,d[h]=_}d.length=h+1;for(let f=0,m=d.length;f<m;f++){let _=d[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 FS=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,LS=`#ifdef USE_ALPHAHASH
+#endif`,zS=`#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`,NS=`#ifdef USE_ALPHAMAP
+#endif`,kS=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,DS=`#ifdef USE_ALPHAMAP
+#endif`,BS=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,OS=`#ifdef USE_ALPHATEST
+#endif`,VS=`#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`,US=`#ifdef USE_ALPHATEST
+#endif`,GS=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,FS=`#ifdef USE_AOMAP
+#endif`,HS=`#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`,zS=`#ifdef USE_AOMAP
+#endif`,$S=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,kS=`#ifdef USE_BATCHING
+#endif`,WS=`#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`,BS=`#ifdef USE_BATCHING
+#endif`,ZS=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,VS=`vec3 transformed = vec3( position );
+#endif`,XS=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,GS=`vec3 objectNormal = vec3( normal );
+#endif`,jS=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,HS=`float G_BlinnPhong_Implicit( ) {
+#endif`,qS=`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`,$S=`#ifdef USE_IRIDESCENCE
+} // validated`,YS=`#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`,WS=`#ifdef USE_BUMPMAP
+#endif`,JS=`#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`,ZS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,KS=`#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`,XS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,QS=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,jS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,eM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,qS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,tM=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,YS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,nM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,JS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,iM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,KS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,rM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,QS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,sM=`#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`,eM=`#define PI 3.141592653589793
+#endif`,oM=`#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`,tM=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,aM=`#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`,nM=`vec3 transformedNormal = objectNormal;
+#endif`,cM=`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`,iM=`#ifdef USE_DISPLACEMENTMAP
+#endif`,lM=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,rM=`#ifdef USE_DISPLACEMENTMAP
+#endif`,uM=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,sM=`#ifdef USE_EMISSIVEMAP
+#endif`,hM=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,oM=`#ifdef USE_EMISSIVEMAP
+#endif`,dM=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,aM="gl_FragColor = linearToOutputTexel( gl_FragColor );",cM=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,fM="gl_FragColor = linearToOutputTexel( gl_FragColor );",pM=`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 );
-}`,lM=`#ifdef USE_ENVMAP
+}`,mM=`#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`,uM=`#ifdef USE_ENVMAP
+#endif`,gM=`#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`,hM=`#ifdef USE_ENVMAP
+#endif`,_M=`#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`,dM=`#ifdef USE_ENVMAP
+#endif`,xM=`#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`,fM=`#ifdef USE_ENVMAP
+#endif`,yM=`#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`,pM=`#ifdef USE_FOG
+#endif`,vM=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,mM=`#ifdef USE_FOG
+#endif`,bM=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,gM=`#ifdef USE_FOG
+#endif`,SM=`#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`,_M=`#ifdef USE_FOG
+#endif`,MM=`#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`,xM=`#ifdef USE_GRADIENTMAP
+#endif`,wM=`#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
-}`,yM=`#ifdef USE_LIGHTMAP
+}`,EM=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,vM=`LambertMaterial material;
+#endif`,AM=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,bM=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,TM=`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`,SM=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,RM=`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>`,MM=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,CM=`#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`,wM=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,EM=`varying vec3 vViewPosition;
+#endif`,PM=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,IM=`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`,AM=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,LM=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,TM=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,NM=`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`,RM=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,DM=`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`,CM=`uniform sampler2D dfgLUT;
+#endif`,OM=`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 );
-}`,PM=`
+}`,UM=`
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`,IM=`#if defined( RE_IndirectDiffuse )
+#endif`,FM=`#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`,LM=`#if defined( RE_IndirectDiffuse )
+#endif`,zM=`#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`,NM=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,kM=`#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`,DM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,BM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,OM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,VM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,UM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,GM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,FM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,HM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,zM=`#ifdef USE_MAP
+#endif`,$M=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,kM=`#ifdef USE_MAP
+#endif`,WM=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,BM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,ZM=`#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`,VM=`#if defined( USE_POINTS_UV )
+#endif`,XM=`#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`,GM=`float metalnessFactor = metalness;
+#endif`,jM=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,HM=`#ifdef USE_METALNESSMAP
+#endif`,qM=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,$M=`#ifdef USE_INSTANCING_MORPH
+#endif`,YM=`#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`,WM=`#if defined( USE_MORPHCOLORS )
+#endif`,JM=`#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`,ZM=`#ifdef USE_MORPHNORMALS
+#endif`,KM=`#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`,XM=`#ifdef USE_MORPHTARGETS
+#endif`,QM=`#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`,jM=`#ifdef USE_MORPHTARGETS
+#endif`,ew=`#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`,qM=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,tw=`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;`,YM=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,nw=`#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;`,YM=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,JM=`#ifndef FLAT_SHADED
+#endif`,iw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,KM=`#ifndef FLAT_SHADED
+#endif`,rw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,QM=`#ifndef FLAT_SHADED
+#endif`,sw=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,YM=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,ew=`#ifdef USE_NORMALMAP
+#endif`,ow=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1843,13 +1843,13 @@ vec3 nonPerturbedNormal = normal;`,YM=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,tw=`#ifdef USE_CLEARCOAT
+#endif`,aw=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,nw=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,cw=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,iw=`#ifdef USE_CLEARCOATMAP
+#endif`,lw=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,YM=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,rw=`#ifdef USE_IRIDESCENCEMAP
+#endif`,uw=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,sw=`#ifdef OPAQUE
+#endif`,hw=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ow=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dw=`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
-}`,aw=`#ifdef PREMULTIPLIED_ALPHA
+}`,fw=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,cw=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,pw=`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;`,lw=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,uw=`#ifdef DITHERING
+#endif`,gw=`#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`,hw=`float roughnessFactor = roughness;
+#endif`,_w=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,dw=`#ifdef USE_ROUGHNESSMAP
+#endif`,xw=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,fw=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,yw=`#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;`,lw=`#ifdef DITHERING
}
#endif
#endif
-#endif`,pw=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,vw=`#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;`,lw=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,mw=`#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`,bw=`#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;`,lw=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,gw=`float getShadowMask() {
+#endif`,Sw=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,lw=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,_w=`#ifdef USE_SKINNING
+}`,Mw=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,xw=`#ifdef USE_SKINNING
+#endif`,ww=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,lw=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,yw=`#ifdef USE_SKINNING
+#endif`,Ew=`#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;`,lw=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,vw=`#ifdef USE_SKINNING
+#endif`,Aw=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,lw=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,bw=`float specularStrength;
+#endif`,Tw=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,Sw=`#ifdef USE_SPECULARMAP
+#endif`,Rw=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,Mw=`#if defined( TONE_MAPPING )
+#endif`,Cw=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,ww=`#ifndef saturate
+#endif`,Pw=`#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; }`,Ew=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ew=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,Aw=`#ifdef USE_TRANSMISSION
+#endif`,Lw=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ew=`#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`,Tw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,Nw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ew=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,Rw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,Dw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ew=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,Cw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,Ow=`#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; }`,Ew=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var Pw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`;var Uw=`#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; }`,Ew=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,Iw=`varying vec2 vUv;
+#endif`,Fw=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,Lw=`uniform sampler2D t2D;
+}`,zw=`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>
-}`,Nw=`varying vec3 vWorldDirection;
+}`,kw=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,Dw=`#ifdef ENVMAP_TYPE_CUBE
+}`,Bw=`#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>
-}`,Ow=`varying vec3 vWorldDirection;
+}`,Vw=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,Uw=`uniform samplerCube tCube;
+}`,Gw=`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>
-}`,Fw=`#include <common>
+}`,Hw=`#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;
-}`,zw=`#if DEPTH_PACKING == 3200
+}`,$w=`#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
-}`,kw=`#define DISTANCE
+}`,Ww=`#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;
-}`,Bw=`#define DISTANCE
+}`,Zw=`#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 );
-}`,Vw=`varying vec3 vWorldDirection;
+}`,Xw=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,Gw=`uniform sampler2D tEquirect;
+}`,jw=`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>
-}`,Hw=`uniform float scale;
+}`,qw=`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>
-}`,$w=`uniform vec3 diffuse;
+}`,Yw=`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>
-}`,Ww=`#include <common>
+}`,Jw=`#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>
-}`,Zw=`uniform vec3 diffuse;
+}`,Kw=`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>
-}`,Xw=`#define LAMBERT
+}`,Qw=`#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>
-}`,jw=`#define LAMBERT
+}`,eE=`#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>
-}`,qw=`#define MATCAP
+}`,tE=`#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;
-}`,Yw=`#define MATCAP
+}`,nE=`#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>
-}`,Jw=`#define NORMAL
+}`,iE=`#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
-}`,Kw=`#define NORMAL
+}`,rE=`#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
-}`,Qw=`#define PHONG
+}`,sE=`#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>
-}`,eE=`#define PHONG
+}`,oE=`#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>
-}`,tE=`#define STANDARD
+}`,aE=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3583,7 +3583,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,nE=`#define STANDARD
+}`,cE=`#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>
-}`,iE=`#define TOON
+}`,lE=`#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>
-}`,rE=`#define TOON
+}`,uE=`#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>
-}`,sE=`uniform float size;
+}`,hE=`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>
-}`,oE=`uniform vec3 diffuse;
+}`,dE=`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>
-}`,aE=`#include <common>
+}`,fE=`#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>
-}`,cE=`uniform vec3 color;
+}`,pE=`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>
-}`,lE=`uniform float rotation;
+}`,mE=`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>
-}`,uE=`uniform vec3 diffuse;
+}`,gE=`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>
-}`,Ze={alphahash_fragment:IS,alphahash_pars_fragment:LS,alphamap_fragment:NS,alphamap_pars_fragment:DS,alphatest_fragment:OS,alphatest_pars_fragment:US,aomap_fragment:FS,aomap_pars_fragment:zS,batching_pars_vertex:kS,batching_vertex:BS,begin_vertex:VS,beginnormal_vertex:GS,bsdfs:HS,iridescence_fragment:$S,bumpmap_pars_fragment:WS,clipping_planes_fragment:ZS,clipping_planes_pars_fragment:XS,clipping_planes_pars_vertex:jS,clipping_planes_vertex:qS,color_fragment:YS,color_pars_fragment:JS,color_pars_vertex:KS,color_vertex:QS,common:eM,cube_uv_reflection_fragment:tM,defaultnormal_vertex:nM,displacementmap_pars_vertex:iM,displacementmap_vertex:rM,emissivemap_fragment:sM,emissivemap_pars_fragment:oM,colorspace_fragment:aM,colorspace_pars_fragment:cM,envmap_fragment:lM,envmap_common_pars_fragment:uM,envmap_pars_fragment:hM,envmap_pars_vertex:dM,envmap_physical_pars_fragment:MM,envmap_vertex:fM,fog_vertex:pM,fog_pars_vertex:mM,fog_fragment:gM,fog_pars_fragment:_M,gradientmap_pars_fragment:xM,lightmap_pars_fragment:yM,lights_lambert_fragment:vM,lights_lambert_pars_fragment:bM,lights_pars_begin:SM,lights_toon_fragment:wM,lights_toon_pars_fragment:EM,lights_phong_fragment:AM,lights_phong_pars_fragment:TM,lights_physical_fragment:RM,lights_physical_pars_fragment:CM,lights_fragment_begin:PM,lights_fragment_maps:IM,lights_fragment_end:LM,lightprobes_pars_fragment:NM,logdepthbuf_fragment:DM,logdepthbuf_pars_fragment:OM,logdepthbuf_pars_vertex:UM,logdepthbuf_vertex:FM,map_fragment:zM,map_pars_fragment:kM,map_particle_fragment:BM,map_particle_pars_fragment:VM,metalnessmap_fragment:GM,metalnessmap_pars_fragment:HM,morphinstance_vertex:$M,morphcolor_vertex:WM,morphnormal_vertex:ZM,morphtarget_pars_vertex:XM,morphtarget_vertex:jM,normal_fragment_begin:qM,normal_fragment_maps:YM,normal_pars_fragment:JM,normal_pars_vertex:KM,normal_vertex:QM,normalmap_pars_fragment:ew,clearcoat_normal_fragment_begin:tw,clearcoat_normal_fragment_maps:nw,clearcoat_pars_fragment:iw,iridescence_pars_fragment:rw,opaque_fragment:sw,packing:ow,premultiplied_alpha_fragment:aw,project_vertex:cw,dithering_fragment:lw,dithering_pars_fragment:uw,roughnessmap_fragment:hw,roughnessmap_pars_fragment:dw,shadowmap_pars_fragment:fw,shadowmap_pars_vertex:pw,shadowmap_vertex:mw,shadowmask_pars_fragment:gw,skinbase_vertex:_w,skinning_pars_vertex:xw,skinning_vertex:yw,skinnormal_vertex:vw,specularmap_fragment:bw,specularmap_pars_fragment:Sw,tonemapping_fragment:Mw,tonemapping_pars_fragment:ww,transmission_fragment:Ew,transmission_pars_fragment:Aw,uv_pars_fragment:Tw,uv_pars_vertex:Rw,uv_vertex:Cw,worldpos_vertex:Pw,background_vert:Iw,background_frag:Lw,backgroundCube_vert:Nw,backgroundCube_frag:Dw,cube_vert:Ow,cube_frag:Uw,depth_vert:Fw,depth_frag:zw,distance_vert:kw,distance_frag:Bw,equirect_vert:Vw,equirect_frag:Gw,linedashed_vert:Hw,linedashed_frag:$w,meshbasic_vert:Ww,meshbasic_frag:Zw,meshlambert_vert:Xw,meshlambert_frag:jw,meshmatcap_vert:qw,meshmatcap_frag:Yw,meshnormal_vert:Jw,meshnormal_frag:Kw,meshphong_vert:Qw,meshphong_frag:eE,meshphysical_vert:tE,meshphysical_frag:nE,meshtoon_vert:iE,meshtoon_frag:rE,points_vert:sE,points_frag:oE,shadow_vert:aE,shadow_frag:cE,sprite_vert:lE,sprite_frag:uE},fe={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new De(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},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 U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new De(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},yi={basic:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:an([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:an([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:an([fe.points,fe.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:an([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:an([fe.common,fe.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:an([fe.sprite,fe.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:an([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:an([fe.lights,fe.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};yi.physical={uniforms:an([yi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new De(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new De},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new De},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Tc={r:0,b:0,g:0},hE=new $e,Um=new Ve;Um.set(-1,0,0,0,1,0,0,0,1);function dE(e,t,n,i,r,s){let o=new Ue(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="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 _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===_o)){if(l===void 0)l=new Mt(new mr(1,1,1),new Bn({name:"BackgroundCubeMaterial",uniforms:Gr(yi.backgroundCube.uniforms),vertexShader:yi.backgroundCube.vertexShader,fragmentShader:yi.backgroundCube.fragmentShader,side:sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,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=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(hE.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Um);if(l.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,u!==y||h!==y.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=y,h=y.version,d=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new Mt(new Po(2,2),new Bn({name:"BackgroundMaterial",uniforms:Gr(yi.background.uniforms),vertexShader:yi.background.vertexShader,fragmentShader:yi.background.fragmentShader,side:ur,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=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||h!==y.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=y,h=y.version,d=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Tc,Qu(e)),n.buffers.color.setClear(Tc.r,Tc.g,Tc.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(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function fE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=h(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function h(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let k=j[K.id];if(k===void 0)k={},j[K.id]=k;let q=k[G];if(q===void 0)q=d(c()),k[G]=q;return q}function d(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let ee=G[k],Se=X[k];if(Se===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Se=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Se=C.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==Se)return!0;if(Se&&ee.data!==Se.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let ee=X[k];if(ee===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)ee=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)ee=C.instanceColor}let Se={};if(Se.attribute=ee,ee&&ee.data)Se.data=ee.data;G[k]=Se,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let k=X[j];if(k.location>=0){let q=G[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 ee=q.normalized,Se=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Be,type:Me,bytesPerElement:Z}=ue,re=Me===e.INT||Me===e.UNSIGNED_INT||q.gpuType===ou;if(q.isInterleavedBufferAttribute){let se=q.data,xe=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<k.locationSize;Ae++)g(k.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<k.locationSize;Ae++)p(k.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let Ae=0;Ae<k.locationSize;Ae++)T(k.location+Ae,Se/k.locationSize,Me,ee,xe*Z,(Ee+Se/k.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)g(k.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let se=0;se<k.locationSize;se++)T(k.location+se,Se/k.locationSize,Me,ee,Se*Z,Se/k.locationSize*se*Z,re)}}else if(P!==void 0){let ee=P[j];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(k.location,ee);break;case 3:e.vertexAttrib3fv(k.location,ee);break;case 4:e.vertexAttrib4fv(k.location,ee);break;default:e.vertexAttrib1fv(k.location,ee)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){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:M,resetDefaultState:z,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function pE(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 mE(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!==gi&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===mi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ei&&R!==Hi&&!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)Le("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)Le("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),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=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:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function gE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Fn,a=new Ve,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 S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,d,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};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,S=d.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(h[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var ks=4,_E=6,xE=20,yE=256,Oo=new $r,pm=new Ue,gh=null,_h=0,xh=0,yh=!1,vE=new U,Wr=new U;class ko{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=vE}=r;gh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),xh=this._renderer.getActiveMipmapLevel(),yh=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=_m(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=gm(),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(gh,_h,xh),this._renderer.xr.enabled=yh,e.scissorTest=!1,zs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ws||e.mapping===Or)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);gh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),xh=this._renderer.getActiveMipmapLevel(),yh=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:qt,minFilter:qt,generateMipmaps:!1,type:mi,format:gi,colorSpace:wn,depthBuffer:!1},i=mm(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=mm(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=bE(r)),this._blurMaterial=ME(r,e,t),this._ggxMaterial=SE(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new on,e);this._renderer.compile(t,Oo)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(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(pm),u.toneMapping=Kn,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 mr,new _i({name:"PMREM.Background",side:sn,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(pm),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if(zs(i,T*y,S>2?y:0,y,y),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===ws||e.mapping===Or;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=_m();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=gm();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,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),h=c*1.25,d=u*h,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-ks?n-f+ks: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,Oo),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,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-ks?i-this._lodMax+ks:0),h=4*(this._cubeSize-l);zs(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,Oo)}}function bE(e){let t=[],n=[],i=e,r=e-ks+1+_E;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 S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*d*g);for(let w=0;w<d;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Wr.set(1,R,A);else if(g===1)Wr.set(-A,1,-R);else if(g===2)Wr.set(-A,R,1);else if(g===3)Wr.set(-1,R,-A);else if(g===4)Wr.set(-A,-1,R);else Wr.set(A,R,-1);Wr.toArray(_,(g*d+w)*f)}}let p=new on;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new Mt(p,null)),i>ks)i--}return{lodMeshes:n,sizeLods:t}}function mm(e,t,n){let i=new En(e,t,n);return i.texture.mapping=_o,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 SE(e,t,n){return new Bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:yE,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:Cc(),fragmentShader:`
+}`,Ze={alphahash_fragment:FS,alphahash_pars_fragment:zS,alphamap_fragment:kS,alphamap_pars_fragment:BS,alphatest_fragment:VS,alphatest_pars_fragment:GS,aomap_fragment:HS,aomap_pars_fragment:$S,batching_pars_vertex:WS,batching_vertex:ZS,begin_vertex:XS,beginnormal_vertex:jS,bsdfs:qS,iridescence_fragment:YS,bumpmap_pars_fragment:JS,clipping_planes_fragment:KS,clipping_planes_pars_fragment:QS,clipping_planes_pars_vertex:eM,clipping_planes_vertex:tM,color_fragment:nM,color_pars_fragment:iM,color_pars_vertex:rM,color_vertex:sM,common:oM,cube_uv_reflection_fragment:aM,defaultnormal_vertex:cM,displacementmap_pars_vertex:lM,displacementmap_vertex:uM,emissivemap_fragment:hM,emissivemap_pars_fragment:dM,colorspace_fragment:fM,colorspace_pars_fragment:pM,envmap_fragment:mM,envmap_common_pars_fragment:gM,envmap_pars_fragment:_M,envmap_pars_vertex:xM,envmap_physical_pars_fragment:CM,envmap_vertex:yM,fog_vertex:vM,fog_pars_vertex:bM,fog_fragment:SM,fog_pars_fragment:MM,gradientmap_pars_fragment:wM,lightmap_pars_fragment:EM,lights_lambert_fragment:AM,lights_lambert_pars_fragment:TM,lights_pars_begin:RM,lights_toon_fragment:PM,lights_toon_pars_fragment:IM,lights_phong_fragment:LM,lights_phong_pars_fragment:NM,lights_physical_fragment:DM,lights_physical_pars_fragment:OM,lights_fragment_begin:UM,lights_fragment_maps:FM,lights_fragment_end:zM,lightprobes_pars_fragment:kM,logdepthbuf_fragment:BM,logdepthbuf_pars_fragment:VM,logdepthbuf_pars_vertex:GM,logdepthbuf_vertex:HM,map_fragment:$M,map_pars_fragment:WM,map_particle_fragment:ZM,map_particle_pars_fragment:XM,metalnessmap_fragment:jM,metalnessmap_pars_fragment:qM,morphinstance_vertex:YM,morphcolor_vertex:JM,morphnormal_vertex:KM,morphtarget_pars_vertex:QM,morphtarget_vertex:ew,normal_fragment_begin:tw,normal_fragment_maps:nw,normal_pars_fragment:iw,normal_pars_vertex:rw,normal_vertex:sw,normalmap_pars_fragment:ow,clearcoat_normal_fragment_begin:aw,clearcoat_normal_fragment_maps:cw,clearcoat_pars_fragment:lw,iridescence_pars_fragment:uw,opaque_fragment:hw,packing:dw,premultiplied_alpha_fragment:fw,project_vertex:pw,dithering_fragment:mw,dithering_pars_fragment:gw,roughnessmap_fragment:_w,roughnessmap_pars_fragment:xw,shadowmap_pars_fragment:yw,shadowmap_pars_vertex:vw,shadowmap_vertex:bw,shadowmask_pars_fragment:Sw,skinbase_vertex:Mw,skinning_pars_vertex:ww,skinning_vertex:Ew,skinnormal_vertex:Aw,specularmap_fragment:Tw,specularmap_pars_fragment:Rw,tonemapping_fragment:Cw,tonemapping_pars_fragment:Pw,transmission_fragment:Iw,transmission_pars_fragment:Lw,uv_pars_fragment:Nw,uv_pars_vertex:Dw,uv_vertex:Ow,worldpos_vertex:Uw,background_vert:Fw,background_frag:zw,backgroundCube_vert:kw,backgroundCube_frag:Bw,cube_vert:Vw,cube_frag:Gw,depth_vert:Hw,depth_frag:$w,distance_vert:Ww,distance_frag:Zw,equirect_vert:Xw,equirect_frag:jw,linedashed_vert:qw,linedashed_frag:Yw,meshbasic_vert:Jw,meshbasic_frag:Kw,meshlambert_vert:Qw,meshlambert_frag:eE,meshmatcap_vert:tE,meshmatcap_frag:nE,meshnormal_vert:iE,meshnormal_frag:rE,meshphong_vert:sE,meshphong_frag:oE,meshphysical_vert:aE,meshphysical_frag:cE,meshtoon_vert:lE,meshtoon_frag:uE,points_vert:hE,points_frag:dE,shadow_vert:fE,shadow_frag:pE,sprite_vert:mE,sprite_frag:gE},fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new ze(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 U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ue(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},xi={basic:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:an([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:an([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:an([fe.points,fe.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:an([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:an([fe.common,fe.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:an([fe.sprite,fe.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:an([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:an([fe.lights,fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};xi.physical={uniforms:an([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Tc={r:0,b:0,g:0},_E=new $e,zm=new Ve;zm.set(-1,0,0,0,1,0,0,0,1);function xE(e,t,n,i,r,s){let o=new ze(0),a=r===!0?0:1,c,l,u=null,d=0,h=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="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 _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===yo)){if(l===void 0)l=new Mt(new mr(1,1,1),new Bn({name:"BackgroundCubeMaterial",uniforms:Gr(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,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=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(_E.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(zm);if(l.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new Mt(new Lo(2,2),new Bn({name:"BackgroundMaterial",uniforms:Gr(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:ur,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=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Tc,eh(e)),n.buffers.color.setClear(Tc.r,Tc.g,Tc.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(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function yE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=d(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function d(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let k=j[K.id];if(k===void 0)k={},j[K.id]=k;let q=k[G];if(q===void 0)q=h(c()),k[G]=q;return q}function h(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=G[k],Me=X[k];if(Me===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Me=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Me=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Me)return!0;if(Me&&Q.data!==Me.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=X[k];if(Q===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let Me={};if(Me.attribute=Q,Q&&Q.data)Me.data=Q.data;G[k]=Me,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let k=X[j];if(k.location>=0){let q=G[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,Me=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Be,type:we,bytesPerElement:Z}=ue,re=we===e.INT||we===e.UNSIGNED_INT||q.gpuType===au;if(q.isInterleavedBufferAttribute){let se=q.data,xe=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<k.locationSize;Ae++)g(k.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<k.locationSize;Ae++)p(k.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let Ae=0;Ae<k.locationSize;Ae++)T(k.location+Ae,Me/k.locationSize,we,Q,xe*Z,(Ee+Me/k.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)g(k.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let se=0;se<k.locationSize;se++)T(k.location+se,Me/k.locationSize,we,Q,Me*Z,Me/k.locationSize*se*Z,re)}}else if(P!==void 0){let Q=P[j];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)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){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:M,resetDefaultState:z,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function vE(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 f=0;f<u;f++)h+=l[f];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function bE(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!==mi&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===pi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==Qn&&R!==Gi&&!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)Le("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Le("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),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function SE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Fn,a=new Ve,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=d,g=e.get(d);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,h,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,f,m){let _=d!==null?d.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,S=h.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(d[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Bs=4,ME=6,wE=20,EE=256,Fo=new $r,gm=new ze,_h=null,xh=0,yh=0,vh=!1,AE=new U,Wr=new U;class Vo{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=AE}=r;_h=this._renderer.getRenderTarget(),xh=this._renderer.getActiveCubeFace(),yh=this._renderer.getActiveMipmapLevel(),vh=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=ym(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=xm(),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(_h,xh,yh),this._renderer.xr.enabled=vh,e.scissorTest=!1,ks(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Es||e.mapping===Or)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);_h=this._renderer.getRenderTarget(),xh=this._renderer.getActiveCubeFace(),yh=this._renderer.getActiveMipmapLevel(),vh=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:qt,minFilter:qt,generateMipmaps:!1,type:pi,format:mi,colorSpace:Mn,depthBuffer:!1},i=_m(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=_m(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=TE(r)),this._blurMaterial=CE(r,e,t),this._ggxMaterial=RE(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new on,e);this._renderer.compile(t,Fo)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(gm),u.toneMapping=Jn,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 mr,new gi({name:"PMREM.Background",side:sn,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(gm),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if(ks(i,T*y,S>2?y:0,y,y),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Es||e.mapping===Or;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=ym();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=xm();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;ks(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Fo)}_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),d=c*1.25,h=u*d,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Bs?n-f+Bs:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=f-t,ks(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,Fo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,ks(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,Fo)}_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-Bs?i-this._lodMax+Bs:0),d=4*(this._cubeSize-l);ks(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(a,Fo)}}function TE(e){let t=[],n=[],i=e,r=e-Bs+1+ME;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],d=6,h=6,f=3,m=new Float32Array(f*h*d),_=new Float32Array(f*h*d);for(let g=0;g<d;g++){let S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*h*g);for(let w=0;w<h;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Wr.set(1,R,A);else if(g===1)Wr.set(-A,1,-R);else if(g===2)Wr.set(-A,R,1);else if(g===3)Wr.set(-1,R,-A);else if(g===4)Wr.set(-A,-1,R);else Wr.set(A,R,-1);Wr.toArray(_,(g*h+w)*f)}}let p=new on;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new Mt(p,null)),i>Bs)i--}return{lodMeshes:n,sizeLods:t}}function _m(e,t,n){let i=new wn(e,t,n);return i.texture.mapping=yo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ks(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function RE(e,t,n){return new Bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:EE,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:Cc(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4048,7 +4048,7 @@ void main() {
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:fi,depthTest:!1,depthWrite:!1})}function ME(e,t,n){return new Bn({name:"SphericalGaussianBlur",defines:{SAMPLES:xE,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:Cc(),fragmentShader:`
+ `,blending:di,depthTest:!1,depthWrite:!1})}function CE(e,t,n){return new Bn({name:"SphericalGaussianBlur",defines:{SAMPLES:wE,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:Cc(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:fi,depthTest:!1,depthWrite:!1})}function gm(){return new Bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cc(),fragmentShader:`
+ `,blending:di,depthTest:!1,depthWrite:!1})}function xm(){return new Bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cc(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4127,7 +4127,7 @@ void main() {
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:fi,depthTest:!1,depthWrite:!1})}function _m(){return new Bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cc(),fragmentShader:`
+ `,blending:di,depthTest:!1,depthWrite:!1})}function ym(){return new Bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cc(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4143,7 +4143,7 @@ void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:fi,depthTest:!1,depthWrite:!1})}function Cc(){return`
+ `,blending:di,depthTest:!1,depthWrite:!1})}function Cc(){return`
precision mediump float;
precision mediump int;
@@ -4158,7 +4158,7 @@ void main() {
gl_Position = vec4( position, 1.0 );
}
- `}class wh extends En{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 gc(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 Eh extends wn{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 gc(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 mr(5,5,5),r=new Bn({name:"CubemapFromEquirect",uniforms:Gr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:sn,blending:fi});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===pi)t.minFilter=qt;return new ch(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 wE(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===Ya||f===Ja)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 wh(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===Ya||f===Ja,_=f===ws||f===Or;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 ko(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 S=d.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new ko(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===Ya)d.mapping=ws;else if(f===Ja)d.mapping=Or;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 EE(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)Nr("WebGLRenderer: "+i+" extension not supported.");return r}}}function AE(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 S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];d.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;d.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?dc:hc)(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 TE(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 RE(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:ze("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 CE(e,t,n){let i=new WeakMap,r=new ft;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 M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};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||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*h),R=new lc(A,y,w,h);R.type=Hi,R.needsUpdate=!0;let x=T*4;for(let z=0;z<h;z++){let C=p[z],L=g[z],K=S[z],I=y*w*4*z;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}d={count:h,texture:R,size:new De(y,w)},i.set(a,d),a.addEventListener("dispose",M)}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 PE(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 IE={[eu]:"LINEAR_TONE_MAPPING",[tu]:"REINHARD_TONE_MAPPING",[nu]:"CINEON_TONE_MAPPING",[go]:"ACES_FILMIC_TONE_MAPPING",[ru]:"AGX_TONE_MAPPING",[su]:"NEUTRAL_TONE_MAPPING",[iu]:"CUSTOM_TONE_MAPPING"};function LE(e,t,n,i,r,s){let o=new En(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 on;l.setAttribute("position",new xn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new xn([0,2,0,0,2,0],2));let u=new eh({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `},i=new mr(5,5,5),r=new Bn({name:"CubemapFromEquirect",uniforms:Gr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:sn,blending:di});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===fi)t.minFilter=qt;return new lh(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 PE(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,f=!1){if(h===null||h===void 0)return null;if(f)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let f=h.mapping;if(f===Ya||f===Ja)if(t.has(h)){let m=t.get(h).texture;return a(m,h.mapping)}else{let m=h.image;if(m&&m.height>0){let _=new Eh(m.height);return _.fromEquirectangularTexture(e,h),t.set(h,_),h.addEventListener("dispose",l),a(_.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,m=f===Ya||f===Ja,_=f===Es||f===Or;if(m||_){let p=n.get(h),g=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g){if(i===null)i=new Vo(e);return p=m?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 S=h.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new Vo(e);return p=m?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,f){if(f===Ya)h.mapping=Es;else if(f===Ja)h.mapping=Or;return h}function c(h){let f=0,m=6;for(let _=0;_<m;_++)if(h[_]!==void 0)f++;return f===m}function l(h){let f=h.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(h){let f=h.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function IE(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)Nr("WebGLRenderer: "+i+" extension not supported.");return r}}}function LE(e,t,n,i){let r={},s=new WeakMap;function o(d){let h=d.target;if(h.index!==null)t.remove(h.index);for(let m in h.attributes)t.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);if(f)t.remove(f),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(d,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(d){let h=d.attributes;for(let f in h)t.update(h[f],e.ARRAY_BUFFER)}function l(d){let h=[],f=d.index,m=d.attributes.position,_=0;if(m===void 0)return;if(f!==null){let S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];h.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;h.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?dc:hc)(h,1);p.version=_;let g=s.get(d);if(g)t.remove(g);s.set(d,p)}function u(d){let h=s.get(d);if(h){let f=d.index;if(f!==null){if(h.version<f.version)l(d)}}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function NE(e,t,n){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,h){e.drawElements(i,h,s,d*o),n.update(h,i,1)}function l(d,h,f){if(f===0)return;e.drawElementsInstanced(i,h,s,d*o,f),n.update(h,i,f)}function u(d,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,d,0,f);let _=0;for(let p=0;p<f;p++)_+=h[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function DE(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:ke("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 OE(e,t,n){let i=new WeakMap,r=new ft;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.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||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*d),R=new lc(A,y,w,d);R.type=Gi,R.needsUpdate=!0;let x=T*4;for(let z=0;z<d;z++){let C=p[z],L=g[z],K=S[z],I=y*w*4*z;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}h={count:d,texture:R,size:new Ue(y,w)},i.set(a,h),a.addEventListener("dispose",M)}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",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function UE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,d=l.geometry,h=t.get(l,d);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 f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,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 FE={[tu]:"LINEAR_TONE_MAPPING",[nu]:"REINHARD_TONE_MAPPING",[iu]:"CINEON_TONE_MAPPING",[xo]:"ACES_FILMIC_TONE_MAPPING",[su]:"AGX_TONE_MAPPING",[ou]:"NEUTRAL_TONE_MAPPING",[ru]:"CUSTOM_TONE_MAPPING"};function zE(e,t,n,i,r,s){let o=new wn(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 on;l.setAttribute("position",new xn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new xn([0,2,0,0,2,0],2));let u=new th({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}),h=new Mt(l,u),d=new $r(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new En(w,A,{type:mi,depthBuffer:!1,stencilBuffer:!1}),c=new En(w,A,{type:mi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===Kn&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=Kn,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},je.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=IE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.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 Fm=new Nt,Sh=new Vr(1,1),zm=new lc,km=new Ju,Bm=new gc,xm=[],ym=[],vm=new Float32Array(16),bm=new Float32Array(9),Sm=new Float32Array(4);function Bs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=xm[r];if(s===void 0)s=new Float32Array(r),xm[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 Ht(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 $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pc(e,t){let n=ym[t];if(n===void 0)n=new Int32Array(t),ym[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function NE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function DE(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(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function OE(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(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function UE(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(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function FE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Sm.set(i),e.uniformMatrix2fv(this.addr,!1,Sm),$t(n,i)}}function zE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;bm.set(i),e.uniformMatrix3fv(this.addr,!1,bm),$t(n,i)}}function kE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;vm.set(i),e.uniformMatrix4fv(this.addr,!1,vm),$t(n,i)}}function BE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function VE(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(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function GE(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(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function HE(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(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function $E(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function WE(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(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function ZE(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(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function XE(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(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function jE(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)Sh.compareFunction=n.isReversedDepthBuffer()?cc:ac,s=Sh;else s=Fm;n.setTexture2D(t||s,r)}function qE(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||km,r)}function YE(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||Bm,r)}function JE(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||zm,r)}function KE(e){switch(e){case 5126:return NE;case 35664:return DE;case 35665:return OE;case 35666:return UE;case 35674:return FE;case 35675:return zE;case 35676:return kE;case 5124:case 35670:return BE;case 35667:case 35671:return VE;case 35668:case 35672:return GE;case 35669:case 35673:return HE;case 5125:return $E;case 36294:return WE;case 36295:return ZE;case 36296:return XE;case 35678:case 36198:case 36298:case 36306:case 35682:return jE;case 35679:case 36299:case 36307:return qE;case 35680:case 36300:case 36308:case 36293:return YE;case 36289:case 36303:case 36311:case 36292:return JE}}function QE(e,t){e.uniform1fv(this.addr,t)}function eA(e,t){let n=Bs(t,this.size,2);e.uniform2fv(this.addr,n)}function tA(e,t){let n=Bs(t,this.size,3);e.uniform3fv(this.addr,n)}function nA(e,t){let n=Bs(t,this.size,4);e.uniform4fv(this.addr,n)}function iA(e,t){let n=Bs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function rA(e,t){let n=Bs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function sA(e,t){let n=Bs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function oA(e,t){e.uniform1iv(this.addr,t)}function aA(e,t){e.uniform2iv(this.addr,t)}function cA(e,t){e.uniform3iv(this.addr,t)}function lA(e,t){e.uniform4iv(this.addr,t)}function uA(e,t){e.uniform1uiv(this.addr,t)}function hA(e,t){e.uniform2uiv(this.addr,t)}function dA(e,t){e.uniform3uiv(this.addr,t)}function fA(e,t){e.uniform4uiv(this.addr,t)}function pA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Sh;else o=Fm;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function mA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||km,s[o])}function gA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Bm,s[o])}function _A(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||zm,s[o])}function xA(e){switch(e){case 5126:return QE;case 35664:return eA;case 35665:return tA;case 35666:return nA;case 35674:return iA;case 35675:return rA;case 35676:return sA;case 5124:case 35670:return oA;case 35667:case 35671:return aA;case 35668:case 35672:return cA;case 35669:case 35673:return lA;case 5125:return uA;case 36294:return hA;case 36295:return dA;case 36296:return fA;case 35678:case 36198:case 36298:case 36306:case 35682:return pA;case 35679:case 36299:case 36307:return mA;case 35680:case 36300:case 36308:case 36293:return gA;case 36289:case 36303:case 36311:case 36292:return _A}}class Vm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=KE(t.type)}}class Gm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=xA(t.type)}}class Hm{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 vh=/(\w+)(\])?(\[|\.)?/g;function Mm(e,t){e.seq.push(t),e.map[t.id]=t}function yA(e,t,n){let i=e.name,r=i.length;vh.lastIndex=0;while(!0){let s=vh.exec(i),o=vh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Mm(n,l===void 0?new Vm(a,e,t):new Gm(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new Hm(a),Mm(n,h);n=h}}}class zo{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);yA(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 wm(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var vA=37297,bA=0;function SA(e,t){let n=e.split(`
+ }`,depthTest:!1,depthWrite:!1}),d=new Mt(l,u),h=new $r(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new wn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1}),c=new wn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===Jn&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=Jn,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},je.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=FE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.render(d,h),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 km=new Nt,Mh=new Vr(1,1),Bm=new lc,Vm=new Ku,Gm=new gc,vm=[],bm=[],Sm=new Float32Array(16),Mm=new Float32Array(9),wm=new Float32Array(4);function Vs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=vm[r];if(s===void 0)s=new Float32Array(r),vm[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 Ht(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 $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pc(e,t){let n=bm[t];if(n===void 0)n=new Int32Array(t),bm[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function kE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function BE(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(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function VE(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(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function GE(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(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function HE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;wm.set(i),e.uniformMatrix2fv(this.addr,!1,wm),$t(n,i)}}function $E(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Mm.set(i),e.uniformMatrix3fv(this.addr,!1,Mm),$t(n,i)}}function WE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Sm.set(i),e.uniformMatrix4fv(this.addr,!1,Sm),$t(n,i)}}function ZE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function XE(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(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function jE(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(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function qE(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(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function YE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function JE(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(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function KE(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(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function QE(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(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function eA(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)Mh.compareFunction=n.isReversedDepthBuffer()?cc:ac,s=Mh;else s=km;n.setTexture2D(t||s,r)}function tA(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||Vm,r)}function nA(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||Gm,r)}function iA(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||Bm,r)}function rA(e){switch(e){case 5126:return kE;case 35664:return BE;case 35665:return VE;case 35666:return GE;case 35674:return HE;case 35675:return $E;case 35676:return WE;case 5124:case 35670:return ZE;case 35667:case 35671:return XE;case 35668:case 35672:return jE;case 35669:case 35673:return qE;case 5125:return YE;case 36294:return JE;case 36295:return KE;case 36296:return QE;case 35678:case 36198:case 36298:case 36306:case 35682:return eA;case 35679:case 36299:case 36307:return tA;case 35680:case 36300:case 36308:case 36293:return nA;case 36289:case 36303:case 36311:case 36292:return iA}}function sA(e,t){e.uniform1fv(this.addr,t)}function oA(e,t){let n=Vs(t,this.size,2);e.uniform2fv(this.addr,n)}function aA(e,t){let n=Vs(t,this.size,3);e.uniform3fv(this.addr,n)}function cA(e,t){let n=Vs(t,this.size,4);e.uniform4fv(this.addr,n)}function lA(e,t){let n=Vs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function uA(e,t){let n=Vs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function hA(e,t){let n=Vs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function dA(e,t){e.uniform1iv(this.addr,t)}function fA(e,t){e.uniform2iv(this.addr,t)}function pA(e,t){e.uniform3iv(this.addr,t)}function mA(e,t){e.uniform4iv(this.addr,t)}function gA(e,t){e.uniform1uiv(this.addr,t)}function _A(e,t){e.uniform2uiv(this.addr,t)}function xA(e,t){e.uniform3uiv(this.addr,t)}function yA(e,t){e.uniform4uiv(this.addr,t)}function vA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Mh;else o=km;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function bA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Vm,s[o])}function SA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Gm,s[o])}function MA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Bm,s[o])}function wA(e){switch(e){case 5126:return sA;case 35664:return oA;case 35665:return aA;case 35666:return cA;case 35674:return lA;case 35675:return uA;case 35676:return hA;case 5124:case 35670:return dA;case 35667:case 35671:return fA;case 35668:case 35672:return pA;case 35669:case 35673:return mA;case 5125:return gA;case 36294:return _A;case 36295:return xA;case 36296:return yA;case 35678:case 36198:case 36298:case 36306:case 35682:return vA;case 35679:case 36299:case 36307:return bA;case 35680:case 36300:case 36308:case 36293:return SA;case 36289:case 36303:case 36311:case 36292:return MA}}class Hm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=rA(t.type)}}class $m{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=wA(t.type)}}class Wm{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 bh=/(\w+)(\])?(\[|\.)?/g;function Em(e,t){e.seq.push(t),e.map[t.id]=t}function EA(e,t,n){let i=e.name,r=i.length;bh.lastIndex=0;while(!0){let s=bh.exec(i),o=bh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Em(n,l===void 0?new Hm(a,e,t):new $m(a,e,t));break}else{let d=n.map[a];if(d===void 0)d=new Wm(a),Em(n,d);n=d}}}class Bo{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);EA(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 Am(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var AA=37297,TA=0;function RA(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 Em=new Ve;function MA(e){je._getMatrix(Em,je.workingColorSpace,e);let t=`mat3( ${Em.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case Wu:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Am(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 Tm=new Ve;function CA(e){je._getMatrix(Tm,je.workingColorSpace,e);let t=`mat3( ${Tm.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case Zu:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Rm(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+`
-`+SA(e.getShaderSource(t),a)}else return s}function wA(e,t){let n=MA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var EA={[eu]:"Linear",[tu]:"Reinhard",[nu]:"Cineon",[go]:"ACESFilmic",[ru]:"AgX",[su]:"Neutral",[iu]:"Custom"};function AA(e,t){let n=EA[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Rc=new U;function TA(){je.getLuminanceCoefficients(Rc);let e=Rc.x.toFixed(4),t=Rc.y.toFixed(4),n=Rc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function RA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fo).join(`
-`)}function CA(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 PA(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 Tm(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 Rm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var IA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Mh(e){return e.replace(IA,NA)}var LA=new Map;function NA(e,t){let n=Ze[t];if(n===void 0){let i=LA.get(t);if(i!==void 0)n=Ze[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Mh(n)}var DA=/#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 Cm(e){return e.replace(DA,OA)}function OA(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 Pm(e){let t=`precision ${e.precision} float;
+`+RA(e.getShaderSource(t),a)}else return s}function PA(e,t){let n=CA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}var IA={[tu]:"Linear",[nu]:"Reinhard",[iu]:"Cineon",[xo]:"ACESFilmic",[su]:"AgX",[ou]:"Neutral",[ru]:"Custom"};function LA(e,t){let n=IA[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Rc=new U;function NA(){je.getLuminanceCoefficients(Rc);let e=Rc.x.toFixed(4),t=Rc.y.toFixed(4),n=Rc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function DA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ko).join(`
+`)}function OA(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 UA(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 ko(e){return e!==""}function Cm(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 Pm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var FA=/^[ \t]*#include +<([\w\d./]+)>/gm;function wh(e){return e.replace(FA,kA)}var zA=new Map;function kA(e,t){let n=Ze[t];if(n===void 0){let i=zA.get(t);if(i!==void 0)n=Ze[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return wh(n)}var BA=/#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 Im(e){return e.replace(BA,VA)}function VA(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 Lm(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 UA={[po]:"SHADOWMAP_TYPE_PCF",[Ss]:"SHADOWMAP_TYPE_VSM"};function FA(e){return UA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var zA={[ws]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE",[_o]:"ENVMAP_TYPE_CUBE_UV"};function kA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return zA[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var BA={[Or]:"ENVMAP_MODE_REFRACTION"};function VA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return BA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var GA={[zp]:"ENVMAP_BLENDING_MULTIPLY",[kp]:"ENVMAP_BLENDING_MIX",[Bp]:"ENVMAP_BLENDING_ADD"};function HA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return GA[e.combine]||"ENVMAP_BLENDING_NONE"}function $A(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 WA(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=FA(n),l=kA(n),u=VA(n),h=HA(n),d=$A(n),f=RA(n),m=CA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`
-`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Fo).join(`
+#define LOW_PRECISION`;return t}var GA={[go]:"SHADOWMAP_TYPE_PCF",[Ms]:"SHADOWMAP_TYPE_VSM"};function HA(e){return GA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var $A={[Es]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE",[yo]:"ENVMAP_TYPE_CUBE_UV"};function WA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return $A[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var ZA={[Or]:"ENVMAP_MODE_REFRACTION"};function XA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return ZA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var jA={[Bp]:"ENVMAP_BLENDING_MULTIPLY",[Vp]:"ENVMAP_BLENDING_MIX",[Gp]:"ENVMAP_BLENDING_ADD"};function qA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return jA[e.combine]||"ENVMAP_BLENDING_NONE"}function YA(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 JA(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=HA(n),l=WA(n),u=XA(n),d=qA(n),h=YA(n),f=DA(n),m=OA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`
+`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ko).join(`
`),p.length>0)p+=`
-`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Fo).join(`
+`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ko).join(`
`),g.length>0)g+=`
-`}else p=[Pm(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(Fo).join(`
-`),g=[Pm(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!==Kn?"#define TONE_MAPPING":"",n.toneMapping!==Kn?Ze.tonemapping_pars_fragment:"",n.toneMapping!==Kn?AA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ze.colorspace_pars_fragment,wA("linearToOutputTexel",n.outputColorSpace),TA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
-`].filter(Fo).join(`
-`);if(o=Mh(o),o=Tm(o,n),o=Rm(o,n),a=Mh(a),a=Tm(a,n),a=Rm(a,n),o=Cm(o),a=Cm(a),n.isRawShaderMaterial!==!0)S=`#version 300 es
+`}else p=[Lm(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(ko).join(`
+`),g=[Lm(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 "+d:"",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!==Jn?"#define TONE_MAPPING":"",n.toneMapping!==Jn?Ze.tonemapping_pars_fragment:"",n.toneMapping!==Jn?LA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ze.colorspace_pars_fragment,PA("linearToOutputTexel",n.outputColorSpace),NA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`].filter(ko).join(`
+`);if(o=wh(o),o=Cm(o,n),o=Pm(o,n),a=wh(a),a=Cm(a,n),a=Pm(a,n),o=Im(o),a=Im(a),n.isRawShaderMaterial!==!0)S=`#version 300 es
`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+p,g=["#define varying in",n.glslVersion===Zu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Zu?"":"#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===Xu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Xu?"":"#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=S+p+o,y=S+g+a,w=wm(r,r.VERTEX_SHADER,T),A=wm(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),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 L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,k=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=Am(r,w,"vertex"),ee=Am(r,A,"fragment");ze("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
+`+g;let T=S+p+o,y=S+g+a,w=Am(r,r.VERTEX_SHADER,T),A=Am(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),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 L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,k=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=Rm(r,w,"vertex"),Q=Rm(r,A,"fragment");ke("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
Material Name: `+C.name+`
Material Type: `+C.type+`
Program Info Log: `+G+`
`+q+`
-`+ee)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")k=!1;if(k)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new zo(r,_),M=PA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(_,vA);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=bA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var ZA=0;class $m{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 Wm(e),t.set(e,n);return n}}class Wm{constructor(e){this.id=ZA++,this.code=e,this.usedTimes=0}}function XA(e){return e===kr||e===rc||e===sc}function jA(e,t,n,i,r,s){let o=new uc,a=new $m,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,M,z,C,L,K){let I=C.fog,G=L.geometry,X=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||X,P),k=!!j&&j.mapping===_o?j.image.height:null,q=f[x.type];if(x.precision!==null){if(d=i.getMaxPrecision(x.precision),d!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead.")}let ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Se=ee!==void 0?ee.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Be,Me,Z,re;if(q){let bt=yi[q];Be=bt.vertexShader,Me=bt.fragmentShader}else{Be=x.vertexShader,Me=x.fragmentShader;let bt=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,bt,lt),Z=bt.id,re=lt.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,wt=!!x.map,Ge=!!x.matcap,Ye=!!j,ht=!!x.aoMap,nt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,Et=!!x.normalMap,gn=!!x.displacementMap,kt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=_n&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,_e=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,Ne=!!x.specularColorMap,Oe=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,Q=!!x.alphaMap,le=x.alphaTest>0,ye=!!x.alphaHash,ne=!!x.extensions,pe=Kn;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let He={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Be,fragmentShader:Me,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:wt,matcap:Ge,envMap:Ye,envMapMode:Ye&&j.mapping,envMapCubeUVHeight:k,aoMap:ht,lightMap:nt,bumpMap:Jt,normalMap:Et,displacementMap:gn,emissiveMap:kt,normalMapObjectSpace:Et&&x.normalMapType===jp,normalMapTangentSpace:Et&&x.normalMapType===$u,packedNormalMap:Et&&x.normalMapType===$u&&XA(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:_n,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:Ne,specularIntensityMap:Oe,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===mo&&x.alphaToCoverage===!1,alphaMap:Q,alphaTest:le,alphaHash:ye,combine:x.combine,mapUv:wt&&m(x.map.channel),aoMapUv:ht&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:Et&&m(x.normalMap.channel),displacementMapUv:gn&&m(x.displacementMap.channel),emissiveMapUv:kt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:Ne&&m(x.specularColorMap.channel),specularIntensityMapUv:Oe&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:Q&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(Et||_n),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(wt||Q),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&Et===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:xe,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:wt&&x.map.isVideoTexture===!0&&je.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:kt&&x.emissiveMap.isVideoTexture===!0&&je.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===kn,flipSided:x.side===sn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return He.vertexUv1s=c.has(1),He.vertexUv2s=c.has(2),He.vertexUv3s=c.has(3),c.clear(),He}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let z in x.defines)M.push(z),M.push(x.defines[z]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],z;if(M){let C=yi[M];z=om.clone(C.uniforms)}else z=x.uniforms;return z}function y(x,M){let z=u.get(M);if(z!==void 0)++z.usedTimes;else z=new WA(e,M,x,r),l.push(z),u.set(M,z);return z}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function qA(){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 YA(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 Im(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 Lm(){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 S=e[t];if(S===void 0)S={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=S;else S.id=d.id,S.object=d,S.geometry=f,S.material=m,S.materialVariant=o(d),S.groupOrder=_,S.renderOrder=d.renderOrder,S.z=p,S.group=g;return t++,S}function c(d,f,m,_,p,g,S){if(S.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 S=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(d,f){if(n.length>1)n.sort(d||YA);if(i.length>1)i.sort(f||Im);if(r.length>1)r.sort(f||Im)}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 JA(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Lm,e.set(i,[o]);else if(r>=s.length)o=new Lm,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function KA(){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 U,color:new Ue};break;case"SpotLight":n={position:new U,direction:new U,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":n={color:new Ue,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function QA(){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 De};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var eT=0;function tT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function nT(e){let t=new KA,n=QA(),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 U);let r=new U,s=new $e,o=new $e;function a(l){let u=0,h=0,d=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,z=0;l.sort(tT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===kr)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,h+=G.g*X,d+=G.b*X;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],X);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=ee,i.sunShadowMap[m]=j;let Se=q.getViewportCount();for(let ue=0;ue<Se;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Se,m++}i.sun[f]=k,f++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize=q.mapSize,i.directionalShadow[p]=ee,i.directionalShadowMap[p]=j,i.directionalShadowMatrix[p]=I.shadow.matrix,w++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(G).multiplyScalar(X),k.distance=P,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[S]=k;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize=q.mapSize,i.spotShadow[S]=ee,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(G).multiplyScalar(X),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=k,T++}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 q=I.shadow,ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize=q.mapSize,ee.shadowCameraNear=q.camera.near,ee.shadowCameraFar=q.camera.far,i.pointShadow[g]=ee,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=I.shadow.matrix,A++}i.point[g]=k,g++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(X),k.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=k,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.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!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==z)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=z,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=z,i.version=eT++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[h];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),h++}else if(y.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),d++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Nm(e){let t=new nT(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 iT(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Nm(e),t.set(r,[a]);else if(s>=o.length)a=new Nm(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var rT=`void main() {
+`+Q)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")k=!1;if(k)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new Bo(r,_),M=UA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(_,AA);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=TA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var KA=0;class Zm{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 Xm(e),t.set(e,n);return n}}class Xm{constructor(e){this.id=KA++,this.code=e,this.usedTimes=0}}function QA(e){return e===kr||e===rc||e===sc}function eT(e,t,n,i,r,s){let o=new uc,a=new Zm,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=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,M,z,C,L,K){let I=C.fog,G=L.geometry,X=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||X,P),k=!!j&&j.mapping===yo?j.image.height:null,q=f[x.type];if(x.precision!==null){if(h=i.getMaxPrecision(x.precision),h!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead.")}let Q=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Me=Q!==void 0?Q.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Be,we,Z,re;if(q){let bt=xi[q];Be=bt.vertexShader,we=bt.fragmentShader}else{Be=x.vertexShader,we=x.fragmentShader;let bt=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,bt,lt),Z=bt.id,re=lt.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,Et=!!x.map,Ge=!!x.matcap,Ye=!!j,ht=!!x.aoMap,nt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,At=!!x.normalMap,gn=!!x.displacementMap,kt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=_n&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,_e=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,De=!!x.specularColorMap,Fe=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,ee=!!x.alphaMap,le=x.alphaTest>0,ye=!!x.alphaHash,ne=!!x.extensions,pe=Jn;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let He={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Be,fragmentShader:we,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Et,matcap:Ge,envMap:Ye,envMapMode:Ye&&j.mapping,envMapCubeUVHeight:k,aoMap:ht,lightMap:nt,bumpMap:Jt,normalMap:At,displacementMap:gn,emissiveMap:kt,normalMapObjectSpace:At&&x.normalMapType===Yp,normalMapTangentSpace:At&&x.normalMapType===Wu,packedNormalMap:At&&x.normalMapType===Wu&&QA(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:_n,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:De,specularIntensityMap:Fe,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===_o&&x.alphaToCoverage===!1,alphaMap:ee,alphaTest:le,alphaHash:ye,combine:x.combine,mapUv:Et&&m(x.map.channel),aoMapUv:ht&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:At&&m(x.normalMap.channel),displacementMapUv:gn&&m(x.displacementMap.channel),emissiveMapUv:kt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:De&&m(x.specularColorMap.channel),specularIntensityMapUv:Fe&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:ee&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(At||_n),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(Et||ee),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&At===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Et&&x.map.isVideoTexture===!0&&je.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:kt&&x.emissiveMap.isVideoTexture===!0&&je.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===kn,flipSided:x.side===sn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return He.vertexUv1s=c.has(1),He.vertexUv2s=c.has(2),He.vertexUv3s=c.has(3),c.clear(),He}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let z in x.defines)M.push(z),M.push(x.defines[z]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],z;if(M){let C=xi[M];z=cm.clone(C.uniforms)}else z=x.uniforms;return z}function y(x,M){let z=u.get(M);if(z!==void 0)++z.usedTimes;else z=new JA(e,M,x,r),l.push(z),u.set(M,z);return z}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function tT(){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 nT(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 Nm(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 Dm(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let f=0;if(h.isInstancedMesh)f+=2;if(h.isSkinnedMesh)f+=1;return f}function a(h,f,m,_,p,g){let S=e[t];if(S===void 0)S={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:_,renderOrder:h.renderOrder,z:p,group:g},e[t]=S;else S.id=h.id,S.object=h,S.geometry=f,S.material=m,S.materialVariant=o(h),S.groupOrder=_,S.renderOrder=h.renderOrder,S.z=p,S.group=g;return t++,S}function c(h,f,m,_,p,g,S){if(S.reversedDepth===!0)p=-p;let T=a(h,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(h,f,m,_,p,g){let S=a(h,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(h,f){if(n.length>1)n.sort(h||nT);if(i.length>1)i.sort(f||Nm);if(r.length>1)r.sort(f||Nm)}function d(){for(let h=t,f=e.length;h<f;h++){let m=e[h];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:d,sort:u}}function iT(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Dm,e.set(i,[o]);else if(r>=s.length)o=new Dm,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function rT(){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 U,color:new ze};break;case"SpotLight":n={position:new U,direction:new U,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new ze,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":n={color:new ze,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function sT(){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 Ue};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var oT=0;function aT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function cT(e){let t=new rT,n=sT(),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 U);let r=new U,s=new $e,o=new $e;function a(l){let u=0,d=0,h=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,z=0;l.sort(aT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===kr)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,d+=G.g*X,h+=G.b*X;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],X);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);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 Me=q.getViewportCount();for(let ue=0;ue<Me;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Me,m++}i.sun[f]=k,f++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);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]=I.shadow.matrix,w++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(G).multiplyScalar(X),k.distance=P,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[S]=k;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[S]=Q,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(G).multiplyScalar(X),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=k,T++}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 q=I.shadow,Q=n.get(I);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]=I.shadow.matrix,A++}i.point[g]=k,g++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(X),k.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=k,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==z)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=z,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=z,i.version=oT++}function c(l,u){let d=0,h=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[d];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),d++}else if(y.isDirectionalLight){let w=i.directional[h];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),h++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Om(e){let t=new cT(e),n=[],i=[],r=[];function s(h){d.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 d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function lT(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Om(e),t.set(r,[a]);else if(s>=o.length)a=new Om(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var uT=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,sT=`uniform sampler2D shadow_pass;
+}`,hT=`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 );
-}`,oT=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],aT=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Dm=new $e,Uo=new U,bh=new U;function cT(e,t,n){let i=new To,r=new De,s=new De,o=new ft,a=new th,c=new nh,l={},u=n.maxTextureSize,h={[ur]:sn,[sn]:ur,[kn]:kn},d=new Bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new De},radius:{value:4}},vertexShader:rT,fragmentShader:sT}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new on;m.setAttribute("position",new jt(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=po;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===up)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=po;let M=e.getRenderTarget(),z=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(fi),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"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 k=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=k,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Ss){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new En(r.x,r.y,{format:kr,type:mi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Vr(r.x,r.y,Hi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Fr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Qn,P.map.depthTexture.magFilter=Qn}else{if(X.isPointLight)P.map=new wh(r.x),P.map.depthTexture=new Ku(r.x,hr);else P.map=new En(r.x,r.y),P.map.depthTexture=new Vr(r.x,r.y,hr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Fr,this.type===po)P.map.depthTexture.compareFunction=k?cc:ac,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Qn,P.map.depthTexture.magFilter=Qn}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(X.isPointLight!==!0)P.updateMatrices(X,x);for(let ee=0;ee<q;ee++){let Se=P.getCamera(ee);if(X.isPointLight){let{camera:ue,matrix:Be}=P,Me=X.distance||ue.far;if(Me!==ue.far)ue.far=Me,ue.updateProjectionMatrix();Uo.setFromMatrixPosition(X.matrixWorld),ue.position.copy(Uo),bh.copy(ue.position),bh.add(oT[ee]),ue.up.copy(aT[ee]),ue.lookAt(bh),ue.updateMatrixWorld(),Be.makeTranslation(-Uo.x,-Uo.y,-Uo.z),Dm.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Dm,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(ee);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(ee),y(R,x,Se,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Ss)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,z,C)};function S(A,R){let x=t.update(_);if(d.defines.VSM_SAMPLES!==A.blurSamples)d.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new En(r.x,r.y,{format:kr,type:mi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);d.uniforms.shadow_pass.value=A.map.depthTexture,d.uniforms.resolution.value.set(A.map.width,A.map.height),d.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let z=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)z=C;else if(z=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 L=z.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=z.clone(),I[K]=G,R.addEventListener("dispose",w);z=G}if(z.visible=R.visible,z.wireframe=R.wireframe,M===Ss)z.side=R.shadowSide!==null?R.shadowSide:R.side;else z.side=R.shadowSide!==null?R.shadowSide:h[R.side];if(z.alphaMap=R.alphaMap,z.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,z.map=R.map,z.clipShadows=R.clipShadows,z.clippingPlanes=R.clippingPlanes,z.clipIntersection=R.clipIntersection,z.displacementMap=R.displacementMap,z.displacementScale=R.displacementScale,z.displacementBias=R.displacementBias,z.wireframeLinewidth=R.wireframeLinewidth,z.linewidth=R.linewidth,x.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let L=e.properties.get(z);L.light=x}return z}function y(A,R,x,M,z){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&z===Ss)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],k=I[j.materialIndex];if(k&&k.visible){let q=T(A,k,M,z);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,z);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,z)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],z=A.target.uuid;if(z in M)M[z].dispose(),delete M[z]}}}function lT(e,t){function n(){let F=!1,ce=new ft,Q=null,le=new ft(0,0,0,0);return{setMask:function(ye){if(Q!==ye&&!F)e.colorMask(ye,ye,ye,ye),Q=ye},setLocked:function(ye){F=ye},setClear:function(ye,ne,pe,He,bt){if(bt===!0)ye*=He,ne*=He,pe*=He;if(ce.set(ye,ne,pe,He),le.equals(ce)===!1)e.clearColor(ye,ne,pe,He),le.copy(ce)},reset:function(){F=!1,Q=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,Q=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 He=ye;ye=null,this.setClear(He)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(Q!==ne&&!F)e.depthMask(ne),Q=ne},setFunc:function(ne){if(ce)ne=rm[ne];if(le!==ne){switch(ne){case Ip:e.depthFunc(e.NEVER);break;case Lp:e.depthFunc(e.ALWAYS);break;case Np:e.depthFunc(e.LESS);break;case Ql:e.depthFunc(e.LEQUAL);break;case Dp:e.depthFunc(e.EQUAL);break;case Op:e.depthFunc(e.GEQUAL);break;case Up:e.depthFunc(e.GREATER);break;case Fp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,Q=null,le=null,ye=null,ce=!1}}}function r(){let F=!1,ce=null,Q=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,ai,Oi){if(Q!==lt||le!==ai||ye!==Oi)e.stencilFunc(lt,ai,Oi),Q=lt,le=ai,ye=Oi},setOp:function(lt,ai,Oi){if(ne!==lt||pe!==ai||He!==Oi)e.stencilOp(lt,ai,Oi),ne=lt,pe=ai,He=Oi},setLocked:function(lt){F=lt},setClear:function(lt){if(bt!==lt)e.clearStencil(lt),bt=lt},reset:function(){F=!1,ce=null,Q=null,le=null,ye=null,ne=null,pe=null,He=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,S=null,T=null,y=null,w=null,A=null,R=null,x=new Ue(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(k)[1]),P=j>=1;else if(k.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),P=j>=2;let q=null,ee={},Se=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Be=new ft().fromArray(Se),Me=new ft().fromArray(ue);function Z(F,ce,Q,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<Q;pe++)if(F===e.TEXTURE_3D||F===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(Ql),Jt(!1),Et(ql),se(e.CULL_FACE),ht(fi);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function xe(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(d[F]!==ce){if(e.bindFramebuffer(F,ce),d[F]=ce,F===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let Q=m,le=!1;if(F){if(Q=f.get(ce),Q===void 0)Q=[],f.set(ce,Q);let ye=F.textures;if(Q.length!==ye.length||Q[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)Q[ne]=e.COLOR_ATTACHMENT0+ne;Q.length=ye.length,le=!0}}else if(Q[0]!==e.BACK)Q[0]=e.BACK,le=!0;if(le)e.drawBuffers(Q)}function wt(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let Ge={[Ms]:e.FUNC_ADD,[dp]:e.FUNC_SUBTRACT,[fp]:e.FUNC_REVERSE_SUBTRACT};Ge[pp]=e.MIN,Ge[mp]=e.MAX;let Ye={[gp]:e.ZERO,[_p]:e.ONE,[xp]:e.SRC_COLOR,[vp]:e.SRC_ALPHA,[Ap]:e.SRC_ALPHA_SATURATE,[wp]:e.DST_COLOR,[Sp]:e.DST_ALPHA,[yp]:e.ONE_MINUS_SRC_COLOR,[bp]:e.ONE_MINUS_SRC_ALPHA,[Ep]:e.ONE_MINUS_DST_COLOR,[Mp]:e.ONE_MINUS_DST_ALPHA,[Tp]:e.CONSTANT_COLOR,[Rp]:e.ONE_MINUS_CONSTANT_COLOR,[Cp]:e.CONSTANT_ALPHA,[Pp]:e.ONE_MINUS_CONSTANT_ALPHA};function ht(F,ce,Q,le,ye,ne,pe,He,bt,lt){if(F===fi){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==hp){if(F!==g||lt!==z){if(S!==Ms||w!==Ms)e.blendEquation(e.FUNC_ADD),S=Ms,w=Ms;if(lt)switch(F){case mo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Yl:e.blendFunc(e.ONE,e.ONE);break;case Jl:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Kl:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:ze("WebGLState: Invalid blending: ",F);break}else switch(F){case mo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Yl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Jl:ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Kl:ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ze("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,z=lt}return}if(ye=ye||ce,ne=ne||Q,pe=pe||le,ce!==S||ye!==w)e.blendEquationSeparate(Ge[ce],Ge[ye]),S=ce,w=ye;if(Q!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Ye[Q],Ye[le],Ye[ne],Ye[pe]),T=Q,y=le,A=ne,R=pe;if(He.equals(x)===!1||bt!==M)e.blendColor(He.r,He.g,He.b,bt),x.copy(He),M=bt;g=F,z=!1}function nt(F,ce){F.side===kn?xe(e.CULL_FACE):se(e.CULL_FACE);let Q=F.side===sn;if(ce)Q=!Q;Jt(Q),F.blending===mo&&F.transparent===!1?ht(fi):ht(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);kt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function Et(F){if(F!==cp){if(se(e.CULL_FACE),F!==L)if(F===ql)e.cullFace(e.BACK);else if(F===lp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);L=F}function gn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function kt(F,ce,Q){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==Q){if(I=ce,G=Q,o.getReversed())ce=-ce;e.polygonOffset(ce,Q)}}else xe(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function _n(F,ce,Q){if(Q===void 0)if(q===null)Q=e.TEXTURE0+X-1;else Q=q;let le=ee[Q];if(le===void 0)le={type:void 0,texture:void 0},ee[Q]=le;if(le.type!==F||le.texture!==ce){if(q!==Q)e.activeTexture(Q),q=Q;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=ee[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function _e(F){if(h[F]!==void 0)return h[F];else return e.getParameter(F)}function Ie(F,ce){if(h[F]!==ce)e.pixelStorei(F,ce),h[F]=ce}function de(F){if(Be.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Be.copy(F)}function oe(F){if(Me.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),Me.copy(F)}function Ne(F,ce){let Q=l.get(ce);if(Q===void 0)Q=new WeakMap,l.set(ce,Q);let le=Q.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),Q.set(F,le)}function Oe(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){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,ee={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new Ue(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,Be.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:Ee,drawBuffers:Ae,useProgram:wt,setBlending:ht,setMaterial:nt,setFlipSided:Jt,setCullFace:Et,setLineWidth:gn,setPolygonOffset:kt,setScissorTest:Bt,activeTexture:D,bindTexture:_n,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:_e,updateUBOMapping:Ne,uniformBlockBinding:Oe,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function uT(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 De,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(E){}function _(E,v){return m?new OffscreenCanvas(E,v):ys("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(d===void 0)d=_(ae,he);let Y=v?_(ae,he):d;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?Wu:je.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===yt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===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 w(E,v){let N;if(E){if(v===null||v===hr||v===Rs)N=e.DEPTH24_STENCIL8;else if(v===Hi)N=e.DEPTH32F_STENCIL8;else if(v===xo)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===hr||v===Rs)N=e.DEPTH_COMPONENT24;else if(v===Hi)N=e.DEPTH_COMPONENT32F;else if(v===xo)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==Qn&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)h.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function z(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)_n(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function k(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function ee(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Se={[Es]:e.REPEAT,[As]:e.CLAMP_TO_EDGE,[Ka]:e.MIRRORED_REPEAT},ue={[Qn]:e.NEAREST,[Qa]:e.NEAREST_MIPMAP_NEAREST,[Ur]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Ts]:e.LINEAR_MIPMAP_NEAREST,[pi]:e.LINEAR_MIPMAP_LINEAR},Be={[qp]:e.NEVER,[em]:e.ALWAYS,[Yp]:e.LESS,[ac]:e.LEQUAL,[Jp]:e.EQUAL,[cc]:e.GEQUAL,[Kp]:e.GREATER,[Qp]:e.NOTEQUAL};function Me(E,v){if(v.type===Hi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Ts||v.magFilter===Ur||v.magFilter===pi||v.minFilter===qt||v.minFilter===Ts||v.minFilter===Ur||v.minFilter===pi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Se[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Se[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Se[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Be[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Qn)return;if(v.minFilter!==Ur&&v.minFilter!==pi)return;if(v.type===Hi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)z(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],Ne=de.start+de.count,Oe=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=Ne+1&&Oe===st&&re(oe.start+oe.count-1,v.width,4)===Oe)de.count=Math.max(de.count,oe.start+oe.count-de.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),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],Ne=Math.floor(oe.start/4),Oe=Math.ceil(oe.count/4),st=Ne%v.width,F=Math.floor(Ne/v.width),ce=Oe,Q=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let Q=je.getPrimaries(je.workingColorSpace),le=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),ye=v.colorSpace===Br||Q===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let _e=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,_e,Ie,v.normalized,v.colorSpace,v.isVideoTexture);Me(H,v);let oe,Ne=v.mipmaps,Oe=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===zr,v.type),st)if(Oe)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,null)}else if(v.isDataTexture)if(Ne.length>0){if(Oe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,Ne[0].width,Ne[0].height);for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],Oe){if(F)n.texSubImage2D(e.TEXTURE_2D,Q,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,Q,de,oe.width,oe.height,0,_e,Ie,oe.data);v.generateMipmaps=!1}else if(Oe){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,_e,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(Oe&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,Ne[0].width,Ne[0].height,te.depth);for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],v.format!==gi)if(_e!==null)if(Oe){if(F)if(v.layerUpdates.size>0){let ye=mh(oe.width,oe.height,v.format,v.type);for(let ne of v.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,Q,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Q,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,Q,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,Q,0,0,0,oe.width,oe.height,te.depth,_e,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,Q,de,oe.width,oe.height,te.depth,0,_e,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(Oe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,Ne[0].width,Ne[0].height);for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],v.format!==gi)if(_e!==null)if(Oe){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,Q,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,Q,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(F)n.texSubImage2D(e.TEXTURE_2D,Q,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,Q,de,oe.width,oe.height,0,_e,Ie,oe.data)}else if(v.isDataArrayTexture)if(Oe){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let Q=mh(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ye=te.data.subarray(le*Q/te.data.BYTES_PER_ELEMENT,(le+1)*Q/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Ie,ye)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isData3DTexture)if(Oe){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(Oe)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let Q=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,de,Q,le,0,_e,Ie,null),Q>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let Q=e.canvas;if(!Q.hasAttribute("layoutsubtree"))Q.setAttribute("layoutsubtree","true");if(te.parentNode!==Q){Q.appendChild(te),h.add(v),Q.onpaint=(le)=>{let ye=le.changedElements;for(let ne of h)if(ye.includes(ne.image))ne.needsUpdate=!0},Q.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(Ne.length>0){if(Oe&&st){let Q=Pt(Ne[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,Q.width,Q.height)}for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],Oe){if(F)n.texSubImage2D(e.TEXTURE_2D,Q,0,0,_e,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,Q,de,_e,Ie,oe);v.generateMipmaps=!1}else if(Oe){if(st){let Q=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,Q.width,Q.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,_e,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=je.getPrimaries(je.workingColorSpace),Y=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),te=v.colorSpace===Br||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!_e&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],Ne=s.convert(v.format,v.colorSpace),Oe=s.convert(v.type),st=y(v.internalFormat,Ne,Oe,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,Q=ie.dataReady,le=A(v,oe);Me(e.TEXTURE_CUBE_MAP,v);let ye;if(_e){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=de[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(v.format!==gi)if(Ne!==null)if(F){if(Q)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,Ne,He.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,He.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,Ne,Oe,He.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,Ne,Oe,He.data)}}}else{if(ye=v.mipmaps,F&&ce){if(ye.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,Ne,Oe,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,Ne,Oe,de[ne].data);for(let pe=0;pe<ye.length;pe++){let bt=ye[pe].image[ne].image;if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,bt.width,bt.height,Ne,Oe,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,bt.width,bt.height,0,Ne,Oe,bt.data)}}else{if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Ne,Oe,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,Ne,Oe,de[ne]);for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Ne,Oe,He.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,Ne,Oe,He.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),_e=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!_e.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function wt(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ge(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v.depthTexture);let _e=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Fr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===zr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,_e,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===zr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Fr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===zr)if(D(v))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 Ye(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)Ge(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)Ge(v.__webglFramebuffer[0],E,0);else Ge(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),wt(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),wt(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ht(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Ye(E)}function nt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let _e=i.get(ie[Y]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let _e=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,_e,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),wt(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let _e=ie[Y],Ie=i.get(_e),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),Me(de,_e),Ae(N.__webglFramebuffer,E,_e,e.COLOR_ATTACHMENT0+Y,de,0),g(_e))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),Me(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Ye(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let Et=[],gn=[];function kt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let _e=0;_e<v.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=E.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<v.length;_e++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(Et.length=0,gn.length=0,Et.push(e.COLOR_ATTACHMENT0+_e),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)Et.push(ae),gn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,gn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,Et)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let _e=0;_e<v.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function _n(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==wn&&N!==Br)if(je.getTransfer(N)===yt){if(H!==gi||ie!==ei)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else ze("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=k,this.setTexture3D=q,this.setTextureCube=ee,this.rebindTextures=ht,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function hT(e,t){function n(i,r=Br){let s,o=je.getTransfer(r);if(i===ei)return e.UNSIGNED_BYTE;if(i===au)return e.UNSIGNED_SHORT_4_4_4_4;if(i===cu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Hp)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===$p)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Vp)return e.BYTE;if(i===Gp)return e.SHORT;if(i===xo)return e.UNSIGNED_SHORT;if(i===ou)return e.INT;if(i===hr)return e.UNSIGNED_INT;if(i===Hi)return e.FLOAT;if(i===mi)return e.HALF_FLOAT;if(i===Wp)return e.ALPHA;if(i===Zp)return e.RGB;if(i===gi)return e.RGBA;if(i===Fr)return e.DEPTH_COMPONENT;if(i===zr)return e.DEPTH_STENCIL;if(i===Xp)return e.RED;if(i===lu)return e.RED_INTEGER;if(i===kr)return e.RG;if(i===uu)return e.RG_INTEGER;if(i===hu)return e.RGBA_INTEGER;if(i===ec||i===tc||i===nc||i===ic)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ec)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ec)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===du||i===fu||i===pu||i===mu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===du)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===pu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===mu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===gu||i===_u||i===xu||i===yu||i===vu||i===rc||i===bu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===gu||i===_u)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===xu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===yu)return s.COMPRESSED_R11_EAC;if(i===vu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===rc)return s.COMPRESSED_RG11_EAC;if(i===bu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Su||i===Mu||i===wu||i===Eu||i===Au||i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===Lu||i===Nu||i===Du||i===Ou)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Su)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Mu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===wu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Eu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Au)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Tu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ru)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Cu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Pu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Iu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Lu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Nu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Du)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ou)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Uu||i===Fu||i===zu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Uu)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Fu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===zu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ku||i===Bu||i===sc||i===Vu)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===ku)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Bu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===sc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Vu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Rs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var dT=`
+}`,dT=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],fT=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Um=new $e,zo=new U,Sh=new U;function pT(e,t,n){let i=new Co,r=new Ue,s=new Ue,o=new ft,a=new nh,c=new ih,l={},u=n.maxTextureSize,d={[ur]:sn,[sn]:ur,[kn]:kn},h=new Bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:uT,fragmentShader:hT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new on;m.setAttribute("position",new jt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=go;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===dp)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=go;let M=e.getRenderTarget(),z=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(di),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"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 k=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=k,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Ms){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new wn(r.x,r.y,{format:kr,type:pi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Vr(r.x,r.y,Gi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Fr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}else{if(X.isPointLight)P.map=new Eh(r.x),P.map.depthTexture=new Qu(r.x,hr);else P.map=new wn(r.x,r.y),P.map.depthTexture=new Vr(r.x,r.y,hr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Fr,this.type===go)P.map.depthTexture.compareFunction=k?cc:ac,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}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(X.isPointLight!==!0)P.updateMatrices(X,x);for(let Q=0;Q<q;Q++){let Me=P.getCamera(Q);if(X.isPointLight){let{camera:ue,matrix:Be}=P,we=X.distance||ue.far;if(we!==ue.far)ue.far=we,ue.updateProjectionMatrix();zo.setFromMatrixPosition(X.matrixWorld),ue.position.copy(zo),Sh.copy(ue.position),Sh.add(dT[Q]),ue.up.copy(fT[Q]),ue.lookAt(Sh),ue.updateMatrixWorld(),Be.makeTranslation(-zo.x,-zo.y,-zo.z),Um.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Um,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(Q),y(R,x,Me,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Ms)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,z,C)};function S(A,R){let x=t.update(_);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new wn(r.x,r.y,{format:kr,type:pi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,h,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let z=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)z=C;else if(z=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 L=z.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=z.clone(),I[K]=G,R.addEventListener("dispose",w);z=G}if(z.visible=R.visible,z.wireframe=R.wireframe,M===Ms)z.side=R.shadowSide!==null?R.shadowSide:R.side;else z.side=R.shadowSide!==null?R.shadowSide:d[R.side];if(z.alphaMap=R.alphaMap,z.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,z.map=R.map,z.clipShadows=R.clipShadows,z.clippingPlanes=R.clippingPlanes,z.clipIntersection=R.clipIntersection,z.displacementMap=R.displacementMap,z.displacementScale=R.displacementScale,z.displacementBias=R.displacementBias,z.wireframeLinewidth=R.wireframeLinewidth,z.linewidth=R.linewidth,x.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let L=e.properties.get(z);L.light=x}return z}function y(A,R,x,M,z){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&z===Ms)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],k=I[j.materialIndex];if(k&&k.visible){let q=T(A,k,M,z);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,z);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,z)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],z=A.target.uuid;if(z in M)M[z].dispose(),delete M[z]}}}function mT(e,t){function n(){let F=!1,ce=new ft,ee=null,le=new ft(0,0,0,0);return{setMask:function(ye){if(ee!==ye&&!F)e.colorMask(ye,ye,ye,ye),ee=ye},setLocked:function(ye){F=ye},setClear:function(ye,ne,pe,He,bt){if(bt===!0)ye*=He,ne*=He,pe*=He;if(ce.set(ye,ne,pe,He),le.equals(ce)===!1)e.clearColor(ye,ne,pe,He),le.copy(ce)},reset:function(){F=!1,ee=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,ee=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 He=ye;ye=null,this.setClear(He)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(ee!==ne&&!F)e.depthMask(ne),ee=ne},setFunc:function(ne){if(ce)ne=om[ne];if(le!==ne){switch(ne){case Np:e.depthFunc(e.NEVER);break;case Dp:e.depthFunc(e.ALWAYS);break;case Op:e.depthFunc(e.LESS);break;case eu:e.depthFunc(e.LEQUAL);break;case Up:e.depthFunc(e.EQUAL);break;case Fp:e.depthFunc(e.GEQUAL);break;case zp:e.depthFunc(e.GREATER);break;case kp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,ee=null,le=null,ye=null,ce=!1}}}function r(){let F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,oi,Di){if(ee!==lt||le!==oi||ye!==Di)e.stencilFunc(lt,oi,Di),ee=lt,le=oi,ye=Di},setOp:function(lt,oi,Di){if(ne!==lt||pe!==oi||He!==Di)e.stencilOp(lt,oi,Di),ne=lt,pe=oi,He=Di},setLocked:function(lt){F=lt},setClear:function(lt){if(bt!==lt)e.clearStencil(lt),bt=lt},reset:function(){F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},d={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(k)[1]),P=j>=1;else if(k.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),P=j>=2;let q=null,Q={},Me=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Be=new ft().fromArray(Me),we=new ft().fromArray(ue);function Z(F,ce,ee,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<ee;pe++)if(F===e.TEXTURE_3D||F===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(eu),Jt(!1),At(Yl),se(e.CULL_FACE),ht(di);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function xe(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(h[F]!==ce){if(e.bindFramebuffer(F,ce),h[F]=ce,F===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let ee=m,le=!1;if(F){if(ee=f.get(ce),ee===void 0)ee=[],f.set(ce,ee);let ye=F.textures;if(ee.length!==ye.length||ee[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)ee[ne]=e.COLOR_ATTACHMENT0+ne;ee.length=ye.length,le=!0}}else if(ee[0]!==e.BACK)ee[0]=e.BACK,le=!0;if(le)e.drawBuffers(ee)}function Et(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let Ge={[ws]:e.FUNC_ADD,[pp]:e.FUNC_SUBTRACT,[mp]:e.FUNC_REVERSE_SUBTRACT};Ge[gp]=e.MIN,Ge[_p]=e.MAX;let Ye={[xp]:e.ZERO,[yp]:e.ONE,[vp]:e.SRC_COLOR,[Sp]:e.SRC_ALPHA,[Rp]:e.SRC_ALPHA_SATURATE,[Ap]:e.DST_COLOR,[wp]:e.DST_ALPHA,[bp]:e.ONE_MINUS_SRC_COLOR,[Mp]:e.ONE_MINUS_SRC_ALPHA,[Tp]:e.ONE_MINUS_DST_COLOR,[Ep]:e.ONE_MINUS_DST_ALPHA,[Cp]:e.CONSTANT_COLOR,[Pp]:e.ONE_MINUS_CONSTANT_COLOR,[Ip]:e.CONSTANT_ALPHA,[Lp]:e.ONE_MINUS_CONSTANT_ALPHA};function ht(F,ce,ee,le,ye,ne,pe,He,bt,lt){if(F===di){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==fp){if(F!==g||lt!==z){if(S!==ws||w!==ws)e.blendEquation(e.FUNC_ADD),S=ws,w=ws;if(lt)switch(F){case _o:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Jl:e.blendFunc(e.ONE,e.ONE);break;case Kl:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Ql:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:ke("WebGLState: Invalid blending: ",F);break}else switch(F){case _o:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Jl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Kl:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ql:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,z=lt}return}if(ye=ye||ce,ne=ne||ee,pe=pe||le,ce!==S||ye!==w)e.blendEquationSeparate(Ge[ce],Ge[ye]),S=ce,w=ye;if(ee!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Ye[ee],Ye[le],Ye[ne],Ye[pe]),T=ee,y=le,A=ne,R=pe;if(He.equals(x)===!1||bt!==M)e.blendColor(He.r,He.g,He.b,bt),x.copy(He),M=bt;g=F,z=!1}function nt(F,ce){F.side===kn?xe(e.CULL_FACE):se(e.CULL_FACE);let ee=F.side===sn;if(ce)ee=!ee;Jt(ee),F.blending===_o&&F.transparent===!1?ht(di):ht(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);kt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function At(F){if(F!==up){if(se(e.CULL_FACE),F!==L)if(F===Yl)e.cullFace(e.BACK);else if(F===hp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);L=F}function gn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function kt(F,ce,ee){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==ee){if(I=ce,G=ee,o.getReversed())ce=-ce;e.polygonOffset(ce,ee)}}else xe(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function _n(F,ce,ee){if(ee===void 0)if(q===null)ee=e.TEXTURE0+X-1;else ee=q;let le=Q[ee];if(le===void 0)le={type:void 0,texture:void 0},Q[ee]=le;if(le.type!==F||le.texture!==ce){if(q!==ee)e.activeTexture(ee),q=ee;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=Q[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function _e(F){if(d[F]!==void 0)return d[F];else return e.getParameter(F)}function Ie(F,ce){if(d[F]!==ce)e.pixelStorei(F,ce),d[F]=ce}function de(F){if(Be.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Be.copy(F)}function oe(F){if(we.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),we.copy(F)}function De(F,ce){let ee=l.get(ce);if(ee===void 0)ee=new WeakMap,l.set(ce,ee);let le=ee.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),ee.set(F,le)}function Fe(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){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={},d={},q=null,Q={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,Be.set(0,0,e.canvas.width,e.canvas.height),we.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:Ee,drawBuffers:Ae,useProgram:Et,setBlending:ht,setMaterial:nt,setFlipSided:Jt,setCullFace:At,setLineWidth:gn,setPolygonOffset:kt,setScissorTest:Bt,activeTexture:D,bindTexture:_n,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:_e,updateUBOMapping:De,uniformBlockBinding:Fe,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function gT(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 Ue,u=new WeakMap,d=new Set,h,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function _(E,v){return m?new OffscreenCanvas(E,v):vs("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(h===void 0)h=_(ae,he);let Y=v?_(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?Zu:je.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===yt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===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 w(E,v){let N;if(E){if(v===null||v===hr||v===Cs)N=e.DEPTH24_STENCIL8;else if(v===Gi)N=e.DEPTH32F_STENCIL8;else if(v===vo)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===hr||v===Cs)N=e.DEPTH_COMPONENT24;else if(v===Gi)N=e.DEPTH_COMPONENT32F;else if(v===vo)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==Kn&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)d.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function z(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)_n(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function k(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function Q(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Me={[As]:e.REPEAT,[Ts]:e.CLAMP_TO_EDGE,[Ka]:e.MIRRORED_REPEAT},ue={[Kn]:e.NEAREST,[Qa]:e.NEAREST_MIPMAP_NEAREST,[Ur]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Rs]:e.LINEAR_MIPMAP_NEAREST,[fi]:e.LINEAR_MIPMAP_LINEAR},Be={[Jp]:e.NEVER,[nm]:e.ALWAYS,[Kp]:e.LESS,[ac]:e.LEQUAL,[Qp]:e.EQUAL,[cc]:e.GEQUAL,[em]:e.GREATER,[tm]:e.NOTEQUAL};function we(E,v){if(v.type===Gi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Rs||v.magFilter===Ur||v.magFilter===fi||v.minFilter===qt||v.minFilter===Rs||v.minFilter===Ur||v.minFilter===fi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Me[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Me[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Me[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Be[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Kn)return;if(v.minFilter!==Ur&&v.minFilter!==fi)return;if(v.type===Gi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)z(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],De=de.start+de.count,Fe=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=De+1&&Fe===st&&re(oe.start+oe.count-1,v.width,4)===Fe)de.count=Math.max(de.count,oe.start+oe.count-de.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),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],De=Math.floor(oe.start/4),Fe=Math.ceil(oe.count/4),st=De%v.width,F=Math.floor(De/v.width),ce=Fe,ee=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let ee=je.getPrimaries(je.workingColorSpace),le=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),ye=v.colorSpace===Br||ee===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let _e=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,_e,Ie,v.normalized,v.colorSpace,v.isVideoTexture);we(H,v);let oe,De=v.mipmaps,Fe=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===zr,v.type),st)if(Fe)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,null)}else if(v.isDataTexture)if(De.length>0){if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data);v.generateMipmaps=!1}else if(Fe){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,_e,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(Fe&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,De[0].width,De[0].height,te.depth);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)if(v.layerUpdates.size>0){let ye=gh(oe.width,oe.height,v.format,v.type);for(let ne of v.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,ee,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,_e,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data)}else if(v.isDataArrayTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let ee=gh(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ye=te.data.subarray(le*ee/te.data.BYTES_PER_ELEMENT,(le+1)*ee/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Ie,ye)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isData3DTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(Fe)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let ee=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,de,ee,le,0,_e,Ie,null),ee>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let ee=e.canvas;if(!ee.hasAttribute("layoutsubtree"))ee.setAttribute("layoutsubtree","true");if(te.parentNode!==ee){ee.appendChild(te),d.add(v),ee.onpaint=(le)=>{let ye=le.changedElements;for(let ne of d)if(ye.includes(ne.image))ne.needsUpdate=!0},ee.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(De.length>0){if(Fe&&st){let ee=Pt(De[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,_e,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,ee,de,_e,Ie,oe);v.generateMipmaps=!1}else if(Fe){if(st){let ee=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,_e,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=je.getPrimaries(je.workingColorSpace),Y=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),te=v.colorSpace===Br||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!_e&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],De=s.convert(v.format,v.colorSpace),Fe=s.convert(v.type),st=y(v.internalFormat,De,Fe,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,ee=ie.dataReady,le=A(v,oe);we(e.TEXTURE_CUBE_MAP,v);let ye;if(_e){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=de[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(v.format!==mi)if(De!==null)if(F){if(ee)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,He.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,He.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,Fe,He.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,De,Fe,He.data)}}}else{if(ye=v.mipmaps,F&&ce){if(ye.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,De,Fe,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,De,Fe,de[ne].data);for(let pe=0;pe<ye.length;pe++){let bt=ye[pe].image[ne].image;if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,bt.width,bt.height,De,Fe,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,bt.width,bt.height,0,De,Fe,bt.data)}}else{if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,De,Fe,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,De,Fe,de[ne]);for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,De,Fe,He.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,De,Fe,He.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),_e=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!_e.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Et(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ge(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),we(e.TEXTURE_CUBE_MAP,v.depthTexture);let _e=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Fr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===zr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,_e,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===zr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Fr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===zr)if(D(v))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 Ye(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)Ge(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)Ge(v.__webglFramebuffer[0],E,0);else Ge(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),Et(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),Et(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ht(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Ye(E)}function nt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let _e=i.get(ie[Y]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let _e=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,_e,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),Et(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),we(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let _e=ie[Y],Ie=i.get(_e),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),we(de,_e),Ae(N.__webglFramebuffer,E,_e,e.COLOR_ATTACHMENT0+Y,de,0),g(_e))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),we(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Ye(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let At=[],gn=[];function kt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let _e=0;_e<v.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=E.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<v.length;_e++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(At.length=0,gn.length=0,At.push(e.COLOR_ATTACHMENT0+_e),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)At.push(ae),gn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,gn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,At)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let _e=0;_e<v.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function _n(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==Mn&&N!==Br)if(je.getTransfer(N)===yt){if(H!==mi||ie!==Qn)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else ke("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=k,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=ht,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function _T(e,t){function n(i,r=Br){let s,o=je.getTransfer(r);if(i===Qn)return e.UNSIGNED_BYTE;if(i===cu)return e.UNSIGNED_SHORT_4_4_4_4;if(i===lu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Wp)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===Zp)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Hp)return e.BYTE;if(i===$p)return e.SHORT;if(i===vo)return e.UNSIGNED_SHORT;if(i===au)return e.INT;if(i===hr)return e.UNSIGNED_INT;if(i===Gi)return e.FLOAT;if(i===pi)return e.HALF_FLOAT;if(i===Xp)return e.ALPHA;if(i===jp)return e.RGB;if(i===mi)return e.RGBA;if(i===Fr)return e.DEPTH_COMPONENT;if(i===zr)return e.DEPTH_STENCIL;if(i===qp)return e.RED;if(i===uu)return e.RED_INTEGER;if(i===kr)return e.RG;if(i===hu)return e.RG_INTEGER;if(i===du)return e.RGBA_INTEGER;if(i===ec||i===tc||i===nc||i===ic)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ec)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ec)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===fu||i===pu||i===mu||i===gu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===fu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===pu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===mu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===gu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===_u||i===xu||i===yu||i===vu||i===bu||i===rc||i===Su)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===_u||i===xu)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===yu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===vu)return s.COMPRESSED_R11_EAC;if(i===bu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===rc)return s.COMPRESSED_RG11_EAC;if(i===Su)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Mu||i===wu||i===Eu||i===Au||i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===Lu||i===Nu||i===Du||i===Ou||i===Uu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Mu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===wu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Eu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Au)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Tu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Ru)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Cu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Pu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Iu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Lu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Nu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Du)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Ou)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Uu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Fu||i===zu||i===ku)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Fu)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===zu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ku)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Bu||i===Vu||i===sc||i===Gu)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Bu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Vu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===sc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Gu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Cs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var xT=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,fT=`
+}`,yT=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4341,11 +4341,11 @@ void main() {
}
-}`;class Zm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new _c(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 Bn({vertexShader:dT,fragmentShader:fT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new Po(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Xm extends ti{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 Zm,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new De,R=null,x=null,M=new Vt;M.viewport=new ft;let z=new Vt;z.viewport=new ft;let C=[M,z],L=new lh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new So,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new So,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new So,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),d=null,h=null,u=null,i=null,T=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},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(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),T=new En(d.framebufferWidth,d.framebufferHeight,{format:gi,type:ei,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let se=null,xe=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?zr:Fr,xe=g.stencil?Rs:hr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,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 En(h.textureWidth,h.textureHeight,{format:gi,type:ei,depthTexture:new Vr(h.textureWidth,h.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),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),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 _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=w.indexOf(se);if(xe>=0)w[xe]=null,y[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=w.indexOf(se);if(xe===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),xe=Ae;break}else if(w[Ae]===null){w[Ae]=se,xe=Ae;break}if(xe===-1)break}let Ee=y[xe];if(Ee)Ee.connect(se)}}let j=new U,k=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=j.distanceTo(k),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,wt=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],ht=(Ee[9]-1)/Ee[5],nt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],Et=wt*nt,gn=wt*Jt,kt=xe/(-nt+Jt),Bt=kt*-nt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(kt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=wt+kt,_n=Ge+kt,ct=Et-Bt,Pt=gn+(xe-Bt),E=Ye*Ge/_n*D,v=ht*Ge/_n*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,_n),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function ee(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(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=z.near=M.near=re,L.far=z.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,z.layers.mask=L.layers.mask&-3;let xe=Z.parent,Ee=L.cameras;ee(L,xe);for(let Ae=0;Ae<Ee.length;Ae++)ee(Ee[Ae],xe);if(Ee.length===2)q(L,M,z);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Se(Z,L,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=Dr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(Z){if(a=Z,h!==null)h.fixedFoveation=Z;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Be(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(d!==null)e.setRenderTargetFramebuffer(T,d.framebuffer),e.setRenderTarget(T);let xe=!1;if(se.length!==L.cameras.length)L.cameras.length=0,xe=!0;for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge],ht=null;if(d!==null)ht=d.getViewport(Ye);else{let Jt=u.getViewSubImage(h,Ye);if(ht=Jt.viewport,Ge===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ge];if(nt===void 0)nt=new Vt,nt.layers.enable(Ge),nt.viewport=new ft,C[Ge]=nt;if(nt.matrix.fromArray(Ye.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Ye.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(ht.x,ht.y,ht.width,ht.height),Ge===0)L.matrix.copy(nt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(xe===!0)L.cameras.push(nt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ge=u.getDepthInformation(se[0]);if(Ge&&Ge.isValid&&Ge.texture)_.init(Ge,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge].camera;if(Ye){let ht=p[Ye];if(!ht)ht=new _c,p[Ye]=ht;let nt=u.getCameraImage(Ye);ht.sourceTexture=nt}}}}for(let se=0;se<y.length;se++){let xe=w[se],Ee=y[se];if(xe!==null&&Ee!==void 0)Ee.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let Me=new Om;Me.setAnimationLoop(Be),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var pT=new $e,jm=new Ve;jm.set(-1,0,0,0,1,0,0,0,1);function mT(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,Qu(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,S,T,y){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,y)}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,S,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===sn)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===sn)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 S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(pT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(jm);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,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,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,S){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===sn)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=S.texture,p.transmissionSamplerSize.value.set(S.width,S.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 S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function gT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)d(y),s[y.id]=x}function u(y){let w=h();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function h(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let z=A[x];if(Array.isArray(z))for(let C=0,L=z.length;C<L;C++)f(z[C],x,C,R);else f(z,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let z=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,z),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))z+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let z=R[M];if(typeof x==="number"||typeof x==="boolean"){if(z!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(z.equals(x)===!1)return z.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,z=w.length;M<z;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],k=g(j),q=A%R,ee=q%k.boundary,Se=q+ee;if(A+=ee,Se!==0&&R-Se<k.storage)A+=R-Se;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=k.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var _T=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]),xi=null;function xT(){if(xi===null)xi=new Eo(_T,16,16,kr,mi),xi.name="DFG_LUT",xi.minFilter=qt,xi.magFilter=qt,xi.wrapS=As,xi.wrapT=As,xi.generateMipmaps=!1,xi.needsUpdate=!0;return xi}class Eh{constructor(e={}){let{canvas:t=tm(),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=ei}=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([hu,uu,lu]),p=new Set([ei,hr,xo,Rs,au,cu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],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=Kn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,z=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=dr;let G=0,X=0,P=null,j=-1,k=null,q=new ft,ee=new ft,Se=null,ue=new Ue(0),Be=0,{width:Me,height:Z}=t,re=1,se=null,xe=null,Ee=new ft(0,0,Me,Z),Ae=new ft(0,0,Me,Z),wt=!1,Ge=new To,Ye=!1,ht=!1,nt=new $e,Jt=new U,Et=new ft,gn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},kt=!1;function Bt(){return P===null?re:1}let D=n;function _n(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,_e,Ie,de,oe,Ne,Oe,st,F,ce,Q,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${ap}`);if(t.addEventListener("webglcontextlost",He,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",lt,!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.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ze("WebGLRenderer: "+b.message),b}function ne(){if(ct=new EE(D),ct.init(),Q=new hT(D,ct),Pt=new mE(D,ct,e,Q),E=new lT(D,ct),Pt.reversedDepthBuffer&&h)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new RE(D),N=new qA,H=new uT(D,ct,E,N,Pt,Q,v),ie=new wE(M),ae=new PS(D),le=new fE(D,ae),he=new AE(D,ae,v,le),Y=new PE(D,he,ae,le,v),st=new CE(D,Pt,H),oe=new gE(N),te=new jA(M,ie,ct,Pt,le,oe),_e=new mT(M,N),Ie=new JA,de=new iT(ct),Oe=new dE(M,ie,E,Y,f,a),Ne=new cT(M,Y,Pt),ye=new gT(D,v,Pt,E),F=new pE(D,ct,v),ce=new TE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=Ne,M.state=E,M.info=v}if(m!==ei)x=new LE(m,t.width,t.height,o,i,r);let pe=new Xm(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.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,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){Me=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===ei){ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("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(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(ee.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return wt},this.setScissorTest=function(b){E.setScissorTest(wt=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=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,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,be=p.has(ge),me=Oe.getClearColor(),Te=Oe.getClearAlpha(),{r:Pe,g:We,b:Ke}=me;if(be)g[0]=Pe,g[1]=We,g[2]=Ke,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=We,S[2]=Ke,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.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",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Oe.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",mf),pe.removeEventListener("sessionend",gf),Rr.stop()};function He(b){b.preventDefault(),fo("WebGLRenderer: Context Lost."),z=!0}function bt(){fo("WebGLRenderer: Context Restored."),z=!1;let b=v.autoReset,O=Ne.enabled,W=Ne.autoUpdate,B=Ne.needsUpdate,V=Ne.type;ne(),v.autoReset=b,Ne.enabled=O,Ne.autoUpdate=W,Ne.needsUpdate=B,Ne.type=V}function lt(b){ze("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function ai(b){let O=b.target;O.removeEventListener("dispose",ai),Oi(O)}function Oi(b){vb(b),N.remove(b)}function vb(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=gn;let be=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Mb(b,O,W,B,V);E.setMaterial(B,be);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let We=W.drawRange,Ke=W.attributes.position,Re=We.start*Pe,ut=(We.start+We.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ut=Math.min(ut,Ke.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let At,xt=F;if(Te!==null)At=ae.get(Te),xt=ce,xt.setIndex(At);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(V.isLine){let tn=B.linewidth;if(tn===void 0)tn=1;if(E.setLineWidth(tn*Bt()),V.isLineSegments)xt.setMode(D.LINES);else if(V.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(V.isPoints)xt.setMode(D.POINTS);else if(V.isSprite)xt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:tn,_multiDrawCounts:ve,_multiDrawCount:un}=V,it=Te?ae.get(Te).bytesPerElement:1,On=N.get(B).currentProgram.getUniforms();for(let ci=0;ci<un;ci++)On.setValue(D,"_gl_DrawID",ci),xt.render(tn[ci]/it,ve[ci])}else xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)xt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let tn=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,tn);xt.renderInstances(Re,Ft,ve)}else xt.render(Re,Ft)};function pf(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ye===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===kn&&b.forceSinglePass===!1)b.side=sn,b.needsUpdate=!0,ba(b,O,B),b.side=ur,b.needsUpdate=!0,ba(b,O,B),b.side=kn;else ba(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),Ye===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)Ne.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let be=0;be<ge.length;be++){let me=ge[be];pf(me,W,O,V),B.add(me)}else pf(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(be){let Te=N.get(be).currentProgram;if(Te===void 0||Te.isReady())B.delete(be)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Sl=null;function bb(b){if(Sl)Sl(b)}function mf(){Rr.stop()}function gf(){Rr.start()}let Rr=new Om;if(Rr.setAnimationLoop(bb),typeof self<"u")Rr.setContext(self);this.setAnimationLoop=function(b){Sl=b,pe.setAnimationLoop(b),b===null?Rr.stop():Rr.start()},pe.addEventListener("sessionstart",mf),pe.addEventListener("sessionend",gf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ge.setFromProjectionMatrix(nt,Xu,O.reversedDepth),ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let be=M.xr.getDepthSensingMesh();if(be!==null)Ml(be,O,-1/0,M.sortObjects)}if(Ml(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,xe);if(kt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,kt)Oe.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ye===!0)oe.beginShadows();let V=w.state.shadowsArray;if(Ne.render(V,b,O),Ye===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let be=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];xf(be,me,b,Ke)}if(kt)Oe.render(b);for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];_f(y,b,Ke,Ke.viewport)}}else{if(me.length>0)xf(be,me,b,O);if(kt)Oe.render(b);_f(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,k=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Ye===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function Ml(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ge)){if(B)Et.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let be=Y.update(b),me=b.material;if(me.visible)y.push(b,be,me,W,Et.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ge)){let be=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();Et.copy(b.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();Et.copy(be.boundingSphere.center)}Et.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(me)){let Te=be.groups;for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe],Re=me[Ke.materialIndex];if(Re&&Re.visible)y.push(b,be,Re,W,Et.z,Ke,O)}}else if(me.visible)y.push(b,be,me,W,Et.z,null,O)}}}let ge=b.children;for(let be=0,me=ge.length;be<me;be++)Ml(ge[be],O,W,B)}function _f(b,O,W,B){let{opaque:V,transmissive:ge,transparent:be}=b;if(w.setupLightsView(W),Ye===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)va(V,O,W);if(ge.length>0)va(ge,O,W);if(be.length>0)va(be,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function xf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new En(1,1,{generateMipmaps:!0,type:Re?mi:ei,minFilter:pi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],be=B.viewport||q;ge.setSize(be.z*M.transmissionResolutionScale,be.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Be=M.getClearAlpha(),Be<1)M.setClearColor(16777215,0.5);if(M.clear(),kt)Oe.render(W);let We=M.toneMapping;M.toneMapping=Kn;let Ke=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Ye===!0)oe.setGlobalState(M.clippingPlanes,B);if(va(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let At=O[ut],{object:xt,geometry:tn,material:ve,group:un}=At;if(ve.side===kn&&xt.layers.test(B.layers)){let it=ve.side;ve.side=sn,ve.needsUpdate=!0,yf(xt,W,B,tn,ve,un),ve.side=it,ve.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Be),Ke!==void 0)B.viewport=Ke;M.toneMapping=We}function va(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let be=b[V],{object:me,geometry:Te,group:Pe}=be,We=be.material;if(We.allowOverride===!0&&B!==null)We=B;if(me.layers.test(W.layers))yf(me,O,W,Te,We,Pe)}}function yf(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===kn&&V.forceSinglePass===!1)V.side=sn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=ur,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=kn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function ba(b,O,W){if(O.isScene!==!0)O=gn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,be=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let We=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,We),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",ai),Pe=new Map,B.programs=Pe;let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===be)return bf(b,me),Ke}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Ke=te.acquireProgram(me,Te),Pe.set(Te,Ke),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(bf(b,me),B.needsLights=Eb(b),B.lightsStateVersion=be,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function vf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=zo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function bf(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Sb(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Mb(b,O,W,B,V){if(O.isScene!==!0)O=gn;H.resetTextureUnits();let ge=O.fog,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:je.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||be,Te),We=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ke=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,At=Kn;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)At=M.toneMapping}let xt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,tn=xt!==void 0?xt.length:0,ve=N.get(B),un=w.state.lights;if(Ye===!0){if(ht===!0||b!==k){let St=b===k&&B.id===j;oe.setState(B,b,St)}}let it=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==un.state.version)it=!0;else if(ve.outputColorSpace!==me)it=!0;else if(V.isBatchedMesh&&ve.batching===!1)it=!0;else if(!V.isBatchedMesh&&ve.batching===!0)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!0&&V._colorsTexture===null)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!1&&V._colorsTexture!==null)it=!0;else if(V.isInstancedMesh&&ve.instancing===!1)it=!0;else if(!V.isInstancedMesh&&ve.instancing===!0)it=!0;else if(V.isSkinnedMesh&&ve.skinning===!1)it=!0;else if(!V.isSkinnedMesh&&ve.skinning===!0)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!0&&V.instanceColor===null)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!1&&V.instanceColor!==null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!0&&V.morphTexture===null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!1&&V.morphTexture!==null)it=!0;else if(ve.envMap!==Pe)it=!0;else if(B.fog===!0&&ve.fog!==ge)it=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))it=!0;else if(ve.vertexAlphas!==We)it=!0;else if(ve.vertexTangents!==Ke)it=!0;else if(ve.morphTargets!==Re)it=!0;else if(ve.morphNormals!==ut)it=!0;else if(ve.morphColors!==Ft)it=!0;else if(ve.toneMapping!==At)it=!0;else if(ve.morphTargetsCount!==tn)it=!0;else if(!!ve.lightProbeGrid!==w.state.lightProbeGridArray.length>0)it=!0}else it=!0,ve.__version=B.version;let On=ve.currentProgram;if(it===!0){if(On=ba(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,On,ve)}let ci=!1,Ki=!1,ns=!1,mt=On.getUniforms(),Ot=ve.uniforms;if(E.useProgram(On.program))ci=!0,Ki=!0,ns=!0;if(B.id!==j)j=B.id,Ki=!0;if(ve.needsLights){let St=Sb(w.state.lightProbeGridArray,V);if(ve.lightProbeGrid!==St)ve.lightProbeGrid=St,Ki=!0}if(ci||k!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();mt.setValue(D,"projectionMatrix",b.projectionMatrix),mt.setValue(D,"viewMatrix",b.matrixWorldInverse);let er=mt.map.cameraPosition;if(er!==void 0)er.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)mt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)mt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ki=!0,ns=!0}if(ve.needsLights){if(un.state.sunShadowMap.length>0)mt.setValue(D,"sunShadowMap",un.state.sunShadowMap,H);if(un.state.directionalShadowMap.length>0)mt.setValue(D,"directionalShadowMap",un.state.directionalShadowMap,H);if(un.state.spotShadowMap.length>0)mt.setValue(D,"spotShadowMap",un.state.spotShadowMap,H);if(un.state.pointShadowMap.length>0)mt.setValue(D,"pointShadowMap",un.state.pointShadowMap,H)}if(V.isSkinnedMesh){mt.setOptional(D,V,"bindMatrix"),mt.setOptional(D,V,"bindMatrixInverse");let St=V.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();mt.setValue(D,"boneTexture",St.boneTexture,H)}}if(V.isBatchedMesh){if(mt.setOptional(D,V,"batchingTexture"),mt.setValue(D,"batchingTexture",V._matricesTexture,H),mt.setOptional(D,V,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",V._indirectTexture,H),mt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)mt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let Qi=W.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)st.update(V,W,On);if(Ki||ve.receiveShadow!==V.receiveShadow)ve.receiveShadow=V.receiveShadow,mt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=xT();if(Ki){if(mt.setValue(D,"toneMappingExposure",M.toneMappingExposure),ve.needsLights)wb(Ot,ns);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ot,ge);if(_e.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let St=ve.lightProbeGrid;Ot.probesSH.value=St.texture,Ot.probesMin.value.copy(St.boundingBox.min),Ot.probesMax.value.copy(St.boundingBox.max),Ot.probesResolution.value.copy(St.resolution)}zo.upload(D,vf(ve),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)zo.upload(D,vf(ve),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)mt.setValue(D,"center",V.center);if(mt.setValue(D,"modelViewMatrix",V.modelViewMatrix),mt.setValue(D,"normalMatrix",V.normalMatrix),mt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let St=B.uniformsGroups;for(let er=0,is=St.length;er<is;er++){let Mf=St[er];ye.update(Mf,On),ye.bind(Mf,On)}}return On}function wb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function Eb(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),ee.copy(b.scissor),Se=b.scissorTest,E.viewport(q),E.scissor(ee),E.setScissorTest(Se),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let We=b.depthTexture;if(me.__boundDepthTexture!==We){if(We!==null&&N.has(We)&&(b.width!==We.image.width||b.height!==We.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),ee.copy(b.scissor),Se=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),ee.copy(Ae).multiplyScalar(re).floor(),Se=wt;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(ee),E.setScissorTest(Se),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function Sf(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Sf(Pe);if(Re.__formatReadable===!1){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,Q.convert(We),Q.convert(Ke),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Sf(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,Q.convert(We),Q.convert(Ke),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let At=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await im(D,At,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(At),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),be=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,be,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let be,me,Te,Pe,We,Ke,Re,ut,Ft,At=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,Pe=W.min.x,We=W.min.y,Ke=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(be=Math.floor(At.width*Ot),me=Math.floor(At.height*Ot),b.isDataArrayTexture)Te=At.depth;else if(b.isData3DTexture)Te=Math.floor(At.depth*Ot);else Te=1;Pe=0,We=0,Ke=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let xt=Q.convert(O.format),tn=Q.convert(O.type),ve;if(O.isData3DTexture)H.setTexture3D(O,0),ve=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),ve=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),ve=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let un=E.getParameter(D.UNPACK_ROW_LENGTH),it=E.getParameter(D.UNPACK_IMAGE_HEIGHT),On=E.getParameter(D.UNPACK_SKIP_PIXELS),ci=E.getParameter(D.UNPACK_SKIP_ROWS),Ki=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,At.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,At.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,We),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ke);let ns=b.isDataArrayTexture||b.isData3DTexture,mt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),Qi=N.get(O),St=N.get(Ot.__renderTarget),er=N.get(Qi.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,er.__webglFramebuffer);for(let is=0;is<Te;is++){if(ns)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Ke+is),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+is);D.blitFramebuffer(Pe,We,be,me,Re,ut,be,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),Qi=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let St=0;St<Te;St++){if(ns)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Ke+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(mt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Qi.__webglTexture,ge,Ft+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Qi.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,We,be,me,Re,ut,be,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(mt)D.copyTexSubImage3D(ve,ge,Re,ut,Ft+St,Pe,We,be,me);else D.copyTexSubImage2D(ve,ge,Re,ut,Pe,We,be,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(mt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(ve,ge,Re,ut,Ft,be,me,Te,xt,tn,At.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(ve,ge,Re,ut,Ft,be,me,Te,xt,At.data);else D.texSubImage3D(ve,ge,Re,ut,Ft,be,me,Te,xt,tn,At);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,be,me,xt,tn,At.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,At.width,At.height,xt,At.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,be,me,xt,tn,At);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,un),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,it),E.pixelStorei(D.UNPACK_SKIP_PIXELS,On),E.pixelStorei(D.UNPACK_SKIP_ROWS,ci),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ki),ge===0&&O.generateMipmaps)D.generateMipmap(ve);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Xu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var Ym={type:"change"},Th={type:"start"},Km={type:"end"},Ic=new fr,Jm=new Fn,yT=Math.cos(70*vo.DEG2RAD),Wt=new U,vn=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ah=0.000001;class Rh extends Ac{constructor(e,t=null){super(e,t);if(this.state=pt.NONE,this.target=new U,this.cursor=new U,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:cr.ROTATE,MIDDLE:cr.DOLLY,RIGHT:cr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.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 U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Do,this._sphericalDelta=new Do,this._scale=1,this._panOffset=new U,this._rotateStart=new De,this._rotateEnd=new De,this._rotateDelta=new De,this._panStart=new De,this._panEnd=new De,this._panDelta=new De,this._dollyStart=new De,this._dollyEnd=new De,this._dollyDelta=new De,this._dollyDirection=new U,this._mouse=new De,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=bT.bind(this),this._onPointerDown=vT.bind(this),this._onPointerUp=ST.bind(this),this._onContextMenu=CT.bind(this),this._onMouseWheel=ET.bind(this),this._onKeyDown=AT.bind(this),this._onTouchStart=TT.bind(this),this._onTouchMove=RT.bind(this),this._onMouseDown=MT.bind(this),this._onMouseMove=wT.bind(this),this._interceptControlDown=PT.bind(this),this._interceptControlUp=IT.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=pt.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(Ym),this.update(),this.state=pt.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(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===pt.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+=vn;else if(n>Math.PI)n-=vn;if(i<-Math.PI)i+=vn;else if(i>Math.PI)i-=vn;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(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),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=Wt.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 U(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 U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.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(Ic.origin.copy(this.object.position),Ic.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ic.direction))<yT)this.object.lookAt(this.target);else Jm.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ic.intersectPlane(Jm,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)>Ah||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ah||this._lastTargetPosition.distanceToSquared(this.target)>Ah)return this.dispatchEvent(Ym),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 vn/60*this.autoRotateSpeed*e;else return vn/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){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.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(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*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(vn*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(-vn*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(vn*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(-vn*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(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*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 De,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 vT(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 bT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function ST(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(Km),this.state=pt.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 MT(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 cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=pt.DOLLY;break;case cr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}break;case cr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Th)}function wT(e){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function ET(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE)return;e.preventDefault(),this.dispatchEvent(Th),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Km)}function AT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function TT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=pt.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=pt.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Th)}function RT(e){switch(this._trackPointer(e),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=pt.NONE}}function CT(e){if(this.enabled===!1)return;e.preventDefault()}function PT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function IT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Ch extends Ps{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new $i({side:sn}),n=new $i,i=new Us(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 Ls(e,n,6),o=new gt;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,Vs(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,Vs(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,Vs(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,Vs(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,Vs(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,Vs(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 Vs(e){return new xc({color:0,emissive:16777215,emissiveIntensity:e})}function Ph(e,t){if(t===Hu)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Cs||t===yo){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===Cs)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 Qm(e){let t=new Map,n=new Map,i=e.clone();return eg(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 eg(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)eg(e.children[i],t.children[i],n)}class Fh extends Zi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new cg(t)}),this.register(function(t){return new lg(t)}),this.register(function(t){return new xg(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new vg(t)}),this.register(function(t){return new hg(t)}),this.register(function(t){return new dg(t)}),this.register(function(t){return new fg(t)}),this.register(function(t){return new pg(t)}),this.register(function(t){return new ag(t)}),this.register(function(t){return new mg(t)}),this.register(function(t){return new ug(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new gg(t)}),this.register(function(t){return new sg(t)}),this.register(function(t){return new Dh(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Dh(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new bg(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=vr.extractUrlBase(e);s=vr.resolveURL(c,this.path)}else s=vr.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 Lo(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))===Sg){try{s[Je.KHR_BINARY_GLTF]=new Mg(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Je.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 Rg(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 Je.KHR_MATERIALS_UNLIT:s[u]=new og;break;case Je.KHR_DRACO_MESH_COMPRESSION:s[u]=new wg(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:s[u]=new Eg;break;case Je.KHR_MESH_QUANTIZATION:s[u]=new Ag;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 LT(){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 Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Je={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 sg{constructor(e){this.parser=e,this.name=Je.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],wn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Fs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Us(l),c.distance=u;break;case"spot":c=new Mc(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),vi(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 og{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return _i}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],wn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,dr))}return Promise.all(i)}}class ag{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class cg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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 De(r,r)}}return Promise.all(i)}}class lg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class ug{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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 hg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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],wn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,dr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class dg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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 fg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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],wn),Promise.all(i)}}class pg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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 mg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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],wn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,dr));return Promise.all(i)}}class gg{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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 _g{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(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 xg{constructor(e){this.parser=e,this.name=Je.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 yg{constructor(e){this.parser=e,this.name=Je.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 vg{constructor(e){this.parser=e,this.name=Je.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 Dh{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 bg{constructor(e){this.name=Je.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!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.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 $e,_=new U,p=new Xt,g=new U(1,1,1),S=new Ls(f.geometry,f.material,h);for(let y=0;y<h;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new ar(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new on,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new ar(w.array,w.itemSize,w.normalized))}gt.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),d.push(S)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var Sg="glTF",Bo=12,tg={JSON:1313821514,BIN:5130562};class Mg{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Bo),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!==Sg)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-Bo,r=new DataView(e,Bo),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===tg.JSON){let c=new Uint8Array(e,Bo+s,o);this.content=n.decode(c)}else if(a===tg.BIN){let c=Bo+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class wg{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.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=Oh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Oh[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=Gs[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,wn,h)})})}}class Eg{constructor(){this.name=Je.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 Ag{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class zh 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-_,S=p-h+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var NT=new Xt;class Tg extends zh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return NT.fromArray(r).normalize().toArray(r),r}}var Vn={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},Gs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ng={9728:Qn,9729:qt,9984:Qa,9985:Ts,9986:Ur,9987:pi},ig={33071:As,33648:Ka,10497:Es},Ih={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Oh={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"},br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},DT={CUBICSPLINE:void 0,LINEAR:oc,STEP:Gu},Lh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function OT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ur});return e.DefaultMaterial}function Zr(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 vi(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 UT(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 FT(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 zT(e){let t,n=e.extensions&&e.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Nh(n.attributes);else t=e.indices+":"+Nh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Nh(e.targets[i]);return t}function Nh(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 Uh(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 kT(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 BT=new $e;class Rg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new LT,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 Ds(this.options.manager);else this.textureLoader=new wc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Lo(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 Zr(r,o,i),vi(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[Je.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(vr.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=Ih[i.type],o=Gs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(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=Ih[i.type],c=Gs[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,S=t.cache.get(g);if(!S)m=new c(o,p*d,i.count*d/l),S=new Mo(m,d/l),t.cache.add(g,S);_=new Is(S,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 jt(m,a,f)}if(i.sparse!==void 0){let p=Ih.SCALAR,g=Gs[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*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=ng[h.magFilter]||qt,l.minFilter=ng[h.minFilter]||pi,l.wrapS=ig[h.wrapS]||Es,l.wrapT=ig[h.wrapT]||Es,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Qn&&l.minFilter!==qt,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 Nt(m);_.needsUpdate=!0,h(_)};t.load(vr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return vi(u,s),u.userData.mimeType=s.mimeType||kT(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[Je.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Je.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 Co,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 Ro,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[Je.KHR_MATERIALS_UNLIT]){let u=i[Je.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 h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],wn),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,dr));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=kn;let l=r.alphaMode||Lh.OPAQUE;if(l===Lh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Lh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==_i){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new De(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==_i){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!==_i){let u=r.emissiveFactor;o.emissive=new Ue().setRGB(u[0],u[1],u[2],wn)}if(r.emissiveTexture!==void 0&&s!==_i)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,dr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(vi(u,r),t.associations.set(u,{materials:e}),r.extensions)Zr(i,u,r);return u})}createUniqueName(e){let t=ot.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[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return rg(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=zT(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=rg(new on,c,t);if(c.mode===Vn.TRIANGLE_STRIP)h=h.then((d)=>Ph(d,yo));else if(c.mode===Vn.TRIANGLE_FAN)h=h.then((d)=>Ph(d,Cs));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?OT(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===Vn.TRIANGLES||_.mode===Vn.TRIANGLE_STRIP||_.mode===Vn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new fc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Vn.LINES)p=new pc(m,g);else if(_.mode===Vn.LINE_STRIP)p=new pr(m,g);else if(_.mode===Vn.LINE_LOOP)p=new mc(m,g);else if(_.mode===Vn.POINTS)p=new Ns(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)FT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),vi(p,r),_.extensions)Zr(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)Zr(i,u[0],r);return u[0]}let h=new ui;if(r.extensions)Zr(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 Vt(vo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new $r(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return vi(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 $e;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 Ao(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 S=0,T=h.length;S<T;S++){let y=h[S],w=d[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let z=0;z<M.length;z++)p.push(M[z])}let g=new bs(r,void 0,p);return vi(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,BT)});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 U().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 wo;else if(c.length>1)l=new ui;else if(c.length===1)l=c[0];else l=new gt;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(vi(l,r),r.extensions)Zr(n,l,r);if(r.matrix!==void 0){let u=new $e;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 ui;if(n.name)r.name=i.createUniqueName(n.name);if(vi(r,n),n.extensions)Zr(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(Qm(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 Nt)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(br[r.path]===br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(br[r.path]){case br.weights:l=_r;break;case br.rotation:l=xr;break;case br.translation:case br.scale:l=Hr;break;default:switch(n.itemSize){case 1:l=_r;break;case 2:case 3:default:l=Hr;break}break}let u=i.interpolation!==void 0?DT[i.interpolation]:oc,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+br[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=Uh(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 xr?Tg:zh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function VT(e,t,n){let i=t.attributes,r=new Gt;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 U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=Uh(Gs[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 U,c=new U;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 _=Uh(Gs[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 An;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function rg(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=Oh[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(je.workingColorSpace!==wn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`);return vi(e,t),VT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?UT(e,t.targets,n):e})}function Go(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 Bh(e,t="|"){return e.map((n)=>Hh(n)).join(t)}function Ho(e,t){if(typeof t==="bigint")return t.toString();return t}class Cg{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 $o(e){return new Cg(e)}function Pg(e){return e===null||e===void 0}function Mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ig(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 Gn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xi(e){return Wo(e._zod.def)??e._zod.def.shape}function Lg(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Gn(this,t,i),i},enumerable:!0,configurable:!0})}function Ng(e,t,n){if(t in e)Gn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Xi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Lg(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Ng(e,s,i?i(o.value,s):o.value)}}function GT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Lg(e,n,()=>t[n]);else Ng(e,n,i.value)}}function Cn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Dg(e){return JSON.stringify(e)}function Og(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Vh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Hs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ug=$o(()=>{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 jr(e){if(Hs(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(Hs(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Gh(e){if(jr(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 Fg=new Set(["string","number","symbol"]),zg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bi(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 Hh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function kg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Lc=(()=>({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]}))(),$h={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function HT(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 Xr(s,e,Nc(e,t)),bi(e,Cn(n,{shape:s,checks:[]}))}function Nc(e,t){let n=Xi(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 $T(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(Nc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Xi(e)).filter((a)=>!s.has(a))),bi(e,Cn(n,{shape:o,checks:[]}))}function WT(e,t){if(!jr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Xi(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 bi(e,Cn(e._zod.def,{shape:Bg(e,t)}))}function Bg(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Xi(e))),GT(n,t),n}function ZT(e,t){if(!jr(t))throw Error("Invalid input to safeExtend: expected a plain object");return bi(e,Cn(e._zod.def,{shape:Bg(e,t)}))}function XT(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={};Xr(n,e,Reflect.ownKeys(Xi(e))),Xr(n,t,Reflect.ownKeys(Xi(t)));let i=Cn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bi(e,i)}function Vg(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(Nc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Xi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),bi(t,Cn(t._zod.def,{shape:c,checks:[]}))}function jT(e,t,n){let i=n?new Set(Nc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Xi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),bi(t,Cn(t._zod.def,{shape:r}))}function Hn(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 Gg(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 Si(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Vo(e){return typeof e==="string"?e:e?.message}function Wh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Mi(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:Vo(e.inst?._zod.def?.error?.(e))??Vo(s?.(e))??Vo(t?.error?.(e))??Vo(n.customError?.(e))??Vo(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 qT=/[\uD800-\uDBFF]/;function Dc(e){let t=e.length;if(!qT.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 Hg(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 qr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function $g(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else YT(e,n,i.value)}}function ji(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Uc(e,t,n){return ji(e,t,n,!1)}function Wg(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return ji(this,n,i(this))},set(r){ji(this,n,r)}})}return t}function YT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ji(this,t,n.bind(this))},set(i){ji(this,t,i)}})}function JT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var kh,Sr=!1,KT={configurable:!0,get(){Sr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&kh!==e._zod){kh=void 0;return}kh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,KT);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 QT(e,t,n,i){let r=JT(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 e1="~constantCatch";function Zg(e){let t=()=>e;return t[e1]=!0,t}var Xg;var Zh={value:void 0,enumerable:!1},jg="captureStackTrace"in Error?Error:null;function t1(e){let t=jg;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return jg=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(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){Zh.value=new s(f);try{Object.defineProperty(d,"_zod",Zh)}finally{Zh.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 S=g??_;if(!a.has(S))a.add(S),$g(S,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?t1(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 wi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Zo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Xg=globalThis).__zod_globalConfig??(Xg.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Pn(e){if(e)Object.assign(dn,e);return dn}function n1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ho,2)),e.message}function i1(e){this._zod.message=e}var r1={get:n1,set:i1,enumerable:!0,configurable:!0},jh={value:void 0,enumerable:!1},qg=new WeakSet([Object.prototype,Error.prototype]),Yg=(e,t)=>{e.name="$ZodError",jh.value=t,Object.defineProperty(e,"issues",jh),jh.value=void 0,Object.defineProperty(e,"message",r1);let n=Object.getPrototypeOf(e);if(!qg.has(n))qg.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})}})},Jg=J("$ZodError",Yg),EN=J("$ZodError",Yg,void 0,{Parent:Error});function s1(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 Kg(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)s1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Qg(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 Fc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var zc=(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 wi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Mi(l,o,Pn())));throw Vh(c,s?.callee??t),c}return a.value};return t};var kc=(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)=>Mi(l,o,Pn())));throw Vh(c,s?.callee??t),c}return a.value};return t};var Bc=(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 wi;return s.issues.length?e_(e,s.issues,r):{success:!0,data:s.value}};function e_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Mi(r,n,Pn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Vc=(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?e_(e,s.issues,r):{success:!0,data:s.value}};var o1=Symbol.for("zod.compile.invalid"),a1=Symbol.for("zod.compile.fallback"),qh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==o1)return!0;if(i.definite===!0&&n===void 0)return!1}return c1(e,t,n)};function c1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[a1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new wi;return s.issues.length===0}var Yh=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},t_=(e)=>{let t=zc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Fc(n,o))};return n};var n_=(e)=>{let t=zc(e),n=(i,r,s,o)=>t(i,r,s,Fc(n,o));return n};var i_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Fc(n,o))};return n};var r_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>await t(i,r,s,Fc(n,o));return n};var s_=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Bc(e)(t,n,r)};var o_=(e)=>(t,n,i)=>Bc(e)(t,n,i);var a_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Vc(e)(t,n,r)};var c_=(e)=>async(t,n,i)=>Vc(e)(t,n,i);var l_=/^[cC][0-9a-z]{6,}$/,u_=/^[0-9a-z]+$/,h_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,d_=/^[0-9a-vA-V]{20}$/,f_=/^[A-Za-z0-9]{27}$/,p_=/^[a-zA-Z0-9_-]{21}$/;function m_(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var g_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var __=/^([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})$/,Kh=(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 x_=/^(?:[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 l1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function y_(){return new RegExp(l1,"u")}var v_=/^(?:(?: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])$/,b_=/^(([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 S_=/^((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])$/,M_=/^(([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])$/,w_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,E_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var A_=/^https?$/,T_=/^\+[1-9]\d{6,14}$/;var R_="(?:(?:\\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 u1(e){return new RegExp(`^${e}$`)}var C_=u1(R_);function Jh(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 P_(e){return new RegExp(`^${Jh(e)}$`)}function I_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Jh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Jh({precision:e.precision})}`:n;return new RegExp(`^${R_}T(?:${i})$`)}var L_=/^[\s\S]{0,}$/,N_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Gc=/^-?\d+$/,$s=/^-?\d+(?:\.\d+)?$/,D_=/^(?:true|false)$/i;var O_=/^[^A-Z]*$/,U_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Qh=(e)=>{let t=e.value;return!Pg(t)&&t.length!==void 0},Hc={number:"number",bigint:"bigint",object:"date"},ed=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Hc[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})}}),td=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Hc[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})}}),F_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.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):Ig(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})}}),z_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Lc[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 k_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=Qh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Dc(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})}}),B_=J("$ZodCheckMinLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=Qh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Dc(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})}}),V_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=Qh),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Dc(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})}}),jo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.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=()=>{})}),G_=J("$ZodCheckRegex",(e,t)=>{jo.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})}}),H_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=O_),jo.init(e,t)}),$_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=U_),jo.init(e,t)}),W_=J("$ZodCheckIncludes",(e,t)=>{Kt.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})}}),Z_=J("$ZodCheckStartsWith",(e,t)=>{Kt.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})}}),X_=J("$ZodCheckEndsWith",(e,t)=>{Kt.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 j_=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class nd{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 jm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new _c(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 Bn({vertexShader:xT,fragmentShader:yT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new Lo(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class qm extends ei{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,d=null,h=null,f=null,m=typeof XRWebGLBinding<"u",_=new jm,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new Ue,R=null,x=null,M=new Vt;M.viewport=new ft;let z=new Vt;z.viewport=new ft;let C=[M,z],L=new uh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new wo,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new wo,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new wo,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),h=null,d=null,u=null,i=null,T=null,we.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:h},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(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),T=new wn(h.framebufferWidth,h.framebufferHeight,{format:mi,type:Qn,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?zr:Fr,xe=g.stencil?Cs:hr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ae),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new wn(d.textureWidth,d.textureHeight,{format:mi,type:Qn,depthTexture:new Vr(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=w.indexOf(se);if(xe>=0)w[xe]=null,y[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=w.indexOf(se);if(xe===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),xe=Ae;break}else if(w[Ae]===null){w[Ae]=se,xe=Ae;break}if(xe===-1)break}let Ee=y[xe];if(Ee)Ee.connect(se)}}let j=new U,k=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=j.distanceTo(k),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,Et=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],ht=(Ee[9]-1)/Ee[5],nt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],At=Et*nt,gn=Et*Jt,kt=xe/(-nt+Jt),Bt=kt*-nt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(kt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=Et+kt,_n=Ge+kt,ct=At-Bt,Pt=gn+(xe-Bt),E=Ye*Ge/_n*D,v=ht*Ge/_n*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,_n),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(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=z.near=M.near=re,L.far=z.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,z.layers.mask=L.layers.mask&-3;let xe=Z.parent,Ee=L.cameras;Q(L,xe);for(let Ae=0;Ae<Ee.length;Ae++)Q(Ee[Ae],xe);if(Ee.length===2)q(L,M,z);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Me(Z,L,xe)};function Me(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=Dr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(d===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,d!==null)d.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Be(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(T,h.framebuffer),e.setRenderTarget(T);let xe=!1;if(se.length!==L.cameras.length)L.cameras.length=0,xe=!0;for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge],ht=null;if(h!==null)ht=h.getViewport(Ye);else{let Jt=u.getViewSubImage(d,Ye);if(ht=Jt.viewport,Ge===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ge];if(nt===void 0)nt=new Vt,nt.layers.enable(Ge),nt.viewport=new ft,C[Ge]=nt;if(nt.matrix.fromArray(Ye.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Ye.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(ht.x,ht.y,ht.width,ht.height),Ge===0)L.matrix.copy(nt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(xe===!0)L.cameras.push(nt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ge=u.getDepthInformation(se[0]);if(Ge&&Ge.isValid&&Ge.texture)_.init(Ge,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge].camera;if(Ye){let ht=p[Ye];if(!ht)ht=new _c,p[Ye]=ht;let nt=u.getCameraImage(Ye);ht.sourceTexture=nt}}}}for(let se=0;se<y.length;se++){let xe=w[se],Ee=y[se];if(xe!==null&&Ee!==void 0)Ee.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let we=new Fm;we.setAnimationLoop(Be),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var vT=new $e,Ym=new Ve;Ym.set(-1,0,0,0,1,0,0,0,1);function bT(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,eh(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,S,T,y){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),d(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),h(p,g),g.isMeshPhysicalMaterial)f(p,g,y)}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,S,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===sn)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===sn)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 S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(vT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Ym);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,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,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 d(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function h(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,S){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===sn)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=S.texture,p.transmissionSamplerSize.value.set(S.width,S.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 S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ST(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)h(y),s[y.id]=x}function u(y){let w=d();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function d(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let z=A[x];if(Array.isArray(z))for(let C=0,L=z.length;C<L;C++)f(z[C],x,C,R);else f(z,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let z=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,z),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))z+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let z=R[M];if(typeof x==="number"||typeof x==="boolean"){if(z!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(z.equals(x)===!1)return z.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,z=w.length;M<z;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],k=g(j),q=A%R,Q=q%k.boundary,Me=q+Q;if(A+=Q,Me!==0&&R-Me<k.storage)A+=R-Me;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=k.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var MT=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]),_i=null;function wT(){if(_i===null)_i=new To(MT,16,16,kr,pi),_i.name="DFG_LUT",_i.minFilter=qt,_i.magFilter=qt,_i.wrapS=Ts,_i.wrapT=Ts,_i.generateMipmaps=!1,_i.needsUpdate=!0;return _i}class Ah{constructor(e={}){let{canvas:t=im(),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:d=!1,outputBufferType:h=Qn}=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=h,_=new Set([du,hu,uu]),p=new Set([Qn,hr,vo,Cs,cu,lu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],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=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,z=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=dr;let G=0,X=0,P=null,j=-1,k=null,q=new ft,Q=new ft,Me=null,ue=new ze(0),Be=0,{width:we,height:Z}=t,re=1,se=null,xe=null,Ee=new ft(0,0,we,Z),Ae=new ft(0,0,we,Z),Et=!1,Ge=new Co,Ye=!1,ht=!1,nt=new $e,Jt=new U,At=new ft,gn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},kt=!1;function Bt(){return P===null?re:1}let D=n;function _n(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,_e,Ie,de,oe,De,Fe,st,F,ce,ee,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${lp}`);if(t.addEventListener("webglcontextlost",He,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",lt,!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.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ke("WebGLRenderer: "+b.message),b}function ne(){if(ct=new IE(D),ct.init(),ee=new _T(D,ct),Pt=new bE(D,ct,e,ee),E=new mT(D,ct),Pt.reversedDepthBuffer&&d)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new DE(D),N=new tT,H=new gT(D,ct,E,N,Pt,ee,v),ie=new PE(M),ae=new US(D),le=new yE(D,ae),he=new LE(D,ae,v,le),Y=new UE(D,he,ae,le,v),st=new OE(D,Pt,H),oe=new SE(N),te=new eT(M,ie,ct,Pt,le,oe),_e=new bT(M,N),Ie=new iT,de=new lT(ct),Fe=new xE(M,ie,E,Y,f,a),De=new pT(M,Y,Pt),ye=new ST(D,v,Pt,E),F=new vE(D,ct,v),ce=new NE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=De,M.state=E,M.info=v}if(m!==Qn)x=new zE(m,t.width,t.height,o,i,r);let pe=new qm(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.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(we,Z,!1)},this.getSize=function(b){return b.set(we,Z)},this.setSize=function(b,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(we=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(we*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){we=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===Qn){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("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(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(Q.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(b){E.setScissorTest(Et=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,Se=p.has(ge),me=Fe.getClearColor(),Te=Fe.getClearAlpha(),{r:Pe,g:We,b:Ke}=me;if(Se)g[0]=Pe,g[1]=We,g[2]=Ke,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=We,S[2]=Ke,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.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",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Fe.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",_f),pe.removeEventListener("sessionend",xf),Rr.stop()};function He(b){b.preventDefault(),mo("WebGLRenderer: Context Lost."),z=!0}function bt(){mo("WebGLRenderer: Context Restored."),z=!1;let b=v.autoReset,O=De.enabled,W=De.autoUpdate,B=De.needsUpdate,V=De.type;ne(),v.autoReset=b,De.enabled=O,De.autoUpdate=W,De.needsUpdate=B,De.type=V}function lt(b){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let O=b.target;O.removeEventListener("dispose",oi),Di(O)}function Di(b){Ab(b),N.remove(b)}function Ab(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=gn;let Se=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Cb(b,O,W,B,V);E.setMaterial(B,Se);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let We=W.drawRange,Ke=W.attributes.position,Re=We.start*Pe,ut=(We.start+We.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ut=Math.min(ut,Ke.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let Tt,xt=F;if(Te!==null)Tt=ae.get(Te),xt=ce,xt.setIndex(Tt);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(V.isLine){let tn=B.linewidth;if(tn===void 0)tn=1;if(E.setLineWidth(tn*Bt()),V.isLineSegments)xt.setMode(D.LINES);else if(V.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(V.isPoints)xt.setMode(D.POINTS);else if(V.isSprite)xt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:tn,_multiDrawCounts:ve,_multiDrawCount:un}=V,it=Te?ae.get(Te).bytesPerElement:1,On=N.get(B).currentProgram.getUniforms();for(let ai=0;ai<un;ai++)On.setValue(D,"_gl_DrawID",ai),xt.render(tn[ai]/it,ve[ai])}else xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)xt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let tn=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,tn);xt.renderInstances(Re,Ft,ve)}else xt.render(Re,Ft)};function gf(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ye===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===kn&&b.forceSinglePass===!1)b.side=sn,b.needsUpdate=!0,ba(b,O,B),b.side=ur,b.needsUpdate=!0,ba(b,O,B),b.side=kn;else ba(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),Ye===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)De.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let Se=0;Se<ge.length;Se++){let me=ge[Se];gf(me,W,O,V),B.add(me)}else gf(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(Se){let Te=N.get(Se).currentProgram;if(Te===void 0||Te.isReady())B.delete(Se)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Ml=null;function Tb(b){if(Ml)Ml(b)}function _f(){Rr.stop()}function xf(){Rr.start()}let Rr=new Fm;if(Rr.setAnimationLoop(Tb),typeof self<"u")Rr.setContext(self);this.setAnimationLoop=function(b){Ml=b,pe.setAnimationLoop(b),b===null?Rr.stop():Rr.start()},pe.addEventListener("sessionstart",_f),pe.addEventListener("sessionend",xf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ge.setFromProjectionMatrix(nt,ju,O.reversedDepth),ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let Se=M.xr.getDepthSensingMesh();if(Se!==null)wl(Se,O,-1/0,M.sortObjects)}if(wl(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,xe);if(kt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,kt)Fe.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ye===!0)oe.beginShadows();let V=w.state.shadowsArray;if(De.render(V,b,O),Ye===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let Se=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];vf(Se,me,b,Ke)}if(kt)Fe.render(b);for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];yf(y,b,Ke,Ke.viewport)}}else{if(me.length>0)vf(Se,me,b,O);if(kt)Fe.render(b);yf(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,k=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Ye===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function wl(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ge)){if(B)At.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Se=Y.update(b),me=b.material;if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ge)){let Se=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();At.copy(b.boundingSphere.center)}else{if(Se.boundingSphere===null)Se.computeBoundingSphere();At.copy(Se.boundingSphere.center)}At.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(me)){let Te=Se.groups;for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe],Re=me[Ke.materialIndex];if(Re&&Re.visible)y.push(b,Se,Re,W,At.z,Ke,O)}}else if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}}let ge=b.children;for(let Se=0,me=ge.length;Se<me;Se++)wl(ge[Se],O,W,B)}function yf(b,O,W,B){let{opaque:V,transmissive:ge,transparent:Se}=b;if(w.setupLightsView(W),Ye===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)va(V,O,W);if(ge.length>0)va(ge,O,W);if(Se.length>0)va(Se,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function vf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new wn(1,1,{generateMipmaps:!0,type:Re?pi:Qn,minFilter:fi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],Se=B.viewport||q;ge.setSize(Se.z*M.transmissionResolutionScale,Se.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Be=M.getClearAlpha(),Be<1)M.setClearColor(16777215,0.5);if(M.clear(),kt)Fe.render(W);let We=M.toneMapping;M.toneMapping=Jn;let Ke=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Ye===!0)oe.setGlobalState(M.clippingPlanes,B);if(va(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let Tt=O[ut],{object:xt,geometry:tn,material:ve,group:un}=Tt;if(ve.side===kn&&xt.layers.test(B.layers)){let it=ve.side;ve.side=sn,ve.needsUpdate=!0,bf(xt,W,B,tn,ve,un),ve.side=it,ve.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Be),Ke!==void 0)B.viewport=Ke;M.toneMapping=We}function va(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let Se=b[V],{object:me,geometry:Te,group:Pe}=Se,We=Se.material;if(We.allowOverride===!0&&B!==null)We=B;if(me.layers.test(W.layers))bf(me,O,W,Te,We,Pe)}}function bf(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===kn&&V.forceSinglePass===!1)V.side=sn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=ur,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=kn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function ba(b,O,W){if(O.isScene!==!0)O=gn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,Se=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let We=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,We),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",oi),Pe=new Map,B.programs=Pe;let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===Se)return Mf(b,me),Ke}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Ke=te.acquireProgram(me,Te),Pe.set(Te,Ke),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(Mf(b,me),B.needsLights=Ib(b),B.lightsStateVersion=Se,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function Sf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=Bo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function Mf(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Rb(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Cb(b,O,W,B,V){if(O.isScene!==!0)O=gn;H.resetTextureUnits();let ge=O.fog,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:je.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||Se,Te),We=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ke=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,Tt=Jn;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)Tt=M.toneMapping}let xt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,tn=xt!==void 0?xt.length:0,ve=N.get(B),un=w.state.lights;if(Ye===!0){if(ht===!0||b!==k){let St=b===k&&B.id===j;oe.setState(B,b,St)}}let it=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==un.state.version)it=!0;else if(ve.outputColorSpace!==me)it=!0;else if(V.isBatchedMesh&&ve.batching===!1)it=!0;else if(!V.isBatchedMesh&&ve.batching===!0)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!0&&V._colorsTexture===null)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!1&&V._colorsTexture!==null)it=!0;else if(V.isInstancedMesh&&ve.instancing===!1)it=!0;else if(!V.isInstancedMesh&&ve.instancing===!0)it=!0;else if(V.isSkinnedMesh&&ve.skinning===!1)it=!0;else if(!V.isSkinnedMesh&&ve.skinning===!0)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!0&&V.instanceColor===null)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!1&&V.instanceColor!==null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!0&&V.morphTexture===null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!1&&V.morphTexture!==null)it=!0;else if(ve.envMap!==Pe)it=!0;else if(B.fog===!0&&ve.fog!==ge)it=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))it=!0;else if(ve.vertexAlphas!==We)it=!0;else if(ve.vertexTangents!==Ke)it=!0;else if(ve.morphTargets!==Re)it=!0;else if(ve.morphNormals!==ut)it=!0;else if(ve.morphColors!==Ft)it=!0;else if(ve.toneMapping!==Tt)it=!0;else if(ve.morphTargetsCount!==tn)it=!0;else if(!!ve.lightProbeGrid!==w.state.lightProbeGridArray.length>0)it=!0}else it=!0,ve.__version=B.version;let On=ve.currentProgram;if(it===!0){if(On=ba(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,On,ve)}let ai=!1,Ki=!1,is=!1,mt=On.getUniforms(),Ot=ve.uniforms;if(E.useProgram(On.program))ai=!0,Ki=!0,is=!0;if(B.id!==j)j=B.id,Ki=!0;if(ve.needsLights){let St=Rb(w.state.lightProbeGridArray,V);if(ve.lightProbeGrid!==St)ve.lightProbeGrid=St,Ki=!0}if(ai||k!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();mt.setValue(D,"projectionMatrix",b.projectionMatrix),mt.setValue(D,"viewMatrix",b.matrixWorldInverse);let er=mt.map.cameraPosition;if(er!==void 0)er.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)mt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)mt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ki=!0,is=!0}if(ve.needsLights){if(un.state.sunShadowMap.length>0)mt.setValue(D,"sunShadowMap",un.state.sunShadowMap,H);if(un.state.directionalShadowMap.length>0)mt.setValue(D,"directionalShadowMap",un.state.directionalShadowMap,H);if(un.state.spotShadowMap.length>0)mt.setValue(D,"spotShadowMap",un.state.spotShadowMap,H);if(un.state.pointShadowMap.length>0)mt.setValue(D,"pointShadowMap",un.state.pointShadowMap,H)}if(V.isSkinnedMesh){mt.setOptional(D,V,"bindMatrix"),mt.setOptional(D,V,"bindMatrixInverse");let St=V.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();mt.setValue(D,"boneTexture",St.boneTexture,H)}}if(V.isBatchedMesh){if(mt.setOptional(D,V,"batchingTexture"),mt.setValue(D,"batchingTexture",V._matricesTexture,H),mt.setOptional(D,V,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",V._indirectTexture,H),mt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)mt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let Qi=W.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)st.update(V,W,On);if(Ki||ve.receiveShadow!==V.receiveShadow)ve.receiveShadow=V.receiveShadow,mt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=wT();if(Ki){if(mt.setValue(D,"toneMappingExposure",M.toneMappingExposure),ve.needsLights)Pb(Ot,is);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ot,ge);if(_e.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let St=ve.lightProbeGrid;Ot.probesSH.value=St.texture,Ot.probesMin.value.copy(St.boundingBox.min),Ot.probesMax.value.copy(St.boundingBox.max),Ot.probesResolution.value.copy(St.resolution)}Bo.upload(D,Sf(ve),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)Bo.upload(D,Sf(ve),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)mt.setValue(D,"center",V.center);if(mt.setValue(D,"modelViewMatrix",V.modelViewMatrix),mt.setValue(D,"normalMatrix",V.normalMatrix),mt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let St=B.uniformsGroups;for(let er=0,rs=St.length;er<rs;er++){let Ef=St[er];ye.update(Ef,On),ye.bind(Ef,On)}}return On}function Pb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function Ib(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest,E.viewport(q),E.scissor(Q),E.setScissorTest(Me),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let We=b.depthTexture;if(me.__boundDepthTexture!==We){if(We!==null&&N.has(We)&&(b.width!==We.image.width||b.height!==We.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),Q.copy(Ae).multiplyScalar(re).floor(),Me=Et;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(Q),E.setScissorTest(Me),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function wf(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=wf(Pe);if(Re.__formatReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=wf(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let Tt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await sm(D,Tt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(Tt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Se=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,Se,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let Se,me,Te,Pe,We,Ke,Re,ut,Ft,Tt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)Se=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Pe=W.min.x,We=W.min.y,Ke=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(Se=Math.floor(Tt.width*Ot),me=Math.floor(Tt.height*Ot),b.isDataArrayTexture)Te=Tt.depth;else if(b.isData3DTexture)Te=Math.floor(Tt.depth*Ot);else Te=1;Pe=0,We=0,Ke=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let xt=ee.convert(O.format),tn=ee.convert(O.type),ve;if(O.isData3DTexture)H.setTexture3D(O,0),ve=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),ve=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),ve=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let un=E.getParameter(D.UNPACK_ROW_LENGTH),it=E.getParameter(D.UNPACK_IMAGE_HEIGHT),On=E.getParameter(D.UNPACK_SKIP_PIXELS),ai=E.getParameter(D.UNPACK_SKIP_ROWS),Ki=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,Tt.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Tt.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,We),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ke);let is=b.isDataArrayTexture||b.isData3DTexture,mt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),Qi=N.get(O),St=N.get(Ot.__renderTarget),er=N.get(Qi.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,er.__webglFramebuffer);for(let rs=0;rs<Te;rs++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Ke+rs),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+rs);D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),Qi=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let St=0;St<Te;St++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Ke+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(mt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Qi.__webglTexture,ge,Ft+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Qi.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(mt)D.copyTexSubImage3D(ve,ge,Re,ut,Ft+St,Pe,We,Se,me);else D.copyTexSubImage2D(ve,ge,Re,ut,Pe,We,Se,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(mt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,tn,Tt.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,Tt.data);else D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,tn,Tt);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,tn,Tt.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,Tt.width,Tt.height,xt,Tt.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,tn,Tt);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,un),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,it),E.pixelStorei(D.UNPACK_SKIP_PIXELS,On),E.pixelStorei(D.UNPACK_SKIP_ROWS,ai),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ki),ge===0&&O.generateMipmaps)D.generateMipmap(ve);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ju}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var Km={type:"change"},Rh={type:"start"},eg={type:"end"},Ic=new fr,Qm=new Fn,ET=Math.cos(70*So.DEG2RAD),Wt=new U,vn=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Th=0.000001;class Ch extends Ac{constructor(e,t=null){super(e,t);if(this.state=pt.NONE,this.target=new U,this.cursor=new U,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:cr.ROTATE,MIDDLE:cr.DOLLY,RIGHT:cr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.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 U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Uo,this._sphericalDelta=new Uo,this._scale=1,this._panOffset=new U,this._rotateStart=new Ue,this._rotateEnd=new Ue,this._rotateDelta=new Ue,this._panStart=new Ue,this._panEnd=new Ue,this._panDelta=new Ue,this._dollyStart=new Ue,this._dollyEnd=new Ue,this._dollyDelta=new Ue,this._dollyDirection=new U,this._mouse=new Ue,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=TT.bind(this),this._onPointerDown=AT.bind(this),this._onPointerUp=RT.bind(this),this._onContextMenu=OT.bind(this),this._onMouseWheel=IT.bind(this),this._onKeyDown=LT.bind(this),this._onTouchStart=NT.bind(this),this._onTouchMove=DT.bind(this),this._onMouseDown=CT.bind(this),this._onMouseMove=PT.bind(this),this._interceptControlDown=UT.bind(this),this._interceptControlUp=FT.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=pt.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(Km),this.update(),this.state=pt.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(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===pt.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+=vn;else if(n>Math.PI)n-=vn;if(i<-Math.PI)i+=vn;else if(i>Math.PI)i-=vn;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(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),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=Wt.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 U(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 U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.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(Ic.origin.copy(this.object.position),Ic.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ic.direction))<ET)this.object.lookAt(this.target);else Qm.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ic.intersectPlane(Qm,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)>Th||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Th||this._lastTargetPosition.distanceToSquared(this.target)>Th)return this.dispatchEvent(Km),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 vn/60*this.autoRotateSpeed*e;else return vn/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){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.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(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*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(vn*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(-vn*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(vn*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(-vn*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(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*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 Ue,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 AT(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 TT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function RT(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(eg),this.state=pt.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 CT(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 cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=pt.DOLLY;break;case cr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}break;case cr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Rh)}function PT(e){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function IT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE)return;e.preventDefault(),this.dispatchEvent(Rh),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(eg)}function LT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function NT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=pt.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=pt.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Rh)}function DT(e){switch(this._trackPointer(e),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=pt.NONE}}function OT(e){if(this.enabled===!1)return;e.preventDefault()}function UT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function FT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Ph extends Is{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new Hi({side:sn}),n=new Hi,i=new Fs(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 Ns(e,n,6),o=new gt;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,Gs(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,Gs(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,Gs(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,Gs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new Mt(e,Gs(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let h=new Mt(e,Gs(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 Gs(e){return new xc({color:0,emissive:16777215,emissiveIntensity:e})}function Ih(e,t){if(t===$u)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Ps||t===bo){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===Ps)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 tg(e){let t=new Map,n=new Map,i=e.clone();return ng(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 ng(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)ng(e.children[i],t.children[i],n)}class zh extends Wi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ug(t)}),this.register(function(t){return new hg(t)}),this.register(function(t){return new vg(t)}),this.register(function(t){return new bg(t)}),this.register(function(t){return new Sg(t)}),this.register(function(t){return new fg(t)}),this.register(function(t){return new pg(t)}),this.register(function(t){return new mg(t)}),this.register(function(t){return new gg(t)}),this.register(function(t){return new lg(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new dg(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new xg(t)}),this.register(function(t){return new ag(t)}),this.register(function(t){return new Oh(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Oh(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Mg(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=vr.extractUrlBase(e);s=vr.resolveURL(c,this.path)}else s=vr.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 Do(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))===wg){try{s[Je.KHR_BINARY_GLTF]=new Eg(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Je.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 Pg(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],d=r.extensionsRequired||[];switch(u){case Je.KHR_MATERIALS_UNLIT:s[u]=new cg;break;case Je.KHR_DRACO_MESH_COMPRESSION:s[u]=new Ag(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:s[u]=new Tg;break;case Je.KHR_MESH_QUANTIZATION:s[u]=new Rg;break;default:if(d.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 zT(){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 Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Je={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 ag{constructor(e){this.parser=e,this.name=Je.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 ze(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Mn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new zs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Fs(l),c.distance=u;break;case"spot":c=new Mc(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),yi(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 cg{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return gi}extendParams(e,t,n){let i=[];e.color=new ze(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],Mn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,dr))}return Promise.all(i)}}class lg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class ug{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 Ue(r,r)}}return Promise.all(i)}}class hg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class dg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 fg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new ze(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],Mn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,dr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class pg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 mg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 ze().setRGB(r[0],r[1],r[2],Mn),Promise.all(i)}}class gg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 _g{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 ze().setRGB(r[0],r[1],r[2],Mn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,dr));return Promise.all(i)}}class xg{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 yg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(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 vg{constructor(e){this.parser=e,this.name=Je.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 bg{constructor(e){this.parser=e,this.name=Je.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 Sg{constructor(e){this.parser=e,this.name=Je.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 Oh{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,d=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,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,d,i.mode,i.filter),h})})}else return null}}class Mg{constructor(e){this.name=Je.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!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.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],d=c[0].count,h=[];for(let f of u){let m=new $e,_=new U,p=new Xt,g=new U(1,1,1),S=new Ns(f.geometry,f.material,d);for(let y=0;y<d;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new ar(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new on,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new ar(w.array,w.itemSize,w.normalized))}gt.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),h.push(S)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var wg="glTF",Go=12,ig={JSON:1313821514,BIN:5130562};class Eg{constructor(e){this.name=Je.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!==wg)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===ig.JSON){let c=new Uint8Array(e,Go+s,o);this.content=n.decode(c)}else if(a===ig.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 Ag{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.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=Uh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Uh[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],h=Hs[d.componentType];c[u]=h.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(h){for(let f in h.attributes){let m=h.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(h)},o,c,Mn,d)})})}}class Tg{constructor(){this.name=Je.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 Rg{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class kh extends $i{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,d=u*u,h=d*u,f=e*c,m=f-c,_=-2*h+3*d,p=h-d,g=1-_,S=p-d+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var kT=new Xt;class Cg extends kh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return kT.fromArray(r).normalize().toArray(r),r}}var Vn={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},Hs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},rg={9728:Kn,9729:qt,9984:Qa,9985:Rs,9986:Ur,9987:fi},sg={33071:Ts,33648:Ka,10497:As},Lh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Uh={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"},br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},BT={CUBICSPLINE:void 0,LINEAR:oc,STEP:Hu},Nh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function VT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Hi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ur});return e.DefaultMaterial}function Zr(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 yi(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 GT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.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 d=t[l];if(i){let h=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;o.push(h)}if(r){let h=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=d.COLOR_0!==void 0?n.getDependency("accessor",d.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],d=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function HT(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[Je.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Dh(n.attributes);else t=e.indices+":"+Dh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Dh(e.targets[i]);return t}function Dh(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 Fh(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 WT(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 ZT=new $e;class Pg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new zT,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 Os(this.options.manager);else this.textureLoader=new wc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Do(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 Zr(r,o,i),yi(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[Je.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(vr.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=Lh[i.type],o=Hs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(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=Lh[i.type],c=Hs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(h&&h!==u){let p=Math.floor(d/h),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,S=t.cache.get(g);if(!S)m=new c(o,p*h,i.count*h/l),S=new Eo(m,h/l),t.cache.add(g,S);_=new Ls(S,a,d%h/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,d,i.count*a);_=new jt(m,a,f)}if(i.sparse!==void 0){let p=Lh.SCALAR,g=Hs[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*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 d=(r.samplers||{})[s.sampler]||{};return l.magFilter=rg[d.magFilter]||qt,l.minFilter=rg[d.minFilter]||fi,l.wrapS=sg[d.wrapS]||As,l.wrapT=sg[d.wrapT]||As,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Kn&&l.minFilter!==qt,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 d=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(d),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(d,h){let f=d;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Nt(m);_.needsUpdate=!0,d(_)};t.load(vr.resolveURL(u,r.path),f,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return yi(u,s),u.userData.mimeType=s.mimeType||WT(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[Je.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Je.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 Io,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 Po,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 Hi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Je.KHR_MATERIALS_UNLIT]){let u=i[Je.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new ze(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Mn),o.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,dr));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(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=kn;let l=r.alphaMode||Nh.OPAQUE;if(l===Nh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Nh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ue(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==gi){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!==gi){let u=r.emissiveFactor;o.emissive=new ze().setRGB(u[0],u[1],u[2],Mn)}if(r.emissiveTexture!==void 0&&s!==gi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,dr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(yi(u,r),t.associations.set(u,{materials:e}),r.extensions)Zr(i,u,r);return u})}createUniqueName(e){let t=ot.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[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return og(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 d;if(c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=og(new on,c,t);if(c.mode===Vn.TRIANGLE_STRIP)d=d.then((h)=>Ih(h,bo));else if(c.mode===Vn.TRIANGLE_FAN)d=d.then((h)=>Ih(h,Ps));i[l]={primitive:c,promise:d},s.push(d)}}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?VT(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,f=l.length;h<f;h++){let m=l[h],_=s[h],p,g=c[h];if(_.mode===Vn.TRIANGLES||_.mode===Vn.TRIANGLE_STRIP||_.mode===Vn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new fc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Vn.LINES)p=new pc(m,g);else if(_.mode===Vn.LINE_STRIP)p=new pr(m,g);else if(_.mode===Vn.LINE_LOOP)p=new mc(m,g);else if(_.mode===Vn.POINTS)p=new Ds(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)HT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),yi(p,r),_.extensions)Zr(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let h=0,f=u.length;h<f;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Zr(i,u[0],r);return u[0]}let d=new li;if(r.extensions)Zr(i,d,r);t.associations.set(d,{meshes:e});for(let h=0,f=u.length;h<f;h++)d.add(u[h]);return d})}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 Vt(So.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new $r(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return yi(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 d=new $e;if(r!==null)d.fromArray(r.array,c*16);a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ro(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,d=i.channels.length;u<d;u++){let h=i.channels[u],f=i.samplers[h.sampler],m=h.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 d=u[0],h=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let S=0,T=d.length;S<T;S++){let y=d[S],w=h[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let z=0;z<M.length;z++)p.push(M[z])}let g=new Ss(r,void 0,p);return yi(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],d=c[2];if(d!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(d,ZT)});for(let h=0,f=u.length;h<f;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,f=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[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 Ao;else if(c.length>1)l=new li;else if(c.length===1)l=c[0];else l=new gt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(yi(l,r),r.extensions)Zr(n,l,r);if(r.matrix!==void 0){let u=new $e;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 li;if(n.name)r.name=i.createUniqueName(n.name);if(yi(r,n),n.extensions)Zr(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 d=a[l];if(d.parent!==null)r.add(tg(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,h]of i.associations)if(d instanceof yn||d instanceof Nt)u.set(d,h);return l.traverse((d)=>{let h=i.associations.get(d);if(h!=null)u.set(d,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(br[r.path]===br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(br[r.path]){case br.weights:l=_r;break;case br.rotation:l=xr;break;case br.translation:case br.scale:l=Hr;break;default:switch(n.itemSize){case 1:l=_r;break;case 2:case 3:default:l=Hr;break}break}let u=i.interpolation!==void 0?BT[i.interpolation]:oc,d=this._getArrayFromAccessor(n);for(let h=0,f=a.length;h<f;h++){let m=new l(a[h]+"."+br[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Fh(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 xr?Cg:kh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function XT(e,t,n){let i=t.attributes,r=new Gt;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 U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=Fh(Hs[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 U,c=new U;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let h=n.json.accessors[d.POSITION],{min:f,max:m}=h;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]))),h.normalized){let _=Fh(Hs[h.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 En;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function og(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=Uh[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(je.workingColorSpace!==Mn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`);return yi(e,t),XT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?GT(e,t.targets,n):e})}function $o(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 Vh(e,t="|"){return e.map((n)=>$h(n)).join(t)}function Wo(e,t){if(typeof t==="bigint")return t.toString();return t}class Ig{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 Zo(e){return new Ig(e)}function Lg(e){return e===null||e===void 0}function Mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ng(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 Gn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Zi(e){return Xo(e._zod.def)??e._zod.def.shape}function Dg(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Gn(this,t,i),i},enumerable:!0,configurable:!0})}function Og(e,t,n){if(t in e)Gn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Zi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Dg(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Og(e,s,i?i(o.value,s):o.value)}}function jT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Dg(e,n,()=>t[n]);else Og(e,n,i.value)}}function Rn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Ug(e){return JSON.stringify(e)}function Fg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Gh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $s(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var zg=Zo(()=>{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 jr(e){if($s(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($s(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Hh(e){if(jr(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 kg=new Set(["string","number","symbol"]),Bg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vi(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 $h(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Vg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Lc=(()=>({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]}))(),Wh={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function qT(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 Xr(s,e,Nc(e,t)),vi(e,Rn(n,{shape:s,checks:[]}))}function Nc(e,t){let n=Zi(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 YT(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(Nc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Zi(e)).filter((a)=>!s.has(a))),vi(e,Rn(n,{shape:o,checks:[]}))}function JT(e,t){if(!jr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Zi(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 vi(e,Rn(e._zod.def,{shape:Gg(e,t)}))}function Gg(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Zi(e))),jT(n,t),n}function KT(e,t){if(!jr(t))throw Error("Invalid input to safeExtend: expected a plain object");return vi(e,Rn(e._zod.def,{shape:Gg(e,t)}))}function QT(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={};Xr(n,e,Reflect.ownKeys(Zi(e))),Xr(n,t,Reflect.ownKeys(Zi(t)));let i=Rn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return vi(e,i)}function Hg(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(Nc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Zi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),vi(t,Rn(t._zod.def,{shape:c,checks:[]}))}function e1(e,t,n){let i=n?new Set(Nc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Zi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),vi(t,Rn(t._zod.def,{shape:r}))}function Hn(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 $g(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 bi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Ho(e){return typeof e==="string"?e:e?.message}function Zh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Si(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:Ho(e.inst?._zod.def?.error?.(e))??Ho(s?.(e))??Ho(t?.error?.(e))??Ho(n.customError?.(e))??Ho(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 t1=/[\uD800-\uDBFF]/;function Dc(e){let t=e.length;if(!t1.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 Wg(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 qr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Zg(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else n1(e,n,i.value)}}function Xi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Uc(e,t,n){return Xi(e,t,n,!1)}function Xg(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Xi(this,n,i(this))},set(r){Xi(this,n,r)}})}return t}function n1(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Xi(this,t,n.bind(this))},set(i){Xi(this,t,i)}})}function i1(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Bh,Sr=!1,r1={configurable:!0,get(){Sr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Bh!==e._zod){Bh=void 0;return}Bh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,r1);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 s1(e,t,n,i){let r=i1(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 o1="~constantCatch";function jg(e){let t=()=>e;return t[o1]=!0,t}var qg;var Xh={value:void 0,enumerable:!1},Yg="captureStackTrace"in Error?Error:null;function a1(e){let t=Yg;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Yg=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=d,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,f){if(!h._zod){Xh.value=new s(f);try{Object.defineProperty(h,"_zod",Xh)}finally{Xh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,f),a){let _=Object.getPrototypeOf(h),p=h._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let S=g??_;if(!a.has(S))a.add(S),Zg(S,o)}let m=d.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in h))h[_]=m[_].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(h){let f=i?.Parent?a1(u):this;c(f,h);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(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Mi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class jo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(qg=globalThis).__zod_globalConfig??(qg.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Cn(e){if(e)Object.assign(dn,e);return dn}function c1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Wo,2)),e.message}function l1(e){this._zod.message=e}var u1={get:c1,set:l1,enumerable:!0,configurable:!0},qh={value:void 0,enumerable:!1},Jg=new WeakSet([Object.prototype,Error.prototype]),Kg=(e,t)=>{e.name="$ZodError",qh.value=t,Object.defineProperty(e,"issues",qh),qh.value=void 0,Object.defineProperty(e,"message",u1);let n=Object.getPrototypeOf(e);if(!Jg.has(n))Jg.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})}})},Qg=J("$ZodError",Kg),NN=J("$ZodError",Kg,void 0,{Parent:Error});function h1(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 e_(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)h1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function t_(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],d=l===a.length-1;if(u==="_errors"){if(d)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(d)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Fc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var zc=(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 Mi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Cn())));throw Gh(c,s?.callee??t),c}return a.value};return t};var kc=(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)=>Si(l,o,Cn())));throw Gh(c,s?.callee??t),c}return a.value};return t};var Bc=(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 Mi;return s.issues.length?n_(e,s.issues,r):{success:!0,data:s.value}};function n_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Si(r,n,Cn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Vc=(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?n_(e,s.issues,r):{success:!0,data:s.value}};var d1=Symbol.for("zod.compile.invalid"),f1=Symbol.for("zod.compile.fallback"),Yh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==d1)return!0;if(i.definite===!0&&n===void 0)return!1}return p1(e,t,n)};function p1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[f1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Mi;return s.issues.length===0}var Jh=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},i_=(e)=>{let t=zc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Fc(n,o))};return n};var r_=(e)=>{let t=zc(e),n=(i,r,s,o)=>t(i,r,s,Fc(n,o));return n};var s_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Fc(n,o))};return n};var o_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>await t(i,r,s,Fc(n,o));return n};var a_=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Bc(e)(t,n,r)};var c_=(e)=>(t,n,i)=>Bc(e)(t,n,i);var l_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Vc(e)(t,n,r)};var u_=(e)=>async(t,n,i)=>Vc(e)(t,n,i);var h_=/^[cC][0-9a-z]{6,}$/,d_=/^[0-9a-z]+$/,f_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,p_=/^[0-9a-vA-V]{20}$/,m_=/^[A-Za-z0-9]{27}$/,g_=/^[a-zA-Z0-9_-]{21}$/;function __(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var x_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var y_=/^([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})$/,Qh=(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 v_=/^(?:[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 m1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function b_(){return new RegExp(m1,"u")}var S_=/^(?:(?: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])$/,M_=/^(([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 w_=/^((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])$/,E_=/^(([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])$/,A_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,T_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var R_=/^https?$/,C_=/^\+[1-9]\d{6,14}$/;var P_="(?:(?:\\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 g1(e){return new RegExp(`^${e}$`)}var I_=g1(P_);function Kh(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 L_(e){return new RegExp(`^${Kh(e)}$`)}function N_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Kh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Kh({precision:e.precision})}`:n;return new RegExp(`^${P_}T(?:${i})$`)}var D_=/^[\s\S]{0,}$/,O_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Gc=/^-?\d+$/,Ws=/^-?\d+(?:\.\d+)?$/,U_=/^(?:true|false)$/i;var F_=/^[^A-Z]*$/,z_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var ed=(e)=>{let t=e.value;return!Lg(t)&&t.length!==void 0},Hc={number:"number",bigint:"bigint",object:"date"},td=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Hc[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})}}),nd=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Hc[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})}}),k_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.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):Ng(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})}}),B_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Lc[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 V_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ed),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Dc(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;Kt.init(e,t),(n=e._zod.def).when??(n.when=ed),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Dc(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})}}),H_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ed),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Dc(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})}}),Yo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.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=()=>{})}),$_=J("$ZodCheckRegex",(e,t)=>{Yo.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})}}),W_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=F_),Yo.init(e,t)}),Z_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=z_),Yo.init(e,t)}),X_=J("$ZodCheckIncludes",(e,t)=>{Kt.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})}}),j_=J("$ZodCheckStartsWith",(e,t)=>{Kt.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})}}),q_=J("$ZodCheckEndsWith",(e,t)=>{Kt.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 Y_=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class id{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 Y_={major:4,minor:6,patch:5};var vt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Y_;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=Hn(a),h;for(let d of c){if(d._zod.def.when){if(Gg(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 wi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Wh(a.issues,f,e),!u)u=Hn(a,f)});else{if(a.issues.length===f)continue;if(Wh(a.issues,f,e),!u)u=Hn(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(Hn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new wi;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 wi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Uc(this,"~standard",sd(this))},set "~standard"(e){ji(this,"~standard",e)}}),u0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Mi(n,t,Pn()))}:{value:e.value};async function h1(e,t){let n={async:!0};return u0(await e._zod.run({value:t,issues:[]},n),n)}function sd(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return u0(i,n)}catch(i){}return h1(e,t)},vendor:"zod",version:1}}var Xc=J("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??L_,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=J("$ZodStringFormat",(e,t)=>{jo.init(e,t),Xc.init(e,t)}),h0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=__),Tt.init(e,t)}),d0=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=Kh(i))}else t.pattern??(t.pattern=Kh());Tt.init(e,t)}),f0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=x_),Tt.init(e,t)}),p0=1,Wc=2;function m0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function d1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return m0(e)||Wc;return f1(e,t)}function f1(e,t){if(!t.normalize&&t.protocol?.source===A_.source&&!/^https?:\/\//i.test(e))return p0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Wc}return new URL(e)}catch{return Wc}}var p1=/[\t\n\r]/g;function J_(e){return e.replace(p1,"")}function m1(e,t){return t.lastIndex=0,t.test(e.hostname)}function g1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var g0=J("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=d1(i,t);if(r===p0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Wc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=J_(i);return}if(t.hostname&&!m1(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&&!g1(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:J_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),_0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=y_()),Tt.init(e,t)}),x0=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?p_:m_(t.length)),Tt.init(e,t)}),y0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=l_),Tt.init(e,t)}),v0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=u_),Tt.init(e,t)}),b0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=h_),Tt.init(e,t)}),S0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=d_),Tt.init(e,t)}),M0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=f_),Tt.init(e,t)}),w0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=I_(t)),Tt.init(e,t)}),E0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=C_),Tt.init(e,t)}),A0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=P_(t)),Tt.init(e,t)}),T0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=g_),Tt.init(e,t)}),R0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=v_),Tt.init(e,t)}),_1=/^[0-9a-fA-F:.]+$/;function C0(e){if(!_1.test(e))return!1;return m0(`http://[${e}]`)}var P0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=b_),Tt.init(e,t),e._zod.check=(n)=>{if(!C0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var I0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=S_),Tt.init(e,t)});function x1(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 C0(n)}var L0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=M_),Tt.init(e,t),e._zod.check=(n)=>{if(!x1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function N0(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 od=/^[0-9a-zA-Z+/]*={0,2}$/,D0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=od),Tt.init(e,t),e._zod.check=(n)=>{if(N0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),jc=/^[A-Za-z0-9_-]*$/;function y1(e){if(!jc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return N0(n)}var O0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jc),Tt.init(e,t),e._zod.check=(n)=>{if(y1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),U0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=T_),Tt.init(e,t)});function v1(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 F0=J("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{if(v1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var ad=J("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=$s,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}}),z0=J("$ZodNumberFormat",(e,t)=>{z_.init(e,t),ad.init(e,t)}),k0=J("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=D_,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 B0=J("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),V0=J("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function K_(e,t,n){if(e.issues.length)t.issues.push(...Si(n,e.issues));t.value[n]=e.value}var G0=J("$ZodArray",(e,t)=>{vt.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((h)=>K_(h,i,c)));else if(K_(u,i,c),a&&u.issues.length!==0&&Hn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function Zc(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(...Si(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 b1=[];function H0(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:b1,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=kg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function $0(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(Hn(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)=>Zc(p,n,m,t,h,d)));else Zc(_,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 S1=J("$ZodObject",(e,t)=>{vt.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=$o(()=>H0(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))Gn(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=Hs,o=t.catchall,a,c=dn.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(Hn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:h[p],issues:[]},u);if(y instanceof Promise)d.push(y.then((w)=>Zc(w,l,p,h,S,T)));else Zc(y,l,p,h,S,T)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return $0(d,h,l,u,r.value,e,m===!0)}}),W0=J("$ZodObjectJIT",(e,t)=>{S1.init(e,t);let n=e._zod.parse,i=$o(()=>H0(t)),r=dn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new nd(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`
+};`)(...Object.values(this.closed))}}var K_={major:4,minor:6,patch:5};var vt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=K_;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=Hn(a),d;for(let h of c){if(h._zod.def.when){if($g(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new Mi;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Zh(a.issues,f,e),!u)u=Hn(a,f)});else{if(a.issues.length===f)continue;if(Zh(a.issues,f,e),!u)u=Hn(a,f)}}if(d)return d.then(()=>a);return a},o=(a,c,l)=>{if(Hn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Mi;return u.then((d)=>e._zod.parse(d,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((d)=>o(d,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Mi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Uc(this,"~standard",od(this))},set "~standard"(e){Xi(this,"~standard",e)}}),d0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Si(n,t,Cn()))}:{value:e.value};async function _1(e,t){let n={async:!0};return d0(await e._zod.run({value:t,issues:[]},n),n)}function od(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return d0(i,n)}catch(i){}return _1(e,t)},vendor:"zod",version:1}}var Xc=J("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??D_,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}}),Rt=J("$ZodStringFormat",(e,t)=>{Yo.init(e,t),Xc.init(e,t)}),f0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=y_),Rt.init(e,t)}),p0=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=Qh(i))}else t.pattern??(t.pattern=Qh());Rt.init(e,t)}),m0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=v_),Rt.init(e,t)}),g0=1,Wc=2;function _0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function x1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return _0(e)||Wc;return y1(e,t)}function y1(e,t){if(!t.normalize&&t.protocol?.source===R_.source&&!/^https?:\/\//i.test(e))return g0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Wc}return new URL(e)}catch{return Wc}}var v1=/[\t\n\r]/g;function Q_(e){return e.replace(v1,"")}function b1(e,t){return t.lastIndex=0,t.test(e.hostname)}function S1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var x0=J("$ZodURL",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=x1(i,t);if(r===g0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Wc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Q_(i);return}if(t.hostname&&!b1(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&&!S1(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:Q_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),y0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=b_()),Rt.init(e,t)}),v0=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?g_:__(t.length)),Rt.init(e,t)}),b0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=h_),Rt.init(e,t)}),S0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=d_),Rt.init(e,t)}),M0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=f_),Rt.init(e,t)}),w0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=p_),Rt.init(e,t)}),E0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=m_),Rt.init(e,t)}),A0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=N_(t)),Rt.init(e,t)}),T0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=I_),Rt.init(e,t)}),R0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=L_(t)),Rt.init(e,t)}),C0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=x_),Rt.init(e,t)}),P0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=S_),Rt.init(e,t)}),M1=/^[0-9a-fA-F:.]+$/;function I0(e){if(!M1.test(e))return!1;return _0(`http://[${e}]`)}var L0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=M_),Rt.init(e,t),e._zod.check=(n)=>{if(!I0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var N0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=w_),Rt.init(e,t)});function w1(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 I0(n)}var D0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=E_),Rt.init(e,t),e._zod.check=(n)=>{if(!w1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function O0(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 ad=/^[0-9a-zA-Z+/]*={0,2}$/,U0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ad),Rt.init(e,t),e._zod.check=(n)=>{if(O0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),jc=/^[A-Za-z0-9_-]*$/;function E1(e){if(!jc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return O0(n)}var F0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jc),Rt.init(e,t),e._zod.check=(n)=>{if(E1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),z0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=C_),Rt.init(e,t)});function A1(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 k0=J("$ZodJWT",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{if(A1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var cd=J("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=Ws,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}}),B0=J("$ZodNumberFormat",(e,t)=>{B_.init(e,t),cd.init(e,t)}),V0=J("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=U_,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 G0=J("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),H0=J("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function e0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}var $0=J("$ZodArray",(e,t)=>{vt.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((d)=>e0(d,i,c)));else if(e0(u,i,c),a&&u.issues.length!==0&&Hn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function Zc(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(...bi(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 T1=[];function W0(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:T1,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=Vg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Z0(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:h}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(Hn(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)=>Zc(p,n,m,t,d,h)));else Zc(_,n,m,t,d,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 R1=J("$ZodObject",(e,t)=>{vt.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=Zo(()=>W0(t));at(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let h in u){let f=u[h]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(d,h))Gn(d,h,new Set);for(let m of f.values)d[h].add(m);if(f.optin!==void 0)d[h].add(void 0)}}return d});let s=$s,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(Hn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:d[p],issues:[]},u);if(y instanceof Promise)h.push(y.then((w)=>Zc(w,l,p,d,S,T)));else Zc(y,l,p,d,S,T)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return Z0(h,d,l,u,r.value,e,m===!0)}}),X0=J("$ZodObjectJIT",(e,t)=>{R1.init(e,t);let n=e._zod.parse,i=Zo(()=>W0(t)),r=dn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new id(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`
let ${w}_ab = false;
for (let i = 0; i < ${w}.issues.length; i++) {
const iss = ${w}.issues[i];
@@ -4356,7 +4356,7 @@ ${t.join(`
if (${w}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:Dg(w),x=`${R} in input`,M=f[w],z=M?._zod?.optin,C=z!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=z==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`
+ }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:Ug(w),x=`${R} in input`,M=f[w],z=M?._zod?.optin,C=z!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=z==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`
const ${A}_present = ${x};
if (!${A}.issues.length || ${A}_present) {
if (${A}.issues.length) {${S(A,R)}
@@ -4395,18 +4395,18 @@ ${t.join(`
if (${A}.value !== undefined || ${x}) {
newResult[${R}] = ${A}.value;
}
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Hs,c=!dn.jitless,u=c&&Ug.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 $0([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function Q_(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)=>!Hn(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)=>Mi(o,i,Pn())))}),t}var cd=J("$ZodUnion",(e,t)=>{vt.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)=>Mr(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 Q_(o,i,e,r);return Promise.all(o).then((a)=>Q_(a,i,e,r))}});function M1(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 Z0=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,cd.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))Gn(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=Wo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=$o(()=>M1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Hs(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}}),X0=J("$ZodIntersection",(e,t)=>{vt.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])=>e0(n,c,l));return e0(n,s,o)}});function id(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(jr(e)&&jr(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=id(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=id(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 e0(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=id(t.value,n.value);if(!c.valid){if(Hn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var j0=J("$ZodTuple",(e,t)=>{vt.init(e,t);let n=t.items,i=dn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=t0(n,"optin"),l=t0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),h=t.rest?s?.abortEarly:void 0,d=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,h&&!d&&m.issues.length)d=Hn(m)}if(t.rest&&!d){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(h&&r.issues.length!==_){if(Hn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>n0(S,r,f)));else n0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>i0(u,r,n,o,l));return i0(u,r,n,o,l)}});function t0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function n0(e,t,n){if(e.issues.length)t.issues.push(...Si(n,e.issues));t.value[n]=e.value}function i0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...Si(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var q0=J("$ZodRecord",(e,t)=>{vt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!jr(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)=>Mi(m,r,Pn())),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(...Si(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Si(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"&&$s.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)=>Mi(m,r,Pn())),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(...Si(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Si(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 Y0=J("$ZodEnum",(e,t)=>{vt.init(e,t);let n=Go(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=Go(r.def.entries).filter((o)=>Fg.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}}),J0=J("$ZodLiteral",(e,t)=>{vt.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 K0=J("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Zo(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 wi;return n.value=r,n}});function r0(e,t){return e.value=t.issues.length?void 0:t.value,e}var ld=J("$ZodOptional",(e,t)=>{vt.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(`^(${Mr(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)=>r0(n,s));return r0(n,r)}return t.innerType._zod.run(n,i)}}),Q0=J("$ZodExactOptional",(e,t)=>{ld.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)}),ex=J("$ZodNullable",(e,t)=>{vt.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(`^(${Mr(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)}}),tx=J("$ZodDefault",(e,t)=>{vt.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)=>s0(s,t));return s0(r,t)}});function s0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var nx=J("$ZodPrefault",(e,t)=>{vt.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)}}),ix=J("$ZodNonOptional",(e,t)=>{vt.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)=>o0(s,e));return o0(r,e)}});function o0(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 a0(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)=>Mi(r,i,Pn()))},input:e.value}),e}var rx=J("$ZodCatch",(e,t)=>{vt.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)=>a0(n,s,t,i));return a0(n,r,t,i)}});var sx=J("$ZodPipe",(e,t)=>{vt.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)=>$c(o,t.in,i));return $c(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>$c(s,t.out,i));return $c(r,t.out,i)}});function $c(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 ox=J("$ZodReadonly",(e,t)=>{vt.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(c0);return c0(r)}});function c0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function w1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return N_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===$s?Gc:o)?.source}function rd(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=rd(i);if(n&&r&&s&&s!==r)return n.replace(Mr(r),()=>Mr(s));return n}if(t.options){let r=t.options.map(rd);if(r.every(Boolean))return`^(${r.map((s)=>Mr(s)).join("|")})$`}return w1(e)}var ax=J("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=rd(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mr(r))}else if(i===null||zg.has(typeof i))n.push(qi(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var cx=J("$ZodCustom",(e,t)=>{Kt.init(e,t),vt.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)=>l0(s,n,i,e));l0(r,n,i,e);return}});function l0(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(qr(r))}}class ux extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var hd="~memo",lx=[];function hx(e){return e!==null&&typeof e==="object"}function ud(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var dx=new WeakMap,qo=0,Jc=1,Yo=2;function Kc(e,t,n){let i=dx.get(e);if(i!==void 0)return i?Yo:qo;if(t.has(e))return Yo;t.add(e);let r=qo,s=(u)=>{if(r!==Yo&&u?._zod){let h=Kc(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=qo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?Jc:m.value?._zod?Kc(m.value,t,n):qo;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=Wo(c);a(u?o(u,!0):Jc),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?Kc(u,t,!1):Jc);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),E1(e,r)}function E1(e,t){if(t!==Jc)dx.set(e,t===Yo);return t}function A1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var qc,Yc=[],T1={alloc(e,t,n){let i=qc;if(!i)return n;qc=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"&&R1(s,r.value))throw new ux;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=Kc(e,new Set,!1);if(g===qo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Yo||i)n=!0;else i=!0}let u=c.value;if(!hx(u))return o(c,l);let h=l[hd];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[hd]=h;let d;if(r===l)d=s;else d=A1(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(...ud(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}qc=d;let m=Yc.length,_=o(c,l);qc=void 0;let p=Yc.length>m?Yc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?ud(g.issues):lx;return g});if(p)p.issues=_.issues.length?ud(_.issues):lx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function fx(){return T1}function R1(e,t){let n=e[hd]?.backEdges;return n!==void 0&&hx(t)&&n.has(t)}var C1=()=>{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=Hg(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 ${Hh(s.values[0])}`;return`Invalid option: expected one of ${Bh(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":""}: ${Bh(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 dd(){return{localeError:C1()}}var px;class mx{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 P1(){return new mx}(px=globalThis).__zod_globalRegistry??(px.__zod_globalRegistry=P1());var Yr=globalThis.__zod_globalRegistry;function gx(e){if(e.checks)e.checks=[...e.checks];return e}function _x(e,t){return new e(gx({type:"string",...Ce(t)}))}function xx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function yx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function vx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function bx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function wx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Ex(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function Ax(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Tx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Rx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Cx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Px(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function $x(e,t){return new e(gx({type:"number",checks:[],...Ce(t)}))}function Wx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function Zx(e,t){return new e({type:"boolean",...Ce(t)})}function Xx(e){return new e({type:"unknown"})}function jx(e,t){return new e({type:"never",...Ce(t)})}function Qc(e,t){return new ed({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Jo(e,t){return new ed({check:"less_than",...Ce(t),value:e,inclusive:!0})}function el(e,t){return new td({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function Ko(e,t){return new td({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function tl(e,t){return new F_({check:"multiple_of",...Ce(t),value:e})}function nl(e,t){return new k_({check:"max_length",...Ce(t),maximum:e})}function Ws(e,t){return new B_({check:"min_length",...Ce(t),minimum:e})}function il(e,t){return new V_({check:"length_equals",...Ce(t),length:e})}function fd(e,t){return new G_({check:"string_format",format:"regex",...Ce(t),pattern:e})}function pd(e){return new H_({check:"string_format",format:"lowercase",...Ce(e)})}function md(e){return new $_({check:"string_format",format:"uppercase",...Ce(e)})}function gd(e,t){return new W_({check:"string_format",format:"includes",...Ce(t),includes:e})}function _d(e,t){return new Z_({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function xd(e,t){return new X_({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function wr(e){return new j_({check:"overwrite",tx:e})}function yd(e){return wr((t)=>t.normalize(e))}function vd(){return wr((e)=>e.trim())}function bd(){return wr((e)=>e.toLowerCase())}function Sd(){return wr((e)=>e.toUpperCase())}function Md(){return wr((e)=>Og(e))}function qx(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function Yx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Jx(e,t){let n=I1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(qr(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(qr(s))}},e(i.value,i)),t);return n}function I1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function Qo(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Gn(e,i,n[i]);return e}function Ed(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??Yr,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 Yi(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 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;It(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Qo(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 Kx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ad(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}/${Kx(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+Kx(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=$s,c=!dn.jitless,u=c&&zg.value,d=t.catchall,h;e._zod.parse=(f,m)=>{h??(h=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),!d)return f;return Z0([],_,f,m,h,e,m?.abortEarly===!0)}return n(f,m)}});function t0(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)=>!Hn(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)=>Si(o,i,Cn())))}),t}var ld=J("$ZodUnion",(e,t)=>{vt.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)=>Mr(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 t0(o,i,e,r);return Promise.all(o).then((a)=>t0(a,i,e,r))}});function C1(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 j0=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ld.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))Gn(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=Xo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Zo(()=>C1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!$s(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}}),q0=J("$ZodIntersection",(e,t)=>{vt.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])=>n0(n,c,l));return n0(n,s,o)}});function rd(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(jr(e)&&jr(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=rd(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=rd(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 n0(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=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);d=[h]}else return!1;for(let h of d){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=rd(t.value,n.value);if(!c.valid){if(Hn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Y0=J("$ZodTuple",(e,t)=>{vt.init(e,t);let n=t.items,i=dn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=i0(n,"optin"),l=i0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,h=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,d&&!h&&m.issues.length)h=Hn(m)}if(t.rest&&!h){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(d&&r.issues.length!==_){if(Hn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>r0(S,r,f)));else r0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>s0(u,r,n,o,l));return s0(u,r,n,o,l)}});function i0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function r0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}function s0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...bi(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var J0=J("$ZodRecord",(e,t)=>{vt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!jr(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 d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((m)=>Si(m,r,Cn())),input:u,path:[u],inst:e});continue}let h=d.value;if(h==="__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(...bi(u,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(u,f.issues));i.value[h]=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"&&Ws.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)=>Si(m,r,Cn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__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(...bi(l,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(l,f.issues));i.value[h]=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 K0=J("$ZodEnum",(e,t)=>{vt.init(e,t);let n=$o(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=$o(r.def.entries).filter((o)=>kg.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}}),Q0=J("$ZodLiteral",(e,t)=>{vt.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 ex=J("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new jo(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 Mi;return n.value=r,n}});function o0(e,t){return e.value=t.issues.length?void 0:t.value,e}var ud=J("$ZodOptional",(e,t)=>{vt.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(`^(${Mr(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)=>o0(n,s));return o0(n,r)}return t.innerType._zod.run(n,i)}}),tx=J("$ZodExactOptional",(e,t)=>{ud.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)}),nx=J("$ZodNullable",(e,t)=>{vt.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(`^(${Mr(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)}}),ix=J("$ZodDefault",(e,t)=>{vt.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)=>a0(s,t));return a0(r,t)}});function a0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var rx=J("$ZodPrefault",(e,t)=>{vt.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)}}),sx=J("$ZodNonOptional",(e,t)=>{vt.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)=>c0(s,e));return c0(r,e)}});function c0(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 l0(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)=>Si(r,i,Cn()))},input:e.value}),e}var ox=J("$ZodCatch",(e,t)=>{vt.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)=>l0(n,s,t,i));return l0(n,r,t,i)}});var ax=J("$ZodPipe",(e,t)=>{vt.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)=>$c(o,t.in,i));return $c(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>$c(s,t.out,i));return $c(r,t.out,i)}});function $c(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 cx=J("$ZodReadonly",(e,t)=>{vt.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(u0);return u0(r)}});function u0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function P1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return O_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===Ws?Gc:o)?.source}function sd(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=sd(i);if(n&&r&&s&&s!==r)return n.replace(Mr(r),()=>Mr(s));return n}if(t.options){let r=t.options.map(sd);if(r.every(Boolean))return`^(${r.map((s)=>Mr(s)).join("|")})$`}return P1(e)}var lx=J("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=sd(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mr(r))}else if(i===null||Bg.has(typeof i))n.push(ji(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var ux=J("$ZodCustom",(e,t)=>{Kt.init(e,t),vt.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)=>h0(s,n,i,e));h0(r,n,i,e);return}});function h0(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(qr(r))}}class dx extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var dd="~memo",hx=[];function fx(e){return e!==null&&typeof e==="object"}function hd(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var px=new WeakMap,Jo=0,Jc=1,Ko=2;function Kc(e,t,n){let i=px.get(e);if(i!==void 0)return i?Ko:Jo;if(t.has(e))return Ko;t.add(e);let r=Jo,s=(u)=>{if(r!==Ko&&u?._zod){let d=Kc(u,t,n);if(d>r)r=d}},o=(u,d)=>{let h=Jo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(d&&!m.enumerable)continue;let _=m.get?Jc:m.value?._zod?Kc(m.value,t,n):Jo;if(_>h)h=_}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Xo(c);a(u?o(u,!0):Jc),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?Kc(u,t,!1):Jc);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 d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let h=d.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let f of h)s(f)}}return t.delete(e),I1(e,r)}function I1(e,t){if(t!==Jc)px.set(e,t===Ko);return t}function L1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var qc,Yc=[],N1={alloc(e,t,n){let i=qc;if(!i)return n;qc=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"&&D1(s,r.value))throw new dx;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=Kc(e,new Set,!1);if(g===Jo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Ko||i)n=!0;else i=!0}let u=c.value;if(!fx(u))return o(c,l);let d=l[dd];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[dd]=d;let h;if(r===l)h=s;else h=L1(d,e),r=l,s=h;let f=h.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...hd(f.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value);return c}qc=h;let m=Yc.length,_=o(c,l);qc=void 0;let p=Yc.length>m?Yc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?hd(g.issues):hx;return g});if(p)p.issues=_.issues.length?hd(_.issues):hx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function mx(){return N1}function D1(e,t){let n=e[dd]?.backEdges;return n!==void 0&&fx(t)&&n.has(t)}var O1=()=>{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=Wg(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 ${$h(s.values[0])}`;return`Invalid option: expected one of ${Vh(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":""}: ${Vh(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 fd(){return{localeError:O1()}}var gx;class _x{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 U1(){return new _x}(gx=globalThis).__zod_globalRegistry??(gx.__zod_globalRegistry=U1());var Yr=globalThis.__zod_globalRegistry;function xx(e){if(e.checks)e.checks=[...e.checks];return e}function yx(e,t){return new e(xx({type:"string",...Ce(t)}))}function vx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function bx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function Mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function wx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Ex(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function Ax(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Tx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function Rx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Cx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Px(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function $x(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function Wx(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function Zx(e,t){return new e(xx({type:"number",checks:[],...Ce(t)}))}function Xx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function jx(e,t){return new e({type:"boolean",...Ce(t)})}function qx(e){return new e({type:"unknown"})}function Yx(e,t){return new e({type:"never",...Ce(t)})}function Qc(e,t){return new td({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Qo(e,t){return new td({check:"less_than",...Ce(t),value:e,inclusive:!0})}function el(e,t){return new nd({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function ea(e,t){return new nd({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function tl(e,t){return new k_({check:"multiple_of",...Ce(t),value:e})}function nl(e,t){return new V_({check:"max_length",...Ce(t),maximum:e})}function Zs(e,t){return new G_({check:"min_length",...Ce(t),minimum:e})}function il(e,t){return new H_({check:"length_equals",...Ce(t),length:e})}function pd(e,t){return new $_({check:"string_format",format:"regex",...Ce(t),pattern:e})}function md(e){return new W_({check:"string_format",format:"lowercase",...Ce(e)})}function gd(e){return new Z_({check:"string_format",format:"uppercase",...Ce(e)})}function _d(e,t){return new X_({check:"string_format",format:"includes",...Ce(t),includes:e})}function xd(e,t){return new j_({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function yd(e,t){return new q_({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function wr(e){return new Y_({check:"overwrite",tx:e})}function vd(e){return wr((t)=>t.normalize(e))}function bd(){return wr((e)=>e.trim())}function Sd(){return wr((e)=>e.toLowerCase())}function Md(){return wr((e)=>e.toUpperCase())}function wd(){return wr((e)=>Fg(e))}function Jx(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function Kx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Qx(e,t){let n=F1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(qr(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(qr(s))}},e(i.value,i)),t);return n}function F1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function ta(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Gn(e,i,n[i]);return e}function Ad(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??Yr,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 qi(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,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,h,u)}let d=e._zod.parent;if(d){if(!o.ref)o.ref=d;It(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)ta(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 ey(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Td(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 d=e.external.registry.get(o[0])?.id,h=e.external.uri??((m)=>m);if(d)return{ref:h(d)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${ey(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+ey(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 d in u)delete u[d];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 ty(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;ty(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 ny=new Set(["type","properties","required","additionalProperties"]),Qx=["oneOf","anyOf"];function ey(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 wd(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!ny.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]??ey(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]:wd(a)??{allOf:a};Gn(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=ey(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 L1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of ny)if(r in e)return;let n=t.filter((r)=>Qx.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=wd(t);else{let r=n[0],s=Qx.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)=>wd([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Qo(e,i)}function Td(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 Qo(l,m);if(Qo(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())ty(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)??[])L1(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)}Qo(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;Gn(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:ea(t,"input",e.processors),output:ea(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 iy=(e,t={})=>(n)=>{let i=Ed({...n,processors:t});return It(e,i),Ad(i,e),Td(i,e)},ea=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Ed({...r??{},target:s,io:t,processors:n});return It(e,o),Ad(o,e),Td(o,e)};var Zs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Xs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},ry=(e,t)=>{Zs(e,"minimum",t),Xs(e,"maximum",t)},cy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ly=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},uy=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},hy=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},sy=(e,t)=>Zs(e,"minimum",t.minimum),oy=(e,t)=>Xs(e,"maximum",t.maximum),ay=(e)=>(t,n)=>{hy(t,n.format);let[i,r]=e[n.format];Zs(t,"minimum",i),Xs(t,"maximum",r)},N1={greater_than:(e,t)=>Zs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Xs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>cy(e,t.value),number_format:ay(Lc),bigint_format:ay($h),min_length:sy,max_length:oy,length_equals:(e,t)=>ry(e,t.length),min_size:sy,max_size:oy,size_equals:(e,t)=>ry(e,t.size),string_format:(e,t)=>{if(hy(e,t.format),t.pattern)ly(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)=>uy(e,t.mime)};function In(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)N1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Zs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Zs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Xs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Xs(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)cy(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)uy(t,r.mime);for(let s of r.patterns??[])ly(t,s);return t}var D1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},O1=new Map([[od,w_],[jc,E_]]),dy=(e)=>O1.get(e)??e,fy=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=In(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=D1[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(dy);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}))]}},py=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=In(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 Yi(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}))]}},my=(e,t,n,i)=>{n.type="boolean"};var gy=(e,t,n,i)=>{n.not={}};var _y=(e,t,n,i)=>{};var xy=(e,t,n,i)=>{let r=e._zod.def,s=Go(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},yy=(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(Yi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Yi(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 vy=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var by=(e,t,n,i)=>{Yi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Sy=(e,t,n,i)=>{Yi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var My=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=In(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 ta(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ta(t.out);if(t.type==="catch")return ta(t.innerType);return e._zod.optin}var wy=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Yi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Gn(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"?ta(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"]})},Ey=(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},Ay=(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)},Ty=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ta(_)!==void 0:_._zod.optout==="optional"))break;u--}let h=s.items.length,d=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,d)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(d)r.maxItems=h}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(d)r.maxItems=h}else{if(r.items=c,d)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(d)r.maxItems=h}let{minimum:f,maximum:m}=In(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function Rd(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 _=Rd(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>Rd(e,g,n));if(p.some((g,S)=>g!==_[S]))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")?$s:Gc).source;return f}var Cd=new WeakMap;function U1(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 Cd.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Rd(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 Ry=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=In(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 h of a)Gn(r.patternProperties,dy(h).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=Cd.get(t);if(!u)u=[],Cd.set(t,u),t.deferred.push(()=>U1(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ta(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)}},Cy=(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"}]},Py=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Pd=Symbol();function Iy(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 Yi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Pd}var Ly=(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=Iy(r.defaultValue,e,t,n,i);if(o!==Pd)n.default=o},Ny=(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=Iy(r.defaultValue,e,t,n,i);if(o!==Pd)n._prefault=o},Dy=(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{Yi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Oy=(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},Uy=(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 Id=(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 Fy=new WeakSet([Object.prototype,Error.prototype]);function rl(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 $1=(e,t)=>{Jg.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Fy.has(n))return;Fy.add(n),rl(n,"format",(i)=>(r)=>Qg(i,r)),rl(n,"flatten",(i)=>(r)=>Kg(i,r)),rl(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Ho,2)}),rl(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Ho,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Ln=J("ZodError",$1,void 0,{Parent:Error});var zy=zc(Ln),ky=kc(Ln),By=Bc(Ln),Vy=Vc(Ln),Gy=t_(Ln),Hy=n_(Ln),$y=i_(Ln),Wy=r_(Ln),Zy=s_(Ln),Xy=o_(Ln),jy=a_(Ln),qy=c_(Ln);function Z1(){if(!dn.localeError)Pn(dd())}function na(){if(!dn.memoizer)Pn({memoizer:fx()})}var Rt=J("ZodType",(e,t)=>(Z1(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Cn(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 bi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(WR(e,t))},superRefine(e,t){return this.check(ZR(e,t))},overwrite(e){return this.check(wr(e))},optional(){return Ky(this)},exactOptional(){return PR(this)},nullable(){return Qy(this)},nullish(){return Ky(Qy(this))},nonoptional(e){return UR(this,e)},array(){return _t(this)},or(e){return ia([this,e])},and(e){return ER(this,e)},transform(e){return ev(this,CR(e))},default(e){return NR(this,e)},prefault(e){return OR(this,e)},catch(e){return zR(this,e)},pipe(e){return ev(this,e)},readonly(){return VR(this)},describe(e){let t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yr.get(this);let t=this.clone();return Yr.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 Uc(this,"~standard",{...sd(this),jsonSchema:{input:ea(this,"input"),output:ea(this,"output")}})},set "~standard"(e){ji(this,"~standard",e)},parse:function e(t,n){return zy(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ky(this,t,n,{callee:e})},safeParse(e,t){return By(this,e,t)},async safeParseAsync(e,t){return Vy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ji(this,"spa",e)},validate(e,t){return qh(this,e,t)},validateAsync(e,t){return Yh(this,e,t)},encode:function e(t,n){return Gy(this,t,n,{callee:e})},decode:function e(t,n){return Hy(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await $y(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Wy(this,t,n,{callee:e})},safeEncode(e,t){return Zy(this,e,t)},safeDecode(e,t){return Xy(this,e,t)},async safeEncodeAsync(e,t){return jy(this,e,t)},async safeDecodeAsync(e,t){return qy(this,e,t)},toJSONSchema(e){return iy(this,{})(e)},get description(){return Yr.get(this)?.description},get _def(){return this._zod.def}}),tv=J("_ZodString",(e,t)=>{Xc.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fy(e,n,i,r)},Wg({format:(e)=>In(e).format??null,minLength:(e)=>In(e).minimum??null,maxLength:(e)=>In(e).maximum??null},{regex(...e){return this.check(fd(...e))},includes(...e){return this.check(gd(...e))},startsWith(...e){return this.check(_d(...e))},endsWith(...e){return this.check(xd(...e))},min(...e){return this.check(Ws(...e))},max(...e){return this.check(nl(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(Ws(1,...e))},lowercase(e){return this.check(pd(e))},uppercase(e){return this.check(md(e))},trim(){return this.check(vd())},normalize(...e){return this.check(yd(...e))},toLowerCase(){return this.check(bd())},toUpperCase(){return this.check(Sd())},slugify(){return this.check(Md())}})),X1=J("ZodString",(e,t)=>{Xc.init(e,t),tv.init(e,t)},{email(e){return this.check(xx(K1,e))},url(e){return this.check(wx(eR,e))},jwt(e){return this.check(kx(mR,e))},emoji(e){return this.check(Ex(tR,e))},guid(e){return this.check(yx(Q1,e))},uuid(e){return this.check(vx(sl,e))},uuidv4(e){return this.check(bx(sl,e))},uuidv6(e){return this.check(Sx(sl,e))},uuidv7(e){return this.check(Mx(sl,e))},nanoid(e){return this.check(Ax(nR,e))},cuid(e){return this.check(Tx(iR,e))},cuid2(e){return this.check(Rx(rR,e))},ulid(e){return this.check(Cx(sR,e))},base64(e){return this.check(Ux(dR,e))},base64url(e){return this.check(Fx(fR,e))},xid(e){return this.check(Px(oR,e))},ksuid(e){return this.check(Ix(aR,e))},ipv4(e){return this.check(Lx(cR,e))},ipv6(e){return this.check(Nx(lR,e))},cidrv4(e){return this.check(Dx(uR,e))},cidrv6(e){return this.check(Ox(hR,e))},e164(e){return this.check(zx(pR,e))},datetime(e){return this.check(Bx(j1,e))},date(e){return this.check(Vx(q1,e))},time(e){return this.check(Gx(Y1,e))},duration(e){return this.check(Hx(J1,e))}});function Xe(e){return _x(X1,e)}var Lt=J("ZodStringFormat",(e,t)=>{Tt.init(e,t),tv.init(e,t)}),j1=J("ZodISODateTime",(e,t)=>{w0.init(e,t),Lt.init(e,t)}),q1=J("ZodISODate",(e,t)=>{E0.init(e,t),Lt.init(e,t)}),Y1=J("ZodISOTime",(e,t)=>{A0.init(e,t),Lt.init(e,t)}),J1=J("ZodISODuration",(e,t)=>{T0.init(e,t),Lt.init(e,t)}),K1=J("ZodEmail",(e,t)=>{f0.init(e,t),Lt.init(e,t)});var Q1=J("ZodGUID",(e,t)=>{h0.init(e,t),Lt.init(e,t)});var sl=J("ZodUUID",(e,t)=>{d0.init(e,t),Lt.init(e,t)});var eR=J("ZodURL",(e,t)=>{g0.init(e,t),Lt.init(e,t)});var tR=J("ZodEmoji",(e,t)=>{_0.init(e,t),Lt.init(e,t)});var nR=J("ZodNanoID",(e,t)=>{x0.init(e,t),Lt.init(e,t)});var iR=J("ZodCUID",(e,t)=>{y0.init(e,t),Lt.init(e,t)});var rR=J("ZodCUID2",(e,t)=>{v0.init(e,t),Lt.init(e,t)});var sR=J("ZodULID",(e,t)=>{b0.init(e,t),Lt.init(e,t)});var oR=J("ZodXID",(e,t)=>{S0.init(e,t),Lt.init(e,t)});var aR=J("ZodKSUID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var cR=J("ZodIPv4",(e,t)=>{R0.init(e,t),Lt.init(e,t)});var lR=J("ZodIPv6",(e,t)=>{P0.init(e,t),Lt.init(e,t)});var uR=J("ZodCIDRv4",(e,t)=>{I0.init(e,t),Lt.init(e,t)});var hR=J("ZodCIDRv6",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var dR=J("ZodBase64",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var fR=J("ZodBase64URL",(e,t)=>{O0.init(e,t),Lt.init(e,t)});var pR=J("ZodE164",(e,t)=>{U0.init(e,t),Lt.init(e,t)});var mR=J("ZodJWT",(e,t)=>{F0.init(e,t),Lt.init(e,t)});var nv=J("ZodNumber",(e,t)=>{ad.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>py(e,n,i,r),e.isFinite=!0},Wg({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=In(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=In(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=In(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>In(e).format??null},{gt(e,t){return this.check(el(e,t))},gte(e,t){return this.check(Ko(e,t))},min(e,t){return this.check(Ko(e,t))},lt(e,t){return this.check(Qc(e,t))},lte(e,t){return this.check(Jo(e,t))},max(e,t){return this.check(Jo(e,t))},int(e){return this.check(Yy(e))},safe(e){return this.check(Yy(e))},positive(e){return this.check(el(0,e))},nonnegative(e){return this.check(Ko(0,e))},negative(e){return this.check(Qc(0,e))},nonpositive(e){return this.check(Jo(0,e))},multipleOf(e,t){return this.check(tl(e,t))},step(e,t){return this.check(tl(e,t))},finite(){return this}}));function et(e){return $x(nv,e)}var gR=J("ZodNumberFormat",(e,t)=>{z0.init(e,t),nv.init(e,t)});function Yy(e){return Wx(gR,e)}var _R=J("ZodBoolean",(e,t)=>{k0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>my(e,n,i,r)});function Kr(e){return Zx(_R,e)}var xR=J("ZodUnknown",(e,t)=>{B0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_y(e,n,i,r)});function Jr(){return Xx(xR)}var yR=J("ZodNever",(e,t)=>{V0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gy(e,n,i,r)});function vR(e){return jx(yR,e)}var bR=J("ZodArray",(e,t)=>{na(),G0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>My(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(nl(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function _t(e,t){return qx(bR,e,t)}var SR=J("ZodObject",(e,t)=>{na(),W0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wy(e,n,i,r),QT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Cn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Cn(this._zod.def,{catchall:Jr()}))},loose(){return this.clone(Cn(this._zod.def,{catchall:Jr()}))},strict(){return this.clone(Cn(this._zod.def,{catchall:vR()}))},strip(){return this.clone(Cn(this._zod.def,{catchall:void 0}))},extend(e){return WT(this,e)},safeExtend(e){return ZT(this,e)},merge(e){return XT(this,e)},pick(e){return HT(this,e)},omit(e){return $T(this,e)},partial(...e){return Vg(Dd,this,e[0])},exactPartial(...e){return Vg(sv,this,e[0],"exactPartial")},required(...e){return jT(ov,this,e[0])}});function we(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new SR(n)}var iv=J("ZodUnion",(e,t)=>{cd.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r),e.options=t.options});function ia(e,t){return new iv({type:"union",options:e,...Ce(t)})}var MR=J("ZodDiscriminatedUnion",(e,t)=>{iv.init(e,t),Z0.init(e,t)});function ii(e,t,n){return new MR({type:"union",options:t,discriminator:e,...Ce(n)})}var wR=J("ZodIntersection",(e,t)=>{X0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r)});function ER(e,t){return new wR({type:"intersection",left:e,right:t})}var AR=J("ZodTuple",(e,t)=>{na(),j0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Dd({type:"optional",innerType:t}))})}});function rv(e,t,n){let i=t instanceof vt,r=i?n:t;return new AR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var Jy=J("ZodRecord",(e,t)=>{na(),q0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ol(e,t,n){if(!t||!t._zod)return new Jy({type:"record",keyType:Xe(),valueType:e,...Ce(t)});return new Jy({type:"record",keyType:e,valueType:t,...Ce(n)})}var Nd=J("ZodEnum",(e,t)=>{Y0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>xy(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 Nd({...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 Nd({...t,checks:[],...Ce(r),entries:s})}});function Ct(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Nd({type:"enum",entries:n,...Ce(t)})}var TR=J("ZodLiteral",(e,t)=>{J0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yy(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 Fe(e,t){return new TR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var RR=J("ZodTransform",(e,t)=>{na(),K0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sy(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Zo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(qr(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(qr(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 CR(e){return new RR({type:"transform",transform:e})}var Dd=J("ZodOptional",(e,t)=>{ld.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Id(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Ky(e){return new Dd({type:"optional",innerType:e})}var sv=J("ZodExactOptional",(e,t)=>{Q0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Id(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function PR(e){return new sv({type:"optional",innerType:e})}var IR=J("ZodNullable",(e,t)=>{ex.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Qy(e){return new IR({type:"nullable",innerType:e})}var LR=J("ZodDefault",(e,t)=>{tx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function NR(e,t){return new LR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Gh(t)}})}var DR=J("ZodPrefault",(e,t)=>{nx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ny(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function OR(e,t){return new DR({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Gh(t)}})}var ov=J("ZodNonOptional",(e,t)=>{ix.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Py(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function UR(e,t){return new ov({type:"nonoptional",innerType:e,...Ce(t)})}var FR=J("ZodCatch",(e,t)=>{rx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function zR(e,t){return new FR({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Zg(t)})}var kR=J("ZodPipe",(e,t)=>{sx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Oy(e,n,i,r),e.in=t.in,e.out=t.out});function ev(e,t){return new kR({type:"pipe",in:e,out:t})}var BR=J("ZodReadonly",(e,t)=>{ox.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function VR(e){return new BR({type:"readonly",innerType:e})}var GR=J("ZodTemplateLiteral",(e,t)=>{ax.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vy(e,n,i,r)});function HR(e,t){return new GR({type:"template_literal",parts:e,...Ce(t)})}var $R=J("ZodCustom",(e,t)=>{cx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>by(e,n,i,r)});function WR(e,t={}){return Yx($R,e,t)}function ZR(e,t){return Jx(e,t)}var av=["neutral","dark","light"];var Ud=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),cv=Object.freeze({neutral:Ud("neutral",[170,177,188]),dark:Ud("dark",[26,26,26]),light:Ud("light",[223,227,232])});var GD=cv.neutral.rgb,HD=cv.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 iy(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;iy(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 ry=new Set(["type","properties","required","additionalProperties"]),ty=["oneOf","anyOf"];function ny(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 Ed(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!ry.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]??ny(l);if(u===null||u===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Ed(a)??{allOf:a};Gn(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=ny(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 z1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of ry)if(r in e)return;let n=t.filter((r)=>ty.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Ed(t);else{let r=n[0],s=ty.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)=>Ed([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,ta(e,i)}function Rd(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},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),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 ta(l,m);if(ta(l,u),a._zod.parent===d)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 h=a._zod.parent;if(h&&h!==d){i(h);let f=e.seen.get(h);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())iy(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 d=a.get(u);if(d)d.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])z1(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)}ta(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;Gn(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:na(t,"input",e.processors),output:na(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 sy=(e,t={})=>(n)=>{let i=Ad({...n,processors:t});return It(e,i),Td(i,e),Rd(i,e)},na=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Ad({...r??{},target:s,io:t,processors:n});return It(e,o),Td(o,e),Rd(o,e)};var Xs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},js=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},oy=(e,t)=>{Xs(e,"minimum",t),js(e,"maximum",t)},uy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},hy=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},dy=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},fy=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ay=(e,t)=>Xs(e,"minimum",t.minimum),cy=(e,t)=>js(e,"maximum",t.maximum),ly=(e)=>(t,n)=>{fy(t,n.format);let[i,r]=e[n.format];Xs(t,"minimum",i),js(t,"maximum",r)},k1={greater_than:(e,t)=>Xs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>js(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>uy(e,t.value),number_format:ly(Lc),bigint_format:ly(Wh),min_length:ay,max_length:cy,length_equals:(e,t)=>oy(e,t.length),min_size:ay,max_size:cy,size_equals:(e,t)=>oy(e,t.size),string_format:(e,t)=>{if(fy(e,t.format),t.pattern)hy(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)=>dy(e,t.mime)};function Pn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)k1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Xs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Xs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)js(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)js(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)uy(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)dy(t,r.mime);for(let s of r.patterns??[])hy(t,s);return t}var B1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},V1=new Map([[ad,A_],[jc,T_]]),py=(e)=>V1.get(e)??e,my=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Pn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=B1[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 d=[...c].map(py);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},gy=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Pn(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)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 qi(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}))]}},_y=(e,t,n,i)=>{n.type="boolean"};var xy=(e,t,n,i)=>{n.not={}};var yy=(e,t,n,i)=>{};var vy=(e,t,n,i)=>{let r=e._zod.def,s=$o(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},by=(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(qi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(qi(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 Sy=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var My=(e,t,n,i)=>{qi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var wy=(e,t,n,i)=>{qi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var Ey=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Pn(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 ia(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ia(t.out);if(t.type==="catch")return ia(t.innerType);return e._zod.optin}var Ay=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&qi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Gn(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"?ia(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"]})},Ty=(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},Ry=(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)},Cy=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ia(_)!==void 0:_._zod.optout==="optional"))break;u--}let d=s.items.length,h=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,h)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(h)r.maxItems=d}else{if(r.items=c,h)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}let{minimum:f,maximum:m}=Pn(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function Cd(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 _=Cd(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>Cd(e,g,n));if(p.some((g,S)=>g!==_[S]))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:d,id:h,...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")?Ws:Gc).source;return f}var Pd=new WeakMap;function G1(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 Pd.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Cd(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 Py=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Pn(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 d of a)Gn(r.patternProperties,py(d).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=Pd.get(t);if(!u)u=[],Pd.set(t,u),t.deferred.push(()=>G1(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ia(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},Iy=(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"}]},Ly=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Id=Symbol();function Ny(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 qi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Id}var Dy=(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=Ny(r.defaultValue,e,t,n,i);if(o!==Id)n.default=o},Oy=(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=Ny(r.defaultValue,e,t,n,i);if(o!==Id)n._prefault=o},Uy=(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{qi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Fy=(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},zy=(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 Ld=(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 ky=new WeakSet([Object.prototype,Error.prototype]);function rl(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 Y1=(e,t)=>{Qg.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(ky.has(n))return;ky.add(n),rl(n,"format",(i)=>(r)=>t_(i,r)),rl(n,"flatten",(i)=>(r)=>e_(i,r)),rl(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Wo,2)}),rl(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Wo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var In=J("ZodError",Y1,void 0,{Parent:Error});var By=zc(In),Vy=kc(In),Gy=Bc(In),Hy=Vc(In),$y=i_(In),Wy=r_(In),Zy=s_(In),Xy=o_(In),jy=a_(In),qy=c_(In),Yy=l_(In),Jy=u_(In);function K1(){if(!dn.localeError)Cn(fd())}function ra(){if(!dn.memoizer)Cn({memoizer:mx()})}var Ct=J("ZodType",(e,t)=>(K1(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Rn(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 vi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(JR(e,t))},superRefine(e,t){return this.check(KR(e,t))},overwrite(e){return this.check(wr(e))},optional(){return ev(this)},exactOptional(){return UR(this)},nullable(){return tv(this)},nullish(){return ev(tv(this))},nonoptional(e){return GR(this,e)},array(){return _t(this)},or(e){return qs([this,e])},and(e){return IR(this,e)},transform(e){return nv(this,OR(e))},default(e){return kR(this,e)},prefault(e){return VR(this,e)},catch(e){return $R(this,e)},pipe(e){return nv(this,e)},readonly(){return XR(this)},describe(e){let t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yr.get(this);let t=this.clone();return Yr.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 Uc(this,"~standard",{...od(this),jsonSchema:{input:na(this,"input"),output:na(this,"output")}})},set "~standard"(e){Xi(this,"~standard",e)},parse:function e(t,n){return By(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Vy(this,t,n,{callee:e})},safeParse(e,t){return Gy(this,e,t)},async safeParseAsync(e,t){return Hy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Xi(this,"spa",e)},validate(e,t){return Yh(this,e,t)},validateAsync(e,t){return Jh(this,e,t)},encode:function e(t,n){return $y(this,t,n,{callee:e})},decode:function e(t,n){return Wy(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Zy(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Xy(this,t,n,{callee:e})},safeEncode(e,t){return jy(this,e,t)},safeDecode(e,t){return qy(this,e,t)},async safeEncodeAsync(e,t){return Yy(this,e,t)},async safeDecodeAsync(e,t){return Jy(this,e,t)},toJSONSchema(e){return sy(this,{})(e)},get description(){return Yr.get(this)?.description},get _def(){return this._zod.def}}),iv=J("_ZodString",(e,t)=>{Xc.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>my(e,n,i,r)},Xg({format:(e)=>Pn(e).format??null,minLength:(e)=>Pn(e).minimum??null,maxLength:(e)=>Pn(e).maximum??null},{regex(...e){return this.check(pd(...e))},includes(...e){return this.check(_d(...e))},startsWith(...e){return this.check(xd(...e))},endsWith(...e){return this.check(yd(...e))},min(...e){return this.check(Zs(...e))},max(...e){return this.check(nl(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(Zs(1,...e))},lowercase(e){return this.check(md(e))},uppercase(e){return this.check(gd(e))},trim(){return this.check(bd())},normalize(...e){return this.check(vd(...e))},toLowerCase(){return this.check(Sd())},toUpperCase(){return this.check(Md())},slugify(){return this.check(wd())}})),Q1=J("ZodString",(e,t)=>{Xc.init(e,t),iv.init(e,t)},{email(e){return this.check(vx(rR,e))},url(e){return this.check(Ax(oR,e))},jwt(e){return this.check(Vx(bR,e))},emoji(e){return this.check(Tx(aR,e))},guid(e){return this.check(bx(sR,e))},uuid(e){return this.check(Sx(sl,e))},uuidv4(e){return this.check(Mx(sl,e))},uuidv6(e){return this.check(wx(sl,e))},uuidv7(e){return this.check(Ex(sl,e))},nanoid(e){return this.check(Rx(cR,e))},cuid(e){return this.check(Cx(lR,e))},cuid2(e){return this.check(Px(uR,e))},ulid(e){return this.check(Ix(hR,e))},base64(e){return this.check(zx(xR,e))},base64url(e){return this.check(kx(yR,e))},xid(e){return this.check(Lx(dR,e))},ksuid(e){return this.check(Nx(fR,e))},ipv4(e){return this.check(Dx(pR,e))},ipv6(e){return this.check(Ox(mR,e))},cidrv4(e){return this.check(Ux(gR,e))},cidrv6(e){return this.check(Fx(_R,e))},e164(e){return this.check(Bx(vR,e))},datetime(e){return this.check(Gx(eR,e))},date(e){return this.check(Hx(tR,e))},time(e){return this.check($x(nR,e))},duration(e){return this.check(Wx(iR,e))}});function Xe(e){return yx(Q1,e)}var Lt=J("ZodStringFormat",(e,t)=>{Rt.init(e,t),iv.init(e,t)}),eR=J("ZodISODateTime",(e,t)=>{A0.init(e,t),Lt.init(e,t)}),tR=J("ZodISODate",(e,t)=>{T0.init(e,t),Lt.init(e,t)}),nR=J("ZodISOTime",(e,t)=>{R0.init(e,t),Lt.init(e,t)}),iR=J("ZodISODuration",(e,t)=>{C0.init(e,t),Lt.init(e,t)}),rR=J("ZodEmail",(e,t)=>{m0.init(e,t),Lt.init(e,t)});var sR=J("ZodGUID",(e,t)=>{f0.init(e,t),Lt.init(e,t)});var sl=J("ZodUUID",(e,t)=>{p0.init(e,t),Lt.init(e,t)});var oR=J("ZodURL",(e,t)=>{x0.init(e,t),Lt.init(e,t)});var aR=J("ZodEmoji",(e,t)=>{y0.init(e,t),Lt.init(e,t)});var cR=J("ZodNanoID",(e,t)=>{v0.init(e,t),Lt.init(e,t)});var lR=J("ZodCUID",(e,t)=>{b0.init(e,t),Lt.init(e,t)});var uR=J("ZodCUID2",(e,t)=>{S0.init(e,t),Lt.init(e,t)});var hR=J("ZodULID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var dR=J("ZodXID",(e,t)=>{w0.init(e,t),Lt.init(e,t)});var fR=J("ZodKSUID",(e,t)=>{E0.init(e,t),Lt.init(e,t)});var pR=J("ZodIPv4",(e,t)=>{P0.init(e,t),Lt.init(e,t)});var mR=J("ZodIPv6",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var gR=J("ZodCIDRv4",(e,t)=>{N0.init(e,t),Lt.init(e,t)});var _R=J("ZodCIDRv6",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var xR=J("ZodBase64",(e,t)=>{U0.init(e,t),Lt.init(e,t)});var yR=J("ZodBase64URL",(e,t)=>{F0.init(e,t),Lt.init(e,t)});var vR=J("ZodE164",(e,t)=>{z0.init(e,t),Lt.init(e,t)});var bR=J("ZodJWT",(e,t)=>{k0.init(e,t),Lt.init(e,t)});var rv=J("ZodNumber",(e,t)=>{cd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gy(e,n,i,r),e.isFinite=!0},Xg({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Pn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Pn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Pn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Pn(e).format??null},{gt(e,t){return this.check(el(e,t))},gte(e,t){return this.check(ea(e,t))},min(e,t){return this.check(ea(e,t))},lt(e,t){return this.check(Qc(e,t))},lte(e,t){return this.check(Qo(e,t))},max(e,t){return this.check(Qo(e,t))},int(e){return this.check(Ky(e))},safe(e){return this.check(Ky(e))},positive(e){return this.check(el(0,e))},nonnegative(e){return this.check(ea(0,e))},negative(e){return this.check(Qc(0,e))},nonpositive(e){return this.check(Qo(0,e))},multipleOf(e,t){return this.check(tl(e,t))},step(e,t){return this.check(tl(e,t))},finite(){return this}}));function et(e){return Zx(rv,e)}var SR=J("ZodNumberFormat",(e,t)=>{B0.init(e,t),rv.init(e,t)});function Ky(e){return Xx(SR,e)}var MR=J("ZodBoolean",(e,t)=>{V0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_y(e,n,i,r)});function Kr(e){return jx(MR,e)}var wR=J("ZodUnknown",(e,t)=>{G0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yy(e,n,i,r)});function Jr(){return qx(wR)}var ER=J("ZodNever",(e,t)=>{H0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xy(e,n,i,r)});function AR(e){return Yx(ER,e)}var TR=J("ZodArray",(e,t)=>{ra(),$0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Zs(e,t))},nonempty(e){return this.check(Zs(1,e))},max(e,t){return this.check(nl(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function _t(e,t){return Jx(TR,e,t)}var RR=J("ZodObject",(e,t)=>{ra(),X0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r),s1(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return wt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Rn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Rn(this._zod.def,{catchall:Jr()}))},loose(){return this.clone(Rn(this._zod.def,{catchall:Jr()}))},strict(){return this.clone(Rn(this._zod.def,{catchall:AR()}))},strip(){return this.clone(Rn(this._zod.def,{catchall:void 0}))},extend(e){return JT(this,e)},safeExtend(e){return KT(this,e)},merge(e){return QT(this,e)},pick(e){return qT(this,e)},omit(e){return YT(this,e)},partial(...e){return Hg(Od,this,e[0])},exactPartial(...e){return Hg(av,this,e[0],"exactPartial")},required(...e){return e1(cv,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new RR(n)}var sv=J("ZodUnion",(e,t)=>{ld.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r),e.options=t.options});function qs(e,t){return new sv({type:"union",options:e,...Ce(t)})}var CR=J("ZodDiscriminatedUnion",(e,t)=>{sv.init(e,t),j0.init(e,t)});function ni(e,t,n){return new CR({type:"union",options:t,discriminator:e,...Ce(n)})}var PR=J("ZodIntersection",(e,t)=>{q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r)});function IR(e,t){return new PR({type:"intersection",left:e,right:t})}var LR=J("ZodTuple",(e,t)=>{ra(),Y0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Od({type:"optional",innerType:t}))})}});function ov(e,t,n){let i=t instanceof vt,r=i?n:t;return new LR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var Qy=J("ZodRecord",(e,t)=>{ra(),J0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Py(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ol(e,t,n){if(!t||!t._zod)return new Qy({type:"record",keyType:Xe(),valueType:e,...Ce(t)});return new Qy({type:"record",keyType:e,valueType:t,...Ce(n)})}var Dd=J("ZodEnum",(e,t)=>{K0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(i,r,s)=>vy(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 Dd({...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 Dd({...t,checks:[],...Ce(r),entries:s})}});function wt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Dd({type:"enum",entries:n,...Ce(t)})}var NR=J("ZodLiteral",(e,t)=>{Q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>by(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 Oe(e,t){return new NR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var DR=J("ZodTransform",(e,t)=>{ra(),ex.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wy(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new jo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(qr(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(qr(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 OR(e){return new DR({type:"transform",transform:e})}var Od=J("ZodOptional",(e,t)=>{ud.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ld(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ev(e){return new Od({type:"optional",innerType:e})}var av=J("ZodExactOptional",(e,t)=>{tx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ld(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function UR(e){return new av({type:"optional",innerType:e})}var FR=J("ZodNullable",(e,t)=>{nx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Iy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function tv(e){return new FR({type:"nullable",innerType:e})}var zR=J("ZodDefault",(e,t)=>{ix.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kR(e,t){return new zR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Hh(t)}})}var BR=J("ZodPrefault",(e,t)=>{rx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Oy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function VR(e,t){return new BR({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Hh(t)}})}var cv=J("ZodNonOptional",(e,t)=>{sx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function GR(e,t){return new cv({type:"nonoptional",innerType:e,...Ce(t)})}var HR=J("ZodCatch",(e,t)=>{ox.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $R(e,t){return new HR({type:"catch",innerType:e,catchValue:typeof t==="function"?t:jg(t)})}var WR=J("ZodPipe",(e,t)=>{ax.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fy(e,n,i,r),e.in=t.in,e.out=t.out});function nv(e,t){return new WR({type:"pipe",in:e,out:t})}var ZR=J("ZodReadonly",(e,t)=>{cx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function XR(e){return new ZR({type:"readonly",innerType:e})}var jR=J("ZodTemplateLiteral",(e,t)=>{lx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sy(e,n,i,r)});function qR(e,t){return new jR({type:"template_literal",parts:e,...Ce(t)})}var YR=J("ZodCustom",(e,t)=>{ux.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>My(e,n,i,r)});function JR(e,t={}){return Kx(YR,e,t)}function KR(e,t){return Qx(e,t)}var lv=["neutral","dark","light"];var Fd=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),uv=Object.freeze({neutral:Fd("neutral",[170,177,188]),dark:Fd("dark",[26,26,26]),light:Fd("light",[223,227,232])});var YD=uv.neutral.rgb,JD=uv.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,Nn=Uint16Array,Wd=Int32Array,al=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]),cl=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]),Bd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mv=function(e,t){var n=new Nn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Wd(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}},gv=mv(al,2),{b:_v,r:Vd}=gv;_v[28]=258,Vd[258]=28;var xv=mv(cl,0),{b:XR,r:lv}=xv,Gd=new Nn(32768);for(Qe=0;Qe<32768;++Qe)Ei=(Qe&43690)>>1|(Qe&21845)<<1,Ei=(Ei&52428)>>2|(Ei&13107)<<2,Ei=(Ei&61680)>>4|(Ei&3855)<<4,Gd[Qe]=((Ei&65280)>>8|(Ei&255)<<8)>>1;var Ei,Qe,Ai=function(e,t,n){var i=e.length,r=0,s=new Nn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new Nn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new Nn(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[Gd[h]>>c]=l}}else{a=new Nn(i);for(r=0;r<i;++r)if(e[r])a[r]=Gd[o[e[r]-1]++]>>15-e[r]}return a},Er=new Dt(288);for(Qe=0;Qe<144;++Qe)Er[Qe]=8;var Qe;for(Qe=144;Qe<256;++Qe)Er[Qe]=9;var Qe;for(Qe=256;Qe<280;++Qe)Er[Qe]=7;var Qe;for(Qe=280;Qe<288;++Qe)Er[Qe]=8;var Qe,oa=new Dt(32);for(Qe=0;Qe<32;++Qe)oa[Qe]=5;var Qe,jR=Ai(Er,9,0),qR=Ai(Er,9,1),YR=Ai(oa,5,0),JR=Ai(oa,5,1),Fd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ri=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},zd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Zd=function(e){return(e+7)/8|0},Xd=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 KR=["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"],$n=function(e,t,n){var i=Error(t||KR[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,$n);if(!n)throw i;return i},QR=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 wt=n.length;if(Ae>wt){var Ge=new Dt(Math.max(wt*2,Ae));Ge.set(n),n=Ge}},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=ri(e,h,1);var S=ri(e,h+1,3);if(h+=3,!S){var T=Zd(h)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)$n(0);break}if(a)l(d+y);n.set(e.subarray(T,w),d),t.b=d+=y,t.p=h=w*8,t.f=u;continue}else if(S==1)f=qR,m=JR,_=9,p=5;else if(S==2){var A=ri(e,h,31)+257,R=ri(e,h+10,15)+4,x=A+ri(e,h+5,31)+1;h+=14;var M=new Dt(x),z=new Dt(19);for(var C=0;C<R;++C)z[Bd[C]]=ri(e,h+C*3,7);h+=R*3;var L=Fd(z),K=(1<<L)-1,I=Ai(z,L,1);for(var C=0;C<x;){var G=I[ri(e,h,K)];h+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ri(e,h,3),h+=2,X=M[C-1];else if(T==17)P=3+ri(e,h,7),h+=3;else if(T==18)P=11+ri(e,h,127),h+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),k=M.subarray(A);_=Fd(j),p=Fd(k),f=Ai(j,_,1),m=Ai(k,p,1)}else $n(1);if(h>g){if(c)$n(0);break}}if(a)l(d+131072);var q=(1<<_)-1,ee=(1<<p)-1,Se=h;for(;;Se=h){var X=f[zd(e,h)&q],ue=X>>4;if(h+=X&15,h>g){if(c)$n(0);break}if(!X)$n(2);if(ue<256)n[d++]=ue;else if(ue==256){Se=h,f=null;break}else{var Be=ue-254;if(ue>264){var C=ue-257,Me=al[C];Be=ri(e,h,(1<<Me)-1)+_v[C],h+=Me}var Z=m[zd(e,h)&ee],re=Z>>4;if(!Z)$n(3);h+=Z&15;var k=XR[re];if(re>3){var Me=cl[re];k+=zd(e,h)&(1<<Me)-1,h+=Me}if(h>g){if(c)$n(0);break}if(a)l(d+131072);var se=d+Be;if(d<k){var xe=s-k,Ee=Math.min(k,se);if(xe+d<0)$n(3);for(;d<Ee;++d)n[d]=i[xe+d]}for(;d<se;++d)n[d]=n[d-k]}}if(t.l=f,t.p=Se,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?Xd(n,0,d):n.subarray(0,d)},Ji=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},ra=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},kd=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:vv,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(w,A){return w.f-A.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 Nn(d+1),m=Hd(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=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 y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},Hd=function(e,t,n){return e.s==-1?Math.max(Hd(e.l,t,n+1),Hd(e.r,t,n+1)):t[e.s]=n},uv=function(e){var t=e.length;while(t&&!e[--t]);var n=new Nn(++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}},sa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},yv=function(e,t,n){var i=n.length,r=Zd(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},hv=function(e,t,n,i,r,s,o,a,c,l,u){Ji(t,u++,n),++r[256];var h=kd(r,15),{t:d,l:f}=h,m=kd(s,15),{t:_,l:p}=m,g=uv(d),{c:S,n:T}=g,y=uv(_),{c:w,n:A}=y,R=new Nn(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=kd(R,7),{t:z,l:C}=M,L=19;for(;L>4&&!z[Bd[L-1]];--L);var K=l+5<<3,I=sa(r,Er)+sa(s,oa)+o,G=sa(r,d)+sa(s,_)+o+14+3*L+sa(R,z)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return yv(t,u,e.subarray(c,c+l));var X,P,j,k;if(Ji(t,u,1+(G<I)),u+=2,G<I){X=Ai(d,f,0),P=d,j=Ai(_,p,0),k=_;var q=Ai(z,C,0);Ji(t,u,T-257),Ji(t,u+5,A-1),Ji(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Ji(t,u+3*x,z[Bd[x]]);u+=3*L;var ee=[S,w];for(var Se=0;Se<2;++Se){var ue=ee[Se];for(var x=0;x<ue.length;++x){var Be=ue[x]&31;if(Ji(t,u,q[Be]),u+=z[Be],Be>15)Ji(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=jR,P=Er,j=YR,k=oa;for(var x=0;x<a;++x){var Me=i[x];if(Me>255){var Be=Me>>18&31;if(ra(t,u,X[Be+257]),u+=P[Be+257],Be>7)Ji(t,u,Me>>23&31),u+=al[Be];var Z=Me&31;if(ra(t,u,j[Z]),u+=k[Z],Z>3)ra(t,u,Me>>5&8191),u+=cl[Z]}else ra(t,u,X[Me]),u+=P[Me]}return ra(t,u,X[256]),u+P[256]},eC=new Wd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vv=new Dt(0),tC=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=eC[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new Nn(32768),p=s.h||new Nn(m+1),g=Math.ceil(n/3),S=2*g,T=function(Ye){return(e[Ye]^e[Ye+1]<<g^e[Ye+2]<<S)&m},y=new Wd(25000),w=new Nn(288),A=new Nn(32),R=0,x=0,M=s.i||0,z=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||z>24576)&&(X>423||!l)){u=hv(e,c,0,y,w,A,x,z,L,M-L,u),z=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,k=0,q=f,ee=I-G&32767;if(X>2&&K==T(M-ee)){var Se=Math.min(d,X)-1,ue=Math.min(32767,M),Be=Math.min(258,X);while(ee<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-ee]){var Me=0;for(;Me<Be&&e[M+Me]==e[M+Me-ee];++Me);if(Me>j){if(j=Me,k=ee,Me>Se)break;var Z=Math.min(ee,Me-2),re=0;for(var P=0;P<Z;++P){var se=M-ee+P&32767,xe=_[se],Ee=se-xe&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],ee+=I-G&32767}}if(k){y[z++]=268435456|Vd[j]<<18|lv[k];var Ae=Vd[j]&31,wt=lv[k]&31;x+=al[Ae]+cl[wt],++w[257+Ae],++A[wt],C=M+j,++R}else y[z++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[z++]=e[M],++w[e[M]];if(u=hv(e,c,l,y,w,A,x,z,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var Ge=M+65535;if(Ge>=o)c[u/8|0]=l,Ge=o;u=yv(c,u+1,e.subarray(M,Ge))}s.i=o}return Xd(a,0,i+Zd(u)+r)},nC=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}(),iC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=nC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var rC=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 tC(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)},bv=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 Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Sv(e,t){return rC(e,t||{},0,0)}function Mv(e,t){return QR(e,{i:2},t&&t.out,t&&t.dictionary)}var wv=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=bv(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],wv(s,o,n,i)}},dv=typeof TextEncoder<"u"&&new TextEncoder,sC=typeof TextDecoder<"u"&&new TextDecoder,oC=0;try{sC.decode(vv,{stream:!0}),oC=1}catch(e){}function fv(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(dv)return dv.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 Xd(s,0,o)}var $d=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)$n(9);t+=i+4}return t},pv=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=$d(l);if(Qt(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)$n(10);if(Qt(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,h),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},aC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Ev(e,t){if(!t)t={};var n={},i=[];wv(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=fv(o),d=h.length,f=l.comment,m=f&&fv(f),_=m&&m.length,p=$d(l.extra);if(d>65535)$n(11);var g=u?Sv(c,l):c,S=g.length,T=iC();T.p(c),i.push(bv(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+S,s+=76+2*(d+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var h=i[R];pv(y,h.o,h,h.f,h.u,h.c.length);var x=30+h.f.length+$d(h.extra);y.set(h.c,h.o+x),pv(y,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+x+(h.m?h.m.length:0)}return aC(y,r,i.length,A,w),y}var Ti=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function cC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";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 aa extends Error{diagnostic;constructor(e,t=cC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var ll=1024,ul=4,hl=8,qd=6,Av=80,es=256;class rt extends aa{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Tv=["solid","checker","stripes","gradient","bricks","noise"],Rv=["normal","multiply","screen","overlay"],lC=new Set(["__proto__","prototype","constructor"]);function dl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new rt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new rt(`${t} must not contain symbol keys.`);if(lC.has(i))throw new rt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new rt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new rt(`${t}.${i} must be a plain JSON data field.`)}return e}function uC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new rt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new rt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new rt(`${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 rt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Ar(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new rt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function si(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new rt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Qr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new rt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Pv(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 rt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function jd(e,t,n){return Pv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function hC(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>Av||n)throw new rt(`${t} must be 1..${Av} visible characters.`);return e}function dC(e,t,n){if(e===void 0)return n;if(!Ti.includes(e))throw new rt(`${t} must be one of ${Ti.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Cv(e,t){let i=(Pv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function fC(e,t){let n=e.blend??"normal";if(!Rv.includes(n))throw new rt(`${t}.blend ${JSON.stringify(n)} is not one of ${Rv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function pC(e,t){let n=`proceduralTexture.layers[${t}]`,i=dl(e,n),r=i.op;if(!Tv.includes(r))throw new rt(`${n}.op ${JSON.stringify(r)} is not one of ${Tv.join(", ")}.`);let s=fC(i,n),o=jd(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return Ar(i,["op","color","blend","opacity"],n),{op:r,color:si(i.color,`${n}.color`),...a};case"checker":return Ar(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:si(i.colorA,`${n}.colorA`),colorB:si(i.colorB,`${n}.colorB`),squares:Qr(i.squares,`${n}.squares`,8,1,es),...a};case"stripes":return Ar(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:si(i.colorA,`${n}.colorA`),colorB:si(i.colorB,`${n}.colorB`),count:Qr(i.count,`${n}.count`,8,1,es),angleDeg:Cv(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return Ar(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:si(i.from,`${n}.from`),to:si(i.to,`${n}.to`),angleDeg:Cv(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return Ar(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:si(i.brick,`${n}.brick`),mortar:si(i.mortar,`${n}.mortar`),rows:Qr(i.rows,`${n}.rows`,8,1,es),cols:Qr(i.cols,`${n}.cols`,4,1,es),mortarWidth:jd(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:jd(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return Ar(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:si(i.colorA,`${n}.colorA`),colorB:si(i.colorB,`${n}.colorB`),scale:Qr(i.scale,`${n}.scale`,8,1,es),octaves:Qr(i.octaves,`${n}.octaves`,3,1,qd),seed:Qr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new rt(`${n}.op is unsupported.`)}}function mC(e){let t=dl(e,"proceduralTexture");if(Ar(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new rt(`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 ca(e){let t=dl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?dl(mC(t),"proceduralTexture"):t;if(Ar(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new rt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<ul||i>ll||(i&i-1)!==0)throw new rt(`proceduralTexture.size must be a power of two between ${ul} and ${ll}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new rt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=uC(r,"proceduralTexture.layers");if(s.length>hl)throw new rt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${hl}.`);let o=hC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:dC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(pC)}}var gC=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]),Ri=(e,t)=>e>>>t|e<<32-t;function js(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Ri(T,7)^Ri(T,18)^T>>>3,A=Ri(y,17)^Ri(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,h,d,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Ri(f,6)^Ri(f,11)^Ri(f,25),y=f&m^~f&_,w=p+T+y+gC[S]+a[S]>>>0,A=Ri(l,2)^Ri(l,13)^Ri(l,22),R=l&u^l&h^u&h,x=A+R>>>0;p=_,_=m,m=f,f=d+w>>>0,d=h,h=u,u=l,l=w+x>>>0}let g=[l,u,h,d,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var qs="kiln.procedural-rgba.v3.1";var ua=1024,_C=1048576,ha=64,pl=64,la=256,ml=32,Iv=64000000,xC=67108864;function tt(e){throw new rt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var yC=new Set(["__proto__","prototype","constructor"]);function vC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)tt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)tt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))tt(`${r} must be finite.`);return}if(typeof i!=="object")tt(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)tt(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))tt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)tt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let h of l){if(typeof h!=="string"||yC.has(h))tt(`${r} has a forbidden key.`);if(o&&h==="length")continue;let d=u[h];if(!d.enumerable||!("value"in d))tt(`${r}.${h} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=c))tt(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)tt(`${r} must be a dense JSON array.`);for(let h of l)if(h!=="length"||!o)n(u[h].value,`${r}.${String(h)}`,s+1)};n(e,"recipe",0)}function Wn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))tt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))tt(`${n} has unknown field ${r}.`);return i}function pn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)tt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Lv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")tt(`${t} must be boolean.`);return e}function fl(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)tt(`${n} must be a ${t}-element array.`);return e.map((s,o)=>pn(s,i,r,`${n}[${o}]`))}function Nv(e,t){let n=fl(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function Dv(e,t,n){let i=Wn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:pn(i.x,-4096,4096,`${t}.x`),y:pn(i.y,-4096,4096,`${t}.y`),width:pn(i.width,1,2048,`${t}.width`),height:pn(i.height,1,2048,`${t}.height`)}}function bC(e,t){let n=Wn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...Dv(n,t,n.kind)};if(n.kind==="polygon"){Wn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>pl)tt(`${t}.points requires 3..${pl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>fl(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return Wn(n,["kind","from","to","width"],t),{kind:"line",from:fl(n.from,2,`${t}.from`,-4096,4096),to:fl(n.to,2,`${t}.to`,-4096,4096),width:pn(n.width,1,2048,`${t}.width`)};return tt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function Ov(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function SC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function MC(e,t,n,i=0,r=0){let[s,o,a,c]=Ov(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function gl(e){vC(e);let t=Wn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)tt("schemaVersion must be 3.");let n=pn(t.width,4,ua,"width"),i=pn(t.height,4,ua,"height"),r=n*i;if(r>_C)tt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ti.includes(s))tt("usage must be a known texture usage.");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))tt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>ha)tt(`operations must be an array with at most ${ha} entries.`);let l=r,u=0,h=0,d=c.map((p,g)=>{let S=`operations[${g}]`,T=Wn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){Wn(T,["op","spec","alpha","opacity"],S);let j=Wn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)tt(`${S}.spec requires explicit schemaVersion 2.`);let k=ca(j);if(k.size!==n||k.size!==i||k.usage!==s)tt(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+k.layers.reduce((q,ee)=>q+(ee.op==="noise"?ee.octaves*16:4),0)),h+=r*4,{op:"legacy-v2",spec:k,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)}}let y=bC(T.shape,`${S}.shape`),w=SC(y),[A,R,x,M]=MC(y,n,i),z=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return Wn(T,["op","shape","alpha","invert"],S),l+=r+z*w,{op:"mask",shape:y,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),invert:Lv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return tt(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Nv(T.rgba,`${S}.rgba`),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return Wn(T,["op","shape","rgba","opacity"],S),l+=z*(w+1),{op:"paint",...C};if(Wn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S),!o)tt("stamps are supported only for color usages albedo and emissive.");let L=pn(T.count,1,la,`${S}.count`),K=Lv(T.periodic,`${S}.periodic`),[I,G,X,P]=Ov(y);if(K&&(X-I>n||P-G>i))tt(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>la)tt(`expanded stamps budget exceeds ${la}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:pn(T.seed,0,4294967295,`${S}.seed`),area:Dv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)tt("palette and dither are supported only for color usages albedo and emissive.");let p=Wn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>ml)tt(`palette.colors requires 1..${ml} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")tt("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>pn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Iv)tt(`estimated work budget ${l} exceeds ${Iv}.`);if(r*4+h>xC)tt("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Nv(t.background,"background"),operations:d,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)tt("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+h}}function Yd(e){return gl(e).spec}function wC(e){return gl(e).canonicalJson}function Jd(e){return`sha256:${js(`${qs}
-${wC(e)}`)}`}var Kd=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],Qd=["nearest","linear"],da=["repeat","clamp-to-edge","mirrored-repeat"];function _l(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new rt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new rt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Kd,magFilter:Qd,wrapS:da,wrapT:da};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new rt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new rt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Ys="kiln.texture-atlas.v1.1",mn=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728});class Fv extends aa{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function ke(e){throw new Fv(e)}function tf(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>mn.jsonBytes)ke("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)ke("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))ke("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)ke("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")ke("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)ke("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))ke("JSON array budget exceeded.");let h=Reflect.ownKeys(o);if(h.length>1024||c&&h.length!==u+1)ke("dense bounded JSON fields are required.");r(2+Math.max(0,h.length-(c?1:0)-1));for(let d of h){if(c&&d==="length")continue;if(typeof d!=="string"||["__proto__","prototype","constructor"].includes(d))ke("forbidden JSON field.");if(d.length>4096)ke("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(d)).length+1);let f=Object.getOwnPropertyDescriptor(o,d);if(!f.enumerable||!("value"in f))ke("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=u))ke("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function bn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))ke(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))ke(`${n} has an unknown field.`);return i}function Zn(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)ke(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Tr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))ke(`${t} must be an exact SHA-256 hash.`);return e}function Uv(e,t){let n=bn(e,["x","y","width","height"],t);return{x:Zn(n.x,0,4096,`${t}.x`),y:Zn(n.y,0,4096,`${t}.y`),width:Zn(n.width,1,4096,`${t}.width`),height:Zn(n.height,1,4096,`${t}.height`)}}function fa(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function zv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)ke("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)ke("source crop/content dimensions must match; resampling is unsupported.")}function ef(e){return e.kind==="procedural"?`procedural:${Jd(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}function pa(e){tf(e);let t=bn(e,["schemaVersion","width","height","usage","sampler","regions"],"atlas");if(t.schemaVersion!==1)ke("schemaVersion must be 1.");let n=Zn(t.width,4,mn.edge,"width"),i=Zn(t.height,4,mn.edge,"height");if(!Ti.includes(t.usage))ke("usage must be a texture usage.");let r=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>mn.regions)ke("regions must contain 1..64 entries.");let s=t.regions.map((c,l)=>{let u=bn(c,["name","content","gutter","edgeMode","source","crop"],`regions[${l}]`);if(typeof u.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(u.name))ke("region name must be a stable lowercase identifier.");let h=Uv(u.content,"content"),d=u.gutter===void 0?2:Zn(u.gutter,0,32,"gutter"),f=u.edgeMode===void 0?"copy-edge":u.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(f))ke("unsupported edgeMode.");if(f==="mask-rgb-dilate"&&r!=="albedo"&&r!=="emissive")ke("mask RGB dilation requires color usage.");let m=bn(u.source,["kind","spec","resourceId","pin","expected"],"source"),_,p=u.crop===void 0?void 0:Uv(u.crop,"crop");if(m.kind==="procedural"){bn(m,["kind","spec"],"procedural source");let T=gl(m.spec);if(T.spec.usage!==r)ke("source usage does not match atlas usage.");_={kind:"procedural",spec:T.spec},p??={x:0,y:0,width:T.spec.width,height:T.spec.height},zv(p,h,T.spec.width,T.spec.height)}else if(m.kind==="resource"){if(bn(m,["kind","resourceId","pin","expected"],"resource source"),typeof m.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(m.resourceId))ke("source resourceId must be an exact returned map ID.");let T=bn(m.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof T.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(T.resourceId))ke("pin resourceId must be a material ID.");let y=Tr(T.revisionId,"pin revisionId"),w=Tr(T.sha256,"pin sha256");if(y!==w)ke("source pin revision/hash mismatch.");let A;if(m.expected!==void 0){let R=bn(m.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");A={...R.width===void 0?{}:{width:Zn(R.width,1,4096,"expected.width")},...R.height===void 0?{}:{height:Zn(R.height,1,4096,"expected.height")},...R.imageSha256===void 0?{}:{imageSha256:Tr(R.imageSha256,"expected.imageSha256")},...R.decodedPixelHash===void 0?{}:{decodedPixelHash:Tr(R.decodedPixelHash,"expected.decodedPixelHash")}}}if(_={kind:"resource",resourceId:m.resourceId,pin:{resourceId:T.resourceId,revisionId:y,sha256:w},...A?{expected:A}:{}},p&&(p.width!==h.width||p.height!==h.height))ke("source crop/content dimensions must match; resampling is unsupported.")}else ke("source kind must be procedural or pinned resource.");let g={name:u.name,content:h,gutter:d,edgeMode:f,source:_,...p?{crop:p}:{}},S=fa(g);if(S.x<0||S.y<0||S.x+S.width>n||S.y+S.height>i)ke("padded allocation is out of bounds.");return g}).sort((c,l)=>c.name<l.name?-1:c.name>l.name?1:0);if(new Set(s.map((c)=>c.name)).size!==s.length)ke("duplicate region name.");for(let c=0;c<s.length;c++)for(let l=c+1;l<s.length;l++){let u=fa(s[c]),h=fa(s[l]);if(u.x<h.x+h.width&&h.x<u.x+u.width&&u.y<h.y+h.height&&h.y<u.y+u.height)ke(`padded allocations overlap: ${s[c].name}, ${s[l].name}.`)}if(new Set(s.map((c)=>ef(c.source))).size>mn.sources)ke("distinct source budget exceeds 16.");let o;try{o=_l(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(c){ke(`sampler: ${c.message}`)}let a={schemaVersion:1,width:n,height:i,usage:r,sampler:o,regions:s};if(new TextEncoder().encode(JSON.stringify(a)).length>mn.jsonBytes)ke("canonical JSON byte budget exceeded.");return a}function EC(e){return JSON.stringify(pa(e))}function AC(e){return`sha256:${js(`${Ys}
-${EC(e)}`)}`}function Ci(e){tf(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 TC(e){return`sha256:${js(`kiln.atlas-layout.v1
-${Ci({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:fa(t)}))})}`)}`}function nf(e,t){tf(e);let n=pa(t),i=bn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Ys||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")ke("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ci(i.sampler)!==Ci(n.sampler)||i.specHash!==AC(n)||i.layoutHash!==TC(n))ke("manifest sampler/spec/layout identity mismatch.");Tr(i.decodedPixelHash,"manifest decodedPixelHash"),Tr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[ef(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)ke("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=bn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))ke("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)ke("manifest source identity mismatch.");let h=Zn(l.width,1,4096,"manifest source width"),d=Zn(l.height,1,4096,"manifest source height");if(Tr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(bn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),h!==u.spec.width||d!==u.spec.height||l.recipeHash!==Jd(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")ke("manifest procedural source identity mismatch.")}else{bn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=bn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==h||f.height!==d||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))ke("manifest pinned resource descriptor mismatch.");if(Tr(f.imageSha256,"manifest source imageSha256"),Zn(f.encodedByteLength,1,mn.encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)ke("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))ke("manifest source expectation mismatch.")}}s.set(l.id,{width:h,height:d})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=bn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),h=ef(l.source),d=s.get(h),f=l.crop??{x:0,y:0,width:d.width,height:d.height};if(zv(f,l.content,d.width,d.height),u.name!==l.name||u.sourceId!==h||Ci(u.content)!==Ci(l.content)||Ci(u.allocation)!==Ci(fa(l))||Ci(u.crop)!==Ci(f))ke("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${js(`kiln.atlas-manifest.v1
-${Ci(a)}`)}`)ke("manifest hash mismatch.");return structuredClone(e)}var RC=(()=>{let e=et().int().min(0).max(16777215),t=et().int().min(1).max(es),n=et().min(-36000).max(36000),i=et().min(0).max(1),r={blend:Ct(["normal","multiply","screen","overlay"]),opacity:i};return we({schemaVersion:Fe(2),size:et().int().min(ul).max(ll),usage:Ct(Ti),name:Xe().min(1).max(80).optional(),layers:_t(ii("op",[we({op:Fe("solid"),color:e,...r}).strict(),we({op:Fe("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),we({op:Fe("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),we({op:Fe("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),we({op:Fe("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),we({op:Fe("noise"),colorA:e,colorB:e,scale:t,octaves:et().int().min(1).max(qd),seed:et().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(hl)}).strict()})();function kv(e,t=RC){let n=(k,q)=>et().int().min(k).max(q),i=n(0,255),r=n(-4096,4096),s=rv([r,r]),o=rv([i,i,i,i]),a=Ct(Ti),c=HR(["sha256:",Xe().regex(/^[a-f0-9]{64}$/)]),l=Xe().min(1).max(80),u=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),h=Xe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),d={width:n(1,4096),height:n(1,4096)},f=we({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=we({x:n(0,4096),y:n(0,4096),...d}).strict(),_=ii("kind",[f.extend({kind:Fe("rectangle")}).strict(),f.extend({kind:Fe("ellipse")}).strict(),we({kind:Fe("polygon"),points:_t(s).min(3).max(pl)}).strict(),we({kind:Fe("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=we({op:Fe("paint"),shape:_,rgba:o,opacity:i}).strict(),g=we({op:Fe("mask"),shape:_,alpha:i,invert:Kr()}).strict(),S=we({op:Fe("stamps"),shape:_,rgba:o,opacity:i,count:n(1,la),seed:n(0,4294967295),area:f,periodic:Kr()}).strict(),T=we({op:Fe("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=we({colors:_t(n(0,16777215)).min(1).max(ml),dither:Ct(["none","bayer4"])}).strict(),w={schemaVersion:Fe(3),width:n(4,ua),height:n(4,ua),usage:a,name:l.optional(),background:o},A=we({...w,operations:_t(ii("op",[p,g,S,T.extend({spec:t})])).max(ha),palette:y.optional()}).strict(),R=we({...w,usage:a.optional(),background:o.optional(),operations:_t(ii("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(ha),palette:y.partial({dither:!0}).optional()}).strict(),x=we({minFilter:Ct(Kd),magFilter:Ct(Qd),wrapS:Ct(da),wrapT:Ct(da)}).strict(),M=we({resourceId:u,revisionId:c,sha256:c}).strict(),z=we({kind:Fe("resource"),resourceId:h,pin:M,expected:we({...d,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=we({name:u,content:m,gutter:n(0,32),edgeMode:Ct(["copy-edge","mask-rgb-dilate"]),source:ii("kind",[we({kind:Fe("procedural"),spec:A}).strict(),z]),crop:m.optional()}).strict(),L={schemaVersion:Fe(1),width:n(4,mn.edge),height:n(4,mn.edge),usage:a,sampler:x},K=we({...L,regions:_t(C).min(1).max(mn.regions)}).strict(),I=we({...L,sampler:x.optional(),regions:_t(C.extend({source:ii("kind",[we({kind:Fe("procedural"),spec:R}).strict(),z])}).partial({gutter:!0,edgeMode:!0})).min(1).max(mn.regions)}).strict(),G=we({materialId:u,revisionId:c,resourceId:h,slot:Ct(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:Ct(["srgb","linear"]),...d,encodedByteLength:n(1,mn.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),X={id:Xe().min(1).max(1024),...d,decodedPixelHash:c},P=ii("kind",[we({...X,kind:Fe("procedural"),recipeHash:c,compilerId:Fe(qs)}).strict(),we({...X,kind:Fe("resource"),descriptor:G}).strict()]),j=we({version:Fe("kiln.atlas-manifest.v1"),compilerId:Fe(Ys),width:L.width,height:L.height,usage:a,origin:Fe("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:_t(P).min(1).max(mn.sources),regions:_t(we({name:u,content:m,allocation:m,crop:m,sourceId:Xe().min(1).max(1024)}).strict()).min(1).max(mn.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:I,canonicalTextureAtlasSpecV1Schema:K,textureAtlasManifestV1Schema:j,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:G}}var cn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Vv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Gv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Ks=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Ii=Xe().regex(/^sha256:[a-f0-9]{64}$/),Pi=Xe().min(1).max(1000),Bv=Xe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Hv=we({id:Ks,kind:Ct(["external","procedural"]),provider:Pi,creator:Pi,assetId:Pi.optional(),assetUrl:Bv.optional(),accessedAt:Xe().datetime().optional(),license:we({spdx:Pi,url:Bv,attribution:Xe().max(4000)}).strict(),originalFiles:_t(we({name:Xe().min(1).max(200),sha256:Ii,bytes:et().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"})}),$v=we({operation:Pi,tool:Pi,version:Pi,parameters:ol(Xe().max(100),ia([Xe().max(2000),et().finite(),Kr()])).optional()}).strict(),oi=et().int().min(0).max(16777215),ma=et().int().min(1).max(256),Js={blend:Ct(["normal","multiply","screen","overlay"]).default("normal"),opacity:et().min(0).max(1).default(1)},_a=we({schemaVersion:Fe(2),size:et().int().min(4).max(1024).default(256),usage:Ct(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Xe().min(1).max(80).optional(),layers:_t(ii("op",[we({op:Fe("solid"),color:oi,...Js}).strict(),we({op:Fe("checker"),colorA:oi,colorB:oi,squares:ma.default(8),...Js}).strict(),we({op:Fe("stripes"),colorA:oi,colorB:oi,count:ma.default(8),angleDeg:et().min(-36000).max(36000).default(0),...Js}).strict(),we({op:Fe("gradient"),from:oi,to:oi,angleDeg:et().min(-36000).max(36000).default(0),...Js}).strict(),we({op:Fe("bricks"),brick:oi,mortar:oi,rows:ma.default(8),cols:ma.default(4),mortarWidth:et().min(0).max(1).default(0.06),stagger:et().min(0).max(1).default(0.5),...Js}).strict(),we({op:Fe("noise"),colorA:oi,colorB:oi,scale:ma.default(8),octaves:et().int().min(1).max(6).default(3),seed:et().int().min(-2147483648).max(2147483647).default(0),...Js}).strict()])).min(1).max(8)}).strict(),of=we({kind:Fe("normal-from-height"),strength:et().finite().positive().max(64)}).strict(),CC=we({compiler:Fe("kiln.procedural-texture.v2"),spec:_a,derive:of.optional(),recipeHash:Ii,pixelHash:Ii,encoder:we({name:Fe("sharp"),version:Pi}).strict()}).strict(),Wv=we({baseColor:et().int().min(0).max(16777215).optional(),roughness:et().min(0).max(1).default(1),metalness:et().min(0).max(1).default(0),emissive:et().int().min(0).max(16777215).optional(),emissiveIntensity:et().min(0).max(64).default(1),alphaMode:Ct(["opaque","mask","blend"]).default("opaque"),alphaCutoff:et().min(0).max(1).default(0.5),doubleSided:Kr().default(!1)}).strict(),ga=we({schemaVersion:Fe(1),materialId:Ks,revisionId:Ii,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30),tileable:Kr(),physicalSizeMeters:we({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Wv,sources:_t(Hv).min(1).max(20),maps:_t(we({slot:Ct(Vv),file:Ct(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Ii,bytes:et().int().positive().max(cn.maxMapBytes),width:et().int().positive().max(cn.maxMapEdge),height:et().int().positive().max(cn.maxMapEdge),usage:Ct(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Ct(["srgb","linear"]),normalConvention:Fe("opengl").optional(),channelPacking:Fe("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Ks,originalFile:Xe().min(1).max(200).optional(),transforms:_t($v).max(30),procedural:CC.optional()}).strict()).min(1).max(5)}).strict(),rf=we({materialId:Ks,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30).optional(),tileable:Kr(),physicalSizeMeters:we({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Wv.partial().optional(),sources:_t(Hv).min(1).max(20),maps:_t(we({slot:Ct(Vv),sourceId:Ks,transforms:_t($v).max(30),normalConvention:Fe("opengl").optional(),channelPacking:Fe("r-occlusion-g-roughness-b-metallic").optional(),procedural:_a,derive:of.optional()}).strict()).min(1).max(5)}).strict(),sf=we({schemaVersion:Fe(1),records:_t(we({manifest:ga,files:ol(Xe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Xe().max(Math.ceil(cn.maxMapBytes/3)*4))}).strict()).max(cn.maxPayloadRecords)}).strict();function eo(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");eo(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function en(e){eo(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 PC(e){if(eo(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=ga.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!==Gv[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(en(r.procedural.spec)!==en(ca(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>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Qs=kv(_a),Zv=Qs.portableSamplerSchema.refine((e)=>{try{return en(e)===en(_l(e))}catch{return!1}}),IC=Qs.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return en(e)===en(Yd(e))}catch{return!1}}),LC=Qs.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return en(e)===en(pa(e))}catch{return!1}}),NC=Qs.textureAtlasManifestV1Schema,DC=we({resourceId:Ks,revisionId:Ii,sha256:Ii}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),OC=ii("kind",[we({kind:Fe("procedural"),compilerId:Ct(["kiln.procedural-texture.v2",qs]),spec:ia([_a,IC]),recipeHash:Ii,pixelHash:Ii,encoder:we({name:Fe("sharp"),version:Pi}).strict(),derive:of.optional()}).strict(),we({kind:Fe("atlas"),compilerId:Fe(Ys),spec:LC,manifest:NC,encoder:we({name:Fe("sharp"),version:Pi}).strict()}).strict().superRefine((e,t)=>{try{nf(e.manifest,e.spec)}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),Xv=ga.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Fe(2),dependencies:_t(DC).max(16),maps:_t(ga.shape.maps.element.omit({procedural:!0}).extend({sampler:Zv,pixelHash:Ii,recipe:OC.optional()}).strict()).min(1).max(5)}).strict(),UC=ii("schemaVersion",[ga,Xv]),FC=sf.extend({schemaVersion:Fe(2),records:_t(sf.shape.records.element.extend({manifest:UC}).strict()).max(cn.maxPayloadRecords)}).strict(),jv=ii("schemaVersion",[sf,FC]);function qv(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var zC=rf.extend({schemaVersion:Fe(2),maps:_t(rf.shape.maps.element.omit({procedural:!0}).extend({sampler:Zv,procedural:ia([_a,Qs.proceduralTextureSpecV3Schema.refine((e)=>{try{return Yd(e),!0}catch{return!1}})]).optional(),atlas:Qs.textureAtlasSpecV1Schema.refine((e)=>{try{return pa(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),bO=ia([rf,zC]);function af(e){if(eo(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return PC(e);let t=Xv.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==Gv[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==qs||c.derive||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||en(l)!==en(ca(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(nf(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||en(c.spec.sampler)!==en(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var xl=67108864,cf=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),kC=Xe().regex(/^sha256:[a-f0-9]{64}$/),lf=we({version:Fe("kiln.asset.v1"),assetId:cf,revisionId:cf,parentRevision:cf.optional(),name:Xe().min(1).max(200),tags:_t(Xe().max(80)).max(30),createdAt:Xe().datetime(),description:Xe().max(4000).optional(),brief:Xe().max(8000).optional(),attribution:we({model:Xe().max(200).optional(),harness:Xe().max(200).optional(),author:Xe().max(200).optional()}).optional(),editable:Kr(),files:ol(Xe(),we({sha256:kC,bytes:et().int().nonnegative().max(xl)})),build:we({engine:Xe(),options:ol(Xe(),Jr()),warnings:_t(Xe()),integration:Jr().optional(),qa:Jr().optional(),dependencies:_t(Jr()).optional(),rebuild:Ct(["engine-required","external-dependencies-required"])}).optional(),preview:we({fidelity:Jr().optional(),error:Xe().optional(),backdrop:Ct(av).optional()}).optional()}),BC="materials.kiln.json",VC=25165824;function GC(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=af(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&en(o)!==en(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>cn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function Yv(e,t=!1){let n=GC(e),i=new Map(n.map((h)=>[`${h.materialId}/${h.revisionId}`,en(h)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}eo(e.materialResources);let r=jv.parse(e.materialResources),s=0,o=0,a=new Map;for(let h of r.records){let d=af(h.manifest),f=`${h.manifest.materialId}/${h.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==en(d))throw Error("Asset material closure mismatch");if(a.set(f,d),Object.keys(h.files).length!==h.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of h.manifest.maps){if(h.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>cn.maxPayloadBytes||o>cn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(h)=>{if(l.has(h))throw Error("Asset material closure contains a cycle");if(c.has(h))return;let d=a.get(h);if(!d)throw Error("Asset material closure incomplete");l.add(h);for(let f of qv(d))u(`${f.resourceId}/${f.revisionId}`);l.delete(h),c.add(h)};for(let h of i.keys())u(h);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var HC=new Set(["asset.glb","source.kiln.js","preview.png"]);function $C(e){let t=lf.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(!HC.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>xl||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");uf(e.files["asset.glb"]),Yv(e)}function uf(e){if(e.length<20||e.length>xl)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 Jv(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){$C(i),Yv(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>VC)throw Error("Asset material payload exceeds byte limit");t[r+BC]=s}}for(let i of Object.values(t))n+=i.length;if(n>xl)throw Error("Bundle exceeds 64 MiB");return Ev(t,{level:0})}function Li(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 Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Kv(e){uf(e);let t=new Io,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Ds(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new Fh(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)Li(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 Qv(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),h=Math.max(h,y),d=Math.min(d,w),f=Math.max(f,w)}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 S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+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 hf(e,t){return{position:e.position.clone(),target:t.clone()}}function df(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).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 U))+r*20,10),e.updateProjectionMatrix()}function eb(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;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 tb(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 nb(e,t,n){if(t())return e;n(e);return}function yl(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 Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;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 Gt().setFromObject(e,!0):n}function xa(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 ib(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));yl(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=xa(e.scene)-r.reduce((c,l)=>c+ff(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+ff(h,l),0));return{chains:r,triangles:a}}var rb=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function ff(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return xa(rb(e,t))}function sb(e,t){let n=rb(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 ob(e,t){for(let n of e.chains)sb(n,t)}function ab(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return sb(i,n),!0}function cb(e,t){if(!e)return;return{triangles:xa(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)=>ff(n,r))}))}}function to(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function lb(e){let t=new Eh({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 Ps,i=new Vt(40,1,0.01,1000),r=new Rh(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 ko(t),f=new Ch,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new Fs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new bc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,z,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),k=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:tb(C.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(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(j.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.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 P=vl(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof Mt||ue instanceof pr||ue instanceof Ns){let Be=new Gt().setFromObject(ue,!0);if(!Be.isEmpty())j.push(Be)}});let{center:k,radius:q,distance:ee,position:Se}=Qv(P,i.aspect,i.fov,j);if(r.target.copy(k),i.position.copy(Se),i.near=Math.max(q/1000,0.0001),i.far=ee+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()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let k=eb(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),M!==void 0)z=performance.now()-M,M=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 k=K(P);clearTimeout(C.timeout),C.resolve(k),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let k=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let ee=await Kv(P);yl(ee,[ee.scene]);let Se=await ib(ee);try{ee.assertTexturesLoaded()}catch(xe){Li(ee.scene);for(let Ee of to(Se))Li(Ee);throw xe}let ue=nb(ee,()=>!x&&q===R&&j.isCurrent?.()!==!1,(xe)=>{Li(xe.scene);for(let Ee of to(Se))Li(Ee)});if(!ue)return;let Be=p&&j.preserveView?hf(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Li(p);for(let xe of to(g))Li(xe)}p=ue.scene,g=Se,M=k,z=void 0,n.add(p),T=ue.animations,S=new Ec(p),y=!0;let{clientWidth:Me,clientHeight:Z}=e;if(t.setSize(Me,Z),i.aspect=Me&&Z?Me/Z:i.aspect,I(),Be)df(i,r.target,Be,vl(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let Ee=xe;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:xa(p),meshes:re,materials:se.size,clips:T.map((xe)=>xe.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)ob(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)ab(g,P,j)},lod(){return p?cb(g,p):void 0},reset:I,cancelMeasurement:L,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,k)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:k,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return hf(i,r.target)},setView(P){if(!p)return;df(i,r.target,P,vl(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,...to(g)]:[])j.traverse((k)=>{let q=k;if(q.isMesh){for(let ee of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in ee)ee.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(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)Li(p);for(let P of to(g))Li(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var ub=["127.0.0.1","localhost","[::1]"];async function hb(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 h=new URL(s);if(h.protocol!=="https:"&&!(h.protocol==="http:"&&ub.includes(h.hostname)))throw Error("Invalid host download URL");return{downloadUrl:h.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 fb=16777216,pb=Math.ceil(fb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function WC(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function db(e){if(typeof e!=="string"||e.length>pb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(WC(n)!==e)Yt("contains noncanonical base64 data");return n}function ya(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function mb(e){if(!ya(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=lf.safeParse(e.manifest);if(!t.success||!ya(e.files))return Yt("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 Yt("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 Yt("file metadata is missing");if(r+=n.files[c].bytes,r>fb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:ya(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>pb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],h;if(typeof l==="string")h=db(l);else{if(!ya(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=db(l.data);try{h=Mv(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(h.length!==u.bytes)return Yt("byte count does not match the saved file");let d=await crypto.subtle.digest("SHA-256",Uint8Array.from(h));if(`sha256:${Array.from(new Uint8Array(d),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=h}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!ya(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function gb(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 Dn=(e)=>document.getElementById(e),Ni=Dn("status"),ln,xb={},ts,ZC=0,Di=0,bl=new Map;function yb(e,t){let n=++ZC;return new Promise((i,r)=>{let s=setTimeout(()=>{bl.delete(n),r(Error("Chat host did not respond."))},20000);bl.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 _b(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function XC(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 jC(e){let t=++Di;ln=void 0,Dn("stats").textContent="",Dn("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 qC(e,t)}catch(n){if(t!==Di)return;Ni.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function qC(e,t){if(e.isError){Ni.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await mb(e._meta?.kilnAsset)}catch(i){if(t!==Di)return;Ni.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Di)return;ln=n.record,Dn("name").textContent=ln.manifest.name,xb=n.downloadUrls,Dn("revision").textContent=`${ln.manifest.editable?"Editable source included":"GLB asset"} · ${ln.manifest.revisionId.slice(0,10)}`,Dn("attribution").textContent=gb(ln.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{ts??=lb(Dn("stage"));let i=await ts.load(ln.files["asset.glb"]);if(t!==Di)return;if(i){Dn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(ln.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Dn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Ni.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Di)return;ts?.dispose(),ts=void 0;let r=ln.files["preview.png"];if(r){let s=new Image;s.alt=`${ln.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${XC(r)}`,Dn("stage").replaceChildren(s)}Ni.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Dn("source").hidden=!ln.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=bl.get(t.id);if(bl.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")jC(t.params);if(t.method==="ui/resource-teardown")ts?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Dn("reset").onclick=()=>ts?.reset();Dn("clips").onchange=(e)=>ts?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!ln)return;let t=Di,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?Jv([ln]):ln.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=ln.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Ni.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await hb(r,`${o}-${i}`,s,yb,a,xb[i]);if(t!==Di)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})},Ni.replaceChildren("Download ready. ",l)}else Ni.textContent="Download requested."}catch(a){if(t===Di)Ni.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!ln||t!==Di}};yb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{_b("ui/notifications/initialized"),_b("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Ni.textContent=e.message});
+*/var Dt=Uint8Array,Ln=Uint16Array,Zd=Int32Array,al=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]),cl=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]),Vd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_v=function(e,t){var n=new Ln(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Zd(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}},xv=_v(al,2),{b:yv,r:Gd}=xv;yv[28]=258,Gd[258]=28;var vv=_v(cl,0),{b:QR,r:hv}=vv,Hd=new Ln(32768);for(Qe=0;Qe<32768;++Qe)wi=(Qe&43690)>>1|(Qe&21845)<<1,wi=(wi&52428)>>2|(wi&13107)<<2,wi=(wi&61680)>>4|(wi&3855)<<4,Hd[Qe]=((wi&65280)>>8|(wi&255)<<8)>>1;var wi,Qe,Ei=function(e,t,n){var i=e.length,r=0,s=new Ln(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new Ln(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new Ln(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],d=o[e[r]-1]++<<u;for(var h=d|(1<<u)-1;d<=h;++d)a[Hd[d]>>c]=l}}else{a=new Ln(i);for(r=0;r<i;++r)if(e[r])a[r]=Hd[o[e[r]-1]++]>>15-e[r]}return a},Er=new Dt(288);for(Qe=0;Qe<144;++Qe)Er[Qe]=8;var Qe;for(Qe=144;Qe<256;++Qe)Er[Qe]=9;var Qe;for(Qe=256;Qe<280;++Qe)Er[Qe]=7;var Qe;for(Qe=280;Qe<288;++Qe)Er[Qe]=8;var Qe,aa=new Dt(32);for(Qe=0;Qe<32;++Qe)aa[Qe]=5;var Qe,eC=Ei(Er,9,0),tC=Ei(Er,9,1),nC=Ei(aa,5,0),iC=Ei(aa,5,1),zd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ii=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},kd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Xd=function(e){return(e+7)/8|0},jd=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 rC=["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"],$n=function(e,t,n){var i=Error(t||rC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,$n);if(!n)throw i;return i},sC=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 Et=n.length;if(Ae>Et){var Ge=new Dt(Math.max(Et*2,Ae));Ge.set(n),n=Ge}},u=t.f||0,d=t.p||0,h=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=ii(e,d,1);var S=ii(e,d+1,3);if(d+=3,!S){var T=Xd(d)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)$n(0);break}if(a)l(h+y);n.set(e.subarray(T,w),h),t.b=h+=y,t.p=d=w*8,t.f=u;continue}else if(S==1)f=tC,m=iC,_=9,p=5;else if(S==2){var A=ii(e,d,31)+257,R=ii(e,d+10,15)+4,x=A+ii(e,d+5,31)+1;d+=14;var M=new Dt(x),z=new Dt(19);for(var C=0;C<R;++C)z[Vd[C]]=ii(e,d+C*3,7);d+=R*3;var L=zd(z),K=(1<<L)-1,I=Ei(z,L,1);for(var C=0;C<x;){var G=I[ii(e,d,K)];d+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ii(e,d,3),d+=2,X=M[C-1];else if(T==17)P=3+ii(e,d,7),d+=3;else if(T==18)P=11+ii(e,d,127),d+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),k=M.subarray(A);_=zd(j),p=zd(k),f=Ei(j,_,1),m=Ei(k,p,1)}else $n(1);if(d>g){if(c)$n(0);break}}if(a)l(h+131072);var q=(1<<_)-1,Q=(1<<p)-1,Me=d;for(;;Me=d){var X=f[kd(e,d)&q],ue=X>>4;if(d+=X&15,d>g){if(c)$n(0);break}if(!X)$n(2);if(ue<256)n[h++]=ue;else if(ue==256){Me=d,f=null;break}else{var Be=ue-254;if(ue>264){var C=ue-257,we=al[C];Be=ii(e,d,(1<<we)-1)+yv[C],d+=we}var Z=m[kd(e,d)&Q],re=Z>>4;if(!Z)$n(3);d+=Z&15;var k=QR[re];if(re>3){var we=cl[re];k+=kd(e,d)&(1<<we)-1,d+=we}if(d>g){if(c)$n(0);break}if(a)l(h+131072);var se=h+Be;if(h<k){var xe=s-k,Ee=Math.min(k,se);if(xe+h<0)$n(3);for(;h<Ee;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=f,t.p=Me,t.b=h,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return h!=n.length&&o?jd(n,0,h):n.subarray(0,h)},Yi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},sa=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},Bd=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:Sv,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(w,A){return w.f-A.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],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 f=new Ln(h+1),m=$d(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=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 y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},$d=function(e,t,n){return e.s==-1?Math.max($d(e.l,t,n+1),$d(e.r,t,n+1)):t[e.s]=n},dv=function(e){var t=e.length;while(t&&!e[--t]);var n=new Ln(++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}},oa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},bv=function(e,t,n){var i=n.length,r=Xd(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},fv=function(e,t,n,i,r,s,o,a,c,l,u){Yi(t,u++,n),++r[256];var d=Bd(r,15),{t:h,l:f}=d,m=Bd(s,15),{t:_,l:p}=m,g=dv(h),{c:S,n:T}=g,y=dv(_),{c:w,n:A}=y,R=new Ln(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=Bd(R,7),{t:z,l:C}=M,L=19;for(;L>4&&!z[Vd[L-1]];--L);var K=l+5<<3,I=oa(r,Er)+oa(s,aa)+o,G=oa(r,h)+oa(s,_)+o+14+3*L+oa(R,z)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return bv(t,u,e.subarray(c,c+l));var X,P,j,k;if(Yi(t,u,1+(G<I)),u+=2,G<I){X=Ei(h,f,0),P=h,j=Ei(_,p,0),k=_;var q=Ei(z,C,0);Yi(t,u,T-257),Yi(t,u+5,A-1),Yi(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Yi(t,u+3*x,z[Vd[x]]);u+=3*L;var Q=[S,w];for(var Me=0;Me<2;++Me){var ue=Q[Me];for(var x=0;x<ue.length;++x){var Be=ue[x]&31;if(Yi(t,u,q[Be]),u+=z[Be],Be>15)Yi(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=eC,P=Er,j=nC,k=aa;for(var x=0;x<a;++x){var we=i[x];if(we>255){var Be=we>>18&31;if(sa(t,u,X[Be+257]),u+=P[Be+257],Be>7)Yi(t,u,we>>23&31),u+=al[Be];var Z=we&31;if(sa(t,u,j[Z]),u+=k[Z],Z>3)sa(t,u,we>>5&8191),u+=cl[Z]}else sa(t,u,X[we]),u+=P[we]}return sa(t,u,X[256]),u+P[256]},oC=new Zd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Sv=new Dt(0),aC=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 d=oC[t-1],h=d>>13,f=d&8191,m=(1<<n)-1,_=s.p||new Ln(32768),p=s.h||new Ln(m+1),g=Math.ceil(n/3),S=2*g,T=function(Ye){return(e[Ye]^e[Ye+1]<<g^e[Ye+2]<<S)&m},y=new Zd(25000),w=new Ln(288),A=new Ln(32),R=0,x=0,M=s.i||0,z=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||z>24576)&&(X>423||!l)){u=fv(e,c,0,y,w,A,x,z,L,M-L,u),z=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,k=0,q=f,Q=I-G&32767;if(X>2&&K==T(M-Q)){var Me=Math.min(h,X)-1,ue=Math.min(32767,M),Be=Math.min(258,X);while(Q<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-Q]){var we=0;for(;we<Be&&e[M+we]==e[M+we-Q];++we);if(we>j){if(j=we,k=Q,we>Me)break;var Z=Math.min(Q,we-2),re=0;for(var P=0;P<Z;++P){var se=M-Q+P&32767,xe=_[se],Ee=se-xe&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],Q+=I-G&32767}}if(k){y[z++]=268435456|Gd[j]<<18|hv[k];var Ae=Gd[j]&31,Et=hv[k]&31;x+=al[Ae]+cl[Et],++w[257+Ae],++A[Et],C=M+j,++R}else y[z++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[z++]=e[M],++w[e[M]];if(u=fv(e,c,l,y,w,A,x,z,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var Ge=M+65535;if(Ge>=o)c[u/8|0]=l,Ge=o;u=bv(c,u+1,e.subarray(M,Ge))}s.i=o}return jd(a,0,i+Xd(u)+r)},cC=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}(),lC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=cC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var uC=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 aC(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)},Mv=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 Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function wv(e,t){return uC(e,t||{},0,0)}function Ev(e,t){return sC(e,{i:2},t&&t.out,t&&t.dictionary)}var Av=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Mv(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],Av(s,o,n,i)}},pv=typeof TextEncoder<"u"&&new TextEncoder,hC=typeof TextDecoder<"u"&&new TextDecoder,dC=0;try{hC.decode(Sv,{stream:!0}),dC=1}catch(e){}function mv(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(pv)return pv.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 jd(s,0,o)}var Wd=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)$n(9);t+=i+4}return t},gv=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,d=Wd(l);if(Qt(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),f=h.getFullYear()-1980;if(f<0||f>119)$n(10);if(Qt(e,t,f<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,d),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,d)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},fC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Tv(e,t){if(!t)t={};var n={},i=[];Av(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,d=mv(o),h=d.length,f=l.comment,m=f&&mv(f),_=m&&m.length,p=Wd(l.extra);if(h>65535)$n(11);var g=u?wv(c,l):c,S=g.length,T=lC();T.p(c),i.push(Mv(l,{size:c.length,crc:T.d(),c:g,f:d,m,u:h!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+h+p+S,s+=76+2*(h+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var d=i[R];gv(y,d.o,d,d.f,d.u,d.c.length);var x=30+d.f.length+Wd(d.extra);y.set(d.c,d.o+x),gv(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+x+(d.m?d.m.length:0)}return fC(y,r,i.length,A,w),y}var Ai=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function pC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";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==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';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 ca extends Error{diagnostic;constructor(e,t=pC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var ll=1024,ul=4,hl=8,Yd=6,Rv=80,es=256;class rt extends ca{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Cv=["solid","checker","stripes","gradient","bricks","noise"],Pv=["normal","multiply","screen","overlay"],mC=new Set(["__proto__","prototype","constructor"]);function dl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new rt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new rt(`${t} must not contain symbol keys.`);if(mC.has(i))throw new rt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new rt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new rt(`${t}.${i} must be a plain JSON data field.`)}return e}function gC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new rt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new rt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new rt(`${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 rt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Ar(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new rt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function ri(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new rt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Qr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new rt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Lv(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 rt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function qd(e,t,n){return Lv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function _C(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>Rv||n)throw new rt(`${t} must be 1..${Rv} visible characters.`);return e}function xC(e,t,n){if(e===void 0)return n;if(!Ai.includes(e))throw new rt(`${t} must be one of ${Ai.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Iv(e,t){let i=(Lv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function yC(e,t){let n=e.blend??"normal";if(!Pv.includes(n))throw new rt(`${t}.blend ${JSON.stringify(n)} is not one of ${Pv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function vC(e,t){let n=`proceduralTexture.layers[${t}]`,i=dl(e,n),r=i.op;if(!Cv.includes(r))throw new rt(`${n}.op ${JSON.stringify(r)} is not one of ${Cv.join(", ")}.`);let s=yC(i,n),o=qd(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return Ar(i,["op","color","blend","opacity"],n),{op:r,color:ri(i.color,`${n}.color`),...a};case"checker":return Ar(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),squares:Qr(i.squares,`${n}.squares`,8,1,es),...a};case"stripes":return Ar(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),count:Qr(i.count,`${n}.count`,8,1,es),angleDeg:Iv(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return Ar(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:ri(i.from,`${n}.from`),to:ri(i.to,`${n}.to`),angleDeg:Iv(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return Ar(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:ri(i.brick,`${n}.brick`),mortar:ri(i.mortar,`${n}.mortar`),rows:Qr(i.rows,`${n}.rows`,8,1,es),cols:Qr(i.cols,`${n}.cols`,4,1,es),mortarWidth:qd(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:qd(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return Ar(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),scale:Qr(i.scale,`${n}.scale`,8,1,es),octaves:Qr(i.octaves,`${n}.octaves`,3,1,Yd),seed:Qr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new rt(`${n}.op is unsupported.`)}}function bC(e){let t=dl(e,"proceduralTexture");if(Ar(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new rt(`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 la(e){let t=dl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?dl(bC(t),"proceduralTexture"):t;if(Ar(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new rt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<ul||i>ll||(i&i-1)!==0)throw new rt(`proceduralTexture.size must be a power of two between ${ul} and ${ll}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new rt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=gC(r,"proceduralTexture.layers");if(s.length>hl)throw new rt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${hl}.`);let o=_C(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:xC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(vC)}}var SC=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]),Ti=(e,t)=>e>>>t|e<<32-t;function Ys(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Ti(T,7)^Ti(T,18)^T>>>3,A=Ti(y,17)^Ti(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,d,h,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Ti(f,6)^Ti(f,11)^Ti(f,25),y=f&m^~f&_,w=p+T+y+SC[S]+a[S]>>>0,A=Ti(l,2)^Ti(l,13)^Ti(l,22),R=l&u^l&d^u&d,x=A+R>>>0;p=_,_=m,m=f,f=h+w>>>0,h=d,d=u,u=l,l=w+x>>>0}let g=[l,u,d,h,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Js="kiln.procedural-rgba.v3.1";var ha=1024,MC=1048576,da=64,pl=64,ua=256,ml=32,Nv=64000000,wC=67108864;function tt(e){throw new rt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var EC=new Set(["__proto__","prototype","constructor"]);function AC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)tt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)tt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))tt(`${r} must be finite.`);return}if(typeof i!=="object")tt(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)tt(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))tt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)tt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||EC.has(d))tt(`${r} has a forbidden key.`);if(o&&d==="length")continue;let h=u[d];if(!h.enumerable||!("value"in h))tt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))tt(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)tt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!o)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function Wn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))tt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))tt(`${n} has unknown field ${r}.`);return i}function pn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)tt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Dv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")tt(`${t} must be boolean.`);return e}function fl(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)tt(`${n} must be a ${t}-element array.`);return e.map((s,o)=>pn(s,i,r,`${n}[${o}]`))}function Ov(e,t){let n=fl(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function Uv(e,t,n){let i=Wn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:pn(i.x,-4096,4096,`${t}.x`),y:pn(i.y,-4096,4096,`${t}.y`),width:pn(i.width,1,2048,`${t}.width`),height:pn(i.height,1,2048,`${t}.height`)}}function TC(e,t){let n=Wn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...Uv(n,t,n.kind)};if(n.kind==="polygon"){Wn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>pl)tt(`${t}.points requires 3..${pl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>fl(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return Wn(n,["kind","from","to","width"],t),{kind:"line",from:fl(n.from,2,`${t}.from`,-4096,4096),to:fl(n.to,2,`${t}.to`,-4096,4096),width:pn(n.width,1,2048,`${t}.width`)};return tt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function Fv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function RC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function CC(e,t,n,i=0,r=0){let[s,o,a,c]=Fv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function gl(e){AC(e);let t=Wn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)tt("schemaVersion must be 3.");let n=pn(t.width,4,ha,"width"),i=pn(t.height,4,ha,"height"),r=n*i;if(r>MC)tt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ai.includes(s))tt("usage must be a known texture usage.");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))tt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>da)tt(`operations must be an array with at most ${da} entries.`);let l=r,u=0,d=0,h=c.map((p,g)=>{let S=`operations[${g}]`,T=Wn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){Wn(T,["op","spec","alpha","opacity"],S);let j=Wn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)tt(`${S}.spec requires explicit schemaVersion 2.`);let k=la(j);if(k.size!==n||k.size!==i||k.usage!==s)tt(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+k.layers.reduce((q,Q)=>q+(Q.op==="noise"?Q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:k,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)}}let y=TC(T.shape,`${S}.shape`),w=RC(y),[A,R,x,M]=CC(y,n,i),z=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return Wn(T,["op","shape","alpha","invert"],S),l+=r+z*w,{op:"mask",shape:y,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),invert:Dv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return tt(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Ov(T.rgba,`${S}.rgba`),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return Wn(T,["op","shape","rgba","opacity"],S),l+=z*(w+1),{op:"paint",...C};if(Wn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S),!o)tt("stamps are supported only for color usages albedo and emissive.");let L=pn(T.count,1,ua,`${S}.count`),K=Dv(T.periodic,`${S}.periodic`),[I,G,X,P]=Fv(y);if(K&&(X-I>n||P-G>i))tt(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>ua)tt(`expanded stamps budget exceeds ${ua}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:pn(T.seed,0,4294967295,`${S}.seed`),area:Uv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)tt("palette and dither are supported only for color usages albedo and emissive.");let p=Wn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>ml)tt(`palette.colors requires 1..${ml} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")tt("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>pn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Nv)tt(`estimated work budget ${l} exceeds ${Nv}.`);if(r*4+d>wC)tt("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Ov(t.background,"background"),operations:h,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)tt("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Jd(e){return gl(e).spec}function PC(e){return gl(e).canonicalJson}function Kd(e){return`sha256:${Ys(`${Js}
+${PC(e)}`)}`}var Qd=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],ef=["nearest","linear"],fa=["repeat","clamp-to-edge","mirrored-repeat"];function _l(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new rt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new rt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Qd,magFilter:ef,wrapS:fa,wrapT:fa};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new rt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new rt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Bv="kiln.texture-atlas.v1.1",Vv="kiln.texture-atlas.v1.2",xl=Object.freeze([Bv,Vv]),ts=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Ji=Object.freeze({...ts,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),nf=Object.freeze([1024,2048]);function Gv(e){return e.pack===void 0?Bv:Vv}function IC(e){return e.pack===void 0?ts:Ji}class Hv extends ca{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function Ne(e){throw new Hv(e)}function rf(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>ts.jsonBytes)Ne("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)Ne("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))Ne("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)Ne("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")Ne("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)Ne("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))Ne("JSON array budget exceeded.");let d=Reflect.ownKeys(o);if(d.length>1024||c&&d.length!==u+1)Ne("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let h of d){if(c&&h==="length")continue;if(typeof h!=="string"||["__proto__","prototype","constructor"].includes(h))Ne("forbidden JSON field.");if(h.length>4096)Ne("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(h)).length+1);let f=Object.getOwnPropertyDescriptor(o,h);if(!f.enumerable||!("value"in f))Ne("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=u))Ne("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function mn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))Ne(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))Ne(`${n} has an unknown field.`);return i}function Nn(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)Ne(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Tr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))Ne(`${t} must be an exact SHA-256 hash.`);return e}function zv(e,t){let n=mn(e,["x","y","width","height"],t);return{x:Nn(n.x,0,4096,`${t}.x`),y:Nn(n.y,0,4096,`${t}.y`),width:Nn(n.width,1,4096,`${t}.width`),height:Nn(n.height,1,4096,`${t}.height`)}}function Ks(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function $v(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)Ne("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)Ne("source crop/content dimensions must match; resampling is unsupported.")}function tf(e){return e.kind==="procedural"?`procedural:${Kd(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var LC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,kv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function NC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(a)=>{let c=[];for(let l of r){if(!LC(l,a)){c.push(l);continue}if(a.x>l.x)c.push({x:l.x,y:l.y,width:a.x-l.x,height:l.height});if(a.x+a.width<l.x+l.width)c.push({x:a.x+a.width,y:l.y,width:l.x+l.width-a.x-a.width,height:l.height});if(a.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:a.y-l.y});if(a.y+a.height<l.y+l.height)c.push({x:l.x,y:a.y+a.height,width:l.width,height:l.y+l.height-a.y-a.height})}if(r=c.filter((l,u)=>!c.some((d,h)=>h!==u&&kv(d,l)&&(!kv(l,d)||h<u))),r.length>16384)Ne("pack: free-space bookkeeping budget exceeded.")};for(let a of n)s(a);let o=[...i].sort((a,c)=>c.width*c.height-a.width*a.height||(a.region.name<c.region.name?-1:a.region.name>c.region.name?1:0));for(let a of o){let c,l;for(let u of r){if(u.width<a.width||u.height<a.height)continue;let d=u.width-a.width,h=u.height-a.height,f=[Math.min(d,h),Math.max(d,h),u.y,u.x];if(!l||f[0]<l[0]||f[0]===l[0]&&(f[1]<l[1]||f[1]===l[1]&&(f[2]<l[2]||f[2]===l[2]&&f[3]<l[3])))c=u,l=f}if(!c)Ne(`pack: region ${a.region.name} (${a.width}x${a.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);a.region.content={x:c.x+a.region.gutter,y:c.y+a.region.gutter,width:a.region.content.width,height:a.region.content.height},s({x:c.x,y:c.y,width:a.width,height:a.height})}}function pa(e){rf(e);let t=mn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)Ne("schemaVersion must be 1.");let n;if(t.pack!==void 0){let h=mn(t.pack,["edge","gutter","algorithm"],"pack");if(!nf.includes(h.edge))Ne("pack.edge must be 1024 or 2048.");if(h.algorithm!==void 0&&h.algorithm!=="maxrects")Ne("pack.algorithm must be 'maxrects'.");n={edge:h.edge,gutter:h.gutter===void 0?2:Nn(h.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Ji:ts,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:Nn(t.width,4,r,"width"),o=n&&t.height===void 0?n.edge:Nn(t.height,4,r,"height");if(s*o>i.outputTexels)Ne("output texel budget exceeded.");if(!Ai.includes(t.usage))Ne("usage must be a texture usage.");let a=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)Ne(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((h,f)=>{let m=mn(h,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${f}]`);if(typeof m.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(m.name))Ne("region name must be a stable lowercase identifier.");let _=m.content!==void 0;if(!_&&!n)Ne(`region ${m.name}: content is required unless the atlas sets pack.`);if(m.packed!==void 0&&(m.packed!==!0||!n||!_))Ne("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let p=_?zv(m.content,"content"):void 0,g=m.gutter===void 0?n?.gutter??2:Nn(m.gutter,0,32,"gutter"),S=m.edgeMode===void 0?"copy-edge":m.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(S))Ne("unsupported edgeMode.");if(S==="mask-rgb-dilate"&&a!=="albedo"&&a!=="emissive")Ne("mask RGB dilation requires color usage.");let T=mn(m.source,["kind","spec","resourceId","pin","expected"],"source"),y,w=m.crop===void 0?void 0:zv(m.crop,"crop");if(T.kind==="procedural"){mn(T,["kind","spec"],"procedural source");let R=gl(T.spec);if(R.spec.usage!==a)Ne("source usage does not match atlas usage.");y={kind:"procedural",spec:R.spec},w??={x:0,y:0,width:R.spec.width,height:R.spec.height},p??={x:0,y:0,width:w.width,height:w.height},$v(w,p,R.spec.width,R.spec.height)}else if(T.kind==="resource"){if(mn(T,["kind","resourceId","pin","expected"],"resource source"),typeof T.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(T.resourceId))Ne("source resourceId must be an exact returned map ID.");let R=mn(T.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof R.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(R.resourceId))Ne("pin resourceId must be a material ID.");let x=Tr(R.revisionId,"pin revisionId"),M=Tr(R.sha256,"pin sha256");if(x!==M)Ne("source pin revision/hash mismatch.");let z;if(T.expected!==void 0){let C=mn(T.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");z={...C.width===void 0?{}:{width:Nn(C.width,1,4096,"expected.width")},...C.height===void 0?{}:{height:Nn(C.height,1,4096,"expected.height")},...C.imageSha256===void 0?{}:{imageSha256:Tr(C.imageSha256,"expected.imageSha256")},...C.decodedPixelHash===void 0?{}:{decodedPixelHash:Tr(C.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:T.resourceId,pin:{resourceId:R.resourceId,revisionId:x,sha256:M},...z?{expected:z}:{}},!p){let C=w??(z?.width!==void 0&&z.height!==void 0?{width:z.width,height:z.height}:Ne(`region ${m.name}: a packed resource region needs a crop or expected width and height (its size).`));p={x:0,y:0,width:C.width,height:C.height}}if(w&&(w.width!==p.width||w.height!==p.height))Ne("source crop/content dimensions must match; resampling is unsupported.")}else Ne("source kind must be procedural or pinned resource.");let A={name:m.name,content:p,gutter:g,edgeMode:S,source:y,...w?{crop:w}:{},...n&&(!_||m.packed===!0)?{packed:!0}:{}};if(!_)c.push({region:A,width:A.content.width+2*g,height:A.content.height+2*g});return A}).sort((h,f)=>h.name<f.name?-1:h.name>f.name?1:0);if(new Set(l.map((h)=>h.name)).size!==l.length)Ne("duplicate region name.");if(c.length){let h=new Set(c.map((f)=>f.region));NC(s,o,l.filter((f)=>!h.has(f)).map((f)=>Ks(f)),c)}for(let h of l){let f=Ks(h);if(f.x<0||f.y<0||f.x+f.width>s||f.y+f.height>o)Ne("padded allocation is out of bounds.")}for(let h=0;h<l.length;h++)for(let f=h+1;f<l.length;f++){let m=Ks(l[h]),_=Ks(l[f]);if(m.x<_.x+_.width&&_.x<m.x+m.width&&m.y<_.y+_.height&&_.y<m.y+m.height)Ne(`padded allocations overlap: ${l[h].name}, ${l[f].name}.`)}if(new Set(l.map((h)=>tf(h.source))).size>i.sources)Ne(`distinct source budget exceeds ${i.sources}.`);let u;try{u=_l(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(h){Ne(`sampler: ${h.message}`)}let d={schemaVersion:1,width:s,height:o,usage:a,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>ts.jsonBytes)Ne("canonical JSON byte budget exceeded.");return d}function DC(e){let t=pa(e);return`sha256:${Ys(`${Gv(t)}
+${JSON.stringify(t)}`)}`}function Ri(e){rf(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 OC(e){return`sha256:${Ys(`kiln.atlas-layout.v1
+${Ri({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:Ks(t)}))})}`)}`}function sf(e,t){rf(e);let n=pa(t),i=mn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Gv(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")Ne("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ri(i.sampler)!==Ri(n.sampler)||i.specHash!==DC(n)||i.layoutHash!==OC(n))Ne("manifest sampler/spec/layout identity mismatch.");Tr(i.decodedPixelHash,"manifest decodedPixelHash"),Tr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[tf(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)Ne("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=mn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))Ne("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)Ne("manifest source identity mismatch.");let d=Nn(l.width,1,4096,"manifest source width"),h=Nn(l.height,1,4096,"manifest source height");if(Tr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(mn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||h!==u.spec.height||l.recipeHash!==Kd(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")Ne("manifest procedural source identity mismatch.")}else{mn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=mn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==d||f.height!==h||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))Ne("manifest pinned resource descriptor mismatch.");if(Tr(f.imageSha256,"manifest source imageSha256"),Nn(f.encodedByteLength,1,IC(n).encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)Ne("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))Ne("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:h})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=mn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=tf(l.source),h=s.get(d),f=l.crop??{x:0,y:0,width:h.width,height:h.height};if($v(f,l.content,h.width,h.height),u.name!==l.name||u.sourceId!==d||Ri(u.content)!==Ri(l.content)||Ri(u.allocation)!==Ri(Ks(l))||Ri(u.crop)!==Ri(f))Ne("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${Ys(`kiln.atlas-manifest.v1
+${Ri(a)}`)}`)Ne("manifest hash mismatch.");return structuredClone(e)}var UC=(()=>{let e=et().int().min(0).max(16777215),t=et().int().min(1).max(es),n=et().min(-36000).max(36000),i=et().min(0).max(1),r={blend:wt(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:Oe(2),size:et().int().min(ul).max(ll),usage:wt(Ai),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:e,...r}).strict(),be({op:Oe("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:Oe("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:Oe("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:Oe("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:Oe("noise"),colorA:e,colorB:e,scale:t,octaves:et().int().min(1).max(Yd),seed:et().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(hl)}).strict()})();function Wv(e,t=UC){let n=(q,Q)=>et().int().min(q).max(Q),i=n(0,255),r=n(-4096,4096),s=ov([r,r]),o=ov([i,i,i,i]),a=wt(Ai),c=qR(["sha256:",Xe().regex(/^[a-f0-9]{64}$/)]),l=Xe().min(1).max(80),u=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Xe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),h={width:n(1,4096),height:n(1,4096)},f=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=be({x:n(0,4096),y:n(0,4096),...h}).strict(),_=ni("kind",[f.extend({kind:Oe("rectangle")}).strict(),f.extend({kind:Oe("ellipse")}).strict(),be({kind:Oe("polygon"),points:_t(s).min(3).max(pl)}).strict(),be({kind:Oe("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=be({op:Oe("paint"),shape:_,rgba:o,opacity:i}).strict(),g=be({op:Oe("mask"),shape:_,alpha:i,invert:Kr()}).strict(),S=be({op:Oe("stamps"),shape:_,rgba:o,opacity:i,count:n(1,ua),seed:n(0,4294967295),area:f,periodic:Kr()}).strict(),T=be({op:Oe("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=be({colors:_t(n(0,16777215)).min(1).max(ml),dither:wt(["none","bayer4"])}).strict(),w={schemaVersion:Oe(3),width:n(4,ha),height:n(4,ha),usage:a,name:l.optional(),background:o},A=be({...w,operations:_t(ni("op",[p,g,S,T.extend({spec:t})])).max(da),palette:y.optional()}).strict(),R=be({...w,usage:a.optional(),background:o.optional(),operations:_t(ni("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(da),palette:y.partial({dither:!0}).optional()}).strict(),x=be({minFilter:wt(Qd),magFilter:wt(ef),wrapS:wt(fa),wrapT:wt(fa)}).strict(),M=be({resourceId:u,revisionId:c,sha256:c}).strict(),z=be({kind:Oe("resource"),resourceId:d,pin:M,expected:be({...h,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=be({name:u,content:m,gutter:n(0,32),edgeMode:wt(["copy-edge","mask-rgb-dilate"]),source:ni("kind",[be({kind:Oe("procedural"),spec:A}).strict(),z]),crop:m.optional(),packed:Oe(!0).optional()}).strict(),L={schemaVersion:Oe(1),width:n(4,Ji.edge),height:n(4,Ji.edge),usage:a,sampler:x},K=qs(nf.map((q)=>Oe(q))),I=be({...L,regions:_t(C).min(1).max(Ji.regions),pack:be({edge:K,gutter:n(0,32),algorithm:Oe("maxrects")}).strict().optional()}).strict(),G=be({...L,width:L.width.optional(),height:L.height.optional(),pack:be({edge:K,gutter:n(0,32).optional(),algorithm:Oe("maxrects").optional()}).strict().optional(),sampler:x.optional(),regions:_t(C.extend({source:ni("kind",[be({kind:Oe("procedural"),spec:R}).strict(),z])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Ji.regions)}).strict(),X=be({materialId:u,revisionId:c,resourceId:d,slot:wt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:wt(["srgb","linear"]),...h,encodedByteLength:n(1,ts.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),P={id:Xe().min(1).max(1024),...h,decodedPixelHash:c},j=ni("kind",[be({...P,kind:Oe("procedural"),recipeHash:c,compilerId:Oe(Js)}).strict(),be({...P,kind:Oe("resource"),descriptor:X}).strict()]),k=be({version:Oe("kiln.atlas-manifest.v1"),compilerId:wt(xl),width:L.width,height:L.height,usage:a,origin:Oe("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:_t(j).min(1).max(Ji.sources),regions:_t(be({name:u,content:m,allocation:m,crop:m,sourceId:Xe().min(1).max(1024)}).strict()).min(1).max(Ji.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:G,canonicalTextureAtlasSpecV1Schema:I,textureAtlasManifestV1Schema:k,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:X}}var cn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Xv=["baseColor","normal","metallicRoughness","emissive","occlusion"],jv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var eo=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Pi=Xe().regex(/^sha256:[a-f0-9]{64}$/),Ci=Xe().min(1).max(1000),Zv=Xe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),qv=be({id:eo,kind:wt(["external","procedural"]),provider:Ci,creator:Ci,assetId:Ci.optional(),assetUrl:Zv.optional(),accessedAt:Xe().datetime().optional(),license:be({spdx:Ci,url:Zv,attribution:Xe().max(4000)}).strict(),originalFiles:_t(be({name:Xe().min(1).max(200),sha256:Pi,bytes:et().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"})}),Yv=be({operation:Ci,tool:Ci,version:Ci,parameters:ol(Xe().max(100),qs([Xe().max(2000),et().finite(),Kr()])).optional()}).strict(),si=et().int().min(0).max(16777215),ma=et().int().min(1).max(256),Qs={blend:wt(["normal","multiply","screen","overlay"]).default("normal"),opacity:et().min(0).max(1).default(1)},_a=be({schemaVersion:Oe(2),size:et().int().min(4).max(1024).default(256),usage:wt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:si,...Qs}).strict(),be({op:Oe("checker"),colorA:si,colorB:si,squares:ma.default(8),...Qs}).strict(),be({op:Oe("stripes"),colorA:si,colorB:si,count:ma.default(8),angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("gradient"),from:si,to:si,angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("bricks"),brick:si,mortar:si,rows:ma.default(8),cols:ma.default(4),mortarWidth:et().min(0).max(1).default(0.06),stagger:et().min(0).max(1).default(0.5),...Qs}).strict(),be({op:Oe("noise"),colorA:si,colorB:si,scale:ma.default(8),octaves:et().int().min(1).max(6).default(3),seed:et().int().min(-2147483648).max(2147483647).default(0),...Qs}).strict()])).min(1).max(8)}).strict(),cf=be({kind:Oe("normal-from-height"),strength:et().finite().positive().max(64)}).strict(),FC=be({compiler:Oe("kiln.procedural-texture.v2"),spec:_a,derive:cf.optional(),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict(),Jv=be({baseColor:et().int().min(0).max(16777215).optional(),roughness:et().min(0).max(1).default(1),metalness:et().min(0).max(1).default(0),emissive:et().int().min(0).max(16777215).optional(),emissiveIntensity:et().min(0).max(64).default(1),alphaMode:wt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:et().min(0).max(1).default(0.5),doubleSided:Kr().default(!1)}).strict(),ga=be({schemaVersion:Oe(1),materialId:eo,revisionId:Pi,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Jv,sources:_t(qv).min(1).max(20),maps:_t(be({slot:wt(Xv),file:wt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Pi,bytes:et().int().positive().max(cn.maxMapBytes),width:et().int().positive().max(cn.maxMapEdge),height:et().int().positive().max(cn.maxMapEdge),usage:wt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:wt(["srgb","linear"]),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),sourceId:eo,originalFile:Xe().min(1).max(200).optional(),transforms:_t(Yv).max(30),procedural:FC.optional()}).strict()).min(1).max(5)}).strict(),of=be({materialId:eo,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30).optional(),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Jv.partial().optional(),sources:_t(qv).min(1).max(20),maps:_t(be({slot:wt(Xv),sourceId:eo,transforms:_t(Yv).max(30),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),procedural:_a,derive:cf.optional()}).strict()).min(1).max(5)}).strict(),af=be({schemaVersion:Oe(1),records:_t(be({manifest:ga,files:ol(Xe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Xe().max(Math.ceil(cn.maxMapBytes/3)*4))}).strict()).max(cn.maxPayloadRecords)}).strict();function no(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");no(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function en(e){no(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 zC(e){if(no(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=ga.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!==jv[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(en(r.procedural.spec)!==en(la(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>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var to=Wv(_a),Kv=to.portableSamplerSchema.refine((e)=>{try{return en(e)===en(_l(e))}catch{return!1}}),kC=to.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return en(e)===en(Jd(e))}catch{return!1}}),BC=to.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return en(e)===en(pa(e))}catch{return!1}}),VC=to.textureAtlasManifestV1Schema,GC=be({resourceId:eo,revisionId:Pi,sha256:Pi}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),HC=ni("kind",[be({kind:Oe("procedural"),compilerId:wt(["kiln.procedural-texture.v2",Js]),spec:qs([_a,kC]),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict(),derive:cf.optional()}).strict(),be({kind:Oe("atlas"),compilerId:wt(xl),spec:BC,manifest:VC,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict().superRefine((e,t)=>{try{if(sf(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error("compiler id")}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),Qv=ga.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Oe(2),dependencies:_t(GC).max(16),maps:_t(ga.shape.maps.element.omit({procedural:!0}).extend({sampler:Kv,pixelHash:Pi,recipe:HC.optional()}).strict()).min(1).max(5)}).strict(),$C=ni("schemaVersion",[ga,Qv]),WC=af.extend({schemaVersion:Oe(2),records:_t(af.shape.records.element.extend({manifest:$C}).strict()).max(cn.maxPayloadRecords)}).strict(),eb=ni("schemaVersion",[af,WC]);function tb(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var ZC=of.extend({schemaVersion:Oe(2),maps:_t(of.shape.maps.element.omit({procedural:!0}).extend({sampler:Kv,procedural:qs([_a,to.proceduralTextureSpecV3Schema.refine((e)=>{try{return Jd(e),!0}catch{return!1}})]).optional(),atlas:to.textureAtlasSpecV1Schema.refine((e)=>{try{return pa(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),CO=qs([of,ZC]);function lf(e){if(no(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return zC(e);let t=Qv.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==jv[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Js||c.derive||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||en(l)!==en(la(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(sf(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||en(c.spec.sampler)!==en(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var yl=67108864,uf=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),XC=Xe().regex(/^sha256:[a-f0-9]{64}$/),hf=be({version:Oe("kiln.asset.v1"),assetId:uf,revisionId:uf,parentRevision:uf.optional(),name:Xe().min(1).max(200),tags:_t(Xe().max(80)).max(30),createdAt:Xe().datetime(),description:Xe().max(4000).optional(),brief:Xe().max(8000).optional(),attribution:be({model:Xe().max(200).optional(),harness:Xe().max(200).optional(),author:Xe().max(200).optional()}).optional(),editable:Kr(),files:ol(Xe(),be({sha256:XC,bytes:et().int().nonnegative().max(yl)})),build:be({engine:Xe(),options:ol(Xe(),Jr()),warnings:_t(Xe()),integration:Jr().optional(),qa:Jr().optional(),dependencies:_t(Jr()).optional(),rebuild:wt(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:Jr().optional(),error:Xe().optional(),backdrop:wt(lv).optional()}).optional()}),jC="materials.kiln.json",qC=25165824;function YC(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=lf(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&en(o)!==en(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>cn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function nb(e,t=!1){let n=YC(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,en(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}no(e.materialResources);let r=eb.parse(e.materialResources),s=0,o=0,a=new Map;for(let d of r.records){let h=lf(d.manifest),f=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==en(h))throw Error("Asset material closure mismatch");if(a.set(f,h),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of d.manifest.maps){if(d.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>cn.maxPayloadBytes||o>cn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let h=a.get(d);if(!h)throw Error("Asset material closure incomplete");l.add(d);for(let f of tb(h))u(`${f.resourceId}/${f.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var JC=new Set(["asset.glb","source.kiln.js","preview.png"]);function KC(e){let t=hf.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(!JC.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>yl||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");df(e.files["asset.glb"]),nb(e)}function df(e){if(e.length<20||e.length>yl)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 ib(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){KC(i),nb(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>qC)throw Error("Asset material payload exceeds byte limit");t[r+jC]=s}}for(let i of Object.values(t))n+=i.length;if(n>yl)throw Error("Bundle exceeds 64 MiB");return Tv(t,{level:0})}function Ii(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 Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function rb(e){df(e);let t=new No,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Os(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new zh(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)Ii(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 sb(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,d=-1/0,h=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),d=Math.max(d,y),h=Math.min(h,w),f=Math.max(f,w)}r.addScaledVector(a,(u+d)/2),r.addScaledVector(c,(h+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+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 ff(e,t){return{position:e.position.clone(),target:t.clone()}}function pf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).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 U))+r*20,10),e.updateProjectionMatrix()}function ob(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;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 ab(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 cb(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 bl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;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 Gt().setFromObject(e,!0):n}function xa(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 lb(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 d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let h=[l];for(let m of u)h.push(await e.parser.getDependency("node",m));vl(e,h.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:h})}if(r.length===0)return;let s=xa(e.scene)-r.reduce((c,l)=>c+mf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,d)=>u+mf(d,l),0));return{chains:r,triangles:a}}var ub=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function mf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return xa(ub(e,t))}function hb(e,t){let n=ub(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 db(e,t){for(let n of e.chains)hb(n,t)}function fb(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return hb(i,n),!0}function pb(e,t){if(!e)return;return{triangles:xa(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)=>mf(n,r))}))}}function io(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function mb(e){let t=new Ah({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=xo,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Is,i=new Vt(40,1,0.01,1000),r=new Ch(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),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let h=new Vo(t),f=new Ph,m=h.fromScene(f,0.04);n.environment=m.texture,f.dispose(),h.dispose();let _=new zs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new bc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,z,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),k=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:ab(C.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(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(j.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.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 P=bl(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof Mt||ue instanceof pr||ue instanceof Ds){let Be=new Gt().setFromObject(ue,!0);if(!Be.isEmpty())j.push(Be)}});let{center:k,radius:q,distance:Q,position:Me}=sb(P,i.aspect,i.fov,j);if(r.target.copy(k),i.position.copy(Me),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()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let k=ob(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),M!==void 0)z=performance.now()-M,M=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 k=K(P);clearTimeout(C.timeout),C.resolve(k),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let k=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let Q=await rb(P);vl(Q,[Q.scene]);let Me=await lb(Q);try{Q.assertTexturesLoaded()}catch(xe){Ii(Q.scene);for(let Ee of io(Me))Ii(Ee);throw xe}let ue=cb(Q,()=>!x&&q===R&&j.isCurrent?.()!==!1,(xe)=>{Ii(xe.scene);for(let Ee of io(Me))Ii(Ee)});if(!ue)return;let Be=p&&j.preserveView?ff(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Ii(p);for(let xe of io(g))Ii(xe)}p=ue.scene,g=Me,M=k,z=void 0,n.add(p),T=ue.animations,S=new Ec(p),y=!0;let{clientWidth:we,clientHeight:Z}=e;if(t.setSize(we,Z),i.aspect=we&&Z?we/Z:i.aspect,I(),Be)pf(i,r.target,Be,bl(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let Ee=xe;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:xa(p),meshes:re,materials:se.size,clips:T.map((xe)=>xe.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)db(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)fb(g,P,j)},lod(){return p?pb(g,p):void 0},reset:I,cancelMeasurement:L,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,k)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:k,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return ff(i,r.target)},setView(P){if(!p)return;pf(i,r.target,P,bl(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,...io(g)]:[])j.traverse((k)=>{let q=k;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(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),p)Ii(p);for(let P of io(g))Ii(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var gb=["127.0.0.1","localhost","[::1]"];async function _b(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 d=new URL(s);if(d.protocol!=="https:"&&!(d.protocol==="http:"&&gb.includes(d.hostname)))throw Error("Invalid host download URL");return{downloadUrl:d.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 yb=16777216,vb=Math.ceil(yb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function QC(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function xb(e){if(typeof e!=="string"||e.length>vb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(QC(n)!==e)Yt("contains noncanonical base64 data");return n}function ya(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function bb(e){if(!ya(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=hf.safeParse(e.manifest);if(!t.success||!ya(e.files))return Yt("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 Yt("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 Yt("file metadata is missing");if(r+=n.files[c].bytes,r>yb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:ya(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>vb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],d;if(typeof l==="string")d=xb(l);else{if(!ya(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=xb(l.data);try{d=Ev(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(d.length!==u.bytes)return Yt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(d));if(`sha256:${Array.from(new Uint8Array(h),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=d}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!ya(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function Sb(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 Dn=(e)=>document.getElementById(e),Li=Dn("status"),ln,wb={},ns,eP=0,Ni=0,Sl=new Map;function Eb(e,t){let n=++eP;return new Promise((i,r)=>{let s=setTimeout(()=>{Sl.delete(n),r(Error("Chat host did not respond."))},20000);Sl.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 Mb(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function tP(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 nP(e){let t=++Ni;ln=void 0,Dn("stats").textContent="",Dn("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 iP(e,t)}catch(n){if(t!==Ni)return;Li.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function iP(e,t){if(e.isError){Li.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await bb(e._meta?.kilnAsset)}catch(i){if(t!==Ni)return;Li.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Ni)return;ln=n.record,Dn("name").textContent=ln.manifest.name,wb=n.downloadUrls,Dn("revision").textContent=`${ln.manifest.editable?"Editable source included":"GLB asset"} · ${ln.manifest.revisionId.slice(0,10)}`,Dn("attribution").textContent=Sb(ln.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{ns??=mb(Dn("stage"));let i=await ns.load(ln.files["asset.glb"]);if(t!==Ni)return;if(i){Dn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(ln.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Dn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Li.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Ni)return;ns?.dispose(),ns=void 0;let r=ln.files["preview.png"];if(r){let s=new Image;s.alt=`${ln.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${tP(r)}`,Dn("stage").replaceChildren(s)}Li.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Dn("source").hidden=!ln.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=Sl.get(t.id);if(Sl.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")nP(t.params);if(t.method==="ui/resource-teardown")ns?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Dn("reset").onclick=()=>ns?.reset();Dn("clips").onchange=(e)=>ns?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!ln)return;let t=Ni,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?ib([ln]):ln.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=ln.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Li.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await _b(r,`${o}-${i}`,s,Eb,a,wb[i]);if(t!==Ni)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})},Li.replaceChildren("Download ready. ",l)}else Li.textContent="Download requested."}catch(a){if(t===Ni)Li.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!ln||t!==Ni}};Eb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{Mb("ui/notifications/initialized"),Mb("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Li.textContent=e.message});
</script>
</body>
diff --git a/package.json b/package.json
index 7f770470..0a3568e7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@instruktlabs/kiln",
- "version": "1.3.0",
+ "version": "1.3.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 71f67a69..0c7dbad9 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.3.0",
+ "version": "1.3.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 a24d2f37..1e0b7f38 100644
--- a/plugins/kiln-engine.release.json
+++ b/plugins/kiln-engine.release.json
@@ -1,4 +1,4 @@
{
- "version": "1.3.0",
- "engineVersion": "1.3.0"
+ "version": "1.3.1",
+ "engineVersion": "1.3.1"
}
diff --git a/plugins/kiln-engine/.claude-plugin/plugin.json b/plugins/kiln-engine/.claude-plugin/plugin.json
index 452a75c9..e03c14df 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.3.0",
+ "version": "1.3.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 0414ca8c..9964e603 100644
--- a/plugins/kiln-engine/README.md
+++ b/plugins/kiln-engine/README.md
@@ -1,7 +1,7 @@
# Kiln local plugin
-Plugin version 1.3.0, maintained by Instrukt Labs under the MIT license.
-This plugin pins engine 1.3.0. Registry setup requires that exact version
+Plugin version 1.3.1, maintained by Instrukt Labs under the MIT license.
+This plugin pins engine 1.3.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 b6baf802..bc67be15 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.3.0",
- "engineVersion": "1.3.0",
+ "pluginVersion": "1.3.1",
+ "engineVersion": "1.3.1",
"executables": [
"bin/kiln-setup-workspace.mjs"
],
"files": {
".claude-plugin/icon.png": "sha256:b4b651c402793b7e27cab780f04b14f80daec6d0cd5b7e4e90313930581a54e9",
- ".claude-plugin/plugin.json": "sha256:9c397a68286473dc2c7cd593953c47da1ab26a8d59c86d91c7a3f4f0ab1d978f",
+ ".claude-plugin/plugin.json": "sha256:c81dbb9d7e09fff4ebff8e30d01561d545ba11a58680769e39d421d74fee6fc4",
"bin/kiln-setup-workspace.mjs": "sha256:3d9a30236919a6ca91acb6b26f808cec442e6edc3dd88fe010645b010d76e838",
"LICENSE": "sha256:cdba278ebf1d6de618869936226bf03be4887179c128efc7aaa13d22034826a5",
- "plugin.json": "sha256:425bcd358ed757c1a805bec8ae6f2cd2c57688d6e438e7f7a06b7e750df7805b",
+ "plugin.json": "sha256:1fcd55985e730a48a5ace0c8dfdbc832f81b4560f9a73dbbe4ae6b9896103cfd",
"PRIVACY.md": "sha256:5f58d981667e40441e21c2dec411f269a9a67a6141cec61976d27088fb12573b",
- "README.md": "sha256:d8be7621db5b864df5242f9dc3cd8ddbef51ebbada3afcfd7043840f9e8006f2",
- "runtime.json": "sha256:b6ed859e3a27c6275a740f11abdd53e0753228919574cca92a15453a870dfa1c",
+ "README.md": "sha256:f90af8133e327a2fe90cf99a7de94d8030a30d720b4ce25461a9104753417741",
+ "runtime.json": "sha256:90a3e66998cc7f360a02f6d6910adb178b53cd24909505b1d2e46c2771e02679",
"SECURITY.md": "sha256:8e238d3985deff828efd71bc3354a5b0275613a4921f369fc971f760ca249606",
"skills/kiln-setup-workspace/references/plugin-install.md": "sha256:c338fb792e7fad0364c3e1a13c94c506afa1395489ec1b6e83b36d04728935fb",
"skills/kiln-setup-workspace/references/renderer-setup.md": "sha256:b743b1b2827fa814385990e1e5b849391cb427413e9c016d273aa19cebd46031",
diff --git a/plugins/kiln-engine/plugin.json b/plugins/kiln-engine/plugin.json
index 0d38ca45..b5c946ab 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.3.0",
+ "version": "1.3.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 367d14ba..d2e25ac3 100644
--- a/plugins/kiln-engine/runtime.json
+++ b/plugins/kiln-engine/runtime.json
@@ -1,6 +1,6 @@
{
"name": "@instruktlabs/kiln",
- "version": "1.3.0",
+ "version": "1.3.1",
"harnesses": [
"claude",
"codex",
diff --git a/plugins/kiln-hosted/plugin.json b/plugins/kiln-hosted/plugin.json
index 9042f25c..5382ad73 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.3.0",
+ "version": "1.3.1",
"description": "Create, review and revise editable 3D assets, with private saved revisions and GLB downloads.",
"author": {
"name": "Instrukt Labs",
diff --git a/src/engine-identity.ts b/src/engine-identity.ts
index 6d8c2a45..0b44cb1a 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.3.0';
+export const ENGINE_VERSION = '1.3.1';
/**
* Where this engine was loaded from, as a `file://` URL of the package root.